#include <helpdialog.h>
Inheritance diagram for HelpDialog:


Definition at line 69 of file helpdialog.h.
typedef QList<ContentItem> HelpDialog::ContentList [private] |
Definition at line 125 of file helpdialog.h.
| HelpDialog::HelpDialog | ( | QWidget * | parent, | |
| MainWindow * | h | |||
| ) |
Definition at line 216 of file helpdialog.cpp.
References QListView::Batched, indexModel, QHeaderView::ResizeToContents, and ui.
00217 : QWidget(parent), lwClosed(false), help(h) 00218 { 00219 ui.setupUi(this); 00220 ui.listContents->setUniformRowHeights(true); 00221 ui.listContents->header()->setStretchLastSection(false); 00222 ui.listContents->header()->setResizeMode(QHeaderView::ResizeToContents); 00223 ui.listBookmarks->setUniformRowHeights(true); 00224 ui.listBookmarks->header()->setStretchLastSection(false); 00225 ui.listBookmarks->header()->setResizeMode(QHeaderView::ResizeToContents); 00226 00227 indexModel = new IndexListModel(this); 00228 ui.listIndex->setModel(indexModel); 00229 ui.listIndex->setLayoutMode(QListView::Batched); 00230 ui.listBookmarks->setItemHidden(ui.listBookmarks->headerItem(), true); 00231 ui.listContents->setItemHidden(ui.listContents->headerItem(), true); 00232 }
| QTabWidget* HelpDialog::tabWidget | ( | ) | const [inline] |
Definition at line 75 of file helpdialog.h.
References ui.
Referenced by MainWindow::saveSettings(), and MainWindow::setup().
00076 { return ui.tabWidget; }
Definition at line 693 of file helpdialog.cpp.
References removeAnchorFromLink(), s, and titleMap.
Referenced by addBookmark(), showIndexItemMenu(), and showIndexTopic().
00694 { 00695 QString s = HelpDialog::removeAnchorFromLink(link); 00696 s = titleMap[s]; 00697 if (s.isEmpty()) 00698 return link; 00699 return s; 00700 }
Here is the call graph for this function:

Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Example:
class MainWindow : public QMainWindow { public: MainWindow(); protected: bool eventFilter(QObject *obj, QEvent *ev); private: QTextEdit *textEdit; }; MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit); textEdit->installEventFilter(this); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); qDebug() << "Ate key press" << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Reimplemented from QObject.
Definition at line 702 of file helpdialog.cpp.
References QObject::eventFilter(), key, Qt::Key_Down, Qt::Key_PageDown, Qt::Key_PageUp, Qt::Key_Up, QEvent::KeyPress, Qt::LeftButton, QEvent::MouseButtonRelease, o, QCoreApplication::sendEvent(), showTopic(), QEvent::type(), and ui.
00703 { 00704 if (o == ui.editIndex && e->type() == QEvent::KeyPress) { 00705 switch (static_cast<QKeyEvent*>(e)->key()) { 00706 case Qt::Key_Up: 00707 case Qt::Key_Down: 00708 case Qt::Key_PageDown: 00709 case Qt::Key_PageUp: 00710 QApplication::sendEvent(ui.listIndex, e); 00711 break; 00712 00713 default: 00714 break; 00715 } 00716 } else if (o == ui.listContents->viewport()) 00717 if (e->type() == QEvent::MouseButtonRelease) { 00718 QMouseEvent *me = static_cast<QMouseEvent*>(e); 00719 if (me->button() == Qt::LeftButton) { 00720 QTreeWidgetItem *item = ui.listContents->itemAt(me->pos()); 00721 if (item) 00722 showTopic(item); 00723 } 00724 } 00725 00726 return QWidget::eventFilter(o, e); 00727 }
Here is the call graph for this function:

| bool HelpDialog::lastWindowClosed | ( | ) | [inline] |
Definition at line 80 of file helpdialog.h.
References lwClosed.
Referenced by initialize().
00080 { return lwClosed; }
| void HelpDialog::timerEvent | ( | QTimerEvent * | e | ) | [virtual] |
This event handler can be reimplemented in a subclass to receive timer events for the object.
QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.
Reimplemented from QObject.
Definition at line 325 of file helpdialog.cpp.
References help, qApp, and QWidget::setWindowOpacity().
00326 { 00327 Q_UNUSED(e); 00328 static int opacity = 255; 00329 help->setWindowOpacity((opacity-=4)/255.0); 00330 if (opacity<=0) 00331 qApp->quit(); 00332 }
Here is the call graph for this function:

Definition at line 1273 of file helpdialog.cpp.
References i, j, l, QString::lastIndexOf(), QString::left(), QString::length(), QString::mid(), and QDir::separator().
Referenced by HelpNavigationListItem::addLink(), loadIndexFile(), setupFullTextIndex(), and titleOfLink().
01274 { 01275 int i = link.length(); 01276 int j = link.lastIndexOf('/'); 01277 int l = link.lastIndexOf(QDir::separator()); 01278 if (l > j) 01279 j = l; 01280 if (j > -1) { 01281 QString fileName = link.mid(j+1); 01282 int k = fileName.lastIndexOf('#'); 01283 if (k > -1) 01284 i = j + k + 1; 01285 } 01286 return link.left(i); 01287 }
Here is the call graph for this function:

| void HelpDialog::showLink | ( | const QString & | s | ) | [signal] |
Referenced by on_helpButton_clicked(), showBookmarkTopic(), showContentsTopic(), and showIndexTopic().
| void HelpDialog::showSearchLink | ( | const QString & | s, | |
| const QStringList & | terms | |||
| ) | [signal] |
Referenced by showResultPage().
| void HelpDialog::initialize | ( | ) | [slot] |
Definition at line 234 of file helpdialog.cpp.
References actionOpenCurrentTab, actionOpenLinkInNewTab, actionOpenLinkInNewWindow, QMenu::addAction(), bookmarksInserted, cacheFilesPath, QObject::connect(), contentList, contentsInserted, currentTabChanged(), QWidget::customContextMenuRequested(), Qt::ElideNone, fullTextIndex, QDir::homePath(), indexDone, initDoneMsgShown, itemPopup, lastWinClosed(), lastWindowClosed(), qApp, searchInIndex(), QAction::setText(), setupTitleMap(), showIndexItemMenu(), showListItemMenu(), showTopic(), showTreeItemMenu(), SIGNAL, SLOT, titleMapDone, and ui.
Referenced by MainWindow::setup().
00235 { 00236 connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); 00237 00238 connect(ui.listContents, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(showTopic(QTreeWidgetItem*))); 00239 connect(ui.listContents, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTreeItemMenu(QPoint))); 00240 ui.listContents->viewport()->installEventFilter(this); 00241 00242 connect(ui.editIndex, SIGNAL(returnPressed()), this, SLOT(showTopic())); 00243 connect(ui.editIndex, SIGNAL(textEdited(QString)), this, SLOT(searchInIndex(QString))); 00244 00245 connect(ui.listIndex, SIGNAL(activated(QModelIndex)), this, SLOT(showTopic())); 00246 connect(ui.listIndex, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showIndexItemMenu(QPoint))); 00247 00248 connect(ui.listBookmarks, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(showTopic(QTreeWidgetItem*))); 00249 connect(ui.listBookmarks, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTreeItemMenu(QPoint))); 00250 00251 connect(ui.resultBox, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showListItemMenu(QPoint))); 00252 00253 cacheFilesPath = QDir::homePath() + QLatin1String("/.assistant"); //### Find a better location for the dbs 00254 00255 ui.editIndex->installEventFilter(this); 00256 00257 ui.framePrepare->hide(); 00258 connect(qApp, SIGNAL(lastWindowClosed()), SLOT(lastWinClosed())); 00259 00260 ui.termsEdit->setValidator(new SearchValidator(ui.termsEdit)); 00261 00262 actionOpenCurrentTab = new QAction(this); 00263 actionOpenCurrentTab->setText(tr("Open Link in Current Tab")); 00264 00265 actionOpenLinkInNewWindow = new QAction(this); 00266 actionOpenLinkInNewWindow->setText(tr("Open Link in New Window")); 00267 00268 actionOpenLinkInNewTab = new QAction(this); 00269 actionOpenLinkInNewTab->setText(tr("Open Link in New Tab")); 00270 00271 itemPopup = new QMenu(this); 00272 itemPopup->addAction(actionOpenCurrentTab); 00273 itemPopup->addAction(actionOpenLinkInNewWindow); 00274 itemPopup->addAction(actionOpenLinkInNewTab); 00275 00276 ui.tabWidget->setElideMode(Qt::ElideNone); 00277 00278 contentList.clear(); 00279 00280 initDoneMsgShown = false; 00281 fullTextIndex = 0; 00282 indexDone = false; 00283 titleMapDone = false; 00284 contentsInserted = false; 00285 bookmarksInserted = false; 00286 setupTitleMap(); 00287 00288 }
| void HelpDialog::startSearch | ( | ) | [slot] |
Definition at line 1076 of file helpdialog.cpp.
References QString::arg(), Qt::ArrowCursor, QList< T >::begin(), buf, QList< T >::clear(), QString::contains(), QString::count(), QList< T >::count(), QList< T >::end(), foundDocs, QString::fromLatin1(), fullTextIndex, Index::getDocumentTitle(), help, i, QString::indexOf(), int, QList< QString >::iterator, QString::mid(), Index::query(), QString::replace(), s, QWidget::setCursor(), QStatusBar::showMessage(), QString::simplified(), QString::split(), QMainWindow::statusBar(), terms, QString::toUtf8(), ui, Qt::WaitCursor, and QMessageBox::warning().
Referenced by on_searchButton_clicked(), and on_termsEdit_returnPressed().
01077 { 01078 QString str = ui.termsEdit->text(); 01079 str = str.simplified(); 01080 str = str.replace(QLatin1String("\'"), QLatin1String("\"")); 01081 str = str.replace(QLatin1String("`"), QLatin1String("\"")); 01082 QString buf = str; 01083 str = str.replace(QLatin1String("-"), QLatin1String(" ")); 01084 str = str.replace(QRegExp(QLatin1String("\\s[\\S]?\\s")), QLatin1String(" ")); 01085 terms = str.split(QLatin1Char(' ')); 01086 QStringList termSeq; 01087 QStringList seqWords; 01088 QStringList::iterator it = terms.begin(); 01089 for (; it != terms.end(); ++it) { 01090 (*it) = (*it).simplified(); 01091 (*it) = (*it).toLower(); 01092 (*it) = (*it).replace(QLatin1String("\""), QLatin1String("")); 01093 } 01094 if (str.contains(QLatin1Char('\"'))) { 01095 if ((str.count(QLatin1Char('\"')))%2 == 0) { 01096 int beg = 0; 01097 int end = 0; 01098 QString s; 01099 beg = str.indexOf(QLatin1Char('\"'), beg); 01100 while (beg != -1) { 01101 beg++; 01102 end = str.indexOf(QLatin1Char('\"'), beg); 01103 s = str.mid(beg, end - beg); 01104 s = s.toLower(); 01105 s = s.simplified(); 01106 if (s.contains(QLatin1Char('*'))) { 01107 QMessageBox::warning(this, tr("Full Text Search"), 01108 tr("Using a wildcard within phrases is not allowed.")); 01109 return; 01110 } 01111 seqWords += s.split(QLatin1Char(' ')); 01112 termSeq << s; 01113 beg = str.indexOf(QLatin1Char('\"'), end + 1); 01114 } 01115 } else { 01116 QMessageBox::warning(this, tr("Full Text Search"), 01117 tr("The closing quotation mark is missing.")); 01118 return; 01119 } 01120 } 01121 setCursor(Qt::WaitCursor); 01122 foundDocs.clear(); 01123 foundDocs = fullTextIndex->query(terms, termSeq, seqWords); 01124 QString msg = QString::fromLatin1("%1 documents found.").arg(foundDocs.count()); 01125 help->statusBar()->showMessage(tr(msg.toUtf8()), 3000); 01126 ui.resultBox->clear(); 01127 for (it = foundDocs.begin(); it != foundDocs.end(); ++it) 01128 ui.resultBox->addItem(fullTextIndex->getDocumentTitle(*it)); 01129 01130 terms.clear(); 01131 bool isPhrase = false; 01132 QString s; 01133 for (int i = 0; i < (int)buf.length(); ++i) { 01134 if (buf[i] == QLatin1Char('\"')) { 01135 isPhrase = !isPhrase; 01136 s = s.simplified(); 01137 if (!s.isEmpty()) 01138 terms << s; 01139 s = QLatin1String(""); 01140 } else if (buf[i] == QLatin1Char(' ') && !isPhrase) { 01141 s = s.simplified(); 01142 if (!s.isEmpty()) 01143 terms << s; 01144 s = QLatin1String(""); 01145 } else 01146 s += buf[i]; 01147 } 01148 if (!s.isEmpty()) 01149 terms << s; 01150 01151 setCursor(Qt::ArrowCursor); 01152 }
| void HelpDialog::addBookmark | ( | ) | [slot] |
Definition at line 729 of file helpdialog.cpp.
References bookmarksInserted, MainWindow::browsers(), TabbedBrowser::currentBrowser(), QTextEdit::documentTitle(), help, i, insertBookmarks(), QString::isEmpty(), LinkRole, saveBookmarks(), QTextBrowser::source(), titleOfLink(), QUrl::toString(), ui, and MainWindow::updateBookmarkMenu().
Referenced by on_buttonAdd_clicked().
00730 { 00731 if (!bookmarksInserted) 00732 insertBookmarks(); 00733 QString link = help->browsers()->currentBrowser()->source().toString(); 00734 QString title = help->browsers()->currentBrowser()->documentTitle(); 00735 if (title.isEmpty()) 00736 title = titleOfLink(link); 00737 00738 QTreeWidgetItem *i = new QTreeWidgetItem(ui.listBookmarks, 0); 00739 i->setText(0, title); 00740 i->setData(0, LinkRole, link); 00741 saveBookmarks(); 00742 help->updateBookmarkMenu(); 00743 }
| void HelpDialog::currentTabChanged | ( | int | index | ) | [slot] |
Definition at line 598 of file helpdialog.cpp.
References insertBookmarks(), insertContents(), loadIndexFile(), s, setupFullTextIndex(), QTimer::singleShot(), SLOT, stripAmpersand(), and ui.
Referenced by initialize(), and MainWindow::setup().
00599 { 00600 QString s = ui.tabWidget->tabText(index); 00601 if (stripAmpersand(s).contains(tr("Index"))) 00602 QTimer::singleShot(0, this, SLOT(loadIndexFile())); 00603 else if (stripAmpersand(s).contains(tr("Bookmarks"))) 00604 insertBookmarks(); 00605 else if (stripAmpersand(s).contains(tr("Contents"))) 00606 QTimer::singleShot(0, this, SLOT(insertContents())); 00607 else if (stripAmpersand(s).contains(tr("Search"))) 00608 QTimer::singleShot(0, this, SLOT(setupFullTextIndex())); 00609 }
| void HelpDialog::locateContents | ( | const QString & | link | ) | [slot] |
Definition at line 923 of file helpdialog.cpp.
References Qt::CaseInsensitive, Qt::CaseSensitive, QString::contains(), contentsInserted, QTreeWidgetItem::data(), i, insertContents(), LinkRole, locateLink(), QString::replace(), QString::startsWith(), QVariant::toString(), and ui.
Referenced by MainWindow::on_actionSyncToc_triggered().
00924 { 00925 //ensure the TOC is filled 00926 if (!contentsInserted) 00927 insertContents(); 00928 #ifdef Q_OS_WIN 00929 Qt::CaseSensitivity checkCase = Qt::CaseInsensitive; 00930 #else 00931 Qt::CaseSensitivity checkCase = Qt::CaseSensitive; 00932 #endif 00933 QString findLink(link); 00934 //Installations on a windows local drive will give the 'link' as <file:///C:/xxx> 00935 //and the contents in the TOC will be <file:C:/xxx>. 00936 //But on others the 'link' of format <file:///root/xxx> 00937 //and the contents in the TOC will be <file:/root/xxx>. 00938 if (findLink.contains("file:///")) { 00939 if (findLink[9] == QChar(':')) //on windows drives 00940 findLink.replace(0, 8, "file:"); 00941 else 00942 findLink.replace(0, 8, "file:/"); 00943 } 00944 QTreeWidgetItem *item = 0; 00945 int i = 0, totalItems = ui.listContents->topLevelItemCount(); 00946 for (i = 0; i < totalItems; i++ ) { 00947 item = (QTreeWidgetItem*)ui.listContents->topLevelItem(i); 00948 if (findLink.startsWith(item->data(0, LinkRole).toString(), checkCase)) 00949 break; 00950 item = locateLink(item, findLink); 00951 if (item) 00952 break; 00953 } 00954 if ( i!= totalItems){ 00955 //remove the old selection 00956 QList<QTreeWidgetItem *> selected = ui.listContents->selectedItems(); 00957 QTreeWidgetItem *sel; 00958 foreach(sel, selected) 00959 ui.listContents->setItemSelected(sel, false); 00960 //set the TOC item and show. 00961 ui.listContents->setItemSelected(item, true); 00962 ui.listContents->scrollToItem(item); 00963 ui.tabWidget->setCurrentIndex(0); 00964 } 00965 }
| void HelpDialog::on_buttonAdd_clicked | ( | ) | [private, slot] |
Definition at line 745 of file helpdialog.cpp.
References addBookmark().
00746 { 00747 addBookmark(); 00748 }
| void HelpDialog::on_buttonRemove_clicked | ( | ) | [private, slot] |
Definition at line 750 of file helpdialog.cpp.
References help, saveBookmarks(), ui, and MainWindow::updateBookmarkMenu().
00751 { 00752 if (!ui.listBookmarks->currentItem()) 00753 return; 00754 00755 delete ui.listBookmarks->currentItem(); 00756 saveBookmarks(); 00757 if (ui.listBookmarks->topLevelItemCount() != 0) { 00758 ui.listBookmarks->setCurrentItem(ui.listBookmarks->topLevelItem(0)); 00759 } 00760 help->updateBookmarkMenu(); 00761 }
| void HelpDialog::on_termsEdit_returnPressed | ( | ) | [private, slot] |
Definition at line 1263 of file helpdialog.cpp.
References startSearch().
01264 { 01265 startSearch(); 01266 }
| void HelpDialog::on_helpButton_clicked | ( | ) | [private, slot] |
Definition at line 1154 of file helpdialog.cpp.
References Config::configuration(), emit, showLink(), and MainWindow::urlifyFileName().
01155 { 01156 emit showLink(MainWindow::urlifyFileName( 01157 Config::configuration()->assistantDocPath() + 01158 QLatin1String("/assistant-manual.html#full-text-searching"))); 01159 }
| void HelpDialog::on_searchButton_clicked | ( | ) | [private, slot] |
Definition at line 1268 of file helpdialog.cpp.
References startSearch().
01269 { 01270 startSearch(); 01271 }
| void HelpDialog::on_resultBox_itemActivated | ( | QListWidgetItem * | ) | [private, slot] |
Definition at line 1161 of file helpdialog.cpp.
References showResultPage().
01162 { 01163 showResultPage(item); 01164 }
| void HelpDialog::showResultPage | ( | QListWidgetItem * | ) | [private, slot] |
Definition at line 1166 of file helpdialog.cpp.
References emit, foundDocs, showSearchLink(), terms, and ui.
Referenced by on_resultBox_itemActivated(), and showListItemMenu().
01167 { 01168 if (item) 01169 emit showSearchLink(foundDocs[ui.resultBox->row(item)], terms); 01170 }
| void HelpDialog::showTopic | ( | QTreeWidgetItem * | ) | [private, slot] |
Definition at line 619 of file helpdialog.cpp.
References showTopic().
00620 { 00621 if (item) 00622 showTopic(); 00623 }
| void HelpDialog::loadIndexFile | ( | ) | [private, slot] |
Definition at line 335 of file helpdialog.cpp.
References IndexListModel::addLink(), Qt::ArrowCursor, buildKeywordDB(), cacheFilesPath, QList< T >::clear(), QFile::close(), Config::configuration(), getFileAges(), help, i, indexDone, indexModel, keywordDocuments, lwClosed, QProgressBar::maximum(), QFile::open(), processEvents(), IndexListModel::publish(), QIODevice::ReadOnly, removeAnchorFromLink(), QDir::separator(), QWidget::setCursor(), QDataStream::setDevice(), QProgressBar::setMaximum(), QProgressBar::setValue(), showInitDoneMessage(), QObject::startTimer(), ui, Qt::WaitCursor, and QMessageBox::warning().
Referenced by currentTabChanged(), and setupFullTextIndex().
00336 { 00337 if (indexDone) 00338 return; 00339 00340 setCursor(Qt::WaitCursor); 00341 indexDone = true; 00342 ui.labelPrepare->setText(tr("Prepare...")); 00343 ui.framePrepare->show(); 00344 processEvents(); 00345 00346 QProgressBar *bar = ui.progressPrepare; 00347 bar->setMaximum(100); 00348 bar->setValue(0); 00349 00350 keywordDocuments.clear(); 00351 QList<IndexKeyword> lst; 00352 QFile indexFile(cacheFilesPath + QDir::separator() + QLatin1String("indexdb40.") + 00353 Config::configuration()->profileName()); 00354 if (!indexFile.open(QFile::ReadOnly)) { 00355 buildKeywordDB(); 00356 processEvents(); 00357 if(lwClosed) 00358 return; 00359 if (!indexFile.open(QFile::ReadOnly)) { 00360 QMessageBox::warning(help, tr("Qt Assistant"), tr("Failed to load keyword index file\n" 00361 "Assistant will not work!")); 00362 #if defined Q_WS_WIN || defined Q_WS_MACX 00363 startTimer(50); 00364 #endif 00365 return; 00366 } 00367 } 00368 00369 QDataStream ds(&indexFile); 00370 quint32 fileAges; 00371 ds >> fileAges; 00372 if (fileAges != getFileAges()) { 00373 indexFile.close(); 00374 buildKeywordDB(); 00375 if (!indexFile.open(QFile::ReadOnly)) { 00376 QMessageBox::warning(help, tr("Qt Assistant"), 00377 tr("Cannot open the index file %1").arg(QFileInfo(indexFile).absoluteFilePath())); 00378 return; 00379 } 00380 ds.setDevice(&indexFile); 00381 ds >> fileAges; 00382 } 00383 ds >> lst; 00384 indexFile.close(); 00385 00386 bar->setValue(bar->maximum()); 00387 processEvents(); 00388 00389 for (int i=0; i<lst.count(); ++i) { 00390 const IndexKeyword &idx = lst.at(i); 00391 indexModel->addLink(idx.keyword, idx.link); 00392 00393 keywordDocuments << HelpDialog::removeAnchorFromLink(idx.link); 00394 } 00395 00396 indexModel->publish(); 00397 00398 ui.framePrepare->hide(); 00399 showInitDoneMessage(); 00400 setCursor(Qt::ArrowCursor); 00401 }
| void HelpDialog::insertContents | ( | ) | [private, slot] |
Definition at line 819 of file helpdialog.cpp.
References Qt::ArrowCursor, QVector< T >::clear(), QList< T >::constBegin(), QList< T >::constEnd(), contentList, contentsInserted, QPaintDevice::depth(), getAllContents(), j, LinkRole, QStack< T >::pop(), processEvents(), QStack< T >::push(), QWidget::setCursor(), QTreeWidgetItem::setData(), QTreeWidgetItem::setText(), setupTitleMap(), showInitDoneMessage(), titleMapDone, QStack< T >::top(), ui, and Qt::WaitCursor.
Referenced by currentTabChanged(), and locateContents().
00820 { 00821 #ifdef Q_WS_MAC 00822 static const QLatin1String IconPath(":/trolltech/assistant/images/win/book.png"); 00823 #else 00824 static const QLatin1String IconPath(":/trolltech/assistant/images/win/book.png"); 00825 #endif 00826 if (contentsInserted) 00827 return; 00828 00829 if (contentList.isEmpty()) 00830 getAllContents(); 00831 00832 contentsInserted = true; 00833 ui.listContents->clear(); 00834 setCursor(Qt::WaitCursor); 00835 if (!titleMapDone) 00836 setupTitleMap(); 00837 00838 #if 0 // ### port me 00839 ui.listContents->setSorting(-1); 00840 #endif 00841 00842 for(QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) { 00843 QTreeWidgetItem *newEntry; 00844 00845 QTreeWidgetItem *contentEntry; 00846 QStack<QTreeWidgetItem*> stack; 00847 stack.clear(); 00848 int depth = 0; 00849 bool root = false; 00850 00851 QTreeWidgetItem *lastItem[64]; 00852 for(int j = 0; j < 64; ++j) 00853 lastItem[j] = 0; 00854 00855 ContentList lst = (*it).second; 00856 for (ContentList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it) { 00857 ContentItem item = *it; 00858 if (item.depth == 0) { 00859 newEntry = new QTreeWidgetItem(ui.listContents, 0); 00860 newEntry->setIcon(0, QIcon(IconPath)); 00861 newEntry->setText(0, item.title); 00862 newEntry->setData(0, LinkRole, item.reference); 00863 stack.push(newEntry); 00864 depth = 1; 00865 root = true; 00866 } 00867 else{ 00868 if((item.depth > depth) && root) { 00869 depth = item.depth; 00870 stack.push(contentEntry); 00871 } 00872 if(item.depth == depth) { 00873 contentEntry = new QTreeWidgetItem(stack.top(), lastItem[ depth ]); 00874 lastItem[ depth ] = contentEntry; 00875 contentEntry->setText(0, item.title); 00876 contentEntry->setData(0, LinkRole, item.reference); 00877 } 00878 else if(item.depth < depth) { 00879 stack.pop(); 00880 depth--; 00881 item = *(--it); 00882 } 00883 } 00884 } 00885 processEvents(); 00886 } 00887 setCursor(Qt::ArrowCursor); 00888 showInitDoneMessage(); 00889 }
| void HelpDialog::setupFullTextIndex | ( | ) | [private, slot] |
Definition at line 1008 of file helpdialog.cpp.
References Qt::ArrowCursor, QList< T >::begin(), cacheFilesPath, QList< T >::clear(), QStatusBar::clearMessage(), Config::configuration(), QObject::connect(), QMap< Key, T >::constBegin(), QMap< Key, T >::constEnd(), QList< T >::end(), QFile::exists(), fullTextIndex, help, QDir::homePath(), QSet< T >::insert(), QMap< Key, T >::key(), keywordDocuments, loadIndexFile(), Index::makeIndex(), processEvents(), Config::profileName(), Index::readDict(), removeAnchorFromLink(), QDir::separator(), QWidget::setCursor(), Index::setDictionaryFile(), Index::setDocList(), Index::setDocListFile(), setIndexingProgress(), showInitDoneMessage(), QStatusBar::showMessage(), SIGNAL, SLOT, QMainWindow::statusBar(), titleMap, QSet< T >::toList(), ui, verifyDirectory(), Qt::WaitCursor, QMessageBox::warning(), and Index::writeDict().
Referenced by currentTabChanged().
01009 { 01010 if (fullTextIndex) 01011 return; 01012 01013 QString pname = Config::configuration()->profileName(); 01014 fullTextIndex = new Index(QStringList(), QDir::homePath()); // ### Is this correct ? 01015 if (!verifyDirectory(cacheFilesPath)) { 01016 QMessageBox::warning(help, tr("Qt Assistant"), 01017 tr("Failed to save fulltext search index\n" 01018 "Assistant will not work!")); 01019 return; 01020 } 01021 fullTextIndex->setDictionaryFile(cacheFilesPath + QDir::separator() + QLatin1String("indexdb40.dict.") + pname); 01022 fullTextIndex->setDocListFile(cacheFilesPath + QDir::separator() + QLatin1String("indexdb40.doc.") + pname); 01023 processEvents(); 01024 01025 connect(fullTextIndex, SIGNAL(indexingProgress(int)), 01026 this, SLOT(setIndexingProgress(int))); 01027 QFile f(cacheFilesPath + QDir::separator() + QLatin1String("indexdb40.dict.") + pname); 01028 if (!f.exists()) { 01029 QString doc; 01030 QSet<QString> documentSet; 01031 QMap<QString, QString>::ConstIterator it = titleMap.constBegin(); 01032 for (; it != titleMap.constEnd(); ++it) { 01033 doc = HelpDialog::removeAnchorFromLink(it.key()); 01034 if (!doc.isEmpty()) 01035 documentSet.insert(doc); 01036 } 01037 loadIndexFile(); 01038 for ( QStringList::Iterator it = keywordDocuments.begin(); it != keywordDocuments.end(); ++it ) { 01039 if (!(*it).isEmpty()) 01040 documentSet.insert(*it); 01041 } 01042 fullTextIndex->setDocList( documentSet.toList() ); 01043 01044 help->statusBar()->clearMessage(); 01045 setCursor(Qt::WaitCursor); 01046 ui.labelPrepare->setText(tr("Indexing files...")); 01047 ui.progressPrepare->setMaximum(100); 01048 ui.progressPrepare->reset(); 01049 ui.progressPrepare->show(); 01050 ui.framePrepare->show(); 01051 processEvents(); 01052 if (fullTextIndex->makeIndex() == -1) 01053 return; 01054 fullTextIndex->writeDict(); 01055 ui.progressPrepare->setValue(100); 01056 ui.framePrepare->hide(); 01057 setCursor(Qt::ArrowCursor); 01058 showInitDoneMessage(); 01059 } else { 01060 setCursor(Qt::WaitCursor); 01061 help->statusBar()->showMessage(tr("Reading dictionary...")); 01062 processEvents(); 01063 fullTextIndex->readDict(); 01064 help->statusBar()->showMessage(tr("Done"), 3000); 01065 setCursor(Qt::ArrowCursor); 01066 } 01067 keywordDocuments.clear(); 01068 }
| void HelpDialog::showTopic | ( | ) | [private, slot] |
Definition at line 625 of file helpdialog.cpp.
References showBookmarkTopic(), showContentsTopic(), showIndexTopic(), stripAmpersand(), and ui.
Referenced by eventFilter(), initialize(), showIndexItemMenu(), and showTopic().
00626 { 00627 QString text = ui.tabWidget->tabText(ui.tabWidget->currentIndex()); 00628 00629 if (stripAmpersand(text).contains(tr("Index"))) 00630 showIndexTopic(); 00631 else if (stripAmpersand(text).contains(tr("Bookmarks"))) 00632 showBookmarkTopic(); 00633 else if (stripAmpersand(text).contains(tr("Contents"))) 00634 showContentsTopic(); 00635 }
| void HelpDialog::searchInIndex | ( | const QString & | s | ) | [private, slot] |
Definition at line 670 of file helpdialog.cpp.
References QString::contains(), QString::count(), IndexListModel::filter(), indexModel, QString::indexOf(), match(), QString::mid(), start, and ui.
Referenced by initialize().
00671 { 00672 QRegExp atoz("[A-Z]"); 00673 int matches = searchString.count(atoz); 00674 if (matches > 0 && !searchString.contains(".*")) 00675 { 00676 int start = 0; 00677 QString newSearch; 00678 for (; matches > 0; --matches) { 00679 int match = searchString.indexOf(atoz, start+1); 00680 if (match <= start) 00681 continue; 00682 newSearch += searchString.mid(start, match-start); 00683 newSearch += ".*"; 00684 start = match; 00685 } 00686 newSearch += searchString.mid(start); 00687 ui.listIndex->setCurrentIndex(indexModel->filter(newSearch, searchString)); 00688 } 00689 else 00690 ui.listIndex->setCurrentIndex(indexModel->filter(searchString, searchString)); 00691 }
| void HelpDialog::toggleContents | ( | ) | [private, slot] |
Definition at line 967 of file helpdialog.cpp.
References QWidget::hide(), QWidget::isVisible(), QWidget::parentWidget(), QWidget::show(), and ui.
00968 { 00969 if (!isVisible() || ui.tabWidget->currentIndex() != 0) { 00970 ui.tabWidget->setCurrentIndex(0); 00971 parentWidget()->show(); 00972 } 00973 else 00974 parentWidget()->hide(); 00975 }
| void HelpDialog::toggleIndex | ( | ) | [private, slot] |
Definition at line 977 of file helpdialog.cpp.
References QWidget::hide(), QWidget::isVisible(), QWidget::parentWidget(), QWidget::show(), and ui.
00978 { 00979 if (!isVisible() || ui.tabWidget->currentIndex() != 1 || !ui.editIndex->hasFocus()) { 00980 ui.tabWidget->setCurrentIndex(1); 00981 parentWidget()->show(); 00982 ui.editIndex->setFocus(); 00983 } 00984 else 00985 parentWidget()->hide(); 00986 }
| void HelpDialog::toggleBookmarks | ( | ) | [private, slot] |
Definition at line 988 of file helpdialog.cpp.
References QWidget::hide(), QWidget::isVisible(), QWidget::parentWidget(), QWidget::show(), and ui.
00989 { 00990 if (!isVisible() || ui.tabWidget->currentIndex() != 2) { 00991 ui.tabWidget->setCurrentIndex(2); 00992 parentWidget()->show(); 00993 } 00994 else 00995 parentWidget()->hide(); 00996 }
| void HelpDialog::toggleSearch | ( | ) | [private, slot] |
Definition at line 998 of file helpdialog.cpp.
References QWidget::hide(), QWidget::isVisible(), QWidget::parentWidget(), QWidget::show(), and ui.
00999 { 01000 if (!isVisible() || ui.tabWidget->currentIndex() != 3) { 01001 ui.tabWidget->setCurrentIndex(3); 01002 parentWidget()->show(); 01003 } 01004 else 01005 parentWidget()->hide(); 01006 }
| void HelpDialog::lastWinClosed | ( | ) | [private, slot] |
Definition at line 296 of file helpdialog.cpp.
References lwClosed.
Referenced by initialize().
00297 { 00298 lwClosed = true; 00299 }
| void HelpDialog::setIndexingProgress | ( | int | prog | ) | [private, slot] |
Definition at line 1070 of file helpdialog.cpp.
References processEvents(), and ui.
Referenced by setupFullTextIndex().
01071 { 01072 ui.progressPrepare->setValue(prog); 01073 processEvents(); 01074 }
| void HelpDialog::showListItemMenu | ( | const QPoint & | pos | ) | [private, slot] |
Definition at line 1214 of file helpdialog.cpp.
References actionOpenCurrentTab, actionOpenLinkInNewWindow, MainWindow::browsers(), TabbedBrowser::currentBrowser(), QMenu::exec(), foundDocs, help, QListWidget::itemAt(), itemPopup, QWidget::mapToGlobal(), HelpWindow::openLinkInNewPage(), HelpWindow::openLinkInNewWindow(), QWidget::pos(), QObject::sender(), showResultPage(), ui, and QAbstractScrollArea::viewport().
Referenced by initialize().
01215 { 01216 QListWidget *listWidget = qobject_cast<QListWidget*>(sender()); 01217 if (!listWidget) 01218 return; 01219 QListWidgetItem *item = listWidget->itemAt(pos); 01220 if (!item) 01221 return; 01222 01223 QAction *action = itemPopup->exec(listWidget->viewport()->mapToGlobal(pos)); 01224 if (action == actionOpenCurrentTab) { 01225 showResultPage(item); 01226 } else if (action) { 01227 HelpWindow *hw = help->browsers()->currentBrowser(); 01228 QString link = foundDocs[ui.resultBox->row(item)]; 01229 if (action == actionOpenLinkInNewWindow) 01230 hw->openLinkInNewWindow(link); 01231 else 01232 hw->openLinkInNewPage(link); 01233 } 01234 }
| void HelpDialog::showIndexItemMenu | ( | const QPoint & | pos | ) | [private, slot] |
Definition at line 1172 of file helpdialog.cpp.
References actionOpenCurrentTab, actionOpenLinkInNewWindow, QList< T >::begin(), MainWindow::browsers(), QList< T >::count(), TabbedBrowser::currentBrowser(), QModelIndex::data(), QList< T >::end(), QMenu::exec(), QList< T >::first(), TopicChooser::getLink(), help, QListView::indexAt(), indexModel, QString::isEmpty(), QModelIndex::isValid(), itemPopup, IndexListModel::links(), QWidget::mapToGlobal(), HelpWindow::openLinkInNewPage(), HelpWindow::openLinkInNewWindow(), QWidget::pos(), QModelIndex::row(), QObject::sender(), showTopic(), titleOfLink(), QVariant::toString(), ui, and QAbstractScrollArea::viewport().
Referenced by initialize().
01173 { 01174 QListView *listView = qobject_cast<QListView*>(sender()); 01175 if (!listView) 01176 return; 01177 01178 QModelIndex idx = listView->indexAt(pos); 01179 if (!idx.isValid()) 01180 return; 01181 01182 QAction *action = itemPopup->exec(listView->viewport()->mapToGlobal(pos)); 01183 if (action == actionOpenCurrentTab) { 01184 showTopic(); 01185 } else if (action) { 01186 HelpWindow *hw = help->browsers()->currentBrowser(); 01187 QString itemName = idx.data().toString(); 01188 ui.editIndex->setText(itemName); 01189 QStringList links = indexModel->links(idx.row()); 01190 if (links.count() == 1) { 01191 if (action == actionOpenLinkInNewWindow) 01192 hw->openLinkInNewWindow(links.first()); 01193 else 01194 hw->openLinkInNewPage(links.first()); 01195 } else { 01196 QStringList::Iterator it = links.begin(); 01197 QStringList linkList; 01198 QStringList linkNames; 01199 for (; it != links.end(); ++it) { 01200 linkList << *it; 01201 linkNames << titleOfLink(*it); 01202 } 01203 QString link = TopicChooser::getLink(this, linkNames, linkList, itemName); 01204 if (!link.isEmpty()) { 01205 if (action == actionOpenLinkInNewWindow) 01206 hw->openLinkInNewWindow(link); 01207 else 01208 hw->openLinkInNewPage(link); 01209 } 01210 } 01211 } 01212 }
| void HelpDialog::showTreeItemMenu | ( | const QPoint & | pos | ) | [private, slot] |
Definition at line 1236 of file helpdialog.cpp.
References actionOpenCurrentTab, actionOpenLinkInNewWindow, MainWindow::browsers(), QString::contains(), TabbedBrowser::currentBrowser(), QMenu::exec(), help, i, QTreeWidget::itemAt(), itemPopup, LinkRole, QWidget::mapToGlobal(), HelpWindow::openLinkInNewPage(), HelpWindow::openLinkInNewWindow(), QWidget::pos(), QObject::sender(), showBookmarkTopic(), showContentsTopic(), stripAmpersand(), ui, and QAbstractScrollArea::viewport().
Referenced by initialize().
01237 { 01238 QTreeWidget *treeWidget = qobject_cast<QTreeWidget*>(sender()); 01239 01240 if (!treeWidget) 01241 return; 01242 01243 QTreeWidgetItem *item = treeWidget->itemAt(pos); 01244 01245 if (!item) 01246 return; 01247 01248 QAction *action = itemPopup->exec(treeWidget->viewport()->mapToGlobal(pos)); 01249 if (action == actionOpenCurrentTab) { 01250 if (stripAmpersand(ui.tabWidget->tabText(ui.tabWidget->currentIndex())).contains(tr("Contents"))) 01251 showContentsTopic(); 01252 else 01253 showBookmarkTopic(); 01254 } else if (action) { 01255 QTreeWidgetItem *i = (QTreeWidgetItem*)item; 01256 if (action == actionOpenLinkInNewWindow) 01257 help->browsers()->currentBrowser()->openLinkInNewWindow(i->data(0, LinkRole).toString()); 01258 else 01259 help->browsers()->currentBrowser()->openLinkInNewPage(i->data(0, LinkRole).toString()); 01260 } 01261 }
| void HelpDialog::insertBookmarks | ( | ) | [private, slot] |
Definition at line 763 of file helpdialog.cpp.
References QTextStream::atEnd(), bookmarksInserted, cacheFilesPath, Config::configuration(), help, i, LinkRole, QFile::open(), QTextStream::readLine(), QIODevice::ReadOnly, QDir::separator(), showInitDoneMessage(), ui, and MainWindow::updateBookmarkMenu().
Referenced by addBookmark(), and currentTabChanged().
00764 { 00765 if (bookmarksInserted) 00766 return; 00767 bookmarksInserted = true; 00768 ui.listBookmarks->clear(); 00769 QFile f(cacheFilesPath + QDir::separator() + QLatin1String("bookmarks.") 00770 + Config::configuration()->profileName()); 00771 if (!f.open(QFile::ReadOnly)) 00772 return; 00773 QTextStream ts(&f); 00774 while (!ts.atEnd()) { 00775 QTreeWidgetItem *i = new QTreeWidgetItem(ui.listBookmarks, 0); 00776 i->setText(0, ts.readLine()); 00777 i->setData(0, LinkRole, ts.readLine()); 00778 } 00779 help->updateBookmarkMenu(); 00780 showInitDoneMessage(); 00781 }
| void HelpDialog::processEvents | ( | ) | [private, slot] |
Definition at line 290 of file helpdialog.cpp.
References QEventLoop::ExcludeUserInputEvents, and qApp.
Referenced by buildKeywordDB(), getAllContents(), insertContents(), loadIndexFile(), setIndexingProgress(), setupFullTextIndex(), and setupTitleMap().
00291 { 00292 qApp->processEvents(QEventLoop::ExcludeUserInputEvents); 00293 }
| void HelpDialog::removeOldCacheFiles | ( | bool | onlyFulltextSearchIndex = false |
) | [private] |
Definition at line 301 of file helpdialog.cpp.
References QList< T >::begin(), cacheFilesPath, Config::configuration(), QList< T >::end(), QFile::exists(), QList< QString >::iterator, Config::profileName(), qWarning(), QFile::remove(), QDir::separator(), and verifyDirectory().
Referenced by getAllContents(), and setupTitleMap().
00302 { 00303 if (!verifyDirectory(cacheFilesPath)) { 00304 qWarning("Failed to created assistant directory"); 00305 return; 00306 } 00307 QString pname = QLatin1String(".") + Config::configuration()->profileName(); 00308 00309 QStringList fileList; 00310 fileList << QLatin1String("indexdb40.dict") 00311 << QLatin1String("indexdb40.doc"); 00312 00313 if (!onlyFulltextSearchIndex) 00314 fileList << QLatin1String("indexdb40") << QLatin1String("contentdb40"); 00315 00316 QStringList::iterator it = fileList.begin(); 00317 for (; it != fileList.end(); ++it) { 00318 if (QFile::exists(cacheFilesPath + QDir::separator() + *it + pname)) { 00319 QFile f(cacheFilesPath + QDir::separator() + *it + pname); 00320 f.remove(); 00321 } 00322 } 00323 }
Here is the call graph for this function:

| void HelpDialog::buildKeywordDB | ( | ) | [private] |
Definition at line 418 of file helpdialog.cpp.
References QList< T >::append(), QString::arg(), QList< T >::begin(), cacheFilesPath, Config::configuration(), DocuParser::createParser(), QMessageBox::critical(), Config::docFiles(), QList< T >::end(), QString::fromLatin1(), handler, i, QList< T >::isEmpty(), QList< QString >::iterator, IndexItem::keyword, lwClosed, QFile::open(), processEvents(), qSort(), IndexItem::reference, s, QDir::separator(), QString::toUtf8(), ui, verifyDirectory(), QMessageBox::warning(), and QIODevice::WriteOnly.
Referenced by loadIndexFile().
00419 { 00420 QStringList addDocuFiles = Config::configuration()->docFiles(); 00421 QStringList::iterator i = addDocuFiles.begin(); 00422 00423 // Set up an indeterminate progress bar. 00424 ui.labelPrepare->setText(tr("Prepare...")); 00425 ui.progressPrepare->setMaximum(0); 00426 ui.progressPrepare->setMinimum(0); 00427 ui.progressPrepare->setValue(0); 00428 processEvents(); 00429 00430 QList<IndexKeyword> lst; 00431 quint32 fileAges = 0; 00432 for(i = addDocuFiles.begin(); i != addDocuFiles.end(); i++){ 00433 QFile file(*i); 00434 if (!file.exists()) { 00435 QMessageBox::warning(this, tr("Warning"), 00436 tr("Documentation file %1 does not exist!\n" 00437 "Skipping file.").arg(QFileInfo(file).absoluteFilePath())); 00438 continue; 00439 } 00440 fileAges += QFileInfo(file).lastModified().toTime_t(); 00441 DocuParser *handler = DocuParser::createParser(*i); 00442 bool ok = handler->parse(&file); 00443 file.close(); 00444 if(!ok){ 00445 QString msg = QString::fromLatin1("In file %1:\n%2") 00446 .arg(QFileInfo(file).absoluteFilePath()) 00447 .arg(handler->errorProtocol()); 00448 QMessageBox::critical(this, tr("Parse Error"), tr(msg.toUtf8())); 00449 delete handler; 00450 continue; 00451 } 00452 00453 QList<IndexItem*> indLst = handler->getIndexItems(); 00454 int counter = 0; 00455 foreach (IndexItem *indItem, indLst) { 00456 QFileInfo fi(indItem->reference); 00457 lst.append(IndexKeyword(indItem->keyword, indItem->reference)); 00458 00459 if(++counter%100 == 0) { 00460 if (ui.progressPrepare) 00461 ui.progressPrepare->setValue(counter); 00462 processEvents(); 00463 if(lwClosed) { 00464 return; 00465 } 00466 } 00467 } 00468 delete handler; 00469 } 00470 if (!lst.isEmpty()) 00471 qSort(lst); 00472 00473 QFile indexout(cacheFilesPath + QDir::separator() + QLatin1String("indexdb40.") 00474 + Config::configuration()->profileName()); 00475 if (verifyDirectory(cacheFilesPath) && indexout.open(QFile::WriteOnly)) { 00476 QDataStream s(&indexout); 00477 s << fileAges; 00478 s << lst; 00479 indexout.close(); 00480 } 00481 }
Here is the call graph for this function:

| quint32 HelpDialog::getFileAges | ( | ) | [private] |
Definition at line 403 of file helpdialog.cpp.
References Config::configuration(), QList< QString >::const_iterator, QList< T >::constBegin(), QList< T >::constEnd(), Config::docFiles(), and i.
Referenced by getAllContents(), and loadIndexFile().
00404 { 00405 QStringList addDocuFiles = Config::configuration()->docFiles(); 00406 QStringList::const_iterator i = addDocuFiles.constBegin(); 00407 00408 quint32 fileAges = 0; 00409 for(; i != addDocuFiles.constEnd(); ++i) { 00410 QFileInfo fi(*i); 00411 if (fi.exists()) 00412 fileAges += fi.lastModified().toTime_t(); 00413 } 00414 00415 return fileAges; 00416 }
Here is the call graph for this function:

| void HelpDialog::showIndexTopic | ( | ) | [private] |
Definition at line 637 of file helpdialog.cpp.
References QList< T >::count(), IndexListModel::description(), emit, QList< T >::first(), TopicChooser::getLink(), QAbstractListModel::index(), indexModel, QStringList::indexOf(), QString::isEmpty(), IndexListModel::links(), QAbstractItemView::PositionAtTop, qSort(), row, QStringListModel::rowCount(), showLink(), QStringListModel::stringList(), titleOfLink(), and ui.
Referenced by showTopic().
00638 { 00639 int row = ui.listIndex->currentIndex().row(); 00640 if (row == -1 || row >= indexModel->rowCount()) 00641 return; 00642 00643 QString description = indexModel->description(row); 00644 QStringList links = indexModel->links(row); 00645 00646 bool blocked = ui.editIndex->blockSignals(true); 00647 ui.editIndex->setText(description); 00648 ui.editIndex->blockSignals(blocked); 00649 00650 if (links.count() == 1) { 00651 emit showLink(links.first()); 00652 } else { 00653 qSort(links); 00654 QStringList::Iterator it = links.begin(); 00655 QStringList linkList; 00656 QStringList linkNames; 00657 for (; it != links.end(); ++it) { 00658 linkList << *it; 00659 linkNames << titleOfLink(*it); 00660 } 00661 QString link = TopicChooser::getLink(this, linkNames, linkList, description); 00662 if (!link.isEmpty()) 00663 emit showLink(link); 00664 } 00665 00666 ui.listIndex->setCurrentIndex(indexModel->index(indexModel->stringList().indexOf(description))); 00667 ui.listIndex->scrollTo(ui.listIndex->currentIndex(), QAbstractItemView::PositionAtTop); 00668 }
Here is the call graph for this function:

| void HelpDialog::showBookmarkTopic | ( | ) | [private] |
Definition at line 783 of file helpdialog.cpp.
References emit, i, LinkRole, showLink(), and ui.
Referenced by showTopic(), and showTreeItemMenu().
00784 { 00785 if (!ui.listBookmarks->currentItem()) 00786 return; 00787 00788 QTreeWidgetItem *i = (QTreeWidgetItem*)ui.listBookmarks->currentItem(); 00789 emit showLink(i->data(0, LinkRole).toString()); 00790 }
| void HelpDialog::setupTitleMap | ( | ) | [private] |
Definition at line 483 of file helpdialog.cpp.
References QList< T >::begin(), QMap< Key, T >::clear(), Config::configuration(), contentList, Profile::createDefaultProfile(), Config::docFiles(), QList< T >::end(), QFile::exists(), getAllContents(), Config::loadDefaultProfile(), processEvents(), profile, ContentItem::reference, removeOldCacheFiles(), Config::saveProfile(), Config::setDocRebuild(), ContentItem::title, titleMap, titleMapDone, and QString::trimmed().
Referenced by initialize(), and insertContents().
00484 { 00485 if (titleMapDone) 00486 return; 00487 00488 bool needRebuild = false; 00489 if (Config::configuration()->profileName() == QLatin1String("default")) { 00490 const QStringList docuFiles = Config::configuration()->docFiles(); 00491 for(QStringList::ConstIterator it = docuFiles.begin(); it != docuFiles.end(); it++) { 00492 if (!QFile::exists(*it)) { 00493 Config::configuration()->saveProfile(Profile::createDefaultProfile()); 00494 Config::configuration()->loadDefaultProfile(); 00495 needRebuild = true; 00496 break; 00497 } 00498 } 00499 } 00500 00501 if (Config::configuration()->docRebuild() || needRebuild) { 00502 removeOldCacheFiles(); 00503 Config::configuration()->setDocRebuild(false); 00504 Config::configuration()->saveProfile(Config::configuration()->profile()); 00505 } 00506 if (contentList.isEmpty()) 00507 getAllContents(); 00508 00509 titleMapDone = true; 00510 titleMap.clear(); 00511 for(QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) { 00512 ContentList lst = (*it).second; 00513 foreach (ContentItem item, lst) { 00514 titleMap[item.reference] = item.title.trimmed(); 00515 } 00516 } 00517 processEvents(); 00518 }
Here is the call graph for this function:

| void HelpDialog::saveBookmarks | ( | ) | [private] |
Definition at line 807 of file helpdialog.cpp.
References cacheFilesPath, Config::configuration(), QFile::open(), QDir::separator(), store(), ui, and QIODevice::WriteOnly.
Referenced by addBookmark(), and on_buttonRemove_clicked().
00808 { 00809 QFile f(cacheFilesPath + QDir::separator() + QLatin1String("bookmarks.") 00810 + Config::configuration()->profileName()); 00811 if (!f.open(QFile::WriteOnly)) 00812 return; 00813 00814 QTextStream ts(&f); 00815 store(ui.listBookmarks, ts); 00816 f.close(); 00817 }
Here is the call graph for this function:

| void HelpDialog::showContentsTopic | ( | ) | [private] |
Definition at line 891 of file helpdialog.cpp.
References emit, i, LinkRole, showLink(), and ui.
Referenced by showTopic(), and showTreeItemMenu().
00892 { 00893 QTreeWidgetItem *i = (QTreeWidgetItem*)ui.listContents->currentItem(); 00894 if (!i) 00895 return; 00896 emit showLink(i->data(0, LinkRole).toString()); 00897 }
| void HelpDialog::showInitDoneMessage | ( | ) | [private] |
Definition at line 611 of file helpdialog.cpp.
References help, initDoneMsgShown, QStatusBar::showMessage(), and QMainWindow::statusBar().
Referenced by insertBookmarks(), insertContents(), loadIndexFile(), and setupFullTextIndex().
00612 { 00613 if (initDoneMsgShown) 00614 return; 00615 initDoneMsgShown = true; 00616 help->statusBar()->showMessage(tr("Done"), 3000); 00617 }
Here is the call graph for this function:

| void HelpDialog::buildContentDict | ( | ) | [private] |
Definition at line 551 of file helpdialog.cpp.
References QString::arg(), QList< T >::begin(), cacheFilesPath, Config::configuration(), contentList, DocuParser::createParser(), QMessageBox::critical(), Config::docFiles(), QList< T >::end(), QString::fromLatin1(), handler, QList< QString >::iterator, QFile::open(), qMakePair(), s, QDir::separator(), QString::toUtf8(), QMessageBox::warning(), and QIODevice::WriteOnly.
Referenced by getAllContents().
00552 { 00553 QStringList docuFiles = Config::configuration()->docFiles(); 00554 00555 quint32 fileAges = 0; 00556 for(QStringList::iterator it = docuFiles.begin(); it != docuFiles.end(); it++) { 00557 QFile file(*it); 00558 if (!file.exists()) { 00559 QMessageBox::warning(this, tr("Warning"), 00560 tr("Documentation file %1 does not exist!\n" 00561 "Skipping file.").arg(QFileInfo(file).absoluteFilePath())); 00562 continue; 00563 } 00564 fileAges += QFileInfo(file).lastModified().toTime_t(); 00565 DocuParser *handler = DocuParser::createParser(*it); 00566 if(!handler) { 00567 QMessageBox::warning(this, tr("Warning"), 00568 tr("Documentation file %1 is not compatible!\n" 00569 "Skipping file.").arg(QFileInfo(file).absoluteFilePath())); 00570 continue; 00571 } 00572 bool ok = handler->parse(&file); 00573 file.close(); 00574 if(ok) { 00575 contentList += qMakePair(*it, QList<ContentItem>(handler->getContentItems())); 00576 delete handler; 00577 } else { 00578 QString msg = QString::fromLatin1("In file %1:\n%2") 00579 .arg(QFileInfo(file).absoluteFilePath()) 00580 .arg(handler->errorProtocol()); 00581 QMessageBox::critical(this, tr("Parse Error"), tr(msg.toUtf8())); 00582 continue; 00583 } 00584 } 00585 00586 QFile contentOut(cacheFilesPath + QDir::separator() + QLatin1String("contentdb40.") 00587 + Config::configuration()->profileName()); 00588 if (contentOut.open(QFile::WriteOnly)) { 00589 QDataStream s(&contentOut); 00590 s << fileAges; 00591 for(QList<QPair<QString, ContentList> >::Iterator it = contentList.begin(); it != contentList.end(); ++it) { 00592 s << *it; 00593 } 00594 contentOut.close(); 00595 } 00596 }
Here is the call graph for this function:

| QTreeWidgetItem * HelpDialog::locateLink | ( | QTreeWidgetItem * | item, | |
| const QString & | link | |||
| ) | [private] |
Definition at line 899 of file helpdialog.cpp.
References Qt::CaseInsensitive, Qt::CaseSensitive, QTreeWidgetItem::child(), QTreeWidgetItem::childCount(), QTreeWidgetItem::data(), i, LinkRole, QString::startsWith(), and QVariant::toString().
Referenced by locateContents().
00900 { 00901 QTreeWidgetItem *child = 0; 00902 #ifdef Q_OS_WIN 00903 Qt::CaseSensitivity checkCase = Qt::CaseInsensitive; 00904 #else 00905 Qt::CaseSensitivity checkCase = Qt::CaseSensitive; 00906 #endif 00907 for(int i = 0, childCount = item->childCount(); i<childCount; i++) { 00908 child = item->child(i); 00910 if (link.startsWith(child->data(0, LinkRole).toString(), checkCase)) 00911 break; 00912 //check if the link is a child of this item 00913 else if(child->childCount()) { 00914 child = locateLink(child, link); 00915 if (child) 00916 break; 00917 } 00918 child = 0; 00919 } 00920 return child; 00921 }
Here is the call graph for this function:

| void HelpDialog::getAllContents | ( | ) | [private] |
Definition at line 520 of file helpdialog.cpp.
References QDataStream::atEnd(), buildContentDict(), cacheFilesPath, QFile::close(), Config::configuration(), contentList, getFileAges(), key, QFile::open(), processEvents(), qMakePair(), QIODevice::ReadOnly, removeOldCacheFiles(), and QDir::separator().
Referenced by insertContents(), and setupTitleMap().
00521 { 00522 QFile contentFile(cacheFilesPath + QDir::separator() + QLatin1String("contentdb40.") 00523 + Config::configuration()->profileName()); 00524 contentList.clear(); 00525 if (!contentFile.open(QFile::ReadOnly)) { 00526 buildContentDict(); 00527 return; 00528 } 00529 00530 QDataStream ds(&contentFile); 00531 quint32 fileAges; 00532 ds >> fileAges; 00533 if (fileAges != getFileAges()) { 00534 contentFile.close(); 00535 removeOldCacheFiles(true); 00536 buildContentDict(); 00537 return; 00538 } 00539 QString key; 00540 QList<ContentItem> lst; 00541 while (!ds.atEnd()) { 00542 ds >> key; 00543 ds >> lst; 00544 contentList += qMakePair(key, QList<ContentItem>(lst)); 00545 } 00546 contentFile.close(); 00547 processEvents(); 00548 00549 }
Here is the call graph for this function:

Ui::HelpDialog HelpDialog::ui [private] |
Definition at line 139 of file helpdialog.h.
Referenced by addBookmark(), buildKeywordDB(), currentTabChanged(), eventFilter(), HelpDialog(), initialize(), insertBookmarks(), insertContents(), loadIndexFile(), locateContents(), on_buttonRemove_clicked(), saveBookmarks(), searchInIndex(), setIndexingProgress(), setupFullTextIndex(), showBookmarkTopic(), showContentsTopic(), showIndexItemMenu(), showIndexTopic(), showListItemMenu(), showResultPage(), showTopic(), showTreeItemMenu(), startSearch(), tabWidget(), toggleBookmarks(), toggleContents(), toggleIndex(), and toggleSearch().
IndexListModel* HelpDialog::indexModel [private] |
Definition at line 141 of file helpdialog.h.
Referenced by HelpDialog(), loadIndexFile(), searchInIndex(), showIndexItemMenu(), and showIndexTopic().
QMap<QString, QString> HelpDialog::titleMap [private] |
Definition at line 142 of file helpdialog.h.
Referenced by setupFullTextIndex(), setupTitleMap(), and titleOfLink().
bool HelpDialog::indexDone [private] |
bool HelpDialog::bookmarksInserted [private] |
Definition at line 143 of file helpdialog.h.
Referenced by addBookmark(), initialize(), and insertBookmarks().
bool HelpDialog::titleMapDone [private] |
Definition at line 143 of file helpdialog.h.
Referenced by initialize(), insertContents(), and setupTitleMap().
bool HelpDialog::contentsInserted [private] |
Definition at line 143 of file helpdialog.h.
Referenced by initialize(), insertContents(), and locateContents().
bool HelpDialog::lwClosed [private] |
Definition at line 144 of file helpdialog.h.
Referenced by buildKeywordDB(), lastWinClosed(), lastWindowClosed(), and loadIndexFile().
MainWindow* HelpDialog::help [private] |
Definition at line 145 of file helpdialog.h.
Referenced by addBookmark(), insertBookmarks(), loadIndexFile(), on_buttonRemove_clicked(), setupFullTextIndex(), showIndexItemMenu(), showInitDoneMessage(), showListItemMenu(), showTreeItemMenu(), startSearch(), and timerEvent().
QString HelpDialog::documentationPath [private] |
Definition at line 146 of file helpdialog.h.
Index* HelpDialog::fullTextIndex [private] |
Definition at line 147 of file helpdialog.h.
Referenced by initialize(), setupFullTextIndex(), and startSearch().
QStringList HelpDialog::terms [private] |
QStringList HelpDialog::foundDocs [private] |
Definition at line 148 of file helpdialog.h.
Referenced by showListItemMenu(), showResultPage(), and startSearch().
bool HelpDialog::initDoneMsgShown [private] |
QList<QPair<QString, ContentList> > HelpDialog::contentList [private] |
Definition at line 151 of file helpdialog.h.
Referenced by buildContentDict(), getAllContents(), initialize(), insertContents(), and setupTitleMap().
QMenu* HelpDialog::itemPopup [private] |
Definition at line 152 of file helpdialog.h.
Referenced by initialize(), showIndexItemMenu(), showListItemMenu(), and showTreeItemMenu().
QString HelpDialog::cacheFilesPath [private] |
Definition at line 153 of file helpdialog.h.
Referenced by buildContentDict(), buildKeywordDB(), getAllContents(), initialize(), insertBookmarks(), loadIndexFile(), removeOldCacheFiles(), saveBookmarks(), and setupFullTextIndex().
QStringList HelpDialog::keywordDocuments [private] |
Definition at line 154 of file helpdialog.h.
Referenced by loadIndexFile(), and setupFullTextIndex().
QAction* HelpDialog::actionOpenCurrentTab [private] |
Definition at line 156 of file helpdialog.h.
Referenced by initialize(), showIndexItemMenu(), showListItemMenu(), and showTreeItemMenu().
QAction* HelpDialog::actionOpenLinkInNewWindow [private] |
Definition at line 157 of file helpdialog.h.
Referenced by initialize(), showIndexItemMenu(), showListItemMenu(), and showTreeItemMenu().
QAction* HelpDialog::actionOpenLinkInNewTab [private] |
1.5.1