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 | |||
@@ -13,71 +13,77 @@ | |||
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; |
@@ -98,29 +104,29 @@ KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | |||
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 | } |
@@ -139,19 +145,19 @@ int KOWhatsNextView::currentDateCount() | |||
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(); |
@@ -214,18 +220,18 @@ void KOWhatsNextView::updateView() | |||
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 ); |
@@ -449,17 +455,17 @@ void KOWhatsNextView::appendDay( int i, QDate eventDate ) | |||
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(); |
@@ -736,17 +742,17 @@ bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool 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 | } |