KDevelop API Documentation

parts/doctreeview/doctreeviewwidget.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 1999-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 "doctreeviewwidget.h" 00017 00018 #include <qdir.h> 00019 #include <qfileinfo.h> 00020 #include <qheader.h> 00021 #include <qregexp.h> 00022 #include <qtimer.h> 00023 #include <qtoolbutton.h> 00024 #include <qtooltip.h> 00025 #include <qlistview.h> 00026 #include <qmessagebox.h> 00027 #include <qlabel.h> 00028 #include <qptrlist.h> 00029 #include <qprogressdialog.h> 00030 #include <qwhatsthis.h> 00031 00032 #include <kdebug.h> 00033 #include <kapplication.h> 00034 #include <kdialogbase.h> 00035 #include <kcombobox.h> 00036 #include <kglobal.h> 00037 #include <kiconloader.h> 00038 #include <klocale.h> 00039 #include <kpopupmenu.h> 00040 #include <kstandarddirs.h> 00041 #include <ksimpleconfig.h> 00042 #include <kprocess.h> 00043 #include <kdeversion.h> 00044 00045 #include "choosedlg.h" 00046 00047 #include "kdevcore.h" 00048 #include "domutil.h" 00049 #include "urlutil.h" 00050 #include "kdevmainwindow.h" 00051 #include "kdevproject.h" 00052 #include "kdevpartcontroller.h" 00053 00054 #include "../../config.h" 00055 #include "misc.h" 00056 #include "doctreeviewfactory.h" 00057 #include "doctreeviewpart.h" 00058 #include "doctreeglobalconfigwidget.h" 00059 #include "doctreeprojectconfigwidget.h" 00060 #include "doclineedit.h" 00061 00062 #include "docsearchdlg.h" 00063 00064 IndexTreeData::IndexTreeData(const QString &text, const QString &parent, const QString &filename) : 00065 m_text(text), m_parent(parent), m_filename(filename), m_visible(true) 00066 { 00067 } 00068 00069 class DocTreeItem : public QListViewItem 00070 { 00071 public: 00072 enum Type { Folder, Book, Doc }; 00073 DocTreeItem( KListView *parent, Type type, const QString &text, const QString &context ); 00074 DocTreeItem( DocTreeItem *parent, Type type, const QString &text, const QString &context); 00075 00076 void setFileName(const QString &fn) 00077 { filename = fn; } 00078 virtual QString fileName() 00079 { return filename; } 00080 virtual void clear(); 00081 virtual QString context() const { return m_context; } 00082 virtual Type getType() const { return typ; } 00083 00084 private: 00085 void init(); 00086 Type typ; 00087 QString filename, m_context; 00088 }; 00089 00090 00091 DocTreeItem::DocTreeItem(KListView *parent, Type type, const QString &text, const QString &context) 00092 : QListViewItem(parent, text), typ(type), m_context(context) 00093 { 00094 init(); 00095 } 00096 00097 00098 DocTreeItem::DocTreeItem(DocTreeItem *parent, Type type, const QString &text, const QString &context) 00099 : QListViewItem(parent, text), typ(type), m_context(context) 00100 { 00101 init(); 00102 } 00103 00104 00105 void DocTreeItem::init() 00106 { 00107 QString icon; 00108 if (typ == Folder) 00109 icon = "folder"; 00110 else if (typ == Book) 00111 icon = "contents"; 00112 else 00113 icon = "document"; 00114 setPixmap(0, SmallIcon(icon)); 00115 } 00116 00117 00118 void DocTreeItem::clear() 00119 { 00120 QListViewItem *child = firstChild(); 00121 while (child) 00122 { 00123 QListViewItem *old = child; 00124 child = child->nextSibling(); 00125 delete old; 00126 } 00127 } 00128 00129 /*************************************/ 00130 /* Folder "Qt/KDE libraries (kdoc)" */ 00131 /*************************************/ 00132 00133 00139 class DocTreeKDELibsBook : public DocTreeItem 00140 { 00141 public: 00142 DocTreeKDELibsBook( DocTreeItem *parent, const QString &name, const QString &idxfilename, const QString &context); 00143 ~DocTreeKDELibsBook(); 00144 00145 virtual QString fileName(); 00146 virtual void setOpen(bool o); 00147 00148 private: 00149 void readContents(); 00150 void readKdoc2Index(FILE *f); 00151 QString idx_filename; 00152 }; 00153 00154 00155 DocTreeKDELibsBook::DocTreeKDELibsBook(DocTreeItem *parent, const QString &name, const QString &idxfilename, const QString &context) 00156 : DocTreeItem(parent, Book, name, context), 00157 idx_filename(idxfilename) 00158 { 00159 setExpandable(true); 00160 } 00161 00162 00163 DocTreeKDELibsBook::~DocTreeKDELibsBook() 00164 {} 00165 00166 00167 QString DocTreeKDELibsBook::fileName() 00168 { 00169 if (DocTreeItem::fileName().isNull()) 00170 readContents(); 00171 return DocTreeItem::fileName()+"/index.html"; 00172 } 00173 00174 00175 void DocTreeKDELibsBook::setOpen(bool o) 00176 { 00177 if (o && DocTreeItem::fileName().isNull()) 00178 readContents(); 00179 DocTreeItem::setOpen(o); 00180 } 00181 00182 00183 void DocTreeKDELibsBook::readContents() 00184 { 00185 FILE *f; 00186 bool success = false; 00187 if (idx_filename.right(3) != QString::fromLatin1(".gz")) 00188 { 00189 if ( (f = fopen(QFile::encodeName( idx_filename ).data(), "r")) != 0) 00190 { 00191 readKdoc2Index(f); 00192 fclose(f); 00193 success = true; 00194 } 00195 } 00196 else 00197 { 00198 QString cmd = "gzip -c -d "; 00199 #if (KDE_VERSION > 305) 00200 cmd += KProcess::quote(idx_filename); 00201 #else 00202 cmd += KShellProcess::quote(idx_filename); 00203 #endif 00204 cmd += " 2>/dev/null"; 00205 if ( (f = popen(QFile::encodeName(cmd), "r")) != 0) 00206 { 00207 readKdoc2Index(f); 00208 pclose(f); 00209 success = true; 00210 } 00211 } 00212 setExpandable(success); 00213 } 00214 00215 00216 void DocTreeKDELibsBook::readKdoc2Index(FILE *f) 00217 { 00218 char buf[1024]; 00219 DocTreeItem *classItem = 0; 00220 int pos0; 00221 QString classname, membername, filename; 00222 00223 while (fgets(buf, sizeof buf, f)) 00224 { 00225 QString s = buf; 00226 if (s.left(pos0=11) == "<BASE URL=\"") 00227 { 00228 int pos2 = s.find("\">", pos0); 00229 if (pos2 != -1) 00230 setFileName(s.mid(pos0, pos2-pos0)); 00231 } 00232 else if (s.left(pos0=9) == "<C NAME=\"") 00233 { 00234 int pos1 = s.find("\" REF=\"", pos0); 00235 if (pos1 == -1) 00236 continue; 00237 int pos2 = s.find("\">", pos1+7); 00238 if (pos2 == -1) 00239 continue; 00240 classname = s.mid(pos0, pos1-pos0); 00241 filename = s.mid(pos1+7, pos2-(pos1+7)); 00242 filename.replace(QRegExp("::"), "__"); 00243 classItem = new DocTreeItem(this, Doc, classname, context()); 00244 classItem->setFileName(DocTreeItem::fileName() + "/" + filename); 00245 } 00246 else if (/*s.left(pos0=9) == "<M NAME=\"" || */s.left(pos0=10) == "<ME NAME=\"") 00247 { 00248 int pos1 = s.find("\" REF=\"", pos0); 00249 if (pos1 == -1) 00250 continue; 00251 int pos2 = s.find("\">", pos1+7); 00252 if (pos2 == -1) 00253 continue; 00254 00255 // Long version: membername = classname + "::" + s.mid(pos0, pos1-pos0); 00256 membername = s.mid(pos0, pos1-pos0); 00257 filename = s.mid(pos1+7, pos2-(pos1+7)); 00258 filename.replace(QRegExp("::"), "__"); 00259 if (classItem) 00260 { 00261 DocTreeItem *item = new DocTreeItem(classItem, Doc, membername, context()); 00262 // kdDebug ( 9000 ) << "++++++++++++++ " << membername << endl; 00263 item->setFileName(DocTreeItem::fileName() + "/" + filename); 00264 } 00265 } 00266 } 00267 00268 sortChildItems(0, true); 00269 } 00270 00271 00272 class DocTreeKDELibsFolder : public DocTreeItem 00273 { 00274 public: 00275 DocTreeKDELibsFolder(QString location, QString name, KListView *parent, const QString &context) 00276 : DocTreeItem(parent, Folder, name, context), m_location(location) 00277 { setExpandable(true); } 00278 void refresh(); 00279 private: 00280 QString m_location; 00281 }; 00282 00283 00284 void DocTreeKDELibsFolder::refresh() 00285 { 00286 DocTreeItem::clear(); 00287 00288 /* QDir d(m_location); 00289 QStringList fileList = d.entryList("*", QDir::Dirs); 00290 00291 QStringList::ConstIterator it; 00292 for (it = fileList.begin(); it != fileList.end(); ++it) { 00293 QString dirName = (*it); 00294 if (dirName == "." || dirName == ".." || dirName == "common") 00295 continue; 00296 qWarning("loading dir %s", dirName.latin1());*/ 00297 QStringList itemNames, fileNames, hiddenNames; 00298 DocTreeViewTool::readLibraryDocs(m_location,&itemNames, &fileNames); 00299 QStringList::Iterator it1, it2; 00300 for (it1 = itemNames.begin(), it2 = fileNames.begin(); 00301 it1 != itemNames.end() && it2 != fileNames.end(); 00302 ++it1, ++it2) 00303 { 00304 new DocTreeKDELibsBook(this, *it1, *it2, context()); 00305 } 00306 //} 00307 00308 sortChildItems(0, true); 00309 00311 00312 // Read in possible items for the Libraries tree 00313 /* QStringList libNames, docDirs, sourceDirs; 00314 DocTreeViewTool::getLibraries(&libNames, &docDirs, &sourceDirs); 00315 QStringList::Iterator libName, docDir, sourceDir; 00316 for (libName = libNames.begin(), 00317 docDir = docDirs.begin(), 00318 sourceDir = sourceDirs.begin() ; 00319 libName!=libNames.end() && docDir!=docDirs.end() && sourceDir!=sourceDirs.end(); 00320 ++libName, ++docDir, ++sourceDir) { 00321 QStringList itemNames, fileNames, hiddenNames; 00322 DocTreeViewTool::readLibraryDocs(*docDir,&itemNames, &fileNames); 00323 QStringList::Iterator it1, it2; 00324 for (it1 = itemNames.begin(), it2 = fileNames.begin(); 00325 it1 != itemNames.end() && it2 != fileNames.end(); 00326 ++it1, ++it2) { 00327 new DocTreeKDELibsBook(this, *it1, *it2, context()); 00328 } 00329 00330 }*/ 00331 } 00332 00333 00334 /***************************************/ 00335 /* Folder "Qt/KDE libraries (Doxygen)" */ 00336 /***************************************/ 00337 00338 00343 class DocTreeDoxygenBook : public DocTreeItem 00344 { 00345 public: 00346 DocTreeDoxygenBook( DocTreeItem *parent, const QString &name, 00347 const QString &tagFileName, const QString &context); 00348 ~DocTreeDoxygenBook(); 00349 static bool isInstallationOK(const QString& bookDir) 00350 { 00351 return QFile::exists(bookDir + "/html/index.html"); 00352 } 00353 00354 virtual void setOpen(bool o); 00355 00356 private: 00357 void readTagFile(); 00358 QString dirname; 00359 }; 00360 00361 00362 DocTreeDoxygenBook::DocTreeDoxygenBook(DocTreeItem *parent, const QString &name, 00363 const QString &dirName, const QString &context) 00364 : DocTreeItem(parent, Book, name, context), 00365 dirname(dirName) 00366 { 00367 QString fileName = dirName + "index.html"; 00368 setFileName(fileName); 00369 setExpandable(true); 00370 } 00371 00372 00373 DocTreeDoxygenBook::~DocTreeDoxygenBook() 00374 {} 00375 00376 00377 void DocTreeDoxygenBook::setOpen(bool o) 00378 { 00379 if (o && childCount() == 0) 00380 readTagFile(); 00381 DocTreeItem::setOpen(o); 00382 } 00383 00384 00385 void DocTreeDoxygenBook::readTagFile() 00386 { 00387 QString tagName = dirname + "/" + text(0) + ".tag"; 00388 QFile f(tagName); 00389 if(!f.exists()) 00390 { 00391 #if QT_VERSION >= 0x030100 00392 tagName.remove("/html/"); 00393 #else 00394 tagName.replace( QRegExp( "\\/html\\/" ), QString() ); 00395 #endif 00396 f.setName( tagName ); 00397 } 00398 if (!f.open(IO_ReadOnly)) 00399 { 00400 kdDebug(9002) << "Could not open tag file: " << f.name() << endl; 00401 return; 00402 } 00403 00404 QDomDocument dom; 00405 if (!dom.setContent(&f) || dom.documentElement().nodeName() != "tagfile") 00406 { 00407 kdDebug(9002) << "No valid tag file" << endl; 00408 return; 00409 } 00410 f.close(); 00411 00412 QDomElement docEl = dom.documentElement(); 00413 00414 QDomElement childEl = docEl.firstChild().toElement(); 00415 while (!childEl.isNull()) 00416 { 00417 if (childEl.tagName() == "compound" && childEl.attribute("kind") == "class") 00418 { 00419 QString classname = childEl.namedItem("name").firstChild().toText().data(); 00420 QString filename = childEl.namedItem("filename").firstChild().toText().data(); 00421 00422 if (QFile::exists(dirname + filename)) 00423 { // don't create bad links 00424 DocTreeItem *item = new DocTreeItem(this, Doc, classname, context()); 00425 item->setFileName(dirname + filename); 00426 } 00427 } 00428 childEl = childEl.nextSibling().toElement(); 00429 } 00430 00431 sortChildItems(0, true); 00432 } 00433 00434 00435 class DocTreeDoxygenFolder : public DocTreeItem 00436 { 00437 public: 00438 DocTreeDoxygenFolder(QString location, QString name, KListView *parent, const QString &context) 00439 : DocTreeItem(parent, Folder, name, context), m_location(location) 00440 { setExpandable(true); } 00441 void refresh(); 00442 private: 00443 QString m_location; 00444 }; 00445 00446 void DocTreeDoxygenFolder::refresh() 00447 { 00448 DocTreeItem::clear(); 00449 00450 /* KConfig *config = DocTreeViewFactory::instance()->config(); 00451 config->setGroup("General"); 00452 QString docdir = config->readPathEntry("kdelibsdocdir", KDELIBS_DOXYDIR); 00453 00454 //kdDebug(9002) << "docdir: " << docdir << endl;*/ 00455 QDir d(m_location); 00456 QStringList fileList = d.entryList("*", QDir::Dirs); 00457 00458 QStringList::ConstIterator it; 00459 for (it = fileList.begin(); it != fileList.end(); ++it) 00460 { 00461 QString dirName = (*it); 00462 //kdDebug(9002) << "dirname: " << dirName << endl; 00463 if (dirName == "." || dirName == ".." || dirName == "common") 00464 continue; 00465 if (DocTreeDoxygenBook::isInstallationOK(d.absFilePath(*it))) 00466 { 00467 new DocTreeDoxygenBook(this, *it, d.absFilePath(*it) + "/html/", context()); 00468 //kdDebug(9002) << "foo: " << d.absFilePath(*it) + "/html/" + *it << endl; 00469 } 00470 } 00471 00472 QFileInfo fi(m_location +"/index.html"); 00473 if (fi.exists()) 00474 setFileName(m_location +"/index.html"); 00475 00476 sortChildItems(0, true); 00477 } 00478 00479 00480 /***************************************/ 00481 /* Folder from the 'tocs' resource dir */ 00482 /***************************************/ 00483 00484 class DocTreeTocFolder : public DocTreeItem 00485 { 00486 public: 00487 DocTreeTocFolder(KListView *parent, const QString &fileName, const QString &context); 00488 ~DocTreeTocFolder(); 00489 00490 QString tocName() const 00491 { return toc_name; } 00492 00493 private: 00494 QString base; 00495 QString toc_name; 00496 void addTocSect(DocTreeItem *parent, QDomElement childEl, uint level); 00497 }; 00498 00499 void DocTreeTocFolder::addTocSect(DocTreeItem *parent, QDomElement childEl, uint level) 00500 { 00501 QListViewItem *lastChildItem = 0; 00502 while (!childEl.isNull()) 00503 { 00504 if (childEl.tagName() == QString("tocsect%1").arg(level)) 00505 { 00506 QString name = childEl.attribute("name"); 00507 QString url = childEl.attribute("url"); 00508 DocTreeItem *item = 0; 00509 if (parent == 0) 00510 item = new DocTreeItem(this, Book, name, DocTreeItem::context()); 00511 else 00512 item = new DocTreeItem(parent, Doc, name, DocTreeItem::context()); 00513 if (!url.isEmpty()) 00514 item->setFileName(base + url); 00515 00516 if (lastChildItem) 00517 item->moveItem(lastChildItem); 00518 lastChildItem = item; 00519 00520 QDomElement grandchildEl = childEl.firstChild().toElement(); 00521 addTocSect(item, grandchildEl, level+1); 00522 } 00523 childEl = childEl.nextSibling().toElement(); 00524 } 00525 } 00526 00527 DocTreeTocFolder::DocTreeTocFolder(KListView *parent, const QString &fileName, const QString &context) 00528 : DocTreeItem(parent, Folder, fileName, context) 00529 { 00530 setFileName( fileName ); 00531 00532 QFileInfo fi(fileName); 00533 toc_name = fi.baseName(); 00534 base = DocTreeViewTool::tocLocation( fileName ); 00535 00536 QFile f(fileName); 00537 if (!f.open(IO_ReadOnly)) 00538 { 00539 kdDebug(9002) << "Could not read doc toc: " << fileName << endl; 00540 return; 00541 } 00542 00543 QDomDocument doc; 00544 if (!doc.setContent(&f) || doc.doctype().name() != "kdeveloptoc") 00545 { 00546 kdDebug() << "Not a valid kdeveloptoc file: " << fileName << endl; 00547 return; 00548 } 00549 f.close(); 00550 00551 QDomElement docEl = doc.documentElement(); 00552 QDomElement titleEl = docEl.namedItem("title").toElement(); 00553 setText(0, titleEl.firstChild().toText().data()); 00554 00555 QDomElement childEl = docEl.firstChild().toElement(); 00556 00558 addTocSect(0, childEl, 1); 00559 00560 /* while (!childEl.isNull()) { 00561 if (childEl.tagName() == "tocsect1") { 00562 QString name = childEl.attribute("name"); 00563 QString url = childEl.attribute("url"); 00564 DocTreeItem *item = new DocTreeItem(this, Book, name, DocTreeItem::context()); 00565 if (!url.isEmpty()) 00566 item->setFileName(base + url); 00567 00568 if (lastChildItem) 00569 item->moveItem(lastChildItem); 00570 lastChildItem = item; 00571 00572 // Ok, this means we have two levels in the table of contents hardcoded 00573 // Eventually, this limitation should go, but at the moment it is simple to implement :-) 00574 QListViewItem *lastGrandchildItem = 0; 00575 QDomElement grandchildEl = childEl.firstChild().toElement(); 00576 while (!grandchildEl.isNull()) { 00577 if (grandchildEl.tagName() == "tocsect2") { 00578 QString name2 = grandchildEl.attribute("name"); 00579 QString url2 = grandchildEl.attribute("url"); 00580 DocTreeItem *item2 = new DocTreeItem(item, Doc, name2, DocTreeItem::context()); 00581 if (!url2.isEmpty()) 00582 item2->setFileName(base + url2); 00583 if (lastGrandchildItem) 00584 item2->moveItem(lastGrandchildItem); 00585 lastGrandchildItem = item2; 00586 // and nobody said there couldn't be another level ;-) 00587 QListViewItem *last2GrandchildItem = 0; 00588 QDomElement grand2childEl = grandchildEl.firstChild().toElement(); 00589 while (!grand2childEl.isNull()) { 00590 if (grand2childEl.tagName() == "tocsect3") { 00591 QString name3 = grand2childEl.attribute("name"); 00592 QString url3 = grand2childEl.attribute("url"); 00593 DocTreeItem *item3 = new DocTreeItem(item2, Doc, name3, DocTreeItem::context()); 00594 if (!url3.isEmpty()) 00595 item3->setFileName(base + url3); 00596 if (last2GrandchildItem) 00597 item3->moveItem(last2GrandchildItem); 00598 last2GrandchildItem = item3; 00599 00600 } 00601 grand2childEl = grand2childEl.nextSibling().toElement(); 00602 } 00603 } 00604 grandchildEl = grandchildEl.nextSibling().toElement(); 00605 } 00606 } 00607 childEl = childEl.nextSibling().toElement(); 00608 }*/ 00609 } 00610 00611 DocTreeTocFolder::~DocTreeTocFolder() 00612 {} 00613 00614 /****************************************************/ 00615 /* Folder from the DevHelp documentation collection */ 00616 /****************************************************/ 00617 class DocTreeDevHelpFolder : public DocTreeItem 00618 { 00619 public: 00620 DocTreeDevHelpFolder(KListView *parent, const QString &fileName, const QString &context); 00621 ~DocTreeDevHelpFolder(); 00622 00623 QString tocName() const 00624 { return toc_name; } 00625 00626 private: 00627 QString base; 00628 QString toc_name; 00629 void addTocSect(DocTreeItem *parent, QDomElement childEl); 00630 }; 00631 00632 void DocTreeDevHelpFolder::addTocSect(DocTreeItem *parent, QDomElement childEl) 00633 { 00634 QListViewItem *lastChildItem = 0; 00635 while (!childEl.isNull()) 00636 { 00637 if ( (childEl.tagName() == "sub") || (childEl.tagName() == "chapter")) 00638 { 00639 QString name = childEl.attribute("name"); 00640 QString url = childEl.attribute("link"); 00641 DocTreeItem *item = 0; 00642 if (parent == 0) 00643 item = new DocTreeItem(this, Book, name, DocTreeItem::context()); 00644 else 00645 item = new DocTreeItem(parent, Doc, name, DocTreeItem::context()); 00646 if (!url.isEmpty()) 00647 item->setFileName(base + url); 00648 00649 if (lastChildItem) 00650 item->moveItem(lastChildItem); 00651 lastChildItem = item; 00652 00653 QDomElement grandchildEl = childEl.firstChild().toElement(); 00654 addTocSect(item, grandchildEl); 00655 } 00656 childEl = childEl.nextSibling().toElement(); 00657 } 00658 } 00659 00660 DocTreeDevHelpFolder::DocTreeDevHelpFolder(KListView *parent, const QString &fileName, const QString &context) 00661 : DocTreeItem(parent, Folder, fileName, context) 00662 { 00663 00664 QFileInfo fi(fileName); 00665 toc_name = fi.baseName(); 00666 base = DocTreeViewTool::devhelpLocation( fileName ); 00667 00668 QFile f(fileName); 00669 if (!f.open(IO_ReadOnly)) 00670 { 00671 kdDebug(9002) << "Could not read devhelp toc: " << fileName << endl; 00672 return; 00673 } 00674 00675 QDomDocument doc; 00676 if (!doc.setContent(&f)) 00677 { 00678 kdDebug() << "Not a valid devhelp file: " << fileName << endl; 00679 return; 00680 } 00681 f.close(); 00682 00683 QDomElement docEl = doc.documentElement(); 00684 QDomElement chaptersEl = docEl.namedItem("chapters").toElement(); 00685 setText(0, docEl.attribute("title")); 00686 setFileName( base + docEl.attribute("link") ); 00687 00688 QDomElement childEl = chaptersEl.firstChild().toElement(); 00689 addTocSect(0, childEl); 00690 00691 } 00692 00693 DocTreeDevHelpFolder::~DocTreeDevHelpFolder() 00694 {} 00695 00696 00697 00698 /*************************************/ 00699 /* Folder "Documentation Base" */ 00700 /*************************************/ 00701 00702 #ifdef WITH_DOCBASE 00703 00704 00705 class DocTreeDocbaseFolder : public DocTreeItem 00706 { 00707 public: 00708 DocTreeDocbaseFolder(KListView *parent, const QString &context); 00709 ~DocTreeDocbaseFolder(); 00710 virtual void setOpen(bool o); 00711 private: 00712 void readDocbaseFile(FILE *f); 00713 }; 00714 00715 00716 DocTreeDocbaseFolder::DocTreeDocbaseFolder(KListView *parent, const QString &context) 00717 : DocTreeItem(parent, Folder, i18n("Documentation Base"), context) 00718 { 00719 setExpandable(true); 00720 } 00721 00722 00723 DocTreeDocbaseFolder::~DocTreeDocbaseFolder() 00724 {} 00725 00726 00727 void DocTreeDocbaseFolder::readDocbaseFile(FILE *f) 00728 { 00729 char buf[1024]; 00730 QString title; 00731 bool html = false; 00732 while (fgets(buf, sizeof buf, f)) 00733 { 00734 QString s = buf; 00735 if (s.right(1) == "\n") 00736 s.truncate(s.length()-1); // chop 00737 00738 if (s.left(7) == "Title: ") 00739 title = s.mid(7, s.length()-7); 00740 else if (s.left(8) == "Format: ") 00741 html = s.find("HTML", 8, false) != -1; 00742 else if (s.left(7) == "Index: " 00743 && html && !title.isEmpty()) 00744 { 00745 QString filename = s.mid(7, s.length()-7); 00746 DocTreeItem *item = new DocTreeItem(this, Doc, title, context()); 00747 item->setFileName(filename); 00748 break; 00749 } 00750 else if (s.left(9) == "Section: " 00751 && s.find("programming", 9, false) == -1) 00752 break; 00753 } 00754 } 00755 00756 00757 void DocTreeDocbaseFolder::setOpen(bool o) 00758 { 00759 if (o && childCount() == 0) 00760 { 00761 QDir d("/usr/share/doc-base"); 00762 QStringList fileList = d.entryList("*", QDir::Files); 00763 QStringList::Iterator it; 00764 for (it = fileList.begin(); it != fileList.end(); ++it) 00765 { 00766 FILE *f; 00767 if ( (f = fopen( QFile::encodeName(d.filePath(*it)), "r")) != 0) 00768 { 00769 readDocbaseFile(f); 00770 fclose(f); 00771 } 00772 } 00773 } 00774 DocTreeItem::setOpen(o); 00775 } 00776 00777 00778 #endif 00779 00780 00781 /*************************************/ 00782 /* Folder "Bookmarks" */ 00783 /*************************************/ 00784 00785 class DocTreeBookmarksFolder : public DocTreeItem 00786 { 00787 public: 00788 DocTreeBookmarksFolder(KListView *parent, const QString &context); 00789 void refresh(); 00790 }; 00791 00792 DocTreeBookmarksFolder::DocTreeBookmarksFolder(KListView *parent, const QString &context) 00793 : DocTreeItem(parent, Folder, i18n("Bookmarks"), context) 00794 {} 00795 00796 void DocTreeBookmarksFolder::refresh() 00797 { 00798 DocTreeItem::clear(); 00799 00800 QStringList othersTitle, othersURL; 00801 DocTreeViewTool::getBookmarks(&othersTitle, &othersURL); 00802 QStringList::Iterator it1, it2; 00803 for (it1 = othersTitle.begin(), it2 = othersURL.begin(); 00804 it1 != othersTitle.end() && it2 != othersURL.end(); 00805 ++it1, ++it2) 00806 { 00807 DocTreeItem *item = new DocTreeItem(this, Book, *it1, context()); 00808 item->setFileName(*it2); 00809 } 00810 } 00811 00812 00813 /*************************************/ 00814 /* Folder "Current Project" */ 00815 /*************************************/ 00816 00817 class DocTreeProjectFolder : public DocTreeItem 00818 { 00819 public: 00820 DocTreeProjectFolder(KListView *parent, const QString &context); 00821 void setProject(KDevProject *project) 00822 { m_project = project; } 00823 void refresh(); 00824 00825 private: 00826 KDevProject *m_project; 00827 QString m_userdocDir, m_apidocDir; 00828 }; 00829 00830 DocTreeProjectFolder::DocTreeProjectFolder(KListView *parent, const QString &context) 00831 : DocTreeItem(parent, Folder, i18n("Current Project"), context), m_project(0) 00832 {} 00833 00834 00835 void DocTreeProjectFolder::refresh() 00836 { 00838 if( !m_project ) 00839 return; 00840 00841 m_userdocDir = DomUtil::readEntry( 00842 *m_project->projectDom() , "/kdevdoctreeview/projectdoc/userdocDir"); 00843 m_apidocDir = DomUtil::readEntry( 00844 *m_project->projectDom() , "/kdevdoctreeview/projectdoc/apidocDir"); 00845 00846 00847 DocTreeItem::clear(); 00848 00849 // API documentation 00850 QDir apidir( m_apidocDir ); 00851 if (apidir.exists()) 00852 { 00853 QStringList entries = apidir.entryList("*.html", QDir::Files); 00854 QString filename = apidir.absPath() + "/index.html"; 00855 if (!QFileInfo(filename).exists()) 00856 return; 00857 DocTreeItem *item = new DocTreeItem( 00858 this, Book, i18n("API of %1").arg(m_project->projectName() ), context()); 00859 item->setFileName(filename); 00860 for (QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) 00861 { 00862 filename = *it; 00863 DocTreeItem *ditem = new DocTreeItem(item, 00864 Doc, QFileInfo(filename).baseName() , context()); 00865 ditem->setFileName(apidir.absPath() +"/"+ filename); 00866 } 00867 } 00868 // User documentation 00869 QDir userdir( m_userdocDir ); 00870 if (userdir.exists()) 00871 { 00872 QStringList entries = userdir.entryList("*.html", QDir::Files); 00873 QString filename = userdir.absPath() + "/index.html"; 00874 if (!QFileInfo(filename).exists()) 00875 return; 00876 DocTreeItem *item = new DocTreeItem( 00877 this, Book, i18n("Usedoc for %1").arg(m_project->projectName() ), context()); 00878 item->setFileName(filename); 00879 for (QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) 00880 { 00881 filename = *it; 00882 DocTreeItem *ditem = new DocTreeItem(item, 00883 Doc, QFileInfo(filename).baseName() , context()); 00884 ditem->setFileName(userdir.absPath() +"/"+ filename); 00885 } 00886 } 00887 00888 if (!firstChild()) 00889 setExpandable(false); 00890 00891 } 00892 00893 00894 /**************************************/ 00895 /* Qt Folder */ 00896 /**************************************/ 00897 00898 class DocTreeQtFolder : public DocTreeItem 00899 { 00900 public: 00901 DocTreeQtFolder(QString xml, QString name, KListView *parent, const QString &context); 00902 void refresh(); 00903 private: 00904 QString filename; 00905 QString m_xml; 00906 }; 00907 00908 DocTreeQtFolder::DocTreeQtFolder(QString xml, QString name, KListView *parent, 00909 const QString &context) 00910 : DocTreeItem(parent, Folder, name, context), m_xml(xml) 00911 { 00912 // filename = _fileName; 00913 } 00914 00915 void DocTreeQtFolder::refresh() 00916 { 00917 filename = m_xml; 00918 00919 QFileInfo fi(filename); 00920 00921 QFile f(filename); 00922 if (!f.open(IO_ReadOnly)) 00923 { 00924 kdDebug(9002) << "Could not read" << m_xml << endl; 00925 kdDebug(9002) << " Filename was: " << filename << endl; 00926 return; 00927 } 00928 QDomDocument doc; 00929 if (!doc.setContent(&f) || doc.doctype().name() != "DCF") 00930 { 00931 kdDebug(9002) << "Not a valid DCF file: " << filename << endl; 00932 return; 00933 } 00934 DocTreeItem::clear(); 00935 00936 f.close(); 00937 00938 QDomElement docEl = doc.documentElement(); 00939 QDomElement titleEl = docEl.namedItem("DCF").toElement(); 00940 00941 setFileName(fi.dirPath( true ) +"/"+ docEl.attribute("ref", QString::null)); 00942 00943 QDomElement childEl = docEl.lastChild().toElement(); 00944 while (!childEl.isNull()) 00945 { 00946 if (childEl.tagName() == "section") 00947 { 00948 QString ref = childEl.attribute("ref"); 00949 QString title = childEl.attribute("title"); 00950 00951 //dymo: enable all qt docs: disable "Class Reference" check 00952 /* int i = title.find("Class Reference"); 00953 if( i > 0 ) 00954 { 00955 title = title.left(i);*/ 00956 DocTreeItem* item = item = new DocTreeItem(this, Book, title, context()); 00957 item->setFileName(fi.dirPath( true ) +"/"+ ref); 00958 00959 QDomElement grandChild = childEl.lastChild().toElement(); 00960 while(!grandChild.isNull()) 00961 { 00962 if (grandChild.tagName() == "keyword") 00963 { 00964 QString dref = grandChild.attribute("ref"); 00965 QString dtitle = grandChild.text(); 00966 00967 DocTreeItem* dItem = new DocTreeItem(item, Doc, dtitle, context()); 00968 dItem->setFileName(fi.dirPath( true ) +"/"+ dref); 00969 } 00970 grandChild = grandChild.previousSibling().toElement(); 00971 } 00972 //kdDebug(9002) <<"ref: "<< ref <<" title: " << title << endl; 00973 // } 00974 childEl = childEl.previousSibling().toElement(); 00975 } 00976 } 00977 } 00978 00979 bool DocTreeViewWidget::initKDocKDELibs() 00980 { 00981 /* KConfig *config = DocTreeViewFactory::instance()->config(); 00982 config->setGroup( "General" ); 00983 kdelibskdoc = config->readBoolEntry("displayKDELibsKDoc", false); 00984 00985 if ( kdelibskdoc ) { 00986 if( folder_kdelibs ) return true; 00987 folder_kdelibs = new DocTreeKDELibsFolder(docView, "ctx_kdelibs"); 00988 folder_kdelibs->refresh(); 00989 return true; 00990 } else { 00991 if( folder_kdelibs ) 00992 delete folder_kdelibs; 00993 folder_kdelibs = 0L; 00994 return false; 00995 }*/ 00996 return true; 00997 } 00998 /**************************************/ 00999 /* The DocTreeViewWidget itself */ 01000 /**************************************/ 01001 01002 DocTreeViewWidget::DocTreeViewWidget(DocTreeViewPart *part) 01003 : QVBox(0, "doc tree widget"), m_activeTreeItem ( 0L ), indexMode ( filteredMode ), // will be switched 01004 subStringSearch( false ) 01005 { 01006 01007 /* initializing the tree/index switch */ 01008 modeSwitch = new KTabCtl(this, "mode switch"); 01009 01010 /* create the 2 tabs */ 01011 treeWidget = new QVBox(modeSwitch, "tree mode widget"); 01012 indexWidget = new QVBox(modeSwitch, "index mode widget"); 01013 01014 // INDEX MODE INIT 01015 QHBox *hbo = new QHBox(indexWidget, "label + edit"); 01016 hbo->setMargin( 2 ); 01017 QLabel *l = new QLabel( 0, i18n("Se&arch:"), hbo, "search-label" ); 01018 filterEdit = new DocLineEdit( hbo, "index mode filter line edit" ); 01019 l->setBuddy(filterEdit); 01020 01021 subSearchButton = new QToolButton ( hbo, "sub search check" ); 01022 subSearchButton->setSizePolicy ( QSizePolicy ( (QSizePolicy::SizeType)0, ( QSizePolicy::SizeType)0, 0, 0, 0) ); 01023 subSearchButton->setPixmap ( SmallIcon ( "grep" ) ); 01024 subSearchButton->setToggleButton(true); 01025 QToolTip::add ( subSearchButton, i18n ( "Search substrings" ) ); 01026 QWhatsThis::add(subSearchButton, i18n("<b>Search substrings</b><p>Index view searches for substrings in index items if toggled.")); 01027 01028 indexModeSwitch = new QToolButton ( hbo, "index mode switch" ); 01029 indexModeSwitch->setSizePolicy ( QSizePolicy ( (QSizePolicy::SizeType)0, ( QSizePolicy::SizeType)0, 0, 0, 0) ); 01030 indexModeSwitch->setPixmap ( SmallIcon ( "contents" ) ); 01031 indexModeSwitch->setToggleButton(true); 01032 indexModeSwitch->setOn( true ); 01033 QToolTip::add ( indexModeSwitch, i18n ( "Show topics for index items" ) ); 01034 QWhatsThis::add(indexModeSwitch, i18n("<b>Show topics for index items</b><p>Index view shows topics to which index items belong if toggled.")); 01035 01036 indexView = new KListView ( indexWidget, "documentation index list view" ); 01037 01038 indexView->setFocusPolicy(ClickFocus); 01039 indexView->setResizeMode(QListView::LastColumn); 01040 indexView->addColumn(QString::null); 01041 indexView->setSorting(0); 01042 indexView->header()->hide(); 01043 01044 connect ( filterEdit, SIGNAL ( textChanged(const QString &) ), this, SLOT ( slotFilterTextChanged(const QString &) ) ); 01045 connect ( filterEdit, SIGNAL ( returnPressed() ), this, SLOT ( slotFilterReturn() ) ); 01046 connect ( filterEdit, SIGNAL ( upPressed() ), this, SLOT ( slotIndexPrevMatch() ) ); 01047 connect ( filterEdit, SIGNAL ( downPressed() ), this, SLOT ( slotIndexNextMatch() ) ); 01048 connect ( filterEdit, SIGNAL ( pgupPressed() ), this, SLOT ( slotIndexPgUp() ) ); 01049 connect ( filterEdit, SIGNAL ( pgdownPressed() ), this, SLOT ( slotIndexPgDown() ) ); 01050 connect ( filterEdit, SIGNAL ( homePressed() ), this, SLOT ( slotIndexHome() ) ); 01051 connect ( filterEdit, SIGNAL ( endPressed() ), this, SLOT ( slotIndexEnd() ) ); 01052 connect ( indexView, SIGNAL ( executed(QListViewItem *) ), this, SLOT ( slotIndexItemExecuted(QListViewItem *) ) ); 01053 connect ( indexView, SIGNAL ( returnPressed(QListViewItem *) ), this, SLOT ( slotIndexItemExecuted(QListViewItem *) ) ); 01054 01055 connect ( modeSwitch, SIGNAL ( tabSelected(int) ), this, SLOT ( slotCurrentTabChanged(int) ) ); 01056 01057 connect ( subSearchButton, SIGNAL ( clicked() ), this, SLOT ( slotSubstringCheckClicked() ) ); 01058 connect ( indexModeSwitch, SIGNAL ( clicked() ), this, SLOT ( slotIndexModeCheckClicked() ) ); 01059 01060 // TREE MODE INIT 01061 01062 /* initializing the documentation tree toolbar */ 01063 searchToolbar = new QHBox ( treeWidget, "search toolbar" ); 01064 searchToolbar->setMargin ( 2 ); 01065 searchToolbar->setSpacing ( 2 ); 01066 01067 completionCombo = new KHistoryCombo ( true, searchToolbar, "completion combo box" ); 01068 01069 startButton = new QToolButton ( searchToolbar, "start searching" ); 01070 startButton->setSizePolicy ( QSizePolicy ( (QSizePolicy::SizeType)0, ( QSizePolicy::SizeType)0, 0, 0, startButton->sizePolicy().hasHeightForWidth()) ); 01071 startButton->setPixmap ( SmallIcon ( "key_enter" ) ); 01072 QToolTip::add ( startButton, i18n ( "Start searching" ) ); 01073 QWhatsThis::add(startButton, i18n("<b>Start searching</b><p>Searches through the documentation topics for a given term and shows the topic found.")); 01074 01075 nextButton = new QToolButton ( searchToolbar, "next match button" ); 01076 nextButton->setSizePolicy ( QSizePolicy ( ( QSizePolicy::SizeType )0, ( QSizePolicy::SizeType) 0, 0, 0, nextButton->sizePolicy().hasHeightForWidth()) ); 01077 nextButton->setPixmap ( SmallIcon ( "next" ) ); 01078 QToolTip::add ( nextButton, i18n ( "Jump to next matching entry" ) ); 01079 QWhatsThis::add(nextButton, i18n("<b>Jump to next matching entry</b><p>Shows the next topic found.")); 01080 nextButton->setEnabled( false ); 01081 01082 prevButton = new QToolButton ( searchToolbar, "previous match button" ); 01083 prevButton->setSizePolicy ( QSizePolicy ( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, prevButton->sizePolicy().hasHeightForWidth()) ); 01084 prevButton->setPixmap ( SmallIcon ( "previous" ) ); 01085 QToolTip::add ( prevButton, i18n ( "Jump to previous matching entry" ) ); 01086 QWhatsThis::add(prevButton, i18n("<b>Jump to previous matching entry</b><p>Shows the previous topic found.")); 01087 prevButton->setEnabled( false ); 01088 01089 docView = new KListView ( treeWidget, "documentation list view" ); 01090 01091 docView->setFocusPolicy(ClickFocus); 01092 docView->setRootIsDecorated(true); 01093 docView->setResizeMode(QListView::LastColumn); 01094 docView->setSorting(-1); 01095 docView->header()->hide(); 01096 docView->addColumn(QString::null); 01097 01098 folder_bookmarks = new DocTreeBookmarksFolder(docView, "ctx_bookmarks"); 01099 folder_bookmarks->refresh(); 01100 01101 folder_project = new DocTreeProjectFolder(docView, "ctx_current"); 01102 folder_project->refresh(); 01103 01104 #ifdef WITH_DOCBASE 01105 folder_docbase = new DocTreeDocbaseFolder(docView, "ctx_docbase"); 01106 #endif 01107 01108 // devhelp docs 01109 KConfig *configdh = DocTreeViewFactory::instance()->config(); 01110 if (configdh) 01111 { 01112 configdh->setGroup("TocDevHelp"); 01113 QString firstScan = configdh->readEntry("FirstScan", "yes"); 01114 if (firstScan != "no") 01115 { 01116 DocTreeViewTool::scanDevHelpDirs(); 01117 configdh->writeEntry("FirstScan", "no"); 01118 } 01119 } 01120 01121 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs(); 01122 QStringList dhtocs = dirs->findAllResources("docdevhelp", QString::null, false, true); 01123 for (QStringList::Iterator tit = dhtocs.begin(); tit != dhtocs.end(); ++tit) 01124 folder_devhelp.append(new DocTreeDevHelpFolder(docView, *tit, QString("ctx_%1").arg(*tit))); 01125 01126 // doctocs 01127 QStringList tocs = dirs->findAllResources("doctocs", QString::null, false, true); 01128 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit) 01129 folder_toc.append(new DocTreeTocFolder(docView, *tit, QString("ctx_%1").arg(*tit))); 01130 01131 // initKDocKDELibs(); 01132 01133 KConfig *config = DocTreeViewFactory::instance()->config(); 01134 if (config) 01135 { 01136 config->setGroup("General KDoc"); 01137 QMap<QString, QString> dmap = config->entryMap("General KDoc"); 01138 QString kdocdir(KDELIBS_DOCDIR); 01139 kdocdir = URLUtil::envExpand(kdocdir); 01140 if (dmap.empty() && (!kdocdir.isEmpty())) 01141 { 01142 config->writePathEntry("KDE Libraries (KDoc)", kdocdir); 01143 dmap["KDE Libraries (KDoc)"] = kdocdir; 01144 } 01145 01146 QMap<QString, QString>::Iterator it; 01147 for (it = dmap.begin(); it != dmap.end(); ++it) 01148 { 01149 DocTreeKDELibsFolder *kdf = new DocTreeKDELibsFolder(it.data(), it.key(), docView, "ctx_kdelibs"); 01150 kdf->refresh(); 01151 folder_kdoc.append(kdf); 01152 } 01153 } 01154 01155 if (config) 01156 { 01157 config->setGroup("General Doxygen"); 01158 QMap<QString, QString> xmap = config->entryMap("General Doxygen"); 01159 QString doxydir(KDELIBS_DOXYDIR); 01160 doxydir = URLUtil::envExpand(doxydir); 01161 if (xmap.empty() && (!doxydir.isEmpty())) 01162 { 01163 config->writePathEntry("KDE Libraries (Doxygen)", doxydir); 01164 xmap["KDE Libraries (Doxygen)"] = doxydir; 01165 } 01166 01167 QMap<QString, QString>::Iterator it; 01168 for (it = xmap.begin(); it != xmap.end(); ++it) 01169 { 01170 DocTreeDoxygenFolder *dxf = new DocTreeDoxygenFolder(config->readPathEntry(it.key()), it.key(), docView, "ctx_doxygen"); 01171 dxf->refresh(); 01172 folder_doxygen.append(dxf); 01173 } 01174 } 01175 01176 01177 // folder_doxygen = new DocTreeDoxygenFolder(docView, "ctx_doxygen"); 01178 01179 // folder_doxygen->refresh(); 01180 01181 // eventually, Qt docu extra 01182 /* QListViewItem* pChild = folder_doxygen->firstChild(); 01183 while (pChild && pChild->text(0) != "qt") { 01184 pChild = pChild->nextSibling(); 01185 } 01186 */ 01187 if (config) 01188 { 01189 config->setGroup("General Qt"); 01190 QMap<QString, QString> emap = config->entryMap("General Qt"); 01191 01192 QString qtdocdir(config->readPathEntry("qtdocdir", QT_DOCDIR)); 01193 qtdocdir = URLUtil::envExpand(qtdocdir); 01194 if (emap.empty() && (!qtdocdir.isEmpty())) 01195 { 01196 #if QT_VERSION >= 0x030200 01197 config->writePathEntry("Qt Reference Documentation", qtdocdir + QString("/qt.dcf")); 01198 emap["Qt Reference Documentation"] = qtdocdir + QString("/qt.dcf"); 01199 config->writePathEntry("Qt Assistant Manual", qtdocdir + QString("/assistant.dcf")); 01200 emap["Qt Assistant Manual"] = qtdocdir + QString("/assistant.dcf"); 01201 config->writePathEntry("Qt Designer Manual", qtdocdir + QString("/designer.dcf")); 01202 emap["Qt Designer Manual"] = qtdocdir + QString("/designer.dcf"); 01203 config->writePathEntry("Guide to the Qt Translation Tools", qtdocdir + QString("/linguist.dcf")); 01204 emap["Guide to the Qt Translation Tools"] = qtdocdir + QString("/linguist.dcf"); 01205 config->writePathEntry("qmake User Guide", qtdocdir + QString("/qmake.dcf")); 01206 emap["qmake User Guide"] = qtdocdir + QString("/qmake.dcf"); 01207 #else 01208 config->writePathEntry("Qt Reference Documentation", qtdocdir + QString("/qt.xml")); 01209 emap["Qt Reference Documentation"] = qtdocdir + QString("/qt.xml"); 01210 config->writePathEntry("Qt Assistant Manual", qtdocdir + QString("/assistant.xml")); 01211 emap["Qt Assistant Manual"] = qtdocdir + QString("/assistant.xml"); 01212 config->writePathEntry("Qt Designer Manual", qtdocdir + QString("/designer.xml")); 01213 emap["Qt Designer Manual"] = qtdocdir + QString("/designer.xml"); 01214 config->writePathEntry("Guide to the Qt Translation Tools", qtdocdir + QString("/linguist.xml")); 01215 emap["Guide to the Qt Translation Tools"] = qtdocdir + QString("/linguist.xml"); 01216 config->writePathEntry("qmake User Guide", qtdocdir + QString("/qmake.xml")); 01217 emap["qmake User Guide"] = qtdocdir + QString("/qmake.xml"); 01218 #endif 01219 } 01220 01221 QMap<QString, QString>::Iterator it; 01222 for (it = emap.begin(); it != emap.end(); ++it) 01223 { 01224 DocTreeQtFolder *qtf = new DocTreeQtFolder(it.data(), it.key(), docView, "ctx_qt"); 01225 qtf->refresh(); 01226 folder_qt.append(qtf); 01227 } 01228 } 01229 01230 connect ( nextButton, SIGNAL ( clicked() ), this, SLOT ( slotJumpToNextMatch() ) ); 01231 connect ( prevButton, SIGNAL ( clicked() ), this, SLOT ( slotJumpToPrevMatch() ) ); 01232 connect ( startButton, SIGNAL ( clicked() ), this, SLOT ( slotStartSearching() ) ); 01233 connect ( completionCombo, SIGNAL ( returnPressed ( const QString& ) ), this, SLOT ( slotHistoryReturnPressed ( const QString& ) ) ); 01234 01235 connect( docView, SIGNAL(executed(QListViewItem*)), 01236 this, SLOT(slotItemExecuted(QListViewItem*)) ); 01237 connect( docView, SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)), 01238 this, SLOT(slotContextMenu(KListView*, QListViewItem*, const QPoint&)) ); 01239 connect ( docView, SIGNAL ( selectionChanged ( QListViewItem* ) ), this, SLOT ( slotSelectionChanged ( QListViewItem* ) ) ); 01240 01241 m_part = part; 01242 01243 // modeSwitch->setShape(QTabBar::TriangularAbove); 01244 modeSwitch->setBorder(false); 01245 modeSwitch->addTab(treeWidget, i18n("Co&ntents")); 01246 modeSwitch->addTab(indexWidget, i18n("&Index")); 01247 } 01248 01249 01250 DocTreeViewWidget::~DocTreeViewWidget() 01251 {} 01252 01253 void DocTreeViewWidget::searchForItem ( const QString& currentText ) 01254 { 01255 completionCombo->addToHistory( currentText ); 01256 01257 QListViewItemIterator docViewIterator( docView ); 01258 while( docViewIterator.current() ) 01259 { 01260 // Load this category 01261 docViewIterator.current()->setOpen(true); 01262 docViewIterator.current()->setOpen(false); 01263 01264 if( docViewIterator.current()->text(0).find( currentText, false ) >= 0 ) 01265 { 01266 searchResultList.append( docViewIterator.current() ); 01267 } 01268 ++docViewIterator; 01269 } 01270 } 01271 01272 void DocTreeViewWidget::slotJumpToNextMatch() 01273 { 01274 if( searchResultList.next() ) 01275 { 01276 docView->setSelected ( searchResultList.current(), true ); 01277 docView->ensureItemVisible ( searchResultList.current() ); 01278 slotItemExecuted ( searchResultList.current() ); 01279 prevButton->setEnabled( true ); 01280 01281 if(searchResultList.current() == searchResultList.getLast() ) 01282 nextButton->setEnabled( false ); 01283 } 01284 else 01285 { 01286 searchResultList.last(); 01287 } 01288 01289 } 01290 01291 void DocTreeViewWidget::slotJumpToPrevMatch() 01292 { 01293 if( searchResultList.prev() ) 01294 { 01295 docView->setSelected ( searchResultList.current(), true ); 01296 docView->ensureItemVisible ( searchResultList.current() ); 01297 slotItemExecuted ( searchResultList.current() ); 01298 nextButton->setEnabled( true ); 01299 01300 if(searchResultList.current() == searchResultList.getFirst() ) 01301 prevButton->setEnabled( false ); 01302 } 01303 else 01304 { 01305 searchResultList.first(); 01306 } 01307 } 01308 01309 void DocTreeViewWidget::slotStartSearching() 01310 { 01311 QString currentText = completionCombo->currentText(); 01312 slotHistoryReturnPressed ( currentText ); 01313 } 01314 01315 void DocTreeViewWidget::slotHistoryReturnPressed ( const QString& currentText ) 01316 { 01317 if( !docView->selectedItem() ) 01318 docView->setCurrentItem( docView->firstChild() ); 01319 01320 nextButton->setEnabled( false ); 01321 prevButton->setEnabled( false ); 01322 searchResultList.clear(); 01323 01324 if( currentText.length() > 0 ) 01325 searchForItem( currentText ); //fills searchResultList 01326 01327 01328 if ( searchResultList.count() ) 01329 { 01330 kdDebug ( 9002 ) << "Found a matching entry!" << endl; 01331 docView->setSelected ( searchResultList.first(), true ); 01332 docView->ensureItemVisible ( searchResultList.first() ); 01333 slotItemExecuted ( searchResultList.first() ); 01334 } 01335 if ( searchResultList.count() > 1 ) 01336 { 01337 nextButton->setEnabled( true ); 01338 } 01339 } 01340 01341 void DocTreeViewWidget::slotSelectionChanged ( QListViewItem* item ) 01342 { 01343 contextItem = item; 01344 01345 if( !item->parent() ) 01346 {// current is a toplevel item, so we initialize all childs 01347 QListViewItem * myChild = item->firstChild(); 01348 while( myChild && myChild->parent()) 01349 {// only initialize current folder, not the below ones 01350 myChild->setOpen( true ); 01351 myChild->setOpen( false ); 01352 01353 myChild = myChild->itemBelow(); 01354 } 01355 } 01356 01357 } 01358 01359 void DocTreeViewWidget::slotItemExecuted(QListViewItem *item) 01360 { 01361 if (!item) 01362 return; 01363 01364 // We assume here that ALL items in the list view 01365 // are DocTreeItem's 01366 DocTreeItem *dtitem = static_cast<DocTreeItem*>(item); 01367 01368 QString ident = dtitem->fileName(); 01369 if (ident.isEmpty()) 01370 return; 01371 01372 // avoid empty pages when clicking on .toc files, choose its first child instead 01373 if (ident.right(4) == ".toc") 01374 { 01375 dtitem = static_cast<DocTreeItem*>(dtitem->firstChild()); 01376 if (!dtitem) return; 01377 ident = dtitem->fileName(); 01378 if (ident.isEmpty()) return; 01379 } 01380 01381 kdDebug(9002) << "Showing: " << ident << endl; 01382 m_part->partController()->showDocument(KURL(ident), dtitem->context()); 01383 m_part->mainWindow()->lowerView(this); 01384 } 01385 01386 01387 void DocTreeViewWidget::slotContextMenu(KListView *, QListViewItem *item, const QPoint &p) 01388 { 01389 if (!item) 01390 return; 01391 contextItem = item; 01392 KPopupMenu popup(i18n("Documentation Tree"), this); 01393 01394 DocTreeItem *dItem = dynamic_cast<DocTreeItem*>( item ); 01395 DocumentationContext dcontext( dItem->fileName(), "" ); 01396 01397 QListViewItem* i = contextItem; 01398 while(i->parent()) // go to folder 01399 { 01400 i = i->parent(); 01401 } 01402 if ( i == folder_project ) 01403 { 01404 int id = popup.insertItem(i18n("Project Properties"), this, SLOT(slotConfigureProject())); 01405 popup.setWhatsThis(id, i18n("<b>Project properties</b><p>Displays <b>Project Documentation</b> properties dialog.")); 01406 } 01407 else 01408 { 01409 int id = popup.insertItem(i18n("Properties"), this, SLOT(slotConfigure())); 01410 popup.setWhatsThis(id, i18n("<b>Properties</b><p>Displays <b>Documentation Tree</b> properties dialog.")); 01411 } 01412 if ( i != folder_bookmarks && dItem && !dItem->fileName().isEmpty() ) 01413 { 01414 int id = popup.insertItem(i18n("Add to Bookmarks"), this, SLOT(slotAddBookmark())); 01415 dcontext = DocumentationContext( dItem->fileName(), dItem->text(0) ); 01416 popup.setWhatsThis(id, i18n("<b>Add to bookmarks</b><p>Adds currently selected topic to the bookmarks list.")); 01417 } 01418 if ( contextItem->parent() && dItem && contextItem->parent() == folder_bookmarks ) 01419 { 01420 int id = popup.insertItem(i18n("Remove"), this, SLOT(slotRemoveBookmark())); 01421 popup.setWhatsThis(id, i18n("<b>Remove</b><p>Removes currently selected bookmark from the bookmarks list.")); 01422 dcontext = DocumentationContext( dItem->fileName(), dItem->text(0) ); 01423 } 01424 m_part->core()->fillContextMenu( &popup , &dcontext ); 01425 popup.exec(p); 01426 } 01427 01428 01429 void DocTreeViewWidget::slotConfigure() 01430 { 01431 KDialogBase dlg(KDialogBase::Tabbed, i18n("Customize Documentation Tree"), 01432 KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, this, 01433 "customization dialog"); 01434 01435 QVBox *vbox1 = dlg.addVBoxPage(i18n("Documentation Tree: Global")); 01436 DocTreeGlobalConfigWidget *w1 = new DocTreeGlobalConfigWidget( m_part, this, vbox1, "doctreeview global config widget"); 01437 connect(&dlg, SIGNAL(okClicked()), w1, SLOT(accept())); 01438 01439 dlg.exec(); 01440 01441 delete w1; 01442 } 01443 01444 void DocTreeViewWidget::slotConfigureProject() 01445 { 01446 KDialogBase dlg(KDialogBase::Tabbed, i18n("Customize Documentation Tree"), 01447 KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, this, 01448 "customization dialog"); 01449 01450 DocTreeProjectConfigWidget *w2 = 0; 01451 01452 if(m_part->project()) 01453 { 01454 QVBox *vbox2 = dlg.addVBoxPage(i18n("Documentation Tree: Project")); 01455 w2 = new DocTreeProjectConfigWidget(this, vbox2, m_part->project(),"doctreeview project config widget"); 01456 connect(&dlg, SIGNAL(okClicked()), w2, SLOT(accept())); 01457 dlg.exec(); 01458 } 01459 if(w2) 01460 delete w2; 01461 } 01462 01463 01464 void DocTreeViewWidget::configurationChanged() 01465 { 01466 kdDebug(9002) << "DocTreeViewWidget::configurationChanged()" << endl; 01467 initKDocKDELibs(); 01468 QTimer::singleShot(0, this, SLOT(refresh())); 01469 } 01470 01471 01472 void DocTreeViewWidget::refresh() 01473 { 01474 kdDebug(9002) << "DocTreeViewWidget::refresh()" << endl; 01475 // folder_doxygen->refresh(); 01476 folder_bookmarks->refresh(); 01477 folder_project->refresh(); 01478 01479 /* if( folder_kdelibs ) 01480 folder_kdelibs->refresh();*/ 01481 01482 folder_devhelp.setAutoDelete(true); 01483 folder_devhelp.clear(); 01484 folder_devhelp.setAutoDelete(false); 01485 01486 KStandardDirs *dirs = DocTreeViewFactory::instance()->dirs(); 01487 QStringList dhtocs = dirs->findAllResources("docdevhelp", QString::null, false, true); 01488 QStringList ignoredh( DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoredevhelp", "toc") ); 01489 01490 for (QStringList::Iterator tit = dhtocs.begin(); tit != dhtocs.end(); ++tit) 01491 { 01492 if( !ignoredh.contains( QFileInfo(*tit).baseName() ) ) 01493 folder_devhelp.append(new DocTreeDevHelpFolder(docView, *tit, QString("ctx_%1").arg(*tit))); 01494 } 01495 01496 01497 DocTreeTocFolder *item; 01498 for ( item = folder_toc.first(); item; item = folder_toc.next() ) 01499 delete item; 01500 01501 folder_toc.clear(); 01502 01503 QStringList tocs = dirs->findAllResources("doctocs", QString::null, false, true); 01504 QStringList ignore( DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoretocs", "toc") ); 01505 01506 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit) 01507 { 01508 if( !ignore.contains( QFileInfo(*tit).baseName() ) ) 01509 folder_toc.append(new DocTreeTocFolder(docView, *tit, QString("ctx_%1").arg(*tit))); 01510 } 01511 01512 folder_kdoc.setAutoDelete(true); 01513 folder_kdoc.clear(); 01514 folder_kdoc.setAutoDelete(false); 01515 01516 KConfig *config = DocTreeViewFactory::instance()->config(); 01517 if (config) 01518 { 01519 QStringList ignorekdocs( DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignorekdocs", "toc") ); 01520 config->setGroup("General KDoc"); 01521 QMap<QString, QString> emap = config->entryMap("General KDoc"); 01522 QMap<QString, QString>::Iterator it; 01523 for (it = emap.begin(); it != emap.end(); ++it) 01524 { 01525 if (!ignorekdocs.contains(it.key())) 01526 { 01527 DocTreeKDELibsFolder *kdf = new DocTreeKDELibsFolder(it.data(), it.key(), docView, "ctx_kdelibs"); 01528 kdf->refresh(); 01529 folder_kdoc.append(kdf); 01530 } 01531 } 01532 } 01533 01534 folder_doxygen.setAutoDelete(true); 01535 folder_doxygen.clear(); 01536 folder_doxygen.setAutoDelete(false); 01537 01538 if (config) 01539 { 01540 QStringList ignoredoxygen( DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoredoxygen", "toc") ); 01541 config->setGroup("General Doxygen"); 01542 QMap<QString, QString> emap = config->entryMap("General Doxygen"); 01543 QMap<QString, QString>::Iterator it; 01544 for (it = emap.begin(); it != emap.end(); ++it) 01545 { 01546 if (!ignoredoxygen.contains(it.key())) 01547 { 01548 DocTreeDoxygenFolder *dxf = new DocTreeDoxygenFolder(it.data(), it.key(), docView, "ctx_doxygen"); 01549 dxf->refresh(); 01550 folder_doxygen.append(dxf); 01551 } 01552 } 01553 } 01554 01555 01556 folder_qt.setAutoDelete(true); 01557 folder_qt.clear(); 01558 folder_qt.setAutoDelete(false); 01559 01560 if (config) 01561 { 01562 QStringList ignoreqt_xml( DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoreqt_xml", "toc") ); 01563 config->setGroup("General Qt"); 01564 QMap<QString, QString> emap = config->entryMap("General Qt"); 01565 QMap<QString, QString>::Iterator it; 01566 for (it = emap.begin(); it != emap.end(); ++it) 01567 { 01568 if (!ignoreqt_xml.contains(it.key())) 01569 { 01570 DocTreeQtFolder *qtf = new DocTreeQtFolder(it.data(), it.key(), docView, "ctx_qt"); 01571 qtf->refresh(); 01572 folder_qt.append(qtf); 01573 } 01574 } 01575 } 01576 } 01577 01578 01579 void DocTreeViewWidget::projectChanged(KDevProject *project) 01580 { 01581 folder_project->setProject(project); 01582 folder_project->refresh(); 01583 if(!project) 01584 { 01585 kdDebug(9002) << "No Project...." << endl; 01586 return; 01587 } 01588 01589 01590 // Remove all... 01591 docView->takeItem(folder_bookmarks); 01592 docView->takeItem(folder_project); 01593 #ifdef WITH_DOCBASE 01594 docView->takeItem(folder_docbase); 01595 #endif 01596 QPtrListIterator<DocTreeDevHelpFolder> itdh(folder_devhelp); 01597 for (; itdh.current(); ++itdh) 01598 docView->takeItem(itdh.current()); 01599 01600 QPtrListIterator<DocTreeTocFolder> it1(folder_toc); 01601 for (; it1.current(); ++it1) 01602 docView->takeItem(it1.current()); 01603 01604 QPtrListIterator<DocTreeKDELibsFolder> itk(folder_kdoc); 01605 for (; itk.current(); ++itk) 01606 docView->takeItem(itk.current()); 01607 // if(folder_doxygen) docView->takeItem(folder_doxygen); 01608 QPtrListIterator<DocTreeDoxygenFolder> itx(folder_doxygen); 01609 for (; itx.current(); ++itx) 01610 docView->takeItem(itx.current()); 01611 01612 QPtrListIterator<DocTreeQtFolder> itq(folder_qt); 01613 for (; itq.current(); ++itq) 01614 docView->takeItem(itq.current()); 01615 // if(folder_qt) docView->takeItem(folder_qt); 01616 // if(folder_kdelibs) docView->takeItem(folder_kdelibs); 01617 // docView->takeItem(folder_kdevelop); 01618 01619 // .. and insert all again except for ignored items 01620 QStringList ignoretocs = DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoretocs", "toc"); 01621 QStringList ignoredh = DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoredevhelp", "toc"); 01622 QStringList ignoredoxygen = DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoredoxygen", "toc"); 01623 QStringList ignorekdocs = DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignorekdocs", "toc"); 01624 QStringList ignoreqt_xml = DomUtil::readListEntry(*m_part->projectDom(), "/kdevdoctreeview/ignoreqt_xml", "toc"); 01625 01626 docView->insertItem(folder_bookmarks); 01627 docView->insertItem(folder_project); 01628 #ifdef WITH_DOCBASE 01629 docView->insertItem(folder_docbase); 01630 #endif 01631 QPtrListIterator<DocTreeDevHelpFolder> itdh2(folder_devhelp); 01632 for (; itdh2.current(); ++itdh2) 01633 { 01634 if (!ignoredh.contains(itdh2.current()->tocName())) 01635 docView->insertItem(itdh2.current()); 01636 } 01637 01638 QPtrListIterator<DocTreeTocFolder> it2(folder_toc); 01639 // it2.toLast(); 01640 // for (; it2.current(); --it2) { 01641 for (; it2.current(); ++it2) 01642 { 01643 if (!ignoretocs.contains(it2.current()->tocName())) 01644 docView->insertItem(it2.current()); 01645 } 01646 01647 // docView->insertItem(folder_doxygen); 01648 QPtrListIterator<DocTreeKDELibsFolder> itk2(folder_kdoc); 01649 // itk2.toLast(); 01650 // for (; itk2.current(); --itk2) 01651 for (; itk2.current(); ++itk2) 01652 { 01653 if (!ignorekdocs.contains(itk2.current()->text(0))) 01654 docView->insertItem(itk2.current()); 01655 } 01656 01657 QPtrListIterator<DocTreeDoxygenFolder> itx2(folder_doxygen); 01658 // itx2.toLast(); 01659 // for (; itx2.current(); --itx2) 01660 for (; itx2.current(); ++itx2) 01661 { 01662 if (!ignoredoxygen.contains(itx2.current()->text(0))) 01663 docView->insertItem(itx2.current()); 01664 } 01665 01666 /* if(folder_kdelibs && kdelibskdoc ) 01667 if (!ignoretocs.contains("kde")) 01668 docView->insertItem(folder_kdelibs); 01669 */ 01670 QPtrListIterator<DocTreeQtFolder> itq2(folder_qt); 01671 // itq2.toLast(); 01672 // for (; itq2.current(); --itq2) 01673 for (; itq2.current(); ++itq2) 01674 { 01675 if (!ignoreqt_xml.contains(itq2.current()->text(0))) 01676 docView->insertItem(itq2.current()); 01677 } 01678 // if(folder_qt) docView->insertItem(folder_qt); 01679 01680 docView->triggerUpdate(); 01681 } 01682 01683 01684 QString DocTreeViewWidget::locatehtml(const QString &fileName) 01685 { 01686 01687 QString path = locate("html", KGlobal::locale()->language() + '/' + fileName); 01688 if (path.isNull()) 01689 path = locate("html", "default/" + fileName); 01690 01691 return path; 01692 } 01693 01694 01695 void DocTreeViewWidget::slotAddBookmark() 01696 { 01697 DocTreeItem *item = dynamic_cast<DocTreeItem*>( contextItem ); 01698 if( item ) 01699 { 01700 DocTreeViewTool::addBookmark( item->text(0), item->fileName() ); 01701 folder_bookmarks->refresh(); 01702 } 01703 } 01704 01705 void DocTreeViewWidget::slotRemoveBookmark() 01706 { 01707 DocTreeItem *item = dynamic_cast<DocTreeItem*>( contextItem ); 01708 if( item ) 01709 { 01710 int posFolder = docView->itemIndex( folder_bookmarks ); 01711 int i = docView->itemIndex( item ) - posFolder; 01712 //kdDebug(9002) << "remove item: " << i << endl; 01713 01714 DocTreeViewTool::removeBookmark( i ); 01715 01716 folder_bookmarks->refresh(); 01717 } 01718 } 01719 01720 /* INDEX MODE SLOTS */ 01721 01722 void DocTreeViewWidget::slotFilterTextChanged(const QString &nt) 01723 { 01724 int res; 01725 QListViewItemIterator docViewIterator( indexView ); 01726 QListViewItem *it = 0; 01727 01728 while( docViewIterator.current() ) 01729 { 01730 res = docViewIterator.current()->text(0).find(nt, 0, false); 01731 // Not listed OR substring but !bSub 01732 if( (res == -1) || (!subStringSearch && (res > 0)) ) docViewIterator.current()->setVisible(false); 01733 else 01734 { 01735 if (it == 0) it = docViewIterator.current(); 01736 docViewIterator.current()->setVisible(true); 01737 } 01738 01739 ++docViewIterator; 01740 } 01741 if (it) 01742 indexView->setCurrentItem(it); 01743 } 01744 01745 void DocTreeViewWidget::slotFilterReturn() 01746 { 01747 indexView->setFocus(); 01748 /* if (indexView->currentItem()) 01749 { 01750 indexView->setFocus(); 01751 slotItemExecuted(indexView->currentItem()); 01752 }*/ 01753 } 01754 01755 void DocTreeViewWidget::slotIndexItemExecuted(QListViewItem *item) 01756 { 01757 IndexTreeData *itd; 01758 QPtrList<IndexTreeData> *resultList; 01759 01760 if (!item) return; 01761 01762 QString ident = item->text(0); 01763 if (ident.isEmpty()) return; 01764 01765 QPtrListIterator<IndexTreeData> ptrListIterator( indexItems ); 01766 resultList = new QPtrList<IndexTreeData>(); 01767 01768 while( ptrListIterator.current() ) 01769 { 01770 itd = static_cast<IndexTreeData *>(ptrListIterator.current()); 01771 01772 if((indexMode == filteredMode) && (itd->text() == ident)) resultList->append(itd); 01773 else if((indexMode == plainListMode) && ((itd->text() + " (" + itd->parent() + ")") == ident)) resultList->append(itd); 01774 ++ptrListIterator; 01775 } 01776 01777 if(resultList->count() == 0) 01778 { 01779 } 01780 else if(resultList->count() == 1) 01781 { 01782 m_part->partController()->showDocument(resultList->first()->fileName(), ident); 01783 m_part->mainWindow()->lowerView(this); 01784 } 01785 else 01786 { 01787 ChooseDlg chooseDlg(this, "choose dlg", m_part); 01788 chooseDlg.setList(resultList); 01789 chooseDlg.exec(); 01790 } 01791 01792 delete resultList; 01793 } 01794 01795 void DocTreeViewWidget::filterMultiReferences() 01796 { 01797 bool bFound; 01798 IndexTreeData *itd; 01799 IndexTreeData *itd2; 01800 01801 QPtrListIterator<IndexTreeData> ptrListIterator( indexItems ); 01802 while( ptrListIterator.current() ) 01803 { 01804 itd = static_cast<IndexTreeData *>(ptrListIterator.current()); 01805 bFound = false; 01806 01807 QPtrListIterator<IndexTreeData> ptrListIterator2( indexItems ); 01808 while( ptrListIterator2.current() ) 01809 { 01810 itd2 = static_cast<IndexTreeData *>(ptrListIterator2.current()); 01811 01812 if( itd2->isVisible() && (itd2->text() == itd->text()) ) 01813 { 01814 bFound = true; 01815 break; 01816 } 01817 ++ptrListIterator2; 01818 } 01819 01820 // Make it visible ! 01821 if(bFound == false) itd->setVisible(true); 01822 01823 qApp->processEvents(); 01824 ++ptrListIterator; 01825 } 01826 } 01827 01828 void DocTreeViewWidget::slotCurrentTabChanged(int curtab) 01829 { 01830 IndexTreeData *iI; 01831 01832 if((curtab == 1) && (indexView->childCount() == 0)) 01833 { 01834 // Index list not created yet 01835 QProgressDialog progress(i18n("Generating Index..."), 0, 100, this, "progDialog", true); 01836 01837 indexItems.clear(); 01838 progress.setProgress(0); 01839 01840 /* Load Data out of the DocView -> easier changes later, but bit slower*/ 01841 QListViewItemIterator docViewIterator( docView ); 01842 while( docViewIterator.current() ) 01843 { 01844 // Load this category 01845 docViewIterator.current()->setOpen(true); 01846 docViewIterator.current()->setOpen(false); 01847 01848 DocTreeItem *dtitem = static_cast<DocTreeItem*>(docViewIterator.current()); 01849 01850 // Save them in a list 01851 iI = new IndexTreeData(dtitem->text(0), (dtitem->parent() != 0) ? dtitem->parent()->text(0) : QString(" "), dtitem->fileName()); 01852 indexItems.append(iI); 01853 01854 qApp->processEvents(); 01855 ++docViewIterator; 01856 } 01857 progress.setProgress(30); 01858 01859 // filterMultiReferences(); 01860 01861 progress.setProgress(90); 01862 01863 // Put them in the list 01864 slotIndexModeCheckClicked(); 01865 01866 progress.setProgress(100); 01867 } 01868 } 01869 01870 void DocTreeViewWidget::slotSubstringCheckClicked() 01871 { 01872 subStringSearch = !subStringSearch; 01873 slotFilterTextChanged(filterEdit->text()); 01874 } 01875 01876 void DocTreeViewWidget::slotIndexModeCheckClicked() 01877 { 01878 QString s; 01879 01880 if(indexMode == filteredMode) indexMode = plainListMode; 01881 else indexMode = filteredMode; 01882 01883 indexView->clear(); 01884 01885 QPtrListIterator<IndexTreeData> ptrListIterator( indexItems ); 01886 while( ptrListIterator.current() ) 01887 { 01888 IndexTreeData *itd = static_cast<IndexTreeData *>(ptrListIterator.current()); 01889 01890 if(indexMode == plainListMode) s = itd->text() + " (" + itd->parent() + ")"; 01891 else s = itd->text(); 01892 01893 if((indexMode == plainListMode) || itd->isVisible()) new QListViewItem(indexView, s); 01894 01895 ++ptrListIterator; 01896 } 01897 01898 slotFilterTextChanged(filterEdit->text()); 01899 } 01900 01901 void DocTreeViewWidget::slotIndexNextMatch( ) 01902 { 01903 if (indexView->currentItem()) 01904 { 01905 QListViewItem *below = indexView->currentItem()->itemBelow(); 01906 if (below) 01907 { 01908 indexView->setCurrentItem(below); 01909 indexView->ensureItemVisible(below); 01910 } 01911 } 01912 } 01913 01914 void DocTreeViewWidget::slotIndexPrevMatch( ) 01915 { 01916 if (indexView->currentItem()) 01917 { 01918 QListViewItem *above = indexView->currentItem()->itemAbove(); 01919 if (above) 01920 { 01921 indexView->setCurrentItem(above); 01922 indexView->ensureItemVisible(above); 01923 } 01924 } 01925 } 01926 01927 void DocTreeViewWidget::slotIndexPgUp( ) 01928 { 01929 } 01930 01931 void DocTreeViewWidget::slotIndexPgDown( ) 01932 { 01933 /* if (indexView->currentItem()) 01934 { 01935 QListViewItem *below = indexView->currentItem()->itemBelow(); 01936 while ( (below) && (below->isVisible()) ) 01937 { 01938 below = below->itemBelow(); 01939 } 01940 if (below) 01941 { 01942 indexView->setCurrentItem(below); 01943 indexView->ensureItemVisible(below); 01944 } 01945 }*/ 01946 } 01947 01948 void DocTreeViewWidget::slotIndexHome( ) 01949 { 01950 /* QListViewItem *item = indexView->firstChild(); 01951 if (item) 01952 { 01953 indexView->setCurrentItem(item); 01954 indexView->ensureItemVisible(item); 01955 }*/ 01956 } 01957 01958 void DocTreeViewWidget::slotIndexEnd( ) 01959 { 01960 /* QListViewItem *item = indexView->lastItem(); 01961 if (item) 01962 { 01963 indexView->setCurrentItem(item); 01964 indexView->ensureItemVisible(item); 01965 }*/ 01966 } 01967 01968 #include "doctreeviewwidget.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:51 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003