kdeui Library API Documentation

klistview.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> 00003 Copyright (C) 2000 Charles Samuels <charles@kde.org> 00004 Copyright (C) 2000 Peter Putzer <putzer@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 #ifndef KLISTVIEW_H 00021 #define KLISTVIEW_H 00022 00023 #include <qlistview.h> 00024 00025 #include <qptrlist.h> 00026 #include <kdemacros.h> 00027 00028 class QDragObject; 00029 class KConfig; 00030 class KLineEdit; 00053 class KListView : public QListView 00054 { 00055 friend class KListViewItem; 00056 00057 Q_OBJECT 00058 Q_ENUMS( SelectionModeExt ) 00059 Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) 00060 Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) 00061 Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) 00062 Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) 00063 Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) 00064 Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) 00065 Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) 00066 Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) 00067 Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) 00068 00069 Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) 00070 00071 public: 00103 enum SelectionModeExt { 00104 Single = QListView::Single, 00105 Multi = QListView::Multi, 00106 Extended = QListView::Extended, 00107 NoSelection = QListView::NoSelection, 00108 FileManager 00109 }; 00110 00117 KListView (QWidget *parent = 0, const char *name = 0); 00118 00122 virtual ~KListView(); 00123 00131 virtual void setAcceptDrops (bool); 00132 00142 virtual bool isExecuteArea( const QPoint& point ); 00143 00149 bool isExecuteArea( int x ); 00150 00154 QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) 00155 00163 void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) KDE_DEPRECATED; 00164 00170 QListViewItem *lastItem() const; 00171 00177 QListViewItem* lastChild () const; 00178 00185 KLineEdit* renameLineEdit() const; 00186 00193 bool itemsMovable() const; 00194 00200 bool itemsRenameable() const; 00201 00207 bool dragEnabled() const; 00208 00214 bool autoOpen() const; 00215 00221 bool isRenameable (int column) const; 00222 00228 bool dropVisualizer() const; 00229 00235 int tooltipColumn() const; 00236 00243 bool createChildren() const KDE_DEPRECATED; 00244 00250 bool dropHighlighter() const; 00251 00258 int dropVisualizerWidth () const; 00259 00266 SelectionModeExt selectionModeExt () const; 00267 00273 int itemIndex( const QListViewItem *item ) const; 00274 00280 QListViewItem* itemAtIndex(int index); 00281 00286 void setFullWidth() KDE_DEPRECATED; 00287 00293 void setFullWidth(bool fullWidth); 00294 00300 bool fullWidth() const; 00301 00307 virtual int addColumn(const QString& label, int width = -1); 00311 virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); 00317 virtual void removeColumn(int index); 00318 00328 void setAlternateBackground(const QColor &c); 00334 const QColor &alternateBackground() const; 00335 00343 void saveLayout(KConfig *config, const QString &group) const; 00351 void restoreLayout(KConfig *config, const QString &group); 00358 virtual void setSorting(int column, bool ascending = true); 00359 00363 int columnSorted(void) const; 00364 00368 bool ascendingSort(void) const; 00369 00373 virtual void takeItem(QListViewItem *i); 00374 00375 signals: 00376 00386 void executed( QListViewItem *item ); 00387 00399 void executed( QListViewItem *item, const QPoint &pos, int c ); 00400 00411 void dropped (QDropEvent * e, QListViewItem *after); 00412 00425 void dropped (KListView* list, QDropEvent* e, QListViewItem* after); 00426 00439 void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); 00440 00452 void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); 00453 00460 void moved(); 00461 00470 void aboutToMove(); 00471 00483 void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); 00484 00485 00491 void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); 00492 00500 void itemRenamed(QListViewItem* item, const QString &str, int col); 00501 00505 void itemRenamed(QListViewItem* item); 00506 00517 void menuShortCutPressed (KListView* list, QListViewItem* item); 00518 00527 void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); 00528 00529 void itemAdded(QListViewItem *item); 00530 void itemRemoved(QListViewItem *item); 00531 00532 public slots: 00536 virtual void rename(QListViewItem *item, int c); 00537 00548 void setRenameable (int column, bool yesno=true); 00549 00556 virtual void setItemsMovable(bool b); 00557 00565 virtual void setItemsRenameable(bool b); 00566 00571 virtual void setDragEnabled(bool b); 00572 00576 virtual void setAutoOpen(bool b); 00577 00583 virtual void setDropVisualizer(bool b); 00584 00589 void setDropVisualizerWidth (int w); 00590 00597 virtual void setTooltipColumn(int column); 00598 00604 virtual void setDropHighlighter(bool b); 00605 00612 virtual void setCreateChildren(bool b) KDE_DEPRECATED; 00613 00619 void setSelectionModeExt (SelectionModeExt mode); 00620 00625 void setTabOrderedRenaming(bool b); 00626 00631 bool tabOrderedRenaming() const; 00632 00633 protected: 00642 inline bool below (const QRect& rect, const QPoint& p) 00643 { 00644 return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); 00645 } 00646 00656 inline bool below (QListViewItem* i, const QPoint& p) 00657 { 00658 return below (itemRect(i), contentsToViewport(p)); 00659 } 00660 00665 virtual bool event( QEvent * ); 00666 00671 void emitExecute( QListViewItem *item, const QPoint &pos, int c ); 00672 00680 virtual void focusInEvent(QFocusEvent* fe); 00681 00689 virtual void focusOutEvent( QFocusEvent *fe ); 00690 00698 virtual void leaveEvent( QEvent *e ); 00699 00703 virtual QString tooltip(QListViewItem* item, int column) const; 00704 00708 virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; 00709 00717 virtual void contentsDragMoveEvent (QDragMoveEvent *event); 00718 00726 virtual void contentsMousePressEvent( QMouseEvent *e ); 00727 00735 virtual void contentsMouseMoveEvent( QMouseEvent *e ); 00736 00744 virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); 00745 00753 virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); 00754 00762 virtual void contentsMouseReleaseEvent (QMouseEvent*); 00763 00771 virtual void contentsDropEvent (QDropEvent*); 00772 00780 virtual void contentsDragEnterEvent (QDragEnterEvent *); 00781 00787 virtual QDragObject *dragObject(); 00788 00794 virtual bool acceptDrag (QDropEvent* event) const; 00795 00803 virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); 00804 00811 virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); 00812 00819 virtual void startDrag(); 00820 00828 virtual void keyPressEvent (QKeyEvent*); 00829 00837 virtual void viewportPaintEvent(QPaintEvent*); 00838 00843 void activateAutomaticSelection(); 00848 void deactivateAutomaticSelection(); 00854 bool automaticSelection() const; 00855 00859 virtual void viewportResizeEvent(QResizeEvent* e); 00860 00868 void disableAutoSelection(); 00869 00875 void resetAutoSelection(); 00876 00881 // KDE 4: remove 00882 void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); 00883 00884 protected slots: 00889 void slotSettingsChanged(int); 00890 00891 void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); 00892 void doneEditing(QListViewItem *item, int row); 00893 00897 void cleanDropVisualizer(); 00898 00902 void cleanItemHighlighter(); 00903 00907 void emitContextMenu (QListViewItem*, const QPoint&, int); 00908 00912 void emitContextMenu (KListView*, QListViewItem*); 00913 00918 void slotOnItem( QListViewItem *item ); 00919 00924 void slotOnViewport(); 00925 00930 void slotAutoSelect(); 00931 00932 void slotDragExpand(); 00933 00938 void slotHeaderChanged(); 00939 00940 protected: 00944 virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); 00945 00952 virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); 00953 00957 void fileManagerKeyPressEvent (QKeyEvent*); 00958 00962 int depthToPixels( int depth ); 00963 00964 private: 00965 class Tooltip; 00966 protected: 00967 virtual void virtual_hook( int id, void* data ); 00968 private: 00969 class KListViewPrivate; 00970 KListViewPrivate *d; 00971 }; 00972 00979 class KListViewItem : public QListViewItem 00980 { 00981 friend class KListView; 00982 public: 00989 KListViewItem(QListView *parent); 00990 KListViewItem(QListViewItem *parent); 00991 KListViewItem(QListView *parent, QListViewItem *after); 00992 KListViewItem(QListViewItem *parent, QListViewItem *after); 00993 00994 KListViewItem(QListView *parent, 00995 QString, QString = QString::null, 00996 QString = QString::null, QString = QString::null, 00997 QString = QString::null, QString = QString::null, 00998 QString = QString::null, QString = QString::null); 00999 01000 KListViewItem(QListViewItem *parent, 01001 QString, QString = QString::null, 01002 QString = QString::null, QString = QString::null, 01003 QString = QString::null, QString = QString::null, 01004 QString = QString::null, QString = QString::null); 01005 01006 KListViewItem(QListView *parent, QListViewItem *after, 01007 QString, QString = QString::null, 01008 QString = QString::null, QString = QString::null, 01009 QString = QString::null, QString = QString::null, 01010 QString = QString::null, QString = QString::null); 01011 01012 KListViewItem(QListViewItem *parent, QListViewItem *after, 01013 QString, QString = QString::null, 01014 QString = QString::null, QString = QString::null, 01015 QString = QString::null, QString = QString::null, 01016 QString = QString::null, QString = QString::null); 01017 01018 virtual ~KListViewItem(); 01019 01020 virtual void insertItem(QListViewItem *item); 01021 virtual void takeItem(QListViewItem *item); 01022 01026 bool isAlternate(); 01030 const QColor &backgroundColor(); 01031 01032 virtual void paintCell(QPainter *p, const QColorGroup &cg, 01033 int column, int width, int alignment); 01034 01035 private: 01036 void init(); 01037 01038 private: 01039 uint m_odd : 1; 01040 uint m_known : 1; 01041 uint m_unused : 30; 01042 }; 01043 01044 #endif 01045 01046 // vim: ts=2 sw=2 et
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:40:33 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003