OSDN Git Service

reformat
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 31 Dec 2003 13:06:28 +0000 (13:06 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 31 Dec 2003 13:06:28 +0000 (13:06 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@755 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/threadlistview.cpp
kita/src/threadlistview.h

index 359466a..139601f 100644 (file)
@@ -1,12 +1,13 @@
 /***************************************************************************
- *   Copyright (C) 2003 by Hideki Ikemoto                                  *
- *   ikemo@wakaba.jp                                                       *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- ***************************************************************************/
+*   Copyright (C) 2003 by Hideki Ikemoto                                  *
+*   ikemo@wakaba.jp                                                       *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+***************************************************************************/
+
 #include "threadlistview.h"
 
 #include <kiconloader.h>
 #include <qcombobox.h>
 #include <qregexp.h>
 
-namespace Kita {
+using namespace Kita;
 
-ThreadListView::ThreadListView(QWidget *parent, const char *name)
: Kita::ThreadListViewBase(parent, name)
+ThreadListView::ThreadListView( QWidget* parent, const char* name )
       : ThreadListViewBase( parent, name )
 {
     SearchButton->setPixmap( SmallIcon( "find" ) );
     HideButton->setPixmap( SmallIcon( "filter" ) );
@@ -38,105 +39,106 @@ ThreadListView::ThreadListView(QWidget *parent, const char *name)
     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) ) );
+    connect( SearchButton, SIGNAL( clicked() ),
+             SLOT( slotSearchButton() ) );
+    connect( SearchCombo, SIGNAL( activated( int ) ),
+             SLOT( slotSearchButton() ) );
+    connect( HideButton, SIGNAL( toggled( bool ) ),
+             SLOT( slotHideButton( bool ) ) );
 }
 
 
 ThreadListView::~ThreadListView()
-{
-}
+{}
 
 void ThreadListView::slotSearchButton()
 {
-  insertSearchCombo();
-  QStringList list = parseSearchQuery( SearchCombo->currentText() );
-  searchNext( list );
+    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;
+    for ( int count = 0; count < SearchCombo->count(); ++count ) {
+        if ( SearchCombo->text( count ) == SearchCombo->currentText() ) {
+            return;
+        }
     }
-  }
-  if ( ! found ) SearchCombo->insertItem( SearchCombo->currentText() );
+    SearchCombo->insertItem( SearchCombo->currentText() );
 }
 
-QStringList ThreadListView::parseSearchQuery(const QString &input)
+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;
+    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)
+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;
+    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)
+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;
-      }
+    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;
     }
-    ++listIt;
-  }
 }
 
-void ThreadListView::slotHideButton(bool on)
+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);
+    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;
     }
-    ++listIt;
-  }
 }
 
-};
 #include "threadlistview.moc"
index 361104e..70b73f3 100644 (file)
@@ -1,12 +1,12 @@
 /***************************************************************************
- *   Copyright (C) 2003 by Hideki Ikemoto                                  *
- *   ikemo@wakaba.jp                                                       *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- ***************************************************************************/
+*   Copyright (C) 2003 by Hideki Ikemoto                                  *
+*   ikemo@wakaba.jp                                                       *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU General Public License as published by  *
+*   the Free Software Foundation; either version 2 of the License, or     *
+*   (at your option) any later version.                                   *
+***************************************************************************/
 #ifndef KITATHREADLISTVIEW_H
 #define KITATHREADLISTVIEW_H
 
 #include <klistview.h>
 
 enum ThreadListViewRows {
-  Row_Mark,
-  Row_ID,
-  Row_Icon,
-  Row_Subject,
-  Row_ResNum,
-  Row_Read,
-  Row_Unread,
-  Row_Board,
-  Row_DatName,
-  Row_DatURL
+    Row_Mark,
+    Row_ID,
+    Row_Icon,
+    Row_Subject,
+    Row_ResNum,
+    Row_Read,
+    Row_Unread,
+    Row_Board,
+    Row_DatName,
+    Row_DatURL
 };
 
-namespace Kita {
-
-/**
-@author Hideki Ikemoto
-*/
-class ThreadListView : public Kita::ThreadListViewBase
+namespace Kita
 {
-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();
-};
+    /**
+    @author Hideki Ikemoto
+    */
+    class ThreadListView : public Kita::ThreadListViewBase
+    {
+        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();
+    };
 
 };