KDevelop API Documentation

parts/doctreeview/doctreeglobalconfigwidget.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2002 by Bernd Gehrmann * 00003 * bernd@kdevelop.org * 00004 * Copyright (C) 2002 by Sebastian Kratzert * 00005 * skratzert@gmx.de * 00006 * Copyright (C) 2003 by Alexander Dymo * 00007 * cloudtemple@mksat.net * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 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 // extEditButton->setEnabled(false); 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 // extListView->addColumn(i18n("Enabled")); 00084 extListView->addColumn(i18n("Title")); 00085 extListView->addColumn(i18n("URL")); 00086 extListView->setAllColumnsShowFocus(true); 00087 00088 dhListView->addColumn(i18n("Name")); 00089 // dhListView->addColumn(i18n("Enabled")); 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 00097 urlDownload->setURL("http://lidn.sourceforge.net"); 00098 connect(urlDownload, SIGNAL(leftClickedURL(const QString&)), kapp, 00099 SLOT(invokeBrowser(const QString&))); 00100 /* 00101 connect(extListView, SIGNAL(executed( QListViewItem *)), this, 00102 SLOT( extEdit())); 00103 connect(bListView, SIGNAL(executed( QListViewItem *)), this, 00104 SLOT( pushEdit_clicked())); 00105 connect(dhListView, SIGNAL(executed( QListViewItem *)), this, 00106 SLOT( dhEditButton_clicked())); 00107 */ 00108 #if QT_VERSION >= 0x030200 00109 connect(extListView, SIGNAL( doubleClicked( QListViewItem *, const QPoint&, int ) ), this, 00110 SLOT( extEdit())); 00111 connect(bListView, SIGNAL( doubleClicked( QListViewItem *, const QPoint&, int ) ), this, 00112 SLOT( pushEdit_clicked())); 00113 connect(dhListView, SIGNAL( doubleClicked( QListViewItem *, const QPoint&, int ) ), this, 00114 SLOT( dhEditButton_clicked())); 00115 #else 00116 connect(extListView, SIGNAL( doubleClicked( QListViewItem * ) ), this, 00117 SLOT( extEdit())); 00118 connect(bListView, SIGNAL( doubleClicked( QListViewItem * ) ), this, 00119 SLOT( pushEdit_clicked())); 00120 connect(dhListView, SIGNAL( doubleClicked( QListViewItem * ) ), this, 00121 SLOT( dhEditButton_clicked())); 00122 #endif 00123 00124 } 00125 00126 00127 DocTreeGlobalConfigWidget::~DocTreeGlobalConfigWidget() 00128 {} 00129 00130 00131 void DocTreeGlobalConfigWidget::readConfig() 00132 { 00133 KConfig *config = DocTreeViewFactory::instance()->config(); 00134 00135 //qt *.xml documentation files 00136 config->setGroup("General Qt"); 00137 QMap<QString, QString> emap = config->entryMap("General Qt"); 00138 QMap<QString, QString>::Iterator it; 00139 for (it = emap.begin(); it != emap.end(); ++it) 00140 { 00141 /*UNUSED! KListViewItem *qtitem = */ new KListViewItem(qtdocs_view, it.key(), config->readPathEntry(it.key())); 00142 } 00143 if (emap.empty()) 00144 { 00145 KListViewItem *qtitem = new KListViewItem(qtdocs_view, "Qt Reference Documentation", QString(QT_DOCDIR) + QString("/qt.xml")); 00146 qtitem = new KListViewItem(qtdocs_view, "Qt Assistant Manual", QString(QT_DOCDIR) + QString("/assistant.xml")); 00147 qtitem = new KListViewItem(qtdocs_view, "Qt Designer Manual", QString(QT_DOCDIR) + QString("/designer.xml")); 00148 qtitem = new KListViewItem(qtdocs_view, "Guide to the Qt Translation Tools", QString(QT_DOCDIR) + QString("/linguist.xml")); 00149 qtitem = new KListViewItem(qtdocs_view, "qmake User Guide", QString(QT_DOCDIR) + QString("/qmake.xml")); 00150 } 00151 00152 config->setGroup("General Doxygen"); 00153 QMap<QString, QString> xmap = config->entryMap("General Doxygen"); 00154 QMap<QString, QString>::Iterator itx; 00155 for (itx = xmap.begin(); itx != xmap.end(); ++itx) 00156 { 00157 /*UNUSED! KListViewItem *qtitem = */ new KListViewItem(doxygen_view, itx.key(), config->readPathEntry(itx.key())); 00158 } 00159 if (xmap.empty() && (!QString(KDELIBS_DOXYDIR).isEmpty())) 00160 { 00161 /*UNUSED! KListViewItem *qtitem = */ new KListViewItem(doxygen_view, "KDE Libraries (Doxygen)", KDELIBS_DOXYDIR); 00162 } 00163 00164 00165 config->setGroup("General KDoc"); 00166 QMap<QString, QString> dmap = config->entryMap("General KDoc"); 00167 QMap<QString, QString>::Iterator itd; 00168 for (itd = dmap.begin(); itd != dmap.end(); ++itd) 00169 { 00170 /*UNUSED! KListViewItem *qtitem = */ new KListViewItem(kdoc_view, itd.key(), config->readPathEntry(itd.key())); 00171 } 00172 if (dmap.empty() && (!QString(KDELIBS_DOCDIR).isEmpty())) 00173 { 00174 /*UNUSED! KListViewItem *qtitem = */ new KListViewItem(kdoc_view, "KDE Libraries (KDoc)", KDELIBS_DOCDIR); 00175 } 00176 00177 /* qtdocdirEdit->setURL(config->readPathEntry("qtdocdir", QT_DOCDIR)); 00178 qtdocdirEdit->fileDialog()->setMode( KFile::Directory ); 00179 kdelibsdoxydirEdit->setURL(config->readPathEntry("kdelibsdocdir", KDELIBS_DOXYDIR)); 00180 kdelibsdoxydirEdit->fileDialog()->setMode( KFile::Directory ); 00181 */ 00182 /* config->setGroup("General"); 00183 kdocCheck->setChecked( config->readBoolEntry("displayKDELibsKDoc", false) ); 00184 */ 00185 config->setGroup("Index"); 00186 indexKDevelopBox->setChecked(config->readBoolEntry("IndexKDevelop")); 00187 indexQtBox->setChecked(config->readBoolEntry("IndexQt")); 00188 indexKdelibsBox->setChecked(config->readBoolEntry("IndexKdelibs")); 00189 indexBooksBox->setChecked(config->readBoolEntry("IndexBooks")); 00190 indexBookmarksBox->setChecked(config->readBoolEntry("IndexBookmarks")); 00191 00192 config->setGroup("htdig"); 00193 QString exe = kapp->dirs()->findExe("htdig"); 00194 htdigbinEdit->setURL(config->readPathEntry("htdigbin", exe)); 00195 exe = kapp->dirs()->findExe("htmerge"); 00196 htmergebinEdit->setURL(config->readPathEntry("htmergebin", exe)); 00197 exe = kapp->dirs()->findExe("htsearch"); 00198 htsearchbinEdit->setURL(config->readPathEntry("htsearchbin", exe)); 00199 00200 //get bookmarks 00201 QStringList bookmarksTitle, bookmarksURL; 00202 DocTreeViewTool::getBookmarks(&bookmarksTitle, &bookmarksURL); 00203 QStringList::Iterator oit1, oit2; 00204 for (oit1 = bookmarksTitle.begin(), oit2 = bookmarksURL.begin(); 00205 oit1 != bookmarksTitle.end() && oit2 != bookmarksURL.end(); 00206 ++oit1, ++oit2) { 00207 new KListViewItem( bListView, *oit1, *oit2); 00208 } 00209 00210 config->setGroup("DevHelp"); 00211 dhURL->setURL(config->readPathEntry("DevHelpDir")); 00212 00213 readTocConfigs(); 00214 DocTreeViewTool::scanDevHelpDirs(); 00215 readDevHelpConfig(); 00216 } 00217 00218 void DocTreeGlobalConfigWidget::readTocConfigs() 00219 { 00220 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs(); 00221 QStringList tocs = dirs->findAllResources("doctocs", QString::null, false, true); 00222 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit) 00223 { 00224 const QString name( QFileInfo(*tit).baseName() ); 00225 const QString location( DocTreeViewTool::tocLocation( *tit ) ); 00226 const QString title (DocTreeViewTool::tocTitle( *tit )); 00227 new KListViewItem( extListView, name, title, location); 00228 /* if( m_ignoreTocs.contains( name ) ) 00229 new KListViewItem( extListView, name, "false", title, location); 00230 else 00231 new KListViewItem( extListView, name, "true", title, location);*/ 00232 } 00233 } 00234 00235 void DocTreeGlobalConfigWidget::storeConfig() 00236 { 00237 KConfig *config = DocTreeViewFactory::instance()->config(); 00238 00239 config->deleteGroup("General Qt"); 00240 config->setGroup("General Qt"); 00241 QListViewItemIterator it( qtdocs_view ); 00242 while ( it.current() ) 00243 { 00244 config->writePathEntry(it.current()->text(0), it.current()->text(1)); 00245 ++it; 00246 } 00247 00248 config->deleteGroup("General Doxygen"); 00249 config->setGroup("General Doxygen"); 00250 QListViewItemIterator itx( doxygen_view ); 00251 while ( itx.current() ) 00252 { 00253 config->writePathEntry(itx.current()->text(0), itx.current()->text(1)); 00254 ++itx; 00255 } 00256 00257 config->deleteGroup("General KDoc"); 00258 config->setGroup("General KDoc"); 00259 QListViewItemIterator itd( kdoc_view ); 00260 while ( itd.current() ) 00261 { 00262 config->writePathEntry(itd.current()->text(0), itd.current()->text(1)); 00263 ++itd; 00264 } 00265 00266 00267 /* config->setGroup("General"); 00268 config->writeEntry("displayKDELibsKDoc", kdocCheck->isChecked() ); 00269 */ 00270 config->setGroup("Index"); 00271 config->writeEntry("IndexKDevelop", indexKDevelopBox->isChecked()); 00272 config->writeEntry("IndexQt", indexQtBox->isChecked()); 00273 config->writeEntry("IndexKdelibs", indexKdelibsBox->isChecked()); 00274 config->writeEntry("IndexBooks", indexBooksBox->isChecked()); 00275 config->writeEntry("IndexBookmarks", indexBookmarksBox->isChecked()); 00276 00277 config->setGroup("htdig"); 00278 #if defined(KDE_IS_VERSION) 00279 # if KDE_IS_VERSION(3,1,3) 00280 # ifndef _KDE_3_1_3_ 00281 # define _KDE_3_1_3_ 00282 # endif 00283 # endif 00284 #endif 00285 00286 #if defined(_KDE_3_1_3_) 00287 config->writePathEntry("htdigbin", htdigbinEdit->url()); 00288 config->writePathEntry("htmergebin", htmergebinEdit->url()); 00289 config->writePathEntry("htsearchbin", htsearchbinEdit->url()); 00290 #else 00291 config->writeEntry("htdigbin", htdigbinEdit->url()); 00292 config->writeEntry("htmergebin", htmergebinEdit->url()); 00293 config->writeEntry("htsearchbin", htsearchbinEdit->url()); 00294 #endif 00295 00296 QStringList bookmarksTitle, bookmarksURL; 00297 { 00298 QListViewItem *item = bListView->firstChild(); 00299 for (; item; item = item->nextSibling()) { 00300 bookmarksTitle.append(item->text(0)); 00301 bookmarksURL.append(item->text(1)); 00302 } 00303 } 00304 DocTreeViewTool::setBookmarks(bookmarksTitle, bookmarksURL); 00305 00306 if (!dhURL->url().isEmpty()) 00307 { 00308 config->setGroup("DevHelp"); 00309 #if defined(_KDE_3_1_3_) 00310 config->writePathEntry("DevHelpDir", dhURL->url()); 00311 #else 00312 config->writeEntry("DevHelpDir", dhURL->url()); 00313 #endif 00314 } 00315 config->sync(); 00316 } 00317 00318 00319 void DocTreeGlobalConfigWidget::updateIndexClicked() 00320 { 00321 // I'm not sure if storing the configuration here is compliant 00322 // with user interface guides, but I see no easy way around 00323 storeConfig(); 00324 00325 DocTreeViewFactory::instance()->config()->sync(); 00326 KProcess proc; 00327 proc << "kdevelop-htdig"; 00328 proc.start(KProcess::DontCare); 00329 } 00330 00331 void DocTreeGlobalConfigWidget::addBookmarkClicked() 00332 { 00333 AddDocItemDialog dlg(KFile::File, "all/allfiles"); 00334 if (!dlg.exec()) 00335 return; 00336 00337 (void) new KListViewItem(bListView, dlg.title(), dlg.url()); 00338 00339 } 00340 00341 void DocTreeGlobalConfigWidget::removeBookmarkClicked() 00342 { 00343 QListViewItem* item = bListView->currentItem(); 00344 if (item) { 00345 bListView->removeItem(item); 00346 } 00347 } 00348 00349 void DocTreeGlobalConfigWidget::accept() 00350 { 00351 storeConfig(); 00352 m_widget->configurationChanged(); 00353 } 00354 00355 void DocTreeGlobalConfigWidget::extEdit() 00356 { 00357 QListViewItem *item = extListView->currentItem(); 00358 if( item ) 00359 { 00360 const QString name( item->text(0) ); 00361 const QString location( item->text(2) ); 00362 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs(); 00363 QStringList tocs = dirs->findAllResources("doctocs", QString::null, false, true); 00364 QString filePath; 00365 for( QStringList::Iterator it = tocs.begin(); it!=tocs.end(); ++it) 00366 { 00367 if(QFileInfo(*it).baseName() == name) 00368 filePath = *it; 00369 } 00370 const QString _default( DocTreeViewTool::tocDocDefaultLocation( filePath ) ); 00371 LibraryDocDlg *dlg = new LibraryDocDlg( this, name.latin1(), location, _default, "TocDirs"); 00372 dlg->libName->setEnabled(false); 00373 dlg->libSource->setEnabled(false); 00374 dlg->exec(); 00375 00376 delete dlg; 00377 } 00378 extListView->clear(); 00379 readTocConfigs(); 00380 } 00381 00382 void DocTreeGlobalConfigWidget::extEnable() 00383 { 00384 /* QListViewItem *item( extListView->selectedItem() ); 00385 if( item && item->text(1) == "false" ) 00386 { 00387 m_ignoreTocs.remove( item->text( 0 ) ); 00388 DomUtil::writeListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoretocs", "toc", m_ignoreTocs ); 00389 item->setText(1, "true"); 00390 }*/ 00391 } 00392 00393 void DocTreeGlobalConfigWidget::extDisable() 00394 { 00395 //kdDebug(9002) << "disable" << endl; 00396 /* QListViewItem *item( extListView->selectedItem() ); 00397 if( item && item->text(1) == "true" ) 00398 { 00399 m_ignoreTocs << item->text( 0 ); 00400 DomUtil::writeListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoretocs", "toc", m_ignoreTocs ); 00401 item->setText(1, "false"); 00402 }*/ 00403 } 00404 00405 00406 void DocTreeGlobalConfigWidget::doxygenadd_button_clicked( ) 00407 { 00408 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, ""); 00409 if (dialog->exec()) 00410 { 00411 QString url = dialog->url(); 00412 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1); 00413 new KListViewItem(doxygen_view, dialog->title(), url); 00414 } 00415 delete dialog; 00416 } 00417 00418 void DocTreeGlobalConfigWidget::doxygenedit_button_clicked( ) 00419 { 00420 if (doxygen_view->currentItem()) 00421 { 00422 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, "", AddDocItemDialog::None, 00423 doxygen_view->currentItem()->text(0), doxygen_view->currentItem()->text(1)); 00424 if (dialog->exec()) 00425 { 00426 QString url = dialog->url(); 00427 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1); 00428 doxygen_view->currentItem()->setText(0, dialog->title()); 00429 doxygen_view->currentItem()->setText(1, url); 00430 } 00431 delete dialog; 00432 } 00433 } 00434 00435 void DocTreeGlobalConfigWidget::doxygenremove_button_clicked( ) 00436 { 00437 if (doxygen_view->currentItem()) 00438 delete doxygen_view->currentItem(); 00439 } 00440 00441 void DocTreeGlobalConfigWidget::qtdocsadd_button_clicked( ) 00442 { 00443 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.xml *.dcf", AddDocItemDialog::Qt); 00444 if (dialog->exec()) 00445 new KListViewItem(qtdocs_view, dialog->title(), dialog->url()); 00446 delete dialog; 00447 } 00448 00449 void DocTreeGlobalConfigWidget::qtdocsedit_button_clicked( ) 00450 { 00451 if (qtdocs_view->currentItem()) 00452 { 00453 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.xml *.dcf", AddDocItemDialog::Qt, 00454 qtdocs_view->currentItem()->text(0), qtdocs_view->currentItem()->text(1)); 00455 if (dialog->exec()) 00456 { 00457 qtdocs_view->currentItem()->setText(0, dialog->title()); 00458 qtdocs_view->currentItem()->setText(1, dialog->url()); 00459 } 00460 delete dialog; 00461 } 00462 } 00463 00464 void DocTreeGlobalConfigWidget::qtdocsremove_button_clicked( ) 00465 { 00466 if (qtdocs_view->currentItem()) 00467 delete qtdocs_view->currentItem(); 00468 } 00469 00470 void DocTreeGlobalConfigWidget::kdocadd_button_clicked( ) 00471 { 00472 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, ""); 00473 if (dialog->exec()) 00474 { 00475 QString url = dialog->url(); 00476 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1); 00477 new KListViewItem(kdoc_view, dialog->title(), url); 00478 } 00479 delete dialog; 00480 } 00481 00482 void DocTreeGlobalConfigWidget::kdocedit_button_clicked( ) 00483 { 00484 if (kdoc_view->currentItem()) 00485 { 00486 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::Directory, "", AddDocItemDialog::None, 00487 kdoc_view->currentItem()->text(0), kdoc_view->currentItem()->text(1)); 00488 if (dialog->exec()) 00489 { 00490 QString url = dialog->url(); 00491 if (url[url.length()-1] == QChar('/')) url.remove(url.length()-1, 1); 00492 kdoc_view->currentItem()->setText(0, dialog->title()); 00493 kdoc_view->currentItem()->setText(1, url); 00494 } 00495 delete dialog; 00496 } 00497 } 00498 00499 void DocTreeGlobalConfigWidget::kdocremove_button_clicked( ) 00500 { 00501 if (kdoc_view->currentItem()) 00502 delete kdoc_view->currentItem(); 00503 } 00504 00505 void DocTreeGlobalConfigWidget::pushEdit_clicked() 00506 { 00507 if (bListView->currentItem()) 00508 { 00509 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "text/html", AddDocItemDialog::None, 00510 bListView->currentItem()->text(0), bListView->currentItem()->text(1)); 00511 if (dialog->exec()) 00512 { 00513 bListView->currentItem()->setText(0, dialog->title()); 00514 bListView->currentItem()->setText(1, dialog->url()); 00515 } 00516 delete dialog; 00517 } 00518 } 00519 00520 void DocTreeGlobalConfigWidget::extAddButton_clicked( ) 00521 { 00522 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.toc", AddDocItemDialog::KDevelopTOC); 00523 if (dialog->exec()) 00524 { 00525 KListViewItem *item = new KListViewItem(extListView); 00526 dhListView->setCurrentItem(item); 00527 00528 QFileInfo fi(dialog->url()); 00529 dhListView->currentItem()->setText(0, fi.baseName()); 00530 // dhListView->currentItem()->setText(1, "true"); 00531 00532 // QString localURL = locateLocal("data", QString("kdevdoctreeview/tocs/") + dialog->title()); 00533 QString localURL = DocTreeViewFactory::instance()->dirs()->saveLocation("doctocs") + fi.baseName() + ".toc"; 00534 KURL src; 00535 src.setPath(dialog->url()); 00536 KURL dest; 00537 dest.setPath(localURL); 00538 KIO::NetAccess::copy(src, dest); 00539 00540 dhListView->currentItem()->setText(2, DocTreeViewTool::tocLocation( localURL )); 00541 dhListView->currentItem()->setText(1, DocTreeViewTool::tocTitle( localURL )); 00542 } 00543 delete dialog; 00544 } 00545 00546 void DocTreeGlobalConfigWidget::extRemoveButton_clicked( ) 00547 { 00548 if (extListView->currentItem()) 00549 { 00550 KURL url; 00551 url.setPath(DocTreeViewFactory::instance()->dirs()->findResource("doctocs", 00552 extListView->currentItem()->text(0) + QString(".toc"))); 00553 if (! KIO::NetAccess::del(url)) 00554 KMessageBox::error(this, i18n("Could not remove documentation TOC!\nIt may be a part of system-wide KDevelop documentation.")); 00555 else 00556 delete extListView->currentItem(); 00557 } 00558 } 00559 00560 void DocTreeGlobalConfigWidget::dhAddButton_clicked( ) 00561 { 00562 AddDocItemDialog *dialog = new AddDocItemDialog(KFile::File, "*.devhelp", AddDocItemDialog::DevHelp); 00563 if (dialog->exec()) 00564 { 00565 KListViewItem *item = new KListViewItem(dhListView); 00566 dhListView->setCurrentItem(item); 00567 00568 QFileInfo fi(dialog->url()); 00569 00570 BookInfo inf = DocTreeViewTool::devhelpInfo(dialog->url()); 00571 dhListView->currentItem()->setText(0, fi.baseName(false)); 00572 // dhListView->currentItem()->setText(1, "true"); 00573 dhListView->currentItem()->setText(1, inf.title); 00574 if (!inf.defaultLocation.isEmpty()) 00575 dhListView->currentItem()->setText(2, inf.defaultLocation); 00576 else 00577 dhListView->currentItem()->setText(2, URLUtil::directory(fi.absFilePath())); 00578 dhListView->currentItem()->setText(3, inf.author); 00579 00580 // QString localURL = locateLocal("data", QString("kdevdoctreeview/tocs/") + dialog->title()); 00581 QString localURL = DocTreeViewFactory::instance()->dirs()->saveLocation("docdevhelp") + fi.baseName() + ".devhelp"; 00582 KURL src; 00583 src.setPath(dialog->url()); 00584 KURL dest; 00585 dest.setPath(localURL); 00586 KIO::NetAccess::copy(src, dest); 00587 } 00588 delete dialog; 00589 } 00590 00591 void DocTreeGlobalConfigWidget::dhDisableButton_clicked( ) 00592 { 00593 /* QListViewItem *item( dhListView->selectedItem() ); 00594 if( item && item->text(1) == "true" ) 00595 { 00596 m_ignoreDevHelp << item->text( 0 ); 00597 DomUtil::writeListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoredevhelp", "toc", m_ignoreDevHelp ); 00598 item->setText(1, "false"); 00599 }*/ 00600 } 00601 00602 void DocTreeGlobalConfigWidget::dhEditButton_clicked( ) 00603 { 00604 QListViewItem *item = dhListView->currentItem(); 00605 if( item ) 00606 { 00607 const QString name( item->text(0) ); 00608 const QString location( item->text(2) ); 00609 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs(); 00610 QStringList tocs = dirs->findAllResources("docdevhelp", QString::null, false, true); 00611 QString filePath; 00612 for( QStringList::Iterator it = tocs.begin(); it!=tocs.end(); ++it) 00613 { 00614 if(QFileInfo(*it).baseName() == name) 00615 filePath = *it; 00616 } 00617 const QString _default( DocTreeViewTool::devhelpInfo(filePath).defaultLocation ); 00618 LibraryDocDlg *dlg = new LibraryDocDlg( this, name.latin1(), location, _default, "TocDevHelp"); 00619 dlg->libName->setEnabled(false); 00620 dlg->libSource->setEnabled(false); 00621 dlg->exec(); 00622 00623 delete dlg; 00624 } 00625 dhListView->clear(); 00626 readDevHelpConfig(); 00627 } 00628 00629 void DocTreeGlobalConfigWidget::dhEnableButton_clicked( ) 00630 { 00631 /* QListViewItem *item( dhListView->selectedItem() ); 00632 if( item && item->text(1) == "false" ) 00633 { 00634 m_ignoreDevHelp.remove( item->text( 0 ) ); 00635 DomUtil::writeListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoredevhelp", "toc", m_ignoreDevHelp ); 00636 item->setText(1, "true"); 00637 }*/ 00638 } 00639 00640 void DocTreeGlobalConfigWidget::dhRemoveButton_clicked( ) 00641 { 00642 if (dhListView->currentItem()) 00643 { 00644 KURL url; 00645 url.setPath(DocTreeViewFactory::instance()->dirs()->findResource("docdevhelp", 00646 dhListView->currentItem()->text(0) + QString(".devhelp"))); 00647 if (! KIO::NetAccess::del(url)) 00648 KMessageBox::error(this, i18n("Could not remove documentation TOC!\nIt may be a part of system-wide KDevelop documentation.")); 00649 else 00650 { 00651 KConfig *config = DocTreeViewFactory::instance()->config(); 00652 config->setGroup("TocDevHelp"); 00653 config->deleteEntry(dhListView->currentItem()->text(0)); 00654 delete dhListView->currentItem(); 00655 } 00656 } 00657 } 00658 00659 void DocTreeGlobalConfigWidget::dhScanButton_clicked( ) 00660 { 00661 dhListView->clear(); 00662 DocTreeViewTool::scanDevHelpDirs(dhURL->url()); 00663 readDevHelpConfig(); 00664 } 00665 00666 void DocTreeGlobalConfigWidget::readDevHelpConfig() 00667 { 00668 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs(); 00669 00670 QStringList tocs = dirs->findAllResources("docdevhelp", QString::null, false, true); 00671 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit) 00672 { 00673 KListViewItem *item = 0; 00674 00675 QFileInfo fi(*tit); 00676 00677 BookInfo inf = DocTreeViewTool::devhelpInfo(*tit); 00678 /* if( m_ignoreDevHelp.contains( fi.baseName() ) ) 00679 item = new KListViewItem( dhListView, "", "false"); 00680 else 00681 item = new KListViewItem( dhListView, "", "true");*/ 00682 item = new KListViewItem(dhListView); 00683 item->setText(0, fi.baseName(false)); 00684 item->setText(1, inf.title); 00685 item->setText(2, DocTreeViewTool::devhelpLocation(fi.baseName() , inf.defaultLocation)); 00686 item->setText(3, inf.author); 00687 } 00688 } 00689 00690 #include "doctreeglobalconfigwidget.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:50 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003