-rw-r--r-- | korganizer/koagenda.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 92c1cd6..acdf5a0 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -61,193 +61,192 @@ 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 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | int secs = QTime::currentTime().second(); | 156 | int secs = QTime::currentTime().second(); |
157 | qDebug("second %d ", secs ); | ||
158 | minutes->start( (60 - secs +1)*1000 ,true); | 157 | minutes->start( (60 - secs +1)*1000 ,true); |
159 | } | 158 | } |
160 | 159 | ||
161 | 160 | ||
162 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
163 | 162 | ||
164 | 163 | ||
165 | /* | 164 | /* |
166 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
167 | */ | 166 | */ |
168 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
169 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
170 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
171 | { | 170 | { |
172 | 171 | ||
173 | mAllAgendaPopup = 0; | 172 | mAllAgendaPopup = 0; |
174 | mColumns = columns; | 173 | mColumns = columns; |
175 | mRows = rows; | 174 | mRows = rows; |
176 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
177 | mAllDayMode = false; | 176 | mAllDayMode = false; |
178 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
179 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
180 | #endif | 179 | #endif |
181 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
182 | init(); | 181 | init(); |
183 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
184 | } | 183 | } |
185 | 184 | ||
186 | /* | 185 | /* |
187 | Create an agenda widget with columns columns and one row. This is used for | 186 | Create an agenda widget with columns columns and one row. This is used for |
188 | all-day events. | 187 | all-day events. |
189 | */ | 188 | */ |
190 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
191 | QScrollView(parent,name,f) | 190 | QScrollView(parent,name,f) |
192 | { | 191 | { |
193 | mAllAgendaPopup = 0; | 192 | mAllAgendaPopup = 0; |
194 | blockResize = false; | 193 | blockResize = false; |
195 | mColumns = columns; | 194 | mColumns = columns; |
196 | mRows = 1; | 195 | mRows = 1; |
197 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
198 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
199 | mAllDayMode = true; | 198 | mAllDayMode = true; |
200 | #ifndef DESKTOP_VERSION | 199 | #ifndef DESKTOP_VERSION |
201 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
202 | #endif | 201 | #endif |
203 | mHolidayMask = 0; | 202 | mHolidayMask = 0; |
204 | init(); | 203 | init(); |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
208 | KOAgenda::~KOAgenda() | 207 | KOAgenda::~KOAgenda() |
209 | { | 208 | { |
210 | if(mMarcusBains) delete mMarcusBains; | 209 | if(mMarcusBains) delete mMarcusBains; |
211 | 210 | ||
212 | } | 211 | } |
213 | 212 | ||
214 | Incidence *KOAgenda::selectedIncidence() const | 213 | Incidence *KOAgenda::selectedIncidence() const |
215 | { | 214 | { |
216 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
217 | } | 216 | } |
218 | 217 | ||
219 | 218 | ||
220 | QDate KOAgenda::selectedIncidenceDate() const | 219 | QDate KOAgenda::selectedIncidenceDate() const |
221 | { | 220 | { |
222 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
223 | } | 222 | } |
224 | 223 | ||
225 | 224 | ||
226 | void KOAgenda::init() | 225 | void KOAgenda::init() |
227 | { | 226 | { |
228 | mPopupTimer = new QTimer(this); | 227 | mPopupTimer = new QTimer(this); |
229 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
230 | 229 | ||
231 | mNewItemPopup = new QPopupMenu( this ); | 230 | mNewItemPopup = new QPopupMenu( this ); |
232 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
233 | QString pathString = ""; | 232 | QString pathString = ""; |
234 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
235 | if ( QApplication::desktop()->width() < 480 ) | 234 | if ( QApplication::desktop()->width() < 480 ) |
236 | pathString += "icons16/"; | 235 | pathString += "icons16/"; |
237 | } else | 236 | } else |
238 | pathString += "iconsmini/"; | 237 | pathString += "iconsmini/"; |
239 | 238 | ||
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
242 | mNewItemPopup->insertSeparator ( ); | 241 | mNewItemPopup->insertSeparator ( ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
248 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
249 | #ifndef _WIN32_ | 248 | #ifndef _WIN32_ |
250 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
251 | viewport()->setWFlags ( wflags); | 250 | viewport()->setWFlags ( wflags); |
252 | #endif | 251 | #endif |
253 | mGridSpacingX = 80; | 252 | mGridSpacingX = 80; |