| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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
    00027 class QDragObject;
    00028 class KConfig;
    00029 class KLineEdit;
    00054 class KListView : public QListView
    00055 {
    00056   friend class KListViewItem;
    00057
    00058   Q_OBJECT
    00059   Q_ENUMS( SelectionModeExt )
    00060   Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth )
    00061   Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt )
    00062
    00063 public:
    00095   enum SelectionModeExt {
    00096         Single = QListView::Single,
    00097         Multi = QListView::Multi,
    00098         Extended = QListView::Extended,
    00099         NoSelection = QListView::NoSelection,
    00100         FileManager
    00101   };
    00102
    00109   KListView (QWidget *parent = 0, const char *name = 0);
    00110
    00114   virtual ~KListView();
    00115
    00123   virtual void setAcceptDrops (bool);
    00124
    00134   virtual bool isExecuteArea( const QPoint& point );
    00135
    00141   bool isExecuteArea( int x );
    00142
    00146   QPtrList<QListViewItem> selectedItems() const;
    00147
    00151   void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after);
    00152
    00158   QListViewItem *lastItem() const;
    00159
    00163   QListViewItem* lastChild () const;
    00164
    00169   KLineEdit* renameLineEdit() const;
    00170
    00174   bool itemsMovable() const;
    00175
    00181   bool itemsRenameable() const;
    00182
    00186   bool dragEnabled() const;
    00187
    00193   bool autoOpen() const;
    00194
    00198   bool isRenameable (int column) const;
    00199
    00203   bool dropVisualizer() const;
    00204
    00208   int tooltipColumn() const;
    00209
    00216   bool createChildren() const;
    00217
    00221   bool dropHighlighter() const;
    00222
    00228   int dropVisualizerWidth () const;
    00229
    00236   SelectionModeExt selectionModeExt () const;
    00237
    00243   int itemIndex( const QListViewItem *item ) const;
    00244
    00250   QListViewItem* itemAtIndex(int index);
    00251
    00255   void setFullWidth();
    00259   void setFullWidth(bool fullWidth);
    00263   bool fullWidth() const;
    00267   virtual int addColumn(const QString& label, int width = -1);
    00271   virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1);
    00275   virtual void removeColumn(int index);
    00276
    00284   void setAlternateBackground(const QColor &c);
    00288   const QColor &alternateBackground() const;
    00289
    00297   void saveLayout(KConfig *config, const QString &group) const;
    00305   void restoreLayout(KConfig *config, const QString &group);
    00309   virtual void setSorting(int column, bool ascending = true);
    00310
    00314   int columnSorted(void) const;
    00315
    00319   bool ascendingSort(void) const;
    00320
    00321 signals:
    00322
    00332   void executed( QListViewItem *item );
    00333
    00345   void executed( QListViewItem *item, const QPoint &pos, int c );
    00346
    00361   void doubleClicked( QListViewItem *item, const QPoint &pos, int c );
    00362
    00373   void dropped (QDropEvent * e, QListViewItem *after);
    00374
    00387   void dropped (KListView* list, QDropEvent* e, QListViewItem* after);
    00388
    00401   void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after);
    00402
    00414   void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after);
    00415
    00422   void moved();
    00423
    00432         void aboutToMove();
    00433
    00446   void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow);
    00447
    00448
    00454   void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow);
    00455
    00463   void itemRenamed(QListViewItem* item, const QString &str, int col);
    00464
    00468   void itemRenamed(QListViewItem* item);
    00469
    00480   void menuShortCutPressed (KListView* list, QListViewItem* item);
    00481
    00490   void contextMenu (KListView* l, QListViewItem* i, const QPoint& p);
    00491
    00492 public slots:
    00496   virtual void rename(QListViewItem *item, int c);
    00497
    00508   void setRenameable (int column, bool yesno=true);
    00509
    00516   virtual void setItemsMovable(bool b);
    00517
    00525   virtual void setItemsRenameable(bool b);
    00526
    00531   virtual void setDragEnabled(bool b);
    00532
    00536   virtual void setAutoOpen(bool b);
    00537
    00543   virtual void setDropVisualizer(bool b);
    00544
    00549   void setDropVisualizerWidth (int w);
    00550
    00557   virtual void setTooltipColumn(int column);
    00558
    00564   virtual void setDropHighlighter(bool b);
    00565
    00572   virtual void setCreateChildren(bool b);
    00573
    00579   void setSelectionModeExt (SelectionModeExt mode);
    00580
    00585   void setTabOrderedRenaming(bool b);
    00586
    00591   bool tabOrderedRenaming() const;
    00592
    00593 protected:
    00602   inline bool below (const QRect& rect, const QPoint& p)
    00603   {
    00604         return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2));
    00605   }
    00606
    00616   inline bool below (QListViewItem* i, const QPoint& p)
    00617   {
    00618         return below (itemRect(i), contentsToViewport(p));
    00619   }
    00620
    00625   virtual bool event( QEvent * );
    00626
    00631   void emitExecute( QListViewItem *item, const QPoint &pos, int c );
    00632
    00640    virtual void focusInEvent(QFocusEvent* fe);
    00641
    00649   virtual void focusOutEvent( QFocusEvent *fe );
    00650
    00658   virtual void leaveEvent( QEvent *e );
    00659
    00663   virtual QString tooltip(QListViewItem* item, int column) const;
    00664
    00668   virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const;
    00669
    00677   virtual void contentsDragMoveEvent (QDragMoveEvent *event);
    00678
    00686   virtual void contentsMousePressEvent( QMouseEvent *e );
    00687
    00695   virtual void contentsMouseMoveEvent( QMouseEvent *e );
    00696
    00704   virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e );
    00705
    00713   virtual void contentsDragLeaveEvent (QDragLeaveEvent *event);
    00714
    00722   virtual void contentsMouseReleaseEvent (QMouseEvent*);
    00723
    00731   virtual void contentsDropEvent (QDropEvent*);
    00732
    00740   virtual void contentsDragEnterEvent (QDragEnterEvent *);
    00741
    00747   virtual QDragObject *dragObject();
    00748
    00754   virtual bool acceptDrag (QDropEvent* event) const;
    00755
    00763   virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after);
    00764
    00771   virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item);
    00772
    00779   virtual void startDrag();
    00780
    00788   virtual void keyPressEvent (QKeyEvent*);
    00789
    00797   virtual void viewportPaintEvent(QPaintEvent*);
    00798
    00803   void activateAutomaticSelection();
    00808   void deactivateAutomaticSelection();
    00814   bool automaticSelection() const;
    00815
    00819   virtual void viewportResizeEvent(QResizeEvent* e);
    00820
    00821 protected slots:
    00826   void slotSettingsChanged(int);
    00827
    00828   void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c );
    00829   void doneEditing(QListViewItem *item, int row);
    00830
    00834   void cleanDropVisualizer();
    00835
    00839   void cleanItemHighlighter();
    00840
    00844   void emitContextMenu (QListViewItem*, const QPoint&, int);
    00845
    00849   void emitContextMenu (KListView*, QListViewItem*);
    00850
    00855   void slotOnItem( QListViewItem *item );
    00856
    00861   void slotOnViewport();
    00862
    00867   void slotAutoSelect();
    00868
    00873   void slotHeaderChanged();
    00874
    00875 protected:
    00879   virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme);
    00880
    00884   virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after);
    00885
    00889   void fileManagerKeyPressEvent (QKeyEvent*);
    00890
    00894   int depthToPixels( int depth );
    00895
    00896 private:
    00897   class Tooltip;
    00898 protected:
    00899   virtual void virtual_hook( int id, void* data );
    00900 private:
    00901   class KListViewPrivate;
    00902   KListViewPrivate *d;
    00903 };
    00904
    00911 class KListViewItem : public QListViewItem
    00912 {
    00913 public:
    00920   KListViewItem(QListView *parent);
    00921   KListViewItem(QListViewItem *parent);
    00922   KListViewItem(QListView *parent, QListViewItem *after);
    00923   KListViewItem(QListViewItem *parent, QListViewItem *after);
    00924
    00925   KListViewItem(QListView *parent,
    00926     QString, QString = QString::null,
    00927     QString = QString::null, QString = QString::null,
    00928     QString = QString::null, QString = QString::null,
    00929     QString = QString::null, QString = QString::null);
    00930
    00931   KListViewItem(QListViewItem *parent,
    00932     QString, QString = QString::null,
    00933     QString = QString::null, QString = QString::null,
    00934     QString = QString::null, QString = QString::null,
    00935     QString = QString::null, QString = QString::null);
    00936
    00937   KListViewItem(QListView *parent, QListViewItem *after,
    00938     QString, QString = QString::null,
    00939     QString = QString::null, QString = QString::null,
    00940     QString = QString::null, QString = QString::null,
    00941     QString = QString::null, QString = QString::null);
    00942
    00943   KListViewItem(QListViewItem *parent, QListViewItem *after,
    00944     QString, QString = QString::null,
    00945     QString = QString::null, QString = QString::null,
    00946     QString = QString::null, QString = QString::null,
    00947     QString = QString::null, QString = QString::null);
    00948
    00949   virtual ~KListViewItem();
    00950
    00954   bool isAlternate();
    00958   const QColor &backgroundColor();
    00959
    00960   virtual void paintCell(QPainter *p, const QColorGroup &cg,
    00961     int column, int width, int alignment);
    00962
    00963 private:
    00964   void init();
    00965
    00966 private:
    00967   uint m_odd : 1;
    00968   uint m_known : 1;
    00969   uint m_unused : 30;
    00970 };
    00971
    00972 #endif
    00973
    00974 // vim: ts=2 sw=2 et

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:57:16 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001