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