-rw-r--r-- | core/pim/todo/tableview.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index faf4611..d229f52 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -61,31 +61,28 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
61 | : QTable( wid ), TodoView( window ) { | 61 | : QTable( wid ), TodoView( window ) { |
62 | setUpdatesEnabled( false ); | 62 | setUpdatesEnabled( false ); |
63 | viewport()->setUpdatesEnabled( false ); | 63 | viewport()->setUpdatesEnabled( false ); |
64 | m_enablePaint = false; | 64 | m_enablePaint = false; |
65 | setNumRows(0); | 65 | setNumRows(0); |
66 | setNumCols(4); | 66 | setNumCols(4); |
67 | 67 | ||
68 | horizontalHeader()->setLabel( 0, tr("C.") ); | 68 | horizontalHeader()->setLabel( 0, tr("C.") ); |
69 | horizontalHeader()->setLabel( 1, tr("Prior.") ); | 69 | horizontalHeader()->setLabel( 1, tr("Priority") ); |
70 | horizontalHeader()->setLabel( 2, tr("Description" ) ); | 70 | horizontalHeader()->setLabel( 2, tr("Description" ) ); |
71 | horizontalHeader()->setLabel( 3, tr("Deadline") ); | 71 | horizontalHeader()->setLabel( 3, tr("Deadline") ); |
72 | 72 | ||
73 | setShowDeadline( todoWindow()->showDeadline() ); | ||
74 | |||
73 | setSorting( TRUE ); | 75 | setSorting( TRUE ); |
74 | setSelectionMode( NoSelection ); | 76 | setSelectionMode( NoSelection ); |
75 | 77 | ||
76 | setLeftMargin( 0 ); | 78 | setLeftMargin( 0 ); |
77 | verticalHeader()->hide(); | 79 | verticalHeader()->hide(); |
78 | 80 | ||
79 | if ( todoWindow()->showDeadline() ) | ||
80 | showColumn( 3 ); | ||
81 | else | ||
82 | hideColumn( 3 ); | ||
83 | |||
84 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 81 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
85 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 82 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
86 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 83 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
87 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 84 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
88 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 85 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
89 | this, SLOT( slotValueChanged(int, int) ) ); | 86 | this, SLOT( slotValueChanged(int, int) ) ); |
90 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 87 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), |
91 | this, SLOT( slotCurrentChanged(int, int) ) ); | 88 | this, SLOT( slotCurrentChanged(int, int) ) ); |
@@ -107,29 +104,16 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
107 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); | 104 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); |
108 | QString namestr; | 105 | QString namestr; |
109 | for ( unsigned int i = 1; i < 6; i++ ) { | 106 | for ( unsigned int i = 1; i < 6; i++ ) { |
110 | namestr = "todo/priority"; | 107 | namestr = "todo/priority"; |
111 | namestr.append( QString::number( i ) ); | 108 | namestr.append( QString::number( i ) ); |
112 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); | 109 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); |
113 | } | 110 | } |
114 | 111 | ||
115 | // Try to intelligently size columns | ||
116 | int col2width = 240; | ||
117 | int width = m_pic_completed.width(); | ||
118 | setColumnWidth( 0, width ); | ||
119 | col2width -= width; | ||
120 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width()+8; | ||
121 | setColumnWidth( 1, width ); | ||
122 | col2width -= width; | ||
123 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width()+8; | ||
124 | setColumnWidth( 3, width ); | ||
125 | col2width -= width; | ||
126 | setColumnWidth( 2, col2width - 2 ); | ||
127 | |||
128 | /* now let's init the config */ | 112 | /* now let's init the config */ |
129 | initConfig(); | 113 | initConfig(); |
130 | } | 114 | } |
131 | /* a new day has started | 115 | /* a new day has started |
132 | * update the day | 116 | * update the day |
133 | */ | 117 | */ |
134 | void TableView::newDay() { | 118 | void TableView::newDay() { |
135 | clear(); | 119 | clear(); |
@@ -220,22 +204,38 @@ void TableView::replaceEvent( const OTodo& ev) { | |||
220 | */ | 204 | */ |
221 | void TableView::removeEvent( int ) { | 205 | void TableView::removeEvent( int ) { |
222 | updateView(); | 206 | updateView(); |
223 | } | 207 | } |
224 | void TableView::setShowCompleted( bool b) { | 208 | void TableView::setShowCompleted( bool b) { |
225 | qWarning("Show Completed %d" + b ); | 209 | qWarning("Show Completed %d" + b ); |
226 | updateView(); | 210 | updateView(); |
227 | } | 211 | } |
228 | void TableView::setShowDeadline( bool b) { | 212 | void TableView::setShowDeadline( bool b ) { |
229 | qWarning("Show DeadLine %d" + b ); | 213 | qWarning( "Show DeadLine %d" + b ); |
230 | if (b) | 214 | if ( b ) |
231 | showColumn(3 ); | 215 | showColumn( 3 ); |
232 | else | 216 | else |
233 | hideColumn(3 ); | 217 | hideColumn( 3 ); |
218 | |||
219 | // Try to intelligently size columns | ||
220 | // TODO - would use width() below, but doesn't have valid value at time of c'tor | ||
221 | int col2width = 238; | ||
222 | int width = m_pic_completed.width(); | ||
223 | setColumnWidth( 0, width ); | ||
224 | col2width -= width; | ||
225 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; | ||
226 | setColumnWidth( 1, width ); | ||
227 | col2width -= width; | ||
228 | if ( b ) { | ||
229 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; | ||
230 | setColumnWidth( 3, width ); | ||
231 | col2width -= width; | ||
232 | } | ||
233 | setColumnWidth( 2, col2width ); | ||
234 | } | 234 | } |
235 | void TableView::setShowCategory( const QString& str) { | 235 | void TableView::setShowCategory( const QString& str) { |
236 | qWarning("setShowCategory"); | 236 | qWarning("setShowCategory"); |
237 | if ( str != m_oleCat || m_first ) | 237 | if ( str != m_oleCat || m_first ) |
238 | updateView(); | 238 | updateView(); |
239 | 239 | ||
240 | m_oleCat = str; | 240 | m_oleCat = str; |
241 | m_first = false; | 241 | m_first = false; |
@@ -331,19 +331,21 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool | |||
331 | 331 | ||
332 | OTodo task = sorted()[row]; | 332 | OTodo task = sorted()[row]; |
333 | 333 | ||
334 | // TODO - give user option for grid or bars? | 334 | // TODO - give user option for grid or bars? |
335 | 335 | ||
336 | // Paint alternating background bars | 336 | // Paint alternating background bars |
337 | if ( (row % 2 ) == 0 ) { | 337 | if ( (row % 2 ) == 0 ) { |
338 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 338 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
339 | p->setPen( QPen( cg.text() ) ); | ||
339 | } | 340 | } |
340 | else { | 341 | else { |
341 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); | 342 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); |
343 | p->setPen( QPen( cg.buttonText() ) ); | ||
342 | } | 344 | } |
343 | 345 | ||
344 | // Paint grid | 346 | // Paint grid |
345 | //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 347 | //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
346 | //QPen op = p->pen(); | 348 | //QPen op = p->pen(); |
347 | //p->setPen(cg.mid()); | 349 | //p->setPen(cg.mid()); |
348 | //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); | 350 | //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); |
349 | //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); | 351 | //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); |