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 
00027 class QDragObject;
00028 class KConfig;
00029 class KLineEdit;
00054 class KListView : public QListView
00055 {
00056   Q_OBJECT
00057   Q_ENUMS( SelectionModeExt )
00058   Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth )
00059   Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt )
00060 
00061 public:
00093   enum SelectionModeExt {
00094     Single = QListView::Single,
00095     Multi = QListView::Multi,
00096     Extended = QListView::Extended,
00097     NoSelection = QListView::NoSelection,
00098     FileManager
00099   };
00100 
00107   KListView (QWidget *parent = 0, const char *name = 0);
00108 
00112   virtual ~KListView();
00113 
00121   virtual void setAcceptDrops (bool);
00122 
00132   virtual bool isExecuteArea( const QPoint& point );
00133 
00139   bool isExecuteArea( int x );
00140 
00144   QPtrList<QListViewItem> selectedItems() const;
00145 
00149   void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after);
00150 
00156   QListViewItem *lastItem() const;
00157 
00161   QListViewItem* lastChild () const;
00162 
00167   KLineEdit* renameLineEdit() const;
00168 
00172   bool itemsMovable() const;
00173 
00179   bool itemsRenameable() const;
00180 
00184   bool dragEnabled() const;
00185 
00191   bool autoOpen() const;
00192 
00196   bool isRenameable (int column) const;
00197 
00201   bool dropVisualizer() const;
00202 
00206   int tooltipColumn() const;
00207 
00214   bool createChildren() const;
00215 
00219   bool dropHighlighter() const;
00220 
00226   int dropVisualizerWidth () const;
00227 
00234   SelectionModeExt selectionModeExt () const;
00235 
00241   int itemIndex( const QListViewItem *item ) const;
00242 
00248   QListViewItem* itemAtIndex(int index);
00249 
00253   void setFullWidth();
00257   void setFullWidth(bool fullWidth);
00261   bool fullWidth() const;
00265   virtual int addColumn(const QString& label, int width = -1);
00269   virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1);
00273   virtual void removeColumn(int index);
00274 
00282   void setAlternateBackground(const QColor &c);
00286   const QColor &alternateBackground() const;
00287 
00295   void saveLayout(KConfig *config, const QString &group) const;
00303   void restoreLayout(KConfig *config, const QString &group);
00307   virtual void setSorting(int column, bool ascending = true);
00308 
00312   int columnSorted(void) const;
00313 
00317   bool ascendingSort(void) const;
00318 
00319 signals:
00320 
00330   void executed( QListViewItem *item );
00331 
00343   void executed( QListViewItem *item, const QPoint &pos, int c );
00344 
00359   void doubleClicked( QListViewItem *item, const QPoint &pos, int c );
00360 
00371   void dropped (QDropEvent * e, QListViewItem *after);
00372 
00385   void dropped (KListView* list, QDropEvent* e, QListViewItem* after);
00386 
00399   void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after);
00400 
00412   void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after);
00413 
00420   void moved();
00421 
00430     void aboutToMove();
00431 
00444   void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow);
00445 
00446 
00452   void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow);
00453 
00461   void itemRenamed(QListViewItem* item, const QString &str, int col);
00462 
00466   void itemRenamed(QListViewItem* item);
00467 
00478   void menuShortCutPressed (KListView* list, QListViewItem* item);
00479 
00488   void contextMenu (KListView* l, QListViewItem* i, const QPoint& p);
00489 
00490 public slots:
00494   virtual void rename(QListViewItem *item, int c);
00495 
00506   void setRenameable (int column, bool yesno=true);
00507 
00514   virtual void setItemsMovable(bool b);
00515 
00523   virtual void setItemsRenameable(bool b);
00524 
00529   virtual void setDragEnabled(bool b);
00530 
00534   virtual void setAutoOpen(bool b);
00535 
00541   virtual void setDropVisualizer(bool b);
00542 
00547   void setDropVisualizerWidth (int w);
00548 
00555   virtual void setTooltipColumn(int column);
00556 
00562   virtual void setDropHighlighter(bool b);
00563 
00570   virtual void setCreateChildren(bool b);
00571 
00577   void setSelectionModeExt (SelectionModeExt mode);
00578 
00583   void setTabOrderedRenaming(bool b);
00584 
00589   bool tabOrderedRenaming() const;
00590 
00591 protected:
00600   inline bool below (const QRect& rect, const QPoint& p)
00601   {
00602     return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2));
00603   }
00604 
00614   inline bool below (QListViewItem* i, const QPoint& p)
00615   {
00616     return below (itemRect(i), contentsToViewport(p));
00617   }
00618 
00623   virtual bool event( QEvent * );
00624 
00629   void emitExecute( QListViewItem *item, const QPoint &pos, int c );
00630 
00638    virtual void focusInEvent(QFocusEvent* fe);
00639 
00647   virtual void focusOutEvent( QFocusEvent *fe );
00648 
00656   virtual void leaveEvent( QEvent *e );
00657 
00661   virtual QString tooltip(QListViewItem* item, int column) const;
00662 
00666   virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const;
00667 
00675   virtual void contentsDragMoveEvent (QDragMoveEvent *event);
00676 
00684   virtual void contentsMousePressEvent( QMouseEvent *e );
00685 
00693   virtual void contentsMouseMoveEvent( QMouseEvent *e );
00694 
00702   virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e );
00703 
00711   virtual void contentsDragLeaveEvent (QDragLeaveEvent *event);
00712 
00720   virtual void contentsMouseReleaseEvent (QMouseEvent*);
00721 
00729   virtual void contentsDropEvent (QDropEvent*);
00730 
00738   virtual void contentsDragEnterEvent (QDragEnterEvent *);
00739 
00745   virtual QDragObject *dragObject();
00746 
00752   virtual bool acceptDrag (QDropEvent* event) const;
00753 
00761   virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after);
00762 
00769   virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item);
00770 
00777   virtual void startDrag();
00778 
00786   virtual void keyPressEvent (QKeyEvent*);
00787 
00795   virtual void viewportPaintEvent(QPaintEvent*);
00796 
00801   void activateAutomaticSelection();
00806   void deactivateAutomaticSelection();
00812   bool automaticSelection() const;
00813 
00817   virtual void viewportResizeEvent(QResizeEvent* e);
00818 
00819 protected slots:
00824   void slotSettingsChanged(int);
00825 
00826   void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c );
00827   void doneEditing(QListViewItem *item, int row);
00828 
00832   void cleanDropVisualizer();
00833 
00837   void cleanItemHighlighter();
00838 
00842   void emitContextMenu (QListViewItem*, const QPoint&, int);
00843 
00847   void emitContextMenu (KListView*, QListViewItem*);
00848 
00853   void slotOnItem( QListViewItem *item );
00854 
00859   void slotOnViewport();
00860 
00865   void slotAutoSelect();
00866 
00871   void slotHeaderChanged();
00872 
00873 protected:
00877   virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme);
00878 
00882   virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after);
00883 
00887   void fileManagerKeyPressEvent (QKeyEvent*);
00888 
00892   int depthToPixels( int depth );
00893 
00894 private:
00895   class Tooltip;
00896 protected:
00897   virtual void virtual_hook( int id, void* data );
00898 private:
00899   class KListViewPrivate;
00900   KListViewPrivate *d;
00901 };
00902 
00909 class KListViewItem : public QListViewItem
00910 {
00911 public:
00918   KListViewItem(QListView *parent);
00919   KListViewItem(QListViewItem *parent);
00920   KListViewItem(QListView *parent, QListViewItem *after);
00921   KListViewItem(QListViewItem *parent, QListViewItem *after);
00922 
00923   KListViewItem(QListView *parent,
00924     QString, QString = QString::null,
00925     QString = QString::null, QString = QString::null,
00926     QString = QString::null, QString = QString::null,
00927     QString = QString::null, QString = QString::null);
00928 
00929   KListViewItem(QListViewItem *parent,
00930     QString, QString = QString::null,
00931     QString = QString::null, QString = QString::null,
00932     QString = QString::null, QString = QString::null,
00933     QString = QString::null, QString = QString::null);
00934 
00935   KListViewItem(QListView *parent, QListViewItem *after,
00936     QString, QString = QString::null,
00937     QString = QString::null, QString = QString::null,
00938     QString = QString::null, QString = QString::null,
00939     QString = QString::null, QString = QString::null);
00940 
00941   KListViewItem(QListViewItem *parent, QListViewItem *after,
00942     QString, QString = QString::null,
00943     QString = QString::null, QString = QString::null,
00944     QString = QString::null, QString = QString::null,
00945     QString = QString::null, QString = QString::null);
00946 
00947   virtual ~KListViewItem();
00948 
00952   bool isAlternate();
00956   const QColor &backgroundColor();
00957 
00958   virtual void paintCell(QPainter *p, const QColorGroup &cg,
00959     int column, int width, int alignment);
00960 
00961 private:
00962   void init();
00963 
00964 private:
00965   uint m_odd : 1;
00966   uint m_known : 1;
00967   uint m_unused : 30;
00968 };
00969 
00970 #endif
00971 
00972 // vim: ts=2 sw=2 et
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:00 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001