summaryrefslogtreecommitdiff
path: root/library/datebookmonth.cpp
Unidiff
Diffstat (limited to 'library/datebookmonth.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/datebookmonth.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp
index e8be313..728045f 100644
--- a/library/datebookmonth.cpp
+++ b/library/datebookmonth.cpp
@@ -75,192 +75,197 @@ DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name )
75 QWhatsThis::add( end, tr("Show December in the selected year") ); 75 QWhatsThis::add( end, tr("Show December in the selected year") );
76 76
77 connect( month, SIGNAL( activated( int ) ), 77 connect( month, SIGNAL( activated( int ) ),
78 this, SLOT( updateDate() ) ); 78 this, SLOT( updateDate() ) );
79 connect( year, SIGNAL( valueChanged( int ) ), 79 connect( year, SIGNAL( valueChanged( int ) ),
80 this, SLOT( updateDate() ) ); 80 this, SLOT( updateDate() ) );
81 connect( begin, SIGNAL( clicked() ), 81 connect( begin, SIGNAL( clicked() ),
82 this, SLOT( firstMonth() ) ); 82 this, SLOT( firstMonth() ) );
83 connect( end, SIGNAL( clicked() ), 83 connect( end, SIGNAL( clicked() ),
84 this, SLOT( lastMonth() ) ); 84 this, SLOT( lastMonth() ) );
85 connect( back, SIGNAL( clicked() ), 85 connect( back, SIGNAL( clicked() ),
86 this, SLOT( monthBack() ) ); 86 this, SLOT( monthBack() ) );
87 connect( next, SIGNAL( clicked() ), 87 connect( next, SIGNAL( clicked() ),
88 this, SLOT( monthForward() ) ); 88 this, SLOT( monthForward() ) );
89 back->setAutoRepeat( TRUE ); 89 back->setAutoRepeat( TRUE );
90 next->setAutoRepeat( TRUE ); 90 next->setAutoRepeat( TRUE );
91} 91}
92 92
93 93
94DateBookMonthHeader::~DateBookMonthHeader() 94DateBookMonthHeader::~DateBookMonthHeader()
95{ 95{
96 96
97} 97}
98 98
99void DateBookMonthHeader::updateDate() 99void DateBookMonthHeader::updateDate()
100{ 100{
101 emit dateChanged( year->value(), month->currentItem() + 1 ); 101 emit dateChanged( year->value(), month->currentItem() + 1 );
102} 102}
103 103
104void DateBookMonthHeader::firstMonth() 104void DateBookMonthHeader::firstMonth()
105{ 105{
106 emit dateChanged( year->value(), 1 ); 106 emit dateChanged( year->value(), 1 );
107 month->setCurrentItem( 0 ); 107 month->setCurrentItem( 0 );
108} 108}
109 109
110void DateBookMonthHeader::lastMonth() 110void DateBookMonthHeader::lastMonth()
111{ 111{
112 emit dateChanged( year->value(), 12 ); 112 emit dateChanged( year->value(), 12 );
113 month->setCurrentItem( 11 ); 113 month->setCurrentItem( 11 );
114} 114}
115 115
116void DateBookMonthHeader::monthBack() 116void DateBookMonthHeader::monthBack()
117{ 117{
118 if ( month->currentItem() > 0 ) { 118 if ( month->currentItem() > 0 ) {
119 emit dateChanged( year->value(), month->currentItem() ); 119 emit dateChanged( year->value(), month->currentItem() );
120 month->setCurrentItem( month->currentItem() - 1 ); 120 month->setCurrentItem( month->currentItem() - 1 );
121 } else { 121 } else {
122 emit dateChanged( year->value() - 1, 12 ); 122 emit dateChanged( year->value() - 1, 12 );
123 // we have a signal set to a changed value in year so we only need to change 123 // we have a signal set to a changed value in year so we only need to change
124 // year to get the result... 124 // year to get the result...
125 month->setCurrentItem( 11 ); 125 month->setCurrentItem( 11 );
126 year->setValue( year->value() - 1 ); 126 year->setValue( year->value() - 1 );
127 } 127 }
128} 128}
129 129
130void DateBookMonthHeader::monthForward() 130void DateBookMonthHeader::monthForward()
131{ 131{
132 if ( month->currentItem() < 11 ) { 132 if ( month->currentItem() < 11 ) {
133 emit dateChanged( year->value(), month->currentItem() + 2 ); 133 emit dateChanged( year->value(), month->currentItem() + 2 );
134 month->setCurrentItem( month->currentItem() + 1 ); 134 month->setCurrentItem( month->currentItem() + 1 );
135 } else { 135 } else {
136 // we have a signal set to a changed value in year so we only need to change 136 // we have a signal set to a changed value in year so we only need to change
137 // year to get the result... 137 // year to get the result...
138 month->setCurrentItem( 0 ); 138 month->setCurrentItem( 0 );
139 year->setValue( year->value() + 1 ); 139 year->setValue( year->value() + 1 );
140 } 140 }
141} 141}
142 142
143void DateBookMonthHeader::setDate( int y, int m ) 143void DateBookMonthHeader::setDate( int y, int m )
144{ 144{
145 year->setValue( y ); 145 year->setValue( y );
146 month->setCurrentItem( m - 1 ); 146 month->setCurrentItem( m - 1 );
147} 147}
148 148
149//--------------------------------------------------------------------------- 149//---------------------------------------------------------------------------
150 150
151class DateBookMonthTablePrivate 151class DateBookMonthTablePrivate
152{ 152{
153public: 153public:
154 DateBookMonthTablePrivate() {}; 154 DateBookMonthTablePrivate() {};
155 ~DateBookMonthTablePrivate() { mMonthEvents.clear(); }; 155 ~DateBookMonthTablePrivate() { mMonthEvents.clear(); };
156 156
157 QValueList<EffectiveEvent> mMonthEvents; 157 QValueList<EffectiveEvent> mMonthEvents;
158 bool onMonday; 158 bool onMonday;
159}; 159};
160 160
161DateBookMonthTable::DateBookMonthTable( QWidget *parent, const char *name, 161DateBookMonthTable::DateBookMonthTable( QWidget *parent, const char *name,
162 DateBookDB *newDb ) 162 DateBookDB *newDb )
163 : QTable( 6, 7, parent, name ), 163 : QTable( 6, 7, parent, name ),
164 db( newDb ) 164 db( newDb )
165{ 165{
166 d = new DateBookMonthTablePrivate(); 166 d = new DateBookMonthTablePrivate();
167 selYear = -1; 167 selYear = -1;
168 selMonth = -1; 168 selMonth = -1;
169 selDay = -1; 169 selDay = -1;
170 170
171 /* init these as well make valgrind happy and be consistent with Qtopia1.6 -zecke */
172 year = -1;
173 month = -1;
174 day = -1;
175
171 Config cfg( "qpe" ); 176 Config cfg( "qpe" );
172 cfg.setGroup( "Time" ); 177 cfg.setGroup( "Time" );
173 d->onMonday = cfg.readBoolEntry( "MONDAY" ); 178 d->onMonday = cfg.readBoolEntry( "MONDAY" );
174 179
175 horizontalHeader()->setResizeEnabled( FALSE ); 180 horizontalHeader()->setResizeEnabled( FALSE );
176 // we have to do this here... or suffer the consequences later... 181 // we have to do this here... or suffer the consequences later...
177 for ( int i = 0; i < 7; i++ ){ 182 for ( int i = 0; i < 7; i++ ){
178 horizontalHeader()->resizeSection( i, 30 ); 183 horizontalHeader()->resizeSection( i, 30 );
179 setColumnStretchable( i, TRUE ); 184 setColumnStretchable( i, TRUE );
180 } 185 }
181 setupLabels(); 186 setupLabels();
182 187
183 verticalHeader()->hide(); 188 verticalHeader()->hide();
184 setLeftMargin( 0 ); 189 setLeftMargin( 0 );
185 for ( int i = 0; i < 6; ++i ) 190 for ( int i = 0; i < 6; ++i )
186 setRowStretchable( i, TRUE ); 191 setRowStretchable( i, TRUE );
187 192
188 setSelectionMode( NoSelection ); 193 setSelectionMode( NoSelection );
189 194
190 connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), 195 connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ),
191 this, SLOT( dayClicked( int, int ) ) ); 196 this, SLOT( dayClicked( int, int ) ) );
192 connect( this, SIGNAL( currentChanged( int, int ) ), 197 connect( this, SIGNAL( currentChanged( int, int ) ),
193 this, SLOT( dragDay( int, int ) ) ); 198 this, SLOT( dragDay( int, int ) ) );
194 setVScrollBarMode( AlwaysOff ); 199 setVScrollBarMode( AlwaysOff );
195 setHScrollBarMode( AlwaysOff ); 200 setHScrollBarMode( AlwaysOff );
196} 201}
197 202
198DateBookMonthTable::~DateBookMonthTable() 203DateBookMonthTable::~DateBookMonthTable()
199{ 204{
200 monthsEvents.clear(); 205 monthsEvents.clear();
201 delete d; 206 delete d;
202} 207}
203 208
204void DateBookMonthTable::setDate(int y, int m, int d) 209void DateBookMonthTable::setDate(int y, int m, int d)
205{ 210{
206 if (month == m && year == y) { 211 if (month == m && year == y) {
207 if ( selYear == -1 ) 212 if ( selYear == -1 )
208 year = selYear; 213 year = selYear;
209 if ( selMonth == -1 ) 214 if ( selMonth == -1 )
210 month = selMonth; 215 month = selMonth;
211 int r1, c1, r2, c2; 216 int r1, c1, r2, c2;
212 findDay(selDay, r1, c1); 217 findDay(selDay, r1, c1);
213 selDay = day = d; 218 selDay = day = d;
214 findDay(selDay, r2, c2); 219 findDay(selDay, r2, c2);
215 setCurrentCell( r2, c2 ); 220 setCurrentCell( r2, c2 );
216 //updateCell(r1,c1); 221 //updateCell(r1,c1);
217 //updateCell(r2,c2); 222 //updateCell(r2,c2);
218 } else { 223 } else {
219 selYear = year = y; 224 selYear = year = y;
220 selMonth = month = m; 225 selMonth = month = m;
221 selDay = day = d; 226 selDay = day = d;
222 setupTable(); 227 setupTable();
223 } 228 }
224} 229}
225 230
226void DateBookMonthTable::redraw() 231void DateBookMonthTable::redraw()
227{ 232{
228 setupLabels(); 233 setupLabels();
229 setupTable(); 234 setupTable();
230} 235}
231 236
232void DateBookMonthTable::setWeekStart( bool onMonday ) 237void DateBookMonthTable::setWeekStart( bool onMonday )
233{ 238{
234 d->onMonday = onMonday; 239 d->onMonday = onMonday;
235 setupLabels(); 240 setupLabels();
236 setupTable(); 241 setupTable();
237} 242}
238 243
239void DateBookMonthTable::setupTable() 244void DateBookMonthTable::setupTable()
240{ 245{
241 QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday ); 246 QValueList<Calendar::Day> days = Calendar::daysOfMonth( year, month, d->onMonday );
242 QValueList<Calendar::Day>::Iterator it = days.begin(); 247 QValueList<Calendar::Day>::Iterator it = days.begin();
243 int row = 0, col = 0; 248 int row = 0, col = 0;
244 int crow = 0; 249 int crow = 0;
245 int ccol = 0; 250 int ccol = 0;
246 for ( ; it != days.end(); ++it ) { 251 for ( ; it != days.end(); ++it ) {
247 DayItemMonth *i = (DayItemMonth *)item( row, col ); 252 DayItemMonth *i = (DayItemMonth *)item( row, col );
248 if ( !i ) { 253 if ( !i ) {
249 i = new DayItemMonth( this, QTableItem::Never, "" ); 254 i = new DayItemMonth( this, QTableItem::Never, "" );
250 setItem( row, col, i ); 255 setItem( row, col, i );
251 } 256 }
252 Calendar::Day calDay = *it; 257 Calendar::Day calDay = *it;
253 i->clearEffEvents(); 258 i->clearEffEvents();
254 i->setDay( calDay.date ); 259 i->setDay( calDay.date );
255 i->setType( calDay.type ); 260 i->setType( calDay.type );
256 if ( i->day() == day && calDay.type == Calendar::Day::ThisMonth ) { 261 if ( i->day() == day && calDay.type == Calendar::Day::ThisMonth ) {
257 crow = row; 262 crow = row;
258 ccol = col; 263 ccol = col;
259 } 264 }
260 265
261 updateCell( row, col ); 266 updateCell( row, col );
262 267
263 if ( col == 6 ) { 268 if ( col == 6 ) {
264 ++row; 269 ++row;
265 col = 0; 270 col = 0;
266 } else { 271 } else {