author | zautrix <zautrix> | 2004-10-10 21:54:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-10 21:54:49 (UTC) |
commit | 640874bb21ea348edb33a54690ad225e0efdd1e4 (patch) (unidiff) | |
tree | a56ba08e3f091574af76bc0d37bb097eee686827 | |
parent | 80ecf83fe91a61792576b5538891953cd19c4fec (diff) | |
download | kdepimpi-640874bb21ea348edb33a54690ad225e0efdd1e4.zip kdepimpi-640874bb21ea348edb33a54690ad225e0efdd1e4.tar.gz kdepimpi-640874bb21ea348edb33a54690ad225e0efdd1e4.tar.bz2 |
added timer in WN view
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 9b53110..0fea9be 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -38,193 +38,193 @@ | |||
38 | #endif | 38 | #endif |
39 | #include "koglobals.h" | 39 | #include "koglobals.h" |
40 | #include "koprefs.h" | 40 | #include "koprefs.h" |
41 | #include "koeventviewerdialog.h" | 41 | #include "koeventviewerdialog.h" |
42 | 42 | ||
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | using namespace KOrg; | 44 | using namespace KOrg; |
45 | 45 | ||
46 | void WhatsNextTextBrowser::setSource(const QString& n) | 46 | void WhatsNextTextBrowser::setSource(const QString& n) |
47 | { | 47 | { |
48 | 48 | ||
49 | if (n.startsWith("event:")) { | 49 | if (n.startsWith("event:")) { |
50 | emit showIncidence(n); | 50 | emit showIncidence(n); |
51 | return; | 51 | return; |
52 | } else if (n.startsWith("todo:")) { | 52 | } else if (n.startsWith("todo:")) { |
53 | emit showIncidence(n); | 53 | emit showIncidence(n); |
54 | return; | 54 | return; |
55 | } else { | 55 | } else { |
56 | QTextBrowser::setSource(n); | 56 | QTextBrowser::setSource(n); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 60 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
61 | const char *name) | 61 | const char *name) |
62 | : KOrg::BaseView(calendar, parent, name) | 62 | : KOrg::BaseView(calendar, parent, name) |
63 | { | 63 | { |
64 | // mDateLabel = | 64 | // mDateLabel = |
65 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 65 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
66 | // mDateLabel->setMargin(2); | 66 | // mDateLabel->setMargin(2); |
67 | // mDateLabel->setAlignment(AlignCenter); | 67 | // mDateLabel->setAlignment(AlignCenter); |
68 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 68 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
69 | mView = new WhatsNextTextBrowser(this); | 69 | mView = new WhatsNextTextBrowser(this); |
70 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 70 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
71 | 71 | ||
72 | mEventViewer = 0; | 72 | mEventViewer = 0; |
73 | 73 | ||
74 | QBoxLayout *topLayout = new QVBoxLayout(this); | 74 | QBoxLayout *topLayout = new QVBoxLayout(this); |
75 | // topLayout->addWidget(mDateLabel); | 75 | // topLayout->addWidget(mDateLabel); |
76 | topLayout->addWidget(mView); | 76 | topLayout->addWidget(mView); |
77 | mTimer = new QTimer( this ); | 77 | mTimer = new QTimer( this ); |
78 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 78 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
79 | 79 | ||
80 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 80 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
81 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 81 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
82 | } | 82 | } |
83 | 83 | ||
84 | KOWhatsNextView::~KOWhatsNextView() | 84 | KOWhatsNextView::~KOWhatsNextView() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | int KOWhatsNextView::maxDatesHint() | 88 | int KOWhatsNextView::maxDatesHint() |
89 | { | 89 | { |
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | int KOWhatsNextView::currentDateCount() | 93 | int KOWhatsNextView::currentDateCount() |
94 | { | 94 | { |
95 | return 0; | 95 | return 0; |
96 | } | 96 | } |
97 | 97 | ||
98 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 98 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
99 | { | 99 | { |
100 | QPtrList<Incidence> eventList; | 100 | QPtrList<Incidence> eventList; |
101 | 101 | ||
102 | return eventList; | 102 | return eventList; |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 106 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
107 | const QDate &td) | 107 | const QDate &td) |
108 | { | 108 | { |
109 | #ifndef KORG_NOPRINTER | 109 | #ifndef KORG_NOPRINTER |
110 | calPrinter->preview(CalPrinter::Day, fd, td); | 110 | calPrinter->preview(CalPrinter::Day, fd, td); |
111 | #endif | 111 | #endif |
112 | } | 112 | } |
113 | void KOWhatsNextView::updateConfig() | 113 | void KOWhatsNextView::updateConfig() |
114 | { | 114 | { |
115 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 115 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
116 | updateView(); | 116 | updateView(); |
117 | 117 | ||
118 | } | 118 | } |
119 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 119 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
120 | { | 120 | { |
121 | //qDebug("KOWhatsNextView::showEvent "); | 121 | //qDebug("KOWhatsNextView::showEvent "); |
122 | restartTimer(); | 122 | restartTimer(); |
123 | QWidget::showEvent ( e ); | 123 | QWidget::showEvent ( e ); |
124 | } | 124 | } |
125 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 125 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
126 | { | 126 | { |
127 | //qDebug(" KOWhatsNextView::hideEvent"); | 127 | //qDebug(" KOWhatsNextView::hideEvent"); |
128 | mTimer->stop(); | 128 | mTimer->stop(); |
129 | QWidget::hideEvent ( e ); | 129 | QWidget::hideEvent ( e ); |
130 | } | 130 | } |
131 | void KOWhatsNextView::restartTimer() | 131 | void KOWhatsNextView::restartTimer() |
132 | { | 132 | { |
133 | //qDebug("KOWhatsNextView::restartTimer() "); | 133 | //qDebug("KOWhatsNextView::restartTimer() "); |
134 | mTimer->start( 180000 ); | 134 | mTimer->start( 300000 ); |
135 | //mTimer->start( 5000 ); | 135 | //mTimer->start( 5000 ); |
136 | } | 136 | } |
137 | void KOWhatsNextView::updateView() | 137 | void KOWhatsNextView::updateView() |
138 | { | 138 | { |
139 | if ( mTimer->isActive() ) | 139 | if ( mTimer->isActive() ) |
140 | restartTimer(); | 140 | restartTimer(); |
141 | //qDebug("KOWhatsNextView::updateView() "); | 141 | //qDebug("KOWhatsNextView::updateView() "); |
142 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 142 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
143 | KIconLoader kil("korganizer"); | 143 | KIconLoader kil("korganizer"); |
144 | QString ipath;// = new QString(); | 144 | QString ipath;// = new QString(); |
145 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 145 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
146 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 146 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
147 | mText = "<table width=\"100%\">\n"; | 147 | mText = "<table width=\"100%\">\n"; |
148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
149 | #ifdef DESKTOP_VERSION | 149 | #ifdef DESKTOP_VERSION |
150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
151 | #else | 151 | #else |
152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
153 | #endif | 153 | #endif |
154 | // mText += "<img src=\""; | 154 | // mText += "<img src=\""; |
155 | // mText += ipath; | 155 | // mText += ipath; |
156 | // mText += "\">"; | 156 | // mText += "\">"; |
157 | mEventDate = QDate::currentDate(); | 157 | mEventDate = QDate::currentDate(); |
158 | #ifdef DESKTOP_VERSION | 158 | #ifdef DESKTOP_VERSION |
159 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 159 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
160 | #else | 160 | #else |
161 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 161 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
162 | #endif | 162 | #endif |
163 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 163 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
164 | int iii; | 164 | int iii; |
165 | mTodos.clear(); | 165 | mTodos.clear(); |
166 | QPtrList<Event> events; | 166 | QPtrList<Event> events; |
167 | QPtrList<Todo> todos = calendar()->todos(); | 167 | QPtrList<Todo> todos = calendar()->todos(); |
168 | Todo * todo; | 168 | Todo * todo; |
169 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 169 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
170 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 170 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
171 | bool itemAdded = false; | 171 | bool itemAdded = false; |
172 | for ( iii = 0; iii < daysToShow; ++iii ) { | 172 | for ( iii = 0; iii < daysToShow; ++iii ) { |
173 | QString date; | 173 | QString date; |
174 | itemAdded = false; | 174 | itemAdded = false; |
175 | events = calendar()->events( mEventDate, true ); | 175 | events = calendar()->events( mEventDate, true ); |
176 | 176 | ||
177 | if ( iii == 0 ) { // today !!! | 177 | if ( iii == 0 ) { // today !!! |
178 | todo = todos.first(); | 178 | todo = todos.first(); |
179 | while(todo) { | 179 | while(todo) { |
180 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 180 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
181 | if ( ! itemAdded ) { | 181 | if ( ! itemAdded ) { |
182 | appendDay ( iii, mEventDate ); | 182 | appendDay ( iii, mEventDate ); |
183 | itemAdded = true; | 183 | itemAdded = true; |
184 | 184 | ||
185 | } | 185 | } |
186 | appendEvent(todo); | 186 | appendEvent(todo); |
187 | } | 187 | } |
188 | todo = todos.next(); | 188 | todo = todos.next(); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | if (events.count() > 0) { | 193 | if (events.count() > 0) { |
194 | // mText += "<p></p>"; | 194 | // mText += "<p></p>"; |
195 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 195 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
196 | // mText += "<h2>"; | 196 | // mText += "<h2>"; |
197 | //mText += " <img src=\""; | 197 | //mText += " <img src=\""; |
198 | //mText += ipath; | 198 | //mText += ipath; |
199 | //mText += "\">"; | 199 | //mText += "\">"; |
200 | if ( ! itemAdded ) { | 200 | if ( ! itemAdded ) { |
201 | appendDay ( iii, mEventDate ); | 201 | appendDay ( iii, mEventDate ); |
202 | itemAdded = true; | 202 | itemAdded = true; |
203 | 203 | ||
204 | } | 204 | } |
205 | Event *ev = events.first(); | 205 | Event *ev = events.first(); |
206 | while(ev) { | 206 | while(ev) { |
207 | //qDebug("+++++event append %s", ev->summary().latin1()); | 207 | //qDebug("+++++event append %s", ev->summary().latin1()); |
208 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 208 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
209 | appendEvent(ev, false , iii!= 0 ); | 209 | appendEvent(ev, false , iii!= 0 ); |
210 | } | 210 | } |
211 | ev = events.next(); | 211 | ev = events.next(); |
212 | } | 212 | } |
213 | 213 | ||
214 | //mText += "</table>\n"; | 214 | //mText += "</table>\n"; |
215 | } | 215 | } |
216 | 216 | ||
217 | todo = todos.first(); | 217 | todo = todos.first(); |
218 | while(todo) { | 218 | while(todo) { |
219 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 219 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
220 | if ( ! itemAdded ) { | 220 | if ( ! itemAdded ) { |
221 | appendDay ( iii, mEventDate ); | 221 | appendDay ( iii, mEventDate ); |
222 | itemAdded = true; | 222 | itemAdded = true; |
223 | } | 223 | } |
224 | appendEvent(todo); | 224 | appendEvent(todo); |
225 | } | 225 | } |
226 | todo = todos.next(); | 226 | todo = todos.next(); |
227 | } | 227 | } |
228 | if ( !itemAdded && iii == 0 ) { | 228 | if ( !itemAdded && iii == 0 ) { |
229 | // appendDay ( iii, mEventDate ); | 229 | // appendDay ( iii, mEventDate ); |
230 | //mText += "<table>"; | 230 | //mText += "<table>"; |