summaryrefslogtreecommitdiff
path: root/core/pim/todo/tableview.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/todo/tableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 8cd2e7e..097af39 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -69,101 +69,103 @@ TableView::TableView( MainWindow* window, QWidget* wid )
connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
this, SLOT( slotValueChanged(int, int) ) );
connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
this, SLOT( slotCurrentChanged(int, int) ) );
m_menuTimer = new QTimer( this );
connect( m_menuTimer, SIGNAL(timeout()),
this, SLOT(slotShowMenu()) );
m_enablePaint = true;
setUpdatesEnabled( true );
viewport()->setUpdatesEnabled( true );
viewport()->update();
}
/* a new day has started
* update the day
*/
void TableView::newDay() {
clear();
- setTodos( begin(),end() );
+ updateView();
}
TableView::~TableView() {
}
void TableView::slotShowMenu() {
QPopupMenu *menu = todoWindow()->contextMenu( current() );
menu->exec(QCursor::pos() );
delete menu;
}
OTodo TableView::find(int uid ) {
OTodo ev = TodoView::event( uid );
return ev;
}
void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) {
TodoView::update( ev.uid(), ev );
/* update the other columns */
/* if completed or not we need to update
* the table
*
* We've two cases
* either item or !item
* this makes cases more easy
*/
if ( !item ) {
item = m_cache[ev.uid()];
}
DueTextItem *due = dueItem( item->row() );
due->setCompleted( ev.isCompleted() );
}
QString TableView::type() const {
return QString::fromLatin1( tr("Table View") );
}
int TableView::current() {
int cur = 0;
CheckItem* i = checkItem( currentRow() );
if (i )
cur = i->uid();
return cur;
}
QString TableView::currentRepresentation() {
return text( currentRow(), 2);
}
/* show overdue */
void TableView::showOverDue( bool ) {
clear();
- setTodos( begin(), end() );
+ updateView();
}
-void TableView::setTodos( OTodoAccess::List::Iterator it,
- OTodoAccess::List::Iterator end ) {
+void TableView::updateView( ) {
+ OTodoAccess::List::Iterator it, end;
+ it = list().begin();
+ end = list().end();
qWarning("setTodos");
QTime time;
time.start();
m_enablePaint = false;
setUpdatesEnabled( false );
viewport()->setUpdatesEnabled( false );
clear();
QString currentCat = todoWindow()->currentCategory();
bool showCompleted = todoWindow()->showCompleted();
bool showOverDue = todoWindow()->showOverDue();
qWarning( "Current Category:" + todoWindow()->currentCategory() );
int id = todoWindow()->currentCatId();
QTime t;
t.start();
setNumRows( it.count() );
uint i = 0;
for (; it != end; ++it ) {
OTodo todo = (*it);
/* test if the categories match */
if ( !currentCat.isEmpty() &&
!todo.categories().contains( id ) ) {
continue;
}
/* the item is completed but we shouldn't show it */
@@ -212,64 +214,64 @@ void TableView::setTodo( int uid, const OTodo& ev ) {
/* update DueDate */
DueTextItem *due = dueItem( row );
due->setToDoEvent( ev );
}
}
void TableView::addEvent( const OTodo& ev) {
int row= numRows();
setNumRows( row + 1 );
insertTodo( ev, row );
}
/*
* find the event
* and then replace the complete row
*/
void TableView::replaceEvent( const OTodo& ev) {
setTodo( ev.uid(), ev );
}
/*
* re aligning table can be slow too
* FIXME: look what performs better
* either this or the old align table
*/
void TableView::removeEvent( int ) {
clear();
- setTodos( begin(), end() );
+ updateView();
}
void TableView::setShowCompleted( bool b) {
qWarning("Show Completed %d" + b );
- setTodos( begin(), end() );
+ updateView();
}
void TableView::setShowDeadline( bool b) {
qWarning("Show DeadLine %d" + b );
if (b)
showColumn(3 );
else
hideColumn(3 );
}
void TableView::setShowCategory( const QString& ) {
qWarning("setShowCategory");
- setTodos( begin(), end() );
+ updateView();
}
void TableView::clear() {
m_cache.clear();
int rows = numRows();
for (int r = 0; r < rows; r++ ) {
for (int c = 0; c < numCols(); c++ ) {
if ( cellWidget(r, c) )
clearCellWidget(r, c );
clearCell(r, c);
}
}
setNumRows( 0);
}
QArray<int> TableView::completed() {
int row = numRows();
QArray<int> ids( row );
int j=0;
for (int i = 0; i < row; i++ ) {
CheckItem* item = checkItem(i );
if (item->isChecked() ) {
ids[j] = item->uid();
j++;
}