-rw-r--r-- | core/pim/todo/tableview.cpp | 97 |
1 files changed, 69 insertions, 28 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 5594b13..5d82eb2 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -91,2 +91,5 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
91 | viewport()->update(); | 91 | viewport()->update(); |
92 | setSortOrder( 0 ); | ||
93 | setAscending( TRUE ); | ||
94 | m_first = true; | ||
92 | } | 95 | } |
@@ -111,5 +114,5 @@ QString TableView::type() const { | |||
111 | int TableView::current() { | 114 | int TableView::current() { |
112 | int cur = 0; | 115 | int uid = sorted().uidAt(currentRow() ); |
113 | // FIXME | 116 | qWarning("uid %d", uid ); |
114 | return cur; | 117 | return uid; |
115 | } | 118 | } |
@@ -125,4 +128,2 @@ void TableView::showOverDue( bool ) { | |||
125 | void TableView::updateView( ) { | 128 | void TableView::updateView( ) { |
126 | setSortOrder( 0 ); | ||
127 | setAscending( true ); | ||
128 | sort(); | 129 | sort(); |
@@ -189,5 +190,10 @@ void TableView::setShowDeadline( bool b) { | |||
189 | } | 190 | } |
190 | void TableView::setShowCategory( const QString& ) { | 191 | void TableView::setShowCategory( const QString& str) { |
191 | qWarning("setShowCategory"); | 192 | qWarning("setShowCategory"); |
192 | updateView(); | 193 | if ( str != m_oleCat || m_first ) |
194 | updateView(); | ||
195 | |||
196 | m_oleCat = str; | ||
197 | m_first = false; | ||
198 | |||
193 | } | 199 | } |
@@ -200,3 +206,4 @@ void TableView::slotClicked(int row, int col, int, | |||
200 | return; | 206 | return; |
201 | int ui=0; // FIXME = uid(row); | 207 | |
208 | int ui= sorted().uidAt( row ); | ||
202 | 209 | ||
@@ -204,19 +211,16 @@ void TableView::slotClicked(int row, int col, int, | |||
204 | switch( col ) { | 211 | switch( col ) { |
205 | case 0: { | 212 | case 0:{ |
206 | // FIXME | 213 | int x = point.x() -columnPos( col ); |
207 | CheckItem* item = 0l; | 214 | int y = point.y() -rowPos( row ); |
208 | /* | 215 | int w = columnWidth( col ); |
209 | * let's see if we centered clicked | 216 | int h = rowHeight( row ); |
210 | */ | 217 | if ( x >= ( w - BoxSize ) / 2 && |
211 | if ( item ) { | 218 | x <= ( w - BoxSize ) / 2 + BoxSize && |
212 | int x = point.x() -columnPos( col ); | 219 | y >= ( h - BoxSize ) / 2 && |
213 | int y = point.y() -rowPos( row ); | 220 | y <= ( h - BoxSize ) / 2 + BoxSize ) { |
214 | int w = columnWidth( col ); | 221 | OTodo todo = sorted()[row]; |
215 | int h = rowHeight( row ); | 222 | todo.setCompleted( !todo.isCompleted() ); |
216 | if ( x >= ( w - OCheckItem::BoxSize ) / 2 && | 223 | TodoView::update( todo.uid(), todo ); |
217 | x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && | 224 | updateView(); |
218 | y >= ( h - OCheckItem::BoxSize ) / 2 && | 225 | } |
219 | y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize ) | ||
220 | item->toggle(); | ||
221 | } | ||
222 | } | 226 | } |
@@ -264,5 +268,7 @@ QWidget* TableView::widget() { | |||
264 | */ | 268 | */ |
265 | void TableView::sortColumn( int row, bool asc, bool ) { | 269 | void TableView::sortColumn( int col, bool asc, bool ) { |
266 | QTable::sortColumn( row, asc, TRUE ); | 270 | qWarning("bool %d", asc ); |
267 | 271 | setSortOrder( col ); | |
272 | setAscending( asc ); | ||
273 | updateView(); | ||
268 | } | 274 | } |
@@ -359 +365,36 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool | |||
359 | } | 365 | } |
366 | QWidget* TableView::createEditor(int row, int col, bool )const { | ||
367 | switch( col ) { | ||
368 | case 1: { | ||
369 | /* the priority stuff */ | ||
370 | QComboBox* combo = new QComboBox( viewport() ); | ||
371 | combo->insertItem( "1" ); | ||
372 | combo->insertItem( "2" ); | ||
373 | combo->insertItem( "3" ); | ||
374 | combo->insertItem( "4" ); | ||
375 | combo->insertItem( "5" ); | ||
376 | combo->setCurrentItem( sorted()[row].priority()-1 ); | ||
377 | return combo; | ||
378 | } | ||
379 | case 0: | ||
380 | default: | ||
381 | return 0l; | ||
382 | } | ||
383 | } | ||
384 | void TableView::setCellContentFromEditor(int row, int col ) { | ||
385 | if ( col == 1 ) { | ||
386 | QWidget* wid = cellWidget(row, 1 ); | ||
387 | if ( wid->inherits("QComboBox") ) { | ||
388 | int pri = ((QComboBox*)wid)->currentItem() + 1; | ||
389 | OTodo todo = sorted()[row]; | ||
390 | if ( todo.priority() != pri ) { | ||
391 | todo.setPriority( pri ); | ||
392 | TodoView::update( todo.uid(), todo ); | ||
393 | updateView(); | ||
394 | } | ||
395 | } | ||
396 | } | ||
397 | } | ||
398 | void TableView::slotPriority() { | ||
399 | setCellContentFromEditor( currentRow(), currentColumn() ); | ||
400 | } | ||