klistview.h
/* This file is part of the KDE libraries
Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
Copyright (C) 2000 Charles Samuels <charles@kde.org>
Copyright (C) 2000 Peter Putzer <putzer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KLISTVIEW_H
#define KLISTVIEW_H
#include <qlistview.h>
#include <qptrlist.h>
#include <kdelibs_export.h>
class QDragObject;
class KConfig;
class KLineEdit;
class KDEUI_EXPORT KListView : public QListView
{
friend class KListViewItem;
Q_OBJECT
Q_ENUMS( SelectionModeExt )
Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth )
Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable )
Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable )
Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled )
Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen )
Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer )
Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn )
Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth )
Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground )
Q_PROPERTY( bool shadeSortColumn READ shadeSortColumn WRITE setShadeSortColumn )
Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt )
public:
enum SelectionModeExt {
Single = QListView::Single,
Multi = QListView::Multi,
Extended = QListView::Extended,
NoSelection = QListView::NoSelection,
FileManager
};
KListView (QWidget *parent = 0, const char *name = 0);
virtual ~KListView();
virtual void setAcceptDrops (bool);
virtual bool isExecuteArea( const QPoint& point );
bool isExecuteArea( int x );
QPtrList<QListViewItem> selectedItems() const;
QPtrList<QListViewItem> selectedItems(bool includeHiddenItems) const; // ### BIC: KDE 4: use an implicitly shared class! (QValutList?) and merge with above, default to true
void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after);
QListViewItem *lastItem() const;
QListViewItem* lastChild () const;
KLineEdit* renameLineEdit() const;
bool itemsMovable() const;
bool itemsRenameable() const;
bool dragEnabled() const;
bool autoOpen() const;
bool isRenameable (int column) const;
bool dropVisualizer() const;
int tooltipColumn() const;
bool createChildren() const KDE_DEPRECATED;
bool dropHighlighter() const;
int dropVisualizerWidth () const;
SelectionModeExt selectionModeExt () const;
int itemIndex( const QListViewItem *item ) const;
QListViewItem* itemAtIndex(int index);
void setFullWidth() KDE_DEPRECATED;
void setFullWidth(bool fullWidth);
bool fullWidth() const;
virtual int addColumn(const QString& label, int width = -1);
virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1);
virtual void removeColumn(int index);
void setAlternateBackground(const QColor &c);
const QColor &alternateBackground() const;
void saveLayout(KConfig *config, const QString &group) const;
void restoreLayout(KConfig *config, const QString &group);
virtual void setSorting(int column, bool ascending = true);
int columnSorted(void) const;
bool ascendingSort(void) const;
virtual void takeItem(QListViewItem *i);
void setShadeSortColumn(bool shadeSortColumn);
bool shadeSortColumn(void) const;
signals:
void executed( QListViewItem *item );
void executed( QListViewItem *item, const QPoint &pos, int c );
void dropped (QDropEvent * e, QListViewItem *after);
void dropped (KListView* list, QDropEvent* e, QListViewItem* after);
void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after);
void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after);
void moved();
void aboutToMove();
void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow);
void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow);
void itemRenamed(QListViewItem* item, const QString &str, int col);
void itemRenamed(QListViewItem* item);
void menuShortCutPressed (KListView* list, QListViewItem* item);
void contextMenu (KListView* l, QListViewItem* i, const QPoint& p);
void itemAdded(QListViewItem *item);
void itemRemoved(QListViewItem *item);
public slots:
virtual void rename(QListViewItem *item, int c);
void setRenameable (int column, bool yesno=true);
virtual void setItemsMovable(bool b);
virtual void setItemsRenameable(bool b);
virtual void setDragEnabled(bool b);
virtual void setAutoOpen(bool b);
virtual void setDropVisualizer(bool b);
void setDropVisualizerWidth (int w);
virtual void setTooltipColumn(int column);
virtual void setDropHighlighter(bool b);
virtual void setCreateChildren(bool b) KDE_DEPRECATED;
void setSelectionModeExt (SelectionModeExt mode);
void setTabOrderedRenaming(bool b);
bool tabOrderedRenaming() const;
protected:
inline bool below (const QRect& rect, const QPoint& p)
{
return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2));
}
inline bool below (QListViewItem* i, const QPoint& p)
{
return below (itemRect(i), contentsToViewport(p));
}
virtual bool event( QEvent * );
void emitExecute( QListViewItem *item, const QPoint &pos, int c );
virtual void focusInEvent(QFocusEvent* fe);
virtual void focusOutEvent( QFocusEvent *fe );
virtual void leaveEvent( QEvent *e );
virtual QString tooltip(QListViewItem* item, int column) const;
virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const;
virtual void contentsDragMoveEvent (QDragMoveEvent *event);
virtual void contentsMousePressEvent( QMouseEvent *e );
virtual void contentsMouseMoveEvent( QMouseEvent *e );
virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e );
virtual void contentsDragLeaveEvent (QDragLeaveEvent *event);
virtual void contentsMouseReleaseEvent (QMouseEvent*);
virtual void contentsDropEvent (QDropEvent*);
virtual void contentsDragEnterEvent (QDragEnterEvent *);
virtual QDragObject *dragObject();
virtual bool acceptDrag (QDropEvent* event) const;
virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after);
virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item);
virtual void startDrag();
virtual void keyPressEvent (QKeyEvent*);
virtual void viewportPaintEvent(QPaintEvent*);
void activateAutomaticSelection();
void deactivateAutomaticSelection();
bool automaticSelection() const;
virtual void viewportResizeEvent(QResizeEvent* e);
void disableAutoSelection();
void resetAutoSelection();
// KDE 4: remove
void doubleClicked( QListViewItem *item, const QPoint &pos, int c );
protected slots:
void slotSettingsChanged(int);
void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c );
void doneEditing(QListViewItem *item, int row);
void cleanDropVisualizer();
void cleanItemHighlighter();
void emitContextMenu (QListViewItem*, const QPoint&, int);
void emitContextMenu (KListView*, QListViewItem*);
void slotOnItem( QListViewItem *item );
void slotOnViewport();
void slotAutoSelect();
void slotDragExpand();
void slotHeaderChanged();
protected:
virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme);
virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after);
void fileManagerKeyPressEvent (QKeyEvent*);
int depthToPixels( int depth );
private:
class Tooltip;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KListViewPrivate;
KListViewPrivate* const d;
bool isExecuteArea( int x, QListViewItem* item );
};
class KDEUI_EXPORT KListViewItem : public QListViewItem
{
friend class KListView;
public:
KListViewItem(QListView *parent);
KListViewItem(QListViewItem *parent);
KListViewItem(QListView *parent, QListViewItem *after);
KListViewItem(QListViewItem *parent, QListViewItem *after);
KListViewItem(QListView *parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
KListViewItem(QListViewItem *parent,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
KListViewItem(QListView *parent, QListViewItem *after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
KListViewItem(QListViewItem *parent, QListViewItem *after,
QString, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null,
QString = QString::null, QString = QString::null);
virtual ~KListViewItem();
virtual void insertItem(QListViewItem *item);
virtual void takeItem(QListViewItem *item);
bool isAlternate();
const QColor &backgroundColor() KDE_DEPRECATED; // #### should be removed in 4.0; use below instead
QColor backgroundColor(int column);
virtual void paintCell(QPainter *p, const QColorGroup &cg,
int column, int width, int alignment);
private:
void init();
private:
uint m_odd : 1;
uint m_known : 1;
uint m_unused : 30;
};
#endif
// vim: ts=2 sw=2 et
KListViewItem
A listview item with support for alternate background colors.
Definition: klistview.h:1009
KListView::below
bool below(QListViewItem *i, const QPoint &p)
An overloaded version of below(const QRect&, const QPoint&).
Definition: klistview.h:685
KListView
This Widget extends the functionality of QListView to honor the system wide settings for Single Click...
Definition: klistview.h:53
KListView::takeItem
virtual void takeItem(QListViewItem *i)
Reimplemented for internal reasons.
Definition: klistview.cpp:2114
KListView::SelectionModeExt
SelectionModeExt
Possible selection modes.
Definition: klistview.h:104
KConfig
KLineEdit
An enhanced QLineEdit widget for inputting text.
Definition: klineedit.h:145

KDE Home | KDE Accessibility Home | Description of Access Keys