summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp18
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/mainwindow.cpp19
-rw-r--r--korganizer/mainwindow.h1
4 files changed, 36 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e0380fa..77de94f 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2206,98 +2206,114 @@ void CalendarView::edit_cut()
if (mViewManager->currentView()->isEventView()) {
if ( incidence && incidence->type() == "Event" ) {
anEvent = static_cast<Event *>(incidence);
}
}
if (!anEvent) {
KNotifyClient::beep();
return;
}
DndFactory factory( mCalendar );
factory.cutIncidence(anEvent);
changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
}
void CalendarView::edit_copy()
{
Event *anEvent=0;
Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
if (mViewManager->currentView()->isEventView()) {
if ( incidence && incidence->type() == "Event" ) {
anEvent = static_cast<Event *>(incidence);
}
}
if (!anEvent) {
KNotifyClient::beep();
return;
}
DndFactory factory( mCalendar );
factory.copyIncidence(anEvent);
}
void CalendarView::edit_paste()
{
QDate date = mNavigator->selectedDates().first();
DndFactory factory( mCalendar );
Event *pastedEvent = (Event *)factory.pasteIncidence( date );
changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
}
void CalendarView::edit_options()
{
+ QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
+ emit save();
+ emit saveStopTimer();
mDialogManager->showOptionsDialog();
- //writeSettings();
+ if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
+ emit saveStopTimer();
+ if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
+ i18n("Timezone settings"),i18n("Reload"))) {
+ qDebug("KO: TZ reload cancelled ");
+ return;
+ }
+ qDebug("KO: Timezone change ");
+ openCalendar( MainWindow::defaultFileName() );
+ setModified(true);
+ }
+ else
+ qDebug("KO: No tz change ");
+
}
void CalendarView::slotSelectPickerDate( QDate d)
{
mDateFrame->hide();
if ( mDatePickerMode == 1 ) {
mNavigator->slotDaySelect( d );
} else if ( mDatePickerMode == 2 ) {
if ( mMoveIncidence->type() == "Todo" ) {
Todo * to = (Todo *) mMoveIncidence;
QTime tim;
if ( to->hasDueDate() )
tim = to->dtDue().time();
else {
tim = QTime ( 0,0,0 );
to->setFloats( true );
to->setHasDueDate( true );
}
QDateTime dt ( d,tim );
to->setDtDue( dt );
todoChanged( to );
} else {
if ( mMoveIncidence->doesRecur() ) {
#if 0
// PENDING implement this
Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
mCalendar()->addIncidence( newInc );
if ( mMoveIncidence->type() == "Todo" )
emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
else
emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
mMoveIncidence = newInc;
#endif
}
QTime tim = mMoveIncidence->dtStart().time();
int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
QDateTime dt ( d,tim );
mMoveIncidence->setDtStart( dt );
((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
}
mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
}
}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 6ea8287..8d7ff36 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -72,96 +72,98 @@ using namespace KCal;
/**
This is the main calendar widget. It provides the different vies on t he
calendar data as well as the date navigator. It also handles synchronisation
of the different views and controls the different dialogs like preferences,
event editor, search dialog etc.
@short main calendar view widget
@author Cornelius Schumacher
*/
class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
{
Q_OBJECT
public:
/**
Constructs a new calendar view widget.
@param calendar calendar document
@param parent parent window
@param name Qt internal widget object name
*/
CalendarView( CalendarResources *calendar, QWidget *parent = 0,
const char *name = 0 );
CalendarView( Calendar *calendar, QWidget *parent = 0,
const char *name = 0 );
virtual ~CalendarView();
Calendar *calendar() { return mCalendar; }
KOViewManager *viewManager();
KODialogManager *dialogManager();
QDate startDate();
QDate endDate();
QWidgetStack *viewStack();
QWidget *leftFrame();
NavigatorBar *navigatorBar();
DateNavigator *dateNavigator();
KDateNavigator *dateNavigatorWidget();
void addView(KOrg::BaseView *);
void showView(KOrg::BaseView *);
KOEventViewerDialog* getEventViewerDialog();
Incidence *currentSelection();
signals:
+ void save ();
+ void saveStopTimer ();
void tempDisableBR(bool);
/** This todo has been modified */
void todoModified(Todo *, int);
/** when change is made to options dialog, the topwidget will catch this
* and emit this signal which notifies all widgets which have registered
* for notification to update their settings. */
void configChanged();
/** emitted when the topwidget is closing down, so that any attached
child windows can also close. */
void closingDown();
/** emitted right before we die */
void closed(QWidget *);
/** Emitted when state of modified flag changes */
void modifiedChanged(bool);
void signalmodified();
/** Emitted when state of read-only flag changes */
void readOnlyChanged(bool);
/** Emitted when the unit of navigation changes */
void changeNavStringPrev(const QString &);
void changeNavStringNext(const QString &);
/** Emitted when state of events selection has changed and user is organizer*/
void organizerEventsSelected(bool);
/** Emitted when state of events selection has changed and user is attendee*/
void groupEventsSelected(bool);
/**
Emitted when an incidence gets selected. If the selection is cleared the
signal is emitted with 0 as argument.
*/
void incidenceSelected( Incidence * );
/** Emitted, when a todoitem is selected or deselected. */
void todoSelected( bool );
/**
Emitted, when clipboard content changes. Parameter indicates if paste
is possible or not.
*/
void pasteEnabled(bool);
/** Emitted, when the number of incoming messages has changed. */
void numIncomingChanged(int);
/** Emitted, when the number of outgoing messages has changed. */
void numOutgoingChanged(int);
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 3feb4ab..a2c20a8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -214,96 +214,98 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
qApp->processEvents();
} else {
oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
finfo.setFile( oldFile );
if (finfo.exists() ) {
KMessageBox::information( this, message);
mView->openCalendar( oldFile );
qApp->processEvents();
}
}
mView->saveCalendar( defaultFileName() );
newFile = true;
}
QTime neededSaveTime = QDateTime::currentDateTime().time();
mView->openCalendar( defaultFileName() );
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
qDebug("KO: Calendar loading time: %d ms",msNeeded );
if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
KOPrefs::instance()->setCategoryDefaults();
int count = mView->addCategories();
}
processIncidenceSelection( 0 );
connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
SLOT( processIncidenceSelection( Incidence * ) ) );
connect( mView, SIGNAL( modifiedChanged( bool ) ),
SLOT( slotModifiedChanged( bool ) ) );
connect( mView, SIGNAL( tempDisableBR(bool) ),
SLOT( disableBR(bool) ) );
connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
mView->setModified( false );
mBlockAtStartup = false;
mView->setModified( false );
setCentralWidget( mView );
globalFlagBlockStartup = 0;
mView->show();
delete splash;
if ( newFile )
mView->updateConfig();
// qApp->processEvents();
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
//fillSyncMenu();
connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
+ connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
+ connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
mSyncManager->setDefaultFileName( defaultFileName());
connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
mSyncManager->fillSyncMenu();
mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
if ( showWarning ) {
KMessageBox::information( this,
"You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
qApp->processEvents();
mView->dialogManager()->showSyncOptions();
}
//US listen for result adressed from Ka/Pi
#ifndef DESKTOP_VERSION
connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
#endif
#ifndef DESKTOP_VERSION
infrared = 0;
#endif
mBRdisabled = false;
//toggleBeamReceive();
}
MainWindow::~MainWindow()
{
//qDebug("MainWindow::~MainWindow() ");
//save toolbar location
delete mCalendar;
delete mSyncManager;
#ifndef DESKTOP_VERSION
if ( infrared )
delete infrared;
#endif
}
void MainWindow::disableBR(bool b)
{
#ifndef DESKTOP_VERSION
if ( b ) {
if ( infrared ) {
toggleBeamReceive();
mBRdisabled = true;
@@ -1402,127 +1404,138 @@ void MainWindow::importBday()
{
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
i18n("Import!"), i18n("Cancel"), 0,
0, 1 );
if ( result == 0 ) {
mView->importBday();
}
}
void MainWindow::importQtopia()
{
#ifndef DESKTOP_VERSION
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
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"),
i18n("Import!"), i18n("Cancel"), 0,
0, 1 );
if ( result == 0 ) {
QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
mView->importQtopia( categories, datebook, todolist );
}
#else
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
i18n("Not supported \non desktop!\n"),
i18n("Ok"), i18n("Cancel"), 0,
0, 1 );
#endif
}
void MainWindow::saveOnClose()
{
KOPrefs *p = KOPrefs::instance();
p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
p->mToolBarUp = iconToolBar->x() > width()/2 ||
iconToolBar->y() > height()/2;
mView->writeSettings();
if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
save();
}
void MainWindow::slotModifiedChanged( bool changed )
{
if ( mBlockAtStartup )
return;
+
int msec;
// we store the changes after 1 minute,
// and for safety reasons after 10 minutes again
if ( !mSyncManager->blockSave() )
msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
else
msec = 1000 * 600;
mSaveTimer.start( msec, true ); // 1 minute
qDebug("KO: Saving File in %d secs!", msec/1000);
mCalendarModifiedFlag = true;
}
+void MainWindow::saveStopTimer()
+{
+ mSaveTimer.stop();
+ if (mSaveTimer.isActive() )
+ qDebug("ti active ");
+ else
+ qDebug("KO: Save timer stopped");
+}
void MainWindow::save()
{
+ if ( !mCalendarModifiedFlag ) {
+ qDebug("KO: Calendar not modified. Nothing saved.");
+ return;
+ }
if ( mSyncManager->blockSave() )
return;
mSyncManager->setBlockSave(true);
if ( mView->checkFileVersion( defaultFileName()) ) {
-
QTime neededSaveTime = QDateTime::currentDateTime().time();
setCaption(i18n("KO/Pi:Saving Data to File ..." ));
qDebug("KO: Start saving data to file!");
mView->saveCalendar( defaultFileName() );
-
+ mCalendarModifiedFlag = false;
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
qDebug("KO: Needed %d ms for saving.",msNeeded );
QString savemes;
savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
setCaption(savemes);
} else
setCaption(i18n("Saving cancelled!"));
- mCalendarModifiedFlag = false;
mSyncManager->setBlockSave( false );
}
void MainWindow::keyReleaseEvent ( QKeyEvent * e)
{
if ( !e->isAutoRepeat() ) {
mFlagKeyPressed = false;
}
}
void MainWindow::keyPressEvent ( QKeyEvent * e )
{
qApp->processEvents();
if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
e->ignore();
// qDebug(" ignore %d",e->isAutoRepeat() );
return;
}
if (! e->isAutoRepeat() )
mFlagKeyPressed = true;
KOPrefs *p = KOPrefs::instance();
bool showSelectedDates = false;
int size;
int pro = 0;
//qDebug("MainWindow::keyPressEvent ");
switch ( e->key() ) {
case Qt::Key_Right:
if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
mView->goNextMonth();
else
mView->goNext();
showSelectedDates = true;
break;
case Qt::Key_Left:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
mView->goPreviousMonth();
else
mView->goPrevious();
showSelectedDates = true;
break;
case Qt::Key_Down:
mView->viewManager()->agendaView()->scrollOneHourDown();
break;
case Qt::Key_Up:
mView->viewManager()->agendaView()->scrollOneHourUp();
break;
case Qt::Key_I:
mView->showIncidence();
break;
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 6de0543..8dd55ac 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -27,96 +27,97 @@ class QPEToolBar;
namespace KCal {
class CalendarLocal;
}
using namespace KCal;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
~MainWindow();
bool beamReceiveEnabled();
static QString defaultFileName();
static QString syncFileName();
static QString resourcePath();
public slots:
virtual void showMaximized ();
void configureAgenda( int );
void recieve( const QCString& msg, const QByteArray& data );
protected slots:
void setCaptionToDates();
void about();
void licence();
void faq();
void usertrans();
void features();
void synchowto();
void kdesynchowto();
void multisynchowto();
void whatsNew();
void keyBindings();
void aboutAutoSaving();;
void aboutKnownBugs();
void processIncidenceSelection( Incidence * );
void importQtopia();
void importBday();
void importOL();
void importIcal();
void importFile( QString, bool );
void quickImportIcal();
void slotModifiedChanged( bool );
void save();
+ void saveStopTimer();
void configureToolBar( int );
void printSel();
void printCal();
void saveCalendar();
void loadCalendar();
void exportVCalendar();
void fillFilterMenu();
void selectFilter( int );
void exportToPhone( int );
void toggleBeamReceive();
void disableBR(bool);
private slots:
void showConfigureAgenda();
void getFile( bool );
void syncFileRequest();
protected:
void displayText( QString, QString);
void enableIncidenceActions( bool );
private:
bool mBRdisabled;
#ifndef DESKTOP_VERSION
QCopChannel* infrared;
#endif
QAction* brAction;
KSyncManager* mSyncManager;
bool mClosed;
void saveOnClose();
bool mFlagKeyPressed;
bool mBlockAtStartup;
QPEToolBar *iconToolBar;
void initActions();
void setDefaultPreferences();
void keyPressEvent ( QKeyEvent * ) ;
void keyReleaseEvent ( QKeyEvent * ) ;
QPopupMenu *configureToolBarMenu;
QPopupMenu *selectFilterMenu;
QPopupMenu *configureAgendaMenu, *syncMenu;
CalendarLocal *mCalendar;
CalendarView *mView;
QAction *mNewSubTodoAction;
QAction *mShowAction;
QAction *mEditAction;
QAction *mDeleteAction;
QAction *mCloneAction;