summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-30 06:57:43 (UTC)
committer zautrix <zautrix>2005-06-30 06:57:43 (UTC)
commit0bcf4379652b763423d0c1843cb8ab8945b798bd (patch) (unidiff)
tree3a0d6457c8457204423c1aa0c9946de479f79881
parent0e4ec4bb2a13a89d3d6145ea076a5734481cb252 (diff)
downloadkdepimpi-0bcf4379652b763423d0c1843cb8ab8945b798bd.zip
kdepimpi-0bcf4379652b763423d0c1843cb8ab8945b798bd.tar.gz
kdepimpi-0bcf4379652b763423d0c1843cb8ab8945b798bd.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kojournalview.cpp1
-rw-r--r--korganizer/mainwindow.cpp6
2 files changed, 2 insertions, 5 deletions
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 51ae0a0..7a96aa5 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -27,193 +27,192 @@
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qscrollview.h> 28#include <qscrollview.h>
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30#include <qhbox.h> 30#include <qhbox.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qapplication.h> 34#include <qapplication.h>
35 35
36#include <klocale.h> 36#include <klocale.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include "koprefs.h" 38#include "koprefs.h"
39#include <kglobal.h> 39#include <kglobal.h>
40 40
41#include <libkcal/calendar.h> 41#include <libkcal/calendar.h>
42 42
43#include "journalentry.h" 43#include "journalentry.h"
44 44
45#include "kojournalview.h" 45#include "kojournalview.h"
46using namespace KOrg; 46using namespace KOrg;
47 47
48KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 48KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
49 const char *name) 49 const char *name)
50 : KOrg::BaseView(calendar, parent, name) 50 : KOrg::BaseView(calendar, parent, name)
51{ 51{
52 mCalendar = calendar; 52 mCalendar = calendar;
53 QScrollView * sv = new QScrollView( this ); 53 QScrollView * sv = new QScrollView( this );
54 QHBoxLayout * hbl = new QHBoxLayout( this ); 54 QHBoxLayout * hbl = new QHBoxLayout( this );
55 hbl->addWidget( sv ); 55 hbl->addWidget( sv );
56 parWid = new QWidget( sv->viewport() ); 56 parWid = new QWidget( sv->viewport() );
57 sv->addChild(parWid); 57 sv->addChild(parWid);
58 sv->setResizePolicy( QScrollView:: AutoOneFit ); 58 sv->setResizePolicy( QScrollView:: AutoOneFit );
59 mTopLayout = new QVBoxLayout(parWid); 59 mTopLayout = new QVBoxLayout(parWid);
60 QHBox * vb = new QHBox ( parWid ); 60 QHBox * vb = new QHBox ( parWid );
61 QPushButton * newJournal = new QPushButton( vb ); 61 QPushButton * newJournal = new QPushButton( vb );
62 QPixmap icon; 62 QPixmap icon;
63 if ( QApplication::desktop()->width() < 321 ) 63 if ( QApplication::desktop()->width() < 321 )
64 icon = SmallIcon("ko16old"); 64 icon = SmallIcon("ko16old");
65 else 65 else
66 icon = SmallIcon("ko24old"); 66 icon = SmallIcon("ko24old");
67 newJournal->setPixmap (icon ) ; 67 newJournal->setPixmap (icon ) ;
68 int size = newJournal->sizeHint().height(); 68 int size = newJournal->sizeHint().height();
69 newJournal->setFixedSize( size, size ); 69 newJournal->setFixedSize( size, size );
70 mDateLabel = new QLabel ( vb ); 70 mDateLabel = new QLabel ( vb );
71 mTopLayout->addWidget( vb ); 71 mTopLayout->addWidget( vb );
72 mDateLabel->setMargin(1); 72 mDateLabel->setMargin(1);
73 mDateLabel->setAlignment(AlignCenter); 73 mDateLabel->setAlignment(AlignCenter);
74 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); 74 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) );
75 getNewEntry(); 75 getNewEntry();
76} 76}
77 77
78KOJournalView::~KOJournalView() 78KOJournalView::~KOJournalView()
79{ 79{
80} 80}
81 81
82int KOJournalView::currentDateCount() 82int KOJournalView::currentDateCount()
83{ 83{
84 return 0; 84 return 0;
85} 85}
86JournalEntry* KOJournalView::getNewEntry() 86JournalEntry* KOJournalView::getNewEntry()
87{ 87{
88 JournalEntry* Entry = new JournalEntry(mCalendar,parWid); 88 JournalEntry* Entry = new JournalEntry(mCalendar,parWid);
89 jEntries.append( Entry ); 89 jEntries.append( Entry );
90 mTopLayout->addWidget(Entry); 90 mTopLayout->addWidget(Entry);
91 Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); 91 Entry->setFont ( KOPrefs::instance()->mJornalViewFont );
92 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; 92 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
93 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; 93 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ;
94 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; 94 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ;
95 return Entry; 95 return Entry;
96} 96}
97 97
98QPtrList<Incidence> KOJournalView::selectedIncidences() 98QPtrList<Incidence> KOJournalView::selectedIncidences()
99{ 99{
100 QPtrList<Incidence> eventList; 100 QPtrList<Incidence> eventList;
101 101
102 return eventList; 102 return eventList;
103} 103}
104void KOJournalView::updateConfig() 104void KOJournalView::updateConfig()
105{ 105{
106 JournalEntry* mEntry = jEntries.first(); 106 JournalEntry* mEntry = jEntries.first();
107 while ( mEntry ) { 107 while ( mEntry ) {
108 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 108 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
109 mEntry = jEntries.next(); 109 mEntry = jEntries.next();
110 } 110 }
111} 111}
112void KOJournalView::updateView() 112void KOJournalView::updateView()
113{ 113{
114 JournalEntry* mEntry = jEntries.first(); 114 JournalEntry* mEntry = jEntries.first();
115 while ( mEntry ) { 115 while ( mEntry ) {
116 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 116 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
117 mEntry = jEntries.next(); 117 mEntry = jEntries.next();
118 } 118 }
119 showDates( mDate, QDate() ); 119 showDates( mDate, QDate() );
120} 120}
121void KOJournalView::checkModified() 121void KOJournalView::checkModified()
122{ 122{
123 qDebug("checkmod ");
124 flushView(); 123 flushView();
125} 124}
126void KOJournalView::flushView() 125void KOJournalView::flushView()
127{ 126{
128 static bool ff = false; 127 static bool ff = false;
129 if ( ff ) return; 128 if ( ff ) return;
130 ff = true; 129 ff = true;
131 JournalEntry* mEntry = jEntries.first(); 130 JournalEntry* mEntry = jEntries.first();
132 while ( mEntry ) { 131 while ( mEntry ) {
133 mEntry->flushEntry(); 132 mEntry->flushEntry();
134 mEntry = jEntries.next(); 133 mEntry = jEntries.next();
135 } 134 }
136 ff = false; 135 ff = false;
137} 136}
138 137
139void KOJournalView::clearList() 138void KOJournalView::clearList()
140{ 139{
141 JournalEntry* mEntry = jEntries.first(); 140 JournalEntry* mEntry = jEntries.first();
142 while ( mEntry ) { 141 while ( mEntry ) {
143 mEntry->clear(); 142 mEntry->clear();
144 mEntry = jEntries.next(); 143 mEntry = jEntries.next();
145 } 144 }
146} 145}
147void KOJournalView::newJournal() 146void KOJournalView::newJournal()
148{ 147{
149 //qDebug(" KOJournalView::newJournal()"); 148 //qDebug(" KOJournalView::newJournal()");
150 flushView(); 149 flushView();
151 Journal* mJournal = new Journal; 150 Journal* mJournal = new Journal;
152 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 151 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
153 mCalendar->addJournal(mJournal); 152 mCalendar->addJournal(mJournal);
154 showDates( mDate, QDate() ); 153 showDates( mDate, QDate() );
155} 154}
156 155
157void KOJournalView::showOnly ( Journal* j ) 156void KOJournalView::showOnly ( Journal* j )
158{ 157{
159 //qDebug("showOnly %x ", j); 158 //qDebug("showOnly %x ", j);
160 flushView(); 159 flushView();
161 if ( j == 0 ) { 160 if ( j == 0 ) {
162 showDates( mDate, QDate() ); 161 showDates( mDate, QDate() );
163 return; 162 return;
164 } 163 }
165 QPtrList<Journal> jl; 164 QPtrList<Journal> jl;
166 jl.append ( j ); 165 jl.append ( j );
167 showList( jl ); 166 showList( jl );
168 JournalEntry* mEntry = jEntries.first(); 167 JournalEntry* mEntry = jEntries.first();
169 mEntry->setShowOnly(); 168 mEntry->setShowOnly();
170} 169}
171void KOJournalView::showList(QPtrList<Journal> jl) 170void KOJournalView::showList(QPtrList<Journal> jl)
172{ 171{
173 //qDebug("KOJournalView::showList %d",jl.count() ); 172 //qDebug("KOJournalView::showList %d",jl.count() );
174 JournalEntry* mEntry = jEntries.first(); 173 JournalEntry* mEntry = jEntries.first();
175 JournalEntry* firstEntry = mEntry; 174 JournalEntry* firstEntry = mEntry;
176 int count = jl.count(); 175 int count = jl.count();
177 int iii = 0; 176 int iii = 0;
178 while ( iii < count ) { 177 while ( iii < count ) {
179 if ( !mEntry ) { 178 if ( !mEntry ) {
180 mEntry = getNewEntry(); 179 mEntry = getNewEntry();
181 mEntry->show(); 180 mEntry->show();
182 mEntry->setVisibleMode( true ); 181 mEntry->setVisibleMode( true );
183 mEntry->setDate(mDate); 182 mEntry->setDate(mDate);
184 mEntry->setJournal(jl.at(iii)); 183 mEntry->setJournal(jl.at(iii));
185 mEntry = 0; 184 mEntry = 0;
186 } else { 185 } else {
187 mEntry->setDate(mDate); 186 mEntry->setDate(mDate);
188 mEntry->setJournal(jl.at(iii)); 187 mEntry->setJournal(jl.at(iii));
189 mEntry->show(); 188 mEntry->show();
190 mEntry->setVisibleMode( true ); 189 mEntry->setVisibleMode( true );
191 mEntry = jEntries.next(); 190 mEntry = jEntries.next();
192 } 191 }
193 ++iii; 192 ++iii;
194 } 193 }
195 while ( mEntry ) { 194 while ( mEntry ) {
196 mEntry->setDate(mDate); 195 mEntry->setDate(mDate);
197 mEntry->clear(); 196 mEntry->clear();
198 if ( mEntry != firstEntry ) { 197 if ( mEntry != firstEntry ) {
199 mEntry->hide(); 198 mEntry->hide();
200 mEntry->setVisibleMode( false ); 199 mEntry->setVisibleMode( false );
201 } 200 }
202 else { 201 else {
203 mEntry->setVisibleMode( true ); 202 mEntry->setVisibleMode( true );
204 mEntry->show(); 203 mEntry->show();
205 } 204 }
206 mEntry = jEntries.next(); 205 mEntry = jEntries.next();
207 } 206 }
208} 207}
209 208
210void KOJournalView::showDates(const QDate &start, const QDate &) 209void KOJournalView::showDates(const QDate &start, const QDate &)
211{ 210{
212 mDate = start; 211 mDate = start;
213 mDateLabel-> setText(KGlobal::locale()->formatDate(mDate)); 212 mDateLabel-> setText(KGlobal::locale()->formatDate(mDate));
214 QPtrList<Journal> jl = calendar()->journals4Date( start ); 213 QPtrList<Journal> jl = calendar()->journals4Date( start );
215 showList( jl ); 214 showList( jl );
216} 215}
217 216
218void KOJournalView::showEvents(QPtrList<Event>) 217void KOJournalView::showEvents(QPtrList<Event>)
219{ 218{
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index fb6d6ec..23537a6 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1742,196 +1742,194 @@ void MainWindow::importBday()
1742 i18n("Import!"), i18n("Cancel"), 0, 1742 i18n("Import!"), i18n("Cancel"), 0,
1743 0, 1 ); 1743 0, 1 );
1744 if ( result == 0 ) { 1744 if ( result == 0 ) {
1745 mView->importBday(); 1745 mView->importBday();
1746 1746
1747 } 1747 }
1748 1748
1749 1749
1750} 1750}
1751void MainWindow::importQtopia() 1751void MainWindow::importQtopia()
1752{ 1752{
1753 //#ifndef DESKTOP_VERSION 1753 //#ifndef DESKTOP_VERSION
1754 QString mess = 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"); 1754 QString mess = 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");
1755#ifdef DESKTOP_VERSION 1755#ifdef DESKTOP_VERSION
1756 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1756 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1757#endif 1757#endif
1758 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1758 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1759 i18n("Import!"), i18n("Cancel"), 0, 1759 i18n("Import!"), i18n("Cancel"), 0,
1760 0, 1 ); 1760 0, 1 );
1761 if ( result == 0 ) { 1761 if ( result == 0 ) {
1762#ifndef DESKTOP_VERSION 1762#ifndef DESKTOP_VERSION
1763 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1763 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1764 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1764 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1765 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1765 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1766#else 1766#else
1767 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1767 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1768 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1768 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1769 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1769 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1770#endif 1770#endif
1771 mView->importQtopia( categories, datebook, todolist ); 1771 mView->importQtopia( categories, datebook, todolist );
1772 } 1772 }
1773 mView->calendar()->reInitAlarmSettings(); 1773 mView->calendar()->reInitAlarmSettings();
1774#if 0 1774#if 0
1775 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1775 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1776 i18n("Not supported \non desktop!\n"), 1776 i18n("Not supported \non desktop!\n"),
1777 i18n("Ok"), i18n("Cancel"), 0, 1777 i18n("Ok"), i18n("Cancel"), 0,
1778 0, 1 ); 1778 0, 1 );
1779 1779
1780#endif 1780#endif
1781} 1781}
1782 1782
1783void MainWindow::saveOnClose() 1783void MainWindow::saveOnClose()
1784{ 1784{
1785 KOPrefs *p = KOPrefs::instance(); 1785 KOPrefs *p = KOPrefs::instance();
1786 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1786 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1787 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1787 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1788 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1788 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1789 if ( filterToolBar ) { 1789 if ( filterToolBar ) {
1790 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1790 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1791 } 1791 }
1792#ifdef DESKTOP_VERSION 1792#ifdef DESKTOP_VERSION
1793 1793
1794 QPoint myP; 1794 QPoint myP;
1795 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1795 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1796 if ( p->mToolBarHor ) 1796 if ( p->mToolBarHor )
1797 p->mToolBarUp = myP.y() > height()/2; 1797 p->mToolBarUp = myP.y() > height()/2;
1798 else 1798 else
1799 p->mToolBarUp = myP.x() > width()/2; 1799 p->mToolBarUp = myP.x() > width()/2;
1800 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1800 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1801 if ( p->mToolBarHorV ) 1801 if ( p->mToolBarHorV )
1802 p->mToolBarUpV = myP.y() > height()/2; 1802 p->mToolBarUpV = myP.y() > height()/2;
1803 else 1803 else
1804 p->mToolBarUpV = myP.x() > width()/2 ; 1804 p->mToolBarUpV = myP.x() > width()/2 ;
1805 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1805 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1806 if ( p->mToolBarHorN ) 1806 if ( p->mToolBarHorN )
1807 p->mToolBarUpN = myP.y() > height()/2; 1807 p->mToolBarUpN = myP.y() > height()/2;
1808 else 1808 else
1809 p->mToolBarUpN = myP.x() > width()/2 ; 1809 p->mToolBarUpN = myP.x() > width()/2 ;
1810 if ( filterToolBar ) { 1810 if ( filterToolBar ) {
1811 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1811 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1812 if ( p->mToolBarHorF ) 1812 if ( p->mToolBarHorF )
1813 p->mToolBarUpF = myP.y() > height()/2; 1813 p->mToolBarUpF = myP.y() > height()/2;
1814 else 1814 else
1815 p->mToolBarUpF = myP.x() > width()/2 ; 1815 p->mToolBarUpF = myP.x() > width()/2 ;
1816 } 1816 }
1817#else 1817#else
1818 if ( p->mToolBarHor ) 1818 if ( p->mToolBarHor )
1819 p->mToolBarUp = iconToolBar->y() > height()/2; 1819 p->mToolBarUp = iconToolBar->y() > height()/2;
1820 else 1820 else
1821 p->mToolBarUp = iconToolBar->x() > width()/2; 1821 p->mToolBarUp = iconToolBar->x() > width()/2;
1822 if ( p->mToolBarHorV ) 1822 if ( p->mToolBarHorV )
1823 p->mToolBarUpV = viewToolBar->y() > height()/2; 1823 p->mToolBarUpV = viewToolBar->y() > height()/2;
1824 else 1824 else
1825 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1825 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1826 1826
1827 if ( p->mToolBarHorN ) 1827 if ( p->mToolBarHorN )
1828 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1828 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1829 else 1829 else
1830 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1830 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1831 if ( filterToolBar ) { 1831 if ( filterToolBar ) {
1832 if ( p->mToolBarHorF ) 1832 if ( p->mToolBarHorF )
1833 p->mToolBarUpF = filterToolBar->y() > height()/2; 1833 p->mToolBarUpF = filterToolBar->y() > height()/2;
1834 else 1834 else
1835 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1835 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1836 } 1836 }
1837#endif 1837#endif
1838 if ( mView->viewManager()->journalView() ) 1838
1839 mView->viewManager()->journalView()->checkModified(); 1839 save();
1840 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1841 save();
1842 mView->writeSettings(); 1840 mView->writeSettings();
1843} 1841}
1844void MainWindow::slotModifiedChanged( bool changed ) 1842void MainWindow::slotModifiedChanged( bool changed )
1845{ 1843{
1846 if ( mBlockAtStartup ) 1844 if ( mBlockAtStartup )
1847 return; 1845 return;
1848 1846
1849 int msec; 1847 int msec;
1850 // we store the changes after 1 minute, 1848 // we store the changes after 1 minute,
1851 // and for safety reasons after 10 minutes again 1849 // and for safety reasons after 10 minutes again
1852 if ( !mSyncManager->blockSave() ) 1850 if ( !mSyncManager->blockSave() )
1853 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1851 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1854 else 1852 else
1855 msec = 1000 * 600; 1853 msec = 1000 * 600;
1856 mSaveTimer.start( msec, true ); // 1 minute 1854 mSaveTimer.start( msec, true ); // 1 minute
1857 qDebug("KO: Saving File in %d secs!", msec/1000); 1855 qDebug("KO: Saving File in %d secs!", msec/1000);
1858 mCalendarModifiedFlag = true; 1856 mCalendarModifiedFlag = true;
1859} 1857}
1860void MainWindow::saveStopTimer() 1858void MainWindow::saveStopTimer()
1861{ 1859{
1862 mSaveTimer.stop(); 1860 mSaveTimer.stop();
1863} 1861}
1864void MainWindow::backupAllFiles() 1862void MainWindow::backupAllFiles()
1865{ 1863{
1866 QDate reference ( 2000,1,1); 1864 QDate reference ( 2000,1,1);
1867 int daysTo = reference.daysTo ( QDate::currentDate() ); 1865 int daysTo = reference.daysTo ( QDate::currentDate() );
1868 setCaption(i18n("Creating backup ... please wait ..." )); 1866 setCaption(i18n("Creating backup ... please wait ..." ));
1869 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1867 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1870 // we need the file path, the backup dir and the number of bups as param 1868 // we need the file path, the backup dir and the number of bups as param
1871 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1869 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1872 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1870 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1873 bupDir = KGlobalSettings::backupDataDir(); 1871 bupDir = KGlobalSettings::backupDataDir();
1874 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1872 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1875 if ( retval == 0 ) { 1873 if ( retval == 0 ) {
1876 setCaption(i18n("Backup cancelled" )); 1874 setCaption(i18n("Backup cancelled" ));
1877 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1875 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1878 // retval == 0 : backup skipped for today, try again tomorrow 1876 // retval == 0 : backup skipped for today, try again tomorrow
1879 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1877 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1880 } else if ( retval == 1 ){ 1878 } else if ( retval == 1 ){
1881 qDebug("KO: Backup created."); 1879 qDebug("KO: Backup created.");
1882 // backup ok 1880 // backup ok
1883 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1881 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1884 KopiCalendarFile * cal = calendars.first(); 1882 KopiCalendarFile * cal = calendars.first();
1885 cal = calendars.next(); 1883 cal = calendars.next();
1886 while ( cal ) { 1884 while ( cal ) {
1887 if ( !cal->mErrorOnLoad ) { 1885 if ( !cal->mErrorOnLoad ) {
1888 int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1886 int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1889 } 1887 }
1890 cal = calendars.next(); 1888 cal = calendars.next();
1891 } 1889 }
1892 KOPrefs::instance()->mLastBackupDate = daysTo; 1890 KOPrefs::instance()->mLastBackupDate = daysTo;
1893 setCaption(i18n("Backup succesfully finished" )); 1891 setCaption(i18n("Backup succesfully finished" ));
1894 } else if ( retval == 2 ){ 1892 } else if ( retval == 2 ){
1895 setCaption(i18n("Backup globally disabled" )); 1893 setCaption(i18n("Backup globally disabled" ));
1896 qDebug("KO: Backup globally cancelled."); 1894 qDebug("KO: Backup globally cancelled.");
1897 // backup globally cancelled 1895 // backup globally cancelled
1898 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1896 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1899 } 1897 }
1900 // retval == 3: do nothing, try again later 1898 // retval == 3: do nothing, try again later
1901} 1899}
1902void MainWindow::save() 1900void MainWindow::save()
1903{ 1901{
1904 if ( mView->viewManager()->journalView() ) 1902 if ( mView->viewManager()->journalView() )
1905 mView->viewManager()->journalView()->checkModified(); 1903 mView->viewManager()->journalView()->checkModified();
1906 if ( !mCalendarModifiedFlag ) { 1904 if ( !mCalendarModifiedFlag ) {
1907 qDebug("KO: Calendar not modified. Nothing saved."); 1905 qDebug("KO: Calendar not modified. Nothing saved.");
1908 return; 1906 return;
1909 } 1907 }
1910 if ( mSyncManager->blockSave() ) 1908 if ( mSyncManager->blockSave() )
1911 return; 1909 return;
1912 mSyncManager->setBlockSave(true); 1910 mSyncManager->setBlockSave(true);
1913 if ( mView->checkAllFileVersions() ) { 1911 if ( mView->checkAllFileVersions() ) {
1914 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1912 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1915 QDate reference ( 2000,1,1); 1913 QDate reference ( 2000,1,1);
1916 int daysTo = reference.daysTo ( QDate::currentDate() ); 1914 int daysTo = reference.daysTo ( QDate::currentDate() );
1917 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1915 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1918 backupAllFiles(); 1916 backupAllFiles();
1919 } 1917 }
1920 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1918 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1921 } 1919 }
1922 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1920 QTime neededSaveTime = QDateTime::currentDateTime().time();
1923 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1921 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1924 qDebug("KO: Start saving data to file!"); 1922 qDebug("KO: Start saving data to file!");
1925 mView->saveCalendars(); 1923 mView->saveCalendars();
1926 mCalendarModifiedFlag = false; 1924 mCalendarModifiedFlag = false;
1927 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1925 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1928 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1926 qDebug("KO: Needed %d ms for saving.",msNeeded );
1929 QString savemes; 1927 QString savemes;
1930 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1928 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1931 setCaption(savemes); 1929 setCaption(savemes);
1932 } else 1930 } else
1933 setCaption(i18n("Saving cancelled!")); 1931 setCaption(i18n("Saving cancelled!"));
1934 mSyncManager->setBlockSave( false ); 1932 mSyncManager->setBlockSave( false );
1935} 1933}
1936 1934
1937void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1935void MainWindow::keyReleaseEvent ( QKeyEvent * e)