summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-07-02 07:02:47 (UTC)
committer zautrix <zautrix>2005-07-02 07:02:47 (UTC)
commit58a4e6e5dcc24e2f5c17ef9f0e6879d625b5f764 (patch) (unidiff)
treef2c6c5c541a76a9e77fe8176add728127c7b6a38 /korganizer
parentb51bfb06293b34b77c46954253ab1b5220c8dd03 (diff)
downloadkdepimpi-58a4e6e5dcc24e2f5c17ef9f0e6879d625b5f764.zip
kdepimpi-58a4e6e5dcc24e2f5c17ef9f0e6879d625b5f764.tar.gz
kdepimpi-58a4e6e5dcc24e2f5c17ef9f0e6879d625b5f764.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/kofilterview.h1
-rw-r--r--korganizer/komonthview.cpp8
-rw-r--r--korganizer/komonthview.h3
-rw-r--r--korganizer/mainwindow.cpp9
5 files changed, 16 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 678143d..5c88abd 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2003,193 +2003,193 @@ bool CalendarView::openCalendar(QString filename, bool merge)
2003 } 2003 }
2004 } 2004 }
2005 return true; 2005 return true;
2006 } else { 2006 } else {
2007 // while failing to load, the calendar object could 2007 // while failing to load, the calendar object could
2008 // have become partially populated. Clear it out. 2008 // have become partially populated. Clear it out.
2009 if ( !merge ) { 2009 if ( !merge ) {
2010 mCalendar->close(); 2010 mCalendar->close();
2011 mViewManager->setDocumentId( filename ); 2011 mViewManager->setDocumentId( filename );
2012 mDialogManager->setDocumentId( filename ); 2012 mDialogManager->setDocumentId( filename );
2013 mTodoList->setDocumentId( filename ); 2013 mTodoList->setDocumentId( filename );
2014 } 2014 }
2015 2015
2016 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2016 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2017 2017
2018 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2018 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2019 globalFlagBlockAgenda = 2; 2019 globalFlagBlockAgenda = 2;
2020 mCalendar->reInitAlarmSettings(); 2020 mCalendar->reInitAlarmSettings();
2021 setSyncEventsReadOnly(); 2021 setSyncEventsReadOnly();
2022 updateUnmanagedViews(); 2022 updateUnmanagedViews();
2023 updateView(); 2023 updateView();
2024 } 2024 }
2025 return false; 2025 return false;
2026} 2026}
2027void CalendarView::showOpenError() 2027void CalendarView::showOpenError()
2028{ 2028{
2029 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2029 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2030} 2030}
2031void CalendarView::setLoadedFileVersion(QDateTime dt) 2031void CalendarView::setLoadedFileVersion(QDateTime dt)
2032{ 2032{
2033 loadedFileVersion = dt; 2033 loadedFileVersion = dt;
2034} 2034}
2035bool CalendarView::checkFileChanged(QString fn) 2035bool CalendarView::checkFileChanged(QString fn)
2036{ 2036{
2037 QFileInfo finf ( fn ); 2037 QFileInfo finf ( fn );
2038 if ( !finf.exists() ) 2038 if ( !finf.exists() )
2039 return true; 2039 return true;
2040 QDateTime dt = finf.lastModified (); 2040 QDateTime dt = finf.lastModified ();
2041 if ( dt <= loadedFileVersion ) 2041 if ( dt <= loadedFileVersion )
2042 return false; 2042 return false;
2043 return true; 2043 return true;
2044 2044
2045} 2045}
2046void CalendarView::watchSavedFile() 2046void CalendarView::watchSavedFile()
2047{ 2047{
2048 QFileInfo finf ( MainWindow::defaultFileName()); 2048 QFileInfo finf ( MainWindow::defaultFileName());
2049 if ( !finf.exists() ) 2049 if ( !finf.exists() )
2050 return; 2050 return;
2051 QDateTime dt = finf.lastModified (); 2051 QDateTime dt = finf.lastModified ();
2052 if ( dt < loadedFileVersion ) { 2052 if ( dt < loadedFileVersion ) {
2053 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2053 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2054 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2054 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2055 return; 2055 return;
2056 } 2056 }
2057 loadedFileVersion = dt; 2057 loadedFileVersion = dt;
2058} 2058}
2059bool CalendarView::checkAllFileVersions() 2059bool CalendarView::checkAllFileVersions()
2060{ 2060{
2061 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2061 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2062 KopiCalendarFile * cal = calendars.first(); 2062 KopiCalendarFile * cal = calendars.first();
2063 mCalendar->setDefaultCalendar( 1 ); 2063 mCalendar->setDefaultCalendar( 1 );
2064 mCalendar->setDefaultCalendarEnabledOnly(); 2064 mCalendar->setDefaultCalendarEnabledOnly();
2065 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2065 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2066 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2066 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2067 restoreCalendarSettings(); 2067 restoreCalendarSettings();
2068 return false; 2068 return false;
2069 } 2069 }
2070 } 2070 }
2071 cal = calendars.next(); 2071 cal = calendars.next();
2072 QDateTime storeTemp = loadedFileVersion; 2072 QDateTime storeTemp = loadedFileVersion;
2073 while ( cal ) { 2073 while ( cal ) {
2074 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2074 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2075 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2075 mCalendar->setDefaultCalendar( cal->mCalNumber );
2076 mCalendar->setDefaultCalendarEnabledOnly(); 2076 mCalendar->setDefaultCalendarEnabledOnly();
2077 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2077 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2078 if ( !checkFileVersion(cal->mFileName )) { 2078 if ( !checkFileVersion(cal->mFileName )) {
2079 loadedFileVersion = storeTemp; 2079 loadedFileVersion = storeTemp;
2080 restoreCalendarSettings(); 2080 restoreCalendarSettings();
2081 return false; 2081 return false;
2082 } 2082 }
2083 } 2083 }
2084 cal = calendars.next(); 2084 cal = calendars.next();
2085 } 2085 }
2086 loadedFileVersion = storeTemp; 2086 loadedFileVersion = storeTemp;
2087 return true; 2087 return true;
2088} 2088}
2089bool CalendarView::checkFileVersion(QString fn) 2089bool CalendarView::checkFileVersion(QString fn)
2090{ 2090{
2091 QFileInfo finf ( fn ); 2091 QFileInfo finf ( fn );
2092 if ( !finf.exists() ) 2092 if ( !finf.exists() )
2093 return true; 2093 return true;
2094 QDateTime dt = finf.lastModified (); 2094 QDateTime dt = finf.lastModified ();
2095 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2095 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2096 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2096 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2097 if ( dt <= loadedFileVersion ) 2097 if ( dt <= loadedFileVersion )
2098 return true; 2098 return true;
2099 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2099 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2100 i18n("KO/Pi Warning"),i18n("Overwrite"), 2100 i18n("KO/Pi Warning"),i18n("Overwrite"),
2101 i18n("Sync+save")); 2101 i18n("Sync+save"));
2102 2102
2103 if ( km == KMessageBox::Cancel ) 2103 if ( km == KMessageBox::Cancel )
2104 return false; 2104 return false;
2105 if ( km == KMessageBox::Yes ) 2105 if ( km == KMessageBox::Yes )
2106 return true; 2106 return true;
2107 2107
2108 setSyncDevice("deleteaftersync" ); 2108 setSyncDevice("deleteaftersync" );
2109 mSyncManager->mAskForPreferences = true; 2109 mSyncManager->mAskForPreferences = true;
2110 mSyncManager->mSyncAlgoPrefs = 3; 2110 mSyncManager->mSyncAlgoPrefs = 3;
2111 mSyncManager->mWriteBackFile = false; 2111 mSyncManager->mWriteBackFile = false;
2112 mSyncManager->mWriteBackExistingOnly = false; 2112 mSyncManager->mWriteBackExistingOnly = false;
2113 mSyncManager->mShowSyncSummary = false; 2113 mSyncManager->mShowSyncSummary = false;
2114 syncCalendar( fn, 3 ); 2114 syncCalendar( fn, 3 );
2115 Event * e = getLastSyncEvent(); 2115 Event * e = getLastSyncEvent();
2116 if ( e ) 2116 if ( e )
2117 mCalendar->deleteEvent( e ); 2117 mCalendar->deleteEvent( e );
2118 return true; 2118 return true;
2119} 2119}
2120bool CalendarView::saveCalendars() 2120bool CalendarView::saveCalendars()
2121{ 2121{
2122 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2122 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2123 KopiCalendarFile * cal = calendars.first(); 2123 KopiCalendarFile * cal = calendars.first();
2124 mCalendar->setDefaultCalendar( 1 ); 2124 mCalendar->setDefaultCalendar( 1 );
2125 mCalendar->setDefaultCalendarEnabledOnly(); 2125 mCalendar->setDefaultCalendarEnabledOnly();
2126 saveCalendar( MainWindow::defaultFileName() ); 2126 saveCalendar( MainWindow::defaultFileName() );
2127 cal = calendars.next(); 2127 cal = calendars.next();
2128 while ( cal ) { 2128 while ( cal ) {
2129 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2129 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2130 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2130 mCalendar->setDefaultCalendar( cal->mCalNumber );
2131 mCalendar->setDefaultCalendarEnabledOnly(); 2131 mCalendar->setDefaultCalendarEnabledOnly();
2132 if ( saveCalendar( cal->mFileName ) ) 2132 if ( saveCalendar( cal->mFileName ) )
2133 cal->mLoadDt = QDateTime::currentDateTime(); 2133 cal->mLoadDt = QDateTime::currentDateTime();
2134 } 2134 }
2135 cal = calendars.next(); 2135 cal = calendars.next();
2136 } 2136 }
2137 restoreCalendarSettings(); 2137 restoreCalendarSettings();
2138 return true; 2138 return true;
2139} 2139}
2140bool CalendarView::saveCalendar( QString filename ) 2140bool CalendarView::saveCalendar( QString filename )
2141{ 2141{
2142 2142
2143 // Store back all unsaved data into calendar object 2143 // Store back all unsaved data into calendar object
2144 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2144 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2145 if ( mViewManager->currentView() ) 2145 if ( mViewManager->currentView() )
2146 mViewManager->currentView()->flushView(); 2146 mViewManager->currentView()->flushView();
2147 2147
2148 2148
2149 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2149 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2150 mStorage->setSaveFormat( new ICalFormat() ); 2150 mStorage->setSaveFormat( new ICalFormat() );
2151 mStorage->setFileName( filename ); 2151 mStorage->setFileName( filename );
2152 bool success; 2152 bool success;
2153 success = mStorage->save(); 2153 success = mStorage->save();
2154 if ( !success ) { 2154 if ( !success ) {
2155 return false; 2155 return false;
2156 } 2156 }
2157 if ( filename == MainWindow::defaultFileName() ) { 2157 if ( filename == MainWindow::defaultFileName() ) {
2158 setLoadedFileVersion( lfv ); 2158 setLoadedFileVersion( lfv );
2159 watchSavedFile(); 2159 watchSavedFile();
2160 } 2160 }
2161 return true; 2161 return true;
2162} 2162}
2163 2163
2164void CalendarView::closeCalendar() 2164void CalendarView::closeCalendar()
2165{ 2165{
2166 2166
2167 // child windows no longer valid 2167 // child windows no longer valid
2168 clearAllViews(); 2168 clearAllViews();
2169 emit closingDown(); 2169 emit closingDown();
2170 2170
2171 mCalendar->close(); 2171 mCalendar->close();
2172 setModified(false); 2172 setModified(false);
2173 updateView(); 2173 updateView();
2174} 2174}
2175 2175
2176void CalendarView::archiveCalendar() 2176void CalendarView::archiveCalendar()
2177{ 2177{
2178 mDialogManager->showArchiveDialog(); 2178 mDialogManager->showArchiveDialog();
2179} 2179}
2180 2180
2181 2181
2182void CalendarView::readSettings() 2182void CalendarView::readSettings()
2183{ 2183{
2184 2184
2185 2185
2186 // mViewManager->showAgendaView(); 2186 // mViewManager->showAgendaView();
2187 QString str; 2187 QString str;
2188 //qDebug("CalendarView::readSettings() "); 2188 //qDebug("CalendarView::readSettings() ");
2189 // read settings from the KConfig, supplying reasonable 2189 // read settings from the KConfig, supplying reasonable
2190 // defaults where none are to be found 2190 // defaults where none are to be found
2191 KConfig *config = KOGlobals::config(); 2191 KConfig *config = KOGlobals::config();
2192#ifndef KORG_NOSPLITTER 2192#ifndef KORG_NOSPLITTER
2193 config->setGroup("KOrganizer Geometry"); 2193 config->setGroup("KOrganizer Geometry");
2194 2194
2195 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2195 QValueList<int> sizes = config->readIntListEntry("Separator1");
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h
index 874fc6a..4322299 100644
--- a/korganizer/kofilterview.h
+++ b/korganizer/kofilterview.h
@@ -1,123 +1,124 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOFILTERVIEW_H 23#ifndef KOFILTERVIEW_H
24#define KOFILTERVIEW_H 24#define KOFILTERVIEW_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qapplication.h>
28#include <qradiobutton.h> 29#include <qradiobutton.h>
29#include <qlayout.h> 30#include <qlayout.h>
30#include <qlabel.h> 31#include <qlabel.h>
31#include <qdialog.h> 32#include <qdialog.h>
32#include <qscrollview.h> 33#include <qscrollview.h>
33#include <qpushbutton.h> 34#include <qpushbutton.h>
34#include <kconfig.h> 35#include <kconfig.h>
35#include "kofilterview_base.h" 36#include "kofilterview_base.h"
36 37
37#include <libkcal/calfilter.h> 38#include <libkcal/calfilter.h>
38 39
39#include <kurlrequester.h> 40#include <kurlrequester.h>
40#include <klineedit.h> 41#include <klineedit.h>
41#include <kglobal.h> 42#include <kglobal.h>
42#include <kmessagebox.h> 43#include <kmessagebox.h>
43 44
44class QGridLayout; 45class QGridLayout;
45 46
46using namespace KCal; 47using namespace KCal;
47 48
48class KONewCalPrefs : public QDialog 49class KONewCalPrefs : public QDialog
49{ 50{
50 Q_OBJECT 51 Q_OBJECT
51 public: 52 public:
52 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 53 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
53 QDialog( parent, name, true ) 54 QDialog( parent, name, true )
54 { 55 {
55 setCaption( i18n("Add new Calendar") ); 56 setCaption( i18n("Add new Calendar") );
56 QVBoxLayout* lay = new QVBoxLayout( this ); 57 QVBoxLayout* lay = new QVBoxLayout( this );
57 lay->setSpacing( 3 ); 58 lay->setSpacing( 3 );
58 lay->setMargin( 3 ); 59 lay->setMargin( 3 );
59 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 60 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
60 lay->addWidget( lab ); 61 lay->addWidget( lab );
61 nameE = new KLineEdit( this ); 62 nameE = new KLineEdit( this );
62 lay->addWidget( nameE ); 63 lay->addWidget( nameE );
63 lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); 64 lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this );
64 lay->addWidget( lab ); 65 lay->addWidget( lab );
65 url = new KURLRequester ( this ); 66 url = new KURLRequester ( this );
66 lay->addWidget( url ); 67 lay->addWidget( url );
67 QPushButton * ok = new QPushButton( i18n("OK"), this ); 68 QPushButton * ok = new QPushButton( i18n("OK"), this );
68 lay->addWidget( ok ); 69 lay->addWidget( ok );
69 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 70 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
70 lay->addWidget( cancel ); 71 lay->addWidget( cancel );
71 connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); 72 connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) );
72 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 73 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
73 int minwid = 220; 74 int minwid = 220;
74 if ( QApplication::desktop()->width() >= 320 ) minwid = 300; 75 if ( QApplication::desktop()->width() >= 320 ) minwid = 300;
75 setMinimumWidth( minwid ); 76 setMinimumWidth( minwid );
76 resize(sizeHint() ); 77 resize(sizeHint() );
77 } 78 }
78 79
79 QString calName() { return nameE->text(); } 80 QString calName() { return nameE->text(); }
80 QString calFileName() { return url->url(); } 81 QString calFileName() { return url->url(); }
81 82
82public slots: 83public slots:
83void checkValid() { 84void checkValid() {
84 if ( nameE->text().isEmpty() ) { 85 if ( nameE->text().isEmpty() ) {
85 KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); 86 KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") );
86 nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); 87 nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () ));
87 return; 88 return;
88 } 89 }
89 if ( url->url().isEmpty() ) { 90 if ( url->url().isEmpty() ) {
90 KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); 91 KMessageBox::information( this, i18n("Sorry, the file name is empty!") );
91 return; 92 return;
92 } 93 }
93 accept(); 94 accept();
94} 95}
95 96
96public: 97public:
97 KLineEdit* nameE; 98 KLineEdit* nameE;
98 KURLRequester *url; 99 KURLRequester *url;
99}; 100};
100 101
101class KOCalButton : public QPushButton 102class KOCalButton : public QPushButton
102{ 103{
103 Q_OBJECT 104 Q_OBJECT
104 public: 105 public:
105 KOCalButton( QWidget *parent=0, const char *name=0 ) : 106 KOCalButton( QWidget *parent=0, const char *name=0 ) :
106 QPushButton( parent, name) 107 QPushButton( parent, name)
107 { 108 {
108 connect( this, SIGNAL( clicked() ), 109 connect( this, SIGNAL( clicked() ),
109 SLOT( bottonClicked() )); 110 SLOT( bottonClicked() ));
110 mNumber = -1; 111 mNumber = -1;
111 setFocusPolicy(NoFocus); 112 setFocusPolicy(NoFocus);
112 } 113 }
113 void setNum ( int num ) {mNumber = num; } 114 void setNum ( int num ) {mNumber = num; }
114 signals: 115 signals:
115 void selectNum ( int ); 116 void selectNum ( int );
116private: 117private:
117 int mNumber; 118 int mNumber;
118 void keyPressEvent ( QKeyEvent * e ) 119 void keyPressEvent ( QKeyEvent * e )
119 { 120 {
120 e->ignore(); 121 e->ignore();
121 } 122 }
122 123
123private slots : 124private slots :
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 264cf28..4fc447e 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1699,217 +1699,219 @@ void KOMonthView::updateView()
1699 st = timeSpan - st; 1699 st = timeSpan - st;
1700 if ( st < 0 ) st = 0; 1700 if ( st < 0 ) st = 0;
1701 if ( end > timeSpan ) end = timeSpan; 1701 if ( end > timeSpan ) end = timeSpan;
1702 int iii; 1702 int iii;
1703 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1703 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1704 for ( iii = st;iii<= end;++iii) 1704 for ( iii = st;iii<= end;++iii)
1705 (*cells)[iii]->insertEvent( event ); 1705 (*cells)[iii]->insertEvent( event );
1706 } 1706 }
1707 } 1707 }
1708 } else { 1708 } else {
1709 if ( invalid ) 1709 if ( invalid )
1710 break; 1710 break;
1711 invalid = true; 1711 invalid = true;
1712 //qDebug("invalid %s", event->summary().latin1()); 1712 //qDebug("invalid %s", event->summary().latin1());
1713 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1713 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1714 } 1714 }
1715 if ( last ) 1715 if ( last )
1716 break; 1716 break;
1717 bool ok; 1717 bool ok;
1718 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1718 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1719 if ( ! ok ) 1719 if ( ! ok )
1720 break; 1720 break;
1721 if ( incidenceStart.date() > endDate ) 1721 if ( incidenceStart.date() > endDate )
1722 break; 1722 break;
1723 } 1723 }
1724 } else { // no recur 1724 } else { // no recur
1725 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1725 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1726 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1726 if ( event->uid().left(15) == QString("last-syncEvent-") )
1727 continue; 1727 continue;
1728 int st = event->dtStart().date().daysTo( endDate ); 1728 int st = event->dtStart().date().daysTo( endDate );
1729 if ( st >= 0 ) { // start before timeend 1729 if ( st >= 0 ) { // start before timeend
1730 int end = mStartDate.daysTo( event->dtEnd().date() ); 1730 int end = mStartDate.daysTo( event->dtEnd().date() );
1731 if ( end >= 0 ) { // end after timestart --- got one! 1731 if ( end >= 0 ) { // end after timestart --- got one!
1732 //normalize 1732 //normalize
1733 st = timeSpan - st; 1733 st = timeSpan - st;
1734 if ( st < 0 ) st = 0; 1734 if ( st < 0 ) st = 0;
1735 if ( end > timeSpan ) end = timeSpan; 1735 if ( end > timeSpan ) end = timeSpan;
1736 int iii; 1736 int iii;
1737 for ( iii = st;iii<= end;++iii) 1737 for ( iii = st;iii<= end;++iii)
1738 (*cells)[iii]->insertEvent( event ); 1738 (*cells)[iii]->insertEvent( event );
1739 } 1739 }
1740 } 1740 }
1741 } 1741 }
1742 } 1742 }
1743 // insert due todos 1743 // insert due todos
1744 QPtrList<Todo> todos = calendar()->todos( ); 1744 QPtrList<Todo> todos = calendar()->todos( );
1745 Todo *todo; 1745 Todo *todo;
1746 for(todo = todos.first(); todo; todo = todos.next()) { 1746 for(todo = todos.first(); todo; todo = todos.next()) {
1747 //insertTodo( todo ); 1747 //insertTodo( todo );
1748 if ( todo->hasDueDate() ) { 1748 if ( todo->hasDueDate() ) {
1749 int day = mStartDate.daysTo( todo->dtDue().date() ); 1749 int day = mStartDate.daysTo( todo->dtDue().date() );
1750 if ( day >= 0 && day < timeSpan + 1) { 1750 if ( day >= 0 && day < timeSpan + 1) {
1751 (*cells)[day]->insertTodo( todo ); 1751 (*cells)[day]->insertTodo( todo );
1752 } 1752 }
1753 } 1753 }
1754 } 1754 }
1755 1755
1756 for( i = 0; i < timeSpan+1; ++i ) { 1756 for( i = 0; i < timeSpan+1; ++i ) {
1757 (*cells)[i]->finishUpdateCell(); 1757 (*cells)[i]->finishUpdateCell();
1758 } 1758 }
1759 processSelectionChange(); 1759 processSelectionChange();
1760 //qApp->processEvents(); 1760 //qApp->processEvents();
1761 for( i = 0; i < timeSpan+1; ++i ) { 1761 for( i = 0; i < timeSpan+1; ++i ) {
1762 //(*cells)[i]->repaintfinishUpdateCell(); 1762 //(*cells)[i]->repaintfinishUpdateCell();
1763 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); 1763 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) );
1764 } 1764 }
1765 setKeyBFocus(); 1765 setKeyBFocus();
1766#else 1766#else
1767 // old code 1767 // old code
1768 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1768 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1769 int i; 1769 int i;
1770 for( i = 0; i < (*cells).count(); ++i ) { 1770 for( i = 0; i < (*cells).count(); ++i ) {
1771 (*cells)[i]->updateCell(); 1771 (*cells)[i]->updateCell();
1772 } 1772 }
1773 1773
1774 //qDebug("KOMonthView::updateView() "); 1774 //qDebug("KOMonthView::updateView() ");
1775 processSelectionChange(); 1775 processSelectionChange();
1776 // qDebug("---------------------------------------------------------------------+ "); 1776 // qDebug("---------------------------------------------------------------------+ ");
1777 (*cells)[0]->setFocus(); 1777 (*cells)[0]->setFocus();
1778#endif 1778#endif
1779 1779
1780 //qDebug("update time %d ", ti.elapsed()); 1780 //qDebug("update time %d ", ti.elapsed());
1781} 1781}
1782 1782
1783void KOMonthView::setKeyBoardFocus() 1783void KOMonthView::setKeyBoardFocus()
1784{ 1784{
1785 //qDebug("KOMonthView::setKeyBoardFocus() "); 1785 //qDebug("KOMonthView::setKeyBoardFocus() ");
1786 bool shootAgain = false; 1786 bool shootAgain = false;
1787 if ( mShowWeekView ) { 1787 if ( mShowWeekView ) {
1788 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1788 shootAgain = !mWeekLabelsW[1]->hasFocus();
1789 mWeekLabelsW[1]->setFocus(); 1789 mWeekLabelsW[1]->setFocus();
1790 } 1790 }
1791 else { 1791 else {
1792 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1792 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1793 mWeekLabels[mNumWeeks]->setFocus(); 1793 mWeekLabels[mNumWeeks]->setFocus();
1794 } 1794 }
1795 if ( shootAgain ) { 1795 --mKBFcounter;
1796 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1796 if ( shootAgain && mKBFcounter > 0 ) {
1797 QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) );
1797 } 1798 }
1798} 1799}
1799void KOMonthView::setKeyBFocus() 1800void KOMonthView::setKeyBFocus()
1800{ 1801{
1801 //qDebug("KOMonthView::setKeyBFocus() "); 1802 //qDebug("KOMonthView::setKeyBFocus() ");
1803 mKBFcounter = 10;
1802 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1804 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1803} 1805}
1804void KOMonthView::resizeEvent(QResizeEvent * e) 1806void KOMonthView::resizeEvent(QResizeEvent * e)
1805{ 1807{
1806 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1808 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1807 if ( isVisible() ) { 1809 if ( isVisible() ) {
1808 //qDebug("KOMonthView::isVisible "); 1810 //qDebug("KOMonthView::isVisible ");
1809 slotComputeLayout(); 1811 slotComputeLayout();
1810 } else 1812 } else
1811 mComputeLayoutTimer->start( 100 ); 1813 mComputeLayoutTimer->start( 100 );
1812} 1814}
1813 1815
1814void KOMonthView::slotComputeLayout() 1816void KOMonthView::slotComputeLayout()
1815{ 1817{
1816 mComputeLayoutTimer->stop(); 1818 mComputeLayoutTimer->stop();
1817 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1819 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1818 computeLayout(); 1820 computeLayout();
1819 clPending = true; 1821 clPending = true;
1820 setKeyBFocus(); 1822 setKeyBFocus();
1821} 1823}
1822void KOMonthView::computeLayoutWeek() 1824void KOMonthView::computeLayoutWeek()
1823{ 1825{
1824 static int lastWid = 0; 1826 static int lastWid = 0;
1825 static int lastHei = 0; 1827 static int lastHei = 0;
1826 int daysToShow; 1828 int daysToShow;
1827 bool combinedSatSun = false; 1829 bool combinedSatSun = false;
1828 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1830 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1829 daysToShow = 6; 1831 daysToShow = 6;
1830 combinedSatSun = true; 1832 combinedSatSun = true;
1831 } 1833 }
1832 int tWid = topLevelWidget()->size().width(); 1834 int tWid = topLevelWidget()->size().width();
1833 int tHei = topLevelWidget()->size().height(); 1835 int tHei = topLevelWidget()->size().height();
1834 1836
1835 int wid = width();//e 1837 int wid = width();//e
1836 int hei = height()-1-mNavigatorBar->height(); 1838 int hei = height()-1-mNavigatorBar->height();
1837 1839
1838 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1840 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1839 return; 1841 return;
1840 1842
1841 if ( lastWid == width() && lastHei == height() ) { 1843 if ( lastWid == width() && lastHei == height() ) {
1842 //qDebug("KOListWeekView::No compute layout needed "); 1844 //qDebug("KOListWeekView::No compute layout needed ");
1843 return; 1845 return;
1844 } 1846 }
1845 lastWid = width(); 1847 lastWid = width();
1846 lastHei = height(); 1848 lastHei = height();
1847 1849
1848 1850
1849 if ( wid < hei ) 1851 if ( wid < hei )
1850 daysToShow = 2; 1852 daysToShow = 2;
1851 else 1853 else
1852 daysToShow = 3; 1854 daysToShow = 3;
1853 mShowSatSunComp = true; 1855 mShowSatSunComp = true;
1854 combinedSatSun = true; 1856 combinedSatSun = true;
1855 1857
1856 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1858 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1857 QFontMetrics fm ( mWeekLabels[0]->font() ); 1859 QFontMetrics fm ( mWeekLabels[0]->font() );
1858 int weeklabelwid = fm.width( "888" ); 1860 int weeklabelwid = fm.width( "888" );
1859 wid -= weeklabelwid; 1861 wid -= weeklabelwid;
1860 1862
1861 int colWid = wid / daysToShow; 1863 int colWid = wid / daysToShow;
1862 int lastCol = wid - ( colWid*6 ); 1864 int lastCol = wid - ( colWid*6 );
1863 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1865 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1864 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1866 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1865 int colModulo = wid % daysToShow; 1867 int colModulo = wid % daysToShow;
1866 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1868 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1867 //qDebug("rowmod %d ", rowModulo); 1869 //qDebug("rowmod %d ", rowModulo);
1868 int i; 1870 int i;
1869 int x,y,w,h; 1871 int x,y,w,h;
1870 x= 0; 1872 x= 0;
1871 y= 0; 1873 y= 0;
1872 w = colWid; 1874 w = colWid;
1873 h = dayLabelHei ; 1875 h = dayLabelHei ;
1874 for ( i = 0; i < 7; i++) { 1876 for ( i = 0; i < 7; i++) {
1875 if ( i && !( i % daysToShow) && i < 6) { 1877 if ( i && !( i % daysToShow) && i < 6) {
1876 y += hei/(5-daysToShow); 1878 y += hei/(5-daysToShow);
1877 x = 0; 1879 x = 0;
1878 w = colWid; 1880 w = colWid;
1879 } 1881 }
1880 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1882 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1881 ++w; 1883 ++w;
1882 } 1884 }
1883 if ( i >= 5 ) { 1885 if ( i >= 5 ) {
1884 int wi = width() - x - weeklabelwid; 1886 int wi = width() - x - weeklabelwid;
1885 if ( i == 5 ) { 1887 if ( i == 5 ) {
1886 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1888 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1887 } else { 1889 } else {
1888 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1890 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1889 } 1891 }
1890 x = x - w + wi - (wi/2 ); 1892 x = x - w + wi - (wi/2 );
1891 } 1893 }
1892 else { 1894 else {
1893 int wi = w; 1895 int wi = w;
1894 if ( !(( i+1) % daysToShow)) { 1896 if ( !(( i+1) % daysToShow)) {
1895 wi = width() - x - weeklabelwid; 1897 wi = width() - x - weeklabelwid;
1896 } 1898 }
1897 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1899 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1898 } 1900 }
1899 x += w; 1901 x += w;
1900 } 1902 }
1901 x= 0; 1903 x= 0;
1902 y= dayLabelHei; 1904 y= dayLabelHei;
1903 w = colWid; 1905 w = colWid;
1904 h = cellHei; 1906 h = cellHei;
1905 int max = 0; 1907 int max = 0;
1906 for ( i = 0; i < mCellsW.count(); ++i) { 1908 for ( i = 0; i < mCellsW.count(); ++i) {
1907 if ( i > 6 ) { 1909 if ( i > 6 ) {
1908 mCellsW[i]->hide(); 1910 mCellsW[i]->hide();
1909 continue; 1911 continue;
1910 } 1912 }
1911 1913
1912 w = colWid; 1914 w = colWid;
1913 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1915 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1914 ++w; 1916 ++w;
1915 } 1917 }
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 0bd6b1c..a41eb54 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -185,161 +185,162 @@ class MonthViewCell : public KNoScrollListBox
185#endif 185#endif
186 signals: 186 signals:
187 void defaultAction( Incidence * ); 187 void defaultAction( Incidence * );
188 void newEventSignal( QDateTime ); 188 void newEventSignal( QDateTime );
189 void showDaySignal( QDate ); 189 void showDaySignal( QDate );
190 190
191 protected: 191 protected:
192 QStringList mToolTip; 192 QStringList mToolTip;
193 void resizeEvent( QResizeEvent * ); 193 void resizeEvent( QResizeEvent * );
194 194
195public slots: 195public slots:
196 void showDay(); 196 void showDay();
197 void deHighLight(); 197 void deHighLight();
198 void repaintfinishUpdateCell(); 198 void repaintfinishUpdateCell();
199 protected slots: 199 protected slots:
200 void defaultAction( QListBoxItem * ); 200 void defaultAction( QListBoxItem * );
201 void contextMenu( QListBoxItem * ); 201 void contextMenu( QListBoxItem * );
202 void selection( QListBoxItem * ); 202 void selection( QListBoxItem * );
203 void cellClicked( QListBoxItem * ); 203 void cellClicked( QListBoxItem * );
204 void newEvent(); 204 void newEvent();
205 205
206 private: 206 private:
207 int mdayCount; 207 int mdayCount;
208 QPtrList <MonthViewItem> mAvailItemList; 208 QPtrList <MonthViewItem> mAvailItemList;
209 KOMonthView *mMonthView; 209 KOMonthView *mMonthView;
210 int currentPalette; 210 int currentPalette;
211 211
212 QDate mDate; 212 QDate mDate;
213 bool mPrimary; 213 bool mPrimary;
214 bool mHoliday; 214 bool mHoliday;
215 QString mHolidayString; 215 QString mHolidayString;
216 216
217 //QLabel *mLabel; 217 //QLabel *mLabel;
218 QPushButton *mLabel; 218 QPushButton *mLabel;
219 //QListBox *mItemList; 219 //QListBox *mItemList;
220#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
221 static QToolTipGroup *mToolTipGroup; 221 static QToolTipGroup *mToolTipGroup;
222#endif 222#endif
223 QSize mLabelSize; 223 QSize mLabelSize;
224 QSize mLabelBigSize; 224 QSize mLabelBigSize;
225 QPalette mHolidayPalette; 225 QPalette mHolidayPalette;
226 QPalette mStandardPalette; 226 QPalette mStandardPalette;
227 QPalette mPrimaryPalette; 227 QPalette mPrimaryPalette;
228 QPalette mNonPrimaryPalette; 228 QPalette mNonPrimaryPalette;
229 void setMyPalette(); 229 void setMyPalette();
230 QPalette getPalette (); 230 QPalette getPalette ();
231 231
232}; 232};
233 233
234 234
235class KOMonthView: public KOEventView 235class KOMonthView: public KOEventView
236{ 236{
237 Q_OBJECT 237 Q_OBJECT
238 public: 238 public:
239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
240 ~KOMonthView(); 240 ~KOMonthView();
241 241
242 /** Returns maximum number of days supported by the komonthview */ 242 /** Returns maximum number of days supported by the komonthview */
243 virtual int maxDatesHint(); 243 virtual int maxDatesHint();
244 244
245 /** Returns number of currently shown dates. */ 245 /** Returns number of currently shown dates. */
246 virtual int currentDateCount(); 246 virtual int currentDateCount();
247 247
248 /** returns the currently selected events */ 248 /** returns the currently selected events */
249 virtual QPtrList<Incidence> selectedIncidences(); 249 virtual QPtrList<Incidence> selectedIncidences();
250 250
251 /** returns dates of the currently selected events */ 251 /** returns dates of the currently selected events */
252 virtual DateList selectedDates(); 252 virtual DateList selectedDates();
253 253
254 virtual void printPreview(CalPrinter *calPrinter, 254 virtual void printPreview(CalPrinter *calPrinter,
255 const QDate &, const QDate &); 255 const QDate &, const QDate &);
256 bool isMonthView() { return !mShowWeekView; } 256 bool isMonthView() { return !mShowWeekView; }
257 bool isUpdatePossible() { return updatePossible; } 257 bool isUpdatePossible() { return updatePossible; }
258 258
259 MonthViewCell * selectedCell(); 259 MonthViewCell * selectedCell();
260 bool skipResize; 260 bool skipResize;
261 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 261 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
262 void clearList(); 262 void clearList();
263 public slots: 263 public slots:
264 void incidenceHighlighted( Incidence *, MonthViewCell*, int ); 264 void incidenceHighlighted( Incidence *, MonthViewCell*, int );
265 void nextCell(); 265 void nextCell();
266 void prevCell(); 266 void prevCell();
267 virtual void updateView(); 267 virtual void updateView();
268 virtual void updateConfig(); 268 virtual void updateConfig();
269 virtual void showDates(const QDate &start, const QDate &end); 269 virtual void showDates(const QDate &start, const QDate &end);
270 virtual void showEvents(QPtrList<Event> eventList); 270 virtual void showEvents(QPtrList<Event> eventList);
271 271
272 void changeEventDisplay(Event *, int); 272 void changeEventDisplay(Event *, int);
273 273
274 void clearSelection(); 274 void clearSelection();
275 275
276 void showContextMenu( Incidence * ); 276 void showContextMenu( Incidence * );
277 277
278 void setSelectedCell( MonthViewCell * ); 278 void setSelectedCell( MonthViewCell * );
279 void setPopupCell( MonthViewCell * ); 279 void setPopupCell( MonthViewCell * );
280 void switchView(); 280 void switchView();
281 void setKeyBoardFocus();
282 void setKeyBFocus(); 281 void setKeyBFocus();
283 282
284 protected slots: 283 protected slots:
284 void setKeyBoardFocus();
285 void slotNewTodo(); 285 void slotNewTodo();
286 void slotNewEvent(); 286 void slotNewEvent();
287 void slotEditJournal(); 287 void slotEditJournal();
288 void slotComputeLayout(); 288 void slotComputeLayout();
289 void selectInternalWeekNum ( int ); 289 void selectInternalWeekNum ( int );
290 void processSelectionChange(); 290 void processSelectionChange();
291 signals: 291 signals:
292 void nextMonth(); 292 void nextMonth();
293 void prevMonth(); 293 void prevMonth();
294 void selectWeekNum ( int ); 294 void selectWeekNum ( int );
295 void selectMonth (); 295 void selectMonth ();
296 void showDaySignal( QDate ); 296 void showDaySignal( QDate );
297 void newTodoSignal( QDateTime, bool ); 297 void newTodoSignal( QDateTime, bool );
298 void showJournalSignal( int,QDate ); 298 void showJournalSignal( int,QDate );
299 protected: 299 protected:
300 void resizeEvent(QResizeEvent *); 300 void resizeEvent(QResizeEvent *);
301 void viewChanged(); 301 void viewChanged();
302 void updateDayLabels(); 302 void updateDayLabels();
303 303
304 private: 304 private:
305 int mKBFcounter;
305 QTimer* mComputeLayoutTimer; 306 QTimer* mComputeLayoutTimer;
306 NavigatorBar* mNavigatorBar; 307 NavigatorBar* mNavigatorBar;
307 int currentWeek(); 308 int currentWeek();
308 bool clPending; 309 bool clPending;
309 QWidgetStack * mWidStack; 310 QWidgetStack * mWidStack;
310 QWidget* mMonthView; 311 QWidget* mMonthView;
311 QWidget* mWeekView; 312 QWidget* mWeekView;
312 bool mShowWeekView; 313 bool mShowWeekView;
313 bool updatePossible; 314 bool updatePossible;
314 int mDaysPerWeek; 315 int mDaysPerWeek;
315 int mNumWeeks; 316 int mNumWeeks;
316 int mNumCells; 317 int mNumCells;
317 //bool mWeekStartsMonday; 318 //bool mWeekStartsMonday;
318 bool mShowSatSunComp; 319 bool mShowSatSunComp;
319 void computeLayout(); 320 void computeLayout();
320 void computeLayoutWeek(); 321 void computeLayoutWeek();
321 322
322 QPtrVector<MonthViewCell> mCells; 323 QPtrVector<MonthViewCell> mCells;
323 QPtrVector<QLabel> mDayLabels; 324 QPtrVector<QLabel> mDayLabels;
324 QPtrVector<KOWeekButton> mWeekLabels; 325 QPtrVector<KOWeekButton> mWeekLabels;
325 QPtrVector<MonthViewCell> mCellsW; 326 QPtrVector<MonthViewCell> mCellsW;
326 QPtrVector<QLabel> mDayLabelsW; 327 QPtrVector<QLabel> mDayLabelsW;
327 QPtrVector<KOWeekButton> mWeekLabelsW; 328 QPtrVector<KOWeekButton> mWeekLabelsW;
328 329
329 bool mShortDayLabelsM; 330 bool mShortDayLabelsM;
330 bool mShortDayLabelsW; 331 bool mShortDayLabelsW;
331 int mWidthLongDayLabel; 332 int mWidthLongDayLabel;
332 333
333 QDate mStartDate; 334 QDate mStartDate;
334 335
335 MonthViewCell *mSelectedCell; 336 MonthViewCell *mSelectedCell;
336 MonthViewCell *mPopupCell; 337 MonthViewCell *mPopupCell;
337 bool mFlagKeyPressed; 338 bool mFlagKeyPressed;
338 KOEventPopupMenu *mContextMenu; 339 KOEventPopupMenu *mContextMenu;
339 QPopupMenu *mNewItemMenu; 340 QPopupMenu *mNewItemMenu;
340 void keyPressEvent ( QKeyEvent * ) ; 341 void keyPressEvent ( QKeyEvent * ) ;
341 void keyReleaseEvent ( QKeyEvent * ) ; 342 void keyReleaseEvent ( QKeyEvent * ) ;
342 343
343}; 344};
344 345
345#endif 346#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 862d437..f68f032 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1819,220 +1819,225 @@ void MainWindow::saveOnClose()
1819 if ( p->mToolBarHorN ) 1819 if ( p->mToolBarHorN )
1820 p->mToolBarUpN = myP.y() > height()/2; 1820 p->mToolBarUpN = myP.y() > height()/2;
1821 else 1821 else
1822 p->mToolBarUpN = myP.x() > width()/2 ; 1822 p->mToolBarUpN = myP.x() > width()/2 ;
1823 if ( filterToolBar ) { 1823 if ( filterToolBar ) {
1824 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1824 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1825 if ( p->mToolBarHorF ) 1825 if ( p->mToolBarHorF )
1826 p->mToolBarUpF = myP.y() > height()/2; 1826 p->mToolBarUpF = myP.y() > height()/2;
1827 else 1827 else
1828 p->mToolBarUpF = myP.x() > width()/2 ; 1828 p->mToolBarUpF = myP.x() > width()/2 ;
1829 } 1829 }
1830#else 1830#else
1831 if ( p->mToolBarHor ) 1831 if ( p->mToolBarHor )
1832 p->mToolBarUp = iconToolBar->y() > height()/2; 1832 p->mToolBarUp = iconToolBar->y() > height()/2;
1833 else 1833 else
1834 p->mToolBarUp = iconToolBar->x() > width()/2; 1834 p->mToolBarUp = iconToolBar->x() > width()/2;
1835 if ( p->mToolBarHorV ) 1835 if ( p->mToolBarHorV )
1836 p->mToolBarUpV = viewToolBar->y() > height()/2; 1836 p->mToolBarUpV = viewToolBar->y() > height()/2;
1837 else 1837 else
1838 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1838 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1839 1839
1840 if ( p->mToolBarHorN ) 1840 if ( p->mToolBarHorN )
1841 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1841 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1842 else 1842 else
1843 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1843 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1844 if ( filterToolBar ) { 1844 if ( filterToolBar ) {
1845 if ( p->mToolBarHorF ) 1845 if ( p->mToolBarHorF )
1846 p->mToolBarUpF = filterToolBar->y() > height()/2; 1846 p->mToolBarUpF = filterToolBar->y() > height()/2;
1847 else 1847 else
1848 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1848 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1849 } 1849 }
1850#endif 1850#endif
1851 save(); 1851 save();
1852 mView->writeSettings(); 1852 mView->writeSettings();
1853 mView->checkSuspendAlarm(); 1853 mView->checkSuspendAlarm();
1854} 1854}
1855void MainWindow::slotModifiedChanged( bool ) 1855void MainWindow::slotModifiedChanged( bool )
1856{ 1856{
1857 if ( mBlockAtStartup ) 1857 if ( mBlockAtStartup )
1858 return; 1858 return;
1859 1859
1860 int msec; 1860 int msec;
1861 // we store the changes after 1 minute, 1861 // we store the changes after 1 minute,
1862 // and for safety reasons after 10 minutes again 1862 // and for safety reasons after 10 minutes again
1863 if ( !mSyncManager->blockSave() ) 1863 if ( !mSyncManager->blockSave() )
1864 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1864 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1865 else 1865 else
1866 msec = 1000 * 600; 1866 msec = 1000 * 600;
1867 mSaveTimer.start( msec, true ); // 1 minute 1867 mSaveTimer.start( msec, true ); // 1 minute
1868 qDebug("KO: Saving File in %d secs!", msec/1000); 1868 qDebug("KO: Saving File in %d secs!", msec/1000);
1869 mCalendarModifiedFlag = true; 1869 mCalendarModifiedFlag = true;
1870} 1870}
1871void MainWindow::saveStopTimer() 1871void MainWindow::saveStopTimer()
1872{ 1872{
1873 mSaveTimer.stop(); 1873 mSaveTimer.stop();
1874} 1874}
1875void MainWindow::backupAllFiles() 1875void MainWindow::backupAllFiles()
1876{ 1876{
1877 QDate reference ( 2000,1,1); 1877 QDate reference ( 2000,1,1);
1878 int daysTo = reference.daysTo ( QDate::currentDate() ); 1878 int daysTo = reference.daysTo ( QDate::currentDate() );
1879 setCaption(i18n("Creating backup ... please wait ..." )); 1879 setCaption(i18n("Creating backup ... please wait ..." ));
1880 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1880 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1881 // we need the file path, the backup dir and the number of bups as param 1881 // we need the file path, the backup dir and the number of bups as param
1882 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1882 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1883 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1883 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1884 bupDir = KGlobalSettings::backupDataDir(); 1884 bupDir = KGlobalSettings::backupDataDir();
1885 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1885 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1886 if ( retval == 0 ) { 1886 if ( retval == 0 ) {
1887 setCaption(i18n("Backup cancelled" )); 1887 setCaption(i18n("Backup cancelled" ));
1888 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1888 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1889 // retval == 0 : backup skipped for today, try again tomorrow 1889 // retval == 0 : backup skipped for today, try again tomorrow
1890 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1890 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1891 } else if ( retval == 1 ){ 1891 } else if ( retval == 1 ){
1892 qDebug("KO: Backup created."); 1892 qDebug("KO: Backup created.");
1893 // backup ok 1893 // backup ok
1894 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1894 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1895 KopiCalendarFile * cal = calendars.first(); 1895 KopiCalendarFile * cal = calendars.first();
1896 cal = calendars.next(); 1896 cal = calendars.next();
1897 while ( cal ) { 1897 while ( cal ) {
1898 if ( !cal->mErrorOnLoad ) { 1898 if ( !cal->mErrorOnLoad ) {
1899 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1899 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1900 } 1900 }
1901 cal = calendars.next(); 1901 cal = calendars.next();
1902 } 1902 }
1903 KOPrefs::instance()->mLastBackupDate = daysTo; 1903 KOPrefs::instance()->mLastBackupDate = daysTo;
1904 setCaption(i18n("Backup succesfully finished" )); 1904 setCaption(i18n("Backup succesfully finished" ));
1905 } else if ( retval == 2 ){ 1905 } else if ( retval == 2 ){
1906 setCaption(i18n("Backup globally disabled" )); 1906 setCaption(i18n("Backup globally disabled" ));
1907 qDebug("KO: Backup globally cancelled."); 1907 qDebug("KO: Backup globally cancelled.");
1908 // backup globally cancelled 1908 // backup globally cancelled
1909 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1909 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1910 } 1910 }
1911 // retval == 3: do nothing, try again later 1911 // retval == 3: do nothing, try again later
1912} 1912}
1913void MainWindow::save() 1913void MainWindow::save()
1914{ 1914{
1915
1915 if ( mView->viewManager()->journalView() ) 1916 if ( mView->viewManager()->journalView() )
1916 mView->viewManager()->journalView()->checkModified(); 1917 mView->viewManager()->journalView()->checkModified();
1917 if ( !mCalendarModifiedFlag ) { 1918 if ( !mCalendarModifiedFlag ) {
1918 qDebug("KO: Calendar not modified. Nothing saved."); 1919 qDebug("KO: Calendar not modified. Nothing saved.");
1919 return; 1920 return;
1920 } 1921 }
1921 if ( mSyncManager->blockSave() ) 1922 if ( mSyncManager->blockSave() )
1922 return; 1923 return;
1923 mSyncManager->setBlockSave(true); 1924 mSyncManager->setBlockSave(true);
1924 if ( mView->checkAllFileVersions() ) { 1925 if ( mView->checkAllFileVersions() ) {
1925 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1926 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1926 QDate reference ( 2000,1,1); 1927 QDate reference ( 2000,1,1);
1927 int daysTo = reference.daysTo ( QDate::currentDate() ); 1928 int daysTo = reference.daysTo ( QDate::currentDate() );
1928 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1929 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1929 backupAllFiles(); 1930 backupAllFiles();
1930 } 1931 }
1931 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1932 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1932 } 1933 }
1933 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1934 QTime neededSaveTime = QDateTime::currentDateTime().time();
1934 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1935 if ( !isMinimized () )
1936 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1935 qDebug("KO: Start saving data to file!"); 1937 qDebug("KO: Start saving data to file!");
1936 mView->saveCalendars(); 1938 mView->saveCalendars();
1937 mCalendarModifiedFlag = false; 1939 mCalendarModifiedFlag = false;
1938 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1940 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1939 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1941 qDebug("KO: Needed %d ms for saving.",msNeeded );
1940 QString savemes; 1942 QString savemes;
1941 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1943 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1942 setCaption(savemes); 1944 if ( !isMinimized () )
1945 setCaption(savemes);
1946 else
1947 qDebug(savemes);
1943 } else 1948 } else
1944 setCaption(i18n("Saving cancelled!")); 1949 setCaption(i18n("Saving cancelled!"));
1945 mSyncManager->setBlockSave( false ); 1950 mSyncManager->setBlockSave( false );
1946} 1951}
1947 1952
1948void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1953void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1949{ 1954{
1950 if ( !e->isAutoRepeat() ) { 1955 if ( !e->isAutoRepeat() ) {
1951 mFlagKeyPressed = false; 1956 mFlagKeyPressed = false;
1952 } 1957 }
1953} 1958}
1954void MainWindow::keyPressEvent ( QKeyEvent * e ) 1959void MainWindow::keyPressEvent ( QKeyEvent * e )
1955{ 1960{
1956 qApp->processEvents(); 1961 qApp->processEvents();
1957 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1962 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1958 e->ignore(); 1963 e->ignore();
1959 // qDebug(" ignore %d",e->isAutoRepeat() ); 1964 // qDebug(" ignore %d",e->isAutoRepeat() );
1960 return; 1965 return;
1961 } 1966 }
1962 if (! e->isAutoRepeat() ) 1967 if (! e->isAutoRepeat() )
1963 mFlagKeyPressed = true; 1968 mFlagKeyPressed = true;
1964 KOPrefs *p = KOPrefs::instance(); 1969 KOPrefs *p = KOPrefs::instance();
1965 bool showSelectedDates = false; 1970 bool showSelectedDates = false;
1966 int size; 1971 int size;
1967 int pro = 0; 1972 int pro = 0;
1968 //qDebug("MainWindow::keyPressEvent "); 1973 //qDebug("MainWindow::keyPressEvent ");
1969 switch ( e->key() ) { 1974 switch ( e->key() ) {
1970 case Qt::Key_Right: 1975 case Qt::Key_Right:
1971 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1976 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1972 mView->goNextMonth(); 1977 mView->goNextMonth();
1973 else 1978 else
1974 mView->goNext(); 1979 mView->goNext();
1975 showSelectedDates = true; 1980 showSelectedDates = true;
1976 break; 1981 break;
1977 case Qt::Key_Left: 1982 case Qt::Key_Left:
1978 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1983 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1979 mView->goPreviousMonth(); 1984 mView->goPreviousMonth();
1980 else 1985 else
1981 mView->goPrevious(); 1986 mView->goPrevious();
1982 showSelectedDates = true; 1987 showSelectedDates = true;
1983 break; 1988 break;
1984 case Qt::Key_Down: 1989 case Qt::Key_Down:
1985 mView->viewManager()->agendaView()->scrollOneHourDown(); 1990 mView->viewManager()->agendaView()->scrollOneHourDown();
1986 break; 1991 break;
1987 case Qt::Key_Up: 1992 case Qt::Key_Up:
1988 mView->viewManager()->agendaView()->scrollOneHourUp(); 1993 mView->viewManager()->agendaView()->scrollOneHourUp();
1989 break; 1994 break;
1990 case Qt::Key_K: 1995 case Qt::Key_K:
1991 mView->viewManager()->showMonthViewWeek(); 1996 mView->viewManager()->showMonthViewWeek();
1992 break; 1997 break;
1993 case Qt::Key_I: 1998 case Qt::Key_I:
1994 mView->showIncidence(); 1999 mView->showIncidence();
1995 break; 2000 break;
1996 case Qt::Key_Delete: 2001 case Qt::Key_Delete:
1997 case Qt::Key_Backspace: 2002 case Qt::Key_Backspace:
1998 mView->deleteIncidence(); 2003 mView->deleteIncidence();
1999 break; 2004 break;
2000 case Qt::Key_D: 2005 case Qt::Key_D:
2001 mView->viewManager()->showDayView(); 2006 mView->viewManager()->showDayView();
2002 showSelectedDates = true; 2007 showSelectedDates = true;
2003 break; 2008 break;
2004 case Qt::Key_O: 2009 case Qt::Key_O:
2005 mView->toggleFilerEnabled( ); 2010 mView->toggleFilerEnabled( );
2006 break; 2011 break;
2007 case Qt::Key_0: 2012 case Qt::Key_0:
2008 case Qt::Key_1: 2013 case Qt::Key_1:
2009 case Qt::Key_2: 2014 case Qt::Key_2:
2010 case Qt::Key_3: 2015 case Qt::Key_3:
2011 case Qt::Key_4: 2016 case Qt::Key_4:
2012 case Qt::Key_5: 2017 case Qt::Key_5:
2013 case Qt::Key_6: 2018 case Qt::Key_6:
2014 case Qt::Key_7: 2019 case Qt::Key_7:
2015 case Qt::Key_8: 2020 case Qt::Key_8:
2016 case Qt::Key_9: 2021 case Qt::Key_9:
2017 pro = e->key()-48; 2022 pro = e->key()-48;
2018 if ( pro == 0 ) 2023 if ( pro == 0 )
2019 pro = 10; 2024 pro = 10;
2020 if ( e->state() == Qt::ControlButton) 2025 if ( e->state() == Qt::ControlButton)
2021 pro += 10; 2026 pro += 10;
2022 break; 2027 break;
2023 case Qt::Key_M: 2028 case Qt::Key_M:
2024 mView->viewManager()->showMonthView(); 2029 mView->viewManager()->showMonthView();
2025 showSelectedDates = true; 2030 showSelectedDates = true;
2026 break; 2031 break;
2027 case Qt::Key_Insert: 2032 case Qt::Key_Insert:
2028 mView->newEvent(); 2033 mView->newEvent();
2029 break; 2034 break;
2030 case Qt::Key_S : 2035 case Qt::Key_S :
2031 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2036 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2032 mView->newSubTodo(); 2037 mView->newSubTodo();
2033 else 2038 else
2034 mView->dialogManager()->showSearchDialog(); 2039 mView->dialogManager()->showSearchDialog();
2035 break; 2040 break;
2036 case Qt::Key_Y : 2041 case Qt::Key_Y :
2037 case Qt::Key_Z : 2042 case Qt::Key_Z :
2038 mView->viewManager()->showWorkWeekView(); 2043 mView->viewManager()->showWorkWeekView();