From: <mrj...@us...> - 2008-01-14 16:51:43
|
Revision: 2441 http://tora.svn.sourceforge.net/tora/?rev=2441&view=rev Author: mrjohnson0 Date: 2008-01-14 08:51:47 -0800 (Mon, 14 Jan 2008) Log Message: ----------- modify iterator so it creates a new QModelIndex when row changes, not every time operator* is called. destructor should be virtual Modified Paths: -------------- branches/tora-1.4/tora/src/toresulttableview.cpp branches/tora-1.4/tora/src/toresulttableview.h Modified: branches/tora-1.4/tora/src/toresulttableview.cpp =================================================================== --- branches/tora-1.4/tora/src/toresulttableview.cpp 2008-01-14 15:38:19 UTC (rev 2440) +++ branches/tora-1.4/tora/src/toresulttableview.cpp 2008-01-14 16:51:47 UTC (rev 2441) @@ -419,6 +419,7 @@ toTableViewIterator::toTableViewIterator(toResultTableView *view) { _row = 0; _view = view; + updateIndex(); } @@ -429,18 +430,25 @@ toTableViewIterator::toTableViewIterator(toTableViewIterator &other) { _row = other._row; _view = other._view; + updateIndex(); } +void toTableViewIterator::updateIndex(void) { + if(_row < _view->model()->rowCount()) + _index = _view->model()->index(_row, 0); + else + _index = QModelIndex(); +} + + /** * Get a QModelIndex for this row. May be invalid if you've gone * too far. Check with QModelIndex.isValid() * */ QModelIndex toTableViewIterator::operator*() const { - if(_row < _view->model()->rowCount()) - return _view->model()->index(_row, 0); - return QModelIndex(); + return _index; } @@ -450,6 +458,7 @@ */ toTableViewIterator& toTableViewIterator::operator++() { _row++; + updateIndex(); return *this; } @@ -461,6 +470,7 @@ const toTableViewIterator toTableViewIterator::operator++(int) { toTableViewIterator tmp(*this); ++(*this); + updateIndex(); return tmp; } @@ -471,6 +481,7 @@ */ toTableViewIterator& toTableViewIterator::operator+=(int n) { _row += n; + updateIndex(); return *this; } @@ -481,6 +492,7 @@ */ toTableViewIterator& toTableViewIterator::operator--() { _row--; + updateIndex(); return *this; } @@ -492,6 +504,7 @@ const toTableViewIterator toTableViewIterator::operator--(int) { toTableViewIterator tmp(*this); --(*this); + updateIndex(); return tmp; } @@ -502,6 +515,7 @@ */ toTableViewIterator& toTableViewIterator::operator-=(int n) { _row -= n; + updateIndex(); return *this; } @@ -513,5 +527,6 @@ toTableViewIterator& toTableViewIterator::operator=(const toTableViewIterator &it) { _row = it._row; _view = it._view; + updateIndex(); return *this; } Modified: branches/tora-1.4/tora/src/toresulttableview.h =================================================================== --- branches/tora-1.4/tora/src/toresulttableview.h 2008-01-14 15:38:19 UTC (rev 2440) +++ branches/tora-1.4/tora/src/toresulttableview.h 2008-01-14 16:51:47 UTC (rev 2441) @@ -174,8 +174,9 @@ QWidget *parent, const char *name = 0, bool editable = false); - ~toResultTableView(void); + virtual ~toResultTableView(void); + /** * Reimplemented to create query and new model. * @@ -349,9 +350,13 @@ class toTableViewIterator { int _row; toResultTableView *_view; + QModelIndex _index; friend class toTableViewIteratorItem; + // update _index + void updateIndex(void); + public: /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |