summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-02-17 21:31:18 (UTC)
committer zautrix <zautrix>2005-02-17 21:31:18 (UTC)
commit8e8d2bd0c31eb272a7f26756252ff4930d0602bc (patch) (unidiff)
tree8392e9ca561d1444bcd949e9f1aaf78f698cde98 /libkcal
parent002e4f8cea2352e4b9a046b98f66be946fbeb5fc (diff)
downloadkdepimpi-8e8d2bd0c31eb272a7f26756252ff4930d0602bc.zip
kdepimpi-8e8d2bd0c31eb272a7f26756252ff4930d0602bc.tar.gz
kdepimpi-8e8d2bd0c31eb272a7f26756252ff4930d0602bc.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/kincidenceformatter.cpp32
-rw-r--r--libkcal/kincidenceformatter.h3
2 files changed, 29 insertions, 6 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index cc3088a..1751ae3 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,31 +1,34 @@
1#include "kincidenceformatter.h" 1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h> 2#include <kstaticdeleter.h>
3#include <kglobal.h> 3#include <kglobal.h>
4#include <klocale.h> 4#include <klocale.h>
5#ifdef DEKTOP_VERSION 5#ifdef DEKTOP_VERSION
6#include <kabc/stdaddressbook.h> 6#include <kabc/stdaddressbook.h>
7#define size count 7#define size count
8#endif 8#endif
9 9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc ) 13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
14{ 14{
15// #ifndef QT_NO_INPUTDIALOG 15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 17// #else
18// return QString::null; 18// return QString::null;
19// #endif 19// #endif
20 mDetails = details;
21 mCreated = created ;
22 mModified = modified;
20 mText = ""; 23 mText = "";
21 if ( inc->type() == "Event" ) 24 if ( inc->type() == "Event" )
22 setEvent((Event *) inc ); 25 setEvent((Event *) inc );
23 else if ( inc->type() == "Todo" ) 26 else if ( inc->type() == "Todo" )
24 setTodo((Todo *) inc ); 27 setTodo((Todo *) inc );
25 return mText; 28 return mText;
26} 29}
27 30
28KIncidenceFormatter* KIncidenceFormatter::instance() 31KIncidenceFormatter* KIncidenceFormatter::instance()
29{ 32{
30 if (!mInstance) { 33 if (!mInstance) {
31 mInstance = insd.setObject(new KIncidenceFormatter()); 34 mInstance = insd.setObject(new KIncidenceFormatter());
@@ -129,33 +132,44 @@ void KIncidenceFormatter::setEvent(Event *event)
129 Alarm *alarm =event->alarms().first() ; 132 Alarm *alarm =event->alarms().first() ;
130 QDateTime t = alarm->time(); 133 QDateTime t = alarm->time();
131 int min = t.secsTo( event->dtStart() )/60; 134 int min = t.secsTo( event->dtStart() )/60;
132 QString s =i18n("(%1 min before)").arg( min ); 135 QString s =i18n("(%1 min before)").arg( min );
133 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 136 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
134 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 137 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
135 //addTag("p",s); 138 //addTag("p",s);
136 } 139 }
137 140
138 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 141 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
139 // mText.append(event->secrecyStr()+"<br>"); 142 // mText.append(event->secrecyStr()+"<br>");
140 formatCategories(event); 143 formatCategories(event);
144 if ( mDetails ) {
141 if (!event->description().isEmpty()) { 145 if (!event->description().isEmpty()) {
142 addTag("p",i18n("<b>Details: </b>")); 146 addTag("p",i18n("<b>Details: </b>"));
143 addTag("p",event->description()); 147 addTag("p",event->description());
144 } 148 }
145 149 }
146 150
147 formatReadOnly(event); 151 formatReadOnly(event);
148 formatAttendees(event); 152 formatAttendees(event);
149 153
154 if ( mCreated ) {
155 addTag("p",i18n("<b>Created: ") +" </b>");
156 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
157
158 }
159 if ( mModified ) {
160 addTag("p",i18n("<b>Last modified: ") +" </b>");
161 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
162
163 }
150 164
151} 165}
152 166
153void KIncidenceFormatter::setTodo(Todo *event ) 167void KIncidenceFormatter::setTodo(Todo *event )
154{ 168{
155 int mode = 0; 169 int mode = 0;
156 mCurrentIncidence = event; 170 mCurrentIncidence = event;
157 bool shortDate = true; 171 bool shortDate = true;
158 if (mode == 0 ) 172 if (mode == 0 )
159 addTag("h3",event->summary()); 173 addTag("h3",event->summary());
160 else { 174 else {
161 if ( mColorMode == 1 ) { 175 if ( mColorMode == 1 ) {
@@ -203,35 +217,43 @@ void KIncidenceFormatter::setTodo(Todo *event )
203 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); 217 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate)));
204 } 218 }
205 219
206 220
207 if (event->hasDueDate()) { 221 if (event->hasDueDate()) {
208 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 222 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
209 } 223 }
210 mText.append(i18n("<p><b>Priority:</b> %2</p>") 224 mText.append(i18n("<p><b>Priority:</b> %2</p>")
211 .arg(QString::number(event->priority()))); 225 .arg(QString::number(event->priority())));
212 226
213 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 227 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
214 formatCategories(event); 228 formatCategories(event);
229 if ( mDetails ) {
215 if (!event->description().isEmpty()) { 230 if (!event->description().isEmpty()) {
216 addTag("p",i18n("<b>Details: </b>")); 231 addTag("p",i18n("<b>Details: </b>"));
217 addTag("p",event->description()); 232 addTag("p",event->description());
218 } 233 }
219 234 }
220
221
222 formatReadOnly(event); 235 formatReadOnly(event);
223 formatAttendees(event); 236 formatAttendees(event);
237 if ( mCreated ) {
238 addTag("p",i18n("<b>Created: ") +" </b>");
239 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
224 240
225} 241}
242 if ( mModified ) {
243 addTag("p",i18n("<b>Last modified: ") +" </b>");
244 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
245
246 }
247}
226 248
227void KIncidenceFormatter::setJournal(Journal* ) 249void KIncidenceFormatter::setJournal(Journal* )
228{ 250{
229 251
230} 252}
231 253
232void KIncidenceFormatter::formatCategories(Incidence *event) 254void KIncidenceFormatter::formatCategories(Incidence *event)
233{ 255{
234 if (!event->categoriesStr().isEmpty()) { 256 if (!event->categoriesStr().isEmpty()) {
235 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 257 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
236 //mText.append(event->categoriesStr()); 258 //mText.append(event->categoriesStr());
237 } 259 }
diff --git a/libkcal/kincidenceformatter.h b/libkcal/kincidenceformatter.h
index 6165a9f..068e6d2 100644
--- a/libkcal/kincidenceformatter.h
+++ b/libkcal/kincidenceformatter.h
@@ -8,35 +8,36 @@
8#include "event.h" 8#include "event.h"
9#include "todo.h" 9#include "todo.h"
10#include "journal.h" 10#include "journal.h"
11 11
12using namespace KCal; 12using namespace KCal;
13 13
14class KIncidenceFormatter : public QObject 14class KIncidenceFormatter : public QObject
15{ 15{
16 public: 16 public:
17 static KIncidenceFormatter* instance(); 17 static KIncidenceFormatter* instance();
18 KIncidenceFormatter(); 18 KIncidenceFormatter();
19 ~KIncidenceFormatter(); 19 ~KIncidenceFormatter();
20 QString getFormattedText( Incidence * inc ); 20 QString getFormattedText( Incidence * inc , bool details = false, bool created = false, bool modified = false );
21 21
22 void setEvent(Event *event); 22 void setEvent(Event *event);
23 void setTodo(Todo *event ); 23 void setTodo(Todo *event );
24 void setJournal(Journal* ); 24 void setJournal(Journal* );
25 25
26 protected: 26 protected:
27 int mColorMode; 27 int mColorMode;
28 void addTag(const QString & tag,const QString & text); 28 void addTag(const QString & tag,const QString & text);
29 29
30 void formatCategories(Incidence *event); 30 void formatCategories(Incidence *event);
31 void formatAttendees(Incidence *event); 31 void formatAttendees(Incidence *event);
32 void formatReadOnly(Incidence *event); 32 void formatReadOnly(Incidence *event);
33 33
34 private: 34 private:
35 bool mSyncMode; 35 bool mSyncMode;
36 bool mDetails, mCreated ,mModified;
36 37
37 QString mText; 38 QString mText;
38 Incidence* mCurrentIncidence; 39 Incidence* mCurrentIncidence;
39 static KIncidenceFormatter* mInstance; 40 static KIncidenceFormatter* mInstance;
40}; 41};
41 42
42#endif 43#endif