From 17a08cc1c2a3b79c17e93896b2f206dda5ef95c4 Mon Sep 17 00:00:00 2001 From: Noldor Date: Tue, 20 May 2008 19:40:51 +0000 Subject: more module help qt4 port (wip) git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1831 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/help/helpwindow.cpp | 43 ++++++++++++++++++++++------------------- src/modules/help/helpwindow.h | 6 +++--- src/modules/help/index.cpp | 3 ++- 3 files changed, 28 insertions(+), 24 deletions(-) (limited to 'src/modules') diff --git a/src/modules/help/helpwindow.cpp b/src/modules/help/helpwindow.cpp index 7c8b1c02a..7ffdb3cb2 100644 --- a/src/modules/help/helpwindow.cpp +++ b/src/modules/help/helpwindow.cpp @@ -93,11 +93,11 @@ KviHelpWindow::KviHelpWindow(KviFrame * lpFrm,const char * name) connect(pBtnRefreshIndex,SIGNAL(clicked()),this,SLOT(refreshIndex())); pBtnRefreshIndex->setToolTip(__tr2qs("Refresh index") ); - m_pIndexListBox = new KviTalListBox(m_pIndexTab); + m_pIndexListWidget = new KviTalListWidget(m_pIndexTab); QStringList docList=g_pDocIndex->titlesList(); - m_pIndexListBox->insertStringList(docList); - connect(m_pIndexListBox,SIGNAL(selected(int)),this,SLOT(indexSelected ( int ))); - m_pIndexListBox->sort(); + m_pIndexListWidget->addItems(docList); + connect(m_pIndexListWidget,SIGNAL(selected(int)),this,SLOT(indexSelected ( int ))); + m_pIndexListWidget->sortItems(); m_pSearchTab = new KviTalVBox(m_pTabWidget); m_pTabWidget->addTab(m_pSearchTab,__tr2qs("Search")); @@ -108,7 +108,7 @@ KviHelpWindow::KviHelpWindow(KviFrame * lpFrm,const char * name) connect( m_pTermsEdit, SIGNAL( returnPressed() ), this, SLOT( startSearch() ) ); - m_pResultBox = new KviTalListBox(m_pSearchTab); + m_pResultBox = new KviTalListWidget(m_pSearchTab); connect(m_pResultBox,SIGNAL(selected(int)),this,SLOT(searchSelected ( int ))); KviValueList li; @@ -141,7 +141,7 @@ void KviHelpWindow::loadProperties(KviConfig *cfg) void KviHelpWindow::refreshIndex() { - m_pIndexListBox->clear(); + m_pIndexListWidget->clear(); QProgressDialog* pProgressDialog = new QProgressDialog( __tr2qs("Indexing help files"), __tr2qs("Cancel"), 0,100 ); connect(g_pDocIndex,SIGNAL(indexingProgress(int)), pProgressDialog, SLOT(setValue(int)) ); g_pDocIndex->makeIndex(); @@ -150,8 +150,8 @@ void KviHelpWindow::refreshIndex() delete pProgressDialog; g_bIndexingDone=TRUE; QStringList docList=g_pDocIndex->titlesList(); - m_pIndexListBox->insertStringList(docList); - m_pIndexListBox->sort(); + m_pIndexListWidget->addItems(docList); + m_pIndexListWidget->sortItems(); } void KviHelpWindow::startSearch() @@ -205,7 +205,7 @@ void KviHelpWindow::startSearch() m_pResultBox->clear(); for ( it = m_foundDocs.begin(); it != m_foundDocs.end(); ++it ) - m_pResultBox->insertItem( g_pDocIndex->getDocumentTitle( *it ) ); + m_pResultBox->addItem( g_pDocIndex->getDocumentTitle( *it ) ); m_terms.clear(); bool isPhrase = FALSE; @@ -237,36 +237,39 @@ QTextBrowser * KviHelpWindow::textBrowser() void KviHelpWindow::showIndexTopic() { - if (m_pIndexSearch->text().isEmpty()|| !m_pIndexListBox->selectedItem()) return; - int i=g_pDocIndex->titlesList().indexOf(m_pIndexListBox->selectedItem()->text()); + if (m_pIndexSearch->text().isEmpty()|| !m_pIndexListWidget->selectedItems().count()) return; + int i=g_pDocIndex->titlesList().indexOf(m_pIndexListWidget->selectedItems().at(0)->text()); textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[ i ])); } void KviHelpWindow::searchInIndex( const QString &s ) { - KviTalListBoxItem *i = m_pIndexListBox->firstItem(); + QListWidgetItem *item ;//= m_pIndexListWidget->firstItem(); QString sl = s.toLower(); - while ( i ) { - QString t = i->text(); + for(int i=0;icount();i++) +// while ( i ) { + { + item=m_pIndexListWidget->item(i); + QString t = item->text(); if ( t.length() >= sl.length() && - i->text().left(s.length()).toLower() == sl ) { - m_pIndexListBox->setCurrentItem( i ); - m_pIndexListBox->setTopItem(m_pIndexListBox->index(i)); + item->text().left(s.length()).toLower() == sl ) { + m_pIndexListWidget->setCurrentItem( item ); + m_pIndexListWidget->scrollToItem(item,QAbstractItemView::PositionAtTop); break; } - i = i->next(); + // i = i->next(); } } void KviHelpWindow::indexSelected ( int index ) { - int i=g_pDocIndex->titlesList().indexOf(m_pIndexListBox->text(index)); + int i=g_pDocIndex->titlesList().indexOf(m_pIndexListWidget->item(index)->text()); textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[ i ])); } void KviHelpWindow::searchSelected ( int index ) { - int i=g_pDocIndex->titlesList().indexOf(m_pResultBox->text(index)); + int i=g_pDocIndex->titlesList().findIndex(m_pResultBox->item(index)->text()); textBrowser()->setSource(QUrl(g_pDocIndex->documentList()[ i ])); } diff --git a/src/modules/help/helpwindow.h b/src/modules/help/helpwindow.h index 941f90456..fbe5c028b 100644 --- a/src/modules/help/helpwindow.h +++ b/src/modules/help/helpwindow.h @@ -25,7 +25,7 @@ #include "kvi_window.h" #include "kvi_string.h" #include "kvi_tal_vbox.h" -#include "kvi_tal_listbox.h" +#include "kvi_tal_listwidget.h" #include #include @@ -47,11 +47,11 @@ protected: KviTalVBox * m_pIndexTab; KviTalVBox * m_pSearchTab; - KviTalListBox * m_pIndexListBox; + KviTalListWidget* m_pIndexListWidget; QLineEdit * m_pIndexSearch; QStringList m_foundDocs; QStringList m_terms; - KviTalListBox * m_pResultBox; + KviTalListWidget* m_pResultBox; QLineEdit * m_pTermsEdit; public: KviHelpWidget * helpWidget(){ return m_pHelpWidget; }; diff --git a/src/modules/help/index.cpp b/src/modules/help/index.cpp index d5e6961fe..9953c35ea 100755 --- a/src/modules/help/index.cpp +++ b/src/modules/help/index.cpp @@ -477,7 +477,8 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo qWarning( warn.toUtf8().data() ); return FALSE; } - + else debug("Open file %s",fileName.utf8().data()); + debug("Patterns %s and words %s",patterns.join(","),words.join(",")); wordNum = 3; miniDict.clear(); -- cgit v1.3.1-10-gc9f91