Diffstat (limited to 'korganizer/kowhatsnextview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 5f14bfa..219f7c3 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -66,97 +66,113 @@ KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | |||
66 | // mDateLabel->setMargin(2); | 66 | // mDateLabel->setMargin(2); |
67 | // mDateLabel->setAlignment(AlignCenter); | 67 | // mDateLabel->setAlignment(AlignCenter); |
68 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 68 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
69 | mView = new WhatsNextTextBrowser(this); | 69 | mView = new WhatsNextTextBrowser(this); |
70 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 70 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
71 | QStyleSheet* stsh = mView->styleSheet(); | 71 | QStyleSheet* stsh = mView->styleSheet(); |
72 | QStyleSheetItem * style ; | 72 | QStyleSheetItem * style ; |
73 | style = stsh->item ("h2" ); | 73 | style = stsh->item ("h2" ); |
74 | if ( style ) { | 74 | if ( style ) { |
75 | style->setMargin(QStyleSheetItem::MarginAll,0); | 75 | style->setMargin(QStyleSheetItem::MarginAll,0); |
76 | } | 76 | } |
77 | style = stsh->item ("h3" ); | 77 | style = stsh->item ("h3" ); |
78 | if ( style ) { | 78 | if ( style ) { |
79 | style->setMargin(QStyleSheetItem::MarginAll,0); | 79 | style->setMargin(QStyleSheetItem::MarginAll,0); |
80 | } | 80 | } |
81 | mEventViewer = 0; | 81 | mEventViewer = 0; |
82 | 82 | ||
83 | QBoxLayout *topLayout = new QVBoxLayout(this); | 83 | QBoxLayout *topLayout = new QVBoxLayout(this); |
84 | // topLayout->addWidget(mDateLabel); | 84 | // topLayout->addWidget(mDateLabel); |
85 | topLayout->addWidget(mView); | 85 | topLayout->addWidget(mView); |
86 | mTimer = new QTimer( this ); | 86 | mTimer = new QTimer( this ); |
87 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 87 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
88 | 88 | ||
89 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 89 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
90 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 90 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
91 | } | 91 | } |
92 | 92 | ||
93 | KOWhatsNextView::~KOWhatsNextView() | 93 | KOWhatsNextView::~KOWhatsNextView() |
94 | { | 94 | { |
95 | } | 95 | } |
96 | 96 | ||
97 | int KOWhatsNextView::maxDatesHint() | 97 | int KOWhatsNextView::maxDatesHint() |
98 | { | 98 | { |
99 | return 0; | 99 | return 0; |
100 | } | 100 | } |
101 | 101 | ||
102 | int KOWhatsNextView::currentDateCount() | 102 | int KOWhatsNextView::currentDateCount() |
103 | { | 103 | { |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
107 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 107 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
108 | { | 108 | { |
109 | QPtrList<Incidence> eventList; | 109 | QPtrList<Incidence> eventList; |
110 | 110 | ||
111 | return eventList; | 111 | return eventList; |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | void KOWhatsNextView::printMe() | |
115 | { | ||
116 | #ifdef DESKTOP_VERSION | ||
117 | QPrinter printer; | ||
118 | if (!printer.setup() ) | ||
119 | return; | ||
120 | QTextBrowser tb; | ||
121 | tb.setFixedSize( 600, 4000 ); | ||
122 | QPainter::redirect ( tb.viewport(), &printer ); | ||
123 | updateView(); | ||
124 | tb.setText( mText ); | ||
125 | tb.show(); | ||
126 | tb.repaint(); | ||
127 | tb.hide(); | ||
128 | KMessageBox::information( this, i18n("Printing What's Next View!\n\nPlease close after\nprinting is finished.")); | ||
129 | #endif | ||
130 | } | ||
115 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 131 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
116 | const QDate &td) | 132 | const QDate &td) |
117 | { | 133 | { |
118 | #ifndef KORG_NOPRINTER | 134 | #ifndef KORG_NOPRINTER |
119 | calPrinter->preview(CalPrinter::Day, fd, td); | 135 | calPrinter->preview(CalPrinter::Day, fd, td); |
120 | #endif | 136 | #endif |
121 | } | 137 | } |
122 | void KOWhatsNextView::updateConfig() | 138 | void KOWhatsNextView::updateConfig() |
123 | { | 139 | { |
124 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 140 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
125 | updateView(); | 141 | updateView(); |
126 | 142 | ||
127 | } | 143 | } |
128 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 144 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
129 | { | 145 | { |
130 | //qDebug("KOWhatsNextView::showEvent "); | 146 | //qDebug("KOWhatsNextView::showEvent "); |
131 | restartTimer(); | 147 | restartTimer(); |
132 | QWidget::showEvent ( e ); | 148 | QWidget::showEvent ( e ); |
133 | } | 149 | } |
134 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 150 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
135 | { | 151 | { |
136 | //qDebug(" KOWhatsNextView::hideEvent"); | 152 | //qDebug(" KOWhatsNextView::hideEvent"); |
137 | mTimer->stop(); | 153 | mTimer->stop(); |
138 | QWidget::hideEvent ( e ); | 154 | QWidget::hideEvent ( e ); |
139 | } | 155 | } |
140 | void KOWhatsNextView::restartTimer() | 156 | void KOWhatsNextView::restartTimer() |
141 | { | 157 | { |
142 | //qDebug("KOWhatsNextView::restartTimer() "); | 158 | //qDebug("KOWhatsNextView::restartTimer() "); |
143 | mTimer->start( 300000 ); | 159 | mTimer->start( 300000 ); |
144 | //mTimer->start( 5000 ); | 160 | //mTimer->start( 5000 ); |
145 | } | 161 | } |
146 | void KOWhatsNextView::updateView() | 162 | void KOWhatsNextView::updateView() |
147 | { | 163 | { |
148 | if ( mTimer->isActive() ) | 164 | if ( mTimer->isActive() ) |
149 | restartTimer(); | 165 | restartTimer(); |
150 | //qDebug("KOWhatsNextView::updateView() "); | 166 | //qDebug("KOWhatsNextView::updateView() "); |
151 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 167 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
152 | KIconLoader kil("korganizer"); | 168 | KIconLoader kil("korganizer"); |
153 | QString ipath;// = new QString(); | 169 | QString ipath;// = new QString(); |
154 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 170 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
155 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 171 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
156 | mText = "<table width=\"100%\">\n"; | 172 | mText = "<table width=\"100%\">\n"; |
157 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 173 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
158 | #ifdef DESKTOP_VERSION | 174 | #ifdef DESKTOP_VERSION |
159 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 175 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
160 | #else | 176 | #else |
161 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 177 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
162 | #endif | 178 | #endif |
@@ -629,80 +645,81 @@ bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | |||
629 | QString year = ""; | 645 | QString year = ""; |
630 | int ye = ((Todo*)ev)->dtDue().date().year(); | 646 | int ye = ((Todo*)ev)->dtDue().date().year(); |
631 | if ( QDateTime::currentDateTime().date().year() != ye ) | 647 | if ( QDateTime::currentDateTime().date().year() != ye ) |
632 | year = QString::number( ye ); | 648 | year = QString::number( ye ); |
633 | QString dfs = KGlobal::locale()->dateFormatShort(); | 649 | QString dfs = KGlobal::locale()->dateFormatShort(); |
634 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 650 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
635 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 651 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
636 | KGlobal::locale()->setDateFormatShort(dfs); | 652 | KGlobal::locale()->setDateFormatShort(dfs); |
637 | } | 653 | } |
638 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 654 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
639 | if ( !ev->location().isEmpty() ) | 655 | if ( !ev->location().isEmpty() ) |
640 | mText += " ("+ev->location() +")"; | 656 | mText += " ("+ev->location() +")"; |
641 | if ( !isSub ) { | 657 | if ( !isSub ) { |
642 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 658 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
643 | mText += " ["+ev->relatedTo()->summary() +"]"; | 659 | mText += " ["+ev->relatedTo()->summary() +"]"; |
644 | mText += "</p>\n"; | 660 | mText += "</p>\n"; |
645 | } | 661 | } |
646 | else { | 662 | else { |
647 | ind += "-"; | 663 | ind += "-"; |
648 | mText += "</li>\n"; | 664 | mText += "</li>\n"; |
649 | } | 665 | } |
650 | QPtrList<Incidence> Relations = ev->relations(); | 666 | QPtrList<Incidence> Relations = ev->relations(); |
651 | Incidence *to; | 667 | Incidence *to; |
652 | for (to=Relations.first();to;to=Relations.next()) { | 668 | for (to=Relations.first();to;to=Relations.next()) { |
653 | if (!((Todo*)to)->isCompleted()) | 669 | if (!((Todo*)to)->isCompleted()) |
654 | appendTodo( to, ind , true ); | 670 | appendTodo( to, ind , true ); |
655 | } | 671 | } |
656 | 672 | ||
657 | return true; | 673 | return true; |
658 | } | 674 | } |
659 | 675 | ||
660 | /* | 676 | /* |
661 | void KOWhatsNextView::createEventViewer() | 677 | void KOWhatsNextView::createEventViewer() |
662 | { | 678 | { |
663 | if (!mEventViewer) { | 679 | if (!mEventViewer) { |
664 | 680 | ||
665 | mEventViewer = new KOEventViewerDialog(this); | 681 | mEventViewer = new KOEventViewerDialog(this); |
666 | } | 682 | } |
667 | } | 683 | } |
668 | */ | 684 | */ |
669 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 685 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
670 | { | 686 | { |
671 | mEventViewer = v; | 687 | mEventViewer = v; |
672 | } | 688 | } |
673 | 689 | ||
674 | // TODO: Create this function in CalendarView and remove it from here | 690 | // TODO: Create this function in CalendarView and remove it from here |
675 | void KOWhatsNextView::showIncidence(const QString &uid) | 691 | void KOWhatsNextView::showIncidence(const QString &uid) |
676 | { | 692 | { |
693 | |||
677 | if ( !mEventViewer ) { | 694 | if ( !mEventViewer ) { |
678 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 695 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
679 | return; | 696 | return; |
680 | } | 697 | } |
681 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 698 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
682 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 699 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
683 | if (uid.startsWith("event:")) { | 700 | if (uid.startsWith("event:")) { |
684 | #ifdef DESKTOP_VERSION | 701 | #ifdef DESKTOP_VERSION |
685 | Event *event = calendar()->event(uid.mid(8)); | 702 | Event *event = calendar()->event(uid.mid(8)); |
686 | #else | 703 | #else |
687 | Event *event = calendar()->event(uid.mid(6)); | 704 | Event *event = calendar()->event(uid.mid(6)); |
688 | #endif | 705 | #endif |
689 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 706 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
690 | if (!event) return; | 707 | if (!event) return; |
691 | //createEventViewer(); | 708 | //createEventViewer(); |
692 | mEventViewer->setEvent(event); | 709 | mEventViewer->setEvent(event); |
693 | } else if (uid.startsWith("todo:")) { | 710 | } else if (uid.startsWith("todo:")) { |
694 | #ifdef DESKTOP_VERSION | 711 | #ifdef DESKTOP_VERSION |
695 | Todo *todo = calendar()->todo(uid.mid(7)); | 712 | Todo *todo = calendar()->todo(uid.mid(7)); |
696 | #else | 713 | #else |
697 | Todo *todo = calendar()->todo(uid.mid(5)); | 714 | Todo *todo = calendar()->todo(uid.mid(5)); |
698 | #endif | 715 | #endif |
699 | if (!todo) return; | 716 | if (!todo) return; |
700 | //createEventViewer(); | 717 | //createEventViewer(); |
701 | mEventViewer->setTodo(todo); | 718 | mEventViewer->setTodo(todo); |
702 | } else { | 719 | } else { |
703 | return; | 720 | return; |
704 | 721 | ||
705 | } | 722 | } |
706 | mEventViewer->showMe(); | 723 | mEventViewer->showMe(); |
707 | mEventViewer->raise(); | 724 | mEventViewer->raise(); |
708 | } | 725 | } |