-rw-r--r-- | korganizer/koagenda.cpp | 23 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 15 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 23 | ||||
-rw-r--r-- | korganizer/kofilterview.h | 1 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 6 | ||||
-rw-r--r-- | korganizer/koprefs.h | 4 | ||||
-rw-r--r-- | microkde/kglobalsettings.cpp | 9 | ||||
-rw-r--r-- | microkde/kglobalsettings.h | 1 |
8 files changed, 59 insertions, 23 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 662576f..92c1cd6 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -40,166 +40,167 @@ | |||
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | 63 | ||
64 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | delete minutes; | 88 | //delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | |||
155 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
156 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
157 | minutes->start(5000,true); | 156 | int secs = QTime::currentTime().second(); |
157 | qDebug("second %d ", secs ); | ||
158 | minutes->start( (60 - secs +1)*1000 ,true); | ||
158 | } | 159 | } |
159 | 160 | ||
160 | 161 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 162 | //////////////////////////////////////////////////////////////////////////// |
162 | 163 | ||
163 | 164 | ||
164 | /* | 165 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 166 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 167 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 168 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 169 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 170 | QScrollView(parent,name,f) |
170 | { | 171 | { |
171 | 172 | ||
172 | mAllAgendaPopup = 0; | 173 | mAllAgendaPopup = 0; |
173 | mColumns = columns; | 174 | mColumns = columns; |
174 | mRows = rows; | 175 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 176 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 177 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 178 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 179 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 180 | #endif |
180 | mHolidayMask = 0; | 181 | mHolidayMask = 0; |
181 | init(); | 182 | init(); |
182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 183 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
183 | } | 184 | } |
184 | 185 | ||
185 | /* | 186 | /* |
186 | Create an agenda widget with columns columns and one row. This is used for | 187 | Create an agenda widget with columns columns and one row. This is used for |
187 | all-day events. | 188 | all-day events. |
188 | */ | 189 | */ |
189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 190 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
190 | QScrollView(parent,name,f) | 191 | QScrollView(parent,name,f) |
191 | { | 192 | { |
192 | mAllAgendaPopup = 0; | 193 | mAllAgendaPopup = 0; |
193 | blockResize = false; | 194 | blockResize = false; |
194 | mColumns = columns; | 195 | mColumns = columns; |
195 | mRows = 1; | 196 | mRows = 1; |
196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 197 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 198 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
198 | mAllDayMode = true; | 199 | mAllDayMode = true; |
199 | #ifndef DESKTOP_VERSION | 200 | #ifndef DESKTOP_VERSION |
200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 201 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
201 | #endif | 202 | #endif |
202 | mHolidayMask = 0; | 203 | mHolidayMask = 0; |
203 | init(); | 204 | init(); |
204 | } | 205 | } |
205 | 206 | ||
@@ -397,97 +398,97 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | |||
397 | return QScrollView::eventFilter(object,event); | 398 | return QScrollView::eventFilter(object,event); |
398 | } | 399 | } |
399 | } | 400 | } |
400 | void KOAgenda::popupMenu() | 401 | void KOAgenda::popupMenu() |
401 | { | 402 | { |
402 | mPopupTimer->stop(); | 403 | mPopupTimer->stop(); |
403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 404 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
404 | if (mActionItem ) { | 405 | if (mActionItem ) { |
405 | endItemAction(); | 406 | endItemAction(); |
406 | } | 407 | } |
407 | mLeftMouseDown = false; // no more leftMouse computation | 408 | mLeftMouseDown = false; // no more leftMouse computation |
408 | if (mPopupItem) { | 409 | if (mPopupItem) { |
409 | //mClickedItem = mPopupItem; | 410 | //mClickedItem = mPopupItem; |
410 | selectItem(mPopupItem); | 411 | selectItem(mPopupItem); |
411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 412 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
412 | mAllAgendaPopup->installEventFilter( this ); | 413 | mAllAgendaPopup->installEventFilter( this ); |
413 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 414 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
414 | 415 | ||
415 | } | 416 | } |
416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 417 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 418 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
418 | endSelectAction( false ); // do not emit new event signal | 419 | endSelectAction( false ); // do not emit new event signal |
419 | mLeftMouseDown = false; // no more leftMouse computation | 420 | mLeftMouseDown = false; // no more leftMouse computation |
420 | } | 421 | } |
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 422 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 423 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 424 | mNewItemPopup->popup( mPopupPos); |
424 | 425 | ||
425 | } | 426 | } |
426 | mLeftMouseDown = false; | 427 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 428 | mPopupItem = 0; |
428 | mPopupKind = 0; | 429 | mPopupKind = 0; |
429 | } | 430 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 431 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 432 | { |
432 | KOAgendaItem *item; | 433 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 434 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 435 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 436 | item->initColor (); |
436 | item->updateItem(); | 437 | item->updateItem(); |
437 | } | 438 | } |
438 | } | 439 | } |
439 | } | 440 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 441 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 442 | { |
442 | 443 | ||
443 | if ( mInvalidPixmap ) { | 444 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 445 | mInvalidPixmap = false; |
445 | qDebug("InvalidPixmap "); | 446 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 447 | computeSizes(); |
447 | emit updateViewSignal(); | 448 | emit updateViewSignal(); |
448 | return true; | 449 | return true; |
449 | } | 450 | } |
450 | emit sendPing(); | 451 | emit sendPing(); |
451 | static int startX = 0; | 452 | static int startX = 0; |
452 | static int startY = 0; | 453 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 454 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 455 | static bool blockMoving = true; |
455 | 456 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 457 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 458 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 459 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 460 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 461 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 462 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 463 | if ( dX < 0 ) |
463 | dX = -dX; | 464 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 465 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 466 | if ( dY < 0 ) |
466 | dY = -dY; | 467 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 468 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 469 | mNewItemPopup->hide(); |
469 | } | 470 | } |
470 | } | 471 | } |
471 | return true; | 472 | return true; |
472 | } | 473 | } |
473 | if ( object == mAllAgendaPopup ) { | 474 | if ( object == mAllAgendaPopup ) { |
474 | //qDebug(" mAllAgendaPopup "); | 475 | //qDebug(" mAllAgendaPopup "); |
475 | if ( me->type() == QEvent::MouseButtonRelease ) { | 476 | if ( me->type() == QEvent::MouseButtonRelease ) { |
476 | mAllAgendaPopup->removeEventFilter( this ); | 477 | mAllAgendaPopup->removeEventFilter( this ); |
477 | int dX = me->globalPos().x() - mPopupPos.x();; | 478 | int dX = me->globalPos().x() - mPopupPos.x();; |
478 | if ( dX < 0 ) | 479 | if ( dX < 0 ) |
479 | dX = -dX; | 480 | dX = -dX; |
480 | int dY = me->globalPos().y() - mPopupPos.y(); | 481 | int dY = me->globalPos().y() - mPopupPos.y(); |
481 | if ( dY < 0 ) | 482 | if ( dY < 0 ) |
482 | dY = -dY; | 483 | dY = -dY; |
483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 484 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
484 | mAllAgendaPopup->hide(); | 485 | mAllAgendaPopup->hide(); |
485 | } | 486 | } |
486 | } | 487 | } |
487 | return true; | 488 | return true; |
488 | } | 489 | } |
489 | QPoint viewportPos; | 490 | QPoint viewportPos; |
490 | if (object != viewport()) { | 491 | if (object != viewport()) { |
491 | blockmoveDist = blockmoveDist*2; | 492 | blockmoveDist = blockmoveDist*2; |
492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 493 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
493 | } else { | 494 | } else { |
@@ -1231,97 +1232,97 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | |||
1231 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1232 | for ( item2=conflictItems2.first(); item2 != 0; | 1233 | for ( item2=conflictItems2.first(); item2 != 0; |
1233 | item2=conflictItems2.next() ) { | 1234 | item2=conflictItems2.next() ) { |
1234 | if ( item2->subCells() != maxSubCells) { | 1235 | if ( item2->subCells() != maxSubCells) { |
1235 | item2->setSubCells(maxSubCells); | 1236 | item2->setSubCells(maxSubCells); |
1236 | if (mAllDayMode) { | 1237 | if (mAllDayMode) { |
1237 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1238 | } else { | 1239 | } else { |
1239 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1240 | } | 1241 | } |
1241 | int x,y; | 1242 | int x,y; |
1242 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1243 | if (mAllDayMode) { | 1244 | if (mAllDayMode) { |
1244 | y += item2->subCell() * newSubCellWidth; | 1245 | y += item2->subCell() * newSubCellWidth; |
1245 | } else { | 1246 | } else { |
1246 | x += item2->subCell() * newSubCellWidth; | 1247 | x += item2->subCell() * newSubCellWidth; |
1247 | } | 1248 | } |
1248 | moveChild(item2,x,y); | 1249 | moveChild(item2,x,y); |
1249 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1250 | } | 1251 | } |
1251 | } | 1252 | } |
1252 | } | 1253 | } |
1253 | } | 1254 | } |
1254 | } else { | 1255 | } else { |
1255 | placeItem->setSubCell(0); | 1256 | placeItem->setSubCell(0); |
1256 | placeItem->setSubCells(1); | 1257 | placeItem->setSubCells(1); |
1257 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1258 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1259 | int x,y; | 1260 | int x,y; |
1260 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1261 | moveChild(placeItem,x,y); | 1262 | moveChild(placeItem,x,y); |
1262 | } | 1263 | } |
1263 | placeItem->setConflictItems(conflictItems); | 1264 | placeItem->setConflictItems(conflictItems); |
1264 | // for ( item=conflictItems.first(); item != 0; | 1265 | // for ( item=conflictItems.first(); item != 0; |
1265 | // item=conflictItems.next() ) { | 1266 | // item=conflictItems.next() ) { |
1266 | // //item->updateItem(); | 1267 | // //item->updateItem(); |
1267 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1268 | // } | 1269 | // } |
1269 | // placeItem->updateItem(); | 1270 | // placeItem->updateItem(); |
1270 | } | 1271 | } |
1271 | 1272 | ||
1272 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1273 | { | 1274 | { |
1274 | if ( globalFlagBlockAgenda ) | 1275 | if ( globalFlagBlockAgenda ) |
1275 | return; | 1276 | return; |
1276 | 1277 | ||
1277 | if ( mInvalidPixmap ) { | 1278 | if ( mInvalidPixmap ) { |
1278 | mInvalidPixmap = false; | 1279 | mInvalidPixmap = false; |
1279 | qDebug("InvalidPixmap "); | 1280 | qDebug("KO: Upsizing Pixmaps "); |
1280 | computeSizes(); | 1281 | computeSizes(); |
1281 | emit updateViewSignal(); | 1282 | emit updateViewSignal(); |
1282 | return; | 1283 | return; |
1283 | } | 1284 | } |
1284 | if ( ! mAllDayMode ) { | 1285 | if ( ! mAllDayMode ) { |
1285 | // currently not working for | 1286 | // currently not working for |
1286 | 1287 | ||
1287 | //qDebug("KOAgenda::drawContents "); | 1288 | //qDebug("KOAgenda::drawContents "); |
1288 | #if 0 | 1289 | #if 0 |
1289 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1290 | qDebug("WAU "); | 1291 | qDebug("WAU "); |
1291 | drawContentsToPainter(); | 1292 | drawContentsToPainter(); |
1292 | } | 1293 | } |
1293 | #endif | 1294 | #endif |
1294 | QPaintDevice* pd = p->device(); | 1295 | QPaintDevice* pd = p->device(); |
1295 | p->end(); | 1296 | p->end(); |
1296 | int vx, vy; | 1297 | int vx, vy; |
1297 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1298 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1298 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1299 | mSelectionCellX * mGridSpacingX; | 1300 | mSelectionCellX * mGridSpacingX; |
1300 | contentsToViewport ( cx, cy, vx,vy); | 1301 | contentsToViewport ( cx, cy, vx,vy); |
1301 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1302 | 1303 | ||
1303 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1304 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1305 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1306 | 1307 | ||
1307 | int vxSel, vySel; | 1308 | int vxSel, vySel; |
1308 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1309 | int off = mSelectionHeight; | 1310 | int off = mSelectionHeight; |
1310 | if ( vySel < 0 ) | 1311 | if ( vySel < 0 ) |
1311 | off += vySel; | 1312 | off += vySel; |
1312 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1313 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1314 | } else { | 1315 | } else { |
1315 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1316 | } | 1317 | } |
1317 | } | 1318 | } |
1318 | if ( mSelectionHeight > 0 ) { | 1319 | if ( mSelectionHeight > 0 ) { |
1319 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1320 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1321 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1322 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1323 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1324 | int hei = mSelectionHeight; | 1325 | int hei = mSelectionHeight; |
1325 | int offset = 0; | 1326 | int offset = 0; |
1326 | while ( hei > 0 ) { | 1327 | while ( hei > 0 ) { |
1327 | int p_hei = 5; | 1328 | int p_hei = 5; |
@@ -1372,97 +1373,97 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | |||
1372 | p->begin( pd ); | 1373 | p->begin( pd ); |
1373 | } | 1374 | } |
1374 | 1375 | ||
1375 | } | 1376 | } |
1376 | 1377 | ||
1377 | void KOAgenda::finishUpdate() | 1378 | void KOAgenda::finishUpdate() |
1378 | { | 1379 | { |
1379 | 1380 | ||
1380 | KOAgendaItem *item; | 1381 | KOAgendaItem *item; |
1381 | globalFlagBlockAgendaItemPaint = 1; | 1382 | globalFlagBlockAgendaItemPaint = 1; |
1382 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1383 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1384 | if ( !item->checkLayout() ) { | 1385 | if ( !item->checkLayout() ) { |
1385 | //qDebug(" conflictitem found "); | 1386 | //qDebug(" conflictitem found "); |
1386 | int newSubCellWidth; | 1387 | int newSubCellWidth; |
1387 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1388 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1389 | 1390 | ||
1390 | if (mAllDayMode) { | 1391 | if (mAllDayMode) { |
1391 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1392 | } else { | 1393 | } else { |
1393 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1394 | } | 1395 | } |
1395 | int x,y; | 1396 | int x,y; |
1396 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1397 | if (mAllDayMode) { | 1398 | if (mAllDayMode) { |
1398 | y += item->subCell() * newSubCellWidth; | 1399 | y += item->subCell() * newSubCellWidth; |
1399 | } else { | 1400 | } else { |
1400 | x += item->subCell() * newSubCellWidth; | 1401 | x += item->subCell() * newSubCellWidth; |
1401 | } | 1402 | } |
1402 | moveChild(item,x,y); | 1403 | moveChild(item,x,y); |
1403 | } | 1404 | } |
1404 | } | 1405 | } |
1405 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1406 | if ( !item->isVisible() ) | 1407 | if ( !item->isVisible() ) |
1407 | item->show(); | 1408 | item->show(); |
1408 | 1409 | ||
1409 | } | 1410 | } |
1410 | globalFlagBlockAgendaItemUpdate = 0; | 1411 | globalFlagBlockAgendaItemUpdate = 0; |
1411 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1412 | item->repaintMe( ); | 1413 | item->repaintMe( ); |
1413 | } | 1414 | } |
1414 | globalFlagBlockAgendaItemUpdate = 1; | 1415 | globalFlagBlockAgendaItemUpdate = 1; |
1415 | qApp->processEvents(); | 1416 | qApp->processEvents(); |
1416 | globalFlagBlockAgendaItemPaint = 0; | 1417 | globalFlagBlockAgendaItemPaint = 0; |
1417 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1418 | item->repaint( false ); | 1419 | item->repaint( false ); |
1419 | } | 1420 | } |
1420 | 1421 | marcus_bains(); | |
1421 | } | 1422 | } |
1422 | 1423 | ||
1423 | /* | 1424 | /* |
1424 | Draw grid in the background of the agenda. | 1425 | Draw grid in the background of the agenda. |
1425 | */ | 1426 | */ |
1426 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1427 | { | 1428 | { |
1428 | 1429 | ||
1429 | 1430 | ||
1430 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1431 | return; | 1432 | return; |
1432 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1433 | return; | 1434 | return; |
1434 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1435 | if ( ch < 1 ) | 1436 | if ( ch < 1 ) |
1436 | ch = 1; | 1437 | ch = 1; |
1437 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1438 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1439 | } | 1440 | } |
1440 | mCurPixWid = contentsWidth(); | 1441 | mCurPixWid = contentsWidth(); |
1441 | mCurPixHei = ch; | 1442 | mCurPixHei = ch; |
1442 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1443 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1444 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1445 | } | 1446 | } |
1446 | mPixPainter.begin( &mPaintPixmap) ; | 1447 | mPixPainter.begin( &mPaintPixmap) ; |
1447 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1448 | QPainter * p ; | 1449 | QPainter * p ; |
1449 | if (paint == 0) { | 1450 | if (paint == 0) { |
1450 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1451 | p = &mPixPainter; | 1452 | p = &mPixPainter; |
1452 | } | 1453 | } |
1453 | else | 1454 | else |
1454 | p = paint ; | 1455 | p = paint ; |
1455 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1456 | 1457 | ||
1457 | //--cx;++cw; | 1458 | //--cx;++cw; |
1458 | int lGridSpacingY = mGridSpacingY*2; | 1459 | int lGridSpacingY = mGridSpacingY*2; |
1459 | int selDay; | 1460 | int selDay; |
1460 | QDate curDate = QDate::currentDate(); | 1461 | QDate curDate = QDate::currentDate(); |
1461 | if ( !backgroundOnly ) { | 1462 | if ( !backgroundOnly ) { |
1462 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1463 | { | 1464 | { |
1464 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1465 | int x1 = cx; | 1466 | int x1 = cx; |
1466 | int y1 = 0; | 1467 | int y1 = 0; |
1467 | if (y1 < cy) y1 = cy; | 1468 | if (y1 < cy) y1 = cy; |
1468 | int x2 = cx+cw-1; | 1469 | int x2 = cx+cw-1; |
@@ -1755,421 +1756,415 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | |||
1755 | item->show(); | 1756 | item->show(); |
1756 | } | 1757 | } |
1757 | qApp->processEvents(); | 1758 | qApp->processEvents(); |
1758 | globalFlagBlockAgendaItemPaint = 0; | 1759 | globalFlagBlockAgendaItemPaint = 0; |
1759 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1760 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1760 | KOAgendaItem *itemit; | 1761 | KOAgendaItem *itemit; |
1761 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1762 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1762 | itemit=oldconflictItems.next() ) { | 1763 | itemit=oldconflictItems.next() ) { |
1763 | globalFlagBlockAgendaItemUpdate = 0; | 1764 | globalFlagBlockAgendaItemUpdate = 0; |
1764 | itemit->repaintMe(); | 1765 | itemit->repaintMe(); |
1765 | globalFlagBlockAgendaItemUpdate = 1; | 1766 | globalFlagBlockAgendaItemUpdate = 1; |
1766 | itemit->repaint(); | 1767 | itemit->repaint(); |
1767 | } | 1768 | } |
1768 | globalFlagBlockAgendaItemUpdate = 0; | 1769 | globalFlagBlockAgendaItemUpdate = 0; |
1769 | item->repaintMe(); | 1770 | item->repaintMe(); |
1770 | globalFlagBlockAgendaItemUpdate = 1; | 1771 | globalFlagBlockAgendaItemUpdate = 1; |
1771 | item->repaint(); | 1772 | item->repaint(); |
1772 | } | 1773 | } |
1773 | /* | 1774 | /* |
1774 | Insert KOAgendaItem into agenda. | 1775 | Insert KOAgendaItem into agenda. |
1775 | */ | 1776 | */ |
1776 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1777 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1777 | { | 1778 | { |
1778 | if (mAllDayMode) { | 1779 | if (mAllDayMode) { |
1779 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1780 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1780 | return 0; | 1781 | return 0; |
1781 | } | 1782 | } |
1782 | 1783 | ||
1783 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1784 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1784 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1785 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1785 | 1786 | ||
1786 | int YSize = YBottom - YTop + 1; | 1787 | int YSize = YBottom - YTop + 1; |
1787 | if (YSize < 0) { | 1788 | if (YSize < 0) { |
1788 | YSize = 1; | 1789 | YSize = 1; |
1789 | } | 1790 | } |
1790 | int iheight = mGridSpacingY * YSize; | 1791 | int iheight = mGridSpacingY * YSize; |
1791 | 1792 | ||
1792 | agendaItem->resize(mGridSpacingX,iheight ); | 1793 | agendaItem->resize(mGridSpacingX,iheight ); |
1793 | agendaItem->setCellXY(X,YTop,YBottom); | 1794 | agendaItem->setCellXY(X,YTop,YBottom); |
1794 | agendaItem->setCellXWidth(X); | 1795 | agendaItem->setCellXWidth(X); |
1795 | 1796 | ||
1796 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1797 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1797 | mItems.append(agendaItem); | 1798 | mItems.append(agendaItem); |
1798 | 1799 | ||
1799 | placeSubCells(agendaItem); | 1800 | placeSubCells(agendaItem); |
1800 | 1801 | ||
1801 | //agendaItem->show(); | 1802 | //agendaItem->show(); |
1802 | 1803 | ||
1803 | marcus_bains(); | ||
1804 | 1804 | ||
1805 | return agendaItem; | 1805 | return agendaItem; |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | 1808 | ||
1809 | /* | 1809 | /* |
1810 | Insert all-day KOAgendaItem into agenda. | 1810 | Insert all-day KOAgendaItem into agenda. |
1811 | */ | 1811 | */ |
1812 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1812 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1813 | { | 1813 | { |
1814 | if (!mAllDayMode) { | 1814 | if (!mAllDayMode) { |
1815 | return 0; | 1815 | return 0; |
1816 | } | 1816 | } |
1817 | 1817 | ||
1818 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1818 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1819 | 1819 | ||
1820 | agendaItem->setCellXY(XBegin,0,0); | 1820 | agendaItem->setCellXY(XBegin,0,0); |
1821 | agendaItem->setCellXWidth(XEnd); | 1821 | agendaItem->setCellXWidth(XEnd); |
1822 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1822 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1823 | 1823 | ||
1824 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1824 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1825 | mItems.append(agendaItem); | 1825 | mItems.append(agendaItem); |
1826 | 1826 | ||
1827 | placeSubCells(agendaItem); | 1827 | placeSubCells(agendaItem); |
1828 | 1828 | ||
1829 | //agendaItem->show(); | 1829 | //agendaItem->show(); |
1830 | 1830 | ||
1831 | return agendaItem; | 1831 | return agendaItem; |
1832 | } | 1832 | } |
1833 | 1833 | ||
1834 | 1834 | ||
1835 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1835 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1836 | int YTop,int YBottom) | 1836 | int YTop,int YBottom) |
1837 | { | 1837 | { |
1838 | if (mAllDayMode) { | 1838 | if (mAllDayMode) { |
1839 | ; | 1839 | ; |
1840 | return; | 1840 | return; |
1841 | } | 1841 | } |
1842 | 1842 | ||
1843 | int cellX,cellYTop,cellYBottom; | 1843 | int cellX,cellYTop,cellYBottom; |
1844 | QString newtext; | 1844 | QString newtext; |
1845 | int width = XEnd - XBegin + 1; | 1845 | int width = XEnd - XBegin + 1; |
1846 | int count = 0; | 1846 | int count = 0; |
1847 | KOAgendaItem *current = 0; | 1847 | KOAgendaItem *current = 0; |
1848 | QPtrList<KOAgendaItem> multiItems; | 1848 | QPtrList<KOAgendaItem> multiItems; |
1849 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1849 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1850 | if (cellX == XBegin) cellYTop = YTop; | 1850 | if (cellX == XBegin) cellYTop = YTop; |
1851 | else cellYTop = 0; | 1851 | else cellYTop = 0; |
1852 | if (cellX == XEnd) cellYBottom = YBottom; | 1852 | if (cellX == XEnd) cellYBottom = YBottom; |
1853 | else cellYBottom = rows() - 1; | 1853 | else cellYBottom = rows() - 1; |
1854 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1854 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1855 | newtext.append(event->summary()); | 1855 | newtext.append(event->summary()); |
1856 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1856 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1857 | current->setText(newtext); | 1857 | current->setText(newtext); |
1858 | multiItems.append(current); | 1858 | multiItems.append(current); |
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | KOAgendaItem *next = 0; | 1861 | KOAgendaItem *next = 0; |
1862 | KOAgendaItem *last = multiItems.last(); | 1862 | KOAgendaItem *last = multiItems.last(); |
1863 | KOAgendaItem *first = multiItems.first(); | 1863 | KOAgendaItem *first = multiItems.first(); |
1864 | KOAgendaItem *setFirst,*setLast; | 1864 | KOAgendaItem *setFirst,*setLast; |
1865 | current = first; | 1865 | current = first; |
1866 | while (current) { | 1866 | while (current) { |
1867 | next = multiItems.next(); | 1867 | next = multiItems.next(); |
1868 | if (current == first) setFirst = 0; | 1868 | if (current == first) setFirst = 0; |
1869 | else setFirst = first; | 1869 | else setFirst = first; |
1870 | if (current == last) setLast = 0; | 1870 | if (current == last) setLast = 0; |
1871 | else setLast = last; | 1871 | else setLast = last; |
1872 | 1872 | ||
1873 | current->setMultiItem(setFirst,next,setLast); | 1873 | current->setMultiItem(setFirst,next,setLast); |
1874 | current = next; | 1874 | current = next; |
1875 | } | 1875 | } |
1876 | |||
1877 | marcus_bains(); | ||
1878 | } | 1876 | } |
1879 | 1877 | ||
1880 | 1878 | ||
1881 | //QSizePolicy KOAgenda::sizePolicy() const | 1879 | //QSizePolicy KOAgenda::sizePolicy() const |
1882 | //{ | 1880 | //{ |
1883 | // Thought this would make the all-day event agenda minimum size and the | 1881 | // Thought this would make the all-day event agenda minimum size and the |
1884 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1882 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1885 | // don´t seem to think that an Expanding widget needs more space than a | 1883 | // don´t seem to think that an Expanding widget needs more space than a |
1886 | // Preferred one. | 1884 | // Preferred one. |
1887 | // But it doesn´t hurt, so it stays. | 1885 | // But it doesn´t hurt, so it stays. |
1888 | // if (mAllDayMode) { | 1886 | // if (mAllDayMode) { |
1889 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1887 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1890 | // } else { | 1888 | // } else { |
1891 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1889 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1892 | // } | 1890 | // } |
1893 | //} | 1891 | //} |
1894 | void KOAgenda::finishResize ( ) | 1892 | void KOAgenda::finishResize ( ) |
1895 | { | 1893 | { |
1896 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1894 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1897 | if ( globalFlagBlockAgenda == 0 ) { | 1895 | if ( globalFlagBlockAgenda == 0 ) { |
1898 | finishUpdate(); | 1896 | finishUpdate(); |
1899 | //qDebug("finishUpdate() called "); | 1897 | //qDebug("finishUpdate() called "); |
1900 | } | 1898 | } |
1901 | } | 1899 | } |
1902 | /* | 1900 | /* |
1903 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1901 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1904 | */ | 1902 | */ |
1905 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1903 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1906 | { | 1904 | { |
1907 | mSelectionHeight = 0; | 1905 | mSelectionHeight = 0; |
1908 | mResizeTimer.start( 150 , true ); | 1906 | mResizeTimer.start( 150 , true ); |
1909 | computeSizes(); | 1907 | computeSizes(); |
1910 | return; | 1908 | return; |
1911 | 1909 | ||
1912 | } | 1910 | } |
1913 | void KOAgenda::computeSizes() | 1911 | void KOAgenda::computeSizes() |
1914 | { | 1912 | { |
1915 | if ( globalFlagBlockStartup ) | 1913 | if ( globalFlagBlockStartup ) |
1916 | return; | 1914 | return; |
1917 | int frameOffset = frameWidth() * 2 +1; | 1915 | int frameOffset = frameWidth() * 2 +1; |
1918 | if (mAllDayMode) { | 1916 | if (mAllDayMode) { |
1919 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1917 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1920 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1918 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1921 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1919 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1922 | // mGridSpacingY = height(); | 1920 | // mGridSpacingY = height(); |
1923 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1921 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1924 | 1922 | ||
1925 | KOAgendaItem *item; | 1923 | KOAgendaItem *item; |
1926 | int subCellWidth; | 1924 | int subCellWidth; |
1927 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1925 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1928 | subCellWidth = mGridSpacingY / item->subCells(); | 1926 | subCellWidth = mGridSpacingY / item->subCells(); |
1929 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1927 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1930 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1928 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1931 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1929 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1932 | item->cellX() * mGridSpacingX, | 1930 | item->cellX() * mGridSpacingX, |
1933 | item->subCell() * subCellWidth); | 1931 | item->subCell() * subCellWidth); |
1934 | } | 1932 | } |
1935 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1933 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1936 | } else { | 1934 | } else { |
1937 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1935 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1938 | if (height() > mGridSpacingY * mRows + 1 ) { | 1936 | if (height() > mGridSpacingY * mRows + 1 ) { |
1939 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1937 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1940 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1938 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1941 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1939 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1942 | emit resizedSignal(); | 1940 | emit resizedSignal(); |
1943 | } else | 1941 | } else |
1944 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1942 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1945 | KOAgendaItem *item; | 1943 | KOAgendaItem *item; |
1946 | int subCellWidth; | 1944 | int subCellWidth; |
1947 | 1945 | ||
1948 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1946 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1949 | subCellWidth = mGridSpacingX / item->subCells(); | 1947 | subCellWidth = mGridSpacingX / item->subCells(); |
1950 | item->resize(subCellWidth,item->height()); | 1948 | item->resize(subCellWidth,item->height()); |
1951 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1949 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1952 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1950 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1953 | item->cellX() * mGridSpacingX) + | 1951 | item->cellX() * mGridSpacingX) + |
1954 | item->subCell() * subCellWidth,childY(item)); | 1952 | item->subCell() * subCellWidth,childY(item)); |
1955 | } | 1953 | } |
1956 | } | 1954 | } |
1957 | int cw = contentsWidth(); | 1955 | int cw = contentsWidth(); |
1958 | int ch = contentsHeight(); | 1956 | int ch = contentsHeight(); |
1959 | if ( mAllDayMode ) { | 1957 | if ( mAllDayMode ) { |
1960 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1958 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1961 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1959 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1962 | qDebug("paintPixAll->resize "); | 1960 | //qDebug("paintPixAll->resize "); |
1963 | paintPixAll->resize( cw, ch ); | 1961 | paintPixAll->resize( cw, ch ); |
1964 | } | 1962 | } |
1965 | } else { | 1963 | } else { |
1966 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1964 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1967 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1965 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1968 | qDebug("paintPix->resize "); | 1966 | //qDebug("paintPix->resize "); |
1969 | paintPix->resize( cw , ch ); | 1967 | paintPix->resize( cw , ch ); |
1970 | } | 1968 | } |
1971 | } | 1969 | } |
1972 | 1970 | ||
1973 | checkScrollBoundaries(); | 1971 | checkScrollBoundaries(); |
1974 | marcus_bains(); | ||
1975 | drawContentsToPainter(); | 1972 | drawContentsToPainter(); |
1976 | viewport()->repaint(false); | 1973 | viewport()->repaint(false); |
1977 | } | 1974 | } |
1978 | 1975 | ||
1979 | void KOAgenda::scrollUp() | 1976 | void KOAgenda::scrollUp() |
1980 | { | 1977 | { |
1981 | scrollBy(0,-mScrollOffset); | 1978 | scrollBy(0,-mScrollOffset); |
1982 | } | 1979 | } |
1983 | 1980 | ||
1984 | 1981 | ||
1985 | void KOAgenda::scrollDown() | 1982 | void KOAgenda::scrollDown() |
1986 | { | 1983 | { |
1987 | scrollBy(0,mScrollOffset); | 1984 | scrollBy(0,mScrollOffset); |
1988 | } | 1985 | } |
1989 | 1986 | ||
1990 | void KOAgenda::popupAlarm() | 1987 | void KOAgenda::popupAlarm() |
1991 | { | 1988 | { |
1992 | if (!mClickedItem) { | 1989 | if (!mClickedItem) { |
1993 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1990 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1994 | return; | 1991 | return; |
1995 | } | 1992 | } |
1996 | // TODO: deal correctly with multiple alarms | 1993 | // TODO: deal correctly with multiple alarms |
1997 | Alarm* alarm; | 1994 | Alarm* alarm; |
1998 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1995 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1999 | for(alarm=list.first();alarm;alarm=list.next()) { | 1996 | for(alarm=list.first();alarm;alarm=list.next()) { |
2000 | alarm->toggleAlarm(); | 1997 | alarm->toggleAlarm(); |
2001 | } | 1998 | } |
2002 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1999 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2003 | mClickedItem->paintMe( true ); | 2000 | mClickedItem->paintMe( true ); |
2004 | mClickedItem->repaint( false ); | 2001 | mClickedItem->repaint( false ); |
2005 | } | 2002 | } |
2006 | 2003 | ||
2007 | /* | 2004 | /* |
2008 | Calculates the minimum width | 2005 | Calculates the minimum width |
2009 | */ | 2006 | */ |
2010 | int KOAgenda::minimumWidth() const | 2007 | int KOAgenda::minimumWidth() const |
2011 | { | 2008 | { |
2012 | // TODO:: develop a way to dynamically determine the minimum width | 2009 | // TODO:: develop a way to dynamically determine the minimum width |
2013 | int min = 100; | 2010 | int min = 100; |
2014 | 2011 | ||
2015 | return min; | 2012 | return min; |
2016 | } | 2013 | } |
2017 | 2014 | ||
2018 | void KOAgenda::updateConfig() | 2015 | void KOAgenda::updateConfig() |
2019 | { | 2016 | { |
2020 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2017 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2021 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2018 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2022 | if ( mAllDayMode ) { | 2019 | if ( mAllDayMode ) { |
2023 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2020 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2024 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2021 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2025 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2022 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2026 | // setMaximumHeight( mGridSpacingY+1 ); | 2023 | // setMaximumHeight( mGridSpacingY+1 ); |
2027 | viewport()->repaint( false ); | 2024 | viewport()->repaint( false ); |
2028 | //setFixedHeight( mGridSpacingY+1 ); | 2025 | //setFixedHeight( mGridSpacingY+1 ); |
2029 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2026 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2030 | } | 2027 | } |
2031 | else { | 2028 | else { |
2032 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2029 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2033 | calculateWorkingHours(); | 2030 | calculateWorkingHours(); |
2034 | marcus_bains(); | ||
2035 | } | 2031 | } |
2036 | } | 2032 | } |
2037 | 2033 | ||
2038 | void KOAgenda::checkScrollBoundaries() | 2034 | void KOAgenda::checkScrollBoundaries() |
2039 | { | 2035 | { |
2040 | // Invalidate old values to force update | 2036 | // Invalidate old values to force update |
2041 | mOldLowerScrollValue = -1; | 2037 | mOldLowerScrollValue = -1; |
2042 | mOldUpperScrollValue = -1; | 2038 | mOldUpperScrollValue = -1; |
2043 | 2039 | ||
2044 | checkScrollBoundaries(verticalScrollBar()->value()); | 2040 | checkScrollBoundaries(verticalScrollBar()->value()); |
2045 | } | 2041 | } |
2046 | 2042 | ||
2047 | void KOAgenda::checkScrollBoundaries(int v) | 2043 | void KOAgenda::checkScrollBoundaries(int v) |
2048 | { | 2044 | { |
2049 | if ( mGridSpacingY == 0 ) | 2045 | if ( mGridSpacingY == 0 ) |
2050 | return; | 2046 | return; |
2051 | int yMin = v/mGridSpacingY; | 2047 | int yMin = v/mGridSpacingY; |
2052 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2048 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2053 | 2049 | ||
2054 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2050 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2055 | 2051 | ||
2056 | if (yMin != mOldLowerScrollValue) { | 2052 | if (yMin != mOldLowerScrollValue) { |
2057 | mOldLowerScrollValue = yMin; | 2053 | mOldLowerScrollValue = yMin; |
2058 | emit lowerYChanged(yMin); | 2054 | emit lowerYChanged(yMin); |
2059 | } | 2055 | } |
2060 | if (yMax != mOldUpperScrollValue) { | 2056 | if (yMax != mOldUpperScrollValue) { |
2061 | mOldUpperScrollValue = yMax; | 2057 | mOldUpperScrollValue = yMax; |
2062 | emit upperYChanged(yMax); | 2058 | emit upperYChanged(yMax); |
2063 | } | 2059 | } |
2064 | } | 2060 | } |
2065 | 2061 | ||
2066 | void KOAgenda::deselectItem() | 2062 | void KOAgenda::deselectItem() |
2067 | { | 2063 | { |
2068 | if (mSelectedItem.isNull()) return; | 2064 | if (mSelectedItem.isNull()) return; |
2069 | mSelectedItem->select(false); | 2065 | mSelectedItem->select(false); |
2070 | mSelectedItem = 0; | 2066 | mSelectedItem = 0; |
2071 | } | 2067 | } |
2072 | 2068 | ||
2073 | void KOAgenda::selectItem(KOAgendaItem *item) | 2069 | void KOAgenda::selectItem(KOAgendaItem *item) |
2074 | { | 2070 | { |
2075 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2071 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2076 | deselectItem(); | 2072 | deselectItem(); |
2077 | if (item == 0) { | 2073 | if (item == 0) { |
2078 | emit incidenceSelected( 0 ); | 2074 | emit incidenceSelected( 0 ); |
2079 | return; | 2075 | return; |
2080 | } | 2076 | } |
2081 | mSelectedItem = item; | 2077 | mSelectedItem = item; |
2082 | mSelectedItem->select(); | 2078 | mSelectedItem->select(); |
2083 | emit incidenceSelected( mSelectedItem->incidence() ); | 2079 | emit incidenceSelected( mSelectedItem->incidence() ); |
2084 | } | 2080 | } |
2085 | 2081 | ||
2086 | // This function seems never be called. | 2082 | // This function seems never be called. |
2087 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2083 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2088 | { | 2084 | { |
2089 | switch(kev->key()) { | 2085 | switch(kev->key()) { |
2090 | case Key_PageDown: | 2086 | case Key_PageDown: |
2091 | verticalScrollBar()->addPage(); | 2087 | verticalScrollBar()->addPage(); |
2092 | break; | 2088 | break; |
2093 | case Key_PageUp: | 2089 | case Key_PageUp: |
2094 | verticalScrollBar()->subtractPage(); | 2090 | verticalScrollBar()->subtractPage(); |
2095 | break; | 2091 | break; |
2096 | case Key_Down: | 2092 | case Key_Down: |
2097 | verticalScrollBar()->addLine(); | 2093 | verticalScrollBar()->addLine(); |
2098 | break; | 2094 | break; |
2099 | case Key_Up: | 2095 | case Key_Up: |
2100 | verticalScrollBar()->subtractLine(); | 2096 | verticalScrollBar()->subtractLine(); |
2101 | break; | 2097 | break; |
2102 | default: | 2098 | default: |
2103 | ; | 2099 | ; |
2104 | } | 2100 | } |
2105 | } | 2101 | } |
2106 | 2102 | ||
2107 | void KOAgenda::calculateWorkingHours() | 2103 | void KOAgenda::calculateWorkingHours() |
2108 | { | 2104 | { |
2109 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2105 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2110 | mWorkingHoursEnable = !mAllDayMode; | 2106 | mWorkingHoursEnable = !mAllDayMode; |
2111 | 2107 | ||
2112 | mWorkingHoursYTop = mGridSpacingY * | 2108 | mWorkingHoursYTop = mGridSpacingY * |
2113 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2109 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2114 | mWorkingHoursYBottom = mGridSpacingY * | 2110 | mWorkingHoursYBottom = mGridSpacingY * |
2115 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2111 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2116 | } | 2112 | } |
2117 | 2113 | ||
2118 | 2114 | ||
2119 | DateList KOAgenda::dateList() const | 2115 | DateList KOAgenda::dateList() const |
2120 | { | 2116 | { |
2121 | return mSelectedDates; | 2117 | return mSelectedDates; |
2122 | } | 2118 | } |
2123 | 2119 | ||
2124 | void KOAgenda::setDateList(const DateList &selectedDates) | 2120 | void KOAgenda::setDateList(const DateList &selectedDates) |
2125 | { | 2121 | { |
2126 | mSelectedDates = selectedDates; | 2122 | mSelectedDates = selectedDates; |
2127 | marcus_bains(); | ||
2128 | } | 2123 | } |
2129 | 2124 | ||
2130 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2125 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2131 | { | 2126 | { |
2132 | mHolidayMask = mask; | 2127 | mHolidayMask = mask; |
2133 | 2128 | ||
2134 | /* | 2129 | /* |
2135 | kdDebug() << "HolidayMask: "; | 2130 | kdDebug() << "HolidayMask: "; |
2136 | for(uint i=0;i<mask->count();++i) { | 2131 | for(uint i=0;i<mask->count();++i) { |
2137 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2132 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2138 | } | 2133 | } |
2139 | kdDebug() << endl; | 2134 | kdDebug() << endl; |
2140 | */ | 2135 | */ |
2141 | } | 2136 | } |
2142 | 2137 | ||
2143 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2138 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2144 | { | 2139 | { |
2145 | 2140 | ||
2146 | QScrollView::contentsMousePressEvent(event); | 2141 | QScrollView::contentsMousePressEvent(event); |
2147 | } | 2142 | } |
2148 | 2143 | ||
2149 | void KOAgenda::storePosition() | 2144 | void KOAgenda::storePosition() |
2150 | { | 2145 | { |
2151 | //mContentPosition | 2146 | //mContentPosition |
2152 | int max = mGridSpacingY*4*24; | 2147 | int max = mGridSpacingY*4*24; |
2153 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2148 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2154 | mContentPosition = 0; | 2149 | mContentPosition = 0; |
2155 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2150 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2156 | mContentPosition = -1.0; | 2151 | mContentPosition = -1.0; |
2157 | else | 2152 | else |
2158 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2153 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2159 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2154 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2160 | 2155 | ||
2161 | } | 2156 | } |
2162 | void KOAgenda::restorePosition() | 2157 | void KOAgenda::restorePosition() |
2163 | { | 2158 | { |
2164 | int posY; | 2159 | int posY; |
2165 | int max = mGridSpacingY*4*24; | 2160 | int max = mGridSpacingY*4*24; |
2166 | if ( mContentPosition < 0 ) | 2161 | if ( mContentPosition < 0 ) |
2167 | posY = max-viewport()->height(); | 2162 | posY = max-viewport()->height(); |
2168 | else | 2163 | else |
2169 | if ( mContentPosition == 0 ) | 2164 | if ( mContentPosition == 0 ) |
2170 | posY = 0; | 2165 | posY = 0; |
2171 | else | 2166 | else |
2172 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2167 | posY = (max/mContentPosition)-(viewport()->height()/2); |
2173 | setContentsPos (0, posY ); | 2168 | setContentsPos (0, posY ); |
2174 | //qDebug("posY %d hei %d", posY, max); | 2169 | //qDebug("posY %d hei %d", posY, max); |
2175 | 2170 | ||
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1b21a71..ef5c4dd 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -31,97 +31,97 @@ | |||
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | #define IDLETIMEOUT 15 | 79 | #define IDLETIMEOUT 45 |
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | myPix.resize( 1, 1 ); | 84 | myPix.resize( 1, 1 ); |
85 | mRows = rows; | 85 | mRows = rows; |
86 | 86 | ||
87 | mRedrawNeeded = true; | 87 | mRedrawNeeded = true; |
88 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
89 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
90 | 90 | ||
91 | enableClipper(true); | 91 | enableClipper(true); |
92 | 92 | ||
93 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
94 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
95 | 95 | ||
96 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
97 | 97 | ||
98 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void TimeLabels::setCellHeight(int height) | 101 | void TimeLabels::setCellHeight(int height) |
102 | { | 102 | { |
103 | mCellHeight = height; | 103 | mCellHeight = height; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | Optimization so that only the "dirty" portion of the scroll view | 107 | Optimization so that only the "dirty" portion of the scroll view |
108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | cx = contentsX() + frameWidth()*2; | 113 | cx = contentsX() + frameWidth()*2; |
114 | cw = contentsWidth() ; | 114 | cw = contentsWidth() ; |
115 | // end of workaround | 115 | // end of workaround |
116 | 116 | ||
117 | int cell = ((int)(cy/mCellHeight)); | 117 | int cell = ((int)(cy/mCellHeight)); |
118 | int y = cell * mCellHeight; | 118 | int y = cell * mCellHeight; |
119 | QFontMetrics fm = fontMetrics(); | 119 | QFontMetrics fm = fontMetrics(); |
120 | QString hour; | 120 | QString hour; |
121 | QString suffix = "am"; | 121 | QString suffix = "am"; |
122 | int timeHeight = fm.ascent(); | 122 | int timeHeight = fm.ascent(); |
123 | QFont nFont = font(); | 123 | QFont nFont = font(); |
124 | p->setFont( font()); | 124 | p->setFont( font()); |
125 | 125 | ||
126 | if (!KGlobal::locale()->use12Clock()) { | 126 | if (!KGlobal::locale()->use12Clock()) { |
127 | suffix = "00"; | 127 | suffix = "00"; |
@@ -528,129 +528,132 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
528 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 528 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
529 | SIGNAL(editIncidenceSignal(Incidence *))); | 529 | SIGNAL(editIncidenceSignal(Incidence *))); |
530 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 530 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
531 | SIGNAL(showIncidenceSignal(Incidence *))); | 531 | SIGNAL(showIncidenceSignal(Incidence *))); |
532 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 532 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
533 | SIGNAL(showIncidenceSignal(Incidence *))); | 533 | SIGNAL(showIncidenceSignal(Incidence *))); |
534 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 534 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
535 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 535 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
536 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 536 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
537 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 537 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
538 | 538 | ||
539 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 539 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
540 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 540 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
541 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 541 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
542 | SLOT(updateEventDates(KOAgendaItem *, int))); | 542 | SLOT(updateEventDates(KOAgendaItem *, int))); |
543 | 543 | ||
544 | // event indicator update | 544 | // event indicator update |
545 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 545 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
546 | SLOT(updateEventIndicatorTop(int))); | 546 | SLOT(updateEventIndicatorTop(int))); |
547 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 547 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
548 | SLOT(updateEventIndicatorBottom(int))); | 548 | SLOT(updateEventIndicatorBottom(int))); |
549 | // drag signals | 549 | // drag signals |
550 | /* | 550 | /* |
551 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 551 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
552 | SLOT(startDrag(Event *))); | 552 | SLOT(startDrag(Event *))); |
553 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 553 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
554 | SLOT(startDrag(Event *))); | 554 | SLOT(startDrag(Event *))); |
555 | */ | 555 | */ |
556 | // synchronize selections | 556 | // synchronize selections |
557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
558 | mAllDayAgenda, SLOT( deselectItem() ) ); | 558 | mAllDayAgenda, SLOT( deselectItem() ) ); |
559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
560 | mAgenda, SLOT( deselectItem() ) ); | 560 | mAgenda, SLOT( deselectItem() ) ); |
561 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 561 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
562 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 562 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
563 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 563 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
564 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 564 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
565 | connect( mAgenda, SIGNAL( resizedSignal() ), | 565 | connect( mAgenda, SIGNAL( resizedSignal() ), |
566 | SLOT( updateConfig( ) ) ); | 566 | SLOT( updateConfig( ) ) ); |
567 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 567 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
568 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 568 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
569 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 569 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
570 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 570 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
571 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 571 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
572 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 572 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
573 | 573 | ||
574 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); | 574 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); |
575 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); | 575 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); |
576 | #ifndef DESKTOP_VERSION | ||
576 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); | 577 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); |
577 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); | 578 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); |
578 | |||
579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); | 579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); |
580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); | 580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); |
581 | |||
582 | |||
583 | mIdleTimer = new QTimer ( this );; | 581 | mIdleTimer = new QTimer ( this );; |
584 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); | 582 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); |
583 | #endif | ||
585 | } | 584 | } |
586 | void KOAgendaView::startIdleTimeout() | 585 | void KOAgendaView::startIdleTimeout() |
587 | { | 586 | { |
587 | #ifndef DESKTOP_VERSION | ||
588 | mIdleStart = QDateTime::currentDateTime(); | 588 | mIdleStart = QDateTime::currentDateTime(); |
589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); | 589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); |
590 | #endif | ||
590 | } | 591 | } |
591 | void KOAgendaView::slotIdleTimeout() | 592 | void KOAgendaView::slotIdleTimeout() |
592 | { | 593 | { |
593 | qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); | 594 | #ifndef DESKTOP_VERSION |
595 | //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); | ||
594 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); | 596 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); |
595 | mIdleTimer->stop(); | 597 | mIdleTimer->stop(); |
596 | bool isActice = topLevelWidget()->isActiveWindow(); | 598 | bool isActice = topLevelWidget()->isActiveWindow(); |
597 | qDebug("KO: Active Window %d %d", isActice, isVisible()); | 599 | //qDebug("KO: Active Window %d %d", isActice, isVisible()); |
598 | // we do nothing if we wake up from a suspend | 600 | // we do nothing if we wake up from a suspend |
599 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { | 601 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { |
600 | qDebug("KO: Wakeup from suspend "); | 602 | qDebug("KO: Wakeup from suspend "); |
601 | startIdleTimeout(); | 603 | startIdleTimeout(); |
602 | return; | 604 | return; |
603 | } | 605 | } |
604 | qDebug("KO: Downsizing Pixmaps "); | 606 | qDebug("KO: Downsizing Pixmaps "); |
605 | mAgenda->shrinkPixmap(); | 607 | mAgenda->shrinkPixmap(); |
606 | mAllDayAgenda->shrinkPixmap(); | 608 | mAllDayAgenda->shrinkPixmap(); |
607 | KOAgendaItem::paintPix()->resize( 20,20); | 609 | KOAgendaItem::paintPix()->resize( 20,20); |
608 | KOAgendaItem::paintPixAllday()->resize( 20,20); | 610 | KOAgendaItem::paintPixAllday()->resize( 20,20); |
611 | #endif | ||
609 | 612 | ||
610 | } | 613 | } |
611 | void KOAgendaView::toggleAllDay() | 614 | void KOAgendaView::toggleAllDay() |
612 | { | 615 | { |
613 | if ( mSplitterAgenda->firstHandle() ) | 616 | if ( mSplitterAgenda->firstHandle() ) |
614 | mSplitterAgenda->firstHandle()->toggle(); | 617 | mSplitterAgenda->firstHandle()->toggle(); |
615 | } | 618 | } |
616 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 619 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
617 | { | 620 | { |
618 | calendar()->addIncidence( inc ); | 621 | calendar()->addIncidence( inc ); |
619 | 622 | ||
620 | if ( incOld ) { | 623 | if ( incOld ) { |
621 | if ( incOld->typeID() == todoID ) | 624 | if ( incOld->typeID() == todoID ) |
622 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 625 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
623 | else | 626 | else |
624 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 627 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
625 | } | 628 | } |
626 | 629 | ||
627 | } | 630 | } |
628 | void KOAgendaView::categoryChanged(Incidence * inc) | 631 | void KOAgendaView::categoryChanged(Incidence * inc) |
629 | { | 632 | { |
630 | mAgenda->categoryChanged( inc ); | 633 | mAgenda->categoryChanged( inc ); |
631 | mAllDayAgenda->categoryChanged( inc ); | 634 | mAllDayAgenda->categoryChanged( inc ); |
632 | } | 635 | } |
633 | KOAgendaView::~KOAgendaView() | 636 | KOAgendaView::~KOAgendaView() |
634 | { | 637 | { |
635 | delete mAllAgendaPopup; | 638 | delete mAllAgendaPopup; |
636 | //delete mAllDayAgendaPopup; | 639 | //delete mAllDayAgendaPopup; |
637 | delete KOAgendaItem::paintPix(); | 640 | delete KOAgendaItem::paintPix(); |
638 | delete KOAgendaItem::paintPixAllday(); | 641 | delete KOAgendaItem::paintPixAllday(); |
639 | } | 642 | } |
640 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 643 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
641 | { | 644 | { |
642 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 645 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
643 | bool uc = false; | 646 | bool uc = false; |
644 | int ow = e->oldSize().width(); | 647 | int ow = e->oldSize().width(); |
645 | int oh = e->oldSize().height(); | 648 | int oh = e->oldSize().height(); |
646 | int w = e->size().width(); | 649 | int w = e->size().width(); |
647 | int h = e->size().height(); | 650 | int h = e->size().height(); |
648 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 651 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
649 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 652 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
650 | uc = true; | 653 | uc = true; |
651 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 654 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
652 | } | 655 | } |
653 | mUpcomingWidth = e->size().width() ; | 656 | mUpcomingWidth = e->size().width() ; |
654 | if ( mBlockUpdating || uc ) { | 657 | if ( mBlockUpdating || uc ) { |
655 | mBlockUpdating = false; | 658 | mBlockUpdating = false; |
656 | //mAgenda->setMinimumSize(800 , 600 ); | 659 | //mAgenda->setMinimumSize(800 , 600 ); |
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index ff80afc..7ce3f1f 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -1,87 +1,88 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <libkcal/calfilter.h> | 34 | #include <libkcal/calfilter.h> |
35 | 35 | ||
36 | #include "kofilterview.h" | 36 | #include "kofilterview.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <kglobalsettings.h> | ||
40 | #include <kcolorbutton.h> | 41 | #include <kcolorbutton.h> |
41 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
42 | 43 | ||
43 | 44 | ||
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 48 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
48 | const char* name,WFlags fl ) | 49 | const char* name,WFlags fl ) |
49 | : KOFilterView_base(parent,name,fl) | 50 | : KOFilterView_base(parent,name,fl) |
50 | { | 51 | { |
51 | mFilters = filterList; | 52 | mFilters = filterList; |
52 | 53 | ||
53 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 54 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
54 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 55 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
55 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 56 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
56 | } | 57 | } |
57 | 58 | ||
58 | KOFilterView::~KOFilterView() | 59 | KOFilterView::~KOFilterView() |
59 | { | 60 | { |
60 | // no need to delete child widgets, Qt does it all for us | 61 | // no need to delete child widgets, Qt does it all for us |
61 | } | 62 | } |
62 | 63 | ||
63 | bool KOFilterView::filtersEnabled() | 64 | bool KOFilterView::filtersEnabled() |
64 | { | 65 | { |
65 | return mEnabledCheck->isChecked(); | 66 | return mEnabledCheck->isChecked(); |
66 | } | 67 | } |
67 | 68 | ||
68 | void KOFilterView::setFiltersEnabled(bool set) | 69 | void KOFilterView::setFiltersEnabled(bool set) |
69 | { | 70 | { |
70 | mEnabledCheck->setChecked(set); | 71 | mEnabledCheck->setChecked(set); |
71 | emit filterChanged(); | 72 | emit filterChanged(); |
72 | } | 73 | } |
73 | 74 | ||
74 | 75 | ||
75 | void KOFilterView::updateFilters() | 76 | void KOFilterView::updateFilters() |
76 | { | 77 | { |
77 | mSelectionCombo->clear(); | 78 | mSelectionCombo->clear(); |
78 | 79 | ||
79 | CalFilter *filter = mFilters->first(); | 80 | CalFilter *filter = mFilters->first(); |
80 | while(filter) { | 81 | while(filter) { |
81 | mSelectionCombo->insertItem(filter->name()); | 82 | mSelectionCombo->insertItem(filter->name()); |
82 | filter = mFilters->next(); | 83 | filter = mFilters->next(); |
83 | } | 84 | } |
84 | } | 85 | } |
85 | 86 | ||
86 | CalFilter *KOFilterView::selectedFilter() | 87 | CalFilter *KOFilterView::selectedFilter() |
87 | { | 88 | { |
@@ -353,113 +354,129 @@ void KOCalEditView::readConfig() | |||
353 | findNewStandard(); | 354 | findNewStandard(); |
354 | lab = new QLabel ( "", mw ); | 355 | lab = new QLabel ( "", mw ); |
355 | mainLayout->addWidget( lab,row,0 ); | 356 | mainLayout->addWidget( lab,row,0 ); |
356 | mw->show(); | 357 | mw->show(); |
357 | 358 | ||
358 | } | 359 | } |
359 | 360 | ||
360 | void KOCalEditView::defaultInfo() | 361 | void KOCalEditView::defaultInfo() |
361 | { | 362 | { |
362 | KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); | 363 | KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); |
363 | } | 364 | } |
364 | void KOCalEditView::addCal() | 365 | void KOCalEditView::addCal() |
365 | { | 366 | { |
366 | bool tryagain = true; | 367 | bool tryagain = true; |
367 | QString name, file; | 368 | QString name, file; |
368 | while ( tryagain ) { | 369 | while ( tryagain ) { |
369 | KONewCalPrefs prefs ( this ); | 370 | KONewCalPrefs prefs ( this ); |
370 | prefs.nameE->setText( name ); | 371 | prefs.nameE->setText( name ); |
371 | prefs.url->setURL( file ); | 372 | prefs.url->setURL( file ); |
372 | if ( ! prefs.exec() ) | 373 | if ( ! prefs.exec() ) |
373 | return; | 374 | return; |
374 | name = prefs.calName(); | 375 | name = prefs.calName(); |
375 | file = prefs.calFileName(); | 376 | file = prefs.calFileName(); |
376 | tryagain = false; | 377 | tryagain = false; |
377 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 378 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
378 | while ( kkf ) { | 379 | while ( kkf ) { |
379 | if ( kkf->mName == name ) { | 380 | if ( kkf->mName == name ) { |
380 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); | 381 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); |
381 | name = ""; | 382 | name = ""; |
382 | tryagain = true; | 383 | tryagain = true; |
383 | break; | 384 | break; |
384 | } | 385 | } |
385 | if ( kkf->mFileName == file ) { | 386 | if ( kkf->mFileName == file ) { |
386 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); | 387 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); |
387 | tryagain = true; | 388 | tryagain = true; |
388 | file = ""; | 389 | file = ""; |
389 | break; | 390 | break; |
390 | } | 391 | } |
391 | kkf = KOPrefs::instance()->mCalendars.next(); | 392 | kkf = KOPrefs::instance()->mCalendars.next(); |
392 | } | 393 | } |
393 | } | 394 | } |
394 | addCalendar ( name, file ); | 395 | addCalendar ( name, file ); |
395 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 396 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
396 | } | 397 | } |
397 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) | 398 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) |
398 | { | 399 | { |
399 | 400 | ||
400 | QFileInfo fi ( file ); | 401 | QFileInfo fi ( file ); |
402 | QString absFile = file; | ||
403 | bool isRelative = false; | ||
404 | if ( fi.isRelative() ) { | ||
405 | isRelative = true; | ||
406 | absFile = KGlobalSettings::calendarDir()+file; | ||
407 | fi.setFile( absFile ); | ||
408 | } else { | ||
409 | QString cd = KGlobalSettings::calendarDir(); | ||
410 | if ( file.left( cd.length() ) == cd ) { | ||
411 | isRelative = true; | ||
412 | file = fi.fileName (); | ||
413 | fi.setFile( absFile ); | ||
414 | } | ||
415 | } | ||
401 | if (!fi.exists() ) { | 416 | if (!fi.exists() ) { |
402 | if ( ask ) | 417 | if ( ask ) |
403 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) | 418 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) |
404 | return 0; | 419 | return 0; |
405 | QFile fileIn( file ); | 420 | QFile fileIn( absFile ); |
406 | if (!fileIn.open( IO_WriteOnly ) ) { | 421 | if (!fileIn.open( IO_WriteOnly ) ) { |
407 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); | 422 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); |
408 | return 0; | 423 | return 0; |
409 | } | 424 | } |
410 | QTextStream tsIn( &fileIn ); | 425 | QTextStream tsIn( &fileIn ); |
411 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 426 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
412 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; | 427 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; |
413 | fileIn.close(); | 428 | fileIn.close(); |
414 | } | 429 | } |
415 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 430 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
416 | kkf->mName = name; | 431 | kkf->mName = name; |
417 | kkf->mFileName = file; | 432 | kkf->mFileName = absFile; |
433 | kkf->mSavedFileName = file; | ||
434 | kkf->isRelative = isRelative; | ||
418 | emit calendarAdded( kkf->mCalNumber ); | 435 | emit calendarAdded( kkf->mCalNumber ); |
419 | if ( ask ) | 436 | if ( ask ) |
420 | emit needsUpdate(); | 437 | emit needsUpdate(); |
421 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 438 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
422 | return kkf->mCalNumber; | 439 | return kkf->mCalNumber; |
423 | } | 440 | } |
424 | int KOCalEditView::getBirtdayID() | 441 | int KOCalEditView::getBirtdayID() |
425 | { | 442 | { |
426 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 443 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
427 | while ( kkf ) { | 444 | while ( kkf ) { |
428 | if ( kkf->mName == i18n("Birthdays") ) | 445 | if ( kkf->mName == i18n("Birthdays") ) |
429 | return kkf->mCalNumber; | 446 | return kkf->mCalNumber; |
430 | kkf = KOPrefs::instance()->mCalendars.next(); | 447 | kkf = KOPrefs::instance()->mCalendars.next(); |
431 | } | 448 | } |
432 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); | 449 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); |
433 | return addCalendar( i18n("Birthdays"), file, false ); | 450 | return addCalendar( i18n("Birthdays"), file, false ); |
434 | } | 451 | } |
435 | 452 | ||
436 | void KOCalEditView::enableAll() | 453 | void KOCalEditView::enableAll() |
437 | { | 454 | { |
438 | toggleList( mEnabledB ); | 455 | toggleList( mEnabledB ); |
439 | } | 456 | } |
440 | void KOCalEditView::enableAlarm() | 457 | void KOCalEditView::enableAlarm() |
441 | { | 458 | { |
442 | toggleList( mAlarmB ); | 459 | toggleList( mAlarmB ); |
443 | } | 460 | } |
444 | void KOCalEditView::disableRO() | 461 | void KOCalEditView::disableRO() |
445 | { | 462 | { |
446 | toggleList( mROB, false ); | 463 | toggleList( mROB, false ); |
447 | } | 464 | } |
448 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) | 465 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) |
449 | { | 466 | { |
450 | bool dis = !enable; | 467 | bool dis = !enable; |
451 | KOCalCheckButton* it = list.first(); | 468 | KOCalCheckButton* it = list.first(); |
452 | while ( it ) { | 469 | while ( it ) { |
453 | if ( !it->isChecked() == enable && it->isEnabled() ) { | 470 | if ( !it->isChecked() == enable && it->isEnabled() ) { |
454 | dis = !dis; | 471 | dis = !dis; |
455 | break; | 472 | break; |
456 | } | 473 | } |
457 | it = list.next(); | 474 | it = list.next(); |
458 | } | 475 | } |
459 | it = list.first(); | 476 | it = list.first(); |
460 | while ( it ) { | 477 | while ( it ) { |
461 | if ( it->isEnabled() ) | 478 | if ( it->isEnabled() ) |
462 | it->setChecked(dis); | 479 | it->setChecked(dis); |
463 | it = list.next(); | 480 | it = list.next(); |
464 | } | 481 | } |
465 | } | 482 | } |
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h index 4322299..be7b5b6 100644 --- a/korganizer/kofilterview.h +++ b/korganizer/kofilterview.h | |||
@@ -44,96 +44,97 @@ | |||
44 | 44 | ||
45 | class QGridLayout; | 45 | class QGridLayout; |
46 | 46 | ||
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | class KONewCalPrefs : public QDialog | 49 | class KONewCalPrefs : public QDialog |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : | 53 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : |
54 | QDialog( parent, name, true ) | 54 | QDialog( parent, name, true ) |
55 | { | 55 | { |
56 | setCaption( i18n("Add new Calendar") ); | 56 | setCaption( i18n("Add new Calendar") ); |
57 | QVBoxLayout* lay = new QVBoxLayout( this ); | 57 | QVBoxLayout* lay = new QVBoxLayout( this ); |
58 | lay->setSpacing( 3 ); | 58 | lay->setSpacing( 3 ); |
59 | lay->setMargin( 3 ); | 59 | lay->setMargin( 3 ); |
60 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); | 60 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); |
61 | lay->addWidget( lab ); | 61 | lay->addWidget( lab ); |
62 | nameE = new KLineEdit( this ); | 62 | nameE = new KLineEdit( this ); |
63 | lay->addWidget( nameE ); | 63 | lay->addWidget( nameE ); |
64 | lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); | 64 | lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); |
65 | lay->addWidget( lab ); | 65 | lay->addWidget( lab ); |
66 | url = new KURLRequester ( this ); | 66 | url = new KURLRequester ( this ); |
67 | lay->addWidget( url ); | 67 | lay->addWidget( url ); |
68 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 68 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
69 | lay->addWidget( ok ); | 69 | lay->addWidget( ok ); |
70 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 70 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
71 | lay->addWidget( cancel ); | 71 | lay->addWidget( cancel ); |
72 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); | 72 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); |
73 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 73 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
74 | int minwid = 220; | 74 | int minwid = 220; |
75 | if ( QApplication::desktop()->width() >= 320 ) minwid = 300; | 75 | if ( QApplication::desktop()->width() >= 320 ) minwid = 300; |
76 | setMinimumWidth( minwid ); | 76 | setMinimumWidth( minwid ); |
77 | resize(sizeHint() ); | 77 | resize(sizeHint() ); |
78 | } | 78 | } |
79 | 79 | ||
80 | QString calName() { return nameE->text(); } | 80 | QString calName() { return nameE->text(); } |
81 | QString calFileName() { return url->url(); } | 81 | QString calFileName() { return url->url(); } |
82 | 82 | ||
83 | public slots: | 83 | public slots: |
84 | void checkValid() { | 84 | void checkValid() { |
85 | if ( nameE->text().isEmpty() ) { | 85 | if ( nameE->text().isEmpty() ) { |
86 | KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); | 86 | KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); |
87 | nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); | 87 | nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); |
88 | return; | 88 | return; |
89 | } | 89 | } |
90 | if ( url->url().isEmpty() ) { | 90 | if ( url->url().isEmpty() ) { |
91 | KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); | 91 | KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); |
92 | url->setURL( nameE->text() + ".ics" ); | ||
92 | return; | 93 | return; |
93 | } | 94 | } |
94 | accept(); | 95 | accept(); |
95 | } | 96 | } |
96 | 97 | ||
97 | public: | 98 | public: |
98 | KLineEdit* nameE; | 99 | KLineEdit* nameE; |
99 | KURLRequester *url; | 100 | KURLRequester *url; |
100 | }; | 101 | }; |
101 | 102 | ||
102 | class KOCalButton : public QPushButton | 103 | class KOCalButton : public QPushButton |
103 | { | 104 | { |
104 | Q_OBJECT | 105 | Q_OBJECT |
105 | public: | 106 | public: |
106 | KOCalButton( QWidget *parent=0, const char *name=0 ) : | 107 | KOCalButton( QWidget *parent=0, const char *name=0 ) : |
107 | QPushButton( parent, name) | 108 | QPushButton( parent, name) |
108 | { | 109 | { |
109 | connect( this, SIGNAL( clicked() ), | 110 | connect( this, SIGNAL( clicked() ), |
110 | SLOT( bottonClicked() )); | 111 | SLOT( bottonClicked() )); |
111 | mNumber = -1; | 112 | mNumber = -1; |
112 | setFocusPolicy(NoFocus); | 113 | setFocusPolicy(NoFocus); |
113 | } | 114 | } |
114 | void setNum ( int num ) {mNumber = num; } | 115 | void setNum ( int num ) {mNumber = num; } |
115 | signals: | 116 | signals: |
116 | void selectNum ( int ); | 117 | void selectNum ( int ); |
117 | private: | 118 | private: |
118 | int mNumber; | 119 | int mNumber; |
119 | void keyPressEvent ( QKeyEvent * e ) | 120 | void keyPressEvent ( QKeyEvent * e ) |
120 | { | 121 | { |
121 | e->ignore(); | 122 | e->ignore(); |
122 | } | 123 | } |
123 | 124 | ||
124 | private slots : | 125 | private slots : |
125 | void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } | 126 | void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } |
126 | }; | 127 | }; |
127 | class KOCalCheckButton : public QCheckBox | 128 | class KOCalCheckButton : public QCheckBox |
128 | { | 129 | { |
129 | Q_OBJECT | 130 | Q_OBJECT |
130 | public: | 131 | public: |
131 | KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : | 132 | KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : |
132 | QCheckBox( parent, name) | 133 | QCheckBox( parent, name) |
133 | { | 134 | { |
134 | connect( this, SIGNAL( toggled ( bool ) ), | 135 | connect( this, SIGNAL( toggled ( bool ) ), |
135 | SLOT( bottonClicked( bool ) )); | 136 | SLOT( bottonClicked( bool ) )); |
136 | mNumber = -1; | 137 | mNumber = -1; |
137 | setFocusPolicy(NoFocus); | 138 | setFocusPolicy(NoFocus); |
138 | //setMaximumWidth( 10 ); | 139 | //setMaximumWidth( 10 ); |
139 | 140 | ||
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index a886735..f1f1442 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -409,196 +409,202 @@ QStringList KOPrefs::getDefaultList() | |||
409 | void KOPrefs::usrReadConfig() | 409 | void KOPrefs::usrReadConfig() |
410 | { | 410 | { |
411 | config()->setGroup("General"); | 411 | config()->setGroup("General"); |
412 | 412 | ||
413 | //qDebug("KOPrefs::usrReadConfig() "); | 413 | //qDebug("KOPrefs::usrReadConfig() "); |
414 | mCustomCategories = config()->readListEntry("Custom Categories"); | 414 | mCustomCategories = config()->readListEntry("Custom Categories"); |
415 | mOldLoadedLanguage = mOldLanguage ; | 415 | mOldLoadedLanguage = mOldLanguage ; |
416 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 416 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
417 | if (mLocationDefaults.isEmpty()) { | 417 | if (mLocationDefaults.isEmpty()) { |
418 | mLocationDefaults = getLocationDefaultList(); | 418 | mLocationDefaults = getLocationDefaultList(); |
419 | } | 419 | } |
420 | 420 | ||
421 | if (mEventSummaryUser.isEmpty()) { | 421 | if (mEventSummaryUser.isEmpty()) { |
422 | mEventSummaryUser = getDefaultList() ; | 422 | mEventSummaryUser = getDefaultList() ; |
423 | } | 423 | } |
424 | if (mTodoSummaryUser.isEmpty()) { | 424 | if (mTodoSummaryUser.isEmpty()) { |
425 | mTodoSummaryUser = getDefaultList() ; | 425 | mTodoSummaryUser = getDefaultList() ; |
426 | } | 426 | } |
427 | 427 | ||
428 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 428 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
429 | 429 | ||
430 | config()->setGroup("Personal Settings"); | 430 | config()->setGroup("Personal Settings"); |
431 | mName = config()->readEntry("user_name",""); | 431 | mName = config()->readEntry("user_name",""); |
432 | mEmail = config()->readEntry("user_email",""); | 432 | mEmail = config()->readEntry("user_email",""); |
433 | fillMailDefaults(); | 433 | fillMailDefaults(); |
434 | 434 | ||
435 | config()->setGroup("Category Colors"); | 435 | config()->setGroup("Category Colors"); |
436 | QStringList::Iterator it; | 436 | QStringList::Iterator it; |
437 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 437 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
438 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 438 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
439 | 439 | ||
440 | } | 440 | } |
441 | KConfig fc (locateLocal("config","kopicalendarrc")); | 441 | KConfig fc (locateLocal("config","kopicalendarrc")); |
442 | fc.setGroup("CC"); | 442 | fc.setGroup("CC"); |
443 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 443 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
444 | mNextAvailableCalendar = 1; | 444 | mNextAvailableCalendar = 1; |
445 | if ( numCals == 0 ) { | 445 | if ( numCals == 0 ) { |
446 | KopiCalendarFile *kkf = getNewCalendar(); | 446 | KopiCalendarFile *kkf = getNewCalendar(); |
447 | kkf->isStandard = true; | 447 | kkf->isStandard = true; |
448 | kkf->mName = i18n("Standard"); | 448 | kkf->mName = i18n("Standard"); |
449 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 449 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
450 | } | 450 | } |
451 | while ( mNextAvailableCalendar <= numCals ) { | 451 | while ( mNextAvailableCalendar <= numCals ) { |
452 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); | 452 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); |
453 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | 453 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); |
454 | KopiCalendarFile *kkf = getNewCalendar(); | 454 | KopiCalendarFile *kkf = getNewCalendar(); |
455 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); | 455 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); |
456 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); | 456 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); |
457 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); | ||
457 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); | 458 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); |
458 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); | 459 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); |
459 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); | 460 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); |
460 | kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); | 461 | kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); |
462 | kkf->mSavedFileName = fc.readEntry( prefix+"_SavedFileName", kkf->mFileName); | ||
461 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 463 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
462 | if ( kkf->mCalNumber == 1 ) { | 464 | if ( kkf->mCalNumber == 1 ) { |
463 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 465 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
464 | } | 466 | } |
465 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 467 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
466 | if ( kkf->mName == i18n("Birthdays") ) { | 468 | if ( kkf->mName == i18n("Birthdays") ) { |
467 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 469 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
468 | } | 470 | } |
471 | if ( kkf->isRelative ) | ||
472 | kkf->mFileName = KGlobalSettings::calendarDir() + kkf->mSavedFileName; | ||
469 | } | 473 | } |
470 | 474 | ||
471 | KPimPrefs::usrReadConfig(); | 475 | KPimPrefs::usrReadConfig(); |
472 | } | 476 | } |
473 | 477 | ||
474 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 478 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
475 | { | 479 | { |
476 | return mDefCalColors[num-1]; | 480 | return mDefCalColors[num-1]; |
477 | } | 481 | } |
478 | 482 | ||
479 | KopiCalendarFile * KOPrefs::getNewCalendar() | 483 | KopiCalendarFile * KOPrefs::getNewCalendar() |
480 | { | 484 | { |
481 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 485 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
482 | kkf->mCalNumber = mNextAvailableCalendar; | 486 | kkf->mCalNumber = mNextAvailableCalendar; |
483 | mDefCalColors.resize( mNextAvailableCalendar ); | 487 | mDefCalColors.resize( mNextAvailableCalendar ); |
484 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 488 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
485 | ++mNextAvailableCalendar; | 489 | ++mNextAvailableCalendar; |
486 | kkf->mDefaultColor = mEventColor; | 490 | kkf->mDefaultColor = mEventColor; |
487 | kkf->mName = i18n("New Calendar"); | 491 | kkf->mName = i18n("New Calendar"); |
488 | mCalendars.append( kkf ); | 492 | mCalendars.append( kkf ); |
489 | return kkf; | 493 | return kkf; |
490 | } | 494 | } |
491 | void KOPrefs::deleteCalendar( int num ) | 495 | void KOPrefs::deleteCalendar( int num ) |
492 | { | 496 | { |
493 | KopiCalendarFile * kkf = mCalendars.first(); | 497 | KopiCalendarFile * kkf = mCalendars.first(); |
494 | while ( kkf ) { | 498 | while ( kkf ) { |
495 | if ( kkf->mCalNumber == num ) { | 499 | if ( kkf->mCalNumber == num ) { |
496 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 500 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
497 | mCalendars.remove( kkf ); | 501 | mCalendars.remove( kkf ); |
498 | delete kkf; | 502 | delete kkf; |
499 | return; | 503 | return; |
500 | } | 504 | } |
501 | kkf = mCalendars.next(); | 505 | kkf = mCalendars.next(); |
502 | } | 506 | } |
503 | } | 507 | } |
504 | int KOPrefs::getCalendarID( const QString & name ) | 508 | int KOPrefs::getCalendarID( const QString & name ) |
505 | { | 509 | { |
506 | KopiCalendarFile * kkf = mCalendars.first(); | 510 | KopiCalendarFile * kkf = mCalendars.first(); |
507 | while ( kkf ) { | 511 | while ( kkf ) { |
508 | if ( name == kkf->mName) | 512 | if ( name == kkf->mName) |
509 | return kkf->mCalNumber; | 513 | return kkf->mCalNumber; |
510 | kkf = mCalendars.next(); | 514 | kkf = mCalendars.next(); |
511 | } | 515 | } |
512 | return 1; | 516 | return 1; |
513 | } | 517 | } |
514 | QString KOPrefs::calName( int calNum) const | 518 | QString KOPrefs::calName( int calNum) const |
515 | { | 519 | { |
516 | return (mDefCalColors[calNum-1])->mName; | 520 | return (mDefCalColors[calNum-1])->mName; |
517 | } | 521 | } |
518 | QColor KOPrefs::defaultColor( int calNum ) const | 522 | QColor KOPrefs::defaultColor( int calNum ) const |
519 | { | 523 | { |
520 | if ( calNum == 1 ) return mEventColor; | 524 | if ( calNum == 1 ) return mEventColor; |
521 | return (mDefCalColors[calNum-1])->mDefaultColor; | 525 | return (mDefCalColors[calNum-1])->mDefaultColor; |
522 | } | 526 | } |
523 | void KOPrefs::usrWriteConfig() | 527 | void KOPrefs::usrWriteConfig() |
524 | { | 528 | { |
525 | config()->setGroup("General"); | 529 | config()->setGroup("General"); |
526 | config()->writeEntry("Custom Categories",mCustomCategories); | 530 | config()->writeEntry("Custom Categories",mCustomCategories); |
527 | 531 | ||
528 | config()->setGroup("Personal Settings"); | 532 | config()->setGroup("Personal Settings"); |
529 | config()->writeEntry("user_name",mName); | 533 | config()->writeEntry("user_name",mName); |
530 | config()->writeEntry("user_email",mEmail); | 534 | config()->writeEntry("user_email",mEmail); |
531 | 535 | ||
532 | config()->setGroup("Category Colors"); | 536 | config()->setGroup("Category Colors"); |
533 | QDictIterator<QColor> it(mCategoryColors); | 537 | QDictIterator<QColor> it(mCategoryColors); |
534 | while (it.current()) { | 538 | while (it.current()) { |
535 | config()->writeEntry(it.currentKey(),*(it.current())); | 539 | config()->writeEntry(it.currentKey(),*(it.current())); |
536 | ++it; | 540 | ++it; |
537 | } | 541 | } |
538 | KConfig fc (locateLocal("config","kopicalendarrc")); | 542 | KConfig fc (locateLocal("config","kopicalendarrc")); |
539 | fc.setGroup("CC"); | 543 | fc.setGroup("CC"); |
540 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 544 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
541 | int numCal = 1; | 545 | int numCal = 1; |
542 | int writeCal = 0; | 546 | int writeCal = 0; |
543 | while ( numCal < mNextAvailableCalendar ) { | 547 | while ( numCal < mNextAvailableCalendar ) { |
544 | KopiCalendarFile * kkf = mCalendars.first(); | 548 | KopiCalendarFile * kkf = mCalendars.first(); |
545 | while ( kkf ) { | 549 | while ( kkf ) { |
546 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 550 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
547 | if ( kkf->mCalNumber == numCal ) { | 551 | if ( kkf->mCalNumber == numCal ) { |
548 | ++writeCal; | 552 | ++writeCal; |
549 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 553 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
550 | QString prefix = "Cal_" + QString::number( writeCal ); | 554 | QString prefix = "Cal_" + QString::number( writeCal ); |
551 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 555 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
552 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 556 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
553 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 557 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
554 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 558 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
559 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | ||
555 | fc.writeEntry( prefix+"_Name", kkf->mName); | 560 | fc.writeEntry( prefix+"_Name", kkf->mName); |
556 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 561 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
562 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | ||
557 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 563 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
558 | } | 564 | } |
559 | kkf = mCalendars.next(); | 565 | kkf = mCalendars.next(); |
560 | } | 566 | } |
561 | ++numCal; | 567 | ++numCal; |
562 | } | 568 | } |
563 | fc.sync(); | 569 | fc.sync(); |
564 | KPimPrefs::usrWriteConfig(); | 570 | KPimPrefs::usrWriteConfig(); |
565 | } | 571 | } |
566 | 572 | ||
567 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 573 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
568 | { | 574 | { |
569 | mCategoryColors.replace(cat,new QColor(color)); | 575 | mCategoryColors.replace(cat,new QColor(color)); |
570 | } | 576 | } |
571 | 577 | ||
572 | QColor *KOPrefs::categoryColor(QString cat) | 578 | QColor *KOPrefs::categoryColor(QString cat) |
573 | { | 579 | { |
574 | QColor *color = 0; | 580 | QColor *color = 0; |
575 | 581 | ||
576 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 582 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
577 | 583 | ||
578 | if (color) return color; | 584 | if (color) return color; |
579 | else return &mDefaultCategoryColor; | 585 | else return &mDefaultCategoryColor; |
580 | } | 586 | } |
581 | 587 | ||
582 | void KOPrefs::setFullName(const QString &name) | 588 | void KOPrefs::setFullName(const QString &name) |
583 | { | 589 | { |
584 | mName = name; | 590 | mName = name; |
585 | } | 591 | } |
586 | 592 | ||
587 | void KOPrefs::setEmail(const QString &email) | 593 | void KOPrefs::setEmail(const QString &email) |
588 | { | 594 | { |
589 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 595 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
590 | mEmail = email; | 596 | mEmail = email; |
591 | } | 597 | } |
592 | 598 | ||
593 | QString KOPrefs::fullName() | 599 | QString KOPrefs::fullName() |
594 | { | 600 | { |
595 | if (mEmailControlCenter) { | 601 | if (mEmailControlCenter) { |
596 | KEMailSettings settings; | 602 | KEMailSettings settings; |
597 | return settings.getSetting(KEMailSettings::RealName); | 603 | return settings.getSetting(KEMailSettings::RealName); |
598 | } else { | 604 | } else { |
599 | return mName; | 605 | return mName; |
600 | } | 606 | } |
601 | } | 607 | } |
602 | 608 | ||
603 | QString KOPrefs::email() | 609 | QString KOPrefs::email() |
604 | { | 610 | { |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 7ec5327..0779e27 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -9,107 +9,111 @@ | |||
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | 31 | ||
32 | class KConfig; | 32 | class KConfig; |
33 | class QFont; | 33 | class QFont; |
34 | class QColor; | 34 | class QColor; |
35 | class QStringList; | 35 | class QStringList; |
36 | 36 | ||
37 | #define VIEW_WN_VIEW 1 | 37 | #define VIEW_WN_VIEW 1 |
38 | #define VIEW_NX_VIEW 2 | 38 | #define VIEW_NX_VIEW 2 |
39 | #define VIEW_J_VIEW 3 | 39 | #define VIEW_J_VIEW 3 |
40 | #define VIEW_A_VIEW 4 | 40 | #define VIEW_A_VIEW 4 |
41 | #define VIEW_ML_VIEW 5 | 41 | #define VIEW_ML_VIEW 5 |
42 | #define VIEW_M_VIEW 6 | 42 | #define VIEW_M_VIEW 6 |
43 | #define VIEW_L_VIEW 7 | 43 | #define VIEW_L_VIEW 7 |
44 | #define VIEW_T_VIEW 8 | 44 | #define VIEW_T_VIEW 8 |
45 | 45 | ||
46 | class KopiCalendarFile : public QObject | 46 | class KopiCalendarFile : public QObject |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KopiCalendarFile( ) : QObject( ) | 49 | KopiCalendarFile( ) : QObject( ) |
50 | { | 50 | { |
51 | isStandard = false; | 51 | isStandard = false; |
52 | isEnabled = true; | 52 | isEnabled = true; |
53 | isAlarmEnabled = true; | 53 | isAlarmEnabled = true; |
54 | isReadOnly = false; | 54 | isReadOnly = false; |
55 | mName = "Calendar"; | 55 | mName = "Calendar"; |
56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; | 56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; |
57 | mSavedFileName = "icalfile.ics"; | ||
57 | mCalNumber = 0; | 58 | mCalNumber = 0; |
58 | mDefaultColor = Qt::red; | 59 | mDefaultColor = Qt::red; |
59 | mErrorOnLoad = false; | 60 | mErrorOnLoad = false; |
61 | isRelative = false; | ||
60 | } | 62 | } |
61 | bool isStandard; | 63 | bool isStandard; |
62 | bool isEnabled; | 64 | bool isEnabled; |
63 | bool isAlarmEnabled; | 65 | bool isAlarmEnabled; |
64 | bool isReadOnly; | 66 | bool isReadOnly; |
65 | bool mErrorOnLoad; | 67 | bool mErrorOnLoad; |
66 | QString mName; | 68 | QString mName; |
67 | QString mFileName; | 69 | QString mFileName; |
70 | QString mSavedFileName; | ||
71 | bool isRelative; | ||
68 | int mCalNumber; | 72 | int mCalNumber; |
69 | QColor mDefaultColor; | 73 | QColor mDefaultColor; |
70 | QDateTime mLoadDt; | 74 | QDateTime mLoadDt; |
71 | }; | 75 | }; |
72 | class KOPrefs : public KPimPrefs | 76 | class KOPrefs : public KPimPrefs |
73 | { | 77 | { |
74 | public: | 78 | public: |
75 | enum { FormatVCalendar, FormatICalendar }; | 79 | enum { FormatVCalendar, FormatICalendar }; |
76 | enum { MailClientKMail, MailClientSendmail }; | 80 | enum { MailClientKMail, MailClientSendmail }; |
77 | enum { IMIPDummy, IMIPKMail }; | 81 | enum { IMIPDummy, IMIPKMail }; |
78 | enum { IMIPOutbox, IMIPdirectsend }; | 82 | enum { IMIPOutbox, IMIPdirectsend }; |
79 | enum { neverAuto, addressbookAuto, selectedAuto }; | 83 | enum { neverAuto, addressbookAuto, selectedAuto }; |
80 | enum { standardDestination, askDestination }; | 84 | enum { standardDestination, askDestination }; |
81 | 85 | ||
82 | virtual ~KOPrefs(); | 86 | virtual ~KOPrefs(); |
83 | 87 | ||
84 | /** Get instance of KOPrefs. It is made sure that there is only one | 88 | /** Get instance of KOPrefs. It is made sure that there is only one |
85 | instance. */ | 89 | instance. */ |
86 | static KOPrefs *instance(); | 90 | static KOPrefs *instance(); |
87 | 91 | ||
88 | /** Set preferences to default values */ | 92 | /** Set preferences to default values */ |
89 | void usrSetDefaults(); | 93 | void usrSetDefaults(); |
90 | 94 | ||
91 | /** Read preferences from config file */ | 95 | /** Read preferences from config file */ |
92 | void usrReadConfig(); | 96 | void usrReadConfig(); |
93 | 97 | ||
94 | /** Write preferences to config file */ | 98 | /** Write preferences to config file */ |
95 | void usrWriteConfig(); | 99 | void usrWriteConfig(); |
96 | void setCategoryDefaults(); | 100 | void setCategoryDefaults(); |
97 | void setAllDefaults(); | 101 | void setAllDefaults(); |
98 | KopiCalendarFile * getNewCalendar(); | 102 | KopiCalendarFile * getNewCalendar(); |
99 | KopiCalendarFile * getCalendar( int ); | 103 | KopiCalendarFile * getCalendar( int ); |
100 | void deleteCalendar( int ); | 104 | void deleteCalendar( int ); |
101 | QColor defaultColor( int ) const; | 105 | QColor defaultColor( int ) const; |
102 | QString calName( int ) const; | 106 | QString calName( int ) const; |
103 | int getCalendarID( const QString & name ); | 107 | int getCalendarID( const QString & name ); |
104 | protected: | 108 | protected: |
105 | void setTimeZoneIdDefault(); | 109 | void setTimeZoneIdDefault(); |
106 | 110 | ||
107 | /** Fill empty mail fields with default values. */ | 111 | /** Fill empty mail fields with default values. */ |
108 | void fillMailDefaults(); | 112 | void fillMailDefaults(); |
109 | 113 | ||
110 | private: | 114 | private: |
111 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 115 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
112 | object. */ | 116 | object. */ |
113 | KOPrefs(); | 117 | KOPrefs(); |
114 | 118 | ||
115 | static KOPrefs *mInstance; | 119 | static KOPrefs *mInstance; |
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp index 3f8a630..2e483e9 100644 --- a/microkde/kglobalsettings.cpp +++ b/microkde/kglobalsettings.cpp | |||
@@ -18,87 +18,96 @@ QFont KGlobalSettings::generalFont() | |||
18 | if (QApplication::desktop()->width() < 480 ) { | 18 | if (QApplication::desktop()->width() < 480 ) { |
19 | size = 10; | 19 | size = 10; |
20 | } | 20 | } |
21 | #ifndef DESKTOP_VERSION | 21 | #ifndef DESKTOP_VERSION |
22 | else | 22 | else |
23 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) | 23 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) |
24 | size = 18; | 24 | size = 18; |
25 | #endif | 25 | #endif |
26 | QFont f = QApplication::font(); | 26 | QFont f = QApplication::font(); |
27 | //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1()); | 27 | //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1()); |
28 | f.setPointSize( size ); | 28 | f.setPointSize( size ); |
29 | return f; | 29 | return f; |
30 | } | 30 | } |
31 | QFont KGlobalSettings::generalMaxFont() | 31 | QFont KGlobalSettings::generalMaxFont() |
32 | { | 32 | { |
33 | int size = 12; | 33 | int size = 12; |
34 | if (QApplication::desktop()->width() < 480 ) { | 34 | if (QApplication::desktop()->width() < 480 ) { |
35 | size = 10; | 35 | size = 10; |
36 | } | 36 | } |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | else | 38 | else |
39 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) | 39 | if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) |
40 | size = 18; | 40 | size = 18; |
41 | #endif | 41 | #endif |
42 | QFont f = QApplication::font(); | 42 | QFont f = QApplication::font(); |
43 | if ( f.pointSize() > size ) | 43 | if ( f.pointSize() > size ) |
44 | f.setPointSize( size ); | 44 | f.setPointSize( size ); |
45 | return f; | 45 | return f; |
46 | } | 46 | } |
47 | 47 | ||
48 | QString KGlobalSettings::timeTrackerDir() | 48 | QString KGlobalSettings::timeTrackerDir() |
49 | { | 49 | { |
50 | static QString dir; | 50 | static QString dir; |
51 | if ( dir.isEmpty() ) { | 51 | if ( dir.isEmpty() ) { |
52 | dir = locateLocal( "data", "timetrackerdir/d.ttl" ); | 52 | dir = locateLocal( "data", "timetrackerdir/d.ttl" ); |
53 | dir = dir.left ( dir.length() - 5); | 53 | dir = dir.left ( dir.length() - 5); |
54 | } | 54 | } |
55 | return dir; | 55 | return dir; |
56 | } | 56 | } |
57 | QString KGlobalSettings::backupDataDir() | 57 | QString KGlobalSettings::backupDataDir() |
58 | { | 58 | { |
59 | static QString dir; | 59 | static QString dir; |
60 | if ( dir.isEmpty() ) { | 60 | if ( dir.isEmpty() ) { |
61 | dir = locateLocal( "data", "backupdir/d.ttl" ); | 61 | dir = locateLocal( "data", "backupdir/d.ttl" ); |
62 | dir = dir.left ( dir.length() - 5); | 62 | dir = dir.left ( dir.length() - 5); |
63 | } | 63 | } |
64 | return dir; | 64 | return dir; |
65 | } | 65 | } |
66 | QString KGlobalSettings::calendarDir() | ||
67 | { | ||
68 | static QString dir; | ||
69 | if ( dir.isEmpty() ) { | ||
70 | dir = locateLocal( "data", "korganizer/d.ttl" ); | ||
71 | dir = dir.left ( dir.length() - 5); | ||
72 | } | ||
73 | return dir; | ||
74 | } | ||
66 | 75 | ||
67 | QFont KGlobalSettings::toolBarFont() | 76 | QFont KGlobalSettings::toolBarFont() |
68 | { | 77 | { |
69 | return QApplication::font(); | 78 | return QApplication::font(); |
70 | } | 79 | } |
71 | 80 | ||
72 | QColor KGlobalSettings::toolBarHighlightColor() | 81 | QColor KGlobalSettings::toolBarHighlightColor() |
73 | { | 82 | { |
74 | return QColor( "black" ); | 83 | return QColor( "black" ); |
75 | } | 84 | } |
76 | 85 | ||
77 | QColor KGlobalSettings::alternateBackgroundColor() | 86 | QColor KGlobalSettings::alternateBackgroundColor() |
78 | { | 87 | { |
79 | return mAlternate; | 88 | return mAlternate; |
80 | 89 | ||
81 | } | 90 | } |
82 | void KGlobalSettings::setAlternateBackgroundColor(QColor c) | 91 | void KGlobalSettings::setAlternateBackgroundColor(QColor c) |
83 | { | 92 | { |
84 | mAlternate = c; | 93 | mAlternate = c; |
85 | 94 | ||
86 | } | 95 | } |
87 | 96 | ||
88 | QRect KGlobalSettings::desktopGeometry( QWidget * ) | 97 | QRect KGlobalSettings::desktopGeometry( QWidget * ) |
89 | { | 98 | { |
90 | return QApplication::desktop()->rect(); | 99 | return QApplication::desktop()->rect(); |
91 | } | 100 | } |
92 | 101 | ||
93 | /** | 102 | /** |
94 | * Returns whether KDE runs in single (default) or double click | 103 | * Returns whether KDE runs in single (default) or double click |
95 | * mode. | 104 | * mode. |
96 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html | 105 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html |
97 | * @return true if single click mode, or false if double click mode. | 106 | * @return true if single click mode, or false if double click mode. |
98 | **/ | 107 | **/ |
99 | bool KGlobalSettings::singleClick() | 108 | bool KGlobalSettings::singleClick() |
100 | { | 109 | { |
101 | KConfig *c = KGlobal::config(); | 110 | KConfig *c = KGlobal::config(); |
102 | KConfigGroupSaver cgs( c, "KDE" ); | 111 | KConfigGroupSaver cgs( c, "KDE" ); |
103 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); | 112 | return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); |
104 | } | 113 | } |
diff --git a/microkde/kglobalsettings.h b/microkde/kglobalsettings.h index 4e4d87c..977e5b6 100644 --- a/microkde/kglobalsettings.h +++ b/microkde/kglobalsettings.h | |||
@@ -1,36 +1,37 @@ | |||
1 | #ifndef MICROKDE_KGLOBALSETTINGS_H | 1 | #ifndef MICROKDE_KGLOBALSETTINGS_H |
2 | #define MICROKDE_KGLOBALSETTINGS_H | 2 | #define MICROKDE_KGLOBALSETTINGS_H |
3 | 3 | ||
4 | #include <qfont.h> | 4 | #include <qfont.h> |
5 | #include <qrect.h> | 5 | #include <qrect.h> |
6 | 6 | ||
7 | 7 | ||
8 | #define KDE_DEFAULT_SINGLECLICK true | 8 | #define KDE_DEFAULT_SINGLECLICK true |
9 | 9 | ||
10 | 10 | ||
11 | class KGlobalSettings | 11 | class KGlobalSettings |
12 | { | 12 | { |
13 | public: | 13 | public: |
14 | static QFont generalFont(); | 14 | static QFont generalFont(); |
15 | static QFont generalMaxFont(); | 15 | static QFont generalMaxFont(); |
16 | static QFont toolBarFont(); | 16 | static QFont toolBarFont(); |
17 | 17 | ||
18 | static QColor mAlternate; | 18 | static QColor mAlternate; |
19 | static QColor toolBarHighlightColor(); | 19 | static QColor toolBarHighlightColor(); |
20 | static QColor alternateBackgroundColor(); | 20 | static QColor alternateBackgroundColor(); |
21 | static void setAlternateBackgroundColor(QColor); | 21 | static void setAlternateBackgroundColor(QColor); |
22 | static QRect desktopGeometry( QWidget * ); | 22 | static QRect desktopGeometry( QWidget * ); |
23 | static QString timeTrackerDir(); | 23 | static QString timeTrackerDir(); |
24 | static QString backupDataDir(); | 24 | static QString backupDataDir(); |
25 | static QString calendarDir(); | ||
25 | 26 | ||
26 | /** | 27 | /** |
27 | * Returns whether KDE runs in single (default) or double click | 28 | * Returns whether KDE runs in single (default) or double click |
28 | * mode. | 29 | * mode. |
29 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html | 30 | * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html |
30 | * @return true if single click mode, or false if double click mode. | 31 | * @return true if single click mode, or false if double click mode. |
31 | **/ | 32 | **/ |
32 | static bool singleClick(); | 33 | static bool singleClick(); |
33 | 34 | ||
34 | }; | 35 | }; |
35 | 36 | ||
36 | #endif | 37 | #endif |