-rw-r--r-- | korganizer/mainwindow.cpp | 106 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 15 | ||||
-rw-r--r-- | microkde/kdatetbl.cpp | 1091 | ||||
-rw-r--r-- | microkde/kdatetbl.h | 63 |
4 files changed, 775 insertions, 500 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 348dd5e..119e28a 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2013 +1,2049 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "simplealarmclient.h" | 62 | #include "simplealarmclient.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #ifdef _OL_IMPORT_ | 69 | #ifdef _OL_IMPORT_ |
70 | #include "koimportoldialog.h" | 70 | #include "koimportoldialog.h" |
71 | #endif | 71 | #endif |
72 | #endif | 72 | #endif |
73 | #include "mainwindow.h" | 73 | #include "mainwindow.h" |
74 | 74 | ||
75 | |||
75 | class KOex2phonePrefs : public QDialog | 76 | class KOex2phonePrefs : public QDialog |
76 | { | 77 | { |
77 | public: | 78 | public: |
78 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 79 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
79 | QDialog( parent, name, true ) | 80 | QDialog( parent, name, true ) |
80 | { | 81 | { |
81 | setCaption( i18n("Export to phone options") ); | 82 | setCaption( i18n("Export to phone options") ); |
82 | QVBoxLayout* lay = new QVBoxLayout( this ); | 83 | QVBoxLayout* lay = new QVBoxLayout( this ); |
83 | lay->setSpacing( 3 ); | 84 | lay->setSpacing( 3 ); |
84 | lay->setMargin( 3 ); | 85 | lay->setMargin( 3 ); |
85 | QLabel *lab; | 86 | QLabel *lab; |
86 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 87 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
87 | lab->setAlignment (AlignHCenter ); | 88 | lab->setAlignment (AlignHCenter ); |
88 | QHBox* temphb; | 89 | QHBox* temphb; |
89 | temphb = new QHBox( this ); | 90 | temphb = new QHBox( this ); |
90 | new QLabel( i18n("I/O device: "), temphb ); | 91 | new QLabel( i18n("I/O device: "), temphb ); |
91 | mPhoneDevice = new QLineEdit( temphb); | 92 | mPhoneDevice = new QLineEdit( temphb); |
92 | lay->addWidget( temphb ); | 93 | lay->addWidget( temphb ); |
93 | temphb = new QHBox( this ); | 94 | temphb = new QHBox( this ); |
94 | new QLabel( i18n("Connection: "), temphb ); | 95 | new QLabel( i18n("Connection: "), temphb ); |
95 | mPhoneConnection = new QLineEdit( temphb); | 96 | mPhoneConnection = new QLineEdit( temphb); |
96 | lay->addWidget( temphb ); | 97 | lay->addWidget( temphb ); |
97 | temphb = new QHBox( this ); | 98 | temphb = new QHBox( this ); |
98 | new QLabel( i18n("Model(opt.): "), temphb ); | 99 | new QLabel( i18n("Model(opt.): "), temphb ); |
99 | mPhoneModel = new QLineEdit( temphb); | 100 | mPhoneModel = new QLineEdit( temphb); |
100 | lay->addWidget( temphb ); | 101 | lay->addWidget( temphb ); |
101 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 102 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
102 | mWriteBackFuture->setChecked( true ); | 103 | mWriteBackFuture->setChecked( true ); |
103 | lay->addWidget( mWriteBackFuture ); | 104 | lay->addWidget( mWriteBackFuture ); |
104 | temphb = new QHBox( this ); | 105 | temphb = new QHBox( this ); |
105 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 106 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
106 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 107 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
107 | mWriteBackFutureWeeks->setValue( 8 ); | 108 | mWriteBackFutureWeeks->setValue( 8 ); |
108 | lay->addWidget( temphb ); | 109 | lay->addWidget( temphb ); |
109 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 110 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
110 | lab->setAlignment (AlignHCenter ); | 111 | lab->setAlignment (AlignHCenter ); |
111 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 112 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
112 | lay->addWidget( ok ); | 113 | lay->addWidget( ok ); |
113 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 114 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
114 | lay->addWidget( cancel ); | 115 | lay->addWidget( cancel ); |
115 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 116 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
116 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 117 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
117 | resize( 220, 240 ); | 118 | resize( 220, 240 ); |
118 | qApp->processEvents(); | 119 | qApp->processEvents(); |
119 | int dw = QApplication::desktop()->width(); | 120 | int dw = QApplication::desktop()->width(); |
120 | int dh = QApplication::desktop()->height(); | 121 | int dh = QApplication::desktop()->height(); |
121 | move( (dw-width())/2, (dh - height() )/2 ); | 122 | move( (dw-width())/2, (dh - height() )/2 ); |
122 | } | 123 | } |
123 | 124 | ||
124 | public: | 125 | public: |
125 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 126 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
126 | QCheckBox* mWriteBackFuture; | 127 | QCheckBox* mWriteBackFuture; |
127 | QSpinBox* mWriteBackFutureWeeks; | 128 | QSpinBox* mWriteBackFutureWeeks; |
128 | }; | 129 | }; |
129 | 130 | ||
130 | int globalFlagBlockStartup; | 131 | int globalFlagBlockStartup; |
131 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 132 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
132 | QMainWindow( parent, name ) | 133 | QMainWindow( parent, name ) |
133 | { | 134 | { |
134 | 135 | ||
135 | 136 | ||
136 | #ifdef DESKTOP_VERSION | 137 | #ifdef DESKTOP_VERSION |
137 | setFont( QFont("Arial"), 14 ); | 138 | setFont( QFont("Arial"), 14 ); |
138 | #endif | 139 | #endif |
139 | mClosed = false; | 140 | mClosed = false; |
140 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 141 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
141 | QString confFile = locateLocal("config","korganizerrc"); | 142 | QString confFile = locateLocal("config","korganizerrc"); |
142 | QFileInfo finf ( confFile ); | 143 | QFileInfo finf ( confFile ); |
143 | bool showWarning = !finf.exists(); | 144 | bool showWarning = !finf.exists(); |
144 | setIcon(SmallIcon( "ko24" ) ); | 145 | setIcon(SmallIcon( "ko24" ) ); |
145 | mBlockAtStartup = true; | 146 | mBlockAtStartup = true; |
146 | mFlagKeyPressed = false; | 147 | mFlagKeyPressed = false; |
148 | setCaption("KOrganizer/Pi"); | ||
147 | KOPrefs *p = KOPrefs::instance(); | 149 | KOPrefs *p = KOPrefs::instance(); |
148 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 150 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
149 | if ( p->mHourSize > 18 ) | 151 | if ( p->mHourSize > 22 ) |
150 | p->mHourSize = 18; | 152 | p->mHourSize = 22; |
151 | QMainWindow::ToolBarDock tbd; | 153 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 154 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 155 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 156 | tbd = Bottom; |
155 | else | 157 | else |
156 | tbd = Top; | 158 | tbd = Top; |
157 | } | 159 | } |
158 | else { | 160 | else { |
159 | if ( p->mToolBarUp ) | 161 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 162 | tbd = Right; |
161 | else | 163 | else |
162 | tbd = Left; | 164 | tbd = Left; |
163 | } | 165 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 166 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 167 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 168 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 169 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 170 | addToolBar (iconToolBar , tbd ); |
169 | mCalendarModifiedFlag = false; | 171 | mCalendarModifiedFlag = false; |
170 | |||
171 | setCaption("KOrganizer/Pi"); | ||
172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
173 | splash->setAlignment ( AlignCenter ); | 173 | splash->setAlignment ( AlignCenter ); |
174 | setCentralWidget( splash ); | 174 | setCentralWidget( splash ); |
175 | #ifndef DESKTOP_VERSION | 175 | #ifndef DESKTOP_VERSION |
176 | showMaximized(); | 176 | showMaximized(); |
177 | #endif | 177 | #endif |
178 | 178 | ||
179 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 179 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
180 | setDefaultPreferences(); | 180 | setDefaultPreferences(); |
181 | mCalendar = new CalendarLocal(); | 181 | mCalendar = new CalendarLocal(); |
182 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 182 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
183 | mView->hide(); | 183 | mView->hide(); |
184 | //mView->resize(splash->size() ); | 184 | //mView->resize(splash->size() ); |
185 | initActions(); | 185 | initActions(); |
186 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 186 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
187 | mSyncManager->setBlockSave(false); | 187 | mSyncManager->setBlockSave(false); |
188 | mView->setSyncManager(mSyncManager); | 188 | mView->setSyncManager(mSyncManager); |
189 | #ifndef DESKTOP_VERSION | 189 | #ifndef DESKTOP_VERSION |
190 | iconToolBar->show(); | 190 | iconToolBar->show(); |
191 | qApp->processEvents(); | 191 | qApp->processEvents(); |
192 | #endif | 192 | #endif |
193 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 193 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
194 | int vh = height() ; | 194 | int vh = height() ; |
195 | int vw = width(); | 195 | int vw = width(); |
196 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 196 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
197 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 197 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
198 | vh -= iconToolBar->height(); | 198 | vh -= iconToolBar->height(); |
199 | } else { | 199 | } else { |
200 | vw -= iconToolBar->height(); | 200 | vw -= iconToolBar->height(); |
201 | } | 201 | } |
202 | //mView->setMaximumSize( splash->size() ); | 202 | //mView->setMaximumSize( splash->size() ); |
203 | //mView->resize( splash->size() ); | 203 | //mView->resize( splash->size() ); |
204 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 204 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
205 | mView->readSettings(); | 205 | mView->readSettings(); |
206 | bool newFile = false; | 206 | bool newFile = false; |
207 | if( !QFile::exists( defaultFileName() ) ) { | 207 | if( !QFile::exists( defaultFileName() ) ) { |
208 | QFileInfo finfo ( defaultFileName() ); | 208 | QFileInfo finfo ( defaultFileName() ); |
209 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 209 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
210 | qDebug("oldfile %s ", oldFile.latin1()); | 210 | qDebug("oldfile %s ", oldFile.latin1()); |
211 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 211 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
212 | finfo.setFile( oldFile ); | 212 | finfo.setFile( oldFile ); |
213 | if (finfo.exists() ) { | 213 | if (finfo.exists() ) { |
214 | KMessageBox::information( this, message); | 214 | KMessageBox::information( this, message); |
215 | mView->openCalendar( oldFile ); | 215 | mView->openCalendar( oldFile ); |
216 | qApp->processEvents(); | 216 | qApp->processEvents(); |
217 | } else { | 217 | } else { |
218 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 218 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
219 | finfo.setFile( oldFile ); | 219 | finfo.setFile( oldFile ); |
220 | if (finfo.exists() ) { | 220 | if (finfo.exists() ) { |
221 | KMessageBox::information( this, message); | 221 | KMessageBox::information( this, message); |
222 | mView->openCalendar( oldFile ); | 222 | mView->openCalendar( oldFile ); |
223 | qApp->processEvents(); | 223 | qApp->processEvents(); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | mView->saveCalendar( defaultFileName() ); | 226 | mView->saveCalendar( defaultFileName() ); |
227 | newFile = true; | 227 | newFile = true; |
228 | } | 228 | } |
229 | 229 | ||
230 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 230 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
231 | mView->openCalendar( defaultFileName() ); | 231 | mView->openCalendar( defaultFileName() ); |
232 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 232 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
233 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 233 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
234 | 234 | ||
235 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 235 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
236 | KOPrefs::instance()->setAllDefaults(); | 236 | KOPrefs::instance()->setAllDefaults(); |
237 | int count = mView->addCategories(); | 237 | int count = mView->addCategories(); |
238 | } | 238 | } |
239 | processIncidenceSelection( 0 ); | 239 | processIncidenceSelection( 0 ); |
240 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 240 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
241 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 241 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
242 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 242 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
243 | SLOT( slotModifiedChanged( bool ) ) ); | 243 | SLOT( slotModifiedChanged( bool ) ) ); |
244 | 244 | ||
245 | 245 | ||
246 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 246 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
247 | SLOT( disableBR(bool) ) ); | 247 | SLOT( disableBR(bool) ) ); |
248 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 248 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
249 | mView->setModified( false ); | 249 | mView->setModified( false ); |
250 | mBlockAtStartup = false; | 250 | mBlockAtStartup = false; |
251 | mView->setModified( false ); | 251 | mView->setModified( false ); |
252 | setCentralWidget( mView ); | 252 | setCentralWidget( mView ); |
253 | globalFlagBlockStartup = 0; | 253 | globalFlagBlockStartup = 0; |
254 | mView->show(); | 254 | mView->show(); |
255 | delete splash; | 255 | delete splash; |
256 | if ( newFile ) | 256 | if ( newFile ) |
257 | mView->updateConfig(); | 257 | mView->updateConfig(); |
258 | // qApp->processEvents(); | 258 | // qApp->processEvents(); |
259 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 259 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
260 | //fillSyncMenu(); | 260 | //fillSyncMenu(); |
261 | 261 | ||
262 | 262 | ||
263 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 263 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
264 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 264 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
265 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 265 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
266 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 266 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
267 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 267 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
268 | mSyncManager->setDefaultFileName( defaultFileName()); | 268 | mSyncManager->setDefaultFileName( defaultFileName()); |
269 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 269 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
270 | mSyncManager->fillSyncMenu(); | 270 | mSyncManager->fillSyncMenu(); |
271 | 271 | ||
272 | 272 | ||
273 | 273 | ||
274 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 274 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
275 | if ( showWarning ) { | 275 | if ( showWarning ) { |
276 | KMessageBox::information( this, | 276 | KMessageBox::information( this, |
277 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 277 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
278 | qApp->processEvents(); | 278 | qApp->processEvents(); |
279 | mView->dialogManager()->showSyncOptions(); | 279 | mView->dialogManager()->showSyncOptions(); |
280 | } | 280 | } |
281 | 281 | ||
282 | //US listen for result adressed from Ka/Pi | 282 | //US listen for result adressed from Ka/Pi |
283 | #ifndef DESKTOP_VERSION | 283 | #ifndef DESKTOP_VERSION |
284 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 284 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
285 | #endif | 285 | #endif |
286 | #ifndef DESKTOP_VERSION | 286 | #ifndef DESKTOP_VERSION |
287 | infrared = 0; | 287 | infrared = 0; |
288 | #endif | 288 | #endif |
289 | updateWeek( mView->startDate() ); | 289 | updateWeek( mView->startDate() ); |
290 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 290 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
291 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 291 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
292 | mBRdisabled = false; | 292 | mBRdisabled = false; |
293 | //toggleBeamReceive(); | 293 | //toggleBeamReceive(); |
294 | } | 294 | } |
295 | MainWindow::~MainWindow() | 295 | MainWindow::~MainWindow() |
296 | { | 296 | { |
297 | //qDebug("MainWindow::~MainWindow() "); | 297 | //qDebug("MainWindow::~MainWindow() "); |
298 | //save toolbar location | 298 | //save toolbar location |
299 | delete mCalendar; | 299 | delete mCalendar; |
300 | delete mSyncManager; | 300 | delete mSyncManager; |
301 | #ifndef DESKTOP_VERSION | 301 | #ifndef DESKTOP_VERSION |
302 | if ( infrared ) | 302 | if ( infrared ) |
303 | delete infrared; | 303 | delete infrared; |
304 | #endif | 304 | #endif |
305 | 305 | ||
306 | 306 | ||
307 | } | 307 | } |
308 | 308 | ||
309 | void MainWindow::disableBR(bool b) | 309 | void MainWindow::disableBR(bool b) |
310 | { | 310 | { |
311 | #ifndef DESKTOP_VERSION | 311 | #ifndef DESKTOP_VERSION |
312 | if ( b ) { | 312 | if ( b ) { |
313 | if ( infrared ) { | 313 | if ( infrared ) { |
314 | toggleBeamReceive(); | 314 | toggleBeamReceive(); |
315 | mBRdisabled = true; | 315 | mBRdisabled = true; |
316 | } | 316 | } |
317 | mBRdisabled = true; | 317 | mBRdisabled = true; |
318 | } else { | 318 | } else { |
319 | if ( mBRdisabled ) { | 319 | if ( mBRdisabled ) { |
320 | mBRdisabled = false; | 320 | mBRdisabled = false; |
321 | //makes no sense,because other cal ap is probably running | 321 | //makes no sense,because other cal ap is probably running |
322 | // toggleBeamReceive(); | 322 | // toggleBeamReceive(); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | #endif | 325 | #endif |
326 | 326 | ||
327 | } | 327 | } |
328 | bool MainWindow::beamReceiveEnabled() | 328 | bool MainWindow::beamReceiveEnabled() |
329 | { | 329 | { |
330 | #ifndef DESKTOP_VERSION | 330 | #ifndef DESKTOP_VERSION |
331 | return ( infrared != 0 ); | 331 | return ( infrared != 0 ); |
332 | #endif | 332 | #endif |
333 | return false; | 333 | return false; |
334 | } | 334 | } |
335 | 335 | ||
336 | void MainWindow::toggleBeamReceive() | 336 | void MainWindow::toggleBeamReceive() |
337 | { | 337 | { |
338 | if ( mBRdisabled ) | 338 | if ( mBRdisabled ) |
339 | return; | 339 | return; |
340 | #ifndef DESKTOP_VERSION | 340 | #ifndef DESKTOP_VERSION |
341 | if ( infrared ) { | 341 | if ( infrared ) { |
342 | qDebug("disable BeamReceive "); | 342 | qDebug("disable BeamReceive "); |
343 | delete infrared; | 343 | delete infrared; |
344 | infrared = 0; | 344 | infrared = 0; |
345 | brAction->setOn(false); | 345 | brAction->setOn(false); |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | qDebug("enable BeamReceive "); | 348 | qDebug("enable BeamReceive "); |
349 | brAction->setOn(true); | 349 | brAction->setOn(true); |
350 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 350 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
351 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 351 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
352 | #endif | 352 | #endif |
353 | } | 353 | } |
354 | void MainWindow::showMaximized () | 354 | void MainWindow::showMaximized () |
355 | { | 355 | { |
356 | #ifndef DESKTOP_VERSION | 356 | #ifndef DESKTOP_VERSION |
357 | if ( ! globalFlagBlockStartup ) | 357 | if ( ! globalFlagBlockStartup ) |
358 | if ( mClosed ) | 358 | if ( mClosed ) |
359 | mView->goToday(); | 359 | mView->goToday(); |
360 | #endif | 360 | #endif |
361 | QWidget::showMaximized () ; | 361 | QWidget::showMaximized () ; |
362 | mClosed = false; | 362 | mClosed = false; |
363 | } | 363 | } |
364 | void MainWindow::closeEvent( QCloseEvent* ce ) | 364 | void MainWindow::closeEvent( QCloseEvent* ce ) |
365 | { | 365 | { |
366 | 366 | ||
367 | 367 | ||
368 | 368 | ||
369 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 369 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
370 | saveOnClose(); | 370 | saveOnClose(); |
371 | mClosed = true; | 371 | mClosed = true; |
372 | ce->accept(); | 372 | ce->accept(); |
373 | return; | 373 | return; |
374 | 374 | ||
375 | } | 375 | } |
376 | 376 | ||
377 | switch( QMessageBox::information( this, "KO/Pi", | 377 | switch( QMessageBox::information( this, "KO/Pi", |
378 | i18n("Do you really want\nto close KO/Pi?"), | 378 | i18n("Do you really want\nto close KO/Pi?"), |
379 | i18n("Close"), i18n("No"), | 379 | i18n("Close"), i18n("No"), |
380 | 0, 0 ) ) { | 380 | 0, 0 ) ) { |
381 | case 0: | 381 | case 0: |
382 | saveOnClose(); | 382 | saveOnClose(); |
383 | mClosed = true; | 383 | mClosed = true; |
384 | ce->accept(); | 384 | ce->accept(); |
385 | break; | 385 | break; |
386 | case 1: | 386 | case 1: |
387 | ce->ignore(); | 387 | ce->ignore(); |
388 | break; | 388 | break; |
389 | case 2: | 389 | case 2: |
390 | 390 | ||
391 | default: | 391 | default: |
392 | break; | 392 | break; |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 398 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
399 | { | 399 | { |
400 | QDataStream stream( data, IO_ReadOnly ); | 400 | QDataStream stream( data, IO_ReadOnly ); |
401 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 401 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
402 | //QString datamess; | 402 | //QString datamess; |
403 | //qDebug("message "); | 403 | //qDebug("message "); |
404 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 404 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
405 | 405 | ||
406 | if ( cmsg == "setDocument(QString)" ) { | 406 | if ( cmsg == "setDocument(QString)" ) { |
407 | QDataStream stream( data, IO_ReadOnly ); | 407 | QDataStream stream( data, IO_ReadOnly ); |
408 | QString fileName; | 408 | QString fileName; |
409 | stream >> fileName; | 409 | stream >> fileName; |
410 | //qDebug("filename %s ", fileName.latin1()); | 410 | //qDebug("filename %s ", fileName.latin1()); |
411 | showMaximized(); | 411 | showMaximized(); |
412 | raise(); | 412 | raise(); |
413 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 413 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
414 | mSyncManager->slotSyncMenu( 1002 ); | 414 | mSyncManager->slotSyncMenu( 1002 ); |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | 417 | ||
418 | if ( cmsg == "-writeFile" ) { | 418 | if ( cmsg == "-writeFile" ) { |
419 | // I made from the "-writeFile" an "-writeAlarm" | 419 | // I made from the "-writeFile" an "-writeAlarm" |
420 | mView->viewManager()->showWhatsNextView(); | 420 | mView->viewManager()->showWhatsNextView(); |
421 | mCalendar->checkAlarmForIncidence( 0, true); | 421 | mCalendar->checkAlarmForIncidence( 0, true); |
422 | showMaximized(); | 422 | showMaximized(); |
423 | raise(); | 423 | raise(); |
424 | return; | 424 | return; |
425 | 425 | ||
426 | } | 426 | } |
427 | if ( cmsg == "-writeFileSilent" ) { | 427 | if ( cmsg == "-writeFileSilent" ) { |
428 | // I made from the "-writeFile" an "-writeAlarm" | 428 | // I made from the "-writeFile" an "-writeAlarm" |
429 | // mView->viewManager()->showWhatsNextView(); | 429 | // mView->viewManager()->showWhatsNextView(); |
430 | mCalendar->checkAlarmForIncidence( 0, true); | 430 | mCalendar->checkAlarmForIncidence( 0, true); |
431 | //showMaximized(); | 431 | //showMaximized(); |
432 | //raise(); | 432 | //raise(); |
433 | hide(); | 433 | hide(); |
434 | return; | 434 | return; |
435 | } | 435 | } |
436 | if ( cmsg == "-newCountdown" ) { | 436 | if ( cmsg == "-newCountdown" ) { |
437 | qDebug("newCountdown "); | 437 | qDebug("newCountdown "); |
438 | 438 | ||
439 | } | 439 | } |
440 | QString msg ; | 440 | QString msg ; |
441 | QString allmsg = cmsg; | 441 | QString allmsg = cmsg; |
442 | while ( allmsg.length() > 0 ) { | 442 | while ( allmsg.length() > 0 ) { |
443 | int nextC = allmsg.find( "-", 1 ); | 443 | int nextC = allmsg.find( "-", 1 ); |
444 | if ( nextC == -1 ) { | 444 | if ( nextC == -1 ) { |
445 | msg = allmsg; | 445 | msg = allmsg; |
446 | allmsg = ""; | 446 | allmsg = ""; |
447 | } else{ | 447 | } else{ |
448 | msg = allmsg.left( nextC ); | 448 | msg = allmsg.left( nextC ); |
449 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 449 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
450 | } | 450 | } |
451 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 451 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
452 | if ( msg == "-newEvent" ) { | 452 | if ( msg == "-newEvent" ) { |
453 | mView->newEvent(); | 453 | mView->newEvent(); |
454 | } | 454 | } |
455 | if ( msg == "-newTodo" ) { | 455 | if ( msg == "-newTodo" ) { |
456 | mView->newTodo(); | 456 | mView->newTodo(); |
457 | 457 | ||
458 | } | 458 | } |
459 | if ( msg == "-showWN" ) { | 459 | if ( msg == "-showWN" ) { |
460 | mView->viewManager()->showWhatsNextView(); | 460 | mView->viewManager()->showWhatsNextView(); |
461 | } | 461 | } |
462 | if ( msg == "-showTodo" ) { | 462 | if ( msg == "-showTodo" ) { |
463 | mView->viewManager()->showTodoView(); | 463 | mView->viewManager()->showTodoView(); |
464 | } | 464 | } |
465 | if ( msg == "-showList" ) { | 465 | if ( msg == "-showList" ) { |
466 | mView->viewManager()->showListView(); | 466 | mView->viewManager()->showListView(); |
467 | } | 467 | } |
468 | else if ( msg == "-showDay" ) { | 468 | else if ( msg == "-showDay" ) { |
469 | mView->viewManager()->showDayView(); | 469 | mView->viewManager()->showDayView(); |
470 | } | 470 | } |
471 | else if ( msg == "-showWWeek" ) { | 471 | else if ( msg == "-showWWeek" ) { |
472 | mView->viewManager()->showWorkWeekView(); | 472 | mView->viewManager()->showWorkWeekView(); |
473 | } | 473 | } |
474 | else if ( msg == "-ringSync" ) { | 474 | else if ( msg == "-ringSync" ) { |
475 | mSyncManager->multiSync( false ); | 475 | mSyncManager->multiSync( false ); |
476 | } | 476 | } |
477 | else if ( msg == "-showWeek" ) { | 477 | else if ( msg == "-showWeek" ) { |
478 | mView->viewManager()->showWeekView(); | 478 | mView->viewManager()->showWeekView(); |
479 | } | 479 | } |
480 | else if ( msg == "-showTodo" ) { | 480 | else if ( msg == "-showTodo" ) { |
481 | mView->viewManager()->showTodoView(); | 481 | mView->viewManager()->showTodoView(); |
482 | } | 482 | } |
483 | else if ( msg == "-showJournal" ) { | 483 | else if ( msg == "-showJournal" ) { |
484 | mView->dateNavigator()->selectDates( 1 ); | 484 | mView->dateNavigator()->selectDates( 1 ); |
485 | mView->dateNavigator()->selectToday(); | 485 | mView->dateNavigator()->selectToday(); |
486 | mView->viewManager()->showJournalView(); | 486 | mView->viewManager()->showJournalView(); |
487 | } | 487 | } |
488 | else if ( msg == "-showKO" ) { | 488 | else if ( msg == "-showKO" ) { |
489 | mView->viewManager()->showNextXView(); | 489 | mView->viewManager()->showNextXView(); |
490 | } | 490 | } |
491 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 491 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
492 | mView->viewManager()->showWhatsNextView(); | 492 | mView->viewManager()->showWhatsNextView(); |
493 | } | 493 | } |
494 | else if ( msg == "-showNextXView" ) { | 494 | else if ( msg == "-showNextXView" ) { |
495 | mView->viewManager()->showNextXView(); | 495 | mView->viewManager()->showNextXView(); |
496 | } | 496 | } |
497 | 497 | ||
498 | 498 | ||
499 | } | 499 | } |
500 | 500 | ||
501 | showMaximized(); | 501 | showMaximized(); |
502 | raise(); | 502 | raise(); |
503 | } | 503 | } |
504 | 504 | ||
505 | QPixmap MainWindow::loadPixmap( QString name ) | 505 | QPixmap MainWindow::loadPixmap( QString name ) |
506 | { | 506 | { |
507 | return SmallIcon( name ); | 507 | return SmallIcon( name ); |
508 | 508 | ||
509 | } | 509 | } |
510 | void MainWindow::initActions() | 510 | void MainWindow::initActions() |
511 | { | 511 | { |
512 | //KOPrefs::instance()->mShowFullMenu | 512 | //KOPrefs::instance()->mShowFullMenu |
513 | iconToolBar->clear(); | 513 | iconToolBar->clear(); |
514 | KOPrefs *p = KOPrefs::instance(); | 514 | KOPrefs *p = KOPrefs::instance(); |
515 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 515 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
516 | 516 | ||
517 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 517 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
518 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 518 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
519 | QPopupMenu *importMenu = new QPopupMenu( this ); | 519 | QPopupMenu *importMenu = new QPopupMenu( this ); |
520 | selectFilterMenu = new QPopupMenu( this ); | 520 | selectFilterMenu = new QPopupMenu( this ); |
521 | selectFilterMenu->setCheckable( true ); | 521 | selectFilterMenu->setCheckable( true ); |
522 | syncMenu = new QPopupMenu( this ); | 522 | syncMenu = new QPopupMenu( this ); |
523 | configureAgendaMenu = new QPopupMenu( this ); | 523 | configureAgendaMenu = new QPopupMenu( this ); |
524 | configureToolBarMenu = new QPopupMenu( this ); | 524 | configureToolBarMenu = new QPopupMenu( this ); |
525 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 525 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
526 | if ( KOPrefs::instance()->mShowFullMenu ) { | 526 | if ( KOPrefs::instance()->mShowFullMenu ) { |
527 | QMenuBar *menuBar1; | 527 | QMenuBar *menuBar1; |
528 | menuBar1 = menuBar(); | 528 | menuBar1 = menuBar(); |
529 | menuBar1->insertItem( i18n("File"), importMenu ); | 529 | menuBar1->insertItem( i18n("File"), importMenu ); |
530 | menuBar1->insertItem( i18n("View"), viewMenu ); | 530 | menuBar1->insertItem( i18n("View"), viewMenu ); |
531 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 531 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
532 | #ifdef DESKTOP_VERSION | 532 | #ifdef DESKTOP_VERSION |
533 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 533 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
534 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 534 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
535 | #else | 535 | #else |
536 | menuBar1->insertItem( i18n("Sync"), syncMenu ); | 536 | menuBar1->insertItem( i18n("Sync"), syncMenu ); |
537 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); | 537 | menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); |
538 | #endif | 538 | #endif |
539 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 539 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
540 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 540 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
541 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 541 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
542 | } else { | 542 | } else { |
543 | QPEMenuBar *menuBar1; | 543 | QPEMenuBar *menuBar1; |
544 | menuBar1 = new QPEMenuBar( iconToolBar ); | 544 | menuBar1 = new QPEMenuBar( iconToolBar ); |
545 | QPopupMenu *menuBar = new QPopupMenu( this ); | 545 | QPopupMenu *menuBar = new QPopupMenu( this ); |
546 | menuBar1->insertItem( i18n("ME"), menuBar); | 546 | menuBar1->insertItem( i18n("ME"), menuBar); |
547 | menuBar->insertItem( i18n("File"), importMenu ); | 547 | menuBar->insertItem( i18n("File"), importMenu ); |
548 | menuBar->insertItem( i18n("View"), viewMenu ); | 548 | menuBar->insertItem( i18n("View"), viewMenu ); |
549 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 549 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
550 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 550 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
551 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 551 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
552 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 552 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
553 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 553 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
554 | menuBar->insertItem( i18n("Help"), helpMenu ); | 554 | menuBar->insertItem( i18n("Help"), helpMenu ); |
555 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 555 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
556 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 556 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
557 | } | 557 | } |
558 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 558 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
559 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); | 559 | connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); |
560 | 560 | QIconSet icon; | |
561 | menuBarWeek = new QPEMenuBar( iconToolBar ); | 561 | int pixWid = 22, pixHei = 22; |
562 | QPopupMenu * wpo = new QPopupMenu (this); | 562 | QString pathString = ""; |
563 | QPopupMenu * all = new QPopupMenu (this); | 563 | if ( !p->mToolBarMiniIcons ) { |
564 | //wpo->insertItem( i18n("W#"), 0 ); | 564 | if ( QApplication::desktop()->width() < 480 ) { |
565 | int first = 1; | 565 | pathString += "icons16/"; |
566 | int i; | 566 | pixWid = 18; pixHei = 16; |
567 | for ( i = 1; i < 50; ++i ) { | ||
568 | if ( !(i%10) ) { | ||
569 | all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); | ||
570 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); | ||
571 | first = i; | ||
572 | wpo = new QPopupMenu (this); | ||
573 | } | 567 | } |
574 | wpo->insertItem( QString::number(i), i ); | 568 | } else { |
575 | } | 569 | pathString += "iconsmini/"; |
576 | for ( i = 50; i < 53; ++i ) { | 570 | pixWid = 18; pixHei = 16; |
577 | wpo->insertItem( QString::number(i), i); | 571 | } |
572 | mWeekBgColor = iconToolBar->backgroundColor(); | ||
573 | mWeekPixmap.resize( pixWid , pixHei ); | ||
574 | mWeekPixmap.fill( mWeekBgColor ); | ||
575 | icon = mWeekPixmap; | ||
576 | mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); | ||
577 | mWeekAction->addTo( iconToolBar ); | ||
578 | mWeekFont = font(); | ||
579 | |||
580 | int fontPoint = mWeekFont.pointSize(); | ||
581 | QFontMetrics f( mWeekFont ); | ||
582 | int fontWid = f.width( "30" ); | ||
583 | while ( fontWid > pixWid ) { | ||
584 | --fontPoint; | ||
585 | mWeekFont.setPointSize( fontPoint ); | ||
586 | QFontMetrics f( mWeekFont ); | ||
587 | fontWid = f.width( "30" ); | ||
588 | qDebug("dec-- "); | ||
578 | } | 589 | } |
579 | all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo ); | 590 | |
580 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeek ( int ) ) ); | 591 | connect( mWeekAction, SIGNAL( activated() ), |
581 | menuBarWeek->insertItem( "00",all,1); | 592 | this, SLOT( weekAction() ) ); |
582 | menuBarWeek->setMaximumSize( menuBarWeek->sizeHint( )); | ||
583 | 593 | ||
584 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); | 594 | connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); |
595 | |||
596 | //#endif | ||
585 | // ****************** | 597 | // ****************** |
586 | QAction *action; | 598 | QAction *action; |
587 | QIconSet icon; | ||
588 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 599 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
589 | configureToolBarMenu->setCheckable( true ); | 600 | configureToolBarMenu->setCheckable( true ); |
590 | 601 | ||
591 | QString pathString = ""; | 602 | |
592 | if ( !p->mToolBarMiniIcons ) { | ||
593 | if ( QApplication::desktop()->width() < 480 ) | ||
594 | pathString += "icons16/"; | ||
595 | } else | ||
596 | pathString += "iconsmini/"; | ||
597 | configureAgendaMenu->setCheckable( true ); | 603 | configureAgendaMenu->setCheckable( true ); |
598 | int iii ; | 604 | int iii ; |
599 | for ( iii = 1;iii<= 10 ;++iii ){ | 605 | for ( iii = 1;iii<= 10 ;++iii ){ |
600 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); | 606 | configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); |
601 | } | 607 | } |
602 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 608 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
603 | 609 | ||
604 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), | 610 | connect( configureAgendaMenu, SIGNAL( aboutToShow()), |
605 | this, SLOT( showConfigureAgenda( ) ) ); | 611 | this, SLOT( showConfigureAgenda( ) ) ); |
606 | 612 | ||
607 | icon = loadPixmap( pathString + "configure" ); | 613 | icon = loadPixmap( pathString + "configure" ); |
608 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 614 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
609 | action->addTo( actionMenu ); | 615 | action->addTo( actionMenu ); |
610 | connect( action, SIGNAL( activated() ), | 616 | connect( action, SIGNAL( activated() ), |
611 | mView, SLOT( edit_options() ) ); | 617 | mView, SLOT( edit_options() ) ); |
612 | actionMenu->insertSeparator(); | 618 | actionMenu->insertSeparator(); |
613 | 619 | ||
614 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); | 620 | action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); |
615 | action->addTo( actionMenu ); | 621 | action->addTo( actionMenu ); |
616 | connect( action, SIGNAL( activated() ), | 622 | connect( action, SIGNAL( activated() ), |
617 | mView, SLOT( undo_delete() ) ); | 623 | mView, SLOT( undo_delete() ) ); |
618 | actionMenu->insertSeparator(); | 624 | actionMenu->insertSeparator(); |
619 | 625 | ||
620 | icon = loadPixmap( pathString + "newevent" ); | 626 | icon = loadPixmap( pathString + "newevent" ); |
621 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 627 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
622 | configureToolBarMenu->insertSeparator(); | 628 | configureToolBarMenu->insertSeparator(); |
623 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 629 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
624 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 630 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
625 | ne_action->addTo( actionMenu ); | 631 | ne_action->addTo( actionMenu ); |
626 | connect( ne_action, SIGNAL( activated() ), | 632 | connect( ne_action, SIGNAL( activated() ), |
627 | mView, SLOT( newEvent() ) ); | 633 | mView, SLOT( newEvent() ) ); |
628 | icon = loadPixmap( pathString + "newtodo" ); | 634 | icon = loadPixmap( pathString + "newtodo" ); |
629 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 635 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
630 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 636 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
631 | nt_action->addTo( actionMenu ); | 637 | nt_action->addTo( actionMenu ); |
632 | connect( nt_action, SIGNAL( activated() ), | 638 | connect( nt_action, SIGNAL( activated() ), |
633 | mView, SLOT( newTodo() ) ); | 639 | mView, SLOT( newTodo() ) ); |
634 | 640 | ||
635 | icon = loadPixmap( pathString + "today" ); | 641 | icon = loadPixmap( pathString + "today" ); |
636 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 642 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
637 | today_action->addTo( viewMenu ); | 643 | today_action->addTo( viewMenu ); |
638 | connect( today_action, SIGNAL( activated() ), | 644 | connect( today_action, SIGNAL( activated() ), |
639 | mView, SLOT( goToday() ) ); | 645 | mView, SLOT( goToday() ) ); |
640 | viewMenu->insertSeparator(); | 646 | viewMenu->insertSeparator(); |
641 | 647 | ||
642 | icon = loadPixmap( pathString + "navi" ); | 648 | icon = loadPixmap( pathString + "navi" ); |
643 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 649 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
644 | action->addTo( viewMenu ); | 650 | action->addTo( viewMenu ); |
645 | connect( action, SIGNAL( activated() ), | 651 | connect( action, SIGNAL( activated() ), |
646 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 652 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
647 | mToggleNav = action ; | 653 | mToggleNav = action ; |
648 | icon = loadPixmap( pathString + "filter" ); | 654 | icon = loadPixmap( pathString + "filter" ); |
649 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 655 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
650 | action->addTo( viewMenu ); | 656 | action->addTo( viewMenu ); |
651 | connect( action, SIGNAL( activated() ), | 657 | connect( action, SIGNAL( activated() ), |
652 | mView, SLOT( toggleFilter() ) ); | 658 | mView, SLOT( toggleFilter() ) ); |
653 | mToggleFilter = action; | 659 | mToggleFilter = action; |
654 | icon = loadPixmap( pathString + "allday" ); | 660 | icon = loadPixmap( pathString + "allday" ); |
655 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); | 661 | action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); |
656 | action->addTo( viewMenu ); | 662 | action->addTo( viewMenu ); |
657 | connect( action, SIGNAL( activated() ), | 663 | connect( action, SIGNAL( activated() ), |
658 | mView, SLOT( toggleAllDaySize() ) ); | 664 | mView, SLOT( toggleAllDaySize() ) ); |
659 | mToggleAllday = action; | 665 | mToggleAllday = action; |
660 | 666 | ||
661 | 667 | ||
662 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 668 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
663 | mToggleNav, SLOT( setEnabled ( bool ) ) ); | 669 | mToggleNav, SLOT( setEnabled ( bool ) ) ); |
664 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), | 670 | connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), |
665 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); | 671 | mToggleFilter, SLOT( setEnabled ( bool ) ) ); |
666 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), | 672 | connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), |
667 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); | 673 | mToggleAllday, SLOT( setEnabled ( bool ) ) ); |
668 | 674 | ||
669 | viewMenu->insertSeparator(); | 675 | viewMenu->insertSeparator(); |
670 | icon = loadPixmap( pathString + "picker" ); | 676 | icon = loadPixmap( pathString + "picker" ); |
671 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 677 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
672 | action->addTo( viewMenu ); | 678 | action->addTo( viewMenu ); |
673 | connect( action, SIGNAL( activated() ), | 679 | connect( action, SIGNAL( activated() ), |
674 | mView, SLOT( showDatePicker() ) ); | 680 | mView, SLOT( showDatePicker() ) ); |
675 | action->addTo( iconToolBar ); | 681 | action->addTo( iconToolBar ); |
676 | viewMenu->insertSeparator(); | 682 | viewMenu->insertSeparator(); |
677 | icon = loadPixmap( pathString + "list" ); | 683 | icon = loadPixmap( pathString + "list" ); |
678 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 684 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
679 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 685 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
680 | showlist_action->addTo( viewMenu ); | 686 | showlist_action->addTo( viewMenu ); |
681 | connect( showlist_action, SIGNAL( activated() ), | 687 | connect( showlist_action, SIGNAL( activated() ), |
682 | mView->viewManager(), SLOT( showListView() ) ); | 688 | mView->viewManager(), SLOT( showListView() ) ); |
683 | 689 | ||
684 | 690 | ||
685 | icon = loadPixmap( pathString + "day" ); | 691 | icon = loadPixmap( pathString + "day" ); |
686 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 692 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
687 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 693 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
688 | day1_action->addTo( viewMenu ); | 694 | day1_action->addTo( viewMenu ); |
689 | // action->addTo( toolBar ); | 695 | // action->addTo( toolBar ); |
690 | connect( day1_action, SIGNAL( activated() ), | 696 | connect( day1_action, SIGNAL( activated() ), |
691 | mView->viewManager(), SLOT( showDayView() ) ); | 697 | mView->viewManager(), SLOT( showDayView() ) ); |
692 | 698 | ||
693 | icon = loadPixmap( pathString + "workweek" ); | 699 | icon = loadPixmap( pathString + "workweek" ); |
694 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 700 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
695 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 701 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
696 | day5_action->addTo( viewMenu ); | 702 | day5_action->addTo( viewMenu ); |
697 | connect( day5_action, SIGNAL( activated() ), | 703 | connect( day5_action, SIGNAL( activated() ), |
698 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 704 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
699 | 705 | ||
700 | icon = loadPixmap( pathString + "week" ); | 706 | icon = loadPixmap( pathString + "week" ); |
701 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 707 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
702 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 708 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
703 | day7_action->addTo( viewMenu ); | 709 | day7_action->addTo( viewMenu ); |
704 | connect( day7_action, SIGNAL( activated() ), | 710 | connect( day7_action, SIGNAL( activated() ), |
705 | mView->viewManager(), SLOT( showWeekView() ) ); | 711 | mView->viewManager(), SLOT( showWeekView() ) ); |
706 | 712 | ||
707 | icon = loadPixmap( pathString + "month" ); | 713 | icon = loadPixmap( pathString + "month" ); |
708 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 714 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
709 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 715 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
710 | month_action->addTo( viewMenu ); | 716 | month_action->addTo( viewMenu ); |
711 | connect( month_action, SIGNAL( activated() ), | 717 | connect( month_action, SIGNAL( activated() ), |
712 | mView->viewManager(), SLOT( showMonthView() ) ); | 718 | mView->viewManager(), SLOT( showMonthView() ) ); |
713 | 719 | ||
714 | icon = loadPixmap( pathString + "todo" ); | 720 | icon = loadPixmap( pathString + "todo" ); |
715 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 721 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
716 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 722 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
717 | todoview_action->addTo( viewMenu ); | 723 | todoview_action->addTo( viewMenu ); |
718 | connect( todoview_action, SIGNAL( activated() ), | 724 | connect( todoview_action, SIGNAL( activated() ), |
719 | mView->viewManager(), SLOT( showTodoView() ) ); | 725 | mView->viewManager(), SLOT( showTodoView() ) ); |
720 | 726 | ||
721 | icon = loadPixmap( pathString + "journal" ); | 727 | icon = loadPixmap( pathString + "journal" ); |
722 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 728 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
723 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 729 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
724 | viewjournal_action->addTo( viewMenu ); | 730 | viewjournal_action->addTo( viewMenu ); |
725 | connect( viewjournal_action, SIGNAL( activated() ), | 731 | connect( viewjournal_action, SIGNAL( activated() ), |
726 | mView->viewManager(), SLOT( showJournalView() ) ); | 732 | mView->viewManager(), SLOT( showJournalView() ) ); |
727 | 733 | ||
728 | icon = loadPixmap( pathString + "xdays" ); | 734 | icon = loadPixmap( pathString + "xdays" ); |
729 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 735 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
730 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 736 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
731 | xdays_action->addTo( viewMenu ); | 737 | xdays_action->addTo( viewMenu ); |
732 | connect( xdays_action, SIGNAL( activated() ), | 738 | connect( xdays_action, SIGNAL( activated() ), |
733 | mView->viewManager(), SLOT( showNextXView() ) ); | 739 | mView->viewManager(), SLOT( showNextXView() ) ); |
734 | 740 | ||
735 | icon = loadPixmap( pathString + "whatsnext" ); | 741 | icon = loadPixmap( pathString + "whatsnext" ); |
736 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 742 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
737 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 743 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
738 | whatsnext_action->addTo( viewMenu ); | 744 | whatsnext_action->addTo( viewMenu ); |
739 | connect( whatsnext_action, SIGNAL( activated() ), | 745 | connect( whatsnext_action, SIGNAL( activated() ), |
740 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 746 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
741 | 747 | ||
742 | #if 0 | 748 | #if 0 |
743 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 749 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
744 | action->addTo( viewMenu ); | 750 | action->addTo( viewMenu ); |
745 | connect( action, SIGNAL( activated() ), | 751 | connect( action, SIGNAL( activated() ), |
746 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 752 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
747 | #endif | 753 | #endif |
748 | 754 | ||
749 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 755 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
750 | this ); | 756 | this ); |
751 | mNewSubTodoAction->addTo( actionMenu ); | 757 | mNewSubTodoAction->addTo( actionMenu ); |
752 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 758 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
753 | mView, SLOT( newSubTodo() ) ); | 759 | mView, SLOT( newSubTodo() ) ); |
754 | 760 | ||
755 | actionMenu->insertSeparator(); | 761 | actionMenu->insertSeparator(); |
756 | 762 | ||
757 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 763 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
758 | mShowAction->addTo( actionMenu ); | 764 | mShowAction->addTo( actionMenu ); |
759 | connect( mShowAction, SIGNAL( activated() ), | 765 | connect( mShowAction, SIGNAL( activated() ), |
760 | mView, SLOT( showIncidence() ) ); | 766 | mView, SLOT( showIncidence() ) ); |
761 | 767 | ||
762 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 768 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
763 | mEditAction->addTo( actionMenu ); | 769 | mEditAction->addTo( actionMenu ); |
764 | connect( mEditAction, SIGNAL( activated() ), | 770 | connect( mEditAction, SIGNAL( activated() ), |
765 | mView, SLOT( editIncidence() ) ); | 771 | mView, SLOT( editIncidence() ) ); |
766 | 772 | ||
767 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 773 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
768 | mDeleteAction->addTo( actionMenu ); | 774 | mDeleteAction->addTo( actionMenu ); |
769 | connect( mDeleteAction, SIGNAL( activated() ), | 775 | connect( mDeleteAction, SIGNAL( activated() ), |
770 | mView, SLOT( deleteIncidence() ) ); | 776 | mView, SLOT( deleteIncidence() ) ); |
771 | 777 | ||
772 | 778 | ||
773 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 779 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
774 | mCloneAction->addTo( actionMenu ); | 780 | mCloneAction->addTo( actionMenu ); |
775 | connect( mCloneAction, SIGNAL( activated() ), | 781 | connect( mCloneAction, SIGNAL( activated() ), |
776 | mView, SLOT( cloneIncidence() ) ); | 782 | mView, SLOT( cloneIncidence() ) ); |
777 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 783 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
778 | mMoveAction->addTo( actionMenu ); | 784 | mMoveAction->addTo( actionMenu ); |
779 | connect( mMoveAction, SIGNAL( activated() ), | 785 | connect( mMoveAction, SIGNAL( activated() ), |
780 | mView, SLOT( moveIncidence() ) ); | 786 | mView, SLOT( moveIncidence() ) ); |
781 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 787 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
782 | mBeamAction->addTo( actionMenu ); | 788 | mBeamAction->addTo( actionMenu ); |
783 | connect( mBeamAction, SIGNAL( activated() ), | 789 | connect( mBeamAction, SIGNAL( activated() ), |
784 | mView, SLOT( beamIncidence() ) ); | 790 | mView, SLOT( beamIncidence() ) ); |
785 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 791 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
786 | mCancelAction->addTo( actionMenu ); | 792 | mCancelAction->addTo( actionMenu ); |
787 | connect( mCancelAction, SIGNAL( activated() ), | 793 | connect( mCancelAction, SIGNAL( activated() ), |
788 | mView, SLOT( toggleCancelIncidence() ) ); | 794 | mView, SLOT( toggleCancelIncidence() ) ); |
789 | 795 | ||
790 | actionMenu->insertSeparator(); | 796 | actionMenu->insertSeparator(); |
791 | 797 | ||
792 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 798 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
793 | this ); | 799 | this ); |
794 | action->addTo( actionMenu ); | 800 | action->addTo( actionMenu ); |
795 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 801 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
796 | 802 | ||
797 | icon = loadPixmap( pathString + "search" ); | 803 | icon = loadPixmap( pathString + "search" ); |
798 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 804 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
799 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 805 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
800 | search_action->addTo( actionMenu ); | 806 | search_action->addTo( actionMenu ); |
801 | connect( search_action, SIGNAL( activated() ), | 807 | connect( search_action, SIGNAL( activated() ), |
802 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 808 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
803 | 809 | ||
804 | 810 | ||
805 | 811 | ||
806 | if ( KOPrefs::instance()->mShowFullMenu ) { | 812 | if ( KOPrefs::instance()->mShowFullMenu ) { |
807 | actionMenu->insertSeparator(); | 813 | actionMenu->insertSeparator(); |
808 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 814 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
809 | 815 | ||
810 | } | 816 | } |
811 | // actionMenu->insertSeparator(); | 817 | // actionMenu->insertSeparator(); |
812 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 818 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
813 | this ); | 819 | this ); |
814 | action->addTo( importMenu ); | 820 | action->addTo( importMenu ); |
815 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 821 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
816 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 822 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
817 | this ); | 823 | this ); |
818 | action->addTo( importMenu ); | 824 | action->addTo( importMenu ); |
819 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 825 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
820 | importMenu->insertSeparator(); | 826 | importMenu->insertSeparator(); |
821 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 827 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
822 | this ); | 828 | this ); |
823 | action->addTo( importMenu ); | 829 | action->addTo( importMenu ); |
824 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 830 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
825 | #ifndef DESKTOP_VERSION | 831 | #ifndef DESKTOP_VERSION |
826 | importMenu->insertSeparator(); | 832 | importMenu->insertSeparator(); |
827 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 833 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
828 | this ); | 834 | this ); |
829 | action->addTo( importMenu ); | 835 | action->addTo( importMenu ); |
830 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 836 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
831 | #else | 837 | #else |
832 | #ifdef _OL_IMPORT_ | 838 | #ifdef _OL_IMPORT_ |
833 | importMenu->insertSeparator(); | 839 | importMenu->insertSeparator(); |
834 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 840 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
835 | this ); | 841 | this ); |
836 | action->addTo( importMenu ); | 842 | action->addTo( importMenu ); |
837 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 843 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
838 | #endif | 844 | #endif |
839 | #endif | 845 | #endif |
840 | 846 | ||
841 | importMenu->insertSeparator(); | 847 | importMenu->insertSeparator(); |
842 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 848 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
843 | this ); | 849 | this ); |
844 | action->addTo( importMenu ); | 850 | action->addTo( importMenu ); |
845 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 851 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
846 | 852 | ||
847 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 853 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
848 | this ); | 854 | this ); |
849 | action->addTo( importMenu ); | 855 | action->addTo( importMenu ); |
850 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 856 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
851 | 857 | ||
852 | importMenu->insertSeparator(); | 858 | importMenu->insertSeparator(); |
853 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 859 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
854 | this ); | 860 | this ); |
855 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 861 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
856 | 862 | ||
857 | 863 | ||
858 | //LR | 864 | //LR |
859 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 865 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
860 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 866 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
861 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 867 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
862 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 868 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
863 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 869 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
864 | 870 | ||
865 | importMenu->insertSeparator(); | 871 | importMenu->insertSeparator(); |
866 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 872 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
867 | this ); | 873 | this ); |
868 | action->addTo( importMenu ); | 874 | action->addTo( importMenu ); |
869 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 875 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
870 | #ifndef DESKTOP_VERSION | 876 | #ifndef DESKTOP_VERSION |
871 | importMenu->insertSeparator(); | 877 | importMenu->insertSeparator(); |
872 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, | 878 | brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, |
873 | this ); | 879 | this ); |
874 | brAction->addTo( importMenu ); | 880 | brAction->addTo( importMenu ); |
875 | brAction->setToggleAction (true ) ; | 881 | brAction->setToggleAction (true ) ; |
876 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); | 882 | connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); |
877 | 883 | ||
878 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 884 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
879 | this ); | 885 | this ); |
880 | action->addTo( importMenu ); | 886 | action->addTo( importMenu ); |
881 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 887 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
882 | 888 | ||
883 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 889 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
884 | this ); | 890 | this ); |
885 | action->addTo( importMenu ); | 891 | action->addTo( importMenu ); |
886 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 892 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
887 | #else | 893 | #else |
888 | importMenu->insertSeparator(); | 894 | importMenu->insertSeparator(); |
889 | icon = loadPixmap( pathString + "print" ); | 895 | icon = loadPixmap( pathString + "print" ); |
890 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 896 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
891 | action->addTo( importMenu ); | 897 | action->addTo( importMenu ); |
892 | connect( action, SIGNAL( activated() ), | 898 | connect( action, SIGNAL( activated() ), |
893 | this, SLOT( printCal() ) ); | 899 | this, SLOT( printCal() ) ); |
894 | 900 | ||
895 | icon = loadPixmap( pathString + "print" ); | 901 | icon = loadPixmap( pathString + "print" ); |
896 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 902 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
897 | action->addTo( importMenu ); | 903 | action->addTo( importMenu ); |
898 | connect( action, SIGNAL( activated() ), | 904 | connect( action, SIGNAL( activated() ), |
899 | this, SLOT( printSel() ) ); | 905 | this, SLOT( printSel() ) ); |
900 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); | 906 | action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); |
901 | action->addTo( importMenu ); | 907 | action->addTo( importMenu ); |
902 | connect( action, SIGNAL( activated() ), | 908 | connect( action, SIGNAL( activated() ), |
903 | mView->viewManager(), SIGNAL( printWNV() ) ); | 909 | mView->viewManager(), SIGNAL( printWNV() ) ); |
904 | #endif | 910 | #endif |
905 | importMenu->insertSeparator(); | 911 | importMenu->insertSeparator(); |
906 | action = new QAction( "beam all", i18n("Save"), 0, | 912 | action = new QAction( "beam all", i18n("Save"), 0, |
907 | this ); | 913 | this ); |
908 | action->addTo( importMenu ); | 914 | action->addTo( importMenu ); |
909 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 915 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
910 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 916 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
911 | this ); | 917 | this ); |
912 | action->addTo( importMenu ); | 918 | action->addTo( importMenu ); |
913 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 919 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
914 | 920 | ||
915 | //menuBar->insertItem( "Configure",configureMenu ); | 921 | //menuBar->insertItem( "Configure",configureMenu ); |
916 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 922 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
917 | icon = loadPixmap( "korganizer/korganizer" ); | 923 | icon = loadPixmap( "korganizer/korganizer" ); |
918 | 924 | ||
919 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 925 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
920 | action->addTo( helpMenu ); | 926 | action->addTo( helpMenu ); |
921 | connect( action, SIGNAL( activated() ), | 927 | connect( action, SIGNAL( activated() ), |
922 | SLOT( whatsNew() ) ); | 928 | SLOT( whatsNew() ) ); |
923 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 929 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
924 | action->addTo( helpMenu ); | 930 | action->addTo( helpMenu ); |
925 | connect( action, SIGNAL( activated() ), | 931 | connect( action, SIGNAL( activated() ), |
926 | SLOT( features() ) ); | 932 | SLOT( features() ) ); |
927 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 933 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
928 | action->addTo( helpMenu ); | 934 | action->addTo( helpMenu ); |
929 | connect( action, SIGNAL( activated() ), | 935 | connect( action, SIGNAL( activated() ), |
930 | SLOT( keyBindings() ) ); | 936 | SLOT( keyBindings() ) ); |
931 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 937 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
932 | action->addTo( helpMenu ); | 938 | action->addTo( helpMenu ); |
933 | connect( action, SIGNAL( activated() ), | 939 | connect( action, SIGNAL( activated() ), |
934 | SLOT( synchowto() ) ); | 940 | SLOT( synchowto() ) ); |
935 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); | 941 | action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); |
936 | action->addTo( helpMenu ); | 942 | action->addTo( helpMenu ); |
937 | connect( action, SIGNAL( activated() ), | 943 | connect( action, SIGNAL( activated() ), |
938 | SLOT( kdesynchowto() ) ); | 944 | SLOT( kdesynchowto() ) ); |
939 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); | 945 | action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); |
940 | action->addTo( helpMenu ); | 946 | action->addTo( helpMenu ); |
941 | connect( action, SIGNAL( activated() ), | 947 | connect( action, SIGNAL( activated() ), |
942 | SLOT( multisynchowto() ) ); | 948 | SLOT( multisynchowto() ) ); |
943 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 949 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
944 | action->addTo( helpMenu ); | 950 | action->addTo( helpMenu ); |
945 | connect( action, SIGNAL( activated() ), | 951 | connect( action, SIGNAL( activated() ), |
946 | SLOT( aboutAutoSaving() ) ); | 952 | SLOT( aboutAutoSaving() ) ); |
947 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 953 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
948 | action->addTo( helpMenu ); | 954 | action->addTo( helpMenu ); |
949 | connect( action, SIGNAL( activated() ), | 955 | connect( action, SIGNAL( activated() ), |
950 | SLOT( aboutKnownBugs() ) ); | 956 | SLOT( aboutKnownBugs() ) ); |
951 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 957 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
952 | action->addTo( helpMenu ); | 958 | action->addTo( helpMenu ); |
953 | connect( action, SIGNAL( activated() ), | 959 | connect( action, SIGNAL( activated() ), |
954 | SLOT( usertrans() ) ); | 960 | SLOT( usertrans() ) ); |
955 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 961 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
956 | action->addTo( helpMenu ); | 962 | action->addTo( helpMenu ); |
957 | connect( action, SIGNAL( activated() ), | 963 | connect( action, SIGNAL( activated() ), |
958 | SLOT( faq() ) ); | 964 | SLOT( faq() ) ); |
959 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 965 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
960 | action->addTo( helpMenu ); | 966 | action->addTo( helpMenu ); |
961 | connect( action, SIGNAL( activated() ), | 967 | connect( action, SIGNAL( activated() ), |
962 | SLOT( licence() ) ); | 968 | SLOT( licence() ) ); |
963 | action = new QAction( "about", i18n("About..."), 0, this ); | 969 | action = new QAction( "about", i18n("About..."), 0, this ); |
964 | action->addTo( helpMenu ); | 970 | action->addTo( helpMenu ); |
965 | connect( action, SIGNAL( activated() ), | 971 | connect( action, SIGNAL( activated() ), |
966 | SLOT( about() ) ); | 972 | SLOT( about() ) ); |
967 | //menuBar->insertSeparator(); | 973 | //menuBar->insertSeparator(); |
968 | 974 | ||
969 | // ****************************************************** | 975 | // ****************************************************** |
970 | // menubar icons | 976 | // menubar icons |
971 | 977 | ||
972 | 978 | ||
973 | iconToolBar->setHorizontalStretchable (true ); | 979 | iconToolBar->setHorizontalStretchable (true ); |
974 | //menuBar->insertItem( iconToolBar ); | 980 | //menuBar->insertItem( iconToolBar ); |
975 | //xdays_action | 981 | //xdays_action |
976 | if (p-> mShowIconNewEvent) | 982 | if (p-> mShowIconNewEvent) |
977 | ne_action->addTo( iconToolBar ); | 983 | ne_action->addTo( iconToolBar ); |
978 | if (p->mShowIconNewTodo ) | 984 | if (p->mShowIconNewTodo ) |
979 | nt_action->addTo( iconToolBar ); | 985 | nt_action->addTo( iconToolBar ); |
980 | if (p-> mShowIconSearch) | 986 | if (p-> mShowIconSearch) |
981 | search_action->addTo( iconToolBar ); | 987 | search_action->addTo( iconToolBar ); |
982 | if (p-> mShowIconNext) | 988 | if (p-> mShowIconNext) |
983 | whatsnext_action->addTo( iconToolBar ); | 989 | whatsnext_action->addTo( iconToolBar ); |
984 | if (p-> mShowIconNextDays) | 990 | if (p-> mShowIconNextDays) |
985 | xdays_action->addTo( iconToolBar ); | 991 | xdays_action->addTo( iconToolBar ); |
986 | if (p-> mShowIconList) | 992 | if (p-> mShowIconList) |
987 | showlist_action->addTo( iconToolBar ); | 993 | showlist_action->addTo( iconToolBar ); |
988 | if (p-> mShowIconDay1) | 994 | if (p-> mShowIconDay1) |
989 | day1_action->addTo( iconToolBar ); | 995 | day1_action->addTo( iconToolBar ); |
990 | if (p-> mShowIconDay5) | 996 | if (p-> mShowIconDay5) |
991 | day5_action->addTo( iconToolBar ); | 997 | day5_action->addTo( iconToolBar ); |
992 | if (p-> mShowIconDay7) | 998 | if (p-> mShowIconDay7) |
993 | day7_action->addTo( iconToolBar ); | 999 | day7_action->addTo( iconToolBar ); |
994 | if (p-> mShowIconMonth) | 1000 | if (p-> mShowIconMonth) |
995 | month_action->addTo( iconToolBar ); | 1001 | month_action->addTo( iconToolBar ); |
996 | if (p-> mShowIconTodoview) | 1002 | if (p-> mShowIconTodoview) |
997 | todoview_action->addTo( iconToolBar ); | 1003 | todoview_action->addTo( iconToolBar ); |
998 | if (p-> mShowIconJournal) | 1004 | if (p-> mShowIconJournal) |
999 | viewjournal_action->addTo( iconToolBar ); | 1005 | viewjournal_action->addTo( iconToolBar ); |
1000 | icon = loadPixmap( pathString + "2leftarrowB" ); | 1006 | icon = loadPixmap( pathString + "2leftarrowB" ); |
1001 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 1007 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
1002 | if (p-> mShowIconBackFast) { | 1008 | if (p-> mShowIconBackFast) { |
1003 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 1009 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
1004 | connect( action, SIGNAL( activated() ), | 1010 | connect( action, SIGNAL( activated() ), |
1005 | mView, SLOT( goPreviousMonth() ) ); | 1011 | mView, SLOT( goPreviousMonth() ) ); |
1006 | action->addTo( iconToolBar ); | 1012 | action->addTo( iconToolBar ); |
1007 | } | 1013 | } |
1008 | icon = loadPixmap( pathString + "1leftarrowB" ); | 1014 | icon = loadPixmap( pathString + "1leftarrowB" ); |
1009 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 1015 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
1010 | if (p-> mShowIconBack) { | 1016 | if (p-> mShowIconBack) { |
1011 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 1017 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
1012 | connect( action, SIGNAL( activated() ), | 1018 | connect( action, SIGNAL( activated() ), |
1013 | mView, SLOT( goPrevious() ) ); | 1019 | mView, SLOT( goPrevious() ) ); |
1014 | action->addTo( iconToolBar ); | 1020 | action->addTo( iconToolBar ); |
1015 | } | 1021 | } |
1016 | icon = loadPixmap( pathString + "today" ); | 1022 | icon = loadPixmap( pathString + "today" ); |
1017 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 1023 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
1018 | if (p-> mShowIconToday) | 1024 | if (p-> mShowIconToday) |
1019 | today_action->addTo( iconToolBar ); | 1025 | today_action->addTo( iconToolBar ); |
1020 | icon = loadPixmap( pathString + "1rightarrowB" ); | 1026 | icon = loadPixmap( pathString + "1rightarrowB" ); |
1021 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 1027 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
1022 | if (p-> mShowIconForward) { | 1028 | if (p-> mShowIconForward) { |
1023 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 1029 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
1024 | connect( action, SIGNAL( activated() ), | 1030 | connect( action, SIGNAL( activated() ), |
1025 | mView, SLOT( goNext() ) ); | 1031 | mView, SLOT( goNext() ) ); |
1026 | action->addTo( iconToolBar ); | 1032 | action->addTo( iconToolBar ); |
1027 | } | 1033 | } |
1028 | icon = loadPixmap( pathString + "2rightarrowB" ); | 1034 | icon = loadPixmap( pathString + "2rightarrowB" ); |
1029 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 1035 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
1030 | if (p-> mShowIconForwardFast) { | 1036 | if (p-> mShowIconForwardFast) { |
1031 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 1037 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
1032 | connect( action, SIGNAL( activated() ), | 1038 | connect( action, SIGNAL( activated() ), |
1033 | mView, SLOT( goNextMonth() ) ); | 1039 | mView, SLOT( goNextMonth() ) ); |
1034 | action->addTo( iconToolBar ); | 1040 | action->addTo( iconToolBar ); |
1035 | } | 1041 | } |
1036 | 1042 | ||
1037 | 1043 | ||
1038 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 1044 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
1039 | 1045 | ||
1040 | if (p-> mShowIconNewEvent) | 1046 | if (p-> mShowIconNewEvent) |
1041 | configureToolBarMenu->setItemChecked( 10, true ); | 1047 | configureToolBarMenu->setItemChecked( 10, true ); |
1042 | if (p->mShowIconNewTodo ) | 1048 | if (p->mShowIconNewTodo ) |
1043 | configureToolBarMenu->setItemChecked( 20, true ); | 1049 | configureToolBarMenu->setItemChecked( 20, true ); |
1044 | if (p-> mShowIconSearch) | 1050 | if (p-> mShowIconSearch) |
1045 | configureToolBarMenu->setItemChecked( 120, true ); | 1051 | configureToolBarMenu->setItemChecked( 120, true ); |
1046 | if (p-> mShowIconList) | 1052 | if (p-> mShowIconList) |
1047 | configureToolBarMenu->setItemChecked( 30, true ); | 1053 | configureToolBarMenu->setItemChecked( 30, true ); |
1048 | if (p-> mShowIconDay1) | 1054 | if (p-> mShowIconDay1) |
1049 | configureToolBarMenu->setItemChecked( 40, true ); | 1055 | configureToolBarMenu->setItemChecked( 40, true ); |
1050 | if (p-> mShowIconDay5) | 1056 | if (p-> mShowIconDay5) |
1051 | configureToolBarMenu->setItemChecked( 50, true ); | 1057 | configureToolBarMenu->setItemChecked( 50, true ); |
1052 | if (p-> mShowIconDay7) | 1058 | if (p-> mShowIconDay7) |
1053 | configureToolBarMenu->setItemChecked( 60, true ); | 1059 | configureToolBarMenu->setItemChecked( 60, true ); |
1054 | if (p-> mShowIconMonth) | 1060 | if (p-> mShowIconMonth) |
1055 | configureToolBarMenu->setItemChecked( 70, true ); | 1061 | configureToolBarMenu->setItemChecked( 70, true ); |
1056 | if (p-> mShowIconTodoview) | 1062 | if (p-> mShowIconTodoview) |
1057 | configureToolBarMenu->setItemChecked( 80, true ); | 1063 | configureToolBarMenu->setItemChecked( 80, true ); |
1058 | if (p-> mShowIconBackFast) | 1064 | if (p-> mShowIconBackFast) |
1059 | configureToolBarMenu->setItemChecked( 200, true ); | 1065 | configureToolBarMenu->setItemChecked( 200, true ); |
1060 | if (p-> mShowIconBack) | 1066 | if (p-> mShowIconBack) |
1061 | configureToolBarMenu->setItemChecked( 210, true ); | 1067 | configureToolBarMenu->setItemChecked( 210, true ); |
1062 | if (p-> mShowIconToday) | 1068 | if (p-> mShowIconToday) |
1063 | configureToolBarMenu->setItemChecked( 130, true ); | 1069 | configureToolBarMenu->setItemChecked( 130, true ); |
1064 | if (p-> mShowIconForward) | 1070 | if (p-> mShowIconForward) |
1065 | configureToolBarMenu->setItemChecked( 220, true ); | 1071 | configureToolBarMenu->setItemChecked( 220, true ); |
1066 | if (p-> mShowIconForwardFast) | 1072 | if (p-> mShowIconForwardFast) |
1067 | configureToolBarMenu->setItemChecked( 230, true ); | 1073 | configureToolBarMenu->setItemChecked( 230, true ); |
1068 | if (p-> mShowIconNextDays) | 1074 | if (p-> mShowIconNextDays) |
1069 | configureToolBarMenu->setItemChecked( 100, true ); | 1075 | configureToolBarMenu->setItemChecked( 100, true ); |
1070 | if (p-> mShowIconNext) | 1076 | if (p-> mShowIconNext) |
1071 | configureToolBarMenu->setItemChecked( 110, true ); | 1077 | configureToolBarMenu->setItemChecked( 110, true ); |
1072 | if (p-> mShowIconJournal) | 1078 | if (p-> mShowIconJournal) |
1073 | configureToolBarMenu->setItemChecked( 90, true ); | 1079 | configureToolBarMenu->setItemChecked( 90, true ); |
1074 | if (p-> mShowIconWhatsThis) | 1080 | if (p-> mShowIconWhatsThis) |
1075 | configureToolBarMenu->setItemChecked( 300, true ); | 1081 | configureToolBarMenu->setItemChecked( 300, true ); |
1076 | 1082 | ||
1077 | QLabel* dummy = new QLabel( iconToolBar ); | 1083 | QLabel* dummy = new QLabel( iconToolBar ); |
1078 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 1084 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
1079 | if (!p-> mShowIconStretch) | 1085 | if (!p-> mShowIconStretch) |
1080 | iconToolBar->setStretchableWidget ( dummy ) ; | 1086 | iconToolBar->setStretchableWidget ( dummy ) ; |
1081 | else | 1087 | else |
1082 | configureToolBarMenu->setItemChecked( 5, true ); | 1088 | configureToolBarMenu->setItemChecked( 5, true ); |
1083 | if (p-> mShowIconWhatsThis) | 1089 | if (p-> mShowIconWhatsThis) |
1084 | QWhatsThis::whatsThisButton ( iconToolBar ); | 1090 | QWhatsThis::whatsThisButton ( iconToolBar ); |
1085 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 1091 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
1086 | configureAgenda( p->mHourSize ); | 1092 | configureAgenda( p->mHourSize ); |
1087 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 1093 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
1088 | } | 1094 | } |
1089 | 1095 | ||
1090 | void MainWindow::exportToPhone( int mode ) | 1096 | void MainWindow::exportToPhone( int mode ) |
1091 | { | 1097 | { |
1092 | 1098 | ||
1093 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1099 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1094 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1100 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1095 | KOex2phonePrefs ex2phone; | 1101 | KOex2phonePrefs ex2phone; |
1096 | 1102 | ||
1097 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1103 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1098 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1104 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1099 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1105 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1100 | if ( mode == 1 ) | 1106 | if ( mode == 1 ) |
1101 | ex2phone.setCaption(i18n("Export complete calendar")); | 1107 | ex2phone.setCaption(i18n("Export complete calendar")); |
1102 | if ( mode == 2 ) | 1108 | if ( mode == 2 ) |
1103 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1109 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1104 | 1110 | ||
1105 | if ( !ex2phone.exec() ) { | 1111 | if ( !ex2phone.exec() ) { |
1106 | return; | 1112 | return; |
1107 | } | 1113 | } |
1108 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1114 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1109 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1115 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1110 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1116 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1111 | 1117 | ||
1112 | int inFuture = 0; | 1118 | int inFuture = 0; |
1113 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1119 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1114 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1120 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1115 | QPtrList<Incidence> delSel; | 1121 | QPtrList<Incidence> delSel; |
1116 | if ( mode == 1 ) | 1122 | if ( mode == 1 ) |
1117 | delSel = mCalendar->rawIncidences(); | 1123 | delSel = mCalendar->rawIncidences(); |
1118 | if ( mode == 2 ) | 1124 | if ( mode == 2 ) |
1119 | delSel = mCalendar->incidences(); | 1125 | delSel = mCalendar->incidences(); |
1120 | CalendarLocal* cal = new CalendarLocal(); | 1126 | CalendarLocal* cal = new CalendarLocal(); |
1121 | cal->setLocalTime(); | 1127 | cal->setLocalTime(); |
1122 | Incidence *incidence = delSel.first(); | 1128 | Incidence *incidence = delSel.first(); |
1123 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1129 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1124 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1130 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1125 | while ( incidence ) { | 1131 | while ( incidence ) { |
1126 | if ( incidence->type() != "Journal" ) { | 1132 | if ( incidence->type() != "Journal" ) { |
1127 | bool add = true; | 1133 | bool add = true; |
1128 | if ( inFuture ) { | 1134 | if ( inFuture ) { |
1129 | QDateTime dt; | 1135 | QDateTime dt; |
1130 | if ( incidence->type() == "Todo" ) { | 1136 | if ( incidence->type() == "Todo" ) { |
1131 | Todo * t = (Todo*)incidence; | 1137 | Todo * t = (Todo*)incidence; |
1132 | if ( t->hasDueDate() ) | 1138 | if ( t->hasDueDate() ) |
1133 | dt = t->dtDue(); | 1139 | dt = t->dtDue(); |
1134 | else | 1140 | else |
1135 | dt = cur.addSecs( 62 ); | 1141 | dt = cur.addSecs( 62 ); |
1136 | } | 1142 | } |
1137 | else { | 1143 | else { |
1138 | bool ok; | 1144 | bool ok; |
1139 | dt = incidence->getNextOccurence( cur, &ok ); | 1145 | dt = incidence->getNextOccurence( cur, &ok ); |
1140 | if ( !ok ) | 1146 | if ( !ok ) |
1141 | dt = cur.addSecs( -62 ); | 1147 | dt = cur.addSecs( -62 ); |
1142 | } | 1148 | } |
1143 | if ( dt < cur || dt > end ) { | 1149 | if ( dt < cur || dt > end ) { |
1144 | add = false; | 1150 | add = false; |
1145 | } | 1151 | } |
1146 | } | 1152 | } |
1147 | if ( add ) { | 1153 | if ( add ) { |
1148 | Incidence *in = incidence->clone(); | 1154 | Incidence *in = incidence->clone(); |
1149 | cal->addIncidence( in ); | 1155 | cal->addIncidence( in ); |
1150 | } | 1156 | } |
1151 | } | 1157 | } |
1152 | incidence = delSel.next(); | 1158 | incidence = delSel.next(); |
1153 | } | 1159 | } |
1154 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1160 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1155 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1161 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1156 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1162 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1157 | 1163 | ||
1158 | setCaption( i18n("Writing to phone...")); | 1164 | setCaption( i18n("Writing to phone...")); |
1159 | if ( PhoneFormat::writeToPhone( cal ) ) | 1165 | if ( PhoneFormat::writeToPhone( cal ) ) |
1160 | setCaption( i18n("Export to phone successful!")); | 1166 | setCaption( i18n("Export to phone successful!")); |
1161 | else | 1167 | else |
1162 | setCaption( i18n("Error exporting to phone!")); | 1168 | setCaption( i18n("Error exporting to phone!")); |
1163 | delete cal; | 1169 | delete cal; |
1164 | } | 1170 | } |
1165 | 1171 | ||
1166 | 1172 | ||
1167 | void MainWindow::setDefaultPreferences() | 1173 | void MainWindow::setDefaultPreferences() |
1168 | { | 1174 | { |
1169 | KOPrefs *p = KOPrefs::instance(); | 1175 | KOPrefs *p = KOPrefs::instance(); |
1170 | 1176 | ||
1171 | p->mCompactDialogs = true; | 1177 | p->mCompactDialogs = true; |
1172 | p->mConfirm = true; | 1178 | p->mConfirm = true; |
1173 | // p->mEnableQuickTodo = false; | 1179 | // p->mEnableQuickTodo = false; |
1174 | 1180 | ||
1175 | } | 1181 | } |
1176 | 1182 | ||
1177 | QString MainWindow::resourcePath() | 1183 | QString MainWindow::resourcePath() |
1178 | { | 1184 | { |
1179 | return KGlobal::iconLoader()->iconPath(); | 1185 | return KGlobal::iconLoader()->iconPath(); |
1180 | } | 1186 | } |
1181 | 1187 | ||
1182 | void MainWindow::displayText( QString text ,QString cap ) | 1188 | void MainWindow::displayText( QString text ,QString cap ) |
1183 | { | 1189 | { |
1184 | QDialog dia( this, "name", true ); ; | 1190 | QDialog dia( this, "name", true ); ; |
1185 | dia.setCaption( cap ); | 1191 | dia.setCaption( cap ); |
1186 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1192 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1187 | lay->setSpacing( 3 ); | 1193 | lay->setSpacing( 3 ); |
1188 | lay->setMargin( 3 ); | 1194 | lay->setMargin( 3 ); |
1189 | QTextBrowser tb ( &dia ); | 1195 | QTextBrowser tb ( &dia ); |
1190 | lay->addWidget( &tb ); | 1196 | lay->addWidget( &tb ); |
1191 | tb.setText( text ); | 1197 | tb.setText( text ); |
1192 | #ifdef DESKTOP_VERSION | 1198 | #ifdef DESKTOP_VERSION |
1193 | dia.resize( 640, 480); | 1199 | dia.resize( 640, 480); |
1194 | #else | 1200 | #else |
1195 | dia.showMaximized(); | 1201 | dia.showMaximized(); |
1196 | #endif | 1202 | #endif |
1197 | dia.exec(); | 1203 | dia.exec(); |
1198 | } | 1204 | } |
1199 | 1205 | ||
1200 | void MainWindow::features() | 1206 | void MainWindow::features() |
1201 | { | 1207 | { |
1202 | 1208 | ||
1203 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); | 1209 | KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); |
1204 | } | 1210 | } |
1205 | 1211 | ||
1206 | void MainWindow::usertrans() | 1212 | void MainWindow::usertrans() |
1207 | { | 1213 | { |
1208 | 1214 | ||
1209 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); | 1215 | KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); |
1210 | } | 1216 | } |
1211 | 1217 | ||
1212 | void MainWindow::kdesynchowto() | 1218 | void MainWindow::kdesynchowto() |
1213 | { | 1219 | { |
1214 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 1220 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
1215 | } | 1221 | } |
1216 | void MainWindow::multisynchowto() | 1222 | void MainWindow::multisynchowto() |
1217 | { | 1223 | { |
1218 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 1224 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
1219 | } | 1225 | } |
1220 | void MainWindow::synchowto() | 1226 | void MainWindow::synchowto() |
1221 | { | 1227 | { |
1222 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1228 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1223 | } | 1229 | } |
1224 | void MainWindow::faq() | 1230 | void MainWindow::faq() |
1225 | { | 1231 | { |
1226 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); | 1232 | KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); |
1227 | 1233 | ||
1228 | } | 1234 | } |
1229 | void MainWindow::whatsNew() | 1235 | void MainWindow::whatsNew() |
1230 | { | 1236 | { |
1231 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1237 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1232 | 1238 | ||
1233 | } | 1239 | } |
1234 | void MainWindow::licence() | 1240 | void MainWindow::licence() |
1235 | { | 1241 | { |
1236 | KApplication::showLicence(); | 1242 | KApplication::showLicence(); |
1237 | 1243 | ||
1238 | } | 1244 | } |
1239 | void MainWindow::about() | 1245 | void MainWindow::about() |
1240 | { | 1246 | { |
1241 | QString version; | 1247 | QString version; |
1242 | #include <../version> | 1248 | #include <../version> |
1243 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1249 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1244 | i18n("KOrganizer/Platform-independent\n") + | 1250 | i18n("KOrganizer/Platform-independent\n") + |
1245 | "(KO/Pi) " + version + " - " + | 1251 | "(KO/Pi) " + version + " - " + |
1246 | 1252 | ||
1247 | #ifdef DESKTOP_VERSION | 1253 | #ifdef DESKTOP_VERSION |
1248 | i18n("Desktop Edition\n") + | 1254 | i18n("Desktop Edition\n") + |
1249 | #else | 1255 | #else |
1250 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1256 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1251 | #endif | 1257 | #endif |
1252 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1258 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1253 | } | 1259 | } |
1254 | void MainWindow::keyBindings() | 1260 | void MainWindow::keyBindings() |
1255 | { | 1261 | { |
1256 | QString cap = i18n("KO/Pi Keys + Colors"); | 1262 | QString cap = i18n("KO/Pi Keys + Colors"); |
1257 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1263 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1258 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1264 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1259 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1265 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1260 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1266 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1261 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1267 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1262 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1268 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1263 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1269 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1264 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1270 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1265 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1271 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1266 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1272 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1267 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1273 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1268 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1274 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1269 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1275 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1270 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1276 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1271 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1277 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1272 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1278 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1273 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1279 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1274 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1280 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1275 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1281 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1276 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1282 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1277 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1283 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1278 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1284 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1279 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1285 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1280 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1286 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1281 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1287 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1282 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1288 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1283 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1289 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1284 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1290 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1285 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1291 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1286 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1292 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1287 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1293 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1288 | i18n("<p><h3>In list view:</h3></p>\n") + | 1294 | i18n("<p><h3>In list view:</h3></p>\n") + |
1289 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1295 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1290 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1296 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1291 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1297 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1292 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1298 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1293 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1299 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1294 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1300 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1295 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1301 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1296 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1302 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1297 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1303 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1298 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1304 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1299 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1305 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1300 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1306 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1301 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1307 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1302 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1308 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1303 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1309 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1304 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1310 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1305 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1311 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1306 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1312 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1307 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1313 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1308 | displayText( text, cap); | 1314 | displayText( text, cap); |
1309 | } | 1315 | } |
1310 | void MainWindow::aboutAutoSaving() | 1316 | void MainWindow::aboutAutoSaving() |
1311 | { | 1317 | { |
1312 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); | 1318 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); |
1313 | 1319 | ||
1314 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1320 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1315 | 1321 | ||
1316 | } | 1322 | } |
1317 | void MainWindow::aboutKnownBugs() | 1323 | void MainWindow::aboutKnownBugs() |
1318 | { | 1324 | { |
1319 | QMessageBox* msg; | 1325 | QMessageBox* msg; |
1320 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1326 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1321 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1327 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1322 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1328 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1323 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1329 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1324 | i18n("\nor report them in the bugtracker on\n") + | 1330 | i18n("\nor report them in the bugtracker on\n") + |
1325 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1331 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1326 | QMessageBox::NoIcon, | 1332 | QMessageBox::NoIcon, |
1327 | QMessageBox::Ok, | 1333 | QMessageBox::Ok, |
1328 | QMessageBox::NoButton, | 1334 | QMessageBox::NoButton, |
1329 | QMessageBox::NoButton); | 1335 | QMessageBox::NoButton); |
1330 | msg->exec(); | 1336 | msg->exec(); |
1331 | delete msg; | 1337 | delete msg; |
1332 | 1338 | ||
1333 | } | 1339 | } |
1334 | 1340 | ||
1335 | QString MainWindow::defaultFileName() | 1341 | QString MainWindow::defaultFileName() |
1336 | { | 1342 | { |
1337 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1343 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1338 | } | 1344 | } |
1339 | QString MainWindow::syncFileName() | 1345 | QString MainWindow::syncFileName() |
1340 | { | 1346 | { |
1341 | #ifdef DESKTOP_VERSION | 1347 | #ifdef DESKTOP_VERSION |
1342 | return locateLocal( "tmp", "synccalendar.ics" ); | 1348 | return locateLocal( "tmp", "synccalendar.ics" ); |
1343 | #else | 1349 | #else |
1344 | return QString( "/tmp/synccalendar.ics" ); | 1350 | return QString( "/tmp/synccalendar.ics" ); |
1345 | #endif | 1351 | #endif |
1346 | } | 1352 | } |
1347 | void MainWindow::updateWeek(QDate seda) | 1353 | void MainWindow::updateWeek(QDate seda) |
1348 | { | 1354 | { |
1349 | int weekNum = 0; | 1355 | int weekNum = 0; |
1350 | QDate d = QDate ( seda.year(), 1,1); | 1356 | QDate d = QDate ( seda.year(), 1,1); |
1351 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday | 1357 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday |
1352 | if ( seda.addDays(6).year() != seda.year() ) { | 1358 | if ( seda.addDays(6).year() != seda.year() ) { |
1353 | if ( seda.year() != d.year() ) { | 1359 | if ( seda.year() != d.year() ) { |
1354 | if ( d.dayOfWeek() > 4 ) | 1360 | if ( d.dayOfWeek() > 4 ) |
1355 | d = QDate ( seda.year(), 1,1); | 1361 | d = QDate ( seda.year(), 1,1); |
1356 | else | 1362 | else |
1357 | weekNum = 1; | 1363 | weekNum = 1; |
1358 | } else { | 1364 | } else { |
1359 | QDate dd( seda.year()+1, 1,1); | 1365 | QDate dd( seda.year()+1, 1,1); |
1360 | if ( dd.dayOfWeek() <= 4 ) | 1366 | if ( dd.dayOfWeek() <= 4 ) |
1361 | weekNum = 1; | 1367 | weekNum = 1; |
1362 | } | 1368 | } |
1363 | } | 1369 | } |
1364 | if ( weekNum == 0 ){ | 1370 | if ( weekNum == 0 ){ |
1365 | int dow = d.dayOfWeek(); | 1371 | int dow = d.dayOfWeek(); |
1366 | if ( dow <= 4 ) | 1372 | if ( dow <= 4 ) |
1367 | d = d.addDays( 1-dow ); | 1373 | d = d.addDays( 1-dow ); |
1368 | else // 5,6,7 | 1374 | else // 5,6,7 |
1369 | d = d.addDays( 8-dow ); | 1375 | d = d.addDays( 8-dow ); |
1370 | // we have the first week of the year.we are on monday | 1376 | // we have the first week of the year.we are on monday |
1371 | weekNum = d.daysTo( seda ) / 7 +1; | 1377 | weekNum = d.daysTo( seda ) / 7 +1; |
1372 | } | 1378 | } |
1373 | //qDebug("weeknum %s ", QString::number( weekNum).latin1()); | 1379 | |
1374 | menuBarWeek-> changeItem(1, QString::number( weekNum) ); | 1380 | mWeekPixmap.fill( mWeekBgColor ); |
1381 | QPainter p ( &mWeekPixmap ); | ||
1382 | p.setFont( mWeekFont ); | ||
1383 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | ||
1384 | p.end(); | ||
1385 | QIconSet icon3 ( mWeekPixmap ); | ||
1386 | mWeekAction->setIconSet ( icon3 ); | ||
1375 | 1387 | ||
1376 | } | 1388 | } |
1377 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1389 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1378 | { | 1390 | { |
1379 | updateWeek( selectedDates.first() ); | 1391 | updateWeek( selectedDates.first() ); |
1380 | } | 1392 | } |
1381 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1393 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1382 | { | 1394 | { |
1383 | 1395 | ||
1384 | if ( !incidence ) { | 1396 | if ( !incidence ) { |
1385 | enableIncidenceActions( false ); | 1397 | enableIncidenceActions( false ); |
1386 | 1398 | ||
1387 | mNewSubTodoAction->setEnabled( false ); | 1399 | mNewSubTodoAction->setEnabled( false ); |
1388 | setCaptionToDates(); | 1400 | setCaptionToDates(); |
1389 | return; | 1401 | return; |
1390 | 1402 | ||
1391 | } | 1403 | } |
1392 | 1404 | ||
1393 | //KGlobal::locale()->formatDateTime(nextA, true); | 1405 | //KGlobal::locale()->formatDateTime(nextA, true); |
1394 | QString startString = ""; | 1406 | QString startString = ""; |
1395 | if ( incidence->type() != "Todo" ) { | 1407 | if ( incidence->type() != "Todo" ) { |
1396 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1408 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1397 | if ( incidence->doesFloat() ) { | 1409 | if ( incidence->doesFloat() ) { |
1398 | startString += ": "+incidence->dtStartDateStr( true ); | 1410 | startString += ": "+incidence->dtStartDateStr( true ); |
1399 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1411 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1400 | 1412 | ||
1401 | } else { | 1413 | } else { |
1402 | startString = ": "+incidence->dtStartStr(true); | 1414 | startString = ": "+incidence->dtStartStr(true); |
1403 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1415 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1404 | 1416 | ||
1405 | } | 1417 | } |
1406 | 1418 | ||
1407 | } else { | 1419 | } else { |
1408 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1420 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1409 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1421 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1410 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1422 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1411 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { | 1423 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { |
1412 | bool ok; | 1424 | bool ok; |
1413 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1425 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1414 | if ( ok ) { | 1426 | if ( ok ) { |
1415 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1427 | int years = noc.date().year() - incidence->dtStart().date().year(); |
1416 | startString += i18n(" (%1 y.)"). arg( years ); | 1428 | startString += i18n(" (%1 y.)"). arg( years ); |
1417 | } | 1429 | } |
1418 | } | 1430 | } |
1419 | else | 1431 | else |
1420 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1432 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1421 | } | 1433 | } |
1422 | 1434 | ||
1423 | } | 1435 | } |
1424 | else | 1436 | else |
1425 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1437 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1426 | if ( !incidence->location().isEmpty() ) | 1438 | if ( !incidence->location().isEmpty() ) |
1427 | startString += " (" +incidence->location()+")"; | 1439 | startString += " (" +incidence->location()+")"; |
1428 | setCaption( incidence->summary()+startString); | 1440 | setCaption( incidence->summary()+startString); |
1429 | 1441 | ||
1430 | enableIncidenceActions( true ); | 1442 | enableIncidenceActions( true ); |
1431 | 1443 | ||
1432 | if ( incidence->type() == "Event" ) { | 1444 | if ( incidence->type() == "Event" ) { |
1433 | mShowAction->setText( i18n("Show Event...") ); | 1445 | mShowAction->setText( i18n("Show Event...") ); |
1434 | mEditAction->setText( i18n("Edit Event...") ); | 1446 | mEditAction->setText( i18n("Edit Event...") ); |
1435 | mDeleteAction->setText( i18n("Delete Event...") ); | 1447 | mDeleteAction->setText( i18n("Delete Event...") ); |
1436 | 1448 | ||
1437 | mNewSubTodoAction->setEnabled( false ); | 1449 | mNewSubTodoAction->setEnabled( false ); |
1438 | } else if ( incidence->type() == "Todo" ) { | 1450 | } else if ( incidence->type() == "Todo" ) { |
1439 | mShowAction->setText( i18n("Show Todo...") ); | 1451 | mShowAction->setText( i18n("Show Todo...") ); |
1440 | mEditAction->setText( i18n("Edit Todo...") ); | 1452 | mEditAction->setText( i18n("Edit Todo...") ); |
1441 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1453 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1442 | 1454 | ||
1443 | mNewSubTodoAction->setEnabled( true ); | 1455 | mNewSubTodoAction->setEnabled( true ); |
1444 | } else { | 1456 | } else { |
1445 | mShowAction->setText( i18n("Show...") ); | 1457 | mShowAction->setText( i18n("Show...") ); |
1446 | mShowAction->setText( i18n("Edit...") ); | 1458 | mShowAction->setText( i18n("Edit...") ); |
1447 | mShowAction->setText( i18n("Delete...") ); | 1459 | mShowAction->setText( i18n("Delete...") ); |
1448 | 1460 | ||
1449 | mNewSubTodoAction->setEnabled( false ); | 1461 | mNewSubTodoAction->setEnabled( false ); |
1450 | } | 1462 | } |
1451 | } | 1463 | } |
1452 | 1464 | ||
1453 | void MainWindow::enableIncidenceActions( bool enabled ) | 1465 | void MainWindow::enableIncidenceActions( bool enabled ) |
1454 | { | 1466 | { |
1455 | mShowAction->setEnabled( enabled ); | 1467 | mShowAction->setEnabled( enabled ); |
1456 | mEditAction->setEnabled( enabled ); | 1468 | mEditAction->setEnabled( enabled ); |
1457 | mDeleteAction->setEnabled( enabled ); | 1469 | mDeleteAction->setEnabled( enabled ); |
1458 | 1470 | ||
1459 | mCloneAction->setEnabled( enabled ); | 1471 | mCloneAction->setEnabled( enabled ); |
1460 | mMoveAction->setEnabled( enabled ); | 1472 | mMoveAction->setEnabled( enabled ); |
1461 | mBeamAction->setEnabled( enabled ); | 1473 | mBeamAction->setEnabled( enabled ); |
1462 | mCancelAction->setEnabled( enabled ); | 1474 | mCancelAction->setEnabled( enabled ); |
1463 | } | 1475 | } |
1464 | 1476 | ||
1465 | void MainWindow::importOL() | 1477 | void MainWindow::importOL() |
1466 | { | 1478 | { |
1467 | #ifdef _OL_IMPORT_ | 1479 | #ifdef _OL_IMPORT_ |
1468 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1480 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1469 | id->exec(); | 1481 | id->exec(); |
1470 | delete id; | 1482 | delete id; |
1471 | mView->updateView(); | 1483 | mView->updateView(); |
1472 | #endif | 1484 | #endif |
1473 | } | 1485 | } |
1474 | void MainWindow::importBday() | 1486 | void MainWindow::importBday() |
1475 | { | 1487 | { |
1476 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1488 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1477 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1489 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1478 | i18n("Import!"), i18n("Cancel"), 0, | 1490 | i18n("Import!"), i18n("Cancel"), 0, |
1479 | 0, 1 ); | 1491 | 0, 1 ); |
1480 | if ( result == 0 ) { | 1492 | if ( result == 0 ) { |
1481 | mView->importBday(); | 1493 | mView->importBday(); |
1482 | 1494 | ||
1483 | } | 1495 | } |
1484 | 1496 | ||
1485 | 1497 | ||
1486 | } | 1498 | } |
1487 | void MainWindow::importQtopia() | 1499 | void MainWindow::importQtopia() |
1488 | { | 1500 | { |
1489 | #ifndef DESKTOP_VERSION | 1501 | #ifndef DESKTOP_VERSION |
1490 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1502 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1491 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1503 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1492 | i18n("Import!"), i18n("Cancel"), 0, | 1504 | i18n("Import!"), i18n("Cancel"), 0, |
1493 | 0, 1 ); | 1505 | 0, 1 ); |
1494 | if ( result == 0 ) { | 1506 | if ( result == 0 ) { |
1495 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1507 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1496 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1508 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1497 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1509 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1498 | mView->importQtopia( categories, datebook, todolist ); | 1510 | mView->importQtopia( categories, datebook, todolist ); |
1499 | } | 1511 | } |
1500 | #else | 1512 | #else |
1501 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1513 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1502 | i18n("Not supported \non desktop!\n"), | 1514 | i18n("Not supported \non desktop!\n"), |
1503 | i18n("Ok"), i18n("Cancel"), 0, | 1515 | i18n("Ok"), i18n("Cancel"), 0, |
1504 | 0, 1 ); | 1516 | 0, 1 ); |
1505 | 1517 | ||
1506 | #endif | 1518 | #endif |
1507 | } | 1519 | } |
1508 | 1520 | ||
1509 | void MainWindow::saveOnClose() | 1521 | void MainWindow::saveOnClose() |
1510 | { | 1522 | { |
1511 | KOPrefs *p = KOPrefs::instance(); | 1523 | KOPrefs *p = KOPrefs::instance(); |
1512 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1524 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1513 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1525 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1514 | iconToolBar->y() > height()/2; | 1526 | iconToolBar->y() > height()/2; |
1515 | mView->writeSettings(); | 1527 | mView->writeSettings(); |
1516 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1528 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1517 | save(); | 1529 | save(); |
1518 | } | 1530 | } |
1519 | void MainWindow::slotModifiedChanged( bool changed ) | 1531 | void MainWindow::slotModifiedChanged( bool changed ) |
1520 | { | 1532 | { |
1521 | if ( mBlockAtStartup ) | 1533 | if ( mBlockAtStartup ) |
1522 | return; | 1534 | return; |
1523 | 1535 | ||
1524 | int msec; | 1536 | int msec; |
1525 | // we store the changes after 1 minute, | 1537 | // we store the changes after 1 minute, |
1526 | // and for safety reasons after 10 minutes again | 1538 | // and for safety reasons after 10 minutes again |
1527 | if ( !mSyncManager->blockSave() ) | 1539 | if ( !mSyncManager->blockSave() ) |
1528 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1540 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1529 | else | 1541 | else |
1530 | msec = 1000 * 600; | 1542 | msec = 1000 * 600; |
1531 | mSaveTimer.start( msec, true ); // 1 minute | 1543 | mSaveTimer.start( msec, true ); // 1 minute |
1532 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1544 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1533 | mCalendarModifiedFlag = true; | 1545 | mCalendarModifiedFlag = true; |
1534 | } | 1546 | } |
1535 | void MainWindow::saveStopTimer() | 1547 | void MainWindow::saveStopTimer() |
1536 | { | 1548 | { |
1537 | mSaveTimer.stop(); | 1549 | mSaveTimer.stop(); |
1538 | if (mSaveTimer.isActive() ) | 1550 | if (mSaveTimer.isActive() ) |
1539 | qDebug("ti active "); | 1551 | qDebug("ti active "); |
1540 | else | 1552 | else |
1541 | qDebug("KO: Save timer stopped"); | 1553 | qDebug("KO: Save timer stopped"); |
1542 | } | 1554 | } |
1543 | void MainWindow::save() | 1555 | void MainWindow::save() |
1544 | { | 1556 | { |
1545 | if ( !mCalendarModifiedFlag ) { | 1557 | if ( !mCalendarModifiedFlag ) { |
1546 | qDebug("KO: Calendar not modified. Nothing saved."); | 1558 | qDebug("KO: Calendar not modified. Nothing saved."); |
1547 | return; | 1559 | return; |
1548 | } | 1560 | } |
1549 | if ( mSyncManager->blockSave() ) | 1561 | if ( mSyncManager->blockSave() ) |
1550 | return; | 1562 | return; |
1551 | mSyncManager->setBlockSave(true); | 1563 | mSyncManager->setBlockSave(true); |
1552 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1564 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1553 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1565 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1554 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1566 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1555 | qDebug("KO: Start saving data to file!"); | 1567 | qDebug("KO: Start saving data to file!"); |
1556 | mView->saveCalendar( defaultFileName() ); | 1568 | mView->saveCalendar( defaultFileName() ); |
1557 | mCalendarModifiedFlag = false; | 1569 | mCalendarModifiedFlag = false; |
1558 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1570 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1559 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1571 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1560 | QString savemes; | 1572 | QString savemes; |
1561 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1573 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1562 | setCaption(savemes); | 1574 | setCaption(savemes); |
1563 | } else | 1575 | } else |
1564 | setCaption(i18n("Saving cancelled!")); | 1576 | setCaption(i18n("Saving cancelled!")); |
1565 | mSyncManager->setBlockSave( false ); | 1577 | mSyncManager->setBlockSave( false ); |
1566 | } | 1578 | } |
1567 | 1579 | ||
1568 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1580 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1569 | { | 1581 | { |
1570 | if ( !e->isAutoRepeat() ) { | 1582 | if ( !e->isAutoRepeat() ) { |
1571 | mFlagKeyPressed = false; | 1583 | mFlagKeyPressed = false; |
1572 | } | 1584 | } |
1573 | } | 1585 | } |
1574 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1586 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1575 | { | 1587 | { |
1576 | qApp->processEvents(); | 1588 | qApp->processEvents(); |
1577 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1589 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1578 | e->ignore(); | 1590 | e->ignore(); |
1579 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1591 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1580 | return; | 1592 | return; |
1581 | } | 1593 | } |
1582 | if (! e->isAutoRepeat() ) | 1594 | if (! e->isAutoRepeat() ) |
1583 | mFlagKeyPressed = true; | 1595 | mFlagKeyPressed = true; |
1584 | KOPrefs *p = KOPrefs::instance(); | 1596 | KOPrefs *p = KOPrefs::instance(); |
1585 | bool showSelectedDates = false; | 1597 | bool showSelectedDates = false; |
1586 | int size; | 1598 | int size; |
1587 | int pro = 0; | 1599 | int pro = 0; |
1588 | //qDebug("MainWindow::keyPressEvent "); | 1600 | //qDebug("MainWindow::keyPressEvent "); |
1589 | switch ( e->key() ) { | 1601 | switch ( e->key() ) { |
1590 | case Qt::Key_Right: | 1602 | case Qt::Key_Right: |
1591 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1603 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1592 | mView->goNextMonth(); | 1604 | mView->goNextMonth(); |
1593 | else | 1605 | else |
1594 | mView->goNext(); | 1606 | mView->goNext(); |
1595 | showSelectedDates = true; | 1607 | showSelectedDates = true; |
1596 | break; | 1608 | break; |
1597 | case Qt::Key_Left: | 1609 | case Qt::Key_Left: |
1598 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1610 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1599 | mView->goPreviousMonth(); | 1611 | mView->goPreviousMonth(); |
1600 | else | 1612 | else |
1601 | mView->goPrevious(); | 1613 | mView->goPrevious(); |
1602 | showSelectedDates = true; | 1614 | showSelectedDates = true; |
1603 | break; | 1615 | break; |
1604 | case Qt::Key_Down: | 1616 | case Qt::Key_Down: |
1605 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1617 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1606 | break; | 1618 | break; |
1607 | case Qt::Key_Up: | 1619 | case Qt::Key_Up: |
1608 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1620 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1609 | break; | 1621 | break; |
1610 | case Qt::Key_I: | 1622 | case Qt::Key_I: |
1611 | mView->showIncidence(); | 1623 | mView->showIncidence(); |
1612 | break; | 1624 | break; |
1613 | case Qt::Key_Delete: | 1625 | case Qt::Key_Delete: |
1614 | case Qt::Key_Backspace: | 1626 | case Qt::Key_Backspace: |
1615 | mView->deleteIncidence(); | 1627 | mView->deleteIncidence(); |
1616 | break; | 1628 | break; |
1617 | case Qt::Key_D: | 1629 | case Qt::Key_D: |
1618 | mView->viewManager()->showDayView(); | 1630 | mView->viewManager()->showDayView(); |
1619 | showSelectedDates = true; | 1631 | showSelectedDates = true; |
1620 | break; | 1632 | break; |
1621 | case Qt::Key_O: | 1633 | case Qt::Key_O: |
1622 | mView->toggleFilerEnabled( ); | 1634 | mView->toggleFilerEnabled( ); |
1623 | break; | 1635 | break; |
1624 | case Qt::Key_0: | 1636 | case Qt::Key_0: |
1625 | case Qt::Key_1: | 1637 | case Qt::Key_1: |
1626 | case Qt::Key_2: | 1638 | case Qt::Key_2: |
1627 | case Qt::Key_3: | 1639 | case Qt::Key_3: |
1628 | case Qt::Key_4: | 1640 | case Qt::Key_4: |
1629 | case Qt::Key_5: | 1641 | case Qt::Key_5: |
1630 | case Qt::Key_6: | 1642 | case Qt::Key_6: |
1631 | case Qt::Key_7: | 1643 | case Qt::Key_7: |
1632 | case Qt::Key_8: | 1644 | case Qt::Key_8: |
1633 | case Qt::Key_9: | 1645 | case Qt::Key_9: |
1634 | pro = e->key()-48; | 1646 | pro = e->key()-48; |
1635 | if ( pro == 0 ) | 1647 | if ( pro == 0 ) |
1636 | pro = 10; | 1648 | pro = 10; |
1637 | if ( e->state() == Qt::ControlButton) | 1649 | if ( e->state() == Qt::ControlButton) |
1638 | pro += 10; | 1650 | pro += 10; |
1639 | break; | 1651 | break; |
1640 | case Qt::Key_M: | 1652 | case Qt::Key_M: |
1641 | mView->viewManager()->showMonthView(); | 1653 | mView->viewManager()->showMonthView(); |
1642 | showSelectedDates = true; | 1654 | showSelectedDates = true; |
1643 | break; | 1655 | break; |
1644 | case Qt::Key_Insert: | 1656 | case Qt::Key_Insert: |
1645 | mView->newEvent(); | 1657 | mView->newEvent(); |
1646 | break; | 1658 | break; |
1647 | case Qt::Key_S : | 1659 | case Qt::Key_S : |
1648 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1660 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1649 | mView->newSubTodo(); | 1661 | mView->newSubTodo(); |
1650 | else | 1662 | else |
1651 | mView->dialogManager()->showSearchDialog(); | 1663 | mView->dialogManager()->showSearchDialog(); |
1652 | break; | 1664 | break; |
1653 | case Qt::Key_Y : | 1665 | case Qt::Key_Y : |
1654 | case Qt::Key_Z : | 1666 | case Qt::Key_Z : |
1655 | mView->viewManager()->showWorkWeekView(); | 1667 | mView->viewManager()->showWorkWeekView(); |
1656 | showSelectedDates = true; | 1668 | showSelectedDates = true; |
1657 | break; | 1669 | break; |
1658 | case Qt::Key_U : | 1670 | case Qt::Key_U : |
1659 | mView->viewManager()->showWeekView(); | 1671 | mView->viewManager()->showWeekView(); |
1660 | showSelectedDates = true; | 1672 | showSelectedDates = true; |
1661 | break; | 1673 | break; |
1662 | case Qt::Key_H : | 1674 | case Qt::Key_H : |
1663 | keyBindings(); | 1675 | keyBindings(); |
1664 | break; | 1676 | break; |
1665 | case Qt::Key_W: | 1677 | case Qt::Key_W: |
1666 | mView->viewManager()->showWhatsNextView(); | 1678 | mView->viewManager()->showWhatsNextView(); |
1667 | break; | 1679 | break; |
1668 | case Qt::Key_L: | 1680 | case Qt::Key_L: |
1669 | mView->viewManager()->showListView(); | 1681 | mView->viewManager()->showListView(); |
1670 | break; | 1682 | break; |
1671 | case Qt::Key_N: | 1683 | case Qt::Key_N: |
1672 | mView->viewManager()->showNextXView(); | 1684 | mView->viewManager()->showNextXView(); |
1673 | showSelectedDates = true; | 1685 | showSelectedDates = true; |
1674 | break; | 1686 | break; |
1675 | case Qt::Key_V: | 1687 | case Qt::Key_V: |
1676 | mView->viewManager()->showTodoView(); | 1688 | mView->viewManager()->showTodoView(); |
1677 | break; | 1689 | break; |
1678 | case Qt::Key_C: | 1690 | case Qt::Key_C: |
1679 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1691 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1680 | break; | 1692 | break; |
1681 | case Qt::Key_P: | 1693 | case Qt::Key_P: |
1682 | mView->showDatePicker( ); | 1694 | mView->showDatePicker( ); |
1683 | break; | 1695 | break; |
1684 | case Qt::Key_F: | 1696 | case Qt::Key_F: |
1685 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1697 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1686 | mView->editFilters(); | 1698 | mView->editFilters(); |
1687 | else | 1699 | else |
1688 | mView->toggleFilter(); | 1700 | mView->toggleFilter(); |
1689 | break; | 1701 | break; |
1690 | case Qt::Key_X: | 1702 | case Qt::Key_X: |
1691 | mView->toggleDateNavigatorWidget(); | 1703 | mView->toggleDateNavigatorWidget(); |
1692 | break; | 1704 | break; |
1693 | case Qt::Key_Space: | 1705 | case Qt::Key_Space: |
1694 | mView->toggleExpand(); | 1706 | mView->toggleExpand(); |
1695 | break; | 1707 | break; |
1696 | case Qt::Key_A: | 1708 | case Qt::Key_A: |
1697 | mView->toggleAllDaySize(); | 1709 | mView->toggleAllDaySize(); |
1698 | break; | 1710 | break; |
1699 | case Qt::Key_T: | 1711 | case Qt::Key_T: |
1700 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1712 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1701 | mView->newTodo(); | 1713 | mView->newTodo(); |
1702 | else { | 1714 | else { |
1703 | mView->goToday(); | 1715 | mView->goToday(); |
1704 | showSelectedDates = true; | 1716 | showSelectedDates = true; |
1705 | } | 1717 | } |
1706 | break; | 1718 | break; |
1707 | case Qt::Key_J: | 1719 | case Qt::Key_J: |
1708 | mView->viewManager()->showJournalView(); | 1720 | mView->viewManager()->showJournalView(); |
1709 | break; | 1721 | break; |
1710 | case Qt::Key_B: | 1722 | case Qt::Key_B: |
1711 | mView->editIncidenceDescription();; | 1723 | mView->editIncidenceDescription();; |
1712 | break; | 1724 | break; |
1713 | // case Qt::Key_Return: | 1725 | // case Qt::Key_Return: |
1714 | case Qt::Key_E: | 1726 | case Qt::Key_E: |
1715 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1727 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1716 | mView->newEvent(); | 1728 | mView->newEvent(); |
1717 | else | 1729 | else |
1718 | mView->editIncidence(); | 1730 | mView->editIncidence(); |
1719 | break; | 1731 | break; |
1720 | case Qt::Key_Plus: | 1732 | case Qt::Key_Plus: |
1721 | size = p->mHourSize +2; | 1733 | size = p->mHourSize +2; |
1722 | if ( size <= 18 ) | 1734 | if ( size <= 22 ) |
1723 | configureAgenda( size ); | 1735 | configureAgenda( size ); |
1724 | break; | 1736 | break; |
1725 | case Qt::Key_Minus: | 1737 | case Qt::Key_Minus: |
1726 | size = p->mHourSize - 2; | 1738 | size = p->mHourSize - 2; |
1727 | if ( size >= 4 ) | 1739 | if ( size >= 4 ) |
1728 | configureAgenda( size ); | 1740 | configureAgenda( size ); |
1729 | break; | 1741 | break; |
1730 | 1742 | ||
1731 | 1743 | ||
1732 | default: | 1744 | default: |
1733 | e->ignore(); | 1745 | e->ignore(); |
1734 | } | 1746 | } |
1735 | if ( pro > 0 ) { | 1747 | if ( pro > 0 ) { |
1736 | mView->selectFilter( pro-1 ); | 1748 | mView->selectFilter( pro-1 ); |
1737 | } | 1749 | } |
1738 | if ( showSelectedDates ) { | 1750 | if ( showSelectedDates ) { |
1739 | ;// setCaptionToDates(); | 1751 | ;// setCaptionToDates(); |
1740 | } | 1752 | } |
1741 | 1753 | ||
1742 | } | 1754 | } |
1743 | 1755 | ||
1744 | void MainWindow::fillFilterMenu() | 1756 | void MainWindow::fillFilterMenu() |
1745 | { | 1757 | { |
1746 | selectFilterMenu->clear(); | 1758 | selectFilterMenu->clear(); |
1747 | bool disable = false; | 1759 | bool disable = false; |
1748 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); | 1760 | selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); |
1749 | selectFilterMenu->insertSeparator(); | 1761 | selectFilterMenu->insertSeparator(); |
1750 | if ( mView->filterView()->filtersEnabled() ) { | 1762 | if ( mView->filterView()->filtersEnabled() ) { |
1751 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); | 1763 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); |
1752 | } | 1764 | } |
1753 | else { | 1765 | else { |
1754 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); | 1766 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); |
1755 | disable = true; | 1767 | disable = true; |
1756 | } | 1768 | } |
1757 | selectFilterMenu->insertSeparator(); | 1769 | selectFilterMenu->insertSeparator(); |
1758 | QPtrList<CalFilter> fili = mView->filters(); | 1770 | QPtrList<CalFilter> fili = mView->filters(); |
1759 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1771 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1760 | CalFilter *filter = fili.first(); | 1772 | CalFilter *filter = fili.first(); |
1761 | int iii = 2; | 1773 | int iii = 2; |
1762 | while(filter) { | 1774 | while(filter) { |
1763 | selectFilterMenu->insertItem( filter->name(), iii ); | 1775 | selectFilterMenu->insertItem( filter->name(), iii ); |
1764 | if ( filter == curfilter) | 1776 | if ( filter == curfilter) |
1765 | selectFilterMenu->setItemChecked( iii, true ); | 1777 | selectFilterMenu->setItemChecked( iii, true ); |
1766 | if ( disable ) | 1778 | if ( disable ) |
1767 | selectFilterMenu->setItemEnabled( iii, false ); | 1779 | selectFilterMenu->setItemEnabled( iii, false ); |
1768 | filter = fili.next(); | 1780 | filter = fili.next(); |
1769 | ++iii; | 1781 | ++iii; |
1770 | } | 1782 | } |
1771 | } | 1783 | } |
1772 | void MainWindow::selectFilter( int fil ) | 1784 | void MainWindow::selectFilter( int fil ) |
1773 | { | 1785 | { |
1774 | if ( fil == 0 ) { | 1786 | if ( fil == 0 ) { |
1775 | mView->editFilters( ); | 1787 | mView->editFilters( ); |
1776 | } else if ( fil == 1 ){ | 1788 | } else if ( fil == 1 ){ |
1777 | mView->toggleFilerEnabled( ); | 1789 | mView->toggleFilerEnabled( ); |
1778 | } else { | 1790 | } else { |
1779 | mView->selectFilter( fil-2 ); | 1791 | mView->selectFilter( fil-2 ); |
1780 | } | 1792 | } |
1781 | } | 1793 | } |
1782 | void MainWindow::configureToolBar( int item ) | 1794 | void MainWindow::configureToolBar( int item ) |
1783 | { | 1795 | { |
1784 | 1796 | ||
1785 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1797 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1786 | KOPrefs *p = KOPrefs::instance(); | 1798 | KOPrefs *p = KOPrefs::instance(); |
1787 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1799 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1788 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1800 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1789 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1801 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1790 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1802 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1791 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1803 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1792 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1804 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1793 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1805 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1794 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1806 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1795 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1807 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1796 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1808 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1797 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1809 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1798 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1810 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1799 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1811 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1800 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1812 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1801 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1813 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1802 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1814 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1803 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1815 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1804 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1816 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1805 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1817 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1806 | // initActions(); | 1818 | // initActions(); |
1807 | } | 1819 | } |
1808 | 1820 | ||
1809 | void MainWindow::setCaptionToDates() | 1821 | void MainWindow::setCaptionToDates() |
1810 | { | 1822 | { |
1811 | QString selDates; | 1823 | QString selDates; |
1812 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1824 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1813 | if (mView->startDate() < mView->endDate() ) | 1825 | if (mView->startDate() < mView->endDate() ) |
1814 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1826 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1815 | else { | 1827 | else { |
1816 | QString addString; | 1828 | QString addString; |
1817 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) | 1829 | if ( mView->startDate() == QDateTime::currentDateTime().date() ) |
1818 | addString = i18n("Today"); | 1830 | addString = i18n("Today"); |
1819 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) | 1831 | else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) |
1820 | addString = i18n("Tomorrow"); | 1832 | addString = i18n("Tomorrow"); |
1821 | if ( !addString.isEmpty() ) | 1833 | if ( !addString.isEmpty() ) |
1822 | selDates = addString+", "+selDates ; | 1834 | selDates = addString+", "+selDates ; |
1823 | } | 1835 | } |
1824 | setCaption( i18n("Dates: ") + selDates ); | 1836 | setCaption( i18n("Dates: ") + selDates ); |
1825 | 1837 | ||
1826 | } | 1838 | } |
1827 | void MainWindow::showConfigureAgenda( ) | 1839 | void MainWindow::showConfigureAgenda( ) |
1828 | { | 1840 | { |
1829 | int iii; | 1841 | int iii; |
1830 | for ( iii = 1;iii<= 10 ;++iii ){ | 1842 | for ( iii = 1;iii<= 10 ;++iii ){ |
1831 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); | 1843 | configureAgendaMenu->setItemChecked( (iii+1)*2, false ); |
1832 | } | 1844 | } |
1833 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); | 1845 | configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); |
1834 | } | 1846 | } |
1835 | void MainWindow::configureAgenda( int item ) | 1847 | void MainWindow::configureAgenda( int item ) |
1836 | { | 1848 | { |
1837 | if ( KOPrefs::instance()->mHourSize == item ) | 1849 | if ( KOPrefs::instance()->mHourSize == item ) |
1838 | return; | 1850 | return; |
1839 | KOPrefs::instance()->mHourSize=item; | 1851 | KOPrefs::instance()->mHourSize=item; |
1840 | mView->viewManager()->agendaView()->updateConfig(); | 1852 | mView->viewManager()->agendaView()->updateConfig(); |
1841 | } | 1853 | } |
1842 | 1854 | ||
1843 | void MainWindow::saveCalendar() | 1855 | void MainWindow::saveCalendar() |
1844 | { | 1856 | { |
1845 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1857 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1846 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1858 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1847 | 1859 | ||
1848 | if ( fn == "" ) | 1860 | if ( fn == "" ) |
1849 | return; | 1861 | return; |
1850 | QFileInfo info; | 1862 | QFileInfo info; |
1851 | info.setFile( fn ); | 1863 | info.setFile( fn ); |
1852 | QString mes; | 1864 | QString mes; |
1853 | bool createbup = true; | 1865 | bool createbup = true; |
1854 | if ( info. exists() ) { | 1866 | if ( info. exists() ) { |
1855 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1867 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1856 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1868 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1857 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1869 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1858 | 0, 1 ); | 1870 | 0, 1 ); |
1859 | if ( result != 0 ) { | 1871 | if ( result != 0 ) { |
1860 | createbup = false; | 1872 | createbup = false; |
1861 | } | 1873 | } |
1862 | } | 1874 | } |
1863 | if ( createbup ) { | 1875 | if ( createbup ) { |
1864 | mView->saveCalendar( fn ); | 1876 | mView->saveCalendar( fn ); |
1865 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1877 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1866 | KOPrefs::instance()->mLastSaveFile = fn; | 1878 | KOPrefs::instance()->mLastSaveFile = fn; |
1867 | setCaption(mes); | 1879 | setCaption(mes); |
1868 | } | 1880 | } |
1869 | } | 1881 | } |
1870 | void MainWindow::loadCalendar() | 1882 | void MainWindow::loadCalendar() |
1871 | { | 1883 | { |
1872 | 1884 | ||
1873 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1885 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1874 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1886 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1875 | 1887 | ||
1876 | if ( fn == "" ) | 1888 | if ( fn == "" ) |
1877 | return; | 1889 | return; |
1878 | QFileInfo info; | 1890 | QFileInfo info; |
1879 | info.setFile( fn ); | 1891 | info.setFile( fn ); |
1880 | QString mess; | 1892 | QString mess; |
1881 | bool loadbup = true; | 1893 | bool loadbup = true; |
1882 | if ( info. exists() ) { | 1894 | if ( info. exists() ) { |
1883 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1895 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1884 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1896 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1885 | mess, | 1897 | mess, |
1886 | i18n("Load!"), i18n("Cancel"), 0, | 1898 | i18n("Load!"), i18n("Cancel"), 0, |
1887 | 0, 1 ); | 1899 | 0, 1 ); |
1888 | if ( result != 0 ) { | 1900 | if ( result != 0 ) { |
1889 | loadbup = false; | 1901 | loadbup = false; |
1890 | } | 1902 | } |
1891 | } else { | 1903 | } else { |
1892 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1904 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1893 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1905 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1894 | 0, 1 ); | 1906 | 0, 1 ); |
1895 | 1907 | ||
1896 | return; | 1908 | return; |
1897 | } | 1909 | } |
1898 | if ( loadbup ) { | 1910 | if ( loadbup ) { |
1899 | mView->openCalendar( fn ); | 1911 | mView->openCalendar( fn ); |
1900 | KOPrefs::instance()->mLastLoadFile = fn; | 1912 | KOPrefs::instance()->mLastLoadFile = fn; |
1901 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1913 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1902 | setCaption(mess); | 1914 | setCaption(mess); |
1903 | } | 1915 | } |
1904 | 1916 | ||
1905 | } | 1917 | } |
1906 | void MainWindow::quickImportIcal() | 1918 | void MainWindow::quickImportIcal() |
1907 | { | 1919 | { |
1908 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1920 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1909 | } | 1921 | } |
1910 | void MainWindow::importFile( QString fn, bool quick ) | 1922 | void MainWindow::importFile( QString fn, bool quick ) |
1911 | { | 1923 | { |
1912 | QFileInfo info; | 1924 | QFileInfo info; |
1913 | info.setFile( fn ); | 1925 | info.setFile( fn ); |
1914 | QString mess; | 1926 | QString mess; |
1915 | bool loadbup = true; | 1927 | bool loadbup = true; |
1916 | if ( !info. exists() ) { | 1928 | if ( !info. exists() ) { |
1917 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1929 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1918 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1930 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1919 | mess ); | 1931 | mess ); |
1920 | return; | 1932 | return; |
1921 | } | 1933 | } |
1922 | int result = 0; | 1934 | int result = 0; |
1923 | if ( !quick ) { | 1935 | if ( !quick ) { |
1924 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1936 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1925 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1937 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1926 | mess, | 1938 | mess, |
1927 | "Import", "Cancel", 0, | 1939 | "Import", "Cancel", 0, |
1928 | 0, 1 ); | 1940 | 0, 1 ); |
1929 | } | 1941 | } |
1930 | if ( result == 0 ) { | 1942 | if ( result == 0 ) { |
1931 | if ( mView->openCalendar( fn, true )) { | 1943 | if ( mView->openCalendar( fn, true )) { |
1932 | KOPrefs::instance()->mLastImportFile = fn; | 1944 | KOPrefs::instance()->mLastImportFile = fn; |
1933 | setCaption(i18n("Imported file successfully")); | 1945 | setCaption(i18n("Imported file successfully")); |
1934 | } else { | 1946 | } else { |
1935 | setCaption(i18n("Error importing file")); | 1947 | setCaption(i18n("Error importing file")); |
1936 | } | 1948 | } |
1937 | } | 1949 | } |
1938 | } | 1950 | } |
1939 | 1951 | ||
1940 | void MainWindow::importIcal() | 1952 | void MainWindow::importIcal() |
1941 | { | 1953 | { |
1942 | 1954 | ||
1943 | QString fn =KOPrefs::instance()->mLastImportFile; | 1955 | QString fn =KOPrefs::instance()->mLastImportFile; |
1944 | 1956 | ||
1945 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1957 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1946 | if ( fn == "" ) | 1958 | if ( fn == "" ) |
1947 | return; | 1959 | return; |
1948 | importFile( fn, true ); | 1960 | importFile( fn, true ); |
1949 | 1961 | ||
1950 | } | 1962 | } |
1951 | 1963 | ||
1952 | void MainWindow::exportVCalendar() | 1964 | void MainWindow::exportVCalendar() |
1953 | { | 1965 | { |
1954 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1966 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1955 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1967 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1956 | if ( fn == "" ) | 1968 | if ( fn == "" ) |
1957 | return; | 1969 | return; |
1958 | QFileInfo info; | 1970 | QFileInfo info; |
1959 | info.setFile( fn ); | 1971 | info.setFile( fn ); |
1960 | QString mes; | 1972 | QString mes; |
1961 | bool createbup = true; | 1973 | bool createbup = true; |
1962 | if ( info. exists() ) { | 1974 | if ( info. exists() ) { |
1963 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1975 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1964 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1976 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1965 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1977 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1966 | 0, 1 ); | 1978 | 0, 1 ); |
1967 | if ( result != 0 ) { | 1979 | if ( result != 0 ) { |
1968 | createbup = false; | 1980 | createbup = false; |
1969 | } | 1981 | } |
1970 | } | 1982 | } |
1971 | if ( createbup ) { | 1983 | if ( createbup ) { |
1972 | if ( mView->exportVCalendar( fn ) ) { | 1984 | if ( mView->exportVCalendar( fn ) ) { |
1973 | KOPrefs::instance()->mLastVcalFile = fn; | 1985 | KOPrefs::instance()->mLastVcalFile = fn; |
1974 | if ( fn.length() > 20 ) | 1986 | if ( fn.length() > 20 ) |
1975 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1987 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1976 | else | 1988 | else |
1977 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1989 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1978 | setCaption(mes); | 1990 | setCaption(mes); |
1979 | } | 1991 | } |
1980 | } | 1992 | } |
1981 | 1993 | ||
1982 | } | 1994 | } |
1983 | 1995 | ||
1984 | void MainWindow::syncFileRequest() | 1996 | void MainWindow::syncFileRequest() |
1985 | { | 1997 | { |
1986 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 1998 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1987 | mSyncManager->slotSyncMenu( 999 ); | 1999 | mSyncManager->slotSyncMenu( 999 ); |
1988 | } | 2000 | } |
1989 | save(); | 2001 | save(); |
1990 | } | 2002 | } |
1991 | void MainWindow::getFile( bool success ) | 2003 | void MainWindow::getFile( bool success ) |
1992 | { | 2004 | { |
1993 | if ( ! success ) { | 2005 | if ( ! success ) { |
1994 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2006 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
1995 | return; | 2007 | return; |
1996 | } | 2008 | } |
1997 | mView->openCalendar( defaultFileName() ); | 2009 | mView->openCalendar( defaultFileName() ); |
1998 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2010 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
1999 | mSyncManager->slotSyncMenu( 999 ); | 2011 | mSyncManager->slotSyncMenu( 999 ); |
2000 | } | 2012 | } |
2001 | setCaption( i18n("Pi-Sync successful!") ); | 2013 | setCaption( i18n("Pi-Sync successful!") ); |
2002 | } | 2014 | } |
2003 | 2015 | ||
2004 | void MainWindow::printSel( ) | 2016 | void MainWindow::printSel( ) |
2005 | { | 2017 | { |
2006 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2018 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2007 | } | 2019 | } |
2008 | 2020 | ||
2009 | void MainWindow::printCal() | 2021 | void MainWindow::printCal() |
2010 | { | 2022 | { |
2011 | mView->print();//mCp->showDialog(); | 2023 | mView->print();//mCp->showDialog(); |
2012 | } | 2024 | } |
2013 | 2025 | ||
2026 | |||
2027 | #include "libkdepim/kdatepicker.h" | ||
2028 | #include <kdatetbl.h> | ||
2029 | void MainWindow::weekAction() | ||
2030 | { | ||
2031 | int month; | ||
2032 | KPopupFrame* popup = new KPopupFrame(this); | ||
2033 | int size = 12; | ||
2034 | if ( QApplication::desktop()->width() >= 480 ) | ||
2035 | size = 18; | ||
2036 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup); | ||
2037 | // ----- | ||
2038 | picker->resize(picker->sizeHint()); | ||
2039 | popup->setMainWidget(picker); | ||
2040 | picker->setFocus(); | ||
2041 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | ||
2042 | if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height())))) | ||
2043 | { | ||
2044 | month = picker->getResult(); | ||
2045 | emit selectWeek ( month ); | ||
2046 | //qDebug("weekSelected %d ", month); | ||
2047 | } | ||
2048 | delete popup; | ||
2049 | } | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 076ab94..5b9f903 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,147 +1,158 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qmenubar.h> | ||
8 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
9 | #include <qregexp.h> | 10 | #include <qregexp.h> |
10 | 11 | ||
11 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
12 | #include "simplealarmclient.h" | 13 | #include "simplealarmclient.h" |
13 | #include <ksyncmanager.h> | 14 | #include <ksyncmanager.h> |
14 | #ifndef DESKTOP_VERSION | 15 | #ifndef DESKTOP_VERSION |
15 | #include <qcopchannel_qws.h> | 16 | #include <qcopchannel_qws.h> |
16 | #endif | 17 | #endif |
17 | class QAction; | 18 | class QAction; |
18 | class CalendarView; | 19 | class CalendarView; |
19 | class KSyncProfile; | 20 | class KSyncProfile; |
20 | #ifdef DESKTOP_VERSION | 21 | #ifdef DESKTOP_VERSION |
21 | 22 | ||
22 | #define QPEToolBar QToolBar | 23 | #define QPEToolBar QToolBar |
23 | #define QPEMenuBar QMenuBar | 24 | #define QPEMenuBar QMenuBar |
24 | #endif | 25 | #endif |
25 | class QPEToolBar; | 26 | class QPEToolBar; |
26 | class QPEMenuBar; | ||
27 | 27 | ||
28 | 28 | ||
29 | namespace KCal { | 29 | namespace KCal { |
30 | class CalendarLocal; | 30 | class CalendarLocal; |
31 | } | 31 | } |
32 | 32 | ||
33 | class KOMenuBar : public QMenuBar | ||
34 | { | ||
35 | public: | ||
36 | KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;} | ||
37 | QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );} | ||
38 | }; | ||
39 | |||
33 | using namespace KCal; | 40 | using namespace KCal; |
34 | 41 | ||
35 | class MainWindow : public QMainWindow | 42 | class MainWindow : public QMainWindow |
36 | { | 43 | { |
37 | Q_OBJECT | 44 | Q_OBJECT |
38 | public: | 45 | public: |
39 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 46 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
40 | ~MainWindow(); | 47 | ~MainWindow(); |
41 | bool beamReceiveEnabled(); | 48 | bool beamReceiveEnabled(); |
42 | static QString defaultFileName(); | 49 | static QString defaultFileName(); |
43 | static QString syncFileName(); | 50 | static QString syncFileName(); |
44 | static QString resourcePath(); | 51 | static QString resourcePath(); |
45 | public slots: | 52 | public slots: |
46 | void updateWeekNum(const KCal::DateList &); | 53 | void updateWeekNum(const KCal::DateList &); |
47 | void updateWeek(QDate); | 54 | void updateWeek(QDate); |
48 | virtual void showMaximized (); | 55 | virtual void showMaximized (); |
49 | void configureAgenda( int ); | 56 | void configureAgenda( int ); |
50 | void recieve( const QCString& msg, const QByteArray& data ); | 57 | void recieve( const QCString& msg, const QByteArray& data ); |
51 | protected slots: | 58 | protected slots: |
52 | void setCaptionToDates(); | 59 | void setCaptionToDates(); |
60 | void weekAction(); | ||
53 | void about(); | 61 | void about(); |
54 | void licence(); | 62 | void licence(); |
55 | void faq(); | 63 | void faq(); |
56 | void usertrans(); | 64 | void usertrans(); |
57 | void features(); | 65 | void features(); |
58 | void synchowto(); | 66 | void synchowto(); |
59 | void kdesynchowto(); | 67 | void kdesynchowto(); |
60 | void multisynchowto(); | 68 | void multisynchowto(); |
61 | void whatsNew(); | 69 | void whatsNew(); |
62 | void keyBindings(); | 70 | void keyBindings(); |
63 | void aboutAutoSaving();; | 71 | void aboutAutoSaving();; |
64 | void aboutKnownBugs(); | 72 | void aboutKnownBugs(); |
65 | 73 | ||
66 | void processIncidenceSelection( Incidence * ); | 74 | void processIncidenceSelection( Incidence * ); |
67 | 75 | ||
68 | void importQtopia(); | 76 | void importQtopia(); |
69 | void importBday(); | 77 | void importBday(); |
70 | void importOL(); | 78 | void importOL(); |
71 | void importIcal(); | 79 | void importIcal(); |
72 | void importFile( QString, bool ); | 80 | void importFile( QString, bool ); |
73 | void quickImportIcal(); | 81 | void quickImportIcal(); |
74 | 82 | ||
75 | void slotModifiedChanged( bool ); | 83 | void slotModifiedChanged( bool ); |
76 | 84 | ||
77 | void save(); | 85 | void save(); |
78 | void saveStopTimer(); | 86 | void saveStopTimer(); |
79 | void configureToolBar( int ); | 87 | void configureToolBar( int ); |
80 | void printSel(); | 88 | void printSel(); |
81 | void printCal(); | 89 | void printCal(); |
82 | void saveCalendar(); | 90 | void saveCalendar(); |
83 | void loadCalendar(); | 91 | void loadCalendar(); |
84 | void exportVCalendar(); | 92 | void exportVCalendar(); |
85 | void fillFilterMenu(); | 93 | void fillFilterMenu(); |
86 | void selectFilter( int ); | 94 | void selectFilter( int ); |
87 | void exportToPhone( int ); | 95 | void exportToPhone( int ); |
88 | void toggleBeamReceive(); | 96 | void toggleBeamReceive(); |
89 | void disableBR(bool); | 97 | void disableBR(bool); |
90 | signals: | 98 | signals: |
91 | void selectWeek ( int ); | 99 | void selectWeek ( int ); |
92 | private slots: | 100 | private slots: |
93 | void showConfigureAgenda(); | 101 | void showConfigureAgenda(); |
94 | void getFile( bool ); | 102 | void getFile( bool ); |
95 | void syncFileRequest(); | 103 | void syncFileRequest(); |
96 | 104 | ||
97 | protected: | 105 | protected: |
98 | void displayText( QString, QString); | 106 | void displayText( QString, QString); |
99 | void enableIncidenceActions( bool ); | 107 | void enableIncidenceActions( bool ); |
100 | 108 | ||
101 | private: | 109 | private: |
102 | bool mBRdisabled; | 110 | bool mBRdisabled; |
103 | #ifndef DESKTOP_VERSION | 111 | #ifndef DESKTOP_VERSION |
104 | QCopChannel* infrared; | 112 | QCopChannel* infrared; |
105 | #endif | 113 | #endif |
106 | QAction* brAction; | 114 | QAction* brAction; |
107 | KSyncManager* mSyncManager; | 115 | KSyncManager* mSyncManager; |
108 | bool mClosed; | 116 | bool mClosed; |
109 | void saveOnClose(); | 117 | void saveOnClose(); |
110 | bool mFlagKeyPressed; | 118 | bool mFlagKeyPressed; |
111 | bool mBlockAtStartup; | 119 | bool mBlockAtStartup; |
112 | QPEToolBar *iconToolBar; | 120 | QPEToolBar *iconToolBar; |
113 | void initActions(); | 121 | void initActions(); |
114 | void setDefaultPreferences(); | 122 | void setDefaultPreferences(); |
115 | void keyPressEvent ( QKeyEvent * ) ; | 123 | void keyPressEvent ( QKeyEvent * ) ; |
116 | void keyReleaseEvent ( QKeyEvent * ) ; | 124 | void keyReleaseEvent ( QKeyEvent * ) ; |
117 | QPopupMenu *configureToolBarMenu; | 125 | QPopupMenu *configureToolBarMenu; |
118 | QPopupMenu *selectFilterMenu; | 126 | QPopupMenu *selectFilterMenu; |
119 | QPopupMenu *configureAgendaMenu, *syncMenu; | 127 | QPopupMenu *configureAgendaMenu, *syncMenu; |
120 | CalendarLocal *mCalendar; | 128 | CalendarLocal *mCalendar; |
121 | CalendarView *mView; | 129 | CalendarView *mView; |
122 | QAction *mNewSubTodoAction; | 130 | QAction *mNewSubTodoAction; |
123 | QPEMenuBar *menuBarWeek; | 131 | QAction *mWeekAction; |
132 | QFont mWeekFont; | ||
133 | QPixmap mWeekPixmap; | ||
134 | QColor mWeekBgColor; | ||
124 | 135 | ||
125 | QAction *mShowAction; | 136 | QAction *mShowAction; |
126 | QAction *mEditAction; | 137 | QAction *mEditAction; |
127 | QAction *mDeleteAction; | 138 | QAction *mDeleteAction; |
128 | QAction *mCloneAction; | 139 | QAction *mCloneAction; |
129 | QAction *mMoveAction; | 140 | QAction *mMoveAction; |
130 | QAction *mBeamAction; | 141 | QAction *mBeamAction; |
131 | QAction *mCancelAction; | 142 | QAction *mCancelAction; |
132 | 143 | ||
133 | QAction *mToggleNav; | 144 | QAction *mToggleNav; |
134 | QAction *mToggleFilter; | 145 | QAction *mToggleFilter; |
135 | QAction *mToggleAllday; | 146 | QAction *mToggleAllday; |
136 | 147 | ||
137 | 148 | ||
138 | void closeEvent( QCloseEvent* ce ); | 149 | void closeEvent( QCloseEvent* ce ); |
139 | SimpleAlarmClient mAlarmClient; | 150 | SimpleAlarmClient mAlarmClient; |
140 | QTimer mSaveTimer; | 151 | QTimer mSaveTimer; |
141 | //bool mBlockSaveFlag; | 152 | //bool mBlockSaveFlag; |
142 | bool mCalendarModifiedFlag; | 153 | bool mCalendarModifiedFlag; |
143 | QPixmap loadPixmap( QString ); | 154 | QPixmap loadPixmap( QString ); |
144 | }; | 155 | }; |
145 | 156 | ||
146 | 157 | ||
147 | #endif | 158 | #endif |
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index 508ce31..fce0e5a 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp | |||
@@ -1,750 +1,915 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | 3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) |
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | 4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) |
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /////////////////// KDateTable widget class ////////////////////// | 21 | /////////////////// KDateTable widget class ////////////////////// |
22 | // | 22 | // |
23 | // Copyright (C) 1997 Tim D. Gilman | 23 | // Copyright (C) 1997 Tim D. Gilman |
24 | // (C) 1998-2001 Mirko Boehm | 24 | // (C) 1998-2001 Mirko Boehm |
25 | // Written using Qt (http://www.troll.no) for the | 25 | // Written using Qt (http://www.troll.no) for the |
26 | // KDE project (http://www.kde.org) | 26 | // KDE project (http://www.kde.org) |
27 | // | 27 | // |
28 | // This is a support class for the KDatePicker class. It just | 28 | // This is a support class for the KDatePicker class. It just |
29 | // draws the calender table without titles, but could theoretically | 29 | // draws the calender table without titles, but could theoretically |
30 | // be used as a standalone. | 30 | // be used as a standalone. |
31 | // | 31 | // |
32 | // When a date is selected by the user, it emits a signal: | 32 | // When a date is selected by the user, it emits a signal: |
33 | // dateSelected(QDate) | 33 | // dateSelected(QDate) |
34 | 34 | ||
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kglobalsettings.h> | 36 | #include <kglobalsettings.h> |
37 | #include <kapplication.h> | 37 | #include <kapplication.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <knotifyclient.h> | 40 | #include <knotifyclient.h> |
41 | #include "kdatetbl.h" | 41 | #include "kdatetbl.h" |
42 | #include <qdatetime.h> | 42 | #include <qdatetime.h> |
43 | #include <qstring.h> | 43 | #include <qstring.h> |
44 | #include <qpen.h> | 44 | #include <qpen.h> |
45 | #include <qpainter.h> | 45 | #include <qpainter.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <assert.h> | 47 | #include <assert.h> |
48 | #include <qapplication.h> | 48 | #include <qapplication.h> |
49 | 49 | ||
50 | KDateValidator::KDateValidator(QWidget* parent, const char* name) | 50 | KDateValidator::KDateValidator(QWidget* parent, const char* name) |
51 | : QValidator(parent, name) | 51 | : QValidator(parent, name) |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | ||
55 | QValidator::State | 55 | QValidator::State |
56 | KDateValidator::validate(QString& text, int&) const | 56 | KDateValidator::validate(QString& text, int&) const |
57 | { | 57 | { |
58 | QDate temp; | 58 | QDate temp; |
59 | // ----- everything is tested in date(): | 59 | // ----- everything is tested in date(): |
60 | return date(text, temp); | 60 | return date(text, temp); |
61 | } | 61 | } |
62 | 62 | ||
63 | QValidator::State | 63 | QValidator::State |
64 | KDateValidator::date(const QString& text, QDate& d) const | 64 | KDateValidator::date(const QString& text, QDate& d) const |
65 | { | 65 | { |
66 | QDate tmp = KGlobal::locale()->readDate(text); | 66 | QDate tmp = KGlobal::locale()->readDate(text); |
67 | if (!tmp.isNull()) | 67 | if (!tmp.isNull()) |
68 | { | 68 | { |
69 | d = tmp; | 69 | d = tmp; |
70 | return Acceptable; | 70 | return Acceptable; |
71 | } else | 71 | } else |
72 | return Valid; | 72 | return Valid; |
73 | } | 73 | } |
74 | 74 | ||
75 | void | 75 | void |
76 | KDateValidator::fixup( QString& ) const | 76 | KDateValidator::fixup( QString& ) const |
77 | { | 77 | { |
78 | 78 | ||
79 | } | 79 | } |
80 | 80 | ||
81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) | 81 | KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) |
82 | : QGridView(parent, name, f) | 82 | : QGridView(parent, name, f) |
83 | { | 83 | { |
84 | setFontSize(10); | 84 | setFontSize(10); |
85 | if(!date_.isValid()) | 85 | if(!date_.isValid()) |
86 | { | 86 | { |
87 | date_=QDate::currentDate(); | 87 | date_=QDate::currentDate(); |
88 | } | 88 | } |
89 | setFocusPolicy( QWidget::StrongFocus ); | 89 | setFocusPolicy( QWidget::StrongFocus ); |
90 | setNumRows(7); // 6 weeks max + headline | 90 | setNumRows(7); // 6 weeks max + headline |
91 | setNumCols(7); // 7 days a week | 91 | setNumCols(7); // 7 days a week |
92 | setHScrollBarMode(AlwaysOff); | 92 | setHScrollBarMode(AlwaysOff); |
93 | setVScrollBarMode(AlwaysOff); | 93 | setVScrollBarMode(AlwaysOff); |
94 | viewport()->setBackgroundColor(QColor(220,245,255)); | 94 | viewport()->setBackgroundColor(QColor(220,245,255)); |
95 | #if 0 | 95 | #if 0 |
96 | viewport()->setEraseColor(lightGray); | 96 | viewport()->setEraseColor(lightGray); |
97 | #endif | 97 | #endif |
98 | mMarkCurrent = false; | 98 | mMarkCurrent = false; |
99 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth | 99 | setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth |
100 | } | 100 | } |
101 | 101 | ||
102 | void | 102 | void |
103 | KDateTable::paintCell(QPainter *painter, int row, int col) | 103 | KDateTable::paintCell(QPainter *painter, int row, int col) |
104 | { | 104 | { |
105 | QRect rect; | 105 | QRect rect; |
106 | QString text; | 106 | QString text; |
107 | QPen pen; | 107 | QPen pen; |
108 | int w=cellWidth(); | 108 | int w=cellWidth(); |
109 | int h=cellHeight(); | 109 | int h=cellHeight(); |
110 | int pos; | 110 | int pos; |
111 | QBrush brushBlue(blue); | 111 | QBrush brushBlue(blue); |
112 | QBrush brushLightblue(QColor(220,245,255)); | 112 | QBrush brushLightblue(QColor(220,245,255)); |
113 | QFont font=KGlobalSettings::generalFont(); | 113 | QFont font=KGlobalSettings::generalFont(); |
114 | // ----- | 114 | // ----- |
115 | font.setPointSize(fontsize); | 115 | font.setPointSize(fontsize); |
116 | if(row==0) | 116 | if(row==0) |
117 | { // we are drawing the headline | 117 | { // we are drawing the headline |
118 | font.setBold(true); | 118 | font.setBold(true); |
119 | painter->setFont(font); | 119 | painter->setFont(font); |
120 | bool normalday = true; | 120 | bool normalday = true; |
121 | QString daystr; | 121 | QString daystr; |
122 | if (KGlobal::locale()->weekStartsMonday()) | 122 | if (KGlobal::locale()->weekStartsMonday()) |
123 | { | 123 | { |
124 | daystr = KGlobal::locale()->weekDayName(col+1, true); | 124 | daystr = KGlobal::locale()->weekDayName(col+1, true); |
125 | if (col == 5 || col == 6) | 125 | if (col == 5 || col == 6) |
126 | normalday = false; | 126 | normalday = false; |
127 | } else { | 127 | } else { |
128 | daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); | 128 | daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); |
129 | if (col == 0 || col == 6) | 129 | if (col == 0 || col == 6) |
130 | normalday = false; | 130 | normalday = false; |
131 | } | ||
132 | if (!normalday) | ||
133 | { | ||
134 | painter->setPen(QColor(220,245,255)); | ||
135 | painter->setBrush(brushLightblue); | ||
136 | painter->drawRect(0, 0, w, h); | ||
137 | painter->setPen(blue); | ||
138 | } else { | ||
139 | painter->setPen(blue); | ||
140 | painter->setBrush(brushBlue); | ||
141 | painter->drawRect(0, 0, w, h); | ||
142 | painter->setPen(white); | ||
143 | } | ||
144 | painter->drawText(0, 0, w, h-1, AlignCenter, | ||
145 | daystr, -1, &rect); | ||
146 | painter->setPen(black); | ||
147 | painter->moveTo(0, h-1); | ||
148 | painter->lineTo(w-1, h-1); | ||
149 | // ----- draw the weekday: | ||
150 | } else { | ||
151 | painter->setFont(font); | ||
152 | pos=7*(row-1)+col; | ||
153 | if (KGlobal::locale()->weekStartsMonday()) | ||
154 | pos++; | ||
155 | if(pos<firstday || (firstday+numdays<=pos)) | ||
156 | { // we are either | ||
157 | // ° painting a day of the previous month or | ||
158 | // ° painting a day of the following month | ||
159 | if(pos<firstday) | ||
160 | { // previous month | ||
161 | text.setNum(numDaysPrevMonth+pos-firstday+1); | ||
162 | } else { // following month | ||
163 | text.setNum(pos-firstday-numdays+1); | ||
164 | } | 131 | } |
165 | painter->setPen(gray); | 132 | if (!normalday) |
166 | } else { // paint a day of the current month | 133 | { |
167 | text.setNum(pos-firstday+1); | 134 | painter->setPen(QColor(220,245,255)); |
168 | painter->setPen(black); | 135 | painter->setBrush(brushLightblue); |
136 | painter->drawRect(0, 0, w, h); | ||
137 | painter->setPen(blue); | ||
138 | } else { | ||
139 | painter->setPen(blue); | ||
140 | painter->setBrush(brushBlue); | ||
141 | painter->drawRect(0, 0, w, h); | ||
142 | painter->setPen(white); | ||
143 | } | ||
144 | painter->drawText(0, 0, w, h-1, AlignCenter, | ||
145 | daystr, -1, &rect); | ||
146 | painter->setPen(black); | ||
147 | painter->moveTo(0, h-1); | ||
148 | painter->lineTo(w-1, h-1); | ||
149 | // ----- draw the weekday: | ||
150 | } else { | ||
151 | painter->setFont(font); | ||
152 | pos=7*(row-1)+col; | ||
153 | if (KGlobal::locale()->weekStartsMonday()) | ||
154 | pos++; | ||
155 | if(pos<firstday || (firstday+numdays<=pos)) | ||
156 | { // we are either | ||
157 | // ° painting a day of the previous month or | ||
158 | // ° painting a day of the following month | ||
159 | if(pos<firstday) | ||
160 | { // previous month | ||
161 | text.setNum(numDaysPrevMonth+pos-firstday+1); | ||
162 | } else { // following month | ||
163 | text.setNum(pos-firstday-numdays+1); | ||
164 | } | ||
165 | painter->setPen(gray); | ||
166 | } else { // paint a day of the current month | ||
167 | text.setNum(pos-firstday+1); | ||
168 | painter->setPen(black); | ||
169 | } | 169 | } |
170 | 170 | ||
171 | pen=painter->pen(); | 171 | pen=painter->pen(); |
172 | if(firstday+date.day()-1==pos) | 172 | if(firstday+date.day()-1==pos) |
173 | { | 173 | { |
174 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 174 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
175 | painter->setPen(green); | 175 | painter->setPen(green); |
176 | else | 176 | else |
177 | painter->setPen(red); | 177 | painter->setPen(red); |
178 | if(hasFocus()) | 178 | if(hasFocus()) |
179 | { | 179 | { |
180 | painter->setBrush(darkRed); | 180 | painter->setBrush(darkRed); |
181 | pen=white; | 181 | pen=white; |
182 | } else { | ||
183 | painter->setBrush(darkGray); | ||
184 | pen=white; | ||
185 | } | ||
182 | } else { | 186 | } else { |
183 | painter->setBrush(darkGray); | 187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) |
184 | pen=white; | 188 | { |
189 | painter->setPen(green); | ||
190 | painter->setBrush(darkGreen); | ||
191 | pen=white; | ||
192 | } else { | ||
193 | painter->setBrush(QColor(220,245,255)); | ||
194 | painter->setPen(QColor(220,245,255)); | ||
185 | } | 195 | } |
186 | } else { | 196 | } |
187 | if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) | 197 | painter->drawRect(0, 0, w, h); |
188 | { | 198 | painter->setPen(pen); |
189 | painter->setPen(green); | 199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); |
190 | painter->setBrush(darkGreen); | ||
191 | pen=white; | ||
192 | } else { | ||
193 | painter->setBrush(QColor(220,245,255)); | ||
194 | painter->setPen(QColor(220,245,255)); | ||
195 | } | ||
196 | } | ||
197 | painter->drawRect(0, 0, w, h); | ||
198 | painter->setPen(pen); | ||
199 | painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); | ||
200 | } | 200 | } |
201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); | 201 | if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); |
202 | if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); | 202 | if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height()); |
203 | } | 203 | } |
204 | 204 | ||
205 | void | 205 | void |
206 | KDateTable::keyPressEvent( QKeyEvent *e ) | 206 | KDateTable::keyPressEvent( QKeyEvent *e ) |
207 | { | 207 | { |
208 | /* | 208 | /* |
209 | // not working properly | 209 | // not working properly |
210 | if ( e->key() == Qt::Key_Prior ) { | 210 | if ( e->key() == Qt::Key_Prior ) { |
211 | if ( date.month() == 1 ) { | 211 | if ( date.month() == 1 ) { |
212 | KNotifyClient::beep(); | 212 | KNotifyClient::beep(); |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | int day = date.day(); | 215 | int day = date.day(); |
216 | if ( day > 27 ) | 216 | if ( day > 27 ) |
217 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) | 217 | while ( !QDate::isValid( date.year(), date.month()-1, day ) ) |
218 | day--; | 218 | day--; |
219 | setDate(QDate(date.year(), date.month()-1, day)); | 219 | setDate(QDate(date.year(), date.month()-1, day)); |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | if ( e->key() == Qt::Key_Next ) { | 222 | if ( e->key() == Qt::Key_Next ) { |
223 | if ( date.month() == 12 ) { | 223 | if ( date.month() == 12 ) { |
224 | KNotifyClient::beep(); | 224 | KNotifyClient::beep(); |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | int day = date.day(); | 227 | int day = date.day(); |
228 | if ( day > 27 ) | 228 | if ( day > 27 ) |
229 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) | 229 | while ( !QDate::isValid( date.year(), date.month()+1, day ) ) |
230 | day--; | 230 | day--; |
231 | setDate(QDate(date.year(), date.month()+1, day)); | 231 | setDate(QDate(date.year(), date.month()+1, day)); |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | */ | 234 | */ |
235 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 235 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
236 | 236 | ||
237 | int temp=firstday+date.day()-dayoff; | 237 | int temp=firstday+date.day()-dayoff; |
238 | int pos = temp; | 238 | int pos = temp; |
239 | bool irgnore = true; | 239 | bool irgnore = true; |
240 | if ( e->state() != Qt::ControlButton ) { | 240 | if ( e->state() != Qt::ControlButton ) { |
241 | if ( e->key() == Qt::Key_Up ) { | 241 | if ( e->key() == Qt::Key_Up ) { |
242 | pos -= 7; | 242 | pos -= 7; |
243 | irgnore = false; | 243 | irgnore = false; |
244 | } | 244 | } |
245 | if ( e->key() == Qt::Key_Down ) { | 245 | if ( e->key() == Qt::Key_Down ) { |
246 | pos += 7; | 246 | pos += 7; |
247 | irgnore = false; | 247 | irgnore = false; |
248 | } | 248 | } |
249 | if ( e->key() == Qt::Key_Left ) { | 249 | if ( e->key() == Qt::Key_Left ) { |
250 | pos--; | 250 | pos--; |
251 | irgnore = false; | 251 | irgnore = false; |
252 | } | 252 | } |
253 | if ( e->key() == Qt::Key_Right ) { | 253 | if ( e->key() == Qt::Key_Right ) { |
254 | pos++; | 254 | pos++; |
255 | irgnore = false; | 255 | irgnore = false; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | if ( irgnore ) | 258 | if ( irgnore ) |
259 | e->ignore(); | 259 | e->ignore(); |
260 | 260 | ||
261 | if(pos+dayoff<=firstday) | 261 | if(pos+dayoff<=firstday) |
262 | { // this day is in the previous month | 262 | { // this day is in the previous month |
263 | KNotifyClient::beep(); | 263 | KNotifyClient::beep(); |
264 | return; | 264 | return; |
265 | } | 265 | } |
266 | if(firstday+numdays<pos+dayoff) | 266 | if(firstday+numdays<pos+dayoff) |
267 | { // this date is in the next month | 267 | { // this date is in the next month |
268 | KNotifyClient::beep(i18n( "Month not long enough" )); | 268 | KNotifyClient::beep(i18n( "Month not long enough" )); |
269 | return; | 269 | return; |
270 | } | 270 | } |
271 | 271 | ||
272 | if ( pos == temp ) | 272 | if ( pos == temp ) |
273 | return; | 273 | return; |
274 | 274 | ||
275 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); | 275 | setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); |
276 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 276 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
277 | updateCell(pos/7+1, pos%7); // Update the selected cell | 277 | updateCell(pos/7+1, pos%7); // Update the selected cell |
278 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 278 | assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
279 | 279 | ||
280 | 280 | ||
281 | } | 281 | } |
282 | 282 | ||
283 | void | 283 | void |
284 | KDateTable::viewportResizeEvent(QResizeEvent * e) | 284 | KDateTable::viewportResizeEvent(QResizeEvent * e) |
285 | { | 285 | { |
286 | QGridView::viewportResizeEvent(e); | 286 | QGridView::viewportResizeEvent(e); |
287 | 287 | ||
288 | setCellWidth(viewport()->width()/7); | 288 | setCellWidth(viewport()->width()/7); |
289 | setCellHeight(viewport()->height()/7); | 289 | setCellHeight(viewport()->height()/7); |
290 | } | 290 | } |
291 | 291 | ||
292 | void | 292 | void |
293 | KDateTable::setFontSize(int size) | 293 | KDateTable::setFontSize(int size) |
294 | { | 294 | { |
295 | int count; | 295 | int count; |
296 | QRect rect; | 296 | QRect rect; |
297 | // ----- store rectangles: | 297 | // ----- store rectangles: |
298 | fontsize=size; | 298 | fontsize=size; |
299 | QFont font = KGlobalSettings::generalFont(); | 299 | QFont font = KGlobalSettings::generalFont(); |
300 | font.setPointSize(fontsize); | 300 | font.setPointSize(fontsize); |
301 | font.setBold( true ); | 301 | font.setBold( true ); |
302 | QFontMetrics metrics(font); | 302 | QFontMetrics metrics(font); |
303 | 303 | ||
304 | // ----- find largest day name: | 304 | // ----- find largest day name: |
305 | maxCell.setWidth(0); | 305 | maxCell.setWidth(0); |
306 | maxCell.setHeight(0); | 306 | maxCell.setHeight(0); |
307 | for(count=0; count<7; ++count) | 307 | for(count=0; count<7; ++count) |
308 | { | 308 | { |
309 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); | 309 | rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); |
310 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); | 310 | maxCell.setWidth(QMAX(maxCell.width(), rect.width())); |
311 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); | 311 | maxCell.setHeight(QMAX(maxCell.height(), rect.height())); |
312 | } | 312 | } |
313 | // ----- compare with a real wide number and add some space: | 313 | // ----- compare with a real wide number and add some space: |
314 | rect=metrics.boundingRect(QString::fromLatin1("88")); | 314 | rect=metrics.boundingRect(QString::fromLatin1("88")); |
315 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); | 315 | maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); |
316 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); | 316 | maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); |
317 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) | 317 | if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) |
318 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); | 318 | maxCell.setHeight(maxCell.width() * 1000 / 1900 ); |
319 | } | 319 | } |
320 | 320 | ||
321 | void | 321 | void |
322 | KDateTable::contentsMousePressEvent(QMouseEvent *e) | 322 | KDateTable::contentsMousePressEvent(QMouseEvent *e) |
323 | { | 323 | { |
324 | if(e->type()!=QEvent::MouseButtonPress) | 324 | if(e->type()!=QEvent::MouseButtonPress) |
325 | { // the KDatePicker only reacts on mouse press events: | 325 | { // the KDatePicker only reacts on mouse press events: |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | if(!isEnabled()) | 328 | if(!isEnabled()) |
329 | { | 329 | { |
330 | KNotifyClient::beep(); | 330 | KNotifyClient::beep(); |
331 | return; | 331 | return; |
332 | } | 332 | } |
333 | 333 | ||
334 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; | 334 | int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; |
335 | // ----- | 335 | // ----- |
336 | int row, col, pos, temp; | 336 | int row, col, pos, temp; |
337 | QPoint mouseCoord; | 337 | QPoint mouseCoord; |
338 | // ----- | 338 | // ----- |
339 | mouseCoord = e->pos(); | 339 | mouseCoord = e->pos(); |
340 | row=rowAt(mouseCoord.y()); | 340 | row=rowAt(mouseCoord.y()); |
341 | col=columnAt(mouseCoord.x()); | 341 | col=columnAt(mouseCoord.x()); |
342 | if(row<0 || col<0) | 342 | if(row<0 || col<0) |
343 | { // the user clicked on the frame of the table | 343 | { // the user clicked on the frame of the table |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | pos=7*(row-1)+col+1; | 346 | pos=7*(row-1)+col+1; |
347 | #if 0 | 347 | #if 0 |
348 | if(pos+dayoff<=firstday) | 348 | if(pos+dayoff<=firstday) |
349 | { // this day is in the previous month | 349 | { // this day is in the previous month |
350 | KNotifyClient::beep(); | 350 | KNotifyClient::beep(); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | if(firstday+numdays<pos+dayoff) | 353 | if(firstday+numdays<pos+dayoff) |
354 | { // this date is in the next month | 354 | { // this date is in the next month |
355 | KNotifyClient::beep(); | 355 | KNotifyClient::beep(); |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | #endif | 358 | #endif |
359 | temp=firstday+date.day()-dayoff-1; | 359 | temp=firstday+date.day()-dayoff-1; |
360 | QDate da = QDate(date.year(), date.month(),1); | 360 | QDate da = QDate(date.year(), date.month(),1); |
361 | setDate(da.addDays( pos-firstday+dayoff-1)); | 361 | setDate(da.addDays( pos-firstday+dayoff-1)); |
362 | updateCell(temp/7+1, temp%7); // Update the previously selected cell | 362 | updateCell(temp/7+1, temp%7); // Update the previously selected cell |
363 | updateCell(row, col); // Update the selected cell | 363 | updateCell(row, col); // Update the selected cell |
364 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); | 364 | // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); |
365 | emit(tableClicked()); | 365 | emit(tableClicked()); |
366 | } | 366 | } |
367 | 367 | ||
368 | bool | 368 | bool |
369 | KDateTable::setDate(const QDate& date_) | 369 | KDateTable::setDate(const QDate& date_) |
370 | { | 370 | { |
371 | bool changed=false; | 371 | bool changed=false; |
372 | QDate temp; | 372 | QDate temp; |
373 | mMarkCurrent = false; | 373 | mMarkCurrent = false; |
374 | // ----- | 374 | // ----- |
375 | if(!date_.isValid()) | 375 | if(!date_.isValid()) |
376 | { | 376 | { |
377 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; | 377 | kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; |
378 | return false; | 378 | return false; |
379 | } | 379 | } |
380 | if(date!=date_) | 380 | if(date!=date_) |
381 | { | 381 | { |
382 | date=date_; | 382 | date=date_; |
383 | changed=true; | 383 | changed=true; |
384 | } | 384 | } |
385 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); | 385 | mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); |
386 | temp.setYMD(date.year(), date.month(), 1); | 386 | temp.setYMD(date.year(), date.month(), 1); |
387 | firstday=temp.dayOfWeek(); | 387 | firstday=temp.dayOfWeek(); |
388 | if(firstday==1) firstday=8; | 388 | if(firstday==1) firstday=8; |
389 | numdays=date.daysInMonth(); | 389 | numdays=date.daysInMonth(); |
390 | if(date.month()==1) | 390 | if(date.month()==1) |
391 | { // set to december of previous year | 391 | { // set to december of previous year |
392 | temp.setYMD(date.year()-1, 12, 1); | 392 | temp.setYMD(date.year()-1, 12, 1); |
393 | } else { // set to previous month | 393 | } else { // set to previous month |
394 | temp.setYMD(date.year(), date.month()-1, 1); | 394 | temp.setYMD(date.year(), date.month()-1, 1); |
395 | } | ||
396 | numDaysPrevMonth=temp.daysInMonth(); | ||
397 | if(changed) | ||
398 | { | ||
399 | repaintContents(false); | ||
400 | } | 395 | } |
401 | emit(dateChanged(date)); | 396 | numDaysPrevMonth=temp.daysInMonth(); |
402 | return true; | 397 | if(changed) |
398 | { | ||
399 | repaintContents(false); | ||
400 | } | ||
401 | emit(dateChanged(date)); | ||
402 | return true; | ||
403 | } | 403 | } |
404 | 404 | ||
405 | const QDate& | 405 | const QDate& |
406 | KDateTable::getDate() const | 406 | KDateTable::getDate() const |
407 | { | 407 | { |
408 | return date; | 408 | return date; |
409 | } | 409 | } |
410 | 410 | ||
411 | void KDateTable::focusInEvent( QFocusEvent *e ) | 411 | void KDateTable::focusInEvent( QFocusEvent *e ) |
412 | { | 412 | { |
413 | repaintContents(false); | 413 | repaintContents(false); |
414 | QGridView::focusInEvent( e ); | 414 | QGridView::focusInEvent( e ); |
415 | } | 415 | } |
416 | 416 | ||
417 | void KDateTable::focusOutEvent( QFocusEvent *e ) | 417 | void KDateTable::focusOutEvent( QFocusEvent *e ) |
418 | { | 418 | { |
419 | repaintContents(false); | 419 | repaintContents(false); |
420 | QGridView::focusOutEvent( e ); | 420 | QGridView::focusOutEvent( e ); |
421 | } | 421 | } |
422 | 422 | ||
423 | QSize | 423 | QSize |
424 | KDateTable::sizeHint() const | 424 | KDateTable::sizeHint() const |
425 | { | 425 | { |
426 | if(maxCell.height()>0 && maxCell.width()>0) | 426 | if(maxCell.height()>0 && maxCell.width()>0) |
427 | { | 427 | { |
428 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), | 428 | return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), |
429 | (maxCell.height()+4)*numRows()+2*frameWidth()); | 429 | (maxCell.height()+4)*numRows()+2*frameWidth()); |
430 | } else { | 430 | } else { |
431 | return QSize(-1, -1); | 431 | return QSize(-1, -1); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | KDateInternalMonthPicker::KDateInternalMonthPicker | 435 | KDateInternalMonthPicker::KDateInternalMonthPicker |
436 | (int fontsize, QWidget* parent, const char* name) | 436 | (int fontsize, QWidget* parent, const char* name) |
437 | : QGridView(parent, name), | 437 | : QGridView(parent, name), |
438 | result(0) // invalid | 438 | result(0) // invalid |
439 | { | 439 | { |
440 | QRect rect; | 440 | QRect rect; |
441 | QFont font; | 441 | QFont font; |
442 | // ----- | 442 | // ----- |
443 | activeCol = -1; | 443 | activeCol = -1; |
444 | activeRow = -1; | 444 | activeRow = -1; |
445 | font=KGlobalSettings::generalFont(); | 445 | font=KGlobalSettings::generalFont(); |
446 | font.setPointSize(fontsize); | 446 | font.setPointSize(fontsize); |
447 | setFont(font); | 447 | setFont(font); |
448 | setHScrollBarMode(AlwaysOff); | 448 | setHScrollBarMode(AlwaysOff); |
449 | setVScrollBarMode(AlwaysOff); | 449 | setVScrollBarMode(AlwaysOff); |
450 | setFrameStyle(QFrame::NoFrame); | 450 | setFrameStyle(QFrame::NoFrame); |
451 | setNumRows(4); | 451 | setNumRows(4); |
452 | setNumCols(3); | 452 | setNumCols(3); |
453 | // enable to find drawing failures: | 453 | // enable to find drawing failures: |
454 | // setTableFlags(Tbl_clipCellPainting); | 454 | // setTableFlags(Tbl_clipCellPainting); |
455 | #if 0 | 455 | #if 0 |
456 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | 456 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker |
457 | #endif | 457 | #endif |
458 | // ----- find the preferred size | 458 | // ----- find the preferred size |
459 | // (this is slow, possibly, but unfortunatly it is needed here): | 459 | // (this is slow, possibly, but unfortunatly it is needed here): |
460 | QFontMetrics metrics(font); | 460 | QFontMetrics metrics(font); |
461 | for(int i=1; i <= 12; ++i) | 461 | for(int i=1; i <= 12; ++i) |
462 | { | 462 | { |
463 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); | 463 | rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); |
464 | if(max.width()<rect.width()) max.setWidth(rect.width()); | 464 | if(max.width()<rect.width()) max.setWidth(rect.width()); |
465 | if(max.height()<rect.height()) max.setHeight(rect.height()); | 465 | if(max.height()<rect.height()) max.setHeight(rect.height()); |
466 | } | 466 | } |
467 | 467 | ||
468 | } | 468 | } |
469 | 469 | ||
470 | QSize | 470 | QSize |
471 | KDateInternalMonthPicker::sizeHint() const | 471 | KDateInternalMonthPicker::sizeHint() const |
472 | { | 472 | { |
473 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | 473 | return QSize((max.width()+6)*numCols()+2*frameWidth(), |
474 | (max.height()+6)*numRows()+2*frameWidth()); | 474 | (max.height()+6)*numRows()+2*frameWidth()); |
475 | } | 475 | } |
476 | 476 | ||
477 | int | 477 | int |
478 | KDateInternalMonthPicker::getResult() const | 478 | KDateInternalMonthPicker::getResult() const |
479 | { | 479 | { |
480 | return result; | 480 | return result; |
481 | } | 481 | } |
482 | 482 | ||
483 | void | 483 | void |
484 | KDateInternalMonthPicker::setupPainter(QPainter *p) | 484 | KDateInternalMonthPicker::setupPainter(QPainter *p) |
485 | { | 485 | { |
486 | p->setPen(black); | 486 | p->setPen(black); |
487 | } | 487 | } |
488 | 488 | ||
489 | void | 489 | void |
490 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) | 490 | KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) |
491 | { | 491 | { |
492 | setCellWidth(width()/3); | 492 | setCellWidth(width()/3); |
493 | setCellHeight(height()/4); | 493 | setCellHeight(height()/4); |
494 | } | 494 | } |
495 | 495 | ||
496 | void | 496 | void |
497 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) | 497 | KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) |
498 | { | 498 | { |
499 | int index; | 499 | int index; |
500 | QString text; | 500 | QString text; |
501 | // ----- find the number of the cell: | 501 | // ----- find the number of the cell: |
502 | index=3*row+col+1; | 502 | index=3*row+col+1; |
503 | text=KGlobal::locale()->monthName(index, false); | 503 | text=KGlobal::locale()->monthName(index, false); |
504 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | 504 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); |
505 | if ( activeCol == col && activeRow == row ) | 505 | if ( activeCol == col && activeRow == row ) |
506 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | 506 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); |
507 | } | 507 | } |
508 | 508 | ||
509 | void | 509 | void |
510 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) | 510 | KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) |
511 | { | 511 | { |
512 | if(!isEnabled() || e->button() != LeftButton) | 512 | if(!isEnabled() || e->button() != LeftButton) |
513 | { | 513 | { |
514 | KNotifyClient::beep(); | 514 | KNotifyClient::beep(); |
515 | return; | 515 | return; |
516 | } | ||
517 | // ----- | ||
518 | int row, col; | ||
519 | QPoint mouseCoord; | ||
520 | // ----- | ||
521 | mouseCoord = e->pos(); | ||
522 | row=rowAt(mouseCoord.y()); | ||
523 | col=columnAt(mouseCoord.x()); | ||
524 | |||
525 | if(row<0 || col<0) | ||
526 | { // the user clicked on the frame of the table | ||
527 | activeCol = -1; | ||
528 | activeRow = -1; | ||
529 | } else { | ||
530 | activeCol = col; | ||
531 | activeRow = row; | ||
532 | updateCell( row, col /*, false */ ); | ||
516 | } | 533 | } |
517 | // ----- | ||
518 | int row, col; | ||
519 | QPoint mouseCoord; | ||
520 | // ----- | ||
521 | mouseCoord = e->pos(); | ||
522 | row=rowAt(mouseCoord.y()); | ||
523 | col=columnAt(mouseCoord.x()); | ||
524 | |||
525 | if(row<0 || col<0) | ||
526 | { // the user clicked on the frame of the table | ||
527 | activeCol = -1; | ||
528 | activeRow = -1; | ||
529 | } else { | ||
530 | activeCol = col; | ||
531 | activeRow = row; | ||
532 | updateCell( row, col /*, false */ ); | ||
533 | } | ||
534 | } | 534 | } |
535 | 535 | ||
536 | void | 536 | void |
537 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) | 537 | KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) |
538 | { | 538 | { |
539 | if (e->state() & LeftButton) | 539 | if (e->state() & LeftButton) |
540 | { | 540 | { |
541 | int row, col; | 541 | int row, col; |
542 | QPoint mouseCoord; | 542 | QPoint mouseCoord; |
543 | // ----- | 543 | // ----- |
544 | mouseCoord = e->pos(); | 544 | mouseCoord = e->pos(); |
545 | row=rowAt(mouseCoord.y()); | 545 | row=rowAt(mouseCoord.y()); |
546 | col=columnAt(mouseCoord.x()); | 546 | col=columnAt(mouseCoord.x()); |
547 | int tmpRow = -1, tmpCol = -1; | 547 | int tmpRow = -1, tmpCol = -1; |
548 | if(row<0 || col<0) | 548 | if(row<0 || col<0) |
549 | { // the user clicked on the frame of the table | 549 | { // the user clicked on the frame of the table |
550 | if ( activeCol > -1 ) | 550 | if ( activeCol > -1 ) |
551 | { | 551 | { |
552 | tmpRow = activeRow; | 552 | tmpRow = activeRow; |
553 | tmpCol = activeCol; | 553 | tmpCol = activeCol; |
554 | } | 554 | } |
555 | activeCol = -1; | 555 | activeCol = -1; |
556 | activeRow = -1; | 556 | activeRow = -1; |
557 | } else { | 557 | } else { |
558 | bool differentCell = (activeRow != row || activeCol != col); | 558 | bool differentCell = (activeRow != row || activeCol != col); |
559 | if ( activeCol > -1 && differentCell) | 559 | if ( activeCol > -1 && differentCell) |
560 | { | 560 | { |
561 | tmpRow = activeRow; | 561 | tmpRow = activeRow; |
562 | tmpCol = activeCol; | 562 | tmpCol = activeCol; |
563 | } | 563 | } |
564 | if ( differentCell) | 564 | if ( differentCell) |
565 | { | 565 | { |
566 | activeRow = row; | 566 | activeRow = row; |
567 | activeCol = col; | 567 | activeCol = col; |
568 | updateCell( row, col /*, false */ ); // mark the new active cell | 568 | updateCell( row, col /*, false */ ); // mark the new active cell |
569 | } | ||
569 | } | 570 | } |
571 | if ( tmpRow > -1 ) // repaint the former active cell | ||
572 | updateCell( tmpRow, tmpCol /*, true */ ); | ||
570 | } | 573 | } |
571 | if ( tmpRow > -1 ) // repaint the former active cell | ||
572 | updateCell( tmpRow, tmpCol /*, true */ ); | ||
573 | } | ||
574 | } | 574 | } |
575 | 575 | ||
576 | void | 576 | void |
577 | KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) | 577 | KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) |
578 | { | 578 | { |
579 | if(!isEnabled()) | 579 | if(!isEnabled()) |
580 | { | 580 | { |
581 | return; | 581 | return; |
582 | } | 582 | } |
583 | // ----- | 583 | // ----- |
584 | int row, col, pos; | 584 | int row, col, pos; |
585 | QPoint mouseCoord; | 585 | QPoint mouseCoord; |
586 | // ----- | 586 | // ----- |
587 | mouseCoord = e->pos(); | 587 | mouseCoord = e->pos(); |
588 | row=rowAt(mouseCoord.y()); | 588 | row=rowAt(mouseCoord.y()); |
589 | col=columnAt(mouseCoord.x()); | 589 | col=columnAt(mouseCoord.x()); |
590 | if(row<0 || col<0) | 590 | if(row<0 || col<0) |
591 | { // the user clicked on the frame of the table | 591 | { // the user clicked on the frame of the table |
592 | emit(closeMe(0)); | 592 | emit(closeMe(0)); |
593 | } | 593 | } |
594 | pos=3*row+col+1; | 594 | pos=3*row+col+1; |
595 | result=pos; | 595 | result=pos; |
596 | emit(closeMe(1)); | 596 | emit(closeMe(1)); |
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | KDateInternalYearSelector::KDateInternalYearSelector | 601 | KDateInternalYearSelector::KDateInternalYearSelector |
602 | (int fontsize, QWidget* parent, const char* name) | 602 | (int fontsize, QWidget* parent, const char* name) |
603 | : QLineEdit(parent, name), | 603 | : QLineEdit(parent, name), |
604 | val(new QIntValidator(this)), | 604 | val(new QIntValidator(this)), |
605 | result(0) | 605 | result(0) |
606 | { | 606 | { |
607 | QFont font; | 607 | QFont font; |
608 | // ----- | 608 | // ----- |
609 | font=KGlobalSettings::generalFont(); | 609 | font=KGlobalSettings::generalFont(); |
610 | font.setPointSize(fontsize); | 610 | font.setPointSize(fontsize); |
611 | setFont(font); | 611 | setFont(font); |
612 | #if 0 | 612 | #if 0 |
613 | setFrameStyle(QFrame::NoFrame); | 613 | setFrameStyle(QFrame::NoFrame); |
614 | #endif | 614 | #endif |
615 | // we have to respect the limits of QDate here, I fear: | 615 | // we have to respect the limits of QDate here, I fear: |
616 | val->setRange(0, 8000); | 616 | val->setRange(0, 8000); |
617 | setValidator(val); | 617 | setValidator(val); |
618 | connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); | 618 | connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); |
619 | } | 619 | } |
620 | 620 | ||
621 | void | 621 | void |
622 | KDateInternalYearSelector::yearEnteredSlot() | 622 | KDateInternalYearSelector::yearEnteredSlot() |
623 | { | 623 | { |
624 | bool ok; | 624 | bool ok; |
625 | int year; | 625 | int year; |
626 | QDate date; | 626 | QDate date; |
627 | // ----- check if this is a valid year: | 627 | // ----- check if this is a valid year: |
628 | year=text().toInt(&ok); | 628 | year=text().toInt(&ok); |
629 | if(!ok) | 629 | if(!ok) |
630 | { | 630 | { |
631 | KNotifyClient::beep(); | 631 | KNotifyClient::beep(); |
632 | return; | 632 | return; |
633 | } | 633 | } |
634 | date.setYMD(year, 1, 1); | 634 | date.setYMD(year, 1, 1); |
635 | if(!date.isValid()) | 635 | if(!date.isValid()) |
636 | { | 636 | { |
637 | KNotifyClient::beep(); | 637 | KNotifyClient::beep(); |
638 | return; | 638 | return; |
639 | } | 639 | } |
640 | result=year; | 640 | result=year; |
641 | emit(closeMe(1)); | 641 | emit(closeMe(1)); |
642 | } | 642 | } |
643 | 643 | ||
644 | int | 644 | int |
645 | KDateInternalYearSelector::getYear() | 645 | KDateInternalYearSelector::getYear() |
646 | { | 646 | { |
647 | return result; | 647 | return result; |
648 | } | 648 | } |
649 | 649 | ||
650 | void | 650 | void |
651 | KDateInternalYearSelector::setYear(int year) | 651 | KDateInternalYearSelector::setYear(int year) |
652 | { | 652 | { |
653 | QString temp; | 653 | QString temp; |
654 | // ----- | 654 | // ----- |
655 | temp.setNum(year); | 655 | temp.setNum(year); |
656 | setText(temp); | 656 | setText(temp); |
657 | } | 657 | } |
658 | 658 | ||
659 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) | 659 | KPopupFrame::KPopupFrame(QWidget* parent, const char* name) |
660 | : QFrame(parent, name, WType_Popup), | 660 | : QFrame(parent, name, WType_Popup), |
661 | result(0), // rejected | 661 | result(0), // rejected |
662 | main(0) | 662 | main(0) |
663 | { | 663 | { |
664 | setFrameStyle(QFrame::Box|QFrame::Raised); | 664 | setFrameStyle(QFrame::Box|QFrame::Raised); |
665 | setMidLineWidth(2); | 665 | setMidLineWidth(2); |
666 | } | 666 | } |
667 | 667 | ||
668 | void | 668 | void |
669 | KPopupFrame::keyPressEvent(QKeyEvent* e) | 669 | KPopupFrame::keyPressEvent(QKeyEvent* e) |
670 | { | 670 | { |
671 | if(e->key()==Key_Escape) | 671 | if(e->key()==Key_Escape) |
672 | { | 672 | { |
673 | result=0; // rejected | 673 | result=0; // rejected |
674 | qApp->exit_loop(); | 674 | qApp->exit_loop(); |
675 | } | 675 | } |
676 | } | 676 | } |
677 | 677 | ||
678 | void | 678 | void |
679 | KPopupFrame::close(int r) | 679 | KPopupFrame::close(int r) |
680 | { | 680 | { |
681 | result=r; | 681 | result=r; |
682 | qApp->exit_loop(); | 682 | qApp->exit_loop(); |
683 | } | 683 | } |
684 | 684 | ||
685 | void | 685 | void |
686 | KPopupFrame::setMainWidget(QWidget* m) | 686 | KPopupFrame::setMainWidget(QWidget* m) |
687 | { | 687 | { |
688 | main=m; | 688 | main=m; |
689 | if(main!=0) | 689 | if(main!=0) |
690 | { | 690 | { |
691 | resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); | 691 | resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); |
692 | } | 692 | } |
693 | } | 693 | } |
694 | 694 | ||
695 | void | 695 | void |
696 | KPopupFrame::resizeEvent(QResizeEvent*) | 696 | KPopupFrame::resizeEvent(QResizeEvent*) |
697 | { | 697 | { |
698 | if(main!=0) | 698 | if(main!=0) |
699 | { | 699 | { |
700 | main->setGeometry(frameWidth(), frameWidth(), | 700 | main->setGeometry(frameWidth(), frameWidth(), |
701 | width()-2*frameWidth(), height()-2*frameWidth()); | 701 | width()-2*frameWidth(), height()-2*frameWidth()); |
702 | } | 702 | } |
703 | } | 703 | } |
704 | 704 | ||
705 | void | 705 | void |
706 | KPopupFrame::popup(const QPoint &pos) | 706 | KPopupFrame::popup(const QPoint &pos) |
707 | { | 707 | { |
708 | // Make sure the whole popup is visible. | 708 | // Make sure the whole popup is visible. |
709 | QRect d = QApplication::desktop()->frameGeometry(); | 709 | QRect d = QApplication::desktop()->frameGeometry(); |
710 | int x = pos.x(); | 710 | int x = pos.x(); |
711 | int y = pos.y(); | 711 | int y = pos.y(); |
712 | int w = width(); | 712 | int w = width(); |
713 | int h = height(); | 713 | int h = height(); |
714 | if (x+w > d.x()+d.width()) | 714 | if (x+w > d.x()+d.width()) |
715 | x = d.width() - w; | 715 | x = d.width() - w; |
716 | if (y+h > d.y()+d.height()) | 716 | if (y+h > d.y()+d.height()) |
717 | y = d.height() - h; | 717 | y = d.height() - h; |
718 | if (x < d.x()) | 718 | if (x < d.x()) |
719 | x = 0; | 719 | x = 0; |
720 | if (y < d.y()) | 720 | if (y < d.y()) |
721 | y = 0; | 721 | y = 0; |
722 | 722 | ||
723 | // Pop the thingy up. | 723 | // Pop the thingy up. |
724 | move(x, y); | 724 | move(x, y); |
725 | show(); | 725 | show(); |
726 | } | 726 | } |
727 | 727 | ||
728 | int | 728 | int |
729 | KPopupFrame::exec(QPoint pos) | 729 | KPopupFrame::exec(QPoint pos) |
730 | { | 730 | { |
731 | popup(pos); | 731 | popup(pos); |
732 | repaint(); | 732 | repaint(); |
733 | qApp->enter_loop(); | 733 | qApp->enter_loop(); |
734 | hide(); | 734 | hide(); |
735 | return result; | 735 | return result; |
736 | } | 736 | } |
737 | 737 | ||
738 | int | 738 | int |
739 | KPopupFrame::exec(int x, int y) | 739 | KPopupFrame::exec(int x, int y) |
740 | { | 740 | { |
741 | return exec(QPoint(x, y)); | 741 | return exec(QPoint(x, y)); |
742 | } | 742 | } |
743 | 743 | ||
744 | void KPopupFrame::virtual_hook( int, void* ) | 744 | void KPopupFrame::virtual_hook( int, void* ) |
745 | { /*BASE::virtual_hook( id, data );*/ } | 745 | { /*BASE::virtual_hook( id, data );*/ } |
746 | 746 | ||
747 | void KDateTable::virtual_hook( int, void* ) | 747 | void KDateTable::virtual_hook( int, void* ) |
748 | { /*BASE::virtual_hook( id, data );*/ } | 748 | { /*BASE::virtual_hook( id, data );*/ } |
749 | 749 | ||
750 | //#include "kdatetbl.moc" | 750 | //#include "kdatetbl.moc" |
751 | |||
752 | |||
753 | KDateInternalWeekPicker::KDateInternalWeekPicker | ||
754 | (int fontsize, QWidget* parent, const char* name) | ||
755 | : QGridView(parent, name), | ||
756 | result(0) // invalid | ||
757 | { | ||
758 | QRect rect; | ||
759 | QFont font; | ||
760 | // ----- | ||
761 | activeCol = -1; | ||
762 | activeRow = -1; | ||
763 | font=KGlobalSettings::generalFont(); | ||
764 | font.setPointSize(fontsize); | ||
765 | setFont(font); | ||
766 | setHScrollBarMode(AlwaysOff); | ||
767 | setVScrollBarMode(AlwaysOff); | ||
768 | setFrameStyle(QFrame::NoFrame); | ||
769 | setNumRows(13); | ||
770 | setNumCols(4); | ||
771 | // enable to find drawing failures: | ||
772 | // setTableFlags(Tbl_clipCellPainting); | ||
773 | #if 0 | ||
774 | viewport()->setEraseColor(lightGray); // for consistency with the datepicker | ||
775 | #endif | ||
776 | // ----- find the preferred size | ||
777 | // (this is slow, possibly, but unfortunatly it is needed here): | ||
778 | QFontMetrics metrics(font); | ||
779 | for(int i=1; i <= 52; ++i) | ||
780 | { | ||
781 | rect=metrics.boundingRect(QString::number( i )); | ||
782 | if(max.width()<rect.width()) max.setWidth(rect.width()); | ||
783 | if(max.height()<rect.height()) max.setHeight(rect.height()); | ||
784 | } | ||
785 | |||
786 | } | ||
787 | |||
788 | QSize | ||
789 | KDateInternalWeekPicker::sizeHint() const | ||
790 | { | ||
791 | return QSize((max.width()+6)*numCols()+2*frameWidth(), | ||
792 | (max.height()+6)*numRows()+2*frameWidth()); | ||
793 | } | ||
794 | |||
795 | int | ||
796 | KDateInternalWeekPicker::getResult() const | ||
797 | { | ||
798 | return result; | ||
799 | } | ||
800 | |||
801 | void | ||
802 | KDateInternalWeekPicker::setupPainter(QPainter *p) | ||
803 | { | ||
804 | p->setPen(black); | ||
805 | } | ||
806 | |||
807 | void | ||
808 | KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) | ||
809 | { | ||
810 | setCellWidth(width()/4); | ||
811 | setCellHeight(height()/13); | ||
812 | } | ||
813 | |||
814 | void | ||
815 | KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) | ||
816 | { | ||
817 | int index; | ||
818 | QString text; | ||
819 | // ----- find the number of the cell: | ||
820 | index=4*row+col+1; | ||
821 | text=QString::number( index ); | ||
822 | painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); | ||
823 | if ( activeCol == col && activeRow == row ) | ||
824 | painter->drawRect( 0, 0, cellWidth(), cellHeight() ); | ||
825 | } | ||
826 | |||
827 | void | ||
828 | KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) | ||
829 | { | ||
830 | if(!isEnabled() || e->button() != LeftButton) | ||
831 | { | ||
832 | KNotifyClient::beep(); | ||
833 | return; | ||
834 | } | ||
835 | // ----- | ||
836 | int row, col; | ||
837 | QPoint mouseCoord; | ||
838 | // ----- | ||
839 | mouseCoord = e->pos(); | ||
840 | row=rowAt(mouseCoord.y()); | ||
841 | col=columnAt(mouseCoord.x()); | ||
842 | |||
843 | if(row<0 || col<0) | ||
844 | { // the user clicked on the frame of the table | ||
845 | activeCol = -1; | ||
846 | activeRow = -1; | ||
847 | } else { | ||
848 | activeCol = col; | ||
849 | activeRow = row; | ||
850 | updateCell( row, col /*, false */ ); | ||
851 | } | ||
852 | } | ||
853 | |||
854 | void | ||
855 | KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) | ||
856 | { | ||
857 | if (e->state() & LeftButton) | ||
858 | { | ||
859 | int row, col; | ||
860 | QPoint mouseCoord; | ||
861 | // ----- | ||
862 | mouseCoord = e->pos(); | ||
863 | row=rowAt(mouseCoord.y()); | ||
864 | col=columnAt(mouseCoord.x()); | ||
865 | int tmpRow = -1, tmpCol = -1; | ||
866 | if(row<0 || col<0) | ||
867 | { // the user clicked on the frame of the table | ||
868 | if ( activeCol > -1 ) | ||
869 | { | ||
870 | tmpRow = activeRow; | ||
871 | tmpCol = activeCol; | ||
872 | } | ||
873 | activeCol = -1; | ||
874 | activeRow = -1; | ||
875 | } else { | ||
876 | bool differentCell = (activeRow != row || activeCol != col); | ||
877 | if ( activeCol > -1 && differentCell) | ||
878 | { | ||
879 | tmpRow = activeRow; | ||
880 | tmpCol = activeCol; | ||
881 | } | ||
882 | if ( differentCell) | ||
883 | { | ||
884 | activeRow = row; | ||
885 | activeCol = col; | ||
886 | updateCell( row, col /*, false */ ); // mark the new active cell | ||
887 | } | ||
888 | } | ||
889 | if ( tmpRow > -1 ) // repaint the former active cell | ||
890 | updateCell( tmpRow, tmpCol /*, true */ ); | ||
891 | } | ||
892 | } | ||
893 | |||
894 | void | ||
895 | KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) | ||
896 | { | ||
897 | if(!isEnabled()) | ||
898 | { | ||
899 | return; | ||
900 | } | ||
901 | // ----- | ||
902 | int row, col, pos; | ||
903 | QPoint mouseCoord; | ||
904 | // ----- | ||
905 | mouseCoord = e->pos(); | ||
906 | row=rowAt(mouseCoord.y()); | ||
907 | col=columnAt(mouseCoord.x()); | ||
908 | if(row<0 || col<0) | ||
909 | { // the user clicked on the frame of the table | ||
910 | emit(closeMe(0)); | ||
911 | } | ||
912 | pos=4*row+col+1; | ||
913 | result=pos; | ||
914 | emit(closeMe(1)); | ||
915 | } | ||
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h index b4d3e16..2efa532 100644 --- a/microkde/kdatetbl.h +++ b/microkde/kdatetbl.h | |||
@@ -1,309 +1,372 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | This file is part of the KDE libraries | 2 | This file is part of the KDE libraries |
3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) | 3 | Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) |
4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) | 4 | (C) 1998-2001 Mirko Boehm (mirko@kde.org) |
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef KDATETBL_H | 20 | #ifndef KDATETBL_H |
21 | #define KDATETBL_H | 21 | #define KDATETBL_H |
22 | 22 | ||
23 | #include <qvalidator.h> | 23 | #include <qvalidator.h> |
24 | #include <qgridview.h> | 24 | #include <qgridview.h> |
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * A table containing month names. It is used to pick a month directly. | 29 | * A table containing month names. It is used to pick a month directly. |
30 | * @internal | 30 | * @internal |
31 | * @version $Id$ | 31 | * @version $Id$ |
32 | * @author Tim Gilman, Mirko Boehm | 32 | * @author Tim Gilman, Mirko Boehm |
33 | */ | 33 | */ |
34 | class KDateInternalMonthPicker : public QGridView | 34 | class KDateInternalMonthPicker : public QGridView |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | protected: | 37 | protected: |
38 | /** | 38 | /** |
39 | * Store the month that has been clicked [1..12]. | 39 | * Store the month that has been clicked [1..12]. |
40 | */ | 40 | */ |
41 | int result; | 41 | int result; |
42 | /** | 42 | /** |
43 | * the cell under mouse cursor when LBM is pressed | 43 | * the cell under mouse cursor when LBM is pressed |
44 | */ | 44 | */ |
45 | short int activeCol; | 45 | short int activeCol; |
46 | short int activeRow; | 46 | short int activeRow; |
47 | /** | 47 | /** |
48 | * Contains the largest rectangle needed by the month names. | 48 | * Contains the largest rectangle needed by the month names. |
49 | */ | 49 | */ |
50 | QRect max; | 50 | QRect max; |
51 | signals: | 51 | signals: |
52 | /** | 52 | /** |
53 | * This is send from the mouse click event handler. | 53 | * This is send from the mouse click event handler. |
54 | */ | 54 | */ |
55 | void closeMe(int); | 55 | void closeMe(int); |
56 | public: | 56 | public: |
57 | /** | 57 | /** |
58 | * The constructor. | 58 | * The constructor. |
59 | */ | 59 | */ |
60 | KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0); | 60 | KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0); |
61 | /** | 61 | /** |
62 | * The size hint. | 62 | * The size hint. |
63 | */ | 63 | */ |
64 | QSize sizeHint() const; | 64 | QSize sizeHint() const; |
65 | /** | 65 | /** |
66 | * Return the result. 0 means no selection (reject()), 1..12 are the | 66 | * Return the result. 0 means no selection (reject()), 1..12 are the |
67 | * months. | 67 | * months. |
68 | */ | 68 | */ |
69 | int getResult() const; | 69 | int getResult() const; |
70 | protected: | 70 | protected: |
71 | /** | 71 | /** |
72 | * Set up the painter. | 72 | * Set up the painter. |
73 | */ | 73 | */ |
74 | void setupPainter(QPainter *p); | 74 | void setupPainter(QPainter *p); |
75 | /** | 75 | /** |
76 | * The resize event. | 76 | * The resize event. |
77 | */ | 77 | */ |
78 | void viewportResizeEvent(QResizeEvent*); | 78 | void viewportResizeEvent(QResizeEvent*); |
79 | /** | 79 | /** |
80 | * Paint a cell. This simply draws the month names in it. | 80 | * Paint a cell. This simply draws the month names in it. |
81 | */ | 81 | */ |
82 | virtual void paintCell(QPainter* painter, int row, int col); | 82 | virtual void paintCell(QPainter* painter, int row, int col); |
83 | /** | 83 | /** |
84 | * Catch mouse click and move events to paint a rectangle around the item. | 84 | * Catch mouse click and move events to paint a rectangle around the item. |
85 | */ | 85 | */ |
86 | void contentsMousePressEvent(QMouseEvent *e); | 86 | void contentsMousePressEvent(QMouseEvent *e); |
87 | void contentsMouseMoveEvent(QMouseEvent *e); | 87 | void contentsMouseMoveEvent(QMouseEvent *e); |
88 | /** | 88 | /** |
89 | * Emit monthSelected(int) when a cell has been released. | 89 | * Emit monthSelected(int) when a cell has been released. |
90 | */ | 90 | */ |
91 | void contentsMouseReleaseEvent(QMouseEvent *e); | 91 | void contentsMouseReleaseEvent(QMouseEvent *e); |
92 | 92 | ||
93 | private: | 93 | private: |
94 | class KDateInternalMonthPrivate; | 94 | class KDateInternalMonthPrivate; |
95 | KDateInternalMonthPrivate *d; | 95 | KDateInternalMonthPrivate *d; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** Year selection widget. | 98 | /** Year selection widget. |
99 | * @internal | 99 | * @internal |
100 | * @version $Id$ | 100 | * @version $Id$ |
101 | * @author Tim Gilman, Mirko Boehm | 101 | * @author Tim Gilman, Mirko Boehm |
102 | */ | 102 | */ |
103 | class KDateInternalYearSelector : public QLineEdit | 103 | class KDateInternalYearSelector : public QLineEdit |
104 | { | 104 | { |
105 | Q_OBJECT | 105 | Q_OBJECT |
106 | protected: | 106 | protected: |
107 | QIntValidator *val; | 107 | QIntValidator *val; |
108 | int result; | 108 | int result; |
109 | public slots: | 109 | public slots: |
110 | void yearEnteredSlot(); | 110 | void yearEnteredSlot(); |
111 | signals: | 111 | signals: |
112 | void closeMe(int); | 112 | void closeMe(int); |
113 | public: | 113 | public: |
114 | KDateInternalYearSelector(int fontsize, | 114 | KDateInternalYearSelector(int fontsize, |
115 | QWidget* parent=0, | 115 | QWidget* parent=0, |
116 | const char* name=0); | 116 | const char* name=0); |
117 | int getYear(); | 117 | int getYear(); |
118 | void setYear(int year); | 118 | void setYear(int year); |
119 | 119 | ||
120 | private: | 120 | private: |
121 | class KDateInternalYearPrivate; | 121 | class KDateInternalYearPrivate; |
122 | KDateInternalYearPrivate *d; | 122 | KDateInternalYearPrivate *d; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Frame with popup menu behaviour. | 126 | * Frame with popup menu behaviour. |
127 | * @author Tim Gilman, Mirko Boehm | 127 | * @author Tim Gilman, Mirko Boehm |
128 | * @version $Id$ | 128 | * @version $Id$ |
129 | */ | 129 | */ |
130 | class KPopupFrame : public QFrame | 130 | class KPopupFrame : public QFrame |
131 | { | 131 | { |
132 | Q_OBJECT | 132 | Q_OBJECT |
133 | protected: | 133 | protected: |
134 | /** | 134 | /** |
135 | * The result. It is returned from exec() when the popup window closes. | 135 | * The result. It is returned from exec() when the popup window closes. |
136 | */ | 136 | */ |
137 | int result; | 137 | int result; |
138 | /** | 138 | /** |
139 | * Catch key press events. | 139 | * Catch key press events. |
140 | */ | 140 | */ |
141 | void keyPressEvent(QKeyEvent* e); | 141 | void keyPressEvent(QKeyEvent* e); |
142 | /** | 142 | /** |
143 | * The only subwidget that uses the whole dialog window. | 143 | * The only subwidget that uses the whole dialog window. |
144 | */ | 144 | */ |
145 | QWidget *main; | 145 | QWidget *main; |
146 | public slots: | 146 | public slots: |
147 | /** | 147 | /** |
148 | * Close the popup window. This is called from the main widget, usually. | 148 | * Close the popup window. This is called from the main widget, usually. |
149 | * @p r is the result returned from exec(). | 149 | * @p r is the result returned from exec(). |
150 | */ | 150 | */ |
151 | void close(int r); | 151 | void close(int r); |
152 | public: | 152 | public: |
153 | /** | 153 | /** |
154 | * The contructor. Creates a dialog without buttons. | 154 | * The contructor. Creates a dialog without buttons. |
155 | */ | 155 | */ |
156 | KPopupFrame(QWidget* parent=0, const char* name=0); | 156 | KPopupFrame(QWidget* parent=0, const char* name=0); |
157 | /** | 157 | /** |
158 | * Set the main widget. You cannot set the main widget from the constructor, | 158 | * Set the main widget. You cannot set the main widget from the constructor, |
159 | * since it must be a child of the frame itselfes. | 159 | * since it must be a child of the frame itselfes. |
160 | * Be careful: the size is set to the main widgets size. It is up to you to | 160 | * Be careful: the size is set to the main widgets size. It is up to you to |
161 | * set the main widgets correct size before setting it as the main | 161 | * set the main widgets correct size before setting it as the main |
162 | * widget. | 162 | * widget. |
163 | */ | 163 | */ |
164 | void setMainWidget(QWidget* m); | 164 | void setMainWidget(QWidget* m); |
165 | /** | 165 | /** |
166 | * The resize event. Simply resizes the main widget to the whole | 166 | * The resize event. Simply resizes the main widget to the whole |
167 | * widgets client size. | 167 | * widgets client size. |
168 | */ | 168 | */ |
169 | void resizeEvent(QResizeEvent*); | 169 | void resizeEvent(QResizeEvent*); |
170 | /** | 170 | /** |
171 | * Open the popup window at position pos. | 171 | * Open the popup window at position pos. |
172 | */ | 172 | */ |
173 | void popup(const QPoint &pos); | 173 | void popup(const QPoint &pos); |
174 | /** | 174 | /** |
175 | * Execute the popup window. | 175 | * Execute the popup window. |
176 | */ | 176 | */ |
177 | int exec(QPoint p); | 177 | int exec(QPoint p); |
178 | /** | 178 | /** |
179 | * Dito. | 179 | * Dito. |
180 | */ | 180 | */ |
181 | int exec(int x, int y); | 181 | int exec(int x, int y); |
182 | 182 | ||
183 | private: | 183 | private: |
184 | 184 | ||
185 | virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } | 185 | virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } |
186 | protected: | 186 | protected: |
187 | virtual void virtual_hook( int id, void* data ); | 187 | virtual void virtual_hook( int id, void* data ); |
188 | private: | 188 | private: |
189 | class KPopupFramePrivate; | 189 | class KPopupFramePrivate; |
190 | KPopupFramePrivate *d; | 190 | KPopupFramePrivate *d; |
191 | }; | 191 | }; |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Validates user-entered dates. | 194 | * Validates user-entered dates. |
195 | */ | 195 | */ |
196 | class KDateValidator : public QValidator | 196 | class KDateValidator : public QValidator |
197 | { | 197 | { |
198 | public: | 198 | public: |
199 | KDateValidator(QWidget* parent=0, const char* name=0); | 199 | KDateValidator(QWidget* parent=0, const char* name=0); |
200 | virtual State validate(QString&, int&) const; | 200 | virtual State validate(QString&, int&) const; |
201 | virtual void fixup ( QString & input ) const; | 201 | virtual void fixup ( QString & input ) const; |
202 | State date(const QString&, QDate&) const; | 202 | State date(const QString&, QDate&) const; |
203 | }; | 203 | }; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Date selection table. | 206 | * Date selection table. |
207 | * This is a support class for the KDatePicker class. It just | 207 | * This is a support class for the KDatePicker class. It just |
208 | * draws the calender table without titles, but could theoretically | 208 | * draws the calender table without titles, but could theoretically |
209 | * be used as a standalone. | 209 | * be used as a standalone. |
210 | * | 210 | * |
211 | * When a date is selected by the user, it emits a signal: | 211 | * When a date is selected by the user, it emits a signal: |
212 | * dateSelected(QDate) | 212 | * dateSelected(QDate) |
213 | * | 213 | * |
214 | * @internal | 214 | * @internal |
215 | * @version $Id$ | 215 | * @version $Id$ |
216 | * @author Tim Gilman, Mirko Boehm | 216 | * @author Tim Gilman, Mirko Boehm |
217 | */ | 217 | */ |
218 | class KDateTable : public QGridView | 218 | class KDateTable : public QGridView |
219 | { | 219 | { |
220 | Q_OBJECT | 220 | Q_OBJECT |
221 | public: | 221 | public: |
222 | /** | 222 | /** |
223 | * The constructor. | 223 | * The constructor. |
224 | */ | 224 | */ |
225 | KDateTable(QWidget *parent=0, | 225 | KDateTable(QWidget *parent=0, |
226 | QDate date=QDate::currentDate(), | 226 | QDate date=QDate::currentDate(), |
227 | const char* name=0, WFlags f=0); | 227 | const char* name=0, WFlags f=0); |
228 | /** | 228 | /** |
229 | * Returns a recommended size for the widget. | 229 | * Returns a recommended size for the widget. |
230 | * To save some time, the size of the largest used cell content is | 230 | * To save some time, the size of the largest used cell content is |
231 | * calculated in each paintCell() call, since all calculations have | 231 | * calculated in each paintCell() call, since all calculations have |
232 | * to be done there anyway. The size is stored in maxCell. The | 232 | * to be done there anyway. The size is stored in maxCell. The |
233 | * sizeHint() simply returns a multiple of maxCell. | 233 | * sizeHint() simply returns a multiple of maxCell. |
234 | */ | 234 | */ |
235 | virtual QSize sizeHint() const; | 235 | virtual QSize sizeHint() const; |
236 | /** | 236 | /** |
237 | * Set the font size of the date table. | 237 | * Set the font size of the date table. |
238 | */ | 238 | */ |
239 | void setFontSize(int size); | 239 | void setFontSize(int size); |
240 | /** | 240 | /** |
241 | * Select and display this date. | 241 | * Select and display this date. |
242 | */ | 242 | */ |
243 | bool setDate(const QDate&); | 243 | bool setDate(const QDate&); |
244 | const QDate& getDate() const; | 244 | const QDate& getDate() const; |
245 | 245 | ||
246 | 246 | ||
247 | protected: | 247 | protected: |
248 | bool mMarkCurrent; | 248 | bool mMarkCurrent; |
249 | /** | 249 | /** |
250 | * Paint a cell. | 250 | * Paint a cell. |
251 | */ | 251 | */ |
252 | virtual void paintCell(QPainter*, int, int); | 252 | virtual void paintCell(QPainter*, int, int); |
253 | /** | 253 | /** |
254 | * Handle the resize events. | 254 | * Handle the resize events. |
255 | */ | 255 | */ |
256 | virtual void viewportResizeEvent(QResizeEvent *); | 256 | virtual void viewportResizeEvent(QResizeEvent *); |
257 | /** | 257 | /** |
258 | * React on mouse clicks that select a date. | 258 | * React on mouse clicks that select a date. |
259 | */ | 259 | */ |
260 | virtual void contentsMousePressEvent(QMouseEvent *); | 260 | virtual void contentsMousePressEvent(QMouseEvent *); |
261 | virtual void keyPressEvent( QKeyEvent *e ); | 261 | virtual void keyPressEvent( QKeyEvent *e ); |
262 | virtual void focusInEvent( QFocusEvent *e ); | 262 | virtual void focusInEvent( QFocusEvent *e ); |
263 | virtual void focusOutEvent( QFocusEvent *e ); | 263 | virtual void focusOutEvent( QFocusEvent *e ); |
264 | /** | 264 | /** |
265 | * The font size of the displayed text. | 265 | * The font size of the displayed text. |
266 | */ | 266 | */ |
267 | int fontsize; | 267 | int fontsize; |
268 | /** | 268 | /** |
269 | * The currently selected date. | 269 | * The currently selected date. |
270 | */ | 270 | */ |
271 | QDate date; | 271 | QDate date; |
272 | /** | 272 | /** |
273 | * The day of the first day in the month [1..7]. | 273 | * The day of the first day in the month [1..7]. |
274 | */ | 274 | */ |
275 | int firstday; | 275 | int firstday; |
276 | /** | 276 | /** |
277 | * The number of days in the current month. | 277 | * The number of days in the current month. |
278 | */ | 278 | */ |
279 | int numdays; | 279 | int numdays; |
280 | /** | 280 | /** |
281 | * The number of days in the previous month. | 281 | * The number of days in the previous month. |
282 | */ | 282 | */ |
283 | int numDaysPrevMonth; | 283 | int numDaysPrevMonth; |
284 | /** | 284 | /** |
285 | * unused | 285 | * unused |
286 | */ | 286 | */ |
287 | bool unused_hasSelection; | 287 | bool unused_hasSelection; |
288 | /** | 288 | /** |
289 | * Save the size of the largest used cell content. | 289 | * Save the size of the largest used cell content. |
290 | */ | 290 | */ |
291 | QRect maxCell; | 291 | QRect maxCell; |
292 | signals: | 292 | signals: |
293 | /** | 293 | /** |
294 | * The selected date changed. | 294 | * The selected date changed. |
295 | */ | 295 | */ |
296 | void dateChanged(QDate); | 296 | void dateChanged(QDate); |
297 | /** | 297 | /** |
298 | * A date has been selected by clicking on the table. | 298 | * A date has been selected by clicking on the table. |
299 | */ | 299 | */ |
300 | void tableClicked(); | 300 | void tableClicked(); |
301 | 301 | ||
302 | protected: | 302 | protected: |
303 | virtual void virtual_hook( int id, void* data ); | 303 | virtual void virtual_hook( int id, void* data ); |
304 | private: | 304 | private: |
305 | class KDateTablePrivate; | 305 | class KDateTablePrivate; |
306 | KDateTablePrivate *d; | 306 | KDateTablePrivate *d; |
307 | }; | 307 | }; |
308 | 308 | ||
309 | #endif // KDATETBL_H | 309 | #endif // KDATETBL_H |
310 | class KDateInternalWeekPicker : public QGridView | ||
311 | { | ||
312 | Q_OBJECT | ||
313 | protected: | ||
314 | /** | ||
315 | * Store the month that has been clicked [1..12]. | ||
316 | */ | ||
317 | int result; | ||
318 | /** | ||
319 | * the cell under mouse cursor when LBM is pressed | ||
320 | */ | ||
321 | short int activeCol; | ||
322 | short int activeRow; | ||
323 | /** | ||
324 | * Contains the largest rectangle needed by the month names. | ||
325 | */ | ||
326 | QRect max; | ||
327 | signals: | ||
328 | /** | ||
329 | * This is send from the mouse click event handler. | ||
330 | */ | ||
331 | void closeMe(int); | ||
332 | public: | ||
333 | /** | ||
334 | * The constructor. | ||
335 | */ | ||
336 | KDateInternalWeekPicker(int fontsize, QWidget* parent, const char* name=0); | ||
337 | /** | ||
338 | * The size hint. | ||
339 | */ | ||
340 | QSize sizeHint() const; | ||
341 | /** | ||
342 | * Return the result. 0 means no selection (reject()), 1..12 are the | ||
343 | * months. | ||
344 | */ | ||
345 | int getResult() const; | ||
346 | protected: | ||
347 | /** | ||
348 | * Set up the painter. | ||
349 | */ | ||
350 | void setupPainter(QPainter *p); | ||
351 | /** | ||
352 | * The resize event. | ||
353 | */ | ||
354 | void viewportResizeEvent(QResizeEvent*); | ||
355 | /** | ||
356 | * Paint a cell. This simply draws the month names in it. | ||
357 | */ | ||
358 | virtual void paintCell(QPainter* painter, int row, int col); | ||
359 | /** | ||
360 | * Catch mouse click and move events to paint a rectangle around the item. | ||
361 | */ | ||
362 | void contentsMousePressEvent(QMouseEvent *e); | ||
363 | void contentsMouseMoveEvent(QMouseEvent *e); | ||
364 | /** | ||
365 | * Emit monthSelected(int) when a cell has been released. | ||
366 | */ | ||
367 | void contentsMouseReleaseEvent(QMouseEvent *e); | ||
368 | |||
369 | private: | ||
370 | class KDateInternalMonthPrivate; | ||
371 | KDateInternalMonthPrivate *d; | ||
372 | }; | ||