Diffstat (limited to 'korganizer/kojournalview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/kojournalview.cpp | 110 |
1 files changed, 91 insertions, 19 deletions
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index bc16037..fae59d6 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp | |||
@@ -1,116 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // | 24 | // |
25 | // View of Journal entries | 25 | // View of Journal entries |
26 | 26 | ||
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | 29 | ||
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include "koprefs.h" | 32 | #include "koprefs.h" |
33 | 33 | ||
34 | #include <libkcal/calendar.h> | 34 | #include <libkcal/calendar.h> |
35 | 35 | ||
36 | #include "journalentry.h" | 36 | #include "journalentry.h" |
37 | 37 | ||
38 | #include "kojournalview.h" | 38 | #include "kojournalview.h" |
39 | using namespace KOrg; | 39 | using namespace KOrg; |
40 | 40 | ||
41 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, | 41 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, |
42 | const char *name) | 42 | const char *name) |
43 | : KOrg::BaseView(calendar, parent, name) | 43 | : KOrg::BaseView(calendar, parent, name) |
44 | { | 44 | { |
45 | mEntry = new JournalEntry(calendar,this); | 45 | mCalendar = calendar; |
46 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 46 | mTopLayout = new QVBoxLayout(this); |
47 | QBoxLayout *topLayout = new QVBoxLayout(this); | 47 | getNewEntry(); |
48 | topLayout->addWidget(mEntry); | ||
49 | connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; | ||
50 | } | 48 | } |
51 | 49 | ||
52 | KOJournalView::~KOJournalView() | 50 | KOJournalView::~KOJournalView() |
53 | { | 51 | { |
54 | } | 52 | } |
55 | 53 | ||
56 | int KOJournalView::currentDateCount() | 54 | int KOJournalView::currentDateCount() |
57 | { | 55 | { |
58 | return 0; | 56 | return 0; |
59 | } | 57 | } |
58 | JournalEntry* KOJournalView::getNewEntry() | ||
59 | { | ||
60 | JournalEntry* Entry = new JournalEntry(mCalendar,this); | ||
61 | jEntries.append( Entry ); | ||
62 | mTopLayout->addWidget(Entry); | ||
63 | Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); | ||
64 | connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; | ||
65 | connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; | ||
66 | connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; | ||
67 | return Entry; | ||
68 | } | ||
60 | 69 | ||
61 | QPtrList<Incidence> KOJournalView::selectedIncidences() | 70 | QPtrList<Incidence> KOJournalView::selectedIncidences() |
62 | { | 71 | { |
63 | QPtrList<Incidence> eventList; | 72 | QPtrList<Incidence> eventList; |
64 | 73 | ||
65 | return eventList; | 74 | return eventList; |
66 | } | 75 | } |
67 | void KOJournalView::updateConfig() | 76 | void KOJournalView::updateConfig() |
68 | { | 77 | { |
69 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 78 | JournalEntry* mEntry = jEntries.first(); |
79 | while ( mEntry ) { | ||
80 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | ||
81 | mEntry = jEntries.next(); | ||
82 | } | ||
70 | } | 83 | } |
71 | void KOJournalView::updateView() | 84 | void KOJournalView::updateView() |
72 | { | 85 | { |
73 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 86 | JournalEntry* mEntry = jEntries.first(); |
87 | while ( mEntry ) { | ||
88 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | ||
89 | mEntry = jEntries.next(); | ||
90 | } | ||
91 | showDates( mDate, QDate() ); | ||
74 | } | 92 | } |
75 | 93 | ||
76 | void KOJournalView::flushView() | 94 | void KOJournalView::flushView() |
77 | { | 95 | { |
78 | mEntry->flushEntry(); | 96 | JournalEntry* mEntry = jEntries.first(); |
97 | while ( mEntry ) { | ||
98 | mEntry->flushEntry(); | ||
99 | mEntry = jEntries.next(); | ||
100 | } | ||
79 | } | 101 | } |
80 | 102 | ||
81 | void KOJournalView::clearList() | 103 | void KOJournalView::clearList() |
82 | { | 104 | { |
83 | mEntry->clear(); | 105 | JournalEntry* mEntry = jEntries.first(); |
106 | while ( mEntry ) { | ||
107 | mEntry->clear(); | ||
108 | mEntry = jEntries.next(); | ||
109 | } | ||
84 | } | 110 | } |
85 | void KOJournalView::showDates(const QDate &start, const QDate &) | 111 | void KOJournalView::newJournal() |
86 | { | 112 | { |
87 | // kdDebug() << "KOJournalView::selectDates()" << endl; | 113 | Journal* mJournal = new Journal; |
114 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | ||
115 | mCalendar->addJournal(mJournal); | ||
116 | showDates( mDate, QDate() ); | ||
117 | } | ||
88 | 118 | ||
89 | mEntry->setDate(start); | 119 | void KOJournalView::showOnly ( Journal* j ) |
120 | { | ||
121 | if ( j == 0 ) { | ||
122 | showDates( mDate, QDate() ); | ||
123 | return; | ||
124 | } | ||
125 | QPtrList<Journal> jl; | ||
126 | jl.append ( j ); | ||
127 | showList( jl ); | ||
128 | JournalEntry* mEntry = jEntries.first(); | ||
129 | mEntry->setShowOnly(); | ||
130 | } | ||
131 | void KOJournalView::showList(QPtrList<Journal> jl) | ||
132 | { | ||
133 | JournalEntry* mEntry = jEntries.first(); | ||
134 | JournalEntry* firstEntry = mEntry; | ||
135 | int count = jl.count(); | ||
136 | int iii = 0; | ||
137 | while ( iii < count ) { | ||
138 | if ( !mEntry ) { | ||
139 | mEntry = getNewEntry(); | ||
140 | mEntry->show(); | ||
141 | mEntry->setDate(mDate); | ||
142 | mEntry->setJournal(jl.at(iii)); | ||
143 | mEntry = 0; | ||
144 | } else { | ||
145 | mEntry->setDate(mDate); | ||
146 | mEntry->setJournal(jl.at(iii)); | ||
147 | mEntry->show(); | ||
148 | mEntry = jEntries.next(); | ||
149 | } | ||
150 | ++iii; | ||
151 | } | ||
152 | while ( mEntry ) { | ||
153 | mEntry->setDate(mDate); | ||
154 | mEntry->clear(); | ||
155 | if ( mEntry != firstEntry ) | ||
156 | mEntry->hide(); | ||
157 | else | ||
158 | mEntry->show(); | ||
159 | mEntry = jEntries.next(); | ||
160 | } | ||
161 | } | ||
90 | 162 | ||
91 | Journal *j = calendar()->journal(start); | 163 | void KOJournalView::showDates(const QDate &start, const QDate &) |
92 | if (j) mEntry->setJournal(j); | 164 | { |
93 | else mEntry->clear(); | 165 | mDate = start; |
94 | 166 | QPtrList<Journal> jl = calendar()->journals4Date( start ); | |
95 | // emit incidenceSelected( 0 ); | 167 | showList( jl ); |
96 | } | 168 | } |
97 | 169 | ||
98 | void KOJournalView::showEvents(QPtrList<Event>) | 170 | void KOJournalView::showEvents(QPtrList<Event>) |
99 | { | 171 | { |
100 | // After new creation of list view no events are selected. | 172 | // After new creation of list view no events are selected. |
101 | // emit incidenceSelected( 0 ); | 173 | // emit incidenceSelected( 0 ); |
102 | } | 174 | } |
103 | 175 | ||
104 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) | 176 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) |
105 | { | 177 | { |
106 | updateView(); | 178 | updateView(); |
107 | } | 179 | } |
108 | 180 | ||
109 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) | 181 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) |
110 | { | 182 | { |
111 | //qDebug("keyPressEven "); | 183 | //qDebug("keyPressEven "); |
112 | if ( e->state() == Qt::ControlButton ) { | 184 | if ( e->state() == Qt::ControlButton ) { |
113 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) | 185 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) |
114 | e->ignore(); | 186 | e->ignore(); |
115 | } | 187 | } |
116 | } | 188 | } |