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 00415 // KDE 4: Remove this signal...already in QListView 00416 void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); 00417 00428 void dropped (QDropEvent * e, QListViewItem *after); 00429 00442 void dropped (KListView* list, QDropEvent* e, QListViewItem* after); 00443 00456 void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); 00457 00469 void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); 00470 00477 void moved(); 00478 00487 void aboutToMove(); 00488 00500 void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); 00501 00502 00508 void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); 00509 00517 void itemRenamed(QListViewItem* item, const QString &str, int col); 00518 00522 void itemRenamed(QListViewItem* item); 00523 00534 void menuShortCutPressed (KListView* list, QListViewItem* item); 00535 00544 void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); 00545 00546 public slots: 00550 virtual void rename(QListViewItem *item, int c); 00551 00562 void setRenameable (int column, bool yesno=true); 00563 00570 virtual void setItemsMovable(bool b); 00571 00579 virtual void setItemsRenameable(bool b); 00580 00585 virtual void setDragEnabled(bool b); 00586 00590 virtual void setAutoOpen(bool b); 00591 00597 virtual void setDropVisualizer(bool b); 00598 00603 void setDropVisualizerWidth (int w); 00604 00611 virtual void setTooltipColumn(int column); 00612 00618 virtual void setDropHighlighter(bool b); 00619 00626 virtual void setCreateChildren(bool b) KDE_DEPRECATED; 00627 00633 void setSelectionModeExt (SelectionModeExt mode); 00634 00639 void setTabOrderedRenaming(bool b); 00640 00645 bool tabOrderedRenaming() const; 00646 00647 protected: 00656 inline bool below (const QRect& rect, const QPoint& p) 00657 { 00658 return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); 00659 } 00660 00670 inline bool below (QListViewItem* i, const QPoint& p) 00671 { 00672 return below (itemRect(i), contentsToViewport(p)); 00673 } 00674 00679 virtual bool event( QEvent * ); 00680 00685 void emitExecute( QListViewItem *item, const QPoint &pos, int c ); 00686 00694 virtual void focusInEvent(QFocusEvent* fe); 00695 00703 virtual void focusOutEvent( QFocusEvent *fe ); 00704 00712 virtual void leaveEvent( QEvent *e ); 00713 00717 virtual QString tooltip(QListViewItem* item, int column) const; 00718 00722 virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; 00723 00731 virtual void contentsDragMoveEvent (QDragMoveEvent *event); 00732 00740 virtual void contentsMousePressEvent( QMouseEvent *e ); 00741 00749 virtual void contentsMouseMoveEvent( QMouseEvent *e ); 00750 00758 virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); 00759 00767 virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); 00768 00776 virtual void contentsMouseReleaseEvent (QMouseEvent*); 00777 00785 virtual void contentsDropEvent (QDropEvent*); 00786 00794 virtual void contentsDragEnterEvent (QDragEnterEvent *); 00795 00801 virtual QDragObject *dragObject(); 00802 00808 virtual bool acceptDrag (QDropEvent* event) const; 00809 00817 virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); 00818 00825 virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); 00826 00833 virtual void startDrag(); 00834 00842 virtual void keyPressEvent (QKeyEvent*); 00843 00851 virtual void viewportPaintEvent(QPaintEvent*); 00852 00857 void activateAutomaticSelection(); 00862 void deactivateAutomaticSelection(); 00868 bool automaticSelection() const; 00869 00873 virtual void viewportResizeEvent(QResizeEvent* e); 00874 00882 void disableAutoSelection(); 00883 00889 void resetAutoSelection(); 00890 00891 protected slots: 00896 void slotSettingsChanged(int); 00897 00898 void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); 00899 void doneEditing(QListViewItem *item, int row); 00900 00904 void cleanDropVisualizer(); 00905 00909 void cleanItemHighlighter(); 00910 00914 void emitContextMenu (QListViewItem*, const QPoint&, int); 00915 00919 void emitContextMenu (KListView*, QListViewItem*); 00920 00925 void slotOnItem( QListViewItem *item ); 00926 00931 void slotOnViewport(); 00932 00937 void slotAutoSelect(); 00938 00939 void slotDragExpand(); 00940 00945 void slotHeaderChanged(); 00946 00947 protected: 00951 virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); 00952 00959 virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); 00960 00964 void fileManagerKeyPressEvent (QKeyEvent*); 00965 00969 int depthToPixels( int depth ); 00970 00971 private: 00972 class Tooltip; 00973 protected: 00974 virtual void virtual_hook( int id, void* data ); 00975 private: 00976 class KListViewPrivate; 00977 KListViewPrivate *d; 00978 }; 00979 00986 class KListViewItem : public QListViewItem 00987 { 00988 public: 00995 KListViewItem(QListView *parent); 00996 KListViewItem(QListViewItem *parent); 00997 KListViewItem(QListView *parent, QListViewItem *after); 00998 KListViewItem(QListViewItem *parent, QListViewItem *after); 00999 01000 KListViewItem(QListView *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(QListViewItem *parent, 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(QListView *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 KListViewItem(QListViewItem *parent, QListViewItem *after, 01019 QString, QString = QString::null, 01020 QString = QString::null, QString = QString::null, 01021 QString = QString::null, QString = QString::null, 01022 QString = QString::null, QString = QString::null); 01023 01024 virtual ~KListViewItem(); 01025 01029 bool isAlternate(); 01033 const QColor &backgroundColor(); 01034 01035 virtual void paintCell(QPainter *p, const QColorGroup &cg, 01036 int column, int width, int alignment); 01037 01038 private: 01039 void init(); 01040 01041 private: 01042 uint m_odd : 1; 01043 uint m_known : 1; 01044 uint m_unused : 30; 01045 }; 01046 01047 #endif 01048 01049 // vim: ts=2 sw=2 et
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Aug 30 22:53:58 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003