00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "doctreeviewpart.h"
00013
00014 #include <qpopupmenu.h>
00015 #include <qvbox.h>
00016 #include <qwhatsthis.h>
00017
00018 #include <kapplication.h>
00019 #include <kdebug.h>
00020 #include <kdialogbase.h>
00021 #include <kiconloader.h>
00022 #include <kinputdialog.h>
00023 #include <klocale.h>
00024 #include <kstandarddirs.h>
00025 #include <kstringhandler.h>
00026 #include <kaction.h>
00027 #include <configwidgetproxy.h>
00028
00029 #include "kdevcore.h"
00030 #include "misc.h"
00031 #include "kdevproject.h"
00032 #include "kdevmainwindow.h"
00033 #include "kdevpartcontroller.h"
00034
00035 #include "docsearchdlg.h"
00036 #include "docindexdlg.h"
00037 #include "doctreeviewfactory.h"
00038 #include "doctreeviewwidget.h"
00039 #include "doctreeglobalconfigwidget.h"
00040 #include "doctreeprojectconfigwidget.h"
00041
00042 #define GLOBALDOC_OPTIONS 1
00043 #define PROJECTDOC_OPTIONS 2
00044
00045 DocTreeViewPart::DocTreeViewPart( QObject *parent, const char *name, const QStringList & )
00046 : KDevPlugin("DocTree", "doctree", parent, name ? name : "DocTreeViewPart")
00047 {
00048 setInstance(DocTreeViewFactory::instance());
00049
00050 setXMLFile("kdevdoctreeview.rc");
00051
00052 connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) );
00053 connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) );
00054
00055
00056 connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)),
00057 this, SLOT(contextMenu(QPopupMenu *, const Context *)) );
00058
00059 _configProxy = new ConfigWidgetProxy( core() );
00060 _configProxy->createGlobalConfigPage( i18n("Documentation Tree"), GLOBALDOC_OPTIONS );
00061 _configProxy->createProjectConfigPage( i18n("Project Documentation"), PROJECTDOC_OPTIONS );
00062 connect( _configProxy, SIGNAL(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )), this, SLOT(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )) );
00063
00064 m_widget = new DocTreeViewWidget(this);
00065 m_widget->setIcon(SmallIcon("contents"));
00066 m_widget->setCaption(i18n("Documentation Tree"));
00067 QWhatsThis::add(m_widget, i18n("<b>Documentation tree</b><p>"
00068 "The documentation tree gives access to various "
00069 "documentation sources (Qt DCF, Doxygen, KDoc, KDevelopTOC and DevHelp "
00070 "documentation) and the KDevelop manuals. It also provides documentation index."));
00071
00072 mainWindow()->embedSelectViewRight(m_widget, i18n("Documentation"), i18n("Documentation browser"));
00073
00074 KAction *action;
00075
00076 action = new KAction( i18n("Full Text &Search..."), 0,
00077 this, SLOT(slotSearchDocumentation()),
00078 actionCollection(), "help_fulltextsearch" );
00079 action->setToolTip( i18n("Full text search in the documentation") );
00080 action->setWhatsThis( i18n("<b>Full text search</b><p>"
00081 "Opens the Search in documentation dialog. It allows "
00082 "a search term to be entered which will be searched for in "
00083 "the documentation. For this to work, a "
00084 "full text index must be created first, which can be done in the "
00085 "configuration dialog of the documentation tree.") );
00086
00087 action = new KAction( i18n("Man Page..."), 0,
00088 this, SLOT(slotManpage()),
00089 actionCollection(), "help_manpage" );
00090 action->setToolTip( i18n("Show a manpage") );
00091 action->setWhatsThis(i18n("<b>Show a manpage</b><p>Opens a man page using embedded viewer."));
00092 }
00093
00094
00095 DocTreeViewPart::~DocTreeViewPart()
00096 {
00097 if ( m_widget )
00098 mainWindow()->removeView( m_widget );
00099 delete (DocTreeViewWidget*) m_widget;
00100 }
00101
00102
00103 void DocTreeViewPart::projectOpened()
00104 {
00105 m_widget->projectChanged(project());
00106 }
00107
00108
00109 void DocTreeViewPart::projectClosed()
00110 {
00111 m_widget->projectChanged(0);
00112 }
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 void DocTreeViewPart::contextMenu(QPopupMenu *, const Context *)
00139 {
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 }
00177
00178 void DocTreeViewPart::slotSearchDocumentation()
00179 {
00180 kdDebug(9002) << "Full text search requested" << endl;
00181 DocSearchDialog dlg(m_widget, "doc search dialog");
00182 if (dlg.exec()) {
00183 QString indexdir = kapp->dirs()->saveLocation("data", "kdevdoctreeview/helpindex");
00184 partController()->showDocument(KURL("file://" + indexdir + "/results.html"));
00185 }
00186 }
00187
00188 void DocTreeViewPart::slotManpage()
00189 {
00190 bool ok;
00191 QString manpage = KInputDialog::getText(i18n("Show Manpage"), i18n("Show manpage on:"), "", &ok, 0);
00192 if (ok && !manpage.isEmpty()) {
00193 QString url = QString::fromLatin1("man:/%1").arg(manpage);
00194 partController()->showDocument(KURL(url));
00195 }
00196 }
00197
00198 void DocTreeViewPart::slotRaiseWidget()
00199 {
00200 mainWindow()->raiseView(m_widget);
00201 }
00202
00203
00204 void DocTreeViewPart::slotContextGotoManpage()
00205 {
00206 QString url = QString::fromLatin1("man:/%1").arg(m_popupstr);
00207 partController()->showDocument(KURL(url));
00208 }
00209
00210 void DocTreeViewPart::slotContextFulltextSearch()
00211 {
00212 DocSearchDialog dlg(m_widget, "doc search dialog");
00213 dlg.setSearchTerm(m_popupstr);
00214 if (dlg.performSearch()) {
00215 QString indexdir = kapp->dirs()->saveLocation("data", "kdevdoctreeview/helpindex");
00216 partController()->showDocument(KURL("file://" + indexdir + "/results.html") );
00217 }
00218 }
00219
00220 void DocTreeViewPart::insertConfigWidget( const KDialogBase * dlg, QWidget * page, unsigned int pagenumber )
00221 {
00222 switch ( pagenumber )
00223 {
00224 case GLOBALDOC_OPTIONS:
00225 {
00226 DocTreeGlobalConfigWidget *w1 = new DocTreeGlobalConfigWidget( this, m_widget, page, "doc tree config widget");
00227 connect( dlg, SIGNAL(okClicked()), w1, SLOT(accept()) );
00228
00229 break;
00230 }
00231 case PROJECTDOC_OPTIONS:
00232 {
00233 DocTreeProjectConfigWidget *w1 = new DocTreeProjectConfigWidget(m_widget, page, project(), "doc tree project config");
00234 connect( dlg, SIGNAL(okClicked()), w1, SLOT(accept()) );
00235
00236 break;
00237 }
00238 }
00239 }
00240
00241 #include "doctreeviewpart.moc"