src/warptreeview.h

00001 /* This file is part of WarpTree
00002  *
00003  * Copyright (C) 2007 Jos van den Oever <jos@vandenoever.info>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
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

Generated on Sun Jun 3 19:54:02 2007 for WarpTree by  doxygen 1.5.0