| 1 | /**************************************************************************** | 
|---|
| 2 | ** $Id: qlistview.h 8 2005-11-16 19:36:46Z dmik $ | 
|---|
| 3 | ** | 
|---|
| 4 | ** Definition of QListView widget class | 
|---|
| 5 | ** | 
|---|
| 6 | ** Created : 970809 | 
|---|
| 7 | ** | 
|---|
| 8 | ** Copyright (C) 1992-2002 Trolltech AS.  All rights reserved. | 
|---|
| 9 | ** | 
|---|
| 10 | ** This file is part of the widgets module of the Qt GUI Toolkit. | 
|---|
| 11 | ** | 
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License | 
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file | 
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file. | 
|---|
| 15 | ** | 
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the | 
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 19 | ** packaging of this file. | 
|---|
| 20 | ** | 
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License | 
|---|
| 23 | ** Agreement provided with the Software. | 
|---|
| 24 | ** | 
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 27 | ** | 
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 
|---|
| 29 | **   information about Qt Commercial License Agreements. | 
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 
|---|
| 32 | ** | 
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are | 
|---|
| 34 | ** not clear to you. | 
|---|
| 35 | ** | 
|---|
| 36 | **********************************************************************/ | 
|---|
| 37 |  | 
|---|
| 38 | #ifndef QLISTVIEW_H | 
|---|
| 39 | #define QLISTVIEW_H | 
|---|
| 40 |  | 
|---|
| 41 | #ifndef QT_H | 
|---|
| 42 | #include "qscrollview.h" | 
|---|
| 43 | #endif // QT_H | 
|---|
| 44 |  | 
|---|
| 45 | #ifndef QT_NO_LISTVIEW | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | class QPixmap; | 
|---|
| 49 | class QFont; | 
|---|
| 50 | class QHeader; | 
|---|
| 51 | class QIconSet; | 
|---|
| 52 |  | 
|---|
| 53 | class QListView; | 
|---|
| 54 | struct QListViewPrivate; | 
|---|
| 55 | struct QCheckListItemPrivate; | 
|---|
| 56 | class QListViewItemIterator; | 
|---|
| 57 | struct QListViewItemIteratorPrivate; | 
|---|
| 58 | class QDragObject; | 
|---|
| 59 | class QMimeSource; | 
|---|
| 60 | class QLineEdit; | 
|---|
| 61 | class QListViewToolTip; | 
|---|
| 62 |  | 
|---|
| 63 | class Q_EXPORT QListViewItem : public Qt | 
|---|
| 64 | { | 
|---|
| 65 | friend class QListViewItemIterator; | 
|---|
| 66 | friend class QListViewToolTip; | 
|---|
| 67 |  | 
|---|
| 68 | public: | 
|---|
| 69 | QListViewItem( QListView * parent ); | 
|---|
| 70 | QListViewItem( QListViewItem * parent ); | 
|---|
| 71 | QListViewItem( QListView * parent, QListViewItem * after ); | 
|---|
| 72 | QListViewItem( QListViewItem * parent, QListViewItem * after ); | 
|---|
| 73 |  | 
|---|
| 74 | QListViewItem( QListView * parent, | 
|---|
| 75 | QString,     QString = QString::null, | 
|---|
| 76 | QString = QString::null, QString = QString::null, | 
|---|
| 77 | QString = QString::null, QString = QString::null, | 
|---|
| 78 | QString = QString::null, QString = QString::null ); | 
|---|
| 79 | QListViewItem( QListViewItem * parent, | 
|---|
| 80 | QString,     QString = QString::null, | 
|---|
| 81 | QString = QString::null, QString = QString::null, | 
|---|
| 82 | QString = QString::null, QString = QString::null, | 
|---|
| 83 | QString = QString::null, QString = QString::null ); | 
|---|
| 84 |  | 
|---|
| 85 | QListViewItem( QListView * parent, QListViewItem * after, | 
|---|
| 86 | QString,     QString = QString::null, | 
|---|
| 87 | QString = QString::null, QString = QString::null, | 
|---|
| 88 | QString = QString::null, QString = QString::null, | 
|---|
| 89 | QString = QString::null, QString = QString::null ); | 
|---|
| 90 | QListViewItem( QListViewItem * parent, QListViewItem * after, | 
|---|
| 91 | QString,     QString = QString::null, | 
|---|
| 92 | QString = QString::null, QString = QString::null, | 
|---|
| 93 | QString = QString::null, QString = QString::null, | 
|---|
| 94 | QString = QString::null, QString = QString::null ); | 
|---|
| 95 | virtual ~QListViewItem(); | 
|---|
| 96 |  | 
|---|
| 97 | virtual void insertItem( QListViewItem * ); | 
|---|
| 98 | virtual void takeItem( QListViewItem * ); | 
|---|
| 99 | virtual void removeItem( QListViewItem *item ) { takeItem( item ); } //obsolete, use takeItem instead | 
|---|
| 100 |  | 
|---|
| 101 | int height() const; | 
|---|
| 102 | virtual void invalidateHeight(); | 
|---|
| 103 | int totalHeight() const; | 
|---|
| 104 | virtual int width( const QFontMetrics&, | 
|---|
| 105 | const QListView*, int column) const; | 
|---|
| 106 | void widthChanged(int column=-1) const; | 
|---|
| 107 | int depth() const; | 
|---|
| 108 |  | 
|---|
| 109 | virtual void setText( int, const QString &); | 
|---|
| 110 | virtual QString text( int ) const; | 
|---|
| 111 |  | 
|---|
| 112 | virtual void setPixmap( int, const QPixmap & ); | 
|---|
| 113 | virtual const QPixmap * pixmap( int ) const; | 
|---|
| 114 |  | 
|---|
| 115 | virtual QString key( int, bool ) const; | 
|---|
| 116 | virtual int compare( QListViewItem *i, int col, bool ) const; | 
|---|
| 117 | virtual void sortChildItems( int, bool ); | 
|---|
| 118 |  | 
|---|
| 119 | int childCount() const { return nChildren; } | 
|---|
| 120 |  | 
|---|
| 121 | bool isOpen() const { return open; } | 
|---|
| 122 | virtual void setOpen( bool ); | 
|---|
| 123 | virtual void setup(); | 
|---|
| 124 |  | 
|---|
| 125 | virtual void setSelected( bool ); | 
|---|
| 126 | bool isSelected() const { return selected; } | 
|---|
| 127 |  | 
|---|
| 128 | virtual void paintCell( QPainter *, const QColorGroup & cg, | 
|---|
| 129 | int column, int width, int alignment ); | 
|---|
| 130 | virtual void paintBranches( QPainter * p, const QColorGroup & cg, | 
|---|
| 131 | int w, int y, int h ); | 
|---|
| 132 | virtual void paintFocus( QPainter *, const QColorGroup & cg, | 
|---|
| 133 | const QRect & r ); | 
|---|
| 134 |  | 
|---|
| 135 | QListViewItem * firstChild() const; | 
|---|
| 136 | QListViewItem * nextSibling() const { return siblingItem; } | 
|---|
| 137 | QListViewItem * parent() const; | 
|---|
| 138 |  | 
|---|
| 139 | QListViewItem * itemAbove(); | 
|---|
| 140 | QListViewItem * itemBelow(); | 
|---|
| 141 |  | 
|---|
| 142 | int itemPos() const; | 
|---|
| 143 |  | 
|---|
| 144 | QListView *listView() const; | 
|---|
| 145 |  | 
|---|
| 146 | virtual void setSelectable( bool enable ); | 
|---|
| 147 | bool isSelectable() const { return selectable && enabled; } | 
|---|
| 148 |  | 
|---|
| 149 | virtual void setExpandable( bool ); | 
|---|
| 150 | bool isExpandable() const { return expandable; } | 
|---|
| 151 |  | 
|---|
| 152 | void repaint() const; | 
|---|
| 153 |  | 
|---|
| 154 | virtual void sort(); | 
|---|
| 155 | void moveItem( QListViewItem *after ); | 
|---|
| 156 |  | 
|---|
| 157 | virtual void setDragEnabled( bool allow ); | 
|---|
| 158 | virtual void setDropEnabled( bool allow ); | 
|---|
| 159 | bool dragEnabled() const; | 
|---|
| 160 | bool dropEnabled() const; | 
|---|
| 161 | virtual bool acceptDrop( const QMimeSource *mime ) const; | 
|---|
| 162 |  | 
|---|
| 163 | void setVisible( bool b ); | 
|---|
| 164 | bool isVisible() const; | 
|---|
| 165 |  | 
|---|
| 166 | virtual void setRenameEnabled( int col, bool b ); | 
|---|
| 167 | bool renameEnabled( int col ) const; | 
|---|
| 168 | virtual void startRename( int col ); | 
|---|
| 169 |  | 
|---|
| 170 | virtual void setEnabled( bool b ); | 
|---|
| 171 | bool isEnabled() const; | 
|---|
| 172 |  | 
|---|
| 173 | virtual int rtti() const; | 
|---|
| 174 | // ### Qt 4: make const or better use an enum | 
|---|
| 175 | static int RTTI; | 
|---|
| 176 |  | 
|---|
| 177 | virtual void setMultiLinesEnabled( bool b ); | 
|---|
| 178 | bool multiLinesEnabled() const; | 
|---|
| 179 |  | 
|---|
| 180 | protected: | 
|---|
| 181 | virtual void enforceSortOrder() const; | 
|---|
| 182 | virtual void setHeight( int ); | 
|---|
| 183 | virtual void activate(); | 
|---|
| 184 |  | 
|---|
| 185 | bool activatedPos( QPoint & ); | 
|---|
| 186 | #ifndef QT_NO_DRAGANDDROP | 
|---|
| 187 | //@@TODO (dmik): no QDropEvent yet (MOC ignores preprocessor macros) | 
|---|
| 188 | //    virtual void dropped( QDropEvent *e ); | 
|---|
| 189 | #endif | 
|---|
| 190 | virtual void dragEntered(); | 
|---|
| 191 | virtual void dragLeft(); | 
|---|
| 192 | virtual void okRename( int col ); | 
|---|
| 193 | virtual void cancelRename( int col ); | 
|---|
| 194 |  | 
|---|
| 195 | void ignoreDoubleClick(); | 
|---|
| 196 |  | 
|---|
| 197 | private: | 
|---|
| 198 | void init(); | 
|---|
| 199 | void moveToJustAfter( QListViewItem * ); | 
|---|
| 200 | void enforceSortOrderBackToRoot(); | 
|---|
| 201 | void removeRenameBox(); | 
|---|
| 202 |  | 
|---|
| 203 | int ownHeight; | 
|---|
| 204 | int maybeTotalHeight; | 
|---|
| 205 | int nChildren; | 
|---|
| 206 |  | 
|---|
| 207 | uint lsc: 14; | 
|---|
| 208 | uint lso: 1; | 
|---|
| 209 | uint open : 1; | 
|---|
| 210 | uint selected : 1; | 
|---|
| 211 | uint selectable: 1; | 
|---|
| 212 | uint configured: 1; | 
|---|
| 213 | uint expandable: 1; | 
|---|
| 214 | uint is_root: 1; | 
|---|
| 215 | uint allow_drag : 1; | 
|---|
| 216 | uint allow_drop : 1; | 
|---|
| 217 | uint visible : 1; | 
|---|
| 218 | uint enabled : 1; | 
|---|
| 219 | uint mlenabled : 1; | 
|---|
| 220 |  | 
|---|
| 221 | QListViewItem * parentItem; | 
|---|
| 222 | QListViewItem * siblingItem; | 
|---|
| 223 | QListViewItem * childItem; | 
|---|
| 224 | QLineEdit *renameBox; | 
|---|
| 225 | int renameCol; | 
|---|
| 226 |  | 
|---|
| 227 | void * columns; | 
|---|
| 228 |  | 
|---|
| 229 | friend class QListView; | 
|---|
| 230 | }; | 
|---|
| 231 |  | 
|---|
| 232 | class QCheckListItem; | 
|---|
| 233 |  | 
|---|
| 234 | class Q_EXPORT QListView: public QScrollView | 
|---|
| 235 | { | 
|---|
| 236 | friend class QListViewItemIterator; | 
|---|
| 237 | friend class QListViewItem; | 
|---|
| 238 | friend class QCheckListItem; | 
|---|
| 239 | friend class QListViewToolTip; | 
|---|
| 240 |  | 
|---|
| 241 | Q_OBJECT | 
|---|
| 242 | Q_ENUMS( SelectionMode ResizeMode RenameAction ) | 
|---|
| 243 | Q_PROPERTY( int columns READ columns ) | 
|---|
| 244 | Q_PROPERTY( bool multiSelection READ isMultiSelection WRITE setMultiSelection DESIGNABLE false ) | 
|---|
| 245 | Q_PROPERTY( SelectionMode selectionMode READ selectionMode WRITE setSelectionMode ) | 
|---|
| 246 | Q_PROPERTY( int childCount READ childCount ) | 
|---|
| 247 | Q_PROPERTY( bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus ) | 
|---|
| 248 | Q_PROPERTY( bool showSortIndicator READ showSortIndicator WRITE setShowSortIndicator ) | 
|---|
| 249 | Q_PROPERTY( int itemMargin READ itemMargin WRITE setItemMargin ) | 
|---|
| 250 | Q_PROPERTY( bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated ) | 
|---|
| 251 | Q_PROPERTY( bool showToolTips READ showToolTips WRITE setShowToolTips ) | 
|---|
| 252 | Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode ) | 
|---|
| 253 | Q_PROPERTY( int treeStepSize READ treeStepSize WRITE setTreeStepSize ) | 
|---|
| 254 | Q_PROPERTY( RenameAction defaultRenameAction READ defaultRenameAction WRITE setDefaultRenameAction ) | 
|---|
| 255 |  | 
|---|
| 256 | public: | 
|---|
| 257 | QListView( QWidget* parent=0, const char* name=0, WFlags f = 0 ); | 
|---|
| 258 | ~QListView(); | 
|---|
| 259 |  | 
|---|
| 260 | int treeStepSize() const; | 
|---|
| 261 | virtual void setTreeStepSize( int ); | 
|---|
| 262 |  | 
|---|
| 263 | virtual void insertItem( QListViewItem * ); | 
|---|
| 264 | virtual void takeItem( QListViewItem * ); | 
|---|
| 265 | virtual void removeItem( QListViewItem *item ) { takeItem( item ); } // obsolete, use takeItem instead | 
|---|
| 266 |  | 
|---|
| 267 | QHeader * header() const; | 
|---|
| 268 |  | 
|---|
| 269 | virtual int addColumn( const QString &label, int size = -1); | 
|---|
| 270 | virtual int addColumn( const QIconSet& iconset, const QString &label, int size = -1); | 
|---|
| 271 | virtual void removeColumn( int index ); | 
|---|
| 272 | virtual void setColumnText( int column, const QString &label ); | 
|---|
| 273 | virtual void setColumnText( int column, const QIconSet& iconset, const QString &label ); | 
|---|
| 274 | QString columnText( int column ) const; | 
|---|
| 275 | virtual void setColumnWidth( int column, int width ); | 
|---|
| 276 | int columnWidth( int column ) const; | 
|---|
| 277 | enum WidthMode { Manual, Maximum }; | 
|---|
| 278 | virtual void setColumnWidthMode( int column, WidthMode ); | 
|---|
| 279 | WidthMode columnWidthMode( int column ) const; | 
|---|
| 280 | int columns() const; | 
|---|
| 281 |  | 
|---|
| 282 | virtual void setColumnAlignment( int, int ); | 
|---|
| 283 | int columnAlignment( int ) const; | 
|---|
| 284 |  | 
|---|
| 285 | void show(); | 
|---|
| 286 |  | 
|---|
| 287 | QListViewItem * itemAt( const QPoint & screenPos ) const; | 
|---|
| 288 | QRect itemRect( const QListViewItem * ) const; | 
|---|
| 289 | int itemPos( const QListViewItem * ); | 
|---|
| 290 |  | 
|---|
| 291 | void ensureItemVisible( const QListViewItem * ); | 
|---|
| 292 |  | 
|---|
| 293 | void repaintItem( const QListViewItem * ) const; | 
|---|
| 294 |  | 
|---|
| 295 | virtual void setMultiSelection( bool enable ); | 
|---|
| 296 | bool isMultiSelection() const; | 
|---|
| 297 |  | 
|---|
| 298 | enum SelectionMode { Single, Multi, Extended, NoSelection  }; | 
|---|
| 299 | void setSelectionMode( SelectionMode mode ); | 
|---|
| 300 | SelectionMode selectionMode() const; | 
|---|
| 301 |  | 
|---|
| 302 | virtual void clearSelection(); | 
|---|
| 303 | virtual void setSelected( QListViewItem *, bool ); | 
|---|
| 304 | void setSelectionAnchor( QListViewItem * ); | 
|---|
| 305 | bool isSelected( const QListViewItem * ) const; | 
|---|
| 306 | QListViewItem * selectedItem() const; | 
|---|
| 307 | virtual void setOpen( QListViewItem *, bool ); | 
|---|
| 308 | bool isOpen( const QListViewItem * ) const; | 
|---|
| 309 |  | 
|---|
| 310 | virtual void setCurrentItem( QListViewItem * ); | 
|---|
| 311 | QListViewItem * currentItem() const; | 
|---|
| 312 |  | 
|---|
| 313 | QListViewItem * firstChild() const; | 
|---|
| 314 | QListViewItem * lastItem() const; | 
|---|
| 315 |  | 
|---|
| 316 | int childCount() const; | 
|---|
| 317 |  | 
|---|
| 318 | virtual void setAllColumnsShowFocus( bool ); | 
|---|
| 319 | bool allColumnsShowFocus() const; | 
|---|
| 320 |  | 
|---|
| 321 | virtual void setItemMargin( int ); | 
|---|
| 322 | int itemMargin() const; | 
|---|
| 323 |  | 
|---|
| 324 | virtual void setRootIsDecorated( bool ); | 
|---|
| 325 | bool rootIsDecorated() const; | 
|---|
| 326 |  | 
|---|
| 327 | virtual void setSorting( int column, bool ascending = TRUE ); | 
|---|
| 328 | int sortColumn() const; | 
|---|
| 329 | void setSortColumn( int column ); | 
|---|
| 330 | SortOrder sortOrder() const; | 
|---|
| 331 | void setSortOrder( SortOrder order ); | 
|---|
| 332 | virtual void sort(); | 
|---|
| 333 |  | 
|---|
| 334 | virtual void setFont( const QFont & ); | 
|---|
| 335 | virtual void setPalette( const QPalette & ); | 
|---|
| 336 |  | 
|---|
| 337 | bool eventFilter( QObject * o, QEvent * ); | 
|---|
| 338 |  | 
|---|
| 339 | QSize sizeHint() const; | 
|---|
| 340 | QSize minimumSizeHint() const; | 
|---|
| 341 |  | 
|---|
| 342 | virtual void setShowSortIndicator( bool show ); | 
|---|
| 343 | bool showSortIndicator() const; | 
|---|
| 344 | virtual void setShowToolTips( bool b ); | 
|---|
| 345 | bool showToolTips() const; | 
|---|
| 346 |  | 
|---|
| 347 | enum ResizeMode { NoColumn, AllColumns, LastColumn }; | 
|---|
| 348 | virtual void setResizeMode( ResizeMode m ); | 
|---|
| 349 | ResizeMode resizeMode() const; | 
|---|
| 350 |  | 
|---|
| 351 | QListViewItem * findItem( const QString& text, int column, ComparisonFlags compare = ExactMatch | CaseSensitive ) const; | 
|---|
| 352 |  | 
|---|
| 353 | enum RenameAction { Accept, Reject }; | 
|---|
| 354 | virtual void setDefaultRenameAction( RenameAction a ); | 
|---|
| 355 | RenameAction defaultRenameAction() const; | 
|---|
| 356 | bool isRenaming() const; | 
|---|
| 357 |  | 
|---|
| 358 | void hideColumn( int column ); | 
|---|
| 359 |  | 
|---|
| 360 | public slots: | 
|---|
| 361 | virtual void clear(); | 
|---|
| 362 | virtual void invertSelection(); | 
|---|
| 363 | virtual void selectAll( bool select ); | 
|---|
| 364 | void triggerUpdate(); | 
|---|
| 365 | void setContentsPos( int x, int y ); | 
|---|
| 366 | void adjustColumn( int col ); | 
|---|
| 367 |  | 
|---|
| 368 | signals: | 
|---|
| 369 | void selectionChanged(); | 
|---|
| 370 | void selectionChanged( QListViewItem * ); | 
|---|
| 371 | void currentChanged( QListViewItem * ); | 
|---|
| 372 | void clicked( QListViewItem * ); | 
|---|
| 373 | void clicked( QListViewItem *, const QPoint &, int ); | 
|---|
| 374 | void pressed( QListViewItem * ); | 
|---|
| 375 | void pressed( QListViewItem *, const QPoint &, int ); | 
|---|
| 376 |  | 
|---|
| 377 | void doubleClicked( QListViewItem * ); | 
|---|
| 378 | void doubleClicked( QListViewItem *, const QPoint&, int ); | 
|---|
| 379 | void returnPressed( QListViewItem * ); | 
|---|
| 380 | void spacePressed( QListViewItem * ); | 
|---|
| 381 | void rightButtonClicked( QListViewItem *, const QPoint&, int ); | 
|---|
| 382 | void rightButtonPressed( QListViewItem *, const QPoint&, int ); | 
|---|
| 383 | void mouseButtonPressed( int, QListViewItem *, const QPoint& , int ); | 
|---|
| 384 | void mouseButtonClicked( int, QListViewItem *,  const QPoint&, int ); | 
|---|
| 385 |  | 
|---|
| 386 | void contextMenuRequested( QListViewItem *, const QPoint &, int ); | 
|---|
| 387 |  | 
|---|
| 388 | void onItem( QListViewItem *item ); | 
|---|
| 389 | void onViewport(); | 
|---|
| 390 |  | 
|---|
| 391 | void expanded( QListViewItem *item ); | 
|---|
| 392 | void collapsed( QListViewItem *item ); | 
|---|
| 393 | #ifndef QT_NO_DRAGANDDROP | 
|---|
| 394 | //@@TODO (dmik): no QDropEvent yet (MOC ignores preprocessor macros) | 
|---|
| 395 | //    void dropped( QDropEvent *e ); | 
|---|
| 396 | #endif | 
|---|
| 397 | void itemRenamed( QListViewItem *item, int col, const QString & ); | 
|---|
| 398 | void itemRenamed( QListViewItem *item, int col  ); | 
|---|
| 399 |  | 
|---|
| 400 | protected: | 
|---|
| 401 | void contentsMousePressEvent( QMouseEvent * e ); | 
|---|
| 402 | void contentsMouseReleaseEvent( QMouseEvent * e ); | 
|---|
| 403 | void contentsMouseMoveEvent( QMouseEvent * e ); | 
|---|
| 404 | void contentsMouseDoubleClickEvent( QMouseEvent * e ); | 
|---|
| 405 | void contentsContextMenuEvent( QContextMenuEvent * e ); | 
|---|
| 406 | #ifndef QT_NO_DRAGANDDROP | 
|---|
| 407 | //@@TODO (dmik): no QDrag* and QDrop* classes yet (MOC ignores preprocessor macros) | 
|---|
| 408 | //    void contentsDragEnterEvent( QDragEnterEvent *e ); | 
|---|
| 409 | //    void contentsDragMoveEvent( QDragMoveEvent *e ); | 
|---|
| 410 | //    void contentsDragLeaveEvent( QDragLeaveEvent *e ); | 
|---|
| 411 | //    void contentsDropEvent( QDropEvent *e ); | 
|---|
| 412 | //    virtual QDragObject *dragObject(); | 
|---|
| 413 | //    virtual void startDrag(); | 
|---|
| 414 | #endif | 
|---|
| 415 |  | 
|---|
| 416 | void focusInEvent( QFocusEvent * e ); | 
|---|
| 417 | void focusOutEvent( QFocusEvent * e ); | 
|---|
| 418 |  | 
|---|
| 419 | void keyPressEvent( QKeyEvent *e ); | 
|---|
| 420 |  | 
|---|
| 421 | void resizeEvent( QResizeEvent *e ); | 
|---|
| 422 | void viewportResizeEvent( QResizeEvent *e ); | 
|---|
| 423 |  | 
|---|
| 424 | void showEvent( QShowEvent * ); | 
|---|
| 425 |  | 
|---|
| 426 | void drawContentsOffset( QPainter *, int ox, int oy, | 
|---|
| 427 | int cx, int cy, int cw, int ch ); | 
|---|
| 428 |  | 
|---|
| 429 | virtual void paintEmptyArea( QPainter *, const QRect & ); | 
|---|
| 430 | void styleChange( QStyle& ); | 
|---|
| 431 | void windowActivationChange( bool ); | 
|---|
| 432 |  | 
|---|
| 433 | protected slots: | 
|---|
| 434 | void updateContents(); | 
|---|
| 435 | void doAutoScroll(); | 
|---|
| 436 |  | 
|---|
| 437 | private slots: | 
|---|
| 438 | void changeSortColumn( int ); | 
|---|
| 439 | void handleIndexChange(); | 
|---|
| 440 | void updateDirtyItems(); | 
|---|
| 441 | void makeVisible(); | 
|---|
| 442 | void handleSizeChange( int, int, int ); | 
|---|
| 443 | void startRename(); | 
|---|
| 444 | void openFocusItem(); | 
|---|
| 445 |  | 
|---|
| 446 | private: | 
|---|
| 447 | void contentsMousePressEventEx( QMouseEvent * e ); | 
|---|
| 448 | void contentsMouseReleaseEventEx( QMouseEvent * e ); | 
|---|
| 449 | void init(); | 
|---|
| 450 | void updateGeometries(); | 
|---|
| 451 | void buildDrawableList() const; | 
|---|
| 452 | void reconfigureItems(); | 
|---|
| 453 | void widthChanged(const QListViewItem*, int c); | 
|---|
| 454 | void handleItemChange( QListViewItem *old, bool shift, bool control ); | 
|---|
| 455 | void selectRange( QListViewItem *from, QListViewItem *to, bool invert, bool includeFirst, bool clearSel = FALSE ); | 
|---|
| 456 | bool selectRange( QListViewItem *newItem, QListViewItem *oldItem, QListViewItem *anchorItem ); | 
|---|
| 457 | bool clearRange( QListViewItem *from, QListViewItem *to, bool includeFirst = TRUE ); | 
|---|
| 458 | void doAutoScroll( const QPoint &cursorPos ); | 
|---|
| 459 |  | 
|---|
| 460 | QListViewPrivate * d; | 
|---|
| 461 |  | 
|---|
| 462 | private:        // Disabled copy constructor and operator= | 
|---|
| 463 | #if defined(Q_DISABLE_COPY) | 
|---|
| 464 | QListView( const QListView & ); | 
|---|
| 465 | QListView &operator=( const QListView & ); | 
|---|
| 466 | #endif | 
|---|
| 467 | }; | 
|---|
| 468 |  | 
|---|
| 469 |  | 
|---|
| 470 | class Q_EXPORT QCheckListItem : public QListViewItem | 
|---|
| 471 | { | 
|---|
| 472 | public: | 
|---|
| 473 | enum Type { RadioButton, | 
|---|
| 474 | CheckBox, | 
|---|
| 475 | Controller, | 
|---|
| 476 | RadioButtonController=Controller, | 
|---|
| 477 | CheckBoxController }; | 
|---|
| 478 | // ### should be integrated with qbutton in ver4 perhaps | 
|---|
| 479 | enum ToggleState { Off, NoChange, On }; | 
|---|
| 480 |  | 
|---|
| 481 | QCheckListItem( QCheckListItem *parent, const QString &text, | 
|---|
| 482 | Type = RadioButtonController ); | 
|---|
| 483 | QCheckListItem( QCheckListItem *parent, QListViewItem *after, | 
|---|
| 484 | const QString &text, Type = RadioButtonController ); | 
|---|
| 485 | QCheckListItem( QListViewItem *parent, const QString &text, | 
|---|
| 486 | Type = RadioButtonController ); | 
|---|
| 487 | QCheckListItem( QListViewItem *parent, QListViewItem *after, | 
|---|
| 488 | const QString &text, Type = RadioButtonController ); | 
|---|
| 489 | QCheckListItem( QListView *parent, const QString &text, | 
|---|
| 490 | Type = RadioButtonController ); | 
|---|
| 491 | QCheckListItem( QListView *parent, QListViewItem *after, | 
|---|
| 492 | const QString &text, Type = RadioButtonController ); | 
|---|
| 493 | QCheckListItem( QListViewItem *parent, const QString &text, | 
|---|
| 494 | const QPixmap & ); | 
|---|
| 495 | QCheckListItem( QListView *parent, const QString &text, | 
|---|
| 496 | const QPixmap & ); | 
|---|
| 497 | ~QCheckListItem(); | 
|---|
| 498 |  | 
|---|
| 499 | void paintCell( QPainter *,  const QColorGroup & cg, | 
|---|
| 500 | int column, int width, int alignment ); | 
|---|
| 501 | virtual void paintFocus( QPainter *, const QColorGroup & cg, | 
|---|
| 502 | const QRect & r ); | 
|---|
| 503 | int width( const QFontMetrics&, const QListView*, int column) const; | 
|---|
| 504 | void setup(); | 
|---|
| 505 |  | 
|---|
| 506 | virtual void setOn( bool ); // ### should be replaced by setChecked in ver4 | 
|---|
| 507 | bool isOn() const { return on; } | 
|---|
| 508 | Type type() const { return myType; } | 
|---|
| 509 | QString text() const { return QListViewItem::text( 0 ); } | 
|---|
| 510 | QString text( int n ) const { return QListViewItem::text( n ); } | 
|---|
| 511 |  | 
|---|
| 512 | void setTristate( bool ); | 
|---|
| 513 | bool isTristate() const; | 
|---|
| 514 | ToggleState state() const; | 
|---|
| 515 | void setState( ToggleState s); | 
|---|
| 516 |  | 
|---|
| 517 | int rtti() const; | 
|---|
| 518 | static int RTTI; | 
|---|
| 519 |  | 
|---|
| 520 | protected: | 
|---|
| 521 | void activate(); | 
|---|
| 522 | void turnOffChild(); | 
|---|
| 523 | virtual void stateChange( bool ); | 
|---|
| 524 |  | 
|---|
| 525 | private: | 
|---|
| 526 | void init(); | 
|---|
| 527 | ToggleState internalState() const; | 
|---|
| 528 | void setStoredState( ToggleState newState, void *key ); | 
|---|
| 529 | ToggleState storedState( void *key ) const; | 
|---|
| 530 | void stateChange( ToggleState s ); | 
|---|
| 531 | void restoreState( void *key, int depth = 0 ); | 
|---|
| 532 | void updateController( bool update = TRUE , bool store = FALSE ); | 
|---|
| 533 | void updateStoredState( void *key ); | 
|---|
| 534 | void setState( ToggleState s, bool update, bool store ); | 
|---|
| 535 | void setCurrentState( ToggleState s ); | 
|---|
| 536 |  | 
|---|
| 537 | Type myType; | 
|---|
| 538 | bool on; // ### remove in ver4 | 
|---|
| 539 | QCheckListItemPrivate *d; | 
|---|
| 540 | }; | 
|---|
| 541 |  | 
|---|
| 542 | class Q_EXPORT QListViewItemIterator | 
|---|
| 543 | { | 
|---|
| 544 | friend struct QListViewPrivate; | 
|---|
| 545 | friend class QListView; | 
|---|
| 546 | friend class QListViewItem; | 
|---|
| 547 |  | 
|---|
| 548 | public: | 
|---|
| 549 | enum IteratorFlag { | 
|---|
| 550 | Visible =               0x00000001, | 
|---|
| 551 | Invisible =             0x00000002, | 
|---|
| 552 | Selected =              0x00000004, | 
|---|
| 553 | Unselected =            0x00000008, | 
|---|
| 554 | Selectable =            0x00000010, | 
|---|
| 555 | NotSelectable =         0x00000020, | 
|---|
| 556 | DragEnabled =           0x00000040, | 
|---|
| 557 | DragDisabled =          0x00000080, | 
|---|
| 558 | DropEnabled =           0x00000100, | 
|---|
| 559 | DropDisabled =          0x00000200, | 
|---|
| 560 | Expandable =            0x00000400, | 
|---|
| 561 | NotExpandable =         0x00000800, | 
|---|
| 562 | Checked =               0x00001000, | 
|---|
| 563 | NotChecked =            0x00002000 | 
|---|
| 564 | }; | 
|---|
| 565 |  | 
|---|
| 566 | QListViewItemIterator(); | 
|---|
| 567 | QListViewItemIterator( QListViewItem *item ); | 
|---|
| 568 | QListViewItemIterator( QListViewItem *item, int iteratorFlags ); | 
|---|
| 569 |  | 
|---|
| 570 | QListViewItemIterator( const QListViewItemIterator &it ); | 
|---|
| 571 | QListViewItemIterator( QListView *lv ); | 
|---|
| 572 | QListViewItemIterator( QListView *lv, int iteratorFlags ); | 
|---|
| 573 |  | 
|---|
| 574 | QListViewItemIterator &operator=( const QListViewItemIterator &it ); | 
|---|
| 575 |  | 
|---|
| 576 | ~QListViewItemIterator(); | 
|---|
| 577 |  | 
|---|
| 578 | QListViewItemIterator &operator++(); | 
|---|
| 579 | const QListViewItemIterator operator++( int ); | 
|---|
| 580 | QListViewItemIterator &operator+=( int j ); | 
|---|
| 581 |  | 
|---|
| 582 | QListViewItemIterator &operator--(); | 
|---|
| 583 | const QListViewItemIterator operator--( int ); | 
|---|
| 584 | QListViewItemIterator &operator-=( int j ); | 
|---|
| 585 |  | 
|---|
| 586 | QListViewItem* operator*(); | 
|---|
| 587 | QListViewItem *current() const; | 
|---|
| 588 |  | 
|---|
| 589 | protected: | 
|---|
| 590 | QListViewItem *curr; | 
|---|
| 591 | QListView *listView; | 
|---|
| 592 |  | 
|---|
| 593 | private: | 
|---|
| 594 | QListViewItemIteratorPrivate* d() const; | 
|---|
| 595 | void init( int flags ); | 
|---|
| 596 | void addToListView(); | 
|---|
| 597 | void currentRemoved(); | 
|---|
| 598 | bool matchesFlags( const QListViewItem* ) const; | 
|---|
| 599 | bool testPair( QListViewItemIterator::IteratorFlag, QListViewItemIterator::IteratorFlag, bool ) const; | 
|---|
| 600 | bool isChecked( const QListViewItem* ) const; | 
|---|
| 601 | }; | 
|---|
| 602 |  | 
|---|
| 603 | #endif // QT_NO_LISTVIEW | 
|---|
| 604 |  | 
|---|
| 605 | #endif // QLISTVIEW_H | 
|---|