00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "doctreeglobalconfigwidget.h"
00017
00018 #include <qcheckbox.h>
00019 #include <kconfig.h>
00020 #include <kprocess.h>
00021 #include <kurlrequester.h>
00022 #include <kdebug.h>
00023 #include <kdeversion.h>
00024 #include "../../config.h"
00025 #include "doctreeviewpart.h"
00026 #include "doctreeviewwidget.h"
00027 #include "doctreeviewfactory.h"
00028 #include "adddocitemdlg.h"
00029 #include "misc.h"
00030 #include "domutil.h"
00031 #include "urlutil.h"
00032 #include "librarydocdlg.h"
00033 #include <qfileinfo.h>
00034 #include <kapplication.h>
00035 #include <kstandarddirs.h>
00036 #include <kfiledialog.h>
00037 #include <kio/netaccess.h>
00038 #include <kmessagebox.h>
00039 #include <klineedit.h>
00040 #include <kurllabel.h>
00041
00042 DocTreeGlobalConfigWidget::DocTreeGlobalConfigWidget(DocTreeViewPart *part, DocTreeViewWidget *widget,
00043 QWidget *parent, const char *name)
00044 : DocTreeGlobalConfigWidgetBase(parent, name)
00045 {
00046 extEnableButton->hide();
00047 extDisableButton->hide();
00048 dhEnableButton->hide();
00049 dhDisableButton->hide();
00050 m_part = part;
00051 QDomDocument d;
00052 if(m_part->projectDom()) d = *m_part->projectDom();
00053 m_ignoreTocs = DomUtil::readListEntry(d, "/kdevdoctreeview/ignoretocs", "toc");
00054 m_ignoreDevHelp = DomUtil::readListEntry(d, "/kdevdoctreeview/ignoredevhelp", "toc");
00055 m_widget = widget;
00056 readConfig();
00057 if (!m_part->project())
00058 {
00059
00060 extEnableButton->setEnabled(false);
00061 extDisableButton->setEnabled(false);
00062 dhEnableButton->setEnabled(false);
00063 dhDisableButton->setEnabled(false);
00064 }
00065
00066 qtdocs_view->addColumn(i18n("Title"));
00067 qtdocs_view->addColumn(i18n("URL"));
00068 qtdocs_view->setAllColumnsShowFocus(true);
00069
00070 doxygen_view->addColumn(i18n("Title"));
00071 doxygen_view->addColumn(i18n("URL"));
00072 doxygen_view->setAllColumnsShowFocus(true);
00073
00074 kdoc_view->addColumn(i18n("Title"));
00075 kdoc_view->addColumn(i18n("URL"));
00076 kdoc_view->setAllColumnsShowFocus(true);
00077
00078 bListView->addColumn(i18n("Title"));
00079 bListView->addColumn(i18n("URL"));
00080 bListView->setAllColumnsShowFocus(true);
00081
00082 extListView->addColumn(i18n("Name"));
00083
00084 extListView->addColumn(i18n("Title"));
00085 extListView->addColumn(i18n("URL"));
00086 extListView->setAllColumnsShowFocus(true);
00087
00088 dhListView->addColumn(i18n("Name"));
00089
00090 dhListView->addColumn(i18n("Title"));
00091 dhListView->addColumn(i18n("URL"));
00092 dhListView->addColumn(i18n("Author"));
00093 dhListView->setAllColumnsShowFocus(true);
00094
00095 dhURL->setMode((int) KFile::Directory);
00096 databaseDirEdit->setMode((int) KFile::Directory);
00097
00098 urlDownload->setURL("http://lidn.sourceforge.net");
00099 connect(urlDownload, SIGNAL(leftClickedURL(const QString&)), kapp,
00100 SLOT(invokeBrowser(const QString&)));
00101
00102
00103
00104
00105
00106
00107
00108
00109 #if QT_VERSION >= 0x030200
00110 connect(extListView, SIGNAL( doubleClicked( QListViewItem *, const QPoint&, int ) ), this,
00111 SLOT( extEdit()));
00112 connect(bListView, SIGNAL( doubleClicked( QListViewItem *, const QPoint&, int ) ), this,
00113 SLOT( pushEdit_clicked()));
00114 connect(dhListView, SIGNAL( doubleClicked( QListViewItem *, const QPoint&, int ) ), this,
00115 SLOT( dhEditButton_clicked()));
00116 #else
00117 connect(extListView, SIGNAL( doubleClicked( QListViewItem * ) ), this,
00118 SLOT( extEdit()));
00119 connect(bListView, SIGNAL( doubleClicked( QListViewItem * ) ), this,
00120 SLOT( pushEdit_clicked()));
00121 connect(dhListView, SIGNAL( doubleClicked( QListViewItem * ) ), this,
00122 SLOT( dhEditButton_clicked()));
00123 #endif
00124
00125 }
00126
00127
00128 DocTreeGlobalConfigWidget::~DocTreeGlobalConfigWidget()
00129 {}
00130
00131
00132 void DocTreeGlobalConfigWidget::readConfig()
00133 {
00134 KConfig *config = DocTreeViewFactory::instance()->config();
00135
00136
00137 config->setGroup("General Qt");
00138 QMap<QString, QString> emap = config->entryMap("General Qt");
00139 QMap<QString, QString>::Iterator it;
00140 for (it = emap.begin(); it != emap.end(); ++it)
00141 {
00142 new KListViewItem(qtdocs_view, it.key(), config->readPathEntry(it.key()));
00143 }
00144 if (emap.empty())
00145 {
00146 KListViewItem *qtitem = new KListViewItem(qtdocs_view, "Qt Reference Documentation", QString(QT_DOCDIR) + QString("/qt.xml"));
00147 qtitem = new KListViewItem(qtdocs_view, "Qt Assistant Manual", QString(QT_DOCDIR) + QString("/assistant.xml"));
00148 qtitem = new KListViewItem(qtdocs_view, "Qt Designer Manual", QString(QT_DOCDIR) + QString("/designer.xml"));
00149 qtitem = new KListViewItem(qtdocs_view, "Guide to the Qt Translation Tools", QString(QT_DOCDIR) + QString("/linguist.xml"));
00150 qtitem = new KListViewItem(qtdocs_view, "qmake User Guide", QString(QT_DOCDIR) + QString("/qmake.xml"));
00151 }
00152
00153 config->setGroup("General Doxygen");
00154 QMap<QString, QString> xmap = config->entryMap("General Doxygen");
00155 QMap<QString, QString>::Iterator itx;
00156 for (itx = xmap.begin(); itx != xmap.end(); ++itx)
00157 {
00158 new KListViewItem(doxygen_view, itx.key(), config->readPathEntry(itx.key()));
00159 }
00160 if (xmap.empty() && (!QString(KDELIBS_DOXYDIR).isEmpty()))
00161 {
00162 new KListViewItem(doxygen_view, "KDE Libraries (Doxygen)", KDELIBS_DOXYDIR);
00163 }
00164
00165
00166 config->setGroup("General KDoc");
00167 QMap<QString, QString> dmap = config->entryMap("General KDoc");
00168 QMap<QString, QString>::Iterator itd;
00169 for (itd = dmap.begin(); itd != dmap.end(); ++itd)
00170 {
00171 new KListViewItem(kdoc_view, itd.key(), config->readPathEntry(itd.key()));
00172 }
00173 if (dmap.empty() && (!QString(KDELIBS_DOCDIR).isEmpty()))
00174 {
00175 new KListViewItem(kdoc_view, "KDE Libraries (KDoc)", KDELIBS_DOCDIR);
00176 }
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 config->setGroup("Index");
00187 indexKDevelopBox->setChecked(config->readBoolEntry("IndexKDevelop"));
00188 indexQtBox->setChecked(config->readBoolEntry("IndexQt"));
00189 indexKdelibsBox->setChecked(config->readBoolEntry("IndexKdelibs"));
00190 indexBooksBox->setChecked(config->readBoolEntry("IndexBooks"));
00191 indexBookmarksBox->setChecked(config->readBoolEntry("IndexBookmarks"));
00192
00193 config->setGroup("htdig");
00194 QString databaseDir = kapp->dirs()->saveLocation("data", "kdevdoctreeview/helpindex");
00195 databaseDirEdit->setURL( config->readPathEntry( "databaseDir", databaseDir ));
00196 QString exe = kapp->dirs()->findExe("htdig");
00197 htdigbinEdit->setURL(config->readPathEntry("htdigbin", exe));
00198 exe = kapp->dirs()->findExe("htmerge");
00199 htmergebinEdit->setURL(config->readPathEntry("htmergebin", exe));
00200 exe = kapp->dirs()->findExe("htsearch");
00201 htsearchbinEdit->setURL(config->readPathEntry("htsearchbin", exe));
00202
00203
00204 QStringList bookmarksTitle, bookmarksURL;
00205 DocTreeViewTool::getBookmarks(&bookmarksTitle, &bookmarksURL);
00206 QStringList::Iterator oit1, oit2;
00207 for (oit1 = bookmarksTitle.begin(), oit2 = bookmarksURL.begin();
00208 oit1 != bookmarksTitle.end() && oit2 != bookmarksURL.end();
00209 ++oit1, ++oit2) {
00210 new KListViewItem( bListView, *oit1, *oit2);
00211 }
00212
00213 config->setGroup("DevHelp");
00214 dhURL->setURL(config->readPathEntry("DevHelpDir"));
00215
00216 readTocConfigs();
00217 DocTreeViewTool::scanDevHelpDirs();
00218 readDevHelpConfig();
00219 }
00220
00221 void DocTreeGlobalConfigWidget::readTocConfigs()
00222 {
00223 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs();
00224 QStringList tocs = dirs->findAllResources("doctocs", QString::null, false, true);
00225 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit)
00226 {
00227 const QString name( QFileInfo(*tit).baseName() );
00228 const QString location( DocTreeViewTool::tocLocation( *tit ) );
00229 const QString title (DocTreeViewTool::tocTitle( *tit ));
00230 new KListViewItem( extListView, name, title, location);
00231
00232
00233
00234
00235 }
00236 }
00237
00238 void DocTreeGlobalConfigWidget::storeConfig()
00239 {
00240 KConfig *config = DocTreeViewFactory::instance()->config();
00241
00242 config->deleteGroup("General Qt");
00243 config->setGroup("General Qt");
00244 QListViewItemIterator it( qtdocs_view );
00245 while ( it.current() )
00246 {
00247 config->writePathEntry(it.current()->text(0), it.current()->text(1));
00248 ++it;
00249 }
00250
00251 config->deleteGroup("General Doxygen");
00252 config->setGroup("General Doxygen");
00253 QListViewItemIterator itx( doxygen_view );
00254 while ( itx.current() )
00255 {
00256 config->writePathEntry(itx.current()->text(0), itx.current()->text(1));
00257 ++itx;
00258 }
00259
00260 config->deleteGroup("General KDoc");
00261 config->setGroup("General KDoc");
00262 QListViewItemIterator itd( kdoc_view );
00263 while ( itd.current() )
00264 {
00265 config->writePathEntry(itd.current()->text(0), itd.current()->text(1));
00266 ++itd;
00267 }
00268
00269
00270
00271
00272
00273 config->setGroup("Index");
00274 config->writeEntry("IndexKDevelop", indexKDevelopBox->isChecked());
00275 config->writeEntry("IndexQt", indexQtBox->isChecked());
00276 config->writeEntry("IndexKdelibs", indexKdelibsBox->isChecked());
00277 config->writeEntry("IndexBooks", indexBooksBox->isChecked());
00278 config->writeEntry("IndexBookmarks", indexBookmarksBox->isChecked());
00279
00280 config->setGroup("htdig");
00281 #if defined(KDE_IS_VERSION)
00282 # if KDE_IS_VERSION(3,1,3)
00283 # ifndef _KDE_3_1_3_
00284 # define _KDE_3_1_3_
00285 # endif
00286 # endif
00287 #endif
00288
00289 #if defined(_KDE_3_1_3_)
00290 config->writePathEntry("databaseDir", databaseDirEdit->url());
00291 config->writePathEntry("htdigbin", htdigbinEdit->url());
00292 config->writePathEntry("htmergebin", htmergebinEdit->url());
00293 config->writePathEntry("htsearchbin", htsearchbinEdit->url());
00294 #else
00295 config->writeEntry("databaseDir", databaseDirEdit->url());
00296 config->writeEntry("htdigbin", htdigbinEdit->url());
00297 config->writeEntry("htmergebin", htmergebinEdit->url());
00298 config->writeEntry("htsearchbin", htsearchbinEdit->url());
00299 #endif
00300
00301 QStringList bookmarksTitle, bookmarksURL;
00302 {
00303 QListViewItem *item = bListView->firstChild();
00304 for (; item; item = item->nextSibling()) {
00305 bookmarksTitle.append(item->text(0));
00306 bookmarksURL.append(item->text(1));
00307 }
00308 }
00309 DocTreeViewTool::setBookmarks(bookmarksTitle, bookmarksURL);
00310
00311 if (!dhURL->url().isEmpty())
00312 {
00313 config->setGroup("DevHelp");
00314 #if defined(_KDE_3_1_3_)
00315 config->writePathEntry("DevHelpDir", dhURL->url());
00316 #else
00317 config->writeEntry("DevHelpDir", dhURL->url());
00318 #endif
00319 }
00320 config->sync();
00321 }
00322
00323 void DocTreeGlobalConfigWidget::updateConfigClicked()
00324 {
00325 runHtdig( "-c" );
00326 }
00327
00328 void DocTreeGlobalConfigWidget::updateIndexClicked()
00329 {
00330 runHtdig( "-i" );
00331 }
00332
00333 void DocTreeGlobalConfigWidget::runHtdig( QString arg )
00334 {
00335
00336
00337 storeConfig();
00338
00339 DocTreeViewFactory::instance()->config()->sync();
00340 KProcess proc;
00341 proc << "kdevelop-htdig" << arg;
00342 proc.start(KProcess::DontCare);
00343 }
00344
00345 void DocTreeGlobalConfigWidget::addBookmarkClicked()
00346 {
00347 AddDocItemDialog dlg(KFile::File, "all/allfiles");
00348 if (!dlg.exec())
00349 return;
00350
00351 (void) new KListViewItem(bListView, dlg.title(), dlg.url());
00352
00353 }
00354
00355 void DocTreeGlobalConfigWidget::removeBookmarkClicked()
00356 {
00357 QListViewItem* item = bListView->currentItem();
00358 if (item) {
00359 bListView->removeItem(item);
00360 }
00361 }
00362
00363 void DocTreeGlobalConfigWidget::accept()
00364 {
00365 storeConfig();
00366 m_widget->configurationChanged();
00367 }
00368
00369 void DocTreeGlobalConfigWidget::extEdit()
00370 {
00371 QListViewItem *item = extListView->currentItem();
00372 if( item )
00373 {
00374 const QString name( item->text(0) );
00375 const QString location( item->text(2) );
00376 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs();
00377 QStringList tocs = dirs->findAllResources("doctocs", QString::null, false, true);
00378 QString filePath;
00379 for( QStringList::Iterator it = tocs.begin(); it!=tocs.end(); ++it)
00380 {
00381 if(QFileInfo(*it).baseName() == name)
00382 filePath = *it;
00383 }
00384 const QString _default( DocTreeViewTool::tocDocDefaultLocation( filePath ) );
00385 LibraryDocDlg *dlg = new LibraryDocDlg( this, name.latin1(), location, _default, "TocDirs");
00386 dlg->libName->setEnabled(false);
00387 dlg->libSource->setEnabled(false);
00388 dlg->exec();
00389
00390 delete dlg;
00391 }
00392 extListView->clear();
00393 readTocConfigs();
00394 }
00395
00396 void DocTreeGlobalConfigWidget::extEnable()
00397 {
00398
00399
00400
00401
00402
00403
00404
00405 }
00406
00407 void DocTreeGlobalConfigWidget::extDisable()
00408 {
00409
00410
00411
00412
00413
00414
00415
00416
00417 }
00418
00419
00420 void DocTreeGlobalConfigWidget::doxygenadd_button_clicked( )
00421 {
00422 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, "");
00423 if (dialog->exec())
00424 {
00425 QString url = dialog->url();
00426 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1);
00427 new KListViewItem(doxygen_view, dialog->title(), url);
00428 }
00429 delete dialog;
00430 }
00431
00432 void DocTreeGlobalConfigWidget::doxygenedit_button_clicked( )
00433 {
00434 if (doxygen_view->currentItem())
00435 {
00436 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, "", AddDocItemDialog::None,
00437 doxygen_view->currentItem()->text(0), doxygen_view->currentItem()->text(1));
00438 if (dialog->exec())
00439 {
00440 QString url = dialog->url();
00441 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1);
00442 doxygen_view->currentItem()->setText(0, dialog->title());
00443 doxygen_view->currentItem()->setText(1, url);
00444 }
00445 delete dialog;
00446 }
00447 }
00448
00449 void DocTreeGlobalConfigWidget::doxygenremove_button_clicked( )
00450 {
00451 if (doxygen_view->currentItem())
00452 delete doxygen_view->currentItem();
00453 }
00454
00455 void DocTreeGlobalConfigWidget::qtdocsadd_button_clicked( )
00456 {
00457 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.xml *.dcf", AddDocItemDialog::Qt);
00458 if (dialog->exec())
00459 new KListViewItem(qtdocs_view, dialog->title(), dialog->url());
00460 delete dialog;
00461 }
00462
00463 void DocTreeGlobalConfigWidget::qtdocsedit_button_clicked( )
00464 {
00465 if (qtdocs_view->currentItem())
00466 {
00467 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.xml *.dcf", AddDocItemDialog::Qt,
00468 qtdocs_view->currentItem()->text(0), qtdocs_view->currentItem()->text(1));
00469 if (dialog->exec())
00470 {
00471 qtdocs_view->currentItem()->setText(0, dialog->title());
00472 qtdocs_view->currentItem()->setText(1, dialog->url());
00473 }
00474 delete dialog;
00475 }
00476 }
00477
00478 void DocTreeGlobalConfigWidget::qtdocsremove_button_clicked( )
00479 {
00480 if (qtdocs_view->currentItem())
00481 delete qtdocs_view->currentItem();
00482 }
00483
00484 void DocTreeGlobalConfigWidget::kdocadd_button_clicked( )
00485 {
00486 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, "");
00487 if (dialog->exec())
00488 {
00489 QString url = dialog->url();
00490 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1);
00491 new KListViewItem(kdoc_view, dialog->title(), url);
00492 }
00493 delete dialog;
00494 }
00495
00496 void DocTreeGlobalConfigWidget::kdocedit_button_clicked( )
00497 {
00498 if (kdoc_view->currentItem())
00499 {
00500 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, "", AddDocItemDialog::None,
00501 kdoc_view->currentItem()->text(0), kdoc_view->currentItem()->text(1));
00502 if (dialog->exec())
00503 {
00504 QString url = dialog->url();
00505 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1);
00506 kdoc_view->currentItem()->setText(0, dialog->title());
00507 kdoc_view->currentItem()->setText(1, url);
00508 }
00509 delete dialog;
00510 }
00511 }
00512
00513 void DocTreeGlobalConfigWidget::kdocremove_button_clicked( )
00514 {
00515 if (kdoc_view->currentItem())
00516 delete kdoc_view->currentItem();
00517 }
00518
00519 void DocTreeGlobalConfigWidget::pushEdit_clicked()
00520 {
00521 if (bListView->currentItem())
00522 {
00523 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "text/html", AddDocItemDialog::None,
00524 bListView->currentItem()->text(0), bListView->currentItem()->text(1));
00525 if (dialog->exec())
00526 {
00527 bListView->currentItem()->setText(0, dialog->title());
00528 bListView->currentItem()->setText(1, dialog->url());
00529 }
00530 delete dialog;
00531 }
00532 }
00533
00534 void DocTreeGlobalConfigWidget::extAddButton_clicked( )
00535 {
00536 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.toc", AddDocItemDialog::KDevelopTOC);
00537 if (dialog->exec())
00538 {
00539 KListViewItem *item = new KListViewItem(extListView);
00540 dhListView->setCurrentItem(item);
00541
00542 QFileInfo fi(dialog->url());
00543 dhListView->currentItem()->setText(0, fi.baseName());
00544
00545
00546
00547 QString localURL = DocTreeViewFactory::instance()->dirs()->saveLocation("doctocs") + fi.baseName() + ".toc";
00548 KURL src;
00549 src.setPath(dialog->url());
00550 KURL dest;
00551 dest.setPath(localURL);
00552 KIO::NetAccess::copy(src, dest);
00553
00554 dhListView->currentItem()->setText(2, DocTreeViewTool::tocLocation( localURL ));
00555 dhListView->currentItem()->setText(1, DocTreeViewTool::tocTitle( localURL ));
00556 }
00557 delete dialog;
00558 }
00559
00560 void DocTreeGlobalConfigWidget::extRemoveButton_clicked( )
00561 {
00562 if (extListView->currentItem())
00563 {
00564 KURL url;
00565 url.setPath(DocTreeViewFactory::instance()->dirs()->findResource("doctocs",
00566 extListView->currentItem()->text(0) + QString(".toc")));
00567 if (! KIO::NetAccess::del(url))
00568 KMessageBox::error(this, i18n("Could not remove documentation TOC.\nIt may be a part of system-wide KDevelop documentation."));
00569 else
00570 delete extListView->currentItem();
00571 }
00572 }
00573
00574 void DocTreeGlobalConfigWidget::dhAddButton_clicked( )
00575 {
00576 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.devhelp", AddDocItemDialog::DevHelp);
00577 if (dialog->exec())
00578 {
00579 KListViewItem *item = new KListViewItem(dhListView);
00580 dhListView->setCurrentItem(item);
00581
00582 QFileInfo fi(dialog->url());
00583
00584 BookInfo inf = DocTreeViewTool::devhelpInfo(dialog->url());
00585 dhListView->currentItem()->setText(0, fi.baseName(false));
00586
00587 dhListView->currentItem()->setText(1, inf.title);
00588 if (!inf.defaultLocation.isEmpty())
00589 dhListView->currentItem()->setText(2, inf.defaultLocation);
00590 else
00591 dhListView->currentItem()->setText(2, URLUtil::directory(fi.absFilePath()));
00592 dhListView->currentItem()->setText(3, inf.author);
00593
00594
00595 QString localURL = DocTreeViewFactory::instance()->dirs()->saveLocation("docdevhelp") + fi.baseName() + ".devhelp";
00596 KURL src;
00597 src.setPath(dialog->url());
00598 KURL dest;
00599 dest.setPath(localURL);
00600 KIO::NetAccess::copy(src, dest);
00601 }
00602 delete dialog;
00603 }
00604
00605 void DocTreeGlobalConfigWidget::dhDisableButton_clicked( )
00606 {
00607
00608
00609
00610
00611
00612
00613
00614 }
00615
00616 void DocTreeGlobalConfigWidget::dhEditButton_clicked( )
00617 {
00618 QListViewItem *item = dhListView->currentItem();
00619 if( item )
00620 {
00621 const QString name( item->text(0) );
00622 const QString location( item->text(2) );
00623 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs();
00624 QStringList tocs = dirs->findAllResources("docdevhelp", QString::null, false, true);
00625 QString filePath;
00626 for( QStringList::Iterator it = tocs.begin(); it!=tocs.end(); ++it)
00627 {
00628 if(QFileInfo(*it).baseName() == name)
00629 filePath = *it;
00630 }
00631 const QString _default( DocTreeViewTool::devhelpInfo(filePath).defaultLocation );
00632 LibraryDocDlg *dlg = new LibraryDocDlg( this, name.latin1(), location, _default, "TocDevHelp");
00633 dlg->libName->setEnabled(false);
00634 dlg->libSource->setEnabled(false);
00635 dlg->exec();
00636
00637 delete dlg;
00638 }
00639 dhListView->clear();
00640 readDevHelpConfig();
00641 }
00642
00643 void DocTreeGlobalConfigWidget::dhEnableButton_clicked( )
00644 {
00645
00646
00647
00648
00649
00650
00651
00652 }
00653
00654 void DocTreeGlobalConfigWidget::dhRemoveButton_clicked( )
00655 {
00656 if (dhListView->currentItem())
00657 {
00658 KURL url;
00659 url.setPath(DocTreeViewFactory::instance()->dirs()->findResource("docdevhelp",
00660 dhListView->currentItem()->text(0) + QString(".devhelp")));
00661 if (! KIO::NetAccess::del(url))
00662 KMessageBox::error(this, i18n("Could not remove documentation TOC.\nIt may be a part of system-wide KDevelop documentation."));
00663 else
00664 {
00665 KConfig *config = DocTreeViewFactory::instance()->config();
00666 config->setGroup("TocDevHelp");
00667 config->deleteEntry(dhListView->currentItem()->text(0));
00668 delete dhListView->currentItem();
00669 }
00670 }
00671 }
00672
00673 void DocTreeGlobalConfigWidget::dhScanButton_clicked( )
00674 {
00675 dhListView->clear();
00676 DocTreeViewTool::scanDevHelpDirs(dhURL->url());
00677 readDevHelpConfig();
00678 }
00679
00680 void DocTreeGlobalConfigWidget::readDevHelpConfig()
00681 {
00682 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs();
00683
00684 QStringList tocs = dirs->findAllResources("docdevhelp", QString::null, false, true);
00685 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit)
00686 {
00687 KListViewItem *item = 0;
00688
00689 QFileInfo fi(*tit);
00690
00691 BookInfo inf = DocTreeViewTool::devhelpInfo(*tit);
00692
00693
00694
00695
00696 item = new KListViewItem(dhListView);
00697 item->setText(0, fi.baseName(false));
00698 item->setText(1, inf.title);
00699 item->setText(2, DocTreeViewTool::devhelpLocation(fi.baseName() , inf.defaultLocation));
00700 item->setText(3, inf.author);
00701 }
00702 }
00703
00704 #include "doctreeglobalconfigwidget.moc"