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