summaryrefslogtreecommitdiffstats
path: root/src/qgraphicstreeview.h
diff options
context:
space:
mode:
authorThomas Zander <thomas.zander@trolltech.com>2009-04-01 13:10:41 +0200
committerThomas Zander <thomas.zander@trolltech.com>2009-04-01 13:10:41 +0200
commit827889692f1e3c7976d267aa2020c27ecbaeb82f (patch)
tree839bfbb3b4b90732082ce03a0ef9b9888e35560a /src/qgraphicstreeview.h
ItemViewsNG lives!
Diffstat (limited to 'src/qgraphicstreeview.h')
-rw-r--r--src/qgraphicstreeview.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/qgraphicstreeview.h b/src/qgraphicstreeview.h
new file mode 100644
index 0000000..d135ebb
--- /dev/null
+++ b/src/qgraphicstreeview.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the Itemviews NG project on Trolltech Labs.
+**
+** This file may be used under the terms of the GNU General Public
+** License version 2.0 or 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of
+** this file. Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSTREEVIEW_H
+#define QGRAPHICSTREEVIEW_H
+
+#include "qtreemodelinterface.h"
+
+#include <QtCore/qsize.h>
+#include <QtGui/qtransform.h>
+#include <QtGui/qgraphicswidget.h>
+#include <QtGui/qstyleoption.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+//QT_MODULE(Gui)
+
+class QtGraphicsTreeViewPrivate;
+class QtTreeSelectionManager;
+class QTreeSelections;
+class QtTreeController;
+class QtGraphicsHeader;
+
+class QPointF;
+class QRegion;
+class QPainter;
+class QWidget;
+
+class Q_GUI_EXPORT QtGraphicsTreeView : public QGraphicsWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QtTreeModelBase* model READ model WRITE setModel) // ###
+ Q_PROPERTY(int firstIndex READ firstIndex WRITE setFirstIndex)
+ Q_PROPERTY(qreal horizontalOffset READ horizontalOffset WRITE setHorizontalOffset)
+ Q_PROPERTY(qreal verticalOffset READ verticalOffset WRITE setVerticalOffset)
+ Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode)
+public:
+ QtGraphicsTreeView(QGraphicsWidget *parent = 0, Qt::WindowFlags wFlags = 0);
+ virtual ~QtGraphicsTreeView();
+
+ QtTreeController *controller() const;
+ void setController(QtTreeController *controller);
+
+ QtTreeModelBase *model() const;
+ QtTreeSelectionManager *selectionManager() const;
+
+ QtGraphicsHeader *header() const;
+ void setHeader(QtGraphicsHeader *header);
+
+ void setTextElideMode(Qt::TextElideMode mode);
+ Qt::TextElideMode textElideMode() const;
+
+ int firstIndex() const;
+ qreal horizontalOffset() const;
+ qreal verticalOffset() const;
+
+ int maximumFirstIndex(int *count = 0) const; // ### flat index
+
+ qreal maximumHorizontalOffset() const;
+ qreal maximumVerticalOffset() const;
+
+ bool isItemExpanded(const QTreeModelIterator &it) const;
+
+ void nextItem(QTreeModelIterator &it) const;
+ void previousItem(QTreeModelIterator &it) const;
+
+ QRectF disclosureRect(const QRectF &rect) const; // ### FIXME
+
+public:
+ virtual QTreeModelIterator itemAt(const QPointF &position, QRectF *rect = 0) const;
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *graphicsOption = 0, QWidget *widget = 0);
+ virtual QSizeF itemSize(const QStyleOptionViewItemV4 *option, const QTreeModelIterator &it, int column) const;
+ virtual void paintItem(QPainter *painter, const QStyleOptionViewItemV4 *option, const QTreeModelIterator &it, int column) const;
+ virtual void paintBranch(QPainter *painter, const QStyleOptionViewItemV4 *option, const QTreeModelIterator &it) const;
+ virtual void initStyleOption(QStyleOptionViewItemV4 *option, QWidget *widget = 0) const;
+ virtual void initStyleOption(QStyleOptionViewItemV4 *option, const QTreeModelIterator &it, int column) const;
+ virtual void initStyleOptionState(QStyleOptionViewItemV4 *option, const QTreeModelIterator &it, int column) const;
+ void copyStyleOptionState(const QStyleOptionGraphicsItem *source, QStyleOptionViewItemV4 *dest);
+
+public Q_SLOTS:
+ void setFirstIndex(int index); // ### flat index - item based scrolling
+ void setHorizontalOffset(qreal offset);
+ void setVerticalOffset(qreal offset);
+// void setVerticalOffset(int offset); // ### for testing
+ void setItemExpanded(QTreeModelIterator &it, bool expanded = true);
+
+Q_SIGNALS:
+ void firstIndexChanged(int index);
+ void horizontalOffsetChanged(qreal offset);
+ void verticalOffsetChanged(qreal offset);
+ void itemClicked(QTreeModelIterator &it, Qt::MouseButton button);
+ void itemExpanded(QTreeModelIterator &it, int count);
+ void itemCollapsed(QTreeModelIterator &it, int count);
+
+protected:
+ QtGraphicsTreeView(QtGraphicsTreeViewPrivate &, QGraphicsWidget *parent = 0, Qt::WindowFlags wFlags = 0);
+ virtual bool event(QEvent *event);
+
+ void setModel(QtTreeModelBase *model);
+ void setSelectionManager(QtTreeSelectionManager *selections);
+
+protected:
+ QtGraphicsTreeViewPrivate *d_ptr;
+
+private:
+ friend class QtTreeController;
+ Q_DECLARE_PRIVATE(QtGraphicsTreeView)
+ Q_DISABLE_COPY(QtGraphicsTreeView)
+ Q_PRIVATE_SLOT(d_func(), void _q_controllerDestroyed())
+ Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
+ Q_PRIVATE_SLOT(d_func(), void _q_selectionsDestroyed())
+ Q_PRIVATE_SLOT(d_func(), void _q_headerDestroyed())
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsChanged(QtTreeModelBase::iterator_base &it, int count, const QList<int> &roles))
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsInserted(QtTreeModelBase::iterator_base &it, int count))
+ Q_PRIVATE_SLOT(d_func(), void _q_itemsRemoved(QtTreeModelBase::iterator_base &it, int count))
+ Q_PRIVATE_SLOT(d_func(), void _q_selectionsChanged(const QTreeSelection &selection))
+ Q_PRIVATE_SLOT(d_func(), void _q_currentChanged(QtTreeModelBase::iterator_base &current, QtTreeModelBase::iterator_base &previous))
+ Q_PRIVATE_SLOT(d_func(), void _q_reset())
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif//QGRAPHICSTREEVIEW_H