summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 68e5e5a..9ad0694 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -16,96 +16,97 @@
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 "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64#include <kglobalsettings.h>
64 65
65using namespace KCal; 66using namespace KCal;
66#ifndef _WIN32_ 67#ifndef _WIN32_
67#include <unistd.h> 68#include <unistd.h>
68#else 69#else
69#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 71#include "koimportoldialog.h"
71#endif 72#endif
72#endif 73#endif
73#include "mainwindow.h" 74#include "mainwindow.h"
74 75
75 76
76class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
77{ 78{
78 public: 79 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
81 { 82 {
82 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
86 QLabel *lab; 87 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 90 QHBox* temphb;
90 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
@@ -1756,96 +1757,125 @@ void MainWindow::saveOnClose()
1756 1757
1757 if ( p->mToolBarHorN ) 1758 if ( p->mToolBarHorN )
1758 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1759 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1759 else 1760 else
1760 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1761 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1761 if ( filterToolBar ) { 1762 if ( filterToolBar ) {
1762 if ( p->mToolBarHorF ) 1763 if ( p->mToolBarHorF )
1763 p->mToolBarUpF = filterToolBar->y() > height()/2; 1764 p->mToolBarUpF = filterToolBar->y() > height()/2;
1764 else 1765 else
1765 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1766 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1766 } 1767 }
1767#endif 1768#endif
1768 1769
1769 1770
1770 mView->writeSettings(); 1771 mView->writeSettings();
1771 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1772 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1772 save(); 1773 save();
1773} 1774}
1774void MainWindow::slotModifiedChanged( bool changed ) 1775void MainWindow::slotModifiedChanged( bool changed )
1775{ 1776{
1776 if ( mBlockAtStartup ) 1777 if ( mBlockAtStartup )
1777 return; 1778 return;
1778 1779
1779 int msec; 1780 int msec;
1780 // we store the changes after 1 minute, 1781 // we store the changes after 1 minute,
1781 // and for safety reasons after 10 minutes again 1782 // and for safety reasons after 10 minutes again
1782 if ( !mSyncManager->blockSave() ) 1783 if ( !mSyncManager->blockSave() )
1783 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1784 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1784 else 1785 else
1785 msec = 1000 * 600; 1786 msec = 1000 * 600;
1786 mSaveTimer.start( msec, true ); // 1 minute 1787 mSaveTimer.start( msec, true ); // 1 minute
1787 qDebug("KO: Saving File in %d secs!", msec/1000); 1788 qDebug("KO: Saving File in %d secs!", msec/1000);
1788 mCalendarModifiedFlag = true; 1789 mCalendarModifiedFlag = true;
1789} 1790}
1790void MainWindow::saveStopTimer() 1791void MainWindow::saveStopTimer()
1791{ 1792{
1792 mSaveTimer.stop(); 1793 mSaveTimer.stop();
1793} 1794}
1794void MainWindow::save() 1795void MainWindow::save()
1795{ 1796{
1796 if ( !mCalendarModifiedFlag ) { 1797 if ( !mCalendarModifiedFlag ) {
1797 qDebug("KO: Calendar not modified. Nothing saved."); 1798 qDebug("KO: Calendar not modified. Nothing saved.");
1798 return; 1799 return;
1799 } 1800 }
1800 if ( mSyncManager->blockSave() ) 1801 if ( mSyncManager->blockSave() )
1801 return; 1802 return;
1802 mSyncManager->setBlockSave(true); 1803 mSyncManager->setBlockSave(true);
1803 if ( mView->checkFileVersion( defaultFileName()) ) { 1804 if ( mView->checkFileVersion( defaultFileName()) ) {
1805 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1806 QDate reference ( 2000,1,1);
1807 int daysTo = reference.daysTo ( QDate::currentDate() );
1808 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1809 setCaption(i18n("KO/Pi:Creating backup ... please wait ..." ));
1810 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1811 // we need the file path, the backup dir and the number of bups as param
1812 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1813 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1814 bupDir = KGlobalSettings::backupDataDir();
1815 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );//55;//call backup
1816 if ( retval == 0 ) {
1817 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1818 // retval == 0 : backup skipped for today, try again tomorrow
1819 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1820 } else if ( retval == 1 ){
1821 qDebug("KO: Backup created.");
1822 // backup ok
1823 KOPrefs::instance()->mLastBackupDate = daysTo;
1824
1825 } else if ( retval == 2 ){
1826 qDebug("KO: Backup globally cancelled.");
1827 // backup globally cancelled
1828 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1829 }
1830 // retval == 3: do nothing, try again later
1831 }
1832 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1833 }
1804 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1834 QTime neededSaveTime = QDateTime::currentDateTime().time();
1805 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1835 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1806 qDebug("KO: Start saving data to file!"); 1836 qDebug("KO: Start saving data to file!");
1807 mView->saveCalendar( defaultFileName() ); 1837 mView->saveCalendar( defaultFileName() );
1808 mCalendarModifiedFlag = false; 1838 mCalendarModifiedFlag = false;
1809 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1839 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1810 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1840 qDebug("KO: Needed %d ms for saving.",msNeeded );
1811 QString savemes; 1841 QString savemes;
1812 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1842 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1813 setCaption(savemes); 1843 setCaption(savemes);
1814 } else 1844 } else
1815 setCaption(i18n("Saving cancelled!")); 1845 setCaption(i18n("Saving cancelled!"));
1816 mSyncManager->setBlockSave( false ); 1846 mSyncManager->setBlockSave( false );
1817} 1847}
1818 1848
1819void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1849void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1820{ 1850{
1821 if ( !e->isAutoRepeat() ) { 1851 if ( !e->isAutoRepeat() ) {
1822 mFlagKeyPressed = false; 1852 mFlagKeyPressed = false;
1823 } 1853 }
1824} 1854}
1825void MainWindow::keyPressEvent ( QKeyEvent * e ) 1855void MainWindow::keyPressEvent ( QKeyEvent * e )
1826{ 1856{
1827 qApp->processEvents(); 1857 qApp->processEvents();
1828 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1858 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1829 e->ignore(); 1859 e->ignore();
1830 // qDebug(" ignore %d",e->isAutoRepeat() ); 1860 // qDebug(" ignore %d",e->isAutoRepeat() );
1831 return; 1861 return;
1832 } 1862 }
1833 if (! e->isAutoRepeat() ) 1863 if (! e->isAutoRepeat() )
1834 mFlagKeyPressed = true; 1864 mFlagKeyPressed = true;
1835 KOPrefs *p = KOPrefs::instance(); 1865 KOPrefs *p = KOPrefs::instance();
1836 bool showSelectedDates = false; 1866 bool showSelectedDates = false;
1837 int size; 1867 int size;
1838 int pro = 0; 1868 int pro = 0;
1839 //qDebug("MainWindow::keyPressEvent "); 1869 //qDebug("MainWindow::keyPressEvent ");
1840 switch ( e->key() ) { 1870 switch ( e->key() ) {
1841 case Qt::Key_Right: 1871 case Qt::Key_Right:
1842 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1872 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1843 mView->goNextMonth(); 1873 mView->goNextMonth();
1844 else 1874 else
1845 mView->goNext(); 1875 mView->goNext();
1846 showSelectedDates = true; 1876 showSelectedDates = true;
1847 break; 1877 break;
1848 case Qt::Key_Left: 1878 case Qt::Key_Left:
1849 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1879 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1850 mView->goPreviousMonth(); 1880 mView->goPreviousMonth();
1851 else 1881 else