KDGantt::TreeViewRowController Class Reference

#include <kdgantttreeviewrowcontroller.h>

Inheritance diagram for KDGantt::TreeViewRowController:

Inheritance graph
[legend]
Collaboration diagram for KDGantt::TreeViewRowController:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 34 of file kdgantttreeviewrowcontroller.h.


Public Member Functions

int headerHeight () const
QModelIndex indexAbove (const QModelIndex &idx) const
QModelIndex indexAt (int height) const
QModelIndex indexBelow (const QModelIndex &idx) const
bool isRowExpanded (const QModelIndex &idx) const
bool isRowVisible (const QModelIndex &idx) const
int maximumItemHeight () const
Span rowGeometry (const QModelIndex &idx) const
int totalHeight () const
 TreeViewRowController (QTreeView *tv, QAbstractProxyModel *proxy)
virtual ~TreeViewRowController ()

Constructor & Destructor Documentation

TreeViewRowController::TreeViewRowController ( QTreeView *  tv,
QAbstractProxyModel proxy 
)

Definition at line 41 of file kdgantttreeviewrowcontroller.cpp.

00043   : _d( new Private )
00044 {
00045     _d->treeview = static_cast<Private::HackTreeView*>(tv);
00046     _d->proxy = proxy;
00047 }

TreeViewRowController::~TreeViewRowController (  )  [virtual]

Definition at line 49 of file kdgantttreeviewrowcontroller.cpp.

00050 {
00051     delete _d; _d=0;
00052 }


Member Function Documentation

int TreeViewRowController::headerHeight (  )  const [virtual]

Returns:
The height of the header part of the view.
Implement this to control how much space is reserved at the top of the view for a header

Implements KDGantt::AbstractRowController.

Definition at line 56 of file kdgantttreeviewrowcontroller.cpp.

References d.

00057 {
00058   //return d->treeview->header()->sizeHint().height();
00059     return d->treeview->viewport()->y()-d->treeview->frameWidth();
00060 }

QModelIndex TreeViewRowController::indexAbove ( const QModelIndex &  idx  )  const [virtual]

Returns:
The modelindex for the previous row before idx.
See also:
QTreeView::indexAbove

Implements KDGantt::AbstractRowController.

Definition at line 121 of file kdgantttreeviewrowcontroller.cpp.

References d.

00122 {
00123     const QModelIndex idx = d->proxy->mapToSource( _idx );
00124     return d->proxy->mapFromSource( d->treeview->indexAbove( idx ) );
00125 }

QModelIndex TreeViewRowController::indexAt ( int  height  )  const [virtual]

Implements KDGantt::AbstractRowController.

Definition at line 95 of file kdgantttreeviewrowcontroller.cpp.

References d.

00096 {
00097   /* using indexAt( QPoint ) wont work here, since it does hit detection
00098    *   against the actual item text/icon, so we would return wrong values
00099    *   for items with no text etc.
00100    *
00101    *   The code below could cache for performance, but currently it doesn't
00102    *   seem to be the performance bottleneck at all.
00103    */
00104     if ( !d->treeview->model() ) return QModelIndex();
00105     int y = d->treeview->verticalOffset();
00106     QModelIndex idx = d->treeview->model()->index( 0, 0, d->treeview->rootIndex() );
00107     do {
00108         if ( y >= height ) break;
00109 #if QT_VERSION >= 0x040300
00110         y += d->treeview->rowHeight( idx );
00111 #else
00112         // Since TreeViewRowController is NOT using uniform row height
00113         // we can use this:
00114         y += d->treeview->indexRowSizeHint( idx );
00115 #endif
00116         idx = d->treeview->indexBelow( idx );
00117     } while ( idx.isValid() );
00118     return d->proxy->mapFromSource( idx );
00119 }

QModelIndex TreeViewRowController::indexBelow ( const QModelIndex &  idx  )  const [virtual]

Returns:
The modelindex for the next row after idx.
See also:
QTreeView::indexBelow

Implements KDGantt::AbstractRowController.

Definition at line 127 of file kdgantttreeviewrowcontroller.cpp.

References d.

00128 {
00129     const QModelIndex idx = d->proxy->mapToSource( _idx );
00130     return d->proxy->mapFromSource( d->treeview->indexBelow( idx ) );
00131 }

bool TreeViewRowController::isRowExpanded ( const QModelIndex &  idx  )  const [virtual]

Implements KDGantt::AbstractRowController.

Definition at line 80 of file kdgantttreeviewrowcontroller.cpp.

References d.

00081 {
00082     const QModelIndex idx = d->proxy->mapToSource( _idx );
00083     assert( idx.isValid() ? ( idx.model() == d->treeview->model() ):( true ) );
00084     return d->treeview->isExpanded( idx );
00085 }

bool TreeViewRowController::isRowVisible ( const QModelIndex &  idx  )  const [virtual]

Returns:
true if the row containing index idx is visible in the view.
Implement this to allow KDGantt to optimise how items on screen are created. It is not harmful to always return true here, but the View will not perform optimally.

Implements KDGantt::AbstractRowController.

Definition at line 72 of file kdgantttreeviewrowcontroller.cpp.

References d.

00073 {
00074   //qDebug() << _idx.model()<<d->proxy << d->treeview->model();
00075     const QModelIndex idx = d->proxy->mapToSource( _idx );
00076     assert( idx.isValid() ? ( idx.model() == d->treeview->model() ):( true ) );
00077     return d->treeview->visualRect(idx).isValid();
00078 }

int TreeViewRowController::maximumItemHeight (  )  const [virtual]

Implements KDGantt::AbstractRowController.

Definition at line 62 of file kdgantttreeviewrowcontroller.cpp.

References d.

00063 {
00064     return d->treeview->fontMetrics().height();
00065 }

Span TreeViewRowController::rowGeometry ( const QModelIndex &  idx  )  const [virtual]

Returns:
A Span consisting of the row offset and height for the row containing idx. A simple implementation might look like
 Span MyRowCtrlr::rowGeometry(const QModelIndex& idx)
 {
      return Span(idx.row()*10,10);
 }

Implements KDGantt::AbstractRowController.

Definition at line 87 of file kdgantttreeviewrowcontroller.cpp.

References d, and r.

00088 {
00089     const QModelIndex idx = d->proxy->mapToSource( _idx );
00090     assert( idx.isValid() ? ( idx.model() == d->treeview->model() ):( true ) );
00091     QRect r = d->treeview->visualRect(idx).translated( QPoint( 0, d->treeview->verticalOffset() ) );
00092     return Span( r.y(), r.height() );
00093 }

int TreeViewRowController::totalHeight (  )  const [virtual]

Returns:
the total height of the rows. For uniformly sized rows that would be number_of_rows*row_height.

Implements KDGantt::AbstractRowController.

Definition at line 67 of file kdgantttreeviewrowcontroller.cpp.

References d.

00068 {
00069     return d->treeview->verticalScrollBar()->maximum()+d->treeview->viewport()->height();
00070 }


The documentation for this class was generated from the following files:
Generated on Thu Mar 4 23:27:21 2010 for KD Chart 2 by  doxygen 1.5.4