Diffstat (limited to 'korganizer/koviewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koviewmanager.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index ba3bc05..4057ae0 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -15,240 +15,242 @@ | |||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | |||
64 | lastMode = 0; | ||
65 | lastCount = 0; | ||
66 | lastNDMode = false; | ||
67 | selecteddatescount = 0; | ||
68 | selecteddate = QDate ( 2000, 1, 1 ); | ||
69 | baseCycleDate = QDate ( 2000, 1, 1 ); | ||
63 | mCurrentView = 0; | 70 | mCurrentView = 0; |
64 | flagResetViewChangeDate = 0; | 71 | flagResetViewChangeDate = 0; |
65 | mWhatsNextView = 0; | 72 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 73 | mTodoView = 0; |
67 | mAgendaView = 0; | 74 | mAgendaView = 0; |
68 | mMonthView = 0; | 75 | mMonthView = 0; |
69 | mListView = 0; | 76 | mListView = 0; |
70 | mJournalView = 0; | 77 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 78 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 79 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 80 | mFlagShowNextxDays = false; |
74 | } | 81 | } |
75 | 82 | ||
76 | KOViewManager::~KOViewManager() | 83 | KOViewManager::~KOViewManager() |
77 | { | 84 | { |
78 | } | 85 | } |
79 | 86 | ||
80 | 87 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 88 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 89 | { |
83 | return mCurrentView; | 90 | return mCurrentView; |
84 | } | 91 | } |
85 | 92 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 93 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 94 | { |
88 | config->setGroup("General"); | 95 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 96 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 97 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") { | 98 | else if (view == "Month") { |
92 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 99 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
93 | showMonthView(); | 100 | showMonthView(); |
94 | else | 101 | else |
95 | showMonthViewWeek(); | 102 | showMonthViewWeek(); |
96 | } | 103 | } |
97 | else if (view == "List") showListView(); | 104 | else if (view == "List") showListView(); |
98 | else if (view == "Journal") showJournalView(); | 105 | else if (view == "Journal") showJournalView(); |
99 | else if (view == "TimeSpan") showTimeSpanView(); | 106 | else if (view == "TimeSpan") showTimeSpanView(); |
100 | else if (view == "Todo") showTodoView(); | 107 | else if (view == "Todo") showTodoView(); |
101 | else { | 108 | else { |
102 | config->setGroup( "Views" ); | 109 | config->setGroup( "Views" ); |
103 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 110 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
104 | mCurrentAgendaView = dateCount; | 111 | mCurrentAgendaView = dateCount; |
105 | showAgendaView(); | 112 | showAgendaView(); |
106 | mCurrentAgendaView = dateCount; | 113 | mCurrentAgendaView = dateCount; |
107 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
108 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); | 115 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); |
109 | #endif | 116 | #endif |
110 | } | 117 | } |
111 | } | 118 | } |
112 | 119 | ||
113 | 120 | ||
114 | void KOViewManager::showDateView( int view, QDate date) | 121 | void KOViewManager::showDateView( int view, QDate date) |
115 | { | 122 | { |
116 | static int lastMode = 0; | 123 | |
117 | static int lastCount = 0; | ||
118 | static bool lastNDMode = false; | ||
119 | static QDate lastDate; | ||
120 | //qDebug("date %d %s", view, date.toString().latin1()); | 124 | //qDebug("date %d %s", view, date.toString().latin1()); |
121 | 125 | ||
122 | if (view != 9) | 126 | if (view != 9) |
123 | lastMode = 0; | 127 | lastMode = 0; |
124 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); | 128 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); |
125 | bool savemFlagShowNextxDays = mFlagShowNextxDays; | 129 | bool savemFlagShowNextxDays = mFlagShowNextxDays; |
126 | mFlagShowNextxDays = false; | 130 | mFlagShowNextxDays = false; |
127 | if ( view == 3 ) { | 131 | if ( view == 3 ) { |
128 | //mCurrentAgendaView = 1 ; | 132 | //mCurrentAgendaView = 1 ; |
129 | lastDate = mMainView->dateNavigator()->selectedDates().first(); | 133 | lastDate = mMainView->dateNavigator()->selectedDates().first(); |
130 | lastCount = mMainView->dateNavigator()->selectedDates().count(); | 134 | lastCount = mMainView->dateNavigator()->selectedDates().count(); |
131 | lastNDMode = savemFlagShowNextxDays; | 135 | lastNDMode = savemFlagShowNextxDays; |
132 | mMainView->dateNavigator()->selectDate( date ); | 136 | mMainView->dateNavigator()->selectDate( date ); |
133 | lastMode = 1; | 137 | lastMode = 1; |
134 | mCurrentAgendaView = 1 ; | 138 | mCurrentAgendaView = 1 ; |
135 | } else if (view == 4 ) { | 139 | } else if (view == 4 ) { |
136 | mCurrentAgendaView = 7 ; | 140 | mCurrentAgendaView = 7 ; |
137 | mMainView->dateNavigator()->selectDates( date, 7 ); | 141 | mMainView->dateNavigator()->selectDates( date, 7 ); |
138 | } else if (view == 5 ) { | 142 | } else if (view == 5 ) { |
139 | mCurrentAgendaView = 14 ; | 143 | mCurrentAgendaView = 14 ; |
140 | mMainView->dateNavigator()->selectDates( date, 14); | 144 | mMainView->dateNavigator()->selectDates( date, 14); |
141 | } else if (view == 6 ) { | 145 | } else if (view == 6 ) { |
142 | resetDateSilent( date,1); | 146 | resetDateSilent( date,1); |
143 | showMonthView(); | 147 | showMonthView(); |
144 | } else if (view == 7 ) { | 148 | } else if (view == 7 ) { |
145 | mMainView->dateNavigator()->selectDate( date ); | 149 | mMainView->dateNavigator()->selectDate( date ); |
146 | showJournalView(); | 150 | showJournalView(); |
147 | } else if (view == 8 ) { | 151 | } else if (view == 8 ) { |
148 | globalFlagBlockAgenda = 1; | 152 | globalFlagBlockAgenda = 1; |
149 | if ( mCurrentAgendaView != 3 ) | 153 | if ( mCurrentAgendaView != 3 ) |
150 | mCurrentAgendaView = -1; | 154 | mCurrentAgendaView = -1; |
151 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 155 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
152 | globalFlagBlockAgenda = 2; | 156 | globalFlagBlockAgenda = 2; |
153 | mMainView->dateNavigator()->selectDates( date , | 157 | mMainView->dateNavigator()->selectDates( date , |
154 | KOPrefs::instance()->mNextXDays ); | 158 | KOPrefs::instance()->mNextXDays ); |
155 | mFlagShowNextxDays = true; | 159 | mFlagShowNextxDays = true; |
156 | mCurrentAgendaView = 3 ; | 160 | mCurrentAgendaView = 3 ; |
157 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) | 161 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) |
158 | if ( lastMode ) { | 162 | if ( lastMode ) { |
159 | mCurrentAgendaView = lastCount ; | 163 | mCurrentAgendaView = lastCount ; |
160 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); | 164 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); |
161 | mFlagShowNextxDays = lastNDMode; | 165 | mFlagShowNextxDays = lastNDMode; |
162 | if ( mFlagShowNextxDays ) { | 166 | if ( mFlagShowNextxDays ) { |
163 | mCurrentAgendaView = 3 ; | 167 | mCurrentAgendaView = 3 ; |
164 | } | 168 | } |
165 | } else | 169 | } else |
166 | showWeekView(); | 170 | showWeekView(); |
167 | } else if (view == 10) { | 171 | } else if (view == 10) { |
168 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); | 172 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); |
169 | } | 173 | } |
170 | } | 174 | } |
171 | 175 | ||
172 | 176 | ||
173 | 177 | ||
174 | void KOViewManager::writeSettings(KConfig *config) | 178 | void KOViewManager::writeSettings(KConfig *config) |
175 | { | 179 | { |
176 | config->setGroup("General"); | 180 | config->setGroup("General"); |
177 | 181 | ||
178 | QString view; | 182 | QString view; |
179 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 183 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
180 | else if (mCurrentView == mMonthView) view = "Month"; | 184 | else if (mCurrentView == mMonthView) view = "Month"; |
181 | else if (mCurrentView == mListView) view = "List"; | 185 | else if (mCurrentView == mListView) view = "List"; |
182 | else if (mCurrentView == mJournalView) view = "Journal"; | 186 | else if (mCurrentView == mJournalView) view = "Journal"; |
183 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 187 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
184 | else if (mCurrentView == mTodoView) view = "Todo"; | 188 | else if (mCurrentView == mTodoView) view = "Todo"; |
185 | else view = "Agenda"; | 189 | else view = "Agenda"; |
186 | 190 | ||
187 | config->writeEntry("Current View",view); | 191 | config->writeEntry("Current View",view); |
188 | 192 | ||
189 | if (mAgendaView) { | 193 | if (mAgendaView) { |
190 | mAgendaView->writeSettings(config); | 194 | mAgendaView->writeSettings(config); |
191 | } | 195 | } |
192 | if (mTimeSpanView) { | 196 | if (mTimeSpanView) { |
193 | mTimeSpanView->writeSettings(config); | 197 | mTimeSpanView->writeSettings(config); |
194 | } | 198 | } |
195 | if (mListView) { | 199 | if (mListView) { |
196 | mListView->writeSettings(config); | 200 | mListView->writeSettings(config); |
197 | } | 201 | } |
198 | if (mTodoView) { | 202 | if (mTodoView) { |
199 | mTodoView->saveLayout(config,"Todo View"); | 203 | mTodoView->saveLayout(config,"Todo View"); |
200 | } | 204 | } |
201 | } | 205 | } |
202 | void KOViewManager::showNextView() | 206 | void KOViewManager::showNextView() |
203 | { | 207 | { |
204 | static int selecteddatescount = 0; | 208 | |
205 | static QDate selecteddate = QDate ( 2000, 1, 1 ); | ||
206 | static QDate baseCycleDate = QDate ( 2000, 1, 1 ); | ||
207 | int newCount = mMainView->dateNavigator()->selectedDates().count(); | 209 | int newCount = mMainView->dateNavigator()->selectedDates().count(); |
208 | if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { | 210 | if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { |
209 | flagResetViewChangeDate = 1; | 211 | flagResetViewChangeDate = 1; |
210 | } | 212 | } |
211 | if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) | 213 | if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) |
212 | flagResetViewChangeDate = 1; | 214 | flagResetViewChangeDate = 1; |
213 | if ( flagResetViewChangeDate > 0 ) { | 215 | if ( flagResetViewChangeDate > 0 ) { |
214 | baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); | 216 | baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); |
215 | //qDebug("newCycle "); | 217 | //qDebug("newCycle "); |
216 | } | 218 | } |
217 | if (mCurrentView == mWhatsNextView) goto NEXT_X; | 219 | if (mCurrentView == mWhatsNextView) goto NEXT_X; |
218 | if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; | 220 | if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; |
219 | if (mCurrentView == mJournalView ) goto DAY_1; | 221 | if (mCurrentView == mJournalView ) goto DAY_1; |
220 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; | 222 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; |
221 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; | 223 | if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; |
222 | if (mCurrentView == mAgendaView ) goto DAY_6; | 224 | if (mCurrentView == mAgendaView ) goto DAY_6; |
223 | if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; | 225 | if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; |
224 | if (mCurrentView == mMonthView ) goto LIST; | 226 | if (mCurrentView == mMonthView ) goto LIST; |
225 | if (mCurrentView == mListView ) goto TODO; | 227 | if (mCurrentView == mListView ) goto TODO; |
226 | // if (mCurrentView == mTodoView ) goto NEXT; | 228 | // if (mCurrentView == mTodoView ) goto NEXT; |
227 | NEXT: | 229 | NEXT: |
228 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} | 230 | if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} |
229 | NEXT_X: | 231 | NEXT_X: |
230 | if ( KOPrefs::instance()->mShowIconNextDays ) { | 232 | if ( KOPrefs::instance()->mShowIconNextDays ) { |
231 | showNextXView(); | 233 | showNextXView(); |
232 | goto ENTE ; | 234 | goto ENTE ; |
233 | } | 235 | } |
234 | JOURNAL: | 236 | JOURNAL: |
235 | if ( KOPrefs::instance()->mShowIconJournal ) { | 237 | if ( KOPrefs::instance()->mShowIconJournal ) { |
236 | resetDateSilent( baseCycleDate , 1 ); | 238 | resetDateSilent( baseCycleDate , 1 ); |
237 | showJournalView() ;goto ENTE ;} | 239 | showJournalView() ;goto ENTE ;} |
238 | DAY_1: | 240 | DAY_1: |
239 | if ( KOPrefs::instance()->mShowIconDay1 ) { | 241 | if ( KOPrefs::instance()->mShowIconDay1 ) { |
240 | resetDateSilent( baseCycleDate , 2 ); | 242 | resetDateSilent( baseCycleDate , 2 ); |
241 | showDayView() ;goto ENTE ;} | 243 | showDayView() ;goto ENTE ;} |
242 | DAY_5: | 244 | DAY_5: |
243 | if ( KOPrefs::instance()->mShowIconDay5 ) { | 245 | if ( KOPrefs::instance()->mShowIconDay5 ) { |
244 | resetDateSilent( baseCycleDate , 2 ); | 246 | resetDateSilent( baseCycleDate , 2 ); |
245 | showWorkWeekView() ;goto ENTE ;} | 247 | showWorkWeekView() ;goto ENTE ;} |
246 | DAY_7: | 248 | DAY_7: |
247 | if ( KOPrefs::instance()->mShowIconDay7 ) { | 249 | if ( KOPrefs::instance()->mShowIconDay7 ) { |
248 | resetDateSilent( baseCycleDate , 2 ); | 250 | resetDateSilent( baseCycleDate , 2 ); |
249 | showWeekView();goto ENTE ;} | 251 | showWeekView();goto ENTE ;} |
250 | DAY_6: | 252 | DAY_6: |
251 | if ( KOPrefs::instance()->mShowIconDay6 ) { | 253 | if ( KOPrefs::instance()->mShowIconDay6 ) { |
252 | resetDateSilent( baseCycleDate , 2 ); | 254 | resetDateSilent( baseCycleDate , 2 ); |
253 | showMonthViewWeek();goto ENTE ;} | 255 | showMonthViewWeek();goto ENTE ;} |
254 | MONTH: | 256 | MONTH: |