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/kowhatsnextview.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/kowhatsnextview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index f88403c..bfe930f 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -5,161 +5,167 @@ | |||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
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 <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <q3textbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <QDesktopWidget> | ||
27 | #ifdef DESKTOP_VERSION | 28 | #ifdef DESKTOP_VERSION |
28 | #include <qpaintdevicemetrics.h> | 29 | #include <q3paintdevicemetrics.h> |
30 | //Added by qt3to4: | ||
31 | #include <Q3PtrList> | ||
32 | #include <QHideEvent> | ||
33 | #include <Q3VBoxLayout> | ||
34 | #include <QShowEvent> | ||
29 | #endif | 35 | #endif |
30 | #include <kglobal.h> | 36 | #include <kglobal.h> |
31 | #include <klocale.h> | 37 | #include <klocale.h> |
32 | #include <kdebug.h> | 38 | #include <kdebug.h> |
33 | #include <kiconloader.h> | 39 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 40 | #include <kmessagebox.h> |
35 | 41 | ||
36 | #include <libkcal/calendar.h> | 42 | #include <libkcal/calendar.h> |
37 | 43 | ||
38 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
39 | #include "calprinter.h" | 45 | #include "calprinter.h" |
40 | #endif | 46 | #endif |
41 | #include "koglobals.h" | 47 | #include "koglobals.h" |
42 | #include "koprefs.h" | 48 | #include "koprefs.h" |
43 | #include "koeventviewerdialog.h" | 49 | #include "koeventviewerdialog.h" |
44 | #include "koeventviewer.h" | 50 | #include "koeventviewer.h" |
45 | #include <qstylesheet.h> | 51 | #include <q3stylesheet.h> |
46 | #include "kowhatsnextview.h" | 52 | #include "kowhatsnextview.h" |
47 | using namespace KOrg; | 53 | using namespace KOrg; |
48 | 54 | ||
49 | void WhatsNextTextBrowser::setSource(const QString& n) | 55 | void WhatsNextTextBrowser::setSource(const QString& n) |
50 | { | 56 | { |
51 | 57 | ||
52 | if (n.startsWith("event:")) { | 58 | if (n.startsWith("event:")) { |
53 | emit showIncidence(n); | 59 | emit showIncidence(n); |
54 | return; | 60 | return; |
55 | } else if (n.startsWith("todo:")) { | 61 | } else if (n.startsWith("todo:")) { |
56 | emit showIncidence(n); | 62 | emit showIncidence(n); |
57 | return; | 63 | return; |
58 | } else { | 64 | } else { |
59 | QTextBrowser::setSource(n); | 65 | Q3TextBrowser::setSource(n); |
60 | } | 66 | } |
61 | } | 67 | } |
62 | void WhatsNextTextBrowser::printMe() | 68 | void WhatsNextTextBrowser::printMe() |
63 | { | 69 | { |
64 | #ifdef DESKTOP_VERSION | 70 | #ifdef DESKTOP_VERSION |
65 | KOPrintPrefs pp ( this ); | 71 | KOPrintPrefs pp ( this ); |
66 | if (!pp.exec() ) | 72 | if (!pp.exec() ) |
67 | return; | 73 | return; |
68 | int scaleval = pp.printMode() ; | 74 | int scaleval = pp.printMode() ; |
69 | 75 | ||
70 | QPrinter printer; | 76 | QPrinter printer; |
71 | if (!printer.setup() ) | 77 | if (!printer.setup() ) |
72 | return; | 78 | return; |
73 | QPainter p; | 79 | QPainter p; |
74 | p.begin ( &printer ); | 80 | p.begin ( &printer ); |
75 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 81 | Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer ); |
76 | float dx, dy; | 82 | float dx, dy; |
77 | int wid = (m.width() * 9)/10; | 83 | int wid = (m.width() * 9)/10; |
78 | dx = (float) wid/(float)contentsWidth (); | 84 | dx = (float) wid/(float)contentsWidth (); |
79 | dy = (float)(m.height()) / (float)contentsHeight (); | 85 | dy = (float)(m.height()) / (float)contentsHeight (); |
80 | float scale; | 86 | float scale; |
81 | // scale to fit the width or height of the paper | 87 | // scale to fit the width or height of the paper |
82 | if ( dx < dy ) | 88 | if ( dx < dy ) |
83 | scale = dx; | 89 | scale = dx; |
84 | else | 90 | else |
85 | scale = dy; | 91 | scale = dy; |
86 | p.translate( m.width()/10,0 ); | 92 | p.translate( m.width()/10,0 ); |
87 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 93 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
88 | p.scale( scale, scale ); | 94 | p.scale( scale, scale ); |
89 | } | 95 | } |
90 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 96 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
91 | p.end(); | 97 | p.end(); |
92 | #endif | 98 | #endif |
93 | } | 99 | } |
94 | 100 | ||
95 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 101 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
96 | const char *name) | 102 | const char *name) |
97 | : KOrg::BaseView(calendar, parent, name) | 103 | : KOrg::BaseView(calendar, parent, name) |
98 | { | 104 | { |
99 | // mDateLabel = | 105 | // mDateLabel = |
100 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 106 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
101 | // mDateLabel->setMargin(2); | 107 | // mDateLabel->setMargin(2); |
102 | // mDateLabel->setAlignment(AlignCenter); | 108 | // mDateLabel->setAlignment(AlignCenter); |
103 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 109 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
104 | mView = new WhatsNextTextBrowser(this); | 110 | mView = new WhatsNextTextBrowser(this); |
105 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 111 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
106 | QStyleSheet* stsh = mView->styleSheet(); | 112 | Q3StyleSheet* stsh = mView->styleSheet(); |
107 | QStyleSheetItem * style ; | 113 | Q3StyleSheetItem * style ; |
108 | style = stsh->item ("h2" ); | 114 | style = stsh->item ("h2" ); |
109 | if ( style ) { | 115 | if ( style ) { |
110 | style->setMargin(QStyleSheetItem::MarginAll,0); | 116 | style->setMargin(Q3StyleSheetItem::MarginAll,0); |
111 | } | 117 | } |
112 | style = stsh->item ("h3" ); | 118 | style = stsh->item ("h3" ); |
113 | if ( style ) { | 119 | if ( style ) { |
114 | style->setMargin(QStyleSheetItem::MarginAll,0); | 120 | style->setMargin(Q3StyleSheetItem::MarginAll,0); |
115 | } | 121 | } |
116 | mEventViewer = 0; | 122 | mEventViewer = 0; |
117 | 123 | ||
118 | QBoxLayout *topLayout = new QVBoxLayout(this); | 124 | Q3BoxLayout *topLayout = new Q3VBoxLayout(this); |
119 | // topLayout->addWidget(mDateLabel); | 125 | // topLayout->addWidget(mDateLabel); |
120 | topLayout->addWidget(mView); | 126 | topLayout->addWidget(mView); |
121 | mTimer = new QTimer( this ); | 127 | mTimer = new QTimer( this ); |
122 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 128 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
123 | 129 | ||
124 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 130 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
125 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 131 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
126 | } | 132 | } |
127 | 133 | ||
128 | KOWhatsNextView::~KOWhatsNextView() | 134 | KOWhatsNextView::~KOWhatsNextView() |
129 | { | 135 | { |
130 | } | 136 | } |
131 | 137 | ||
132 | int KOWhatsNextView::maxDatesHint() | 138 | int KOWhatsNextView::maxDatesHint() |
133 | { | 139 | { |
134 | return 0; | 140 | return 0; |
135 | } | 141 | } |
136 | 142 | ||
137 | int KOWhatsNextView::currentDateCount() | 143 | int KOWhatsNextView::currentDateCount() |
138 | { | 144 | { |
139 | return 0; | 145 | return 0; |
140 | } | 146 | } |
141 | 147 | ||
142 | void KOWhatsNextView::clearList() | 148 | void KOWhatsNextView::clearList() |
143 | { | 149 | { |
144 | mTimer->stop(); | 150 | mTimer->stop(); |
145 | mView->setText(" "); | 151 | mView->setText(" "); |
146 | } | 152 | } |
147 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 153 | Q3PtrList<Incidence> KOWhatsNextView::selectedIncidences() |
148 | { | 154 | { |
149 | QPtrList<Incidence> eventList; | 155 | Q3PtrList<Incidence> eventList; |
150 | 156 | ||
151 | return eventList; | 157 | return eventList; |
152 | } | 158 | } |
153 | 159 | ||
154 | void KOWhatsNextView::printMe() | 160 | void KOWhatsNextView::printMe() |
155 | { | 161 | { |
156 | #ifdef DESKTOP_VERSION | 162 | #ifdef DESKTOP_VERSION |
157 | mView->printMe(); | 163 | mView->printMe(); |
158 | #endif | 164 | #endif |
159 | } | 165 | } |
160 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 166 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
161 | const QDate &td) | 167 | const QDate &td) |
162 | { | 168 | { |
163 | #ifndef KORG_NOPRINTER | 169 | #ifndef KORG_NOPRINTER |
164 | calPrinter->preview(CalPrinter::Day, fd, td); | 170 | calPrinter->preview(CalPrinter::Day, fd, td); |
165 | #endif | 171 | #endif |
@@ -206,34 +212,34 @@ void KOWhatsNextView::updateView() | |||
206 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 212 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
207 | #else | 213 | #else |
208 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 214 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
209 | #endif | 215 | #endif |
210 | // mText += "<img src=\""; | 216 | // mText += "<img src=\""; |
211 | // mText += ipath; | 217 | // mText += ipath; |
212 | // mText += "\">"; | 218 | // mText += "\">"; |
213 | mEventDate = QDate::currentDate(); | 219 | mEventDate = QDate::currentDate(); |
214 | #ifdef DESKTOP_VERSION | 220 | #ifdef DESKTOP_VERSION |
215 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 221 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
216 | #else | 222 | #else |
217 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 223 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
218 | #endif | 224 | #endif |
219 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 225 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
220 | int iii; | 226 | int iii; |
221 | mTodos.clear(); | 227 | mTodos.clear(); |
222 | QPtrList<Event> events; | 228 | Q3PtrList<Event> events; |
223 | QPtrList<Todo> todos = calendar()->todos(); | 229 | Q3PtrList<Todo> todos = calendar()->todos(); |
224 | Todo * todo; | 230 | Todo * todo; |
225 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 231 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
226 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 232 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
227 | bool itemAdded = false; | 233 | bool itemAdded = false; |
228 | for ( iii = 0; iii < daysToShow; ++iii ) { | 234 | for ( iii = 0; iii < daysToShow; ++iii ) { |
229 | QString date; | 235 | QString date; |
230 | itemAdded = false; | 236 | itemAdded = false; |
231 | events = calendar()->events( mEventDate, true ); | 237 | events = calendar()->events( mEventDate, true ); |
232 | 238 | ||
233 | if ( iii == 0 ) { // today !!! | 239 | if ( iii == 0 ) { // today !!! |
234 | todo = todos.first(); | 240 | todo = todos.first(); |
235 | while(todo) { | 241 | while(todo) { |
236 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 242 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
237 | if ( ! itemAdded ) { | 243 | if ( ! itemAdded ) { |
238 | appendDay ( iii, mEventDate ); | 244 | appendDay ( iii, mEventDate ); |
239 | //itemAdded = true; | 245 | //itemAdded = true; |
@@ -441,33 +447,33 @@ void KOWhatsNextView::appendDay( int i, QDate eventDate ) | |||
441 | } | 447 | } |
442 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 448 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
443 | 449 | ||
444 | #endif | 450 | #endif |
445 | mText += "<h2>" + date + "</h2>\n"; | 451 | mText += "<h2>" + date + "</h2>\n"; |
446 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 452 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
447 | mText += "<table>\n"; | 453 | mText += "<table>\n"; |
448 | } | 454 | } |
449 | } | 455 | } |
450 | 456 | ||
451 | 457 | ||
452 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 458 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
453 | { | 459 | { |
454 | updateView(); | 460 | updateView(); |
455 | } | 461 | } |
456 | 462 | ||
457 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 463 | void KOWhatsNextView::showEvents(Q3PtrList<Event>) |
458 | { | 464 | { |
459 | } | 465 | } |
460 | 466 | ||
461 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 467 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
462 | { | 468 | { |
463 | switch(action) { | 469 | switch(action) { |
464 | case KOGlobals::EVENTADDED: | 470 | case KOGlobals::EVENTADDED: |
465 | updateView(); | 471 | updateView(); |
466 | break; | 472 | break; |
467 | case KOGlobals::EVENTEDITED: | 473 | case KOGlobals::EVENTEDITED: |
468 | updateView(); | 474 | updateView(); |
469 | break; | 475 | break; |
470 | case KOGlobals::EVENTDELETED: | 476 | case KOGlobals::EVENTDELETED: |
471 | updateView(); | 477 | updateView(); |
472 | break; | 478 | break; |
473 | default: | 479 | default: |
@@ -728,33 +734,33 @@ bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | |||
728 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 734 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
729 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 735 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
730 | KGlobal::locale()->setDateFormatShort(dfs); | 736 | KGlobal::locale()->setDateFormatShort(dfs); |
731 | } | 737 | } |
732 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 738 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
733 | if ( !ev->location().isEmpty() ) | 739 | if ( !ev->location().isEmpty() ) |
734 | mText += " ("+ev->location() +")"; | 740 | mText += " ("+ev->location() +")"; |
735 | if ( !isSub ) { | 741 | if ( !isSub ) { |
736 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 742 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
737 | mText += " ["+ev->relatedTo()->summary() +"]"; | 743 | mText += " ["+ev->relatedTo()->summary() +"]"; |
738 | mText += "</p>\n"; | 744 | mText += "</p>\n"; |
739 | } | 745 | } |
740 | else { | 746 | else { |
741 | ind += "-"; | 747 | ind += "-"; |
742 | mText += "</li>\n"; | 748 | mText += "</li>\n"; |
743 | } | 749 | } |
744 | QPtrList<Incidence> Relations = ev->relations(); | 750 | Q3PtrList<Incidence> Relations = ev->relations(); |
745 | Incidence *to; | 751 | Incidence *to; |
746 | for (to=Relations.first();to;to=Relations.next()) { | 752 | for (to=Relations.first();to;to=Relations.next()) { |
747 | if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) | 753 | if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) |
748 | appendTodo( to, ind , true ); | 754 | appendTodo( to, ind , true ); |
749 | } | 755 | } |
750 | 756 | ||
751 | return true; | 757 | return true; |
752 | } | 758 | } |
753 | 759 | ||
754 | /* | 760 | /* |
755 | void KOWhatsNextView::createEventViewer() | 761 | void KOWhatsNextView::createEventViewer() |
756 | { | 762 | { |
757 | if (!mEventViewer) { | 763 | if (!mEventViewer) { |
758 | 764 | ||
759 | mEventViewer = new KOEventViewerDialog(this); | 765 | mEventViewer = new KOEventViewerDialog(this); |
760 | } | 766 | } |