klistviewsearchline.h
00001 /* This file is part of the KDE libraries 00002 Copyright (c) 2003 Scott Wheeler <wheeler@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef KLISTVIEWSEARCHLINE_H 00020 #define KLISTVIEWSEARCHLINE_H 00021 00022 #include <klineedit.h> 00023 #include <qhbox.h> 00024 00025 class KListView; 00026 class QListViewItem; 00027 class QToolButton; 00028 00047 class KDEUI_EXPORT KListViewSearchLine : public KLineEdit 00048 { 00049 Q_OBJECT 00050 00051 public: 00052 00060 KListViewSearchLine(QWidget *parent = 0, KListView *listView = 0, const char *name = 0); 00061 00066 KListViewSearchLine(QWidget *parent, const char *name); 00067 00071 virtual ~KListViewSearchLine(); 00072 00078 bool caseSensitive() const; 00079 00086 QValueList<int> searchColumns() const; 00087 00094 bool keepParentsVisible() const; 00095 00101 KListView *listView() const; 00102 00103 public slots: 00108 virtual void updateSearch(const QString &s = QString::null); 00109 00115 void setCaseSensitive(bool cs); 00116 00127 void setKeepParentsVisible(bool v); 00128 00136 void setSearchColumns(const QValueList<int> &columns); 00137 00144 void setListView(KListView *lv); 00145 00146 protected: 00147 00153 virtual bool itemMatches(const QListViewItem *item, const QString &s) const; 00154 00160 virtual QPopupMenu *createPopupMenu(); 00161 00162 protected slots: 00176 void queueSearch(const QString &search); 00177 00186 void activateSearch(); 00187 00188 private: 00189 00194 void checkItemParentsNotVisible(); 00195 00201 bool checkItemParentsVisible(QListViewItem *item, QListViewItem *highestHiddenParent = 0); 00202 00203 private slots: 00204 void itemAdded(QListViewItem *item) const; 00205 void listViewDeleted(); 00206 void searchColumnsMenuActivated(int); 00207 00208 private: 00209 class KListViewSearchLinePrivate; 00210 KListViewSearchLinePrivate *d; 00211 }; 00212 00219 class KDEUI_EXPORT KListViewSearchLineWidget : public QHBox 00220 { 00221 Q_OBJECT 00222 00223 public: 00228 KListViewSearchLineWidget(KListView *listView = 0, QWidget *parent = 0, 00229 const char *name = 0); 00230 00234 ~KListViewSearchLineWidget(); 00235 00240 virtual KListViewSearchLine *createSearchLine(KListView *listView); 00241 00245 KListViewSearchLine *searchLine() const; 00246 00247 protected slots: 00254 virtual void createWidgets(); 00255 00256 private slots: 00257 void positionInToolBar(); 00258 00259 private: 00260 class KListViewSearchLineWidgetPrivate; 00261 KListViewSearchLineWidgetPrivate *d; 00262 }; 00263 00264 #endif