summaryrefslogtreecommitdiff
path: root/core/pim/todo/tableview.cpp
Unidiff
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 )
69 69
70 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 70 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
71 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 71 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
72 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 72 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
73 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 73 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
74 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 74 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
75 this, SLOT( slotValueChanged(int, int) ) ); 75 this, SLOT( slotValueChanged(int, int) ) );
76 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 76 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
77 this, SLOT( slotCurrentChanged(int, int) ) ); 77 this, SLOT( slotCurrentChanged(int, int) ) );
78 78
79 m_menuTimer = new QTimer( this ); 79 m_menuTimer = new QTimer( this );
80 connect( m_menuTimer, SIGNAL(timeout()), 80 connect( m_menuTimer, SIGNAL(timeout()),
81 this, SLOT(slotShowMenu()) ); 81 this, SLOT(slotShowMenu()) );
82 82
83 m_enablePaint = true; 83 m_enablePaint = true;
84 setUpdatesEnabled( true ); 84 setUpdatesEnabled( true );
85 viewport()->setUpdatesEnabled( true ); 85 viewport()->setUpdatesEnabled( true );
86 viewport()->update(); 86 viewport()->update();
87} 87}
88/* a new day has started 88/* a new day has started
89 * update the day 89 * update the day
90 */ 90 */
91void TableView::newDay() { 91void TableView::newDay() {
92 clear(); 92 clear();
93 setTodos( begin(),end() ); 93 updateView();
94} 94}
95TableView::~TableView() { 95TableView::~TableView() {
96 96
97} 97}
98void TableView::slotShowMenu() { 98void TableView::slotShowMenu() {
99 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 99 QPopupMenu *menu = todoWindow()->contextMenu( current() );
100 menu->exec(QCursor::pos() ); 100 menu->exec(QCursor::pos() );
101 delete menu; 101 delete menu;
102} 102}
103OTodo TableView::find(int uid ) { 103OTodo TableView::find(int uid ) {
104 OTodo ev = TodoView::event( uid ); 104 OTodo ev = TodoView::event( uid );
105 return ev; 105 return ev;
106} 106}
107void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) { 107void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) {
108 TodoView::update( ev.uid(), ev ); 108 TodoView::update( ev.uid(), ev );
109 109
110 /* update the other columns */ 110 /* update the other columns */
111 /* if completed or not we need to update 111 /* if completed or not we need to update
112 * the table 112 * the table
113 * 113 *
114 * We've two cases 114 * We've two cases
115 * either item or !item 115 * either item or !item
116 * this makes cases more easy 116 * this makes cases more easy
117 */ 117 */
118 if ( !item ) { 118 if ( !item ) {
119 item = m_cache[ev.uid()]; 119 item = m_cache[ev.uid()];
120 } 120 }
121 DueTextItem *due = dueItem( item->row() ); 121 DueTextItem *due = dueItem( item->row() );
122 due->setCompleted( ev.isCompleted() ); 122 due->setCompleted( ev.isCompleted() );
123} 123}
124QString TableView::type() const { 124QString TableView::type() const {
125 return QString::fromLatin1( tr("Table View") ); 125 return QString::fromLatin1( tr("Table View") );
126} 126}
127int TableView::current() { 127int TableView::current() {
128 int cur = 0; 128 int cur = 0;
129 CheckItem* i = checkItem( currentRow() ); 129 CheckItem* i = checkItem( currentRow() );
130 if (i ) 130 if (i )
131 cur = i->uid(); 131 cur = i->uid();
132 132
133 return cur; 133 return cur;
134} 134}
135QString TableView::currentRepresentation() { 135QString TableView::currentRepresentation() {
136 return text( currentRow(), 2); 136 return text( currentRow(), 2);
137} 137}
138/* show overdue */ 138/* show overdue */
139void TableView::showOverDue( bool ) { 139void TableView::showOverDue( bool ) {
140 clear(); 140 clear();
141 setTodos( begin(), end() ); 141 updateView();
142} 142}
143 143
144void TableView::setTodos( OTodoAccess::List::Iterator it, 144void TableView::updateView( ) {
145 OTodoAccess::List::Iterator end ) { 145 OTodoAccess::List::Iterator it, end;
146 it = list().begin();
147 end = list().end();
146 qWarning("setTodos"); 148 qWarning("setTodos");
147 QTime time; 149 QTime time;
148 time.start(); 150 time.start();
149 m_enablePaint = false; 151 m_enablePaint = false;
150 setUpdatesEnabled( false ); 152 setUpdatesEnabled( false );
151 viewport()->setUpdatesEnabled( false ); 153 viewport()->setUpdatesEnabled( false );
152 clear(); 154 clear();
153 QString currentCat = todoWindow()->currentCategory(); 155 QString currentCat = todoWindow()->currentCategory();
154 bool showCompleted = todoWindow()->showCompleted(); 156 bool showCompleted = todoWindow()->showCompleted();
155 bool showOverDue = todoWindow()->showOverDue(); 157 bool showOverDue = todoWindow()->showOverDue();
156 qWarning( "Current Category:" + todoWindow()->currentCategory() ); 158 qWarning( "Current Category:" + todoWindow()->currentCategory() );
157 int id = todoWindow()->currentCatId(); 159 int id = todoWindow()->currentCatId();
158 QTime t; 160 QTime t;
159 t.start(); 161 t.start();
160 setNumRows( it.count() ); 162 setNumRows( it.count() );
161 uint i = 0; 163 uint i = 0;
162 for (; it != end; ++it ) { 164 for (; it != end; ++it ) {
163 OTodo todo = (*it); 165 OTodo todo = (*it);
164 /* test if the categories match */ 166 /* test if the categories match */
165 if ( !currentCat.isEmpty() && 167 if ( !currentCat.isEmpty() &&
166 !todo.categories().contains( id ) ) { 168 !todo.categories().contains( id ) ) {
167 continue; 169 continue;
168 } 170 }
169 /* the item is completed but we shouldn't show it */ 171 /* the item is completed but we shouldn't show it */
@@ -212,64 +214,64 @@ void TableView::setTodo( int uid, const OTodo& ev ) {
212 /* update DueDate */ 214 /* update DueDate */
213 DueTextItem *due = dueItem( row ); 215 DueTextItem *due = dueItem( row );
214 due->setToDoEvent( ev ); 216 due->setToDoEvent( ev );
215 } 217 }
216} 218}
217void TableView::addEvent( const OTodo& ev) { 219void TableView::addEvent( const OTodo& ev) {
218 int row= numRows(); 220 int row= numRows();
219 setNumRows( row + 1 ); 221 setNumRows( row + 1 );
220 insertTodo( ev, row ); 222 insertTodo( ev, row );
221} 223}
222/* 224/*
223 * find the event 225 * find the event
224 * and then replace the complete row 226 * and then replace the complete row
225 */ 227 */
226void TableView::replaceEvent( const OTodo& ev) { 228void TableView::replaceEvent( const OTodo& ev) {
227 setTodo( ev.uid(), ev ); 229 setTodo( ev.uid(), ev );
228} 230}
229/* 231/*
230 * re aligning table can be slow too 232 * re aligning table can be slow too
231 * FIXME: look what performs better 233 * FIXME: look what performs better
232 * either this or the old align table 234 * either this or the old align table
233 */ 235 */
234void TableView::removeEvent( int ) { 236void TableView::removeEvent( int ) {
235 clear(); 237 clear();
236 setTodos( begin(), end() ); 238 updateView();
237} 239}
238void TableView::setShowCompleted( bool b) { 240void TableView::setShowCompleted( bool b) {
239 qWarning("Show Completed %d" + b ); 241 qWarning("Show Completed %d" + b );
240 setTodos( begin(), end() ); 242 updateView();
241} 243}
242void TableView::setShowDeadline( bool b) { 244void TableView::setShowDeadline( bool b) {
243 qWarning("Show DeadLine %d" + b ); 245 qWarning("Show DeadLine %d" + b );
244 if (b) 246 if (b)
245 showColumn(3 ); 247 showColumn(3 );
246 else 248 else
247 hideColumn(3 ); 249 hideColumn(3 );
248} 250}
249void TableView::setShowCategory( const QString& ) { 251void TableView::setShowCategory( const QString& ) {
250 qWarning("setShowCategory"); 252 qWarning("setShowCategory");
251 setTodos( begin(), end() ); 253 updateView();
252} 254}
253void TableView::clear() { 255void TableView::clear() {
254 m_cache.clear(); 256 m_cache.clear();
255 int rows = numRows(); 257 int rows = numRows();
256 for (int r = 0; r < rows; r++ ) { 258 for (int r = 0; r < rows; r++ ) {
257 for (int c = 0; c < numCols(); c++ ) { 259 for (int c = 0; c < numCols(); c++ ) {
258 if ( cellWidget(r, c) ) 260 if ( cellWidget(r, c) )
259 clearCellWidget(r, c ); 261 clearCellWidget(r, c );
260 clearCell(r, c); 262 clearCell(r, c);
261 } 263 }
262 } 264 }
263 setNumRows( 0); 265 setNumRows( 0);
264} 266}
265QArray<int> TableView::completed() { 267QArray<int> TableView::completed() {
266 int row = numRows(); 268 int row = numRows();
267 QArray<int> ids( row ); 269 QArray<int> ids( row );
268 270
269 int j=0; 271 int j=0;
270 for (int i = 0; i < row; i++ ) { 272 for (int i = 0; i < row; i++ ) {
271 CheckItem* item = checkItem(i ); 273 CheckItem* item = checkItem(i );
272 if (item->isChecked() ) { 274 if (item->isChecked() ) {
273 ids[j] = item->uid(); 275 ids[j] = item->uid();
274 j++; 276 j++;
275 } 277 }