author | zautrix <zautrix> | 2005-08-05 19:37:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-05 19:37:52 (UTC) |
commit | 6bf157dca5ab703c7f1674c117cc62d9675f4bde (patch) (unidiff) | |
tree | 3f9df43dab51dfc409779bb31085b7bcbeee16ff | |
parent | 78ae7e3faed42b510f4f0a60007115756cd06128 (diff) | |
download | kdepimpi-6bf157dca5ab703c7f1674c117cc62d9675f4bde.zip kdepimpi-6bf157dca5ab703c7f1674c117cc62d9675f4bde.tar.gz kdepimpi-6bf157dca5ab703c7f1674c117cc62d9675f4bde.tar.bz2 |
fixx
-rw-r--r-- | korganizer/kojournalview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index 0523954..a23a3b2 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp | |||
@@ -1,237 +1,241 @@ | |||
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 <qscrollview.h> | 28 | #include <qscrollview.h> |
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | #include <qhbox.h> | 30 | #include <qhbox.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | 35 | ||
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include "koprefs.h" | 38 | #include "koprefs.h" |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | 40 | ||
41 | #include <libkcal/calendar.h> | 41 | #include <libkcal/calendar.h> |
42 | 42 | ||
43 | #include "journalentry.h" | 43 | #include "journalentry.h" |
44 | 44 | ||
45 | #include "kojournalview.h" | 45 | #include "kojournalview.h" |
46 | using namespace KOrg; | 46 | using namespace KOrg; |
47 | 47 | ||
48 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, | 48 | KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, |
49 | const char *name) | 49 | const char *name) |
50 | : KOrg::BaseView(calendar, parent, name) | 50 | : KOrg::BaseView(calendar, parent, name) |
51 | { | 51 | { |
52 | mCalendar = calendar; | 52 | mCalendar = calendar; |
53 | QHBox * vb = new QHBox ( this ); | 53 | QHBox * vb = new QHBox ( this ); |
54 | QPushButton * newJournal = new QPushButton( vb ); | 54 | QPushButton * newJournal = new QPushButton( vb ); |
55 | QPixmap icon; | 55 | QPixmap icon; |
56 | if ( QApplication::desktop()->width() < 321 ) | 56 | if ( QApplication::desktop()->width() < 321 ) |
57 | icon = SmallIcon("ko16old"); | 57 | icon = SmallIcon("ko16old"); |
58 | else | 58 | else |
59 | icon = SmallIcon("ko24old"); | 59 | icon = SmallIcon("ko24old"); |
60 | newJournal->setPixmap (icon ) ; | 60 | newJournal->setPixmap (icon ) ; |
61 | int size = newJournal->sizeHint().height(); | 61 | int size = newJournal->sizeHint().height(); |
62 | newJournal->setFixedSize( size, size ); | 62 | newJournal->setFixedSize( size, size ); |
63 | mDateLabel = new QLabel ( vb ); | 63 | mDateLabel = new QLabel ( vb ); |
64 | mDateLabel->setMargin(1); | 64 | mDateLabel->setMargin(1); |
65 | mDateLabel->setAlignment(AlignCenter); | 65 | mDateLabel->setAlignment(AlignCenter); |
66 | QScrollView * sv = new QScrollView( this ); | 66 | QScrollView * sv = new QScrollView( this ); |
67 | QVBoxLayout * hbl = new QVBoxLayout( this ); | 67 | QVBoxLayout * hbl = new QVBoxLayout( this ); |
68 | hbl->addWidget( vb ); | 68 | hbl->addWidget( vb ); |
69 | hbl->addWidget( sv ); | 69 | hbl->addWidget( sv ); |
70 | parWid = new QWidget( sv->viewport() ); | 70 | parWid = new QWidget( sv->viewport() ); |
71 | sv->addChild(parWid); | 71 | sv->addChild(parWid); |
72 | sv->setResizePolicy( QScrollView:: AutoOneFit ); | 72 | sv->setResizePolicy( QScrollView:: AutoOneFit ); |
73 | mTopLayout = new QVBoxLayout(parWid); | 73 | mTopLayout = new QVBoxLayout(parWid); |
74 | connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); | 74 | connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); |
75 | getNewEntry(); | 75 | getNewEntry(); |
76 | } | 76 | } |
77 | 77 | ||
78 | KOJournalView::~KOJournalView() | 78 | KOJournalView::~KOJournalView() |
79 | { | 79 | { |
80 | } | 80 | } |
81 | 81 | ||
82 | int KOJournalView::currentDateCount() | 82 | int KOJournalView::currentDateCount() |
83 | { | 83 | { |
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | JournalEntry* KOJournalView::getNewEntry() | 86 | JournalEntry* KOJournalView::getNewEntry() |
87 | { | 87 | { |
88 | JournalEntry* Entry = new JournalEntry(mCalendar,parWid); | 88 | JournalEntry* Entry = new JournalEntry(mCalendar,parWid); |
89 | jEntries.append( Entry ); | 89 | jEntries.append( Entry ); |
90 | mTopLayout->addWidget(Entry); | 90 | mTopLayout->addWidget(Entry); |
91 | Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 91 | Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); |
92 | connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; | 92 | connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; |
93 | connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; | 93 | connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; |
94 | connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; | 94 | connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; |
95 | return Entry; | 95 | return Entry; |
96 | } | 96 | } |
97 | 97 | ||
98 | QPtrList<Incidence> KOJournalView::selectedIncidences() | 98 | QPtrList<Incidence> KOJournalView::selectedIncidences() |
99 | { | 99 | { |
100 | QPtrList<Incidence> eventList; | 100 | QPtrList<Incidence> eventList; |
101 | 101 | ||
102 | return eventList; | 102 | return eventList; |
103 | } | 103 | } |
104 | void KOJournalView::updateConfig() | 104 | void KOJournalView::updateConfig() |
105 | { | 105 | { |
106 | JournalEntry* mEntry = jEntries.first(); | 106 | JournalEntry* mEntry = jEntries.first(); |
107 | while ( mEntry ) { | 107 | while ( mEntry ) { |
108 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 108 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); |
109 | mEntry = jEntries.next(); | 109 | mEntry = jEntries.next(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | void KOJournalView::updateView() | 112 | void KOJournalView::updateView() |
113 | { | 113 | { |
114 | JournalEntry* mEntry = jEntries.first(); | 114 | JournalEntry* mEntry = jEntries.first(); |
115 | while ( mEntry ) { | 115 | while ( mEntry ) { |
116 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); | 116 | mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); |
117 | mEntry = jEntries.next(); | 117 | mEntry = jEntries.next(); |
118 | } | 118 | } |
119 | showDates( mDate, QDate() ); | 119 | showDates( mDate, QDate() ); |
120 | } | 120 | } |
121 | void KOJournalView::checkModified() | 121 | void KOJournalView::checkModified() |
122 | { | 122 | { |
123 | flushView(); | 123 | flushView(); |
124 | } | 124 | } |
125 | void KOJournalView::flushView() | 125 | void KOJournalView::flushView() |
126 | { | 126 | { |
127 | static bool ff = false; | 127 | static bool ff = false; |
128 | if ( ff ) return; | 128 | if ( ff ) return; |
129 | ff = true; | 129 | ff = true; |
130 | JournalEntry* mEntry = jEntries.first(); | 130 | JournalEntry* mEntry = jEntries.first(); |
131 | while ( mEntry ) { | 131 | while ( mEntry ) { |
132 | mEntry->flushEntry(); | 132 | mEntry->flushEntry(); |
133 | mEntry = jEntries.next(); | 133 | mEntry = jEntries.next(); |
134 | } | 134 | } |
135 | ff = false; | 135 | ff = false; |
136 | } | 136 | } |
137 | 137 | ||
138 | void KOJournalView::clearList() | 138 | void KOJournalView::clearList() |
139 | { | 139 | { |
140 | JournalEntry* mEntry = jEntries.first(); | 140 | JournalEntry* mEntry = jEntries.first(); |
141 | while ( mEntry ) { | 141 | while ( mEntry ) { |
142 | mEntry->clear(); | 142 | mEntry->clear(); |
143 | mEntry = jEntries.next(); | 143 | mEntry = jEntries.next(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | void KOJournalView::newJournal() | 146 | void KOJournalView::newJournal() |
147 | { | 147 | { |
148 | //qDebug(" KOJournalView::newJournal()"); | 148 | //qDebug(" KOJournalView::newJournal()"); |
149 | flushView(); | 149 | flushView(); |
150 | Journal* mJournal = new Journal; | 150 | Journal* mJournal = new Journal; |
151 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 151 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
152 | mCalendar->addJournal(mJournal); | 152 | mCalendar->addJournal(mJournal); |
153 | showDates( mDate, QDate() ); | 153 | showDates( mDate, QDate() ); |
154 | } | 154 | } |
155 | 155 | ||
156 | void KOJournalView::showOnly ( Journal* j ) | 156 | void KOJournalView::showOnly ( Journal* j ) |
157 | { | 157 | { |
158 | //qDebug("showOnly %x ", j); | 158 | //qDebug("showOnly %x ", j); |
159 | flushView(); | 159 | flushView(); |
160 | if ( j == 0 ) { | 160 | if ( j == 0 ) { |
161 | showDates( mDate, QDate() ); | 161 | showDates( mDate, QDate() ); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | QPtrList<Journal> jl; | 164 | QPtrList<Journal> jl; |
165 | jl.append ( j ); | 165 | jl.append ( j ); |
166 | showList( jl ); | 166 | showList( jl ); |
167 | JournalEntry* mEntry = jEntries.first(); | 167 | JournalEntry* mEntry = jEntries.first(); |
168 | mEntry->setShowOnly(); | 168 | mEntry->setShowOnly(); |
169 | } | 169 | } |
170 | void KOJournalView::showList(QPtrList<Journal> jl) | 170 | void KOJournalView::showList(QPtrList<Journal> jl) |
171 | { | 171 | { |
172 | static bool ff = false; | ||
173 | if ( ff ) return; | ||
174 | ff = true; | ||
172 | //qDebug("KOJournalView::showList %d",jl.count() ); | 175 | //qDebug("KOJournalView::showList %d",jl.count() ); |
173 | JournalEntry* mEntry = jEntries.first(); | 176 | JournalEntry* mEntry = jEntries.first(); |
174 | JournalEntry* firstEntry = mEntry; | 177 | JournalEntry* firstEntry = mEntry; |
175 | int count = jl.count(); | 178 | int count = jl.count(); |
176 | int iii = 0; | 179 | int iii = 0; |
177 | while ( iii < count ) { | 180 | while ( iii < count ) { |
178 | if ( !mEntry ) { | 181 | if ( !mEntry ) { |
179 | mEntry = getNewEntry(); | 182 | mEntry = getNewEntry(); |
180 | mEntry->setVisibleMode( true ); | 183 | mEntry->setVisibleMode( true ); |
181 | mEntry->setDate(mDate); | 184 | mEntry->setDate(mDate); |
182 | mEntry->setJournal(jl.at(iii), false); | 185 | mEntry->setJournal(jl.at(iii), false); |
183 | mEntry->setVisibleMode( true ); | 186 | mEntry->setVisibleMode( true ); |
184 | mEntry->show(); | 187 | mEntry->show(); |
185 | mEntry = 0; | 188 | mEntry = 0; |
186 | } else { | 189 | } else { |
187 | mEntry->setVisibleMode( true ); | 190 | mEntry->setVisibleMode( true ); |
188 | mEntry->setDate(mDate); | 191 | mEntry->setDate(mDate); |
189 | mEntry->setJournal(jl.at(iii), false); | 192 | mEntry->setJournal(jl.at(iii), false); |
190 | mEntry->setVisibleMode( true ); | 193 | mEntry->setVisibleMode( true ); |
191 | mEntry->show(); | 194 | mEntry->show(); |
192 | mEntry = jEntries.next(); | 195 | mEntry = jEntries.next(); |
193 | } | 196 | } |
194 | ++iii; | 197 | ++iii; |
195 | } | 198 | } |
196 | while ( mEntry ) { | 199 | while ( mEntry ) { |
197 | mEntry->setDate(mDate); | 200 | mEntry->setDate(mDate); |
198 | mEntry->clear(); | 201 | mEntry->clear(); |
199 | if ( mEntry != firstEntry ) { | 202 | if ( mEntry != firstEntry ) { |
200 | mEntry->hide(); | 203 | mEntry->hide(); |
201 | mEntry->setVisibleMode( false ); | 204 | mEntry->setVisibleMode( false ); |
202 | } | 205 | } |
203 | else { | 206 | else { |
204 | mEntry->setVisibleMode( true ); | 207 | mEntry->setVisibleMode( true ); |
205 | mEntry->show(); | 208 | mEntry->show(); |
206 | } | 209 | } |
207 | mEntry = jEntries.next(); | 210 | mEntry = jEntries.next(); |
208 | } | 211 | } |
212 | ff = false; | ||
209 | } | 213 | } |
210 | 214 | ||
211 | void KOJournalView::showDates(const QDate &start, const QDate &) | 215 | void KOJournalView::showDates(const QDate &start, const QDate &) |
212 | { | 216 | { |
213 | mDate = start; | 217 | mDate = start; |
214 | mDateLabel->setText(KGlobal::locale()->formatDate(mDate)); | 218 | mDateLabel->setText(KGlobal::locale()->formatDate(mDate)); |
215 | QPtrList<Journal> jl = calendar()->journals4Date( start ); | 219 | QPtrList<Journal> jl = calendar()->journals4Date( start ); |
216 | showList( jl ); | 220 | showList( jl ); |
217 | } | 221 | } |
218 | 222 | ||
219 | void KOJournalView::showEvents(QPtrList<Event>) | 223 | void KOJournalView::showEvents(QPtrList<Event>) |
220 | { | 224 | { |
221 | // After new creation of list view no events are selected. | 225 | // After new creation of list view no events are selected. |
222 | // emit incidenceSelected( 0 ); | 226 | // emit incidenceSelected( 0 ); |
223 | } | 227 | } |
224 | 228 | ||
225 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) | 229 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) |
226 | { | 230 | { |
227 | updateView(); | 231 | updateView(); |
228 | } | 232 | } |
229 | 233 | ||
230 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) | 234 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) |
231 | { | 235 | { |
232 | //qDebug("keyPressEven "); | 236 | //qDebug("keyPressEven "); |
233 | if ( e->state() == Qt::ControlButton ) { | 237 | if ( e->state() == Qt::ControlButton ) { |
234 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) | 238 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) |
235 | e->ignore(); | 239 | e->ignore(); |
236 | } | 240 | } |
237 | } | 241 | } |