OSDN Git Service

board search.
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 28 May 2005 14:39:00 +0000 (14:39 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 28 May 2005 14:39:00 +0000 (14:39 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1735 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/bbs/bbsview.cpp
kita/src/bbs/bbsview.h
kita/src/bbs/bbsviewbase.ui

index 851cf76..f91a020 100644 (file)
@@ -18,6 +18,7 @@
 #include <ksimpleconfig.h>
 #include <kdeversion.h>
 #include <kmessagebox.h>
+#include <kiconloader.h>
 
 #include <qfile.h>
 #include <qtextcodec.h>
@@ -27,6 +28,8 @@
 #include <qheader.h>
 #include <qclipboard.h>
 #include <qmessagebox.h>
+#include <qtoolbutton.h>
+#include <qcombobox.h>
 
 #include "bbsview.h"
 
@@ -80,6 +83,9 @@ KitaBBSView::KitaBBSView( QWidget *parent, const char *name )
                                const KURL&, const KParts::URLArgs&, QString, int, const KURL& ) ),
              signalCollection, SIGNAL( openURLRequestExt(
                                            const KURL& , const KParts::URLArgs&, QString, int, const KURL& ) ) );
+
+    connect( SearchCombo, SIGNAL( textChanged( const QString& ) ),
+             SLOT( filter( const QString& ) ) );
 }
 
 KitaBBSView::~KitaBBSView()
@@ -622,3 +628,30 @@ void KitaBBSView::saveOpened()
 
     config.writeEntry( "Opened", openedList );
 }
+
+/**
+ * search and show matched item.
+ *
+ * @param str string to search.
+ */
+void KitaBBSView::filter( const QString& str )
+{
+    QListViewItem* categoryItem;
+    QListViewItem* boardItem;
+
+    for ( categoryItem = m_boardList->firstChild(); categoryItem; categoryItem = categoryItem->nextSibling() ) {
+        bool matched = false;
+
+        for ( boardItem = categoryItem->firstChild(); boardItem; boardItem = boardItem->nextSibling() ) {
+            QString boardName = boardItem->text( 0 );
+            if ( boardName.contains( str ) ) {
+                boardItem->setVisible( true );
+                matched = true;
+            } else {
+                boardItem->setVisible( false );
+            }
+        }
+
+        categoryItem->setVisible( matched );
+    }    
+}
index 789b846..eae1f9c 100644 (file)
@@ -55,6 +55,7 @@ private slots:
     void slotContextMenuRequested( QListViewItem*, const QPoint&, int );
     void slotMouseButtonClicked( int, QListViewItem* );
     void refreshFavoriteBoards();
+    void filter( const QString& str );
 
 public:
     KitaBBSView( QWidget *parent, const char *name = 0 );
index 6a7b1eb..e25e320 100644 (file)
     <property name="caption">
         <string>Form1</string>
     </property>
-    <grid>
+    <vbox>
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
         <property name="margin">
             <number>0</number>
         </property>
-        <widget class="KListView" row="0" column="0">
+        <property name="spacing">
+            <number>0</number>
+        </property>
+        <widget class="QLayoutWidget">
             <property name="name">
-                <cstring>m_boardList</cstring>
+                <cstring>layout8</cstring>
             </property>
-            <property name="lineWidth">
-                <number>2</number>
+            <hbox>
+                <property name="name">
+                    <cstring>unnamed</cstring>
+                </property>
+                <widget class="QComboBox">
+                    <property name="name">
+                        <cstring>SearchCombo</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>1</hsizetype>
+                            <vsizetype>4</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="editable">
+                        <bool>true</bool>
+                    </property>
+                    <property name="sizeLimit">
+                        <number>10</number>
+                    </property>
+                </widget>
+                <widget class="QToolButton">
+                    <property name="name">
+                        <cstring>SearchButton</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Search</string>
+                    </property>
+                    <property name="toolTip" stdset="0">
+                        <string>search word</string>
+                    </property>
+                </widget>
+                <spacer>
+                    <property name="name">
+                        <cstring>spacer2</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Horizontal</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Expanding</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>398</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
+            </hbox>
+        </widget>
+        <widget class="KListView">
+            <property name="name">
+                <cstring>m_boardList</cstring>
             </property>
             <property name="rootIsDecorated">
                 <bool>true</bool>
@@ -39,7 +96,7 @@
                 <bool>true</bool>
             </property>
         </widget>
-    </grid>
+    </vbox>
 </widget>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>