kdganttlistviewrowcontroller.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB.  All rights reserved.
00003  **
00004  ** This file is part of the KD Gantt library.
00005  **
00006  ** This file may be distributed and/or modified under the terms of the
00007  ** GNU General Public License version 2 as published by the Free Software
00008  ** Foundation and appearing in the file LICENSE.GPL included in the
00009  ** packaging of this file.
00010  **
00011  ** Licensees holding valid commercial KD Gantt licenses may use this file in
00012  ** accordance with the KD Gantt Commercial License Agreement provided with
00013  ** the Software.
00014  **
00015  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017  **
00018  ** See http://www.kdab.net/kdgantt for
00019  **   information about KD Gantt Commercial License Agreements.
00020  **
00021  ** Contact info@kdab.net if any conditions of this
00022  ** licensing are not clear to you.
00023  **
00024  **********************************************************************/
00025 #include "kdganttlistviewrowcontroller.h"
00026 #include "kdganttlistviewrowcontroller_p.h"
00027 
00028 #include <QAbstractProxyModel>
00029 #include <QScrollBar>
00030 
00031 #include <cassert>
00032 
00033 using namespace KDGantt;
00034 
00042 ListViewRowController::ListViewRowController( QListView* lv, QAbstractProxyModel* proxy )
00043   : _d( new Private(lv,proxy) )
00044 {
00045 }
00046 
00047 ListViewRowController::~ListViewRowController()
00048 {
00049     delete _d; _d = 0;
00050 }
00051 
00052 #define d d_func()
00053 
00054 int ListViewRowController::headerHeight() const
00055 {
00056     return d->listview->viewport()->y()-d->listview->frameWidth();
00057 }
00058 
00059 int ListViewRowController::maximumItemHeight() const
00060 {
00061     return d->listview->fontMetrics().height();
00062 }
00063 
00064 int ListViewRowController::totalHeight() const
00065 {
00066     return d->listview->verticalScrollBar()->maximum()+d->listview->viewport()->height();
00067 }
00068 
00069 bool ListViewRowController::isRowVisible( const QModelIndex& _idx ) const
00070 {
00071     const QModelIndex idx = d->proxy->mapToSource( _idx );
00072     assert( idx.isValid() ? ( idx.model() == d->listview->model() ):( true ) );
00073     return d->listview->visualRect(idx).isValid();
00074 }
00075 
00076 bool ListViewRowController::isRowExpanded( const QModelIndex& _idx ) const
00077 {
00078     return false;
00079 }
00080 
00081 Span ListViewRowController::rowGeometry( const QModelIndex& _idx ) const
00082 {
00083     const QModelIndex idx = d->proxy->mapToSource( _idx );
00084     assert( idx.isValid() ? ( idx.model() == d->listview->model() ):( true ) );
00085     QRect r = d->listview->visualRect(idx).translated( QPoint( 0,
00086                   static_cast<Private::HackListView*>(d->listview)->verticalOffset() ) );
00087     return Span( r.y(), r.height() );
00088 }
00089 
00090 QModelIndex ListViewRowController::indexAt( int height ) const
00091 {
00092     return d->proxy->mapFromSource( d->listview->indexAt( QPoint( 1,height ) ) );
00093 }
00094 
00095 QModelIndex ListViewRowController::indexAbove( const QModelIndex& _idx ) const
00096 {
00097     const QModelIndex idx = d->proxy->mapToSource( _idx );
00098     return d->proxy->mapFromSource( idx.sibling( idx.row()-1, idx.column()) );
00099 }
00100 
00101 QModelIndex ListViewRowController::indexBelow( const QModelIndex& _idx ) const
00102 {
00103     const QModelIndex idx = d->proxy->mapToSource( _idx );
00104     if( !idx.isValid() || idx.column()!=0 ) return QModelIndex();
00105     if( idx.model()->rowCount(idx.parent())<idx.row()+1 ) return QModelIndex();
00106     return d->proxy->mapFromSource( idx.sibling( idx.row()+1, idx.column()) );
00107 }
00108 

Generated on Thu Mar 4 23:19:13 2010 for KD Chart 2 by  doxygen 1.5.4