/usr/include/ktreewidgetsearchline.h is in kdelibs5-dev 4:4.14.16-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | /* This file is part of the KDE libraries
Copyright (c) 2003 Scott Wheeler <wheeler@kde.org>
Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
Copyright (c) 2006 Hamish Rodda <rodda@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KTREEWIDGETSEARCHLINE_H
#define KTREEWIDGETSEARCHLINE_H
#include <klineedit.h>
class QModelIndex;
class QTreeWidget;
class QTreeWidgetItem;
/**
* This class makes it easy to add a search line for filtering the items in
* listviews based on a simple text search.
*
* No changes to the application other than instantiating this class with
* appropriate QTreeWidgets should be needed.
*/
class KDEUI_EXPORT KTreeWidgetSearchLine : public KLineEdit
{
Q_OBJECT
Q_PROPERTY( Qt::CaseSensitivity caseSensitity READ caseSensitivity WRITE setCaseSensitivity )
Q_PROPERTY( bool keepParentsVisible READ keepParentsVisible WRITE setKeepParentsVisible )
public:
/**
* Constructs a KTreeWidgetSearchLine with \a treeWidget being the QTreeWidget to
* be filtered.
*
* If \a treeWidget is null then the widget will be disabled until listviews
* are set with setTreeWidget(), setTreeWidgets() or added with addTreeWidget().
*/
explicit KTreeWidgetSearchLine( QWidget *parent = 0, QTreeWidget *treeWidget = 0 );
/**
* Constructs a KTreeWidgetSearchLine with \a treeWidgets being the list of
* pointers to QTreeWidgets to be filtered.
*
* If \a treeWidgets is empty then the widget will be disabled until listviews
* are set with setTreeWidget(), setTreeWidgets() or added with addTreeWidget().
*/
KTreeWidgetSearchLine( QWidget *parent, const QList<QTreeWidget *> &treeWidgets );
/**
* Destroys the KTreeWidgetSearchLine.
*/
virtual ~KTreeWidgetSearchLine();
/**
* Returns true if the search is case sensitive. This defaults to false.
*
* @see setCaseSensitive()
*/
Qt::CaseSensitivity caseSensitivity() const;
/**
* Returns the current list of columns that will be searched. If the
* returned list is empty all visible columns will be searched.
*
* @see setSearchColumns
*/
QList<int> searchColumns() const;
/**
* If this is true (the default) then the parents of matched items will also
* be shown.
*
* @see setKeepParentsVisible()
*/
bool keepParentsVisible() const;
/**
* Returns the listview that is currently filtered by the search.
* If there are multiple listviews filtered, it returns 0.
*
* @see setTreeWidget(), treeWidgets()
*/
QTreeWidget *treeWidget() const;
/**
* Returns the list of pointers to listviews that are currently filtered by
* the search.
*
* @see setTreeWidgets(), addTreeWidget(), treeWidget()
*/
QList<QTreeWidget *> treeWidgets() const;
Q_SIGNALS:
/**
* This signal is emitted whenever an item gets hidden or unhidden due
* to it not matching or matching the search string.
*/
void hiddenChanged(QTreeWidgetItem *, bool);
public Q_SLOTS:
/**
* Adds a QTreeWidget to the list of listviews filtered by this search line.
* If \a treeWidget is null then the widget will be disabled.
*
* @see treeWidget(), setTreeWidgets(), removeTreeWidget()
*/
void addTreeWidget( QTreeWidget *treeWidget );
/**
* Removes a QTreeWidget from the list of listviews filtered by this search
* line. Does nothing if \a treeWidget is 0 or is not filtered by the quick search
* line.
*
* @see listVew(), setTreeWidgets(), addTreeWidget()
*/
void removeTreeWidget( QTreeWidget *treeWidget );
/**
* Updates search to only make visible the items that match \a pattern. If
* \a s is null then the line edit's text will be used.
*/
virtual void updateSearch( const QString &pattern = QString() );
/**
* Make the search case sensitive or case insensitive.
*
* @see caseSenstivity()
*/
void setCaseSensitivity( Qt::CaseSensitivity caseSensitivity );
/**
* When a search is active on a list that's organized into a tree view if
* a parent or ancesestor of an item is does not match the search then it
* will be hidden and as such so too will any children that match.
*
* If this is set to true (the default) then the parents of matching items
* will be shown.
*
* \warning setKeepParentsVisible(true) does not have the expected effect
* on items being added to or removed from the view while a search is active.
* When a new search starts afterwards the behavior will be normal.
*
* @see keepParentsVisible
*/
void setKeepParentsVisible( bool value );
/**
* Sets the list of columns to be searched. The default is to search all,
* visible columns which can be restored by passing \a columns as an empty
* list.
* If listviews to be filtered have different numbers or labels of columns
* this method has no effect.
*
* @see searchColumns
*/
void setSearchColumns( const QList<int> &columns );
/**
* Sets the QTreeWidget that is filtered by this search line, replacing any
* previously filtered listviews. If \a treeWidget is null then the widget will be
* disabled.
*
* @see treeWidget(), setTreeWidgets()
*/
void setTreeWidget( QTreeWidget *treeWidget );
/**
* Sets QTreeWidgets that are filtered by this search line, replacing any
* previously filtered listviews. If \a treeWidgets is empty then the widget will
* be disabled.
*
* @see treeWidgets(), addTreeWidget(), setTreeWidget()
*/
void setTreeWidgets( const QList<QTreeWidget *> &treeWidgets );
protected:
/**
* Returns true if \a item matches the search \a pattern. This will be evaluated
* based on the value of caseSensitive(). This can be overridden in
* subclasses to implement more complicated matching schemes.
*/
virtual bool itemMatches( const QTreeWidgetItem *item, const QString &pattern ) const;
/**
* Re-implemented for internal reasons. API not affected.
*/
virtual void contextMenuEvent( QContextMenuEvent* );
/**
* Updates search to only make visible appropriate items in \a treeWidget. If
* \a treeWidget is null then nothing is done.
*/
virtual void updateSearch( QTreeWidget *treeWidget );
/**
* Connects signals of this listview to the appropriate slots of the search
* line.
*/
virtual void connectTreeWidget( QTreeWidget* );
/**
* Disconnects signals of a listviews from the search line.
*/
virtual void disconnectTreeWidget( QTreeWidget* );
/**
* Checks columns in all listviews and decides whether choosing columns to
* filter on makes any sense.
*
* Returns false if either of the following is true:
* * there are no listviews connected,
* * the listviews have different numbers of columns,
* * the listviews have only one column,
* * the listviews differ in column labels.
*
* Otherwise it returns true.
*
* @see setSearchColumns()
*/
virtual bool canChooseColumnsCheck();
/**
* Re-implemented for internal reasons. API not affected.
*/
virtual bool event(QEvent *event);
private:
class Private;
Private* const d;
Q_PRIVATE_SLOT(d, void _k_rowsInserted(const QModelIndex&, int, int) const)
Q_PRIVATE_SLOT(d, void _k_treeWidgetDeleted(QObject*))
Q_PRIVATE_SLOT(d, void _k_slotColumnActivated(QAction*))
Q_PRIVATE_SLOT(d, void _k_slotAllVisibleColumns())
Q_PRIVATE_SLOT(d, void _k_queueSearch(const QString&))
Q_PRIVATE_SLOT(d, void _k_activateSearch())
};
/**
* Creates a widget featuring a KTreeWidgetSearchLine, a label with the text
* "Search" and a button to clear the search.
*/
class KDEUI_EXPORT KTreeWidgetSearchLineWidget : public QWidget
{
Q_OBJECT
public:
/**
* Creates a KTreeWidgetSearchLineWidget for \a treeWidget with \a parent as the
* parent.
*/
explicit KTreeWidgetSearchLineWidget( QWidget *parent = 0, QTreeWidget *treeWidget = 0 );
/**
* Destroys the KTreeWidgetSearchLineWidget
*/
~KTreeWidgetSearchLineWidget();
/**
* Returns a pointer to the search line.
*/
KTreeWidgetSearchLine *searchLine() const;
protected Q_SLOTS:
/**
* Creates the widgets inside of the widget. This is called from the
* constructor via a single shot timer so that it it guaranteed to run
* after construction is complete. This makes it suitable for overriding in
* subclasses.
*/
virtual void createWidgets();
protected:
/**
* Creates the search line. This can be useful to reimplement in cases where
* a KTreeWidgetSearchLine subclass is used.
*
* It is const because it is be called from searchLine(), which to the user
* doesn't conceptually alter the widget.
*/
virtual KTreeWidgetSearchLine *createSearchLine( QTreeWidget *treeWidget ) const;
private:
class Private;
Private* const d;
};
#endif
|