00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef WARPTREEVIEW_H
00021 #define WARPTREEVIEW_H
00022
00023 #include <QtGui/QAbstractItemView>
00024
00028 class WarpTreeNode {
00029 public:
00033 WarpTreeNode(int d) :depth(d) {}
00037 QModelIndex index;
00041 QRect rect;
00045 int depth;
00046 };
00047
00051 class WarpNodePainter : public QObject {
00052 private:
00053 const QFontMetrics fontmetrics;
00054 const QWidget* widget;
00055 public:
00062 WarpNodePainter(QWidget*);
00066 virtual ~WarpNodePainter();
00070 virtual QSize getLabelSize(const QModelIndex& index, int depth) const;
00074 virtual void paintBackground(QPainter& painter, const QSize& size,
00075 const WarpTreeNode& activeNode);
00084 virtual void paintNode(QPainter& painter, const WarpTreeNode& node,
00085 bool active, bool loaded, bool hovered);
00089 virtual void paintLine(QPainter& painter, const QPoint& parent,
00090 const QPoint& node, int depth);
00091 };
00092
00096 class WarpTreeView : public QAbstractItemView {
00097 public:
00098 class Private;
00099 private:
00100 Private* p;
00101 public:
00106 WarpTreeView(QWidget* p = 0);
00110 ~WarpTreeView();
00114 QRect visualRect(const QModelIndex&) const;
00119 void scrollTo(const QModelIndex&, QAbstractItemView::ScrollHint);
00123 QModelIndex indexAt(const QPoint&) const;
00128 QModelIndex moveCursor(QAbstractItemView::CursorAction,
00129 Qt::KeyboardModifiers);
00133 int horizontalOffset() const;
00137 int verticalOffset() const;
00142 bool isIndexHidden(const QModelIndex&) const;
00147 void setSelection(const QRect&, QFlags<QItemSelectionModel::SelectionFlag>);
00151 QRegion visualRegionForSelection(const QItemSelection&) const;
00157 void currentChanged(const QModelIndex& current,
00158 const QModelIndex& previous);
00162 void paintEvent(QPaintEvent* e);
00166 void resizeEvent(QResizeEvent* e);
00170 void mouseMoveEvent(QMouseEvent* event);
00174 void mousePressEvent(QMouseEvent* event);
00178 void mouseReleaseEvent(QMouseEvent* event);
00182 void wheelEvent(QWheelEvent* event);
00186 void setModel(QAbstractItemModel* model);
00190 void setRootIndex(const QModelIndex& index);
00194 void setWarpNodePainter(WarpNodePainter* painter);
00198 void setAntialiased(bool a);
00202 bool antialiased() const;
00203 };
00204
00205 #endif