Diffstat (limited to 'korganizer/koeventviewer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeventviewer.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index f6c252b..2d0bfff 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -65,96 +65,106 @@ KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | |||
65 | : QTextBrowser(parent,name) | 65 | : QTextBrowser(parent,name) |
66 | { | 66 | { |
67 | mSyncMode = false; | 67 | mSyncMode = false; |
68 | mColorMode = 0; | 68 | mColorMode = 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | KOEventViewer::~KOEventViewer() | 71 | KOEventViewer::~KOEventViewer() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KOEventViewer::printMe() | 75 | void KOEventViewer::printMe() |
76 | { | 76 | { |
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | 78 | ||
79 | KOPrintPrefs pp ( this ); | 79 | KOPrintPrefs pp ( this ); |
80 | if (!pp.exec() ) | 80 | if (!pp.exec() ) |
81 | return; | 81 | return; |
82 | int scaleval = pp.printMode() ; | 82 | int scaleval = pp.printMode() ; |
83 | 83 | ||
84 | QPrinter printer; | 84 | QPrinter printer; |
85 | if (!printer.setup() ) | 85 | if (!printer.setup() ) |
86 | return; | 86 | return; |
87 | QPainter p; | 87 | QPainter p; |
88 | p.begin ( &printer ); | 88 | p.begin ( &printer ); |
89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
90 | float dx, dy; | 90 | float dx, dy; |
91 | int wid = (m.width() * 9)/10; | 91 | int wid = (m.width() * 9)/10; |
92 | dx = (float) wid/(float)contentsWidth (); | 92 | dx = (float) wid/(float)contentsWidth (); |
93 | dy = (float)(m.height()) / (float)contentsHeight (); | 93 | dy = (float)(m.height()) / (float)contentsHeight (); |
94 | float scale; | 94 | float scale; |
95 | // scale to fit the width or height of the paper | 95 | // scale to fit the width or height of the paper |
96 | if ( dx < dy ) | 96 | if ( dx < dy ) |
97 | scale = dx; | 97 | scale = dx; |
98 | else | 98 | else |
99 | scale = dy; | 99 | scale = dy; |
100 | 100 | ||
101 | p.translate( m.width()/10,0 ); | 101 | p.translate( m.width()/10,0 ); |
102 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 102 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
103 | p.scale( scale, scale ); | 103 | p.scale( scale, scale ); |
104 | } | 104 | } |
105 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 105 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
106 | p.end(); | 106 | p.end(); |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | } | 109 | } |
110 | void KOEventViewer::setSource(const QString& n) | 110 | void KOEventViewer::setSource(const QString& n) |
111 | { | 111 | { |
112 | 112 | ||
113 | if ( n.left(8) == "todo_uid" ) { | ||
114 | int midstr = 9; | ||
115 | #ifdef DESKTOP_VERSION | ||
116 | midstr = 11; | ||
117 | #endif | ||
118 | qDebug("-%s- ", n.mid(midstr).latin1()); | ||
119 | emit showIncidence( n.mid(midstr) ); | ||
120 | return; | ||
121 | } | ||
122 | |||
113 | if ( n.left(3) == "uid" ) | 123 | if ( n.left(3) == "uid" ) |
114 | #ifdef DESKTOP_VERSION | 124 | #ifdef DESKTOP_VERSION |
115 | { | 125 | { |
116 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 126 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
117 | KABC::AddressBook::Iterator it; | 127 | KABC::AddressBook::Iterator it; |
118 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 128 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
119 | // LR I do not understand, why the uid string is different on zaurus and desktop | 129 | // LR I do not understand, why the uid string is different on zaurus and desktop |
120 | QString uid = "uid://"+(*it).uid(); | 130 | QString uid = "uid://"+(*it).uid(); |
121 | 131 | ||
122 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 132 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
123 | if (n == uid ) { | 133 | if (n == uid ) { |
124 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 134 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
125 | QDialog dia( this,"dia123", true ); | 135 | QDialog dia( this,"dia123", true ); |
126 | dia.setCaption( i18n("Details of attendee") ); | 136 | dia.setCaption( i18n("Details of attendee") ); |
127 | QVBoxLayout lay ( &dia ); | 137 | QVBoxLayout lay ( &dia ); |
128 | KABC::AddresseeView av ( &dia ); | 138 | KABC::AddresseeView av ( &dia ); |
129 | av.setAddressee( (*it) ); | 139 | av.setAddressee( (*it) ); |
130 | lay.addWidget( &av ); | 140 | lay.addWidget( &av ); |
131 | if ( QApplication::desktop()->width() < 480 ) | 141 | if ( QApplication::desktop()->width() < 480 ) |
132 | dia.resize( 220, 240); | 142 | dia.resize( 220, 240); |
133 | else { | 143 | else { |
134 | dia.resize( 400,400); | 144 | dia.resize( 400,400); |
135 | } | 145 | } |
136 | dia.exec(); | 146 | dia.exec(); |
137 | break; | 147 | break; |
138 | } | 148 | } |
139 | } | 149 | } |
140 | return; | 150 | return; |
141 | } | 151 | } |
142 | #else | 152 | #else |
143 | { | 153 | { |
144 | if ( "uid:organizer" == n ) { | 154 | if ( "uid:organizer" == n ) { |
145 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 155 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
146 | return; | 156 | return; |
147 | } | 157 | } |
148 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 158 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
149 | if (attendees.count()) { | 159 | if (attendees.count()) { |
150 | Attendee *a; | 160 | Attendee *a; |
151 | for(a=attendees.first();a;a=attendees.next()) { | 161 | for(a=attendees.first();a;a=attendees.next()) { |
152 | if ( "uid:"+a->uid() == n ) { | 162 | if ( "uid:"+a->uid() == n ) { |
153 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 163 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
154 | return; | 164 | return; |
155 | } | 165 | } |
156 | } | 166 | } |
157 | } | 167 | } |
158 | return; | 168 | return; |
159 | } | 169 | } |
160 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 170 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
@@ -485,104 +495,116 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) | |||
485 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 495 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
486 | } | 496 | } |
487 | if (!event->location().isEmpty()) { | 497 | if (!event->location().isEmpty()) { |
488 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); | 498 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); |
489 | mMailSubject += i18n(" at ") + event->location(); | 499 | mMailSubject += i18n(" at ") + event->location(); |
490 | } | 500 | } |
491 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 501 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
492 | .arg(QString::number(event->priority()))); | 502 | .arg(QString::number(event->priority()))); |
493 | 503 | ||
494 | if (event->isAlarmEnabled()) { | 504 | if (event->isAlarmEnabled()) { |
495 | Alarm *alarm =event->alarms().first() ; | 505 | Alarm *alarm =event->alarms().first() ; |
496 | QDateTime t = alarm->time(); | 506 | QDateTime t = alarm->time(); |
497 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 507 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
498 | if ( wideScreen ) { | 508 | if ( wideScreen ) { |
499 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); | 509 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); |
500 | } else { | 510 | } else { |
501 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 511 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
502 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 512 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
503 | } | 513 | } |
504 | } | 514 | } |
505 | 515 | ||
506 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); | 516 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); |
507 | 517 | ||
508 | formatCategories(event); | 518 | formatCategories(event); |
509 | 519 | ||
510 | formatAttendees(event); | 520 | formatAttendees(event); |
511 | 521 | ||
512 | if ( KOPrefs::instance()->mEVshowCreated ) { | 522 | if ( KOPrefs::instance()->mEVshowCreated ) { |
513 | if(wideScreen ){ | 523 | if(wideScreen ){ |
514 | 524 | ||
515 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 525 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
516 | 526 | ||
517 | } else { | 527 | } else { |
518 | addTag("p",i18n("<b>Created: ") +" </b>"); | 528 | addTag("p",i18n("<b>Created: ") +" </b>"); |
519 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 529 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
520 | } | 530 | } |
521 | } | 531 | } |
522 | if ( KOPrefs::instance()->mEVshowChanged ) { | 532 | if ( KOPrefs::instance()->mEVshowChanged ) { |
523 | if(wideScreen ){ | 533 | if(wideScreen ){ |
524 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); | 534 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); |
525 | 535 | ||
526 | } else { | 536 | } else { |
527 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 537 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
528 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 538 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
529 | } | 539 | } |
530 | } | 540 | } |
531 | if ( event->relatedTo() ) { | 541 | if ( event->relatedTo() ) { |
532 | addTag("b",i18n("Parent todo:<br>")); | 542 | addTag("b",i18n("Parent todo:<br>")); |
533 | mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 543 | |
544 | QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); | ||
545 | |||
546 | mText += t_name; | ||
547 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; | ||
548 | mText += deTag(event->relatedTo()->summary()); | ||
549 | mText += "</a><br>"; | ||
550 | |||
551 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); | ||
534 | } | 552 | } |
535 | QPtrList<Incidence> Relations = event->relations(); | 553 | QPtrList<Incidence> Relations = event->relations(); |
536 | Incidence *to; | 554 | Incidence *to; |
537 | if ( Relations.first() ) | 555 | if ( Relations.first() ) |
538 | addTag("b",i18n("Sub todos:<br>")); | 556 | addTag("b",i18n("Sub todos:<br>")); |
539 | for (to=Relations.first();to;to=Relations.next()) { | 557 | for (to=Relations.first();to;to=Relations.next()) { |
540 | mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 558 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); |
559 | mText += t_name; | ||
560 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; | ||
561 | mText += deTag(to->summary()); | ||
562 | mText += "</a><br>"; | ||
541 | 563 | ||
542 | } | 564 | } |
543 | 565 | ||
544 | if ( KOPrefs::instance()->mEVshowDetails ) { | 566 | if ( KOPrefs::instance()->mEVshowDetails ) { |
545 | if (!event->description().isEmpty()) { | 567 | if (!event->description().isEmpty()) { |
546 | addTag("p",i18n("<b>Details: </b>")); | 568 | addTag("p",i18n("<b>Details: </b>")); |
547 | addTag("p",deTag(event->description())); | 569 | addTag("p",deTag(event->description())); |
548 | } | 570 | } |
549 | } | 571 | } |
550 | setText(mText); | 572 | setText(mText); |
551 | } | 573 | } |
552 | 574 | ||
553 | void KOEventViewer::formatCategories(Incidence *event) | 575 | void KOEventViewer::formatCategories(Incidence *event) |
554 | { | 576 | { |
555 | if (!event->categoriesStr().isEmpty()) { | 577 | if (!event->categoriesStr().isEmpty()) { |
556 | if (event->categories().count() == 1) { | 578 | if (event->categories().count() == 1) { |
557 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); | 579 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); |
558 | } else { | 580 | } else { |
559 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; | 581 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; |
560 | } | 582 | } |
561 | } | 583 | } |
562 | } | 584 | } |
563 | void KOEventViewer::formatAttendees(Incidence *event) | 585 | void KOEventViewer::formatAttendees(Incidence *event) |
564 | { | 586 | { |
565 | QPtrList<Attendee> attendees = event->attendees(); | 587 | QPtrList<Attendee> attendees = event->attendees(); |
566 | if (attendees.count()) { | 588 | if (attendees.count()) { |
567 | 589 | ||
568 | 590 | ||
569 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 591 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
570 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 592 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
571 | addTag("h3",i18n("Organizer")); | 593 | addTag("h3",i18n("Organizer")); |
572 | mText.append("<ul><li>"); | 594 | mText.append("<ul><li>"); |
573 | #ifndef KORG_NOKABC | 595 | #ifndef KORG_NOKABC |
574 | 596 | ||
575 | #ifdef DESKTOP_VERSION | 597 | #ifdef DESKTOP_VERSION |
576 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 598 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
577 | KABC::Addressee::List addressList; | 599 | KABC::Addressee::List addressList; |
578 | addressList = add_book->findByEmail(event->organizer()); | 600 | addressList = add_book->findByEmail(event->organizer()); |
579 | KABC::Addressee o = addressList.first(); | 601 | KABC::Addressee o = addressList.first(); |
580 | if (!o.isEmpty() && addressList.size()<2) { | 602 | if (!o.isEmpty() && addressList.size()<2) { |
581 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 603 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
582 | mText += o.formattedName(); | 604 | mText += o.formattedName(); |
583 | mText += "</a>\n"; | 605 | mText += "</a>\n"; |
584 | } else { | 606 | } else { |
585 | mText.append(event->organizer()); | 607 | mText.append(event->organizer()); |
586 | } | 608 | } |
587 | #else //DESKTOP_VERSION | 609 | #else //DESKTOP_VERSION |
588 | mText += "<a href=\"uid:organizer\">"; | 610 | mText += "<a href=\"uid:organizer\">"; |