author | zecke <zecke> | 2003-02-11 19:12:34 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-11 19:12:34 (UTC) |
commit | 17738622fd2b61138695441df860f8ecd16f286f (patch) (unidiff) | |
tree | 11b6282188661c21d66fef3fb0397437842112a7 | |
parent | 5145521f5ff79d6a418244e33d357b5b8168e072 (diff) | |
download | opie-17738622fd2b61138695441df860f8ecd16f286f.zip opie-17738622fd2b61138695441df860f8ecd16f286f.tar.gz opie-17738622fd2b61138695441df860f8ecd16f286f.tar.bz2 |
fix 0000535.
What is the right size? That depends on the user so save
the columWidth() the user used so he should be happy
-rw-r--r-- | core/pim/todo/tableview.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index cec8b5e..ae27fab 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,189 +1,199 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <zecke> | 3 | .=l. Copyright (c) 2002 <zecke> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <cmath> | 29 | #include <cmath> |
30 | 30 | ||
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | #include <qpoint.h> | 34 | #include <qpoint.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <opie/orecur.h> | 40 | #include <opie/orecur.h> |
41 | 41 | ||
42 | #include "mainwindow.h" | 42 | #include "mainwindow.h" |
43 | //#include "tableitems.h" | 43 | //#include "tableitems.h" |
44 | #include "tableview.h" | 44 | #include "tableview.h" |
45 | 45 | ||
46 | using namespace Todo; | 46 | using namespace Todo; |
47 | 47 | ||
48 | namespace { | 48 | namespace { |
49 | static const int BoxSize = 14; | 49 | static const int BoxSize = 14; |
50 | static const int RowHeight = 20; | 50 | static const int RowHeight = 20; |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | void TableView::initConfig() { | 54 | void TableView::initConfig() { |
55 | Config config( "todo" ); | 55 | Config config( "todo" ); |
56 | config.setGroup( "Options" ); | 56 | config.setGroup( "Options" ); |
57 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); | 57 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); |
58 | for (int i = 0; i < numCols(); i++ ) { | ||
59 | int width = config.readNumEntry("Width"+QString::number(i), -1 ); | ||
60 | setColumnWidth(i, width == -1 ? columnWidth(i) : width ); | ||
61 | } | ||
58 | } | 62 | } |
59 | 63 | ||
60 | TableView::TableView( MainWindow* window, QWidget* wid ) | 64 | TableView::TableView( MainWindow* window, QWidget* wid ) |
61 | : QTable( wid ), TodoView( window ) { | 65 | : QTable( wid ), TodoView( window ) { |
62 | 66 | ||
63 | // Load icons | 67 | // Load icons |
64 | // TODO - probably should be done globally somewhere else, | 68 | // TODO - probably should be done globally somewhere else, |
65 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h | 69 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h |
66 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); | 70 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); |
67 | QString namestr; | 71 | QString namestr; |
68 | for ( unsigned int i = 1; i < 6; i++ ) { | 72 | for ( unsigned int i = 1; i < 6; i++ ) { |
69 | namestr = "todo/priority"; | 73 | namestr = "todo/priority"; |
70 | namestr.append( QString::number( i ) ); | 74 | namestr.append( QString::number( i ) ); |
71 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); | 75 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); |
72 | } | 76 | } |
73 | 77 | ||
74 | setUpdatesEnabled( false ); | 78 | setUpdatesEnabled( false ); |
75 | viewport()->setUpdatesEnabled( false ); | 79 | viewport()->setUpdatesEnabled( false ); |
76 | m_enablePaint = false; | 80 | m_enablePaint = false; |
77 | setNumRows(0); | 81 | setNumRows(0); |
78 | setNumCols(4); | 82 | setNumCols(4); |
79 | 83 | ||
80 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); | 84 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); |
81 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); | 85 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); |
82 | horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); | 86 | horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); |
83 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); | 87 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); |
84 | 88 | ||
85 | setShowDeadline( todoWindow()->showDeadline() ); | 89 | setShowDeadline( todoWindow()->showDeadline() ); |
86 | 90 | ||
87 | setSorting( TRUE ); | 91 | setSorting( TRUE ); |
88 | setSelectionMode( NoSelection ); | 92 | setSelectionMode( NoSelection ); |
89 | 93 | ||
90 | setLeftMargin( 0 ); | 94 | setLeftMargin( 0 ); |
91 | verticalHeader()->hide(); | 95 | verticalHeader()->hide(); |
92 | 96 | ||
93 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 97 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
94 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 98 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
95 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 99 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
96 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 100 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
97 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 101 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
98 | this, SLOT( slotValueChanged(int, int) ) ); | 102 | this, SLOT( slotValueChanged(int, int) ) ); |
99 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 103 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), |
100 | this, SLOT( slotCurrentChanged(int, int) ) ); | 104 | this, SLOT( slotCurrentChanged(int, int) ) ); |
101 | 105 | ||
102 | m_menuTimer = new QTimer( this ); | 106 | m_menuTimer = new QTimer( this ); |
103 | connect( m_menuTimer, SIGNAL(timeout()), | 107 | connect( m_menuTimer, SIGNAL(timeout()), |
104 | this, SLOT(slotShowMenu()) ); | 108 | this, SLOT(slotShowMenu()) ); |
105 | 109 | ||
110 | /* now let's init the config */ | ||
111 | initConfig(); | ||
112 | |||
113 | |||
106 | m_enablePaint = true; | 114 | m_enablePaint = true; |
107 | setUpdatesEnabled( true ); | 115 | setUpdatesEnabled( true ); |
108 | viewport()->setUpdatesEnabled( true ); | 116 | viewport()->setUpdatesEnabled( true ); |
109 | viewport()->update(); | 117 | viewport()->update(); |
110 | setSortOrder( 0 ); | 118 | setSortOrder( 0 ); |
111 | setAscending( TRUE ); | 119 | setAscending( TRUE ); |
112 | m_first = true; | 120 | m_first = true; |
113 | 121 | ||
114 | /* now let's init the config */ | 122 | |
115 | initConfig(); | ||
116 | } | 123 | } |
117 | /* a new day has started | 124 | /* a new day has started |
118 | * update the day | 125 | * update the day |
119 | */ | 126 | */ |
120 | void TableView::newDay() { | 127 | void TableView::newDay() { |
121 | clear(); | 128 | clear(); |
122 | updateView(); | 129 | updateView(); |
123 | } | 130 | } |
124 | TableView::~TableView() { | 131 | TableView::~TableView() { |
125 | 132 | Config config( "todo" ); | |
133 | config.setGroup( "Options" ); | ||
134 | for (int i = 0; i < numCols(); i++ ) | ||
135 | config.writeEntry("Width"+QString::number(i), columnWidth(i) ); | ||
126 | } | 136 | } |
127 | void TableView::slotShowMenu() { | 137 | void TableView::slotShowMenu() { |
128 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); | 138 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); |
129 | menu->exec(QCursor::pos() ); | 139 | menu->exec(QCursor::pos() ); |
130 | delete menu; | 140 | delete menu; |
131 | } | 141 | } |
132 | QString TableView::type() const { | 142 | QString TableView::type() const { |
133 | return QString::fromLatin1( tr("Table View") ); | 143 | return QString::fromLatin1( tr("Table View") ); |
134 | } | 144 | } |
135 | int TableView::current() { | 145 | int TableView::current() { |
136 | int uid = sorted().uidAt(currentRow() ); | 146 | int uid = sorted().uidAt(currentRow() ); |
137 | 147 | ||
138 | return uid; | 148 | return uid; |
139 | } | 149 | } |
140 | QString TableView::currentRepresentation() { | 150 | QString TableView::currentRepresentation() { |
141 | OTodo to = sorted()[currentRow()]; | 151 | OTodo to = sorted()[currentRow()]; |
142 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | 152 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; |
143 | } | 153 | } |
144 | /* show overdue */ | 154 | /* show overdue */ |
145 | void TableView::showOverDue( bool ) { | 155 | void TableView::showOverDue( bool ) { |
146 | clear(); | 156 | clear(); |
147 | updateView(); | 157 | updateView(); |
148 | } | 158 | } |
149 | 159 | ||
150 | void TableView::updateView( ) { | 160 | void TableView::updateView( ) { |
151 | qWarning("update view"); | 161 | qWarning("update view"); |
152 | m_row = false; | 162 | m_row = false; |
153 | static int id; | 163 | static int id; |
154 | id = startTimer(4000 ); | 164 | id = startTimer(4000 ); |
155 | /* FIXME we want one page to be read! | 165 | /* FIXME we want one page to be read! |
156 | * | 166 | * |
157 | * Calculate that screensize | 167 | * Calculate that screensize |
158 | */ | 168 | */ |
159 | todoWindow()->setReadAhead( 4 ); | 169 | todoWindow()->setReadAhead( 4 ); |
160 | sort(); | 170 | sort(); |
161 | OTodoAccess::List::Iterator it, end; | 171 | OTodoAccess::List::Iterator it, end; |
162 | it = sorted().begin(); | 172 | it = sorted().begin(); |
163 | end = sorted().end(); | 173 | end = sorted().end(); |
164 | 174 | ||
165 | qWarning("setTodos"); | 175 | qWarning("setTodos"); |
166 | QTime time; | 176 | QTime time; |
167 | time.start(); | 177 | time.start(); |
168 | m_enablePaint = false; | 178 | m_enablePaint = false; |
169 | setUpdatesEnabled( false ); | 179 | setUpdatesEnabled( false ); |
170 | viewport()->setUpdatesEnabled( false ); | 180 | viewport()->setUpdatesEnabled( false ); |
171 | 181 | ||
172 | setNumRows( it.count() ); | 182 | setNumRows( it.count() ); |
173 | if ( it.count() == 0 ) | 183 | if ( it.count() == 0 ) |
174 | killTimer(id); | 184 | killTimer(id); |
175 | 185 | ||
176 | // int elc = time.elapsed(); | 186 | // int elc = time.elapsed(); |
177 | setUpdatesEnabled( true ); | 187 | setUpdatesEnabled( true ); |
178 | viewport()->setUpdatesEnabled( true ); | 188 | viewport()->setUpdatesEnabled( true ); |
179 | viewport()->update(); | 189 | viewport()->update(); |
180 | 190 | ||
181 | m_enablePaint = true; | 191 | m_enablePaint = true; |
182 | // int el = time.elapsed(); | 192 | // int el = time.elapsed(); |
183 | } | 193 | } |
184 | void TableView::setTodo( int, const OTodo&) { | 194 | void TableView::setTodo( int, const OTodo&) { |
185 | sort(); | 195 | sort(); |
186 | 196 | ||
187 | /* repaint */ | 197 | /* repaint */ |
188 | repaint(); | 198 | repaint(); |
189 | } | 199 | } |