author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/koeventviewer.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'korganizer/koeventviewer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeventviewer.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index c0acf34..4df26a9 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -12,22 +12,27 @@ | |||
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 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <q3cstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <q3whatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <QDesktopWidget> | ||
24 | #include <qlabel.h> | 25 | #include <qlabel.h> |
25 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | //Added by qt3to4: | ||
28 | #include <QKeyEvent> | ||
29 | #include <Q3PtrList> | ||
30 | #include <Q3VBoxLayout> | ||
26 | 31 | ||
27 | #include <klocale.h> | 32 | #include <klocale.h> |
28 | #include <kapplication.h> | 33 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 34 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 35 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 36 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
33 | #include <krun.h> | 38 | #include <krun.h> |
@@ -50,24 +55,24 @@ | |||
50 | //#define size count | 55 | //#define size count |
51 | //#endif | 56 | //#endif |
52 | 57 | ||
53 | #ifdef DESKTOP_VERSION | 58 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 59 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 60 | #include <kabc/addresseeview.h> |
56 | #include <qprinter.h> | 61 | #include <qprinter.h> |
57 | #include <qpainter.h> | 62 | #include <qpainter.h> |
58 | #include <qpaintdevicemetrics.h> | 63 | #include <q3paintdevicemetrics.h> |
59 | #else //DESKTOP_VERSION | 64 | #else //DESKTOP_VERSION |
60 | #include <qtopia/qcopenvelope_qws.h> | 65 | #include <qtopia/qcopenvelope_qws.h> |
61 | #endif //DESKTOP_VERSION | 66 | #endif //DESKTOP_VERSION |
62 | #include <externalapphandler.h> | 67 | #include <externalapphandler.h> |
63 | 68 | ||
64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 69 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
65 | : QTextBrowser(parent,name) | 70 | : Q3TextBrowser(parent,name) |
66 | { | 71 | { |
67 | mSyncMode = false; | 72 | mSyncMode = false; |
68 | mColorMode = 0; | 73 | mColorMode = 0; |
69 | } | 74 | } |
70 | 75 | ||
71 | KOEventViewer::~KOEventViewer() | 76 | KOEventViewer::~KOEventViewer() |
72 | { | 77 | { |
73 | } | 78 | } |
@@ -81,17 +86,17 @@ void KOEventViewer::printMe() | |||
81 | return; | 86 | return; |
82 | int scaleval = pp.printMode() ; | 87 | int scaleval = pp.printMode() ; |
83 | 88 | ||
84 | QPrinter printer; | 89 | QPrinter printer; |
85 | if (!printer.setup() ) | 90 | if (!printer.setup() ) |
86 | return; | 91 | return; |
87 | QPainter p; | 92 | QPainter p; |
88 | p.begin ( &printer ); | 93 | p.begin ( &printer ); |
89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 94 | Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer ); |
90 | float dx, dy; | 95 | float dx, dy; |
91 | int wid = (m.width() * 9)/10; | 96 | int wid = (m.width() * 9)/10; |
92 | dx = (float) wid/(float)contentsWidth (); | 97 | dx = (float) wid/(float)contentsWidth (); |
93 | dy = (float)(m.height()) / (float)contentsHeight (); | 98 | dy = (float)(m.height()) / (float)contentsHeight (); |
94 | float scale; | 99 | float scale; |
95 | // scale to fit the width or height of the paper | 100 | // scale to fit the width or height of the paper |
96 | if ( dx < dy ) | 101 | if ( dx < dy ) |
97 | scale = dx; | 102 | scale = dx; |
@@ -129,17 +134,17 @@ void KOEventViewer::setSource(const QString& n) | |||
129 | // LR I do not understand, why the uid string is different on zaurus and desktop | 134 | // LR I do not understand, why the uid string is different on zaurus and desktop |
130 | QString uid = "uid://"+(*it).uid(); | 135 | QString uid = "uid://"+(*it).uid(); |
131 | 136 | ||
132 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 137 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
133 | if (n == uid ) { | 138 | if (n == uid ) { |
134 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 139 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
135 | QDialog dia( this,"dia123", true ); | 140 | QDialog dia( this,"dia123", true ); |
136 | dia.setCaption( i18n("Details of attendee") ); | 141 | dia.setCaption( i18n("Details of attendee") ); |
137 | QVBoxLayout lay ( &dia ); | 142 | Q3VBoxLayout lay ( &dia ); |
138 | KABC::AddresseeView av ( &dia ); | 143 | KABC::AddresseeView av ( &dia ); |
139 | av.setAddressee( (*it) ); | 144 | av.setAddressee( (*it) ); |
140 | lay.addWidget( &av ); | 145 | lay.addWidget( &av ); |
141 | if ( QApplication::desktop()->width() < 480 ) | 146 | if ( QApplication::desktop()->width() < 480 ) |
142 | dia.resize( 220, 240); | 147 | dia.resize( 220, 240); |
143 | else { | 148 | else { |
144 | dia.resize( 400,400); | 149 | dia.resize( 400,400); |
145 | } | 150 | } |
@@ -150,17 +155,17 @@ void KOEventViewer::setSource(const QString& n) | |||
150 | return; | 155 | return; |
151 | } | 156 | } |
152 | #else | 157 | #else |
153 | { | 158 | { |
154 | if ( "uid:organizer" == n ) { | 159 | if ( "uid:organizer" == n ) { |
155 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 160 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
156 | return; | 161 | return; |
157 | } | 162 | } |
158 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 163 | Q3PtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
159 | if (attendees.count()) { | 164 | if (attendees.count()) { |
160 | Attendee *a; | 165 | Attendee *a; |
161 | for(a=attendees.first();a;a=attendees.next()) { | 166 | for(a=attendees.first();a;a=attendees.next()) { |
162 | if ( "uid:"+a->uid() == n ) { | 167 | if ( "uid:"+a->uid() == n ) { |
163 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 168 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
164 | return; | 169 | return; |
165 | } | 170 | } |
166 | } | 171 | } |
@@ -195,24 +200,24 @@ void KOEventViewer::setSource(const QString& n) | |||
195 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 200 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
196 | //emit showIncidence(n); | 201 | //emit showIncidence(n); |
197 | return; | 202 | return; |
198 | } else if (n.startsWith("uid:")) { | 203 | } else if (n.startsWith("uid:")) { |
199 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 204 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
200 | const QByteArray noParamData; | 205 | const QByteArray noParamData; |
201 | const QByteArray paramData; | 206 | const QByteArray paramData; |
202 | QByteArray replyData; | 207 | QByteArray replyData; |
203 | QCString replyTypeStr; | 208 | Q3CString replyTypeStr; |
204 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 209 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
205 | bool foundAbbrowser = PING_ABBROWSER; | 210 | bool foundAbbrowser = PING_ABBROWSER; |
206 | 211 | ||
207 | if (foundAbbrowser) { | 212 | if (foundAbbrowser) { |
208 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 213 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
209 | //client->send("kaddressbook","KAddressBookIface", | 214 | //client->send("kaddressbook","KAddressBookIface", |
210 | QDataStream arg(paramData, IO_WriteOnly); | 215 | QDataStream arg(paramData, QIODevice::WriteOnly); |
211 | arg << n.mid(6); | 216 | arg << n.mid(6); |
212 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 217 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
213 | return; | 218 | return; |
214 | } else { | 219 | } else { |
215 | /* | 220 | /* |
216 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 221 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
217 | We start it without its main interface | 222 | We start it without its main interface |
218 | */ | 223 | */ |
@@ -226,17 +231,17 @@ void KOEventViewer::setSource(const QString& n) | |||
226 | } | 231 | } |
227 | } else { | 232 | } else { |
228 | //QTextBrowser::setSource(n); | 233 | //QTextBrowser::setSource(n); |
229 | } | 234 | } |
230 | #endif | 235 | #endif |
231 | } | 236 | } |
232 | void KOEventViewer::mailToAttendees( bool all ) | 237 | void KOEventViewer::mailToAttendees( bool all ) |
233 | { | 238 | { |
234 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 239 | Q3PtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
235 | if (attendees.count() == 0) return; | 240 | if (attendees.count() == 0) return; |
236 | QStringList nameList; | 241 | QStringList nameList; |
237 | QStringList emailList; | 242 | QStringList emailList; |
238 | QStringList uidList; | 243 | QStringList uidList; |
239 | Attendee* a; | 244 | Attendee* a; |
240 | for(a=attendees.first();a;a=attendees.next()) { | 245 | for(a=attendees.first();a;a=attendees.next()) { |
241 | if ( !all && !a->RSVP() ) continue; | 246 | if ( !all && !a->RSVP() ) continue; |
242 | if (!a->email().isEmpty()) { | 247 | if (!a->email().isEmpty()) { |
@@ -255,17 +260,17 @@ void KOEventViewer::mailToAttendees( bool all ) | |||
255 | 260 | ||
256 | #else | 261 | #else |
257 | ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject ); | 262 | ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject ); |
258 | #endif | 263 | #endif |
259 | 264 | ||
260 | } | 265 | } |
261 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 266 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
262 | { | 267 | { |
263 | int number=text.contains("\n"); | 268 | int number=text.count("\n"); |
264 | QString str = "<" + tag + ">"; | 269 | QString str = "<" + tag + ">"; |
265 | QString tmpText=text; | 270 | QString tmpText=text; |
266 | QString tmpStr=str; | 271 | QString tmpStr=str; |
267 | if(number !=-1) | 272 | if(number !=-1) |
268 | { | 273 | { |
269 | if (number > 0) { | 274 | if (number > 0) { |
270 | int pos=0; | 275 | int pos=0; |
271 | QString tmp; | 276 | QString tmp; |
@@ -582,17 +587,17 @@ void KOEventViewer::appendTodo(Todo *event, int mode ) | |||
582 | 587 | ||
583 | mText += t_name; | 588 | mText += t_name; |
584 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; | 589 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; |
585 | mText += deTag(event->relatedTo()->summary()); | 590 | mText += deTag(event->relatedTo()->summary()); |
586 | mText += "</a><br>"; | 591 | mText += "</a><br>"; |
587 | 592 | ||
588 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); | 593 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); |
589 | } | 594 | } |
590 | QPtrList<Incidence> Relations = event->relations(); | 595 | Q3PtrList<Incidence> Relations = event->relations(); |
591 | Incidence *to; | 596 | Incidence *to; |
592 | if ( Relations.first() ) | 597 | if ( Relations.first() ) |
593 | addTag("b",i18n("Sub todos:<br>")); | 598 | addTag("b",i18n("Sub todos:<br>")); |
594 | for (to=Relations.first();to;to=Relations.next()) { | 599 | for (to=Relations.first();to;to=Relations.next()) { |
595 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); | 600 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); |
596 | mText += t_name; | 601 | mText += t_name; |
597 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; | 602 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; |
598 | mText += deTag(to->summary()); | 603 | mText += deTag(to->summary()); |
@@ -616,17 +621,17 @@ void KOEventViewer::formatCategories(Incidence *event) | |||
616 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); | 621 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); |
617 | } else { | 622 | } else { |
618 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; | 623 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; |
619 | } | 624 | } |
620 | } | 625 | } |
621 | } | 626 | } |
622 | void KOEventViewer::formatAttendees(Incidence *event) | 627 | void KOEventViewer::formatAttendees(Incidence *event) |
623 | { | 628 | { |
624 | QPtrList<Attendee> attendees = event->attendees(); | 629 | Q3PtrList<Attendee> attendees = event->attendees(); |
625 | if (attendees.count()) { | 630 | if (attendees.count()) { |
626 | 631 | ||
627 | 632 | ||
628 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 633 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
629 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 634 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
630 | addTag("h3",i18n("Organizer")); | 635 | addTag("h3",i18n("Organizer")); |
631 | mText.append("<ul><li>"); | 636 | mText.append("<ul><li>"); |
632 | #ifndef KORG_NOKABC | 637 | #ifndef KORG_NOKABC |
@@ -649,17 +654,17 @@ void KOEventViewer::formatAttendees(Incidence *event) | |||
649 | mText += "</a>\n"; | 654 | mText += "</a>\n"; |
650 | #endif //DESKTOP_VERSION | 655 | #endif //DESKTOP_VERSION |
651 | 656 | ||
652 | 657 | ||
653 | #else | 658 | #else |
654 | mText.append(event->organizer()); | 659 | mText.append(event->organizer()); |
655 | #endif | 660 | #endif |
656 | 661 | ||
657 | if (iconPath) { | 662 | if (!iconPath.isEmpty()) { |
658 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 663 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
659 | mText += "<IMG src=\"" + iconPath + "\">"; | 664 | mText += "<IMG src=\"" + iconPath + "\">"; |
660 | mText += "</a>\n"; | 665 | mText += "</a>\n"; |
661 | } | 666 | } |
662 | mText.append("</li></ul>"); | 667 | mText.append("</li></ul>"); |
663 | 668 | ||
664 | addTag("h3",i18n("Attendees")); | 669 | addTag("h3",i18n("Attendees")); |
665 | Attendee *a; | 670 | Attendee *a; |
@@ -699,17 +704,17 @@ void KOEventViewer::formatAttendees(Incidence *event) | |||
699 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 704 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
700 | if (!a->name().isEmpty()) mText += a->name(); | 705 | if (!a->name().isEmpty()) mText += a->name(); |
701 | else mText += a->email(); | 706 | else mText += a->email(); |
702 | mText += "</a>\n"; | 707 | mText += "</a>\n"; |
703 | #endif | 708 | #endif |
704 | 709 | ||
705 | 710 | ||
706 | if (!a->email().isEmpty()) { | 711 | if (!a->email().isEmpty()) { |
707 | if (iconPath) { | 712 | if (!iconPath.isEmpty()) { |
708 | mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 713 | mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
709 | if ( a->RSVP() ) { | 714 | if ( a->RSVP() ) { |
710 | ++a_count_nr; | 715 | ++a_count_nr; |
711 | mText += "<IMG src=\"" + iconPath + "\">"; | 716 | mText += "<IMG src=\"" + iconPath + "\">"; |
712 | } | 717 | } |
713 | else { | 718 | else { |
714 | ++a_count; | 719 | ++a_count; |
715 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 720 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
@@ -857,12 +862,12 @@ QString KOEventViewer::deTag(QString text) | |||
857 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) | 862 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) |
858 | { | 863 | { |
859 | switch ( e->key() ) { | 864 | switch ( e->key() ) { |
860 | case Qt::Key_Return: | 865 | case Qt::Key_Return: |
861 | case Qt::Key_Enter : | 866 | case Qt::Key_Enter : |
862 | e->ignore(); | 867 | e->ignore(); |
863 | break; | 868 | break; |
864 | default: | 869 | default: |
865 | QTextBrowser::keyPressEvent ( e ); | 870 | Q3TextBrowser::keyPressEvent ( e ); |
866 | break; | 871 | break; |
867 | } | 872 | } |
868 | } | 873 | } |