void FavoriteListView::update()
{
+ // FIXME: KitaSubjectView::loadBoard()¤Ë¥³¥Ô¡¼
+ {
+ m_hitList.clear();
+ m_nextHitIndex = 0;
+ m_prevquery = "";
+ }
+
const QDict<Kita::Thread>& threads = FavoriteThreads::getInstance()->threads();
// FavoriteThreads::const_iterator it;
KitaSubjectView::KitaSubjectView(QWidget *parent, const char *name)
: Kita::ThreadListView(parent, name)
{
- connect( SearchButton, SIGNAL( clicked() ), SLOT( slotSearchButton() ) );
- connect( SearchCombo, SIGNAL( activated(int) ), SLOT( slotSearchButton() ) );
- connect( HideButton, SIGNAL( toggled(bool) ), SLOT( slotHideButton(bool) ) );
connect( subjectList, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ),
SLOT( slotContextMenuRequested( QListViewItem*, const QPoint&, int ) ) );
connect( subjectList, SIGNAL( clicked( QListViewItem* ) ),
{
}
-void KitaSubjectView::loadThread( int, QListViewItem* item )
-{
- loadThread( item );
-}
-
void KitaSubjectView::loadThread( QListViewItem* item )
{
if( ! item ) return;
void KitaSubjectView::loadBoard(const Kita::Board* board)
{
// reset member variables.
+ // FIXME: FavoriteListView::update()¤Ë¥³¥Ô¡¼
{
m_hitList.clear();
m_nextHitIndex = 0;
subjectList->setFocus();
}
-void KitaSubjectView::slotSearchButton()
-{
- insertSearchCombo();
- QStringList list = parseSearchQuery( SearchCombo->currentText() );
- searchNext( list );
-}
-
-void KitaSubjectView::insertSearchCombo()
-{
- int count;
- bool found = false;
-
- for( count = 0; count < SearchCombo->count(); ++count ) {
- if ( SearchCombo->text( count ) == SearchCombo->currentText() ) {
- found = true;
- break;
- }
- }
- if ( ! found ) SearchCombo->insertItem( SearchCombo->currentText() );
-}
-
-QStringList KitaSubjectView::parseSearchQuery(const QString &input)
-{
- QStringList tmp = QStringList::split( ' ', input );
- QStringList ret_list;
- QRegExp truncSpace("\\s*$");
- QStringList::iterator it = tmp.begin();
- for( ; it != tmp.end(); ++it )
- ret_list += (*it).replace( truncSpace, "" );
- return ret_list;
-}
-
-void KitaSubjectView::searchNext(const QStringList &query)
-{
- if ( query.isEmpty() ) return;
-
- if ( query != m_prevquery ) {
- searchAll( query );
- slotHideButton( HideButton->isOn() );
- m_nextHitIndex = 0; //A next jump-search target reset to '0'.
- return;
- }
-
- if(m_nextHitIndex >= m_hitList.size()) return;
-
- KListViewItem* item = m_hitList[m_nextHitIndex];
- subjectList->ensureItemVisible(item);
- subjectList->setSelected(item, true);
- m_nextHitIndex++;
- if(m_nextHitIndex >= m_hitList.size()) m_nextHitIndex = 0;
-}
-
-void KitaSubjectView::searchAll(const QStringList &query)
-{
- m_hitList.clear();
- m_prevquery = query;
-
- QListViewItemIterator listIt( subjectList );
- while( listIt.current() != 0 ) {
- KListViewItem* item = static_cast<KListViewItem*>(listIt.current());
- item->setPixmap(Row_Icon, 0);
-
- QStringList::const_iterator queryIt = query.begin();
- for( ; queryIt != query.end(); ++queryIt ) {
- if( item->text( Row_Subject ).contains( *queryIt, false ) ) {
- item->setPixmap(Row_Icon, SmallIcon("find") );
- m_hitList.append(item);
- break;
- }
- }
- ++listIt;
- }
-}
-
-void KitaSubjectView::slotHideButton(bool on)
-{
- if(m_hitList.empty()) return;
-
- QListViewItemIterator listIt( subjectList );
- while( listIt.current() != 0 ) {
- KListViewItem* item = static_cast<KListViewItem*>(listIt.current());
- if( on && ! item->pixmap(Row_Icon)) {
- item->setVisible(false);
- } else {
- item->setVisible(true);
- }
- ++listIt;
- }
-}
-
void KitaSubjectView::setFont( const QFont& font )
{
subjectList->setFont(font);
private:
const Kita::Board* m_board;
- QStringList m_prevquery;
- unsigned m_nextHitIndex;
- QValueList<KListViewItem*> m_hitList;
-
- void insertSearchCombo();
- QStringList parseSearchQuery(const QString &input);
- void searchNext(const QStringList &input);
- void searchAll(const QStringList &query);
private slots:
- void loadThread( int, QListViewItem* item );
void loadThread( QListViewItem* item );
- void slotSearchButton();
- void slotHideButton(bool on);
void slotContextMenuRequested( QListViewItem*, const QPoint&, int );
signals:
#include <klocale.h>
#include <qtoolbutton.h>
+#include <qcombobox.h>
+#include <qregexp.h>
namespace Kita {
subjectList->setColumnWidth( Row_Subject, 400 );
subjectList->setColumnWidthMode( Row_Subject, QListView::Manual );
+
+ connect( SearchButton, SIGNAL( clicked() ), SLOT( slotSearchButton() ) );
+ connect( SearchCombo, SIGNAL( activated(int) ), SLOT( slotSearchButton() ) );
+ connect( HideButton, SIGNAL( toggled(bool) ), SLOT( slotHideButton(bool) ) );
}
{
}
+void ThreadListView::slotSearchButton()
+{
+ insertSearchCombo();
+ QStringList list = parseSearchQuery( SearchCombo->currentText() );
+ searchNext( list );
+}
+
+void ThreadListView::insertSearchCombo()
+{
+ int count;
+ bool found = false;
+
+ for( count = 0; count < SearchCombo->count(); ++count ) {
+ if ( SearchCombo->text( count ) == SearchCombo->currentText() ) {
+ found = true;
+ break;
+ }
+ }
+ if ( ! found ) SearchCombo->insertItem( SearchCombo->currentText() );
+}
+
+QStringList ThreadListView::parseSearchQuery(const QString &input)
+{
+ QStringList tmp = QStringList::split( ' ', input );
+ QStringList ret_list;
+ QRegExp truncSpace("\\s*$");
+ QStringList::iterator it = tmp.begin();
+ for( ; it != tmp.end(); ++it )
+ ret_list += (*it).replace( truncSpace, "" );
+ return ret_list;
+}
+
+void ThreadListView::searchNext(const QStringList &query)
+{
+ if ( query.isEmpty() ) return;
+
+ if ( query != m_prevquery ) {
+ searchAll( query );
+ slotHideButton( HideButton->isOn() );
+ m_nextHitIndex = 0; //A next jump-search target reset to '0'.
+ return;
+ }
+
+ if(m_nextHitIndex >= m_hitList.size()) return;
+
+ KListViewItem* item = m_hitList[m_nextHitIndex];
+ subjectList->ensureItemVisible(item);
+ subjectList->setSelected(item, true);
+ m_nextHitIndex++;
+ if(m_nextHitIndex >= m_hitList.size()) m_nextHitIndex = 0;
+}
+
+void ThreadListView::searchAll(const QStringList &query)
+{
+ m_hitList.clear();
+ m_prevquery = query;
+
+ QListViewItemIterator listIt( subjectList );
+ while( listIt.current() != 0 ) {
+ KListViewItem* item = static_cast<KListViewItem*>(listIt.current());
+ item->setPixmap(Row_Icon, 0);
+
+ QStringList::const_iterator queryIt = query.begin();
+ for( ; queryIt != query.end(); ++queryIt ) {
+ if( item->text( Row_Subject ).contains( *queryIt, false ) ) {
+ item->setPixmap(Row_Icon, SmallIcon("find") );
+ m_hitList.append(item);
+ break;
+ }
+ }
+ ++listIt;
+ }
+}
+
+void ThreadListView::slotHideButton(bool on)
+{
+ if(m_hitList.empty()) return;
+
+ QListViewItemIterator listIt( subjectList );
+ while( listIt.current() != 0 ) {
+ KListViewItem* item = static_cast<KListViewItem*>(listIt.current());
+ if( on && ! item->pixmap(Row_Icon)) {
+ item->setVisible(false);
+ } else {
+ item->setVisible(true);
+ }
+ ++listIt;
+ }
+}
};
#include "threadlistview.moc"
#ifndef KITATHREADLISTVIEW_H
#define KITATHREADLISTVIEW_H
-#include <threadlistviewbase.h>
+#include "threadlistviewbase.h"
+
+#include <klistview.h>
enum ThreadListViewRows {
Row_Mark,
Q_OBJECT
public:
ThreadListView(QWidget *parent = 0, const char *name = 0);
-
~ThreadListView();
+protected:
+ QStringList m_prevquery;
+ unsigned m_nextHitIndex;
+ QValueList<KListViewItem*> m_hitList;
+
+ void insertSearchCombo();
+ QStringList parseSearchQuery(const QString &input);
+ void searchNext(const QStringList &input);
+ void searchAll(const QStringList &query);
+
+protected slots:
+ void slotHideButton(bool on);
+
+private slots:
+ void slotSearchButton();
};
};