Index: trunk/kdepim/korganizer/outgoingdialog.cpp =================================================================== --- trunk/kdepim/korganizer/outgoingdialog.cpp (revision 123089) +++ trunk/kdepim/korganizer/outgoingdialog.cpp (revision 123090) @@ -1,117 +1,165 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // $Id$ #include +#include +#include + #include //#include #include #ifndef KORG_NOMAIL #include "mailscheduler.h" #endif #include "koprefs.h" #include "outgoingdialog.h" +#include "koeventviewerdialog.h" ScheduleItemOut::ScheduleItemOut(QListView *parent,Event *ev, Scheduler::Method method, const QString &recipients) : QListViewItem(parent) { mEvent = ev; mMethod = method; mRecipients = recipients; - + setText(0,ev->summary()); - setText(1,Scheduler::methodName(mMethod)); + setText(1,ev->dtStartDateStr()); + if (ev->doesFloat()) { + setText(2,"no time"); + setText(4,"no time"); + } + else { + setText(2,ev->dtStartTimeStr()); + if (ev->hasDuration()) { + setText(4,ev->dtEndTimeStr()); + } + else { + setText(4,"no time"); + } + } + if (ev->hasEndDate()) { + setText(3,ev->dtEndDateStr()); + } + else { + setText(3,""); + } + setText(5,Scheduler::methodName(mMethod)); if (mMethod == Scheduler::Publish) { if (!recipients.isEmpty()) - setText(2,mRecipients); + setText(6,mRecipients); } } OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent, const char* name,bool modal, WFlags fl) : OutgoingDialog_base(parent,name,modal,fl) { mCalendar = calendar; - + if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) { kdDebug() << "--- Dummy" << endl; mScheduler = new DummyScheduler(mCalendar); } else { #ifndef KORG_NOMAIL kdDebug() << "--- Mailer" << endl; mScheduler = new MailScheduler(mCalendar); #else mScheduler = new DummyScheduler(mCalendar); #endif } + mMessageListView->setColumnAlignment(1,AlignHCenter); + mMessageListView->setColumnAlignment(2,AlignHCenter); + mMessageListView->setColumnAlignment(3,AlignHCenter); + mMessageListView->setColumnAlignment(4,AlignHCenter); + QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), + this,SLOT(showEvent(QListViewItem *))); } OutgoingDialog::~OutgoingDialog() { } bool OutgoingDialog::addMessage(Event *incidence,Scheduler::Method method) { if (method == Scheduler::Publish) return false; - new ScheduleItemOut(mMessageListView,incidence,method); - - emit numMessagesChanged(mMessageListView->childCount()); - + if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { + new ScheduleItemOut(mMessageListView,incidence,method); + emit numMessagesChanged(mMessageListView->childCount()); + } + else { + mScheduler->performTransaction(incidence,method); + } return true; } bool OutgoingDialog::addMessage(Event *incidence,Scheduler::Method method, const QString &recipients) { if (method != Scheduler::Publish) return false; - - new ScheduleItemOut(mMessageListView,incidence,method,recipients); - - emit numMessagesChanged(mMessageListView->childCount()); + if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { + new ScheduleItemOut(mMessageListView,incidence,method,recipients); + emit numMessagesChanged(mMessageListView->childCount()); + } + else { + mScheduler->publish(incidence,recipients); + } return true; } void OutgoingDialog::send() { ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild()); while(item) { bool success; if (item->method() == Scheduler::Publish) { success = mScheduler->publish(item->event(),item->recipients()); } else { success = mScheduler->performTransaction(item->event(),item->method()); } ScheduleItemOut *oldItem = item; item = (ScheduleItemOut *)(item->nextSibling()); if (success) delete oldItem; } emit numMessagesChanged(mMessageListView->childCount()); } +void OutgoingDialog::showEvent(QListViewItem *item) +{ + Event *event = ((ScheduleItemOut *)item)->event(); + //ScheduleItemOut *so = (ScheduleItemOut *)item; + //Event *event; + if (event) { + KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); + eventViewer->setEvent(event); + eventViewer->show(); + } +} + #include "outgoingdialog.moc" Index: trunk/kdepim/korganizer/incomingdialog.cpp =================================================================== --- trunk/kdepim/korganizer/incomingdialog.cpp (revision 123089) +++ trunk/kdepim/korganizer/incomingdialog.cpp (revision 123090) @@ -1,137 +1,206 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // $Id$ #include +//#include +#include +#include #include #include +#include #include #ifndef KORG_NOMAIL #include "mailscheduler.h" #else #include #endif #include "incomingdialog.h" +#include "koeventviewerdialog.h" + ScheduleItemIn::ScheduleItemIn(QListView *parent,Incidence *ev, Scheduler::Method method,ScheduleMessage::Status status) : QListViewItem(parent) { mEvent = ev; mMethod = method; mStatus = status; - - setText(0,ev->summary()); - setText(1,Scheduler::methodName(mMethod)); - setText(2,ScheduleMessage::statusName(status)); + setText(6,Scheduler::methodName(mMethod)+" "); + setText(7,ScheduleMessage::statusName(status)); +} + + +/* Visitor */ +ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) +{ + mItem = item; +} + +ScheduleItemVisitor::~ScheduleItemVisitor() +{ +} + +bool ScheduleItemVisitor::visit(Event *e) +{ + mItem->setText(0,e->summary()); + mItem->setText(1,e->dtStartDateStr()); + if (e->doesFloat()) { + mItem->setText(2,"no time "); + mItem->setText(4,"no time "); + } + else { + mItem->setText(2,e->dtStartTimeStr()); + mItem->setText(4,e->dtEndTimeStr()); + } + if (e->hasEndDate()) { + mItem->setText(3,e->dtEndDateStr()); + } + else { + mItem->setText(3,""); + } + mItem->setText(5,e->organizer()+" "); + + return true; +} + +bool ScheduleItemVisitor::visit(Todo *t) +{ + return false; +} + +bool ScheduleItemVisitor::visit(Journal *) +{ + return false; } -/* - * Constructs a IncomingDialog which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' +/* + * Constructs a IncomingDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ IncomingDialog::IncomingDialog(Calendar *calendar,QWidget* parent, const char* name,bool modal,WFlags fl) : IncomingDialog_base(parent,name,modal,fl) { mCalendar = calendar; #ifndef KORG_NOMAIL mScheduler = new MailScheduler(mCalendar); + retrieve(); #else mScheduler = new DummyScheduler(mCalendar); #endif + mMessageListView->setColumnAlignment(1,AlignHCenter); + mMessageListView->setColumnAlignment(2,AlignHCenter); + mMessageListView->setColumnAlignment(3,AlignHCenter); + mMessageListView->setColumnAlignment(4,AlignHCenter); + QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), + this,SLOT(showEvent(QListViewItem *))); } -/* +/* * Destroys the object and frees any allocated resources */ IncomingDialog::~IncomingDialog() { // no need to delete child widgets, Qt does it all for us } void IncomingDialog::retrieve() { QPtrList messages = mScheduler->retrieveTransactions(); ScheduleMessage *message; for(message = messages.first();message;message = messages.next()) { Incidence *event = message->event(); Scheduler::Method method = (Scheduler::Method)message->method(); ScheduleMessage::Status status = message->status(); - + kdDebug() << "IncomingDialog::retrieve(): summary: " << event->summary() << " method: " << Scheduler::methodName(method) << endl; - new ScheduleItemIn(mMessageListView,event,method,status); + ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,event,method,status); + ScheduleItemVisitor v(item); + if (event->accept(v)) return; + else delete item; } emit numMessagesChanged(mMessageListView->childCount()); } void IncomingDialog::acceptAllMessages() { bool success = false; - + ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); while(item) { ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); if (acceptMessage(item)) success = true; item = nextitem; } - + if (success) emit calendarUpdated(); } void IncomingDialog::acceptMessage() { ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); if (item) { if (acceptMessage(item)) emit calendarUpdated(); } } bool IncomingDialog::acceptMessage(ScheduleItemIn *item) { if (mScheduler->acceptTransaction(item->event(),item->status())) { delete item; emit numMessagesChanged(mMessageListView->childCount()); return true; } else { kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl; return false; } } void IncomingDialog::rejectMessage() { ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); if (item) { delete item; emit numMessagesChanged(mMessageListView->childCount()); } } + +void IncomingDialog::showEvent(QListViewItem *item) +{ + Event *event = dynamic_cast(((ScheduleItemIn *)item)->event()); + if (event) { + KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); + eventViewer->setEvent(event); + eventViewer->show(); + } +} + #include "incomingdialog.moc" Index: trunk/kdepim/korganizer/mailscheduler.h =================================================================== --- trunk/kdepim/korganizer/mailscheduler.h (revision 123089) +++ trunk/kdepim/korganizer/mailscheduler.h (revision 123090) @@ -1,48 +1,56 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef MAILSCHEDULER_H #define MAILSCHEDULER_H // $Id$ // // Mail implementation of iTIP methods // #include +#include +#include #include namespace KCal { /* This class implements the iTIP interface using the email interface specified as Mail. */ class MailScheduler : public IMIPScheduler { public: MailScheduler(Calendar *); virtual ~MailScheduler(); - + bool publish (Event *incidence,const QString &recipients); bool performTransaction(Event *incidence,Method method); QPtrList retrieveTransactions(); + + protected: + bool deleteTransaction(Incidence *incidence); + + private: + QMap mEventMap; }; } #endif Index: trunk/kdepim/korganizer/koprefs.h =================================================================== --- trunk/kdepim/korganizer/koprefs.h (revision 123089) +++ trunk/kdepim/korganizer/koprefs.h (revision 123090) @@ -1,152 +1,154 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOPREFS_H #define _KOPREFS_H // $Id$ #include #include "kprefs.h" class KConfig; class QFont; class QColor; class QStringList; class KOPrefs : public KPrefs { public: enum { FormatVCalendar, FormatICalendar }; enum { MailClientKMail, MailClientSendmail }; enum { IMIPDummy, IMIPKMail }; + enum { IMIPOutbox, IMIPdirectsend }; virtual ~KOPrefs(); /** Get instance of KOPrefs. It is made sure that there is only one instance. */ static KOPrefs *instance(); /** Set preferences to default values */ void usrSetDefaults(); /** Read preferences from config file */ void usrReadConfig(); /** Write preferences to config file */ void usrWriteConfig(); protected: void setCategoryDefaults(); void setTimeZoneIdDefault(); /** Fill empty mail fields with default values. */ void fillMailDefaults(); private: /** Constructor disabled for public. Use instance() to create a KOPrefs object. */ KOPrefs(); static KOPrefs *mInstance; public: // preferences data void setFullName(const QString &); QString fullName(); void setEmail(const QString &); QString email(); QString mAdditional; bool mEmailControlCenter; bool mBcc; QString mHoliday; bool mAutoSave; int mAutoSaveInterval; bool mConfirm; bool mEnableGroupScheduling; bool mEnableProjectView; int mDefaultFormat; int mMailClient; bool mAlarmdAutostart; QString mTimeZone; QString mTimeZoneId; int mStartTime; int mDefaultDuration; int mAlarmTime; int mDaylightSavings; int mWorkingHoursStart; int mWorkingHoursEnd; bool mExcludeHolidays; bool mExcludeSaturdays; bool mMarcusBainsShowSeconds; QFont mTimeBarFont; QFont mMonthViewFont; QFont mAgendaViewFont; QFont mMarcusBainsFont; QColor mHolidayColor; QColor mHighlightColor; QColor mEventColor; QColor mAgendaBgColor; QColor mWorkingHoursColor; int mDayBegins; int mHourSize; bool mDailyRecur; bool mWeeklyRecur; bool mEnableToolTips; bool mEnableMonthScroll; bool mFullViewMonth; bool mFullViewTodo; bool mMarcusBainsEnabled; QString mPrintPreview; QStringList mCustomCategories; void setCategoryColor(QString cat,const QColor & color); QColor *categoryColor(QString cat); QString mArchiveFile; QString mHtmlExportFile; QStringList mSelectedPlugins; int mIMIPScheduler; + int mIMIPSend; private: QDict mCategoryColors; QColor mDefaultCategoryColor; QFont mDefaultTimeBarFont; QFont mDefaultViewFont; QString mName; QString mEmail; }; #endif Index: trunk/kdepim/korganizer/outgoingdialog_base.ui =================================================================== --- trunk/kdepim/korganizer/outgoingdialog_base.ui (revision 123089) +++ trunk/kdepim/korganizer/outgoingdialog_base.ui (revision 123090) @@ -1,146 +1,166 @@ - + OutgoingDialog_base - - QDialog - - name + + OutgoingDialog_base - - geometry + 0 0 621 206 - - caption + Scheduler - Outgoing Messages - - margin + + unnamed + + 11 - - spacing + 6 - - QListView + - - text + Summary - - clickable + + true + + + true + + + + + Start Date + + + true + + true - - resizeable + + + + Start Time + + + true + + true - - text + + End Date + + + true + + + true + + + + + End Time + + + true + + + true + + + + Method - - clickable + true - - resizeable + true - - text + Recipients - - clickable + true - - resizeable + true - - name + mMessageListView - - allColumnsShowFocus + true - - QPushButton - - name + + PushButton5 - - text + Send Messages - - - name + + Spacer2 - - geometry - - 549 - 39 - 20 - 128 - - - - orientation + Vertical - - sizeType + Expanding + + + 20 + 20 + + - - QPushButton - - name + + PushButton6 - - text + Close PushButton6 clicked() OutgoingDialog_base accept() PushButton5 clicked() OutgoingDialog_base send() - send() + + send() + + Index: trunk/kdepim/korganizer/incomingdialog_base.ui =================================================================== --- trunk/kdepim/korganizer/incomingdialog_base.ui (revision 123089) +++ trunk/kdepim/korganizer/incomingdialog_base.ui (revision 123090) @@ -1,221 +1,244 @@ - + IncomingDialog_base - - QDialog - - name + + IncomingDialog_base - - geometry + 0 0 - 618 - 212 + 617 + 273 - - caption + Scheduler - Incoming Messages - - margin + + unnamed + + 11 - - spacing + 6 - - QGroupBox - - name + + GroupBox1 - - title + Message - - margin + + unnamed + + 11 - - spacing + 6 - - QPushButton - - name + + PushButton9 - - text + Reject - - QPushButton - - name + + PushButton8 - - text + Accept - - QPushButton - - name + + PushButton4 - - text + Retrieve Messages - - - name + + Spacer3 - - geometry - - 539 - 151 - 20 - 22 - - - - orientation + Vertical - - sizeType + Expanding + + + 20 + 20 + + - - QPushButton - - name + + PushButton7 - - text + Close - - QListView + - - text + Summary - - clickable + + true + + + true + + + + + Start Date + + true - - resizeable + true - - text + + Start Time + + + true + + + true + + + + + End Date + + + true + + + true + + + + + End Time + + + true + + + true + + + + + Organizer + + + true + + + true + + + + Method - - clickable + true - - resizeable + true - - text + Status - - clickable + true - - resizeable + true - - name + mMessageListView - - allColumnsShowFocus + true - - QPushButton - - name + + PushButton7_2 - - text + Accept All PushButton7 clicked() IncomingDialog_base accept() PushButton4 clicked() IncomingDialog_base retrieve() PushButton7_2 clicked() IncomingDialog_base acceptAllMessages() PushButton8 clicked() IncomingDialog_base acceptMessage() PushButton9 clicked() IncomingDialog_base rejectMessage() + + + incomingdialog_base.ui.h + + acceptAllMessages() acceptMessage() rejectMessage() retrieve() - + + Index: trunk/kdepim/korganizer/mailscheduler.cpp =================================================================== --- trunk/kdepim/korganizer/mailscheduler.cpp (revision 123089) +++ trunk/kdepim/korganizer/mailscheduler.cpp (revision 123090) @@ -1,105 +1,113 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // $Id$ // // MailScheduler - Mail implementation of iTIP methods // #include #include #include #include #include #include #include "komailclient.h" #include "mailscheduler.h" using namespace KCal; MailScheduler::MailScheduler(Calendar *calendar) : IMIPScheduler(calendar) { } MailScheduler::~MailScheduler() { } bool MailScheduler::publish (Event *incidence,const QString &recipients) { QString messageText = mFormat->createScheduleMessage(incidence, Scheduler::Publish); // KOMailClient mailer; return false; } bool MailScheduler::performTransaction(Event *incidence,Method method) { QString messageText = mFormat->createScheduleMessage(incidence,method); KOMailClient mailer; return mailer.mailAttendees(incidence,messageText); } QPtrList MailScheduler::retrieveTransactions() { QString incomingDirName = locateLocal("appdata","income"); kdDebug() << "MailScheduler::retrieveTransactions: dir: " << incomingDirName << endl; QPtrList messageList; QDir incomingDir(incomingDirName); QStringList incoming = incomingDir.entryList(QDir::Files); QStringList::ConstIterator it; for(it = incoming.begin(); it != incoming.end(); ++it) { kdDebug() << "-- File: " << (*it) << endl; QFile f(incomingDirName + "/" + (*it)); if (!f.open(IO_ReadOnly)) { kdDebug() << "MailScheduler::retrieveTransactions(): Can't open file'" << (*it) << "'" << endl; } else { QTextStream t(&f); QString messageString = t.read(); ScheduleMessage *message = mFormat->parseScheduleMessage(messageString); if (message) { kdDebug() << "MailScheduler::retrieveTransactions: got message '" - << (*it) << "'" << endl; + << (*it) << "'" << endl; messageList.append(message); + mEventMap[message->event()->VUID()] = incomingDirName + "/" + (*it); } else { QString errorMessage; if (mFormat->exception()) { errorMessage = mFormat->exception()->message(); } kdDebug() << "MailScheduler::retrieveTransactions() Error parsing " "message: " << errorMessage << endl; } f.close(); } } - return messageList; } + +bool MailScheduler::deleteTransaction(Incidence *incidence) +{ + QFile f( mEventMap[incidence->VUID()] ); + if ( !f.exists() ) return false; + else + return f.remove(); +} Index: trunk/kdepim/korganizer/calendarview.cpp =================================================================== --- trunk/kdepim/korganizer/calendarview.cpp (revision 123089) +++ trunk/kdepim/korganizer/calendarview.cpp (revision 123090) @@ -1,1744 +1,1742 @@ /* This file is part of KOrganizer. Requires the Qt and KDE widget libraries, available at no cost at http://www.troll.no and http://www.kde.org respectively Copyright (c) 1997, 1998, 1999 Preston Brown (preston.brown@yale.edu) Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) Ian Dawes (iadawes@globalserve.net) Laszlo Boloni (boloni@cs.purdue.edu) Copyright (c) 2000, 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // $Id$ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef KORG_NOARCHIVE #include "archivedialog.h" #endif #ifndef KORG_NOMAIL #include "komailclient.h" #endif #include "calprinter.h" //#include "exportwebdialog.h" #include "koprefsdialog.h" #include "koeventeditor.h" #include "kotodoeditor.h" #include "koprefs.h" #include "koeventviewerdialog.h" #include "outgoingdialog.h" #include "incomingdialog.h" #include "categoryeditdialog.h" #include "kofilterview.h" #include "filtereditdialog.h" #include "kowhatsnextview.h" #include "kojournalview.h" #ifndef KORG_NOPLUGINS #include "plugindialog.h" #endif #include "koglobals.h" #include "calendarview.h" #include "calendarview.moc" bool CreateEditorVisitor::visit(Event *) { return false; } bool CreateEditorVisitor::visit(Todo *) { return false; } bool CreateEditorVisitor::visit(Journal *) { return false; } CalendarView::CalendarView(QWidget *parent,const char *name) : CalendarViewBase(parent,name) { kdDebug() << "CalendarView::CalendarView()" << endl; mCurrentView = 0; mWhatsNextView = 0; mTodoView = 0; mAgendaView = 0; mMonthView = 0; mListView = 0; // mProjectView = 0; mJournalView = 0; mModified = false; mReadOnly = false; mEventsSelected = true; mOptionsDialog = 0; mSearchDialog = 0; mArchiveDialog = 0; mFilterEditDialog = 0; mExportWebDialog = 0; mOutgoingDialog = 0; mIncomingDialog = 0; mPluginDialog = 0; mCalPrinter = 0; // setMinimumSize(620,400); // make sure we don't get resized too small... // Create calendar object, which manages all calendar information associated // with this calendar view window. mCalendar = new CalendarLocal(KOPrefs::instance()->mTimeZoneId.local8Bit()); mCalendar->setOwner(KOPrefs::instance()->fullName()); mCalendar->setEmail(KOPrefs::instance()->email()); connect(mCalendar,SIGNAL(calUpdated(Incidence *)), SLOT(eventUpdated(Incidence *))); mCategoryEditDialog = new CategoryEditDialog(); QBoxLayout *topLayout = new QVBoxLayout(this); // create the main layout frames. mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); topLayout->addWidget(mPanner); mLeftFrame = new QSplitter(QSplitter::Vertical,mPanner, "CalendarView::LeftFrame"); mPanner->setResizeMode(mLeftFrame,QSplitter::KeepSize); mRightFrame = new QWidgetStack(mPanner, "CalendarView::RightFrame"); mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, "CalendarView::DateNavigator", QDate::currentDate()); mLeftFrame->setResizeMode(mDateNavigator,QSplitter::KeepSize); connect(mDateNavigator, SIGNAL(datesSelected(const QDateList)), SLOT(selectDates(const QDateList))); connect(mDateNavigator,SIGNAL(weekClicked(QDate)),SLOT(selectWeek(QDate))); connect(mDateNavigator,SIGNAL(eventDropped(Event *)), SLOT(eventAdded(Event *))); connect(this, SIGNAL(configChanged()), mDateNavigator, SLOT(updateConfig())); mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolist"); connect(mTodoList, SIGNAL(newTodoSignal()), this, SLOT(newTodo())); connect(mTodoList, SIGNAL(newSubTodoSignal(Todo *)), this, SLOT(newSubTodo(Todo *))); connect(mTodoList, SIGNAL(editTodoSignal(Todo *)), this, SLOT(editTodo(Todo *))); connect(mTodoList, SIGNAL(showTodoSignal(Todo *)), this, SLOT(showTodo(Todo *))); connect(mTodoList, SIGNAL(deleteTodoSignal(Todo *)), this, SLOT(deleteTodo(Todo *))); connect(this, SIGNAL(configChanged()), mTodoList, SLOT(updateConfig())); mFilters.setAutoDelete(true); mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); connect(mFilterView,SIGNAL(filterChanged()),SLOT(updateFilter())); connect(mFilterView,SIGNAL(editFilters()),SLOT(editFilters())); // Hide filter per default mFilterView->hide(); readSettings(); setupRollover(); // We should think about seperating startup settings and configuration change. updateConfig(); connect(QApplication::clipboard(),SIGNAL(dataChanged()), SLOT(checkClipboard())); kdDebug() << "CalendarView::CalendarView() done" << endl; } CalendarView::~CalendarView() { kdDebug() << "~CalendarView()" << endl; hide(); // clean up our calender object mCalendar->close(); // CS: This seems to cause a "Double QObject deletion" delete mCalendar; mCalendar = 0; kdDebug() << "~CalendarView() done" << endl; } QDate CalendarView::startDate() { QDateList dates = mDateNavigator->getSelected(); return *dates.first(); } QDate CalendarView::endDate() { QDateList dates = mDateNavigator->getSelected(); return *dates.last(); } void CalendarView::createOptionsDialog() { if (!mOptionsDialog) { mOptionsDialog = new KOPrefsDialog(this); mOptionsDialog->readConfig(); connect(mOptionsDialog,SIGNAL(configChanged()),SLOT(updateConfig())); connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), mOptionsDialog,SLOT(updateCategories())); } } void CalendarView::createOutgoingDialog() { if (!mOutgoingDialog) { mOutgoingDialog = new OutgoingDialog(mCalendar,this); connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)), SIGNAL(numOutgoingChanged(int))); } } void CalendarView::createIncomingDialog() { if (!mIncomingDialog) { mIncomingDialog = new IncomingDialog(mCalendar,this); connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), SIGNAL(numIncomingChanged(int))); connect(mIncomingDialog,SIGNAL(calendarUpdated()),SLOT(updateView())); } } void CalendarView::createPrinter() { if (!mCalPrinter) { mCalPrinter = new CalPrinter(this, mCalendar); connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); } } bool CalendarView::openCalendar(QString filename, bool merge) { kdDebug() << "CalendarView::openCalendar(): " << filename << endl; if (filename.isEmpty()) { kdDebug() << "CalendarView::openCalendar(): Error! Empty filename." << endl; return false; } if (!QFile::exists(filename)) { kdDebug() << "CalendarView::openCalendar(): Error! File '" << filename << "' doesn't exist." << endl; } if (!merge) mCalendar->close(); if (mCalendar->load(filename)) { if (merge) setModified(true); else { setModified(false); if (mTodoView) mTodoView->setDocumentId( filename ); mTodoList->setDocumentId( filename ); } updateView(); return true; } else { // while failing to load, the calendar object could // have become partially populated. Clear it out. if (!merge) mCalendar->close(); KMessageBox::error(this,i18n("Couldn't load calendar '%1'.").arg(filename)); return false; } } bool CalendarView::saveCalendar(QString filename) { kdDebug() << "CalendarView::saveCalendar(): " << filename << endl; // Store back all unsaved data into calendar object mCurrentView->flushView(); CalFormat *format = new ICalFormat(mCalendar); bool success = mCalendar->save(filename,format); delete format; if (!success) { return false; } setModified(false); return true; } void CalendarView::closeCalendar() { kdDebug() << "CalendarView::closeCalendar()" << endl; // child windows no longer valid emit closingDown(); mCalendar->close(); setModified(false); updateView(); } void CalendarView::archiveCalendar() { #ifndef KORG_NOARCHIVE if (!mArchiveDialog) { mArchiveDialog = new ArchiveDialog(mCalendar,this); connect(mArchiveDialog,SIGNAL(eventsDeleted()),SLOT(updateView())); } mArchiveDialog->show(); mArchiveDialog->raise(); // Workaround. QApplication::restoreOverrideCursor(); #endif } void CalendarView::readSettings() { // kdDebug() << "CalendarView::readSettings()" << endl; QString str; // read settings from the KConfig, supplying reasonable // defaults where none are to be found KConfig *config = KGlobal::config(); config->setGroup("KOrganizer Geometry"); QValueList sizes = config->readIntListEntry("Separator1"); if (sizes.count() != 2) { sizes << mDateNavigator->minimumSizeHint().width(); sizes << 300; } mPanner->setSizes(sizes); sizes = config->readIntListEntry("Separator2"); if (sizes.count() == 3) { mLeftFrame->setSizes(sizes); } // Set current view from Entry "Current View" readCurrentView(config); readFilterSettings(config); } void CalendarView::readCurrentView(KConfig *config) { config->setGroup("General"); QString view = config->readEntry("Current View"); if (view == "WhatsNext") showWhatsNextView(); else if (view == "Month") showMonthView(); else if (view == "List") showListView(); // else if (view == "Project") showProjectView(); else if (view == "Journal") showJournalView(); else showAgendaView(); } void CalendarView::writeCurrentView(KConfig *config) { config->setGroup("General"); QString view; if (mCurrentView == mWhatsNextView) view = "WhatsNext"; else if (mCurrentView == mMonthView) view = "Month"; else if (mCurrentView == mListView) view = "List"; // else if (mCurrentView == mProjectView) view = "Project"; else if (mCurrentView == mJournalView) view = "Journal"; else view = "Agenda"; - + config->writeEntry("Current View",view); } void CalendarView::writeSettings() { // kdDebug() << "CalendarView::writeSettings" << endl; KConfig *config = KGlobal::config(); config->setGroup("KOrganizer Geometry"); QValueList list = mPanner->sizes(); config->writeEntry("Separator1",list); list = mLeftFrame->sizes(); config->writeEntry("Separator2",list); writeCurrentView(config); if (mAgendaView) { mAgendaView->writeSettings(config); } #if 0 if (mProjectView) { mProjectView->writeSettings(config); } #endif KOPrefs::instance()->writeConfig(); writeFilterSettings(config); config->sync(); } void CalendarView::readFilterSettings(KConfig *config) { // kdDebug() << "CalendarView::readFilterSettings()" << endl; mFilters.clear(); config->setGroup("General"); QStringList filterList = config->readListEntry("CalendarFilters"); QStringList::ConstIterator it = filterList.begin(); QStringList::ConstIterator end = filterList.end(); while(it != end) { // kdDebug() << " filter: " << (*it) << endl; CalFilter *filter; filter = new CalFilter(*it); config->setGroup("Filter_" + (*it)); filter->setCriteria(config->readNumEntry("Criteria",0)); filter->setCategoryList(config->readListEntry("CategoryList")); mFilters.append(filter); ++it; } if (mFilters.count() == 0) { CalFilter *filter = new CalFilter(i18n("Default")); mFilters.append(filter); } mFilterView->updateFilters(); } void CalendarView::writeFilterSettings(KConfig *config) { // kdDebug() << "CalendarView::writeFilterSettings()" << endl; QStringList filterList; CalFilter *filter = mFilters.first(); while(filter) { // kdDebug() << " fn: " << filter->name() << endl; filterList << filter->name(); config->setGroup("Filter_" + filter->name()); config->writeEntry("Criteria",filter->criteria()); config->writeEntry("CategoryList",filter->categoryList()); filter = mFilters.next(); } config->setGroup("General"); config->writeEntry("CalendarFilters",filterList); } void CalendarView::goToday() { QDateList tmpList; QDate today(QDate::currentDate()); tmpList.append(&today); mDateNavigator->selectDates(tmpList); mSaveSingleDate = QDate::currentDate(); updateView(mDateNavigator->getSelected()); } void CalendarView::goNext() { // adapt this to work for other views if (mAgendaView) mAgendaView->slotNextDates(); // this *appears* to work fine... updateView(mDateNavigator->getSelected()); } void CalendarView::goPrevious() { // adapt this to work for other views if (mAgendaView) mAgendaView->slotPrevDates(); // this *appears* to work fine... updateView(mDateNavigator->getSelected()); } void CalendarView::setupRollover() { // right now, this is a single shot (because I am too lazy to code a // real one using a real qtimer object). It will only work for a single // day rollover. I should fix this. :) QDate tmpDate = QDate::currentDate().addDays(1); QTime tmpTime = QTime(00, 1); QDateTime tomorrow(tmpDate, tmpTime); QTimer::singleShot(QDateTime::currentDateTime().secsTo(tomorrow)*1000, mDateNavigator, SLOT(updateView())); } void CalendarView::updateConfig() { kdDebug() << "CalendarView::updateConfig()" << endl; emit configChanged(); mCalendar->updateConfig(); mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId.local8Bit()); // To make the "fill window" configurations work raiseCurrentView(); } void CalendarView::eventChanged(Event *event) { changeEventDisplay(event,KOGlobals::EVENTEDITED); } void CalendarView::eventAdded(Event *event) { changeEventDisplay(event,KOGlobals::EVENTADDED); } void CalendarView::eventToBeDeleted(Event *) { kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; } void CalendarView::eventDeleted() { changeEventDisplay(0,KOGlobals::EVENTDELETED); } // most of the changeEventDisplays() right now just call the view's // total update mode, but they SHOULD be recoded to be more refresh-efficient. void CalendarView::changeEventDisplay(Event *which, int action) { // kdDebug() << "CalendarView::changeEventDisplay" << endl; mDateNavigator->updateView(); if (mSearchDialog) mSearchDialog->updateView(); if (which) { // If there is an event view visible update the display mCurrentView->changeEventDisplay(which,action); // TODO: check, if update needed // if (which->getTodoStatus()) { mTodoList->updateView(); // } } else { mCurrentView->updateView(); } } void CalendarView::updateTodoViews() { kdDebug() << "CalendarView::updateTodoViews()" << endl; mTodoList->updateView(); mCurrentView->updateView(); } void CalendarView::changeAgendaView( int newView ) { if (!mAgendaView) return; if (newView == mAgendaView->currentView()) return; switch( newView ) { case KOAgendaView::DAY: { QDateList tmpList(FALSE); tmpList = mDateNavigator->getSelected(); if (mSaveSingleDate != *tmpList.first()) { mDateNavigator->selectDates(mSaveSingleDate); updateView(mDateNavigator->getSelected()); } break; } // if its a workweek view, calculate the dates and emit case KOAgendaView::WORKWEEK: break; // if its a week view, calculate the dates and emit case KOAgendaView::WEEK: break; // if its a list view, update the list properties. case KOAgendaView::LIST: // we want to make sure that this is up to date. break; } mAgendaView->slotViewChange( newView ); adaptNavigationUnits(); } void CalendarView::nextAgendaView() { if (!mAgendaView) return; int view; if( mCurrentView == mAgendaView ) { view = mAgendaView->currentView() + 1; if ((view >= KOAgendaView::DAY) && ( view < KOAgendaView::LIST)) changeAgendaView( view ); else changeAgendaView( KOAgendaView::DAY ); } else { changeAgendaView( mAgendaView->currentView() ); showView( mAgendaView ); } } void CalendarView::showView(KOrg::BaseView *view) { if(view == mCurrentView) return; mCurrentView = view; raiseCurrentView(); processEventSelection(false); updateView(mDateNavigator->getSelected()); adaptNavigationUnits(); } void CalendarView::raiseCurrentView() { if ((mMonthView && KOPrefs::instance()->mFullViewMonth && mCurrentView == mMonthView) || (mTodoView && KOPrefs::instance()->mFullViewTodo && mCurrentView == mTodoView)) { mLeftFrame->hide(); } else { mLeftFrame->show(); } mRightFrame->raiseWidget(mCurrentView); } void CalendarView::updateView(const QDateList selectedDates) { // kdDebug() << "CalendarView::updateView()" << endl; QDateList tmpList(false); tmpList = selectedDates; int numView; // if there are 5 dates and the first is a monday, we have a workweek. if ((tmpList.count() == 5) && (tmpList.first()->dayOfWeek() == 1) && (tmpList.first()->daysTo(*tmpList.last()) == 4)) { numView = KOAgendaView::WORKWEEK; // if there are 7 dates and the first date is a monday, we have a regular week. } else if ((tmpList.count() == 7) && (tmpList.first()->dayOfWeek() == (KGlobal::locale()->weekStartsMonday() ? 1 : 7)) && (tmpList.first()->daysTo(*tmpList.last()) == 6)) { numView = KOAgendaView::WEEK; } else if (tmpList.count() == 1) { numView = KOAgendaView::DAY; mSaveSingleDate = *tmpList.first(); } else { // for sanity, set viewtype to LIST for now... numView = KOAgendaView::LIST; } mCurrentView->selectDates(selectedDates); mTodoList->updateView(); if (mTodoView) mTodoView->updateView(); } void CalendarView::updateView() { // update the current view with the current dates from the date navigator QDateList tmpList(FALSE); // we want a shallow copy tmpList = mDateNavigator->getSelected(); // if no dates are supplied, we should refresh the mDateNavigator too... mDateNavigator->updateView(); updateView(tmpList); } int CalendarView::msgItemDelete() { return KMessageBox::warningContinueCancel(this, i18n("This item will be permanently deleted."), i18n("KOrganizer Confirmation"),i18n("Delete")); } void CalendarView::edit_cut() { Event *anEvent=0; if (mCurrentView->isEventView()) { anEvent = dynamic_cast((mCurrentView->getSelected()).first()); } if (!anEvent) { KNotifyClient::beep(); return; } mCalendar->cutEvent(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } void CalendarView::edit_copy() { Event *anEvent=0; if (mCurrentView->isEventView()) { anEvent = dynamic_cast((mCurrentView->getSelected()).first()); } if (!anEvent) { KNotifyClient::beep(); return; } mCalendar->copyEvent(anEvent); } void CalendarView::edit_paste() { Event *pastedEvent; QDateList tmpList(FALSE); tmpList = mDateNavigator->getSelected(); pastedEvent = mCalendar->pasteEvent(tmpList.first()); changeEventDisplay(pastedEvent, KOGlobals::EVENTADDED); } void CalendarView::edit_options() { createOptionsDialog(); mOptionsDialog->readConfig(); mOptionsDialog->show(); } void CalendarView::newEvent() { kdDebug() << "CalendarView::newEvent()" << endl; newEvent(QDate::currentDate()); } void CalendarView::newEvent(QDateTime fh) { newEvent(fh, QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); } void CalendarView::newEvent(QDate dt) { newEvent(QDateTime(dt, QTime(0,0,0)), QDateTime(dt, QTime(0,0,0)), TRUE); } void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) { KOEventEditor *eventEditor = getEventEditor(); eventEditor->newEvent(fromHint,toHint); eventEditor->show(); } void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) { KOEventEditor *eventEditor = getEventEditor(); eventEditor->newEvent(fromHint,toHint,allDay); eventEditor->show(); } void CalendarView::newTodo() { KOTodoEditor *todoEditor = getTodoEditor(); todoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); todoEditor->show(); } void CalendarView::newSubTodo(Todo *parentEvent) { KOTodoEditor *todoEditor = getTodoEditor(); todoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); todoEditor->show(); } void CalendarView::appointment_new() { QDate from, to; QDateList tmpList(FALSE); tmpList = mDateNavigator->getSelected(); from = *tmpList.first(); to = *tmpList.last(); ASSERT(from.isValid()); if (!from.isValid()) { // mDateNavigator sometimes returns GARBAGE! from = QDate::currentDate(); to = from; } newEvent(QDateTime(from, QTime(KOPrefs::instance()->mStartTime,0,0)), QDateTime(to, QTime(KOPrefs::instance()->mStartTime + KOPrefs::instance()->mDefaultDuration,0,0))); } void CalendarView::allday_new() { QDate from, to; QDateList tmpList(FALSE); tmpList = mDateNavigator->getSelected(); from = *tmpList.first(); to = *tmpList.last(); ASSERT(from.isValid()); if (!from.isValid()) { from = QDate::currentDate(); to = from; } newEvent(QDateTime(from, QTime(12,0,0)), QDateTime(to, QTime(12,0,0)), TRUE); } void CalendarView::editEvent(Event *anEvent) { if(anEvent) { if (anEvent->isReadOnly()) { showEvent(anEvent); return; } QDateList tmpList(FALSE); QDate qd; tmpList = mDateNavigator->getSelected(); qd = *tmpList.first(); KOEventEditor *eventEditor = getEventEditor(); eventEditor->editEvent(anEvent,qd); eventEditor->show(); } else { KNotifyClient::beep(); } } void CalendarView::editTodo(Todo *todo) { if (todo) { if (todo->isReadOnly()) { showTodo(todo); return; } QDateList tmpList(FALSE); QDate qd; tmpList = mDateNavigator->getSelected(); qd = *tmpList.first(); KOTodoEditor *todoEditor = getTodoEditor(); todoEditor->editTodo(todo,qd); todoEditor->show(); } else { KNotifyClient::beep(); } } void CalendarView::showEvent(Event *event) { KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); eventViewer->setEvent(event); eventViewer->show(); } void CalendarView::showTodo(Todo *event) { KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); eventViewer->setTodo(event); eventViewer->show(); } void CalendarView::appointment_show() { Event *anEvent = 0; if (mCurrentView->isEventView()) { anEvent = dynamic_cast((mCurrentView->getSelected()).first()); } if (!anEvent) { KNotifyClient::beep(); return; } showEvent(anEvent); } void CalendarView::appointment_edit() { Event *anEvent = 0; if (mCurrentView->isEventView()) { anEvent = dynamic_cast((mCurrentView->getSelected()).first()); } if (!anEvent) { KNotifyClient::beep(); return; } editEvent(anEvent); } void CalendarView::appointment_delete() { Event *anEvent = 0; if (mCurrentView->isEventView()) { anEvent = dynamic_cast((mCurrentView->getSelected()).first()); } if (!anEvent) { KNotifyClient::beep(); return; } deleteEvent(anEvent); } // Is this function needed anymore? It could just call the deleteTodo slot of // the KOTodoView, couldn't it? void CalendarView::action_deleteTodo() { Todo *aTodo; KOTodoView *todoList2 = (mCurrentView->isEventView() ? mTodoList : mTodoView); // TodoView *todoList2 = (viewMode == TODOVIEW ? mTodoView : mTodoList); if (!todoList2) { KNotifyClient::beep(); return; } aTodo = (todoList2->selectedTodos()).first(); if (!aTodo) { KNotifyClient::beep(); return; } // disable deletion for now, because it causes a crash. return; if (KOPrefs::instance()->mConfirm) { switch(msgItemDelete()) { case KMessageBox::Continue: // OK mCalendar->deleteTodo(aTodo); // If there would be a removeTodo() function in KOTodoView we would call // it here... (before the mCalendar->deleteTodo call actually) todoList2->updateView(); break; } // switch } else { mCalendar->deleteTodo(aTodo); // If there would be a removeTodo() function in KOTodoView we would call // it here... (before the mCalendar->deleteTodo call actually) todoList2->updateView(); } } void CalendarView::deleteTodo(Todo *todo) { if (!todo) { KNotifyClient::beep(); return; } if (KOPrefs::instance()->mConfirm) { switch (msgItemDelete()) { case KMessageBox::Continue: // OK mCalendar->deleteTodo(todo); updateView(); break; } // switch } else { mCalendar->deleteTodo(todo); updateView(); } } void CalendarView::deleteEvent(Event *anEvent) { if (!anEvent) { KNotifyClient::beep(); return; } if (anEvent->recurrence()->doesRecur()) { switch(KMessageBox::warningContinueCancel(this, i18n("This event recurs over multiple dates.\n" "Are you sure you want to delete this event " "and all its recurrences?"), i18n("KOrganizer Confirmation"),i18n("&Continue"))) { case KMessageBox::Continue: // all mCalendar->deleteEvent(anEvent); changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); break; // Disabled because it does not work #if 0 case KMessageBox::No: // just this one QDate qd; QDateList tmpList(FALSE); tmpList = mDateNavigator->getSelected(); qd = *(tmpList.first()); if (!qd.isValid()) { kdDebug() << "no date selected, or invalid date" << endl; KNotifyClient::beep(); return; } while (!anEvent->recursOn(qd)) qd = qd.addDays(1); anEvent->addExDate(qd); changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); break; #endif } // switch } else { if (KOPrefs::instance()->mConfirm) { switch (msgItemDelete()) { case KMessageBox::Continue: // OK mCalendar->deleteEvent(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); break; } // switch } else { mCalendar->deleteEvent(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } } // if-else } bool CalendarView::deleteEvent(const QString &VUID) { Event *ev = mCalendar->getEvent(VUID); if (ev) { deleteEvent(ev); return true; } else { return false; } } /*****************************************************************************/ void CalendarView::action_search() { if (!mSearchDialog) { mSearchDialog = new SearchDialog(mCalendar,this); connect(mSearchDialog,SIGNAL(showEventSignal(Event *)), SLOT(showEvent(Event *))); connect(mSearchDialog,SIGNAL(editEventSignal(Event *)), SLOT(editEvent(Event *))); connect(mSearchDialog,SIGNAL(deleteEventSignal(Event *)), SLOT(deleteEvent(Event *))); connect(this,SIGNAL(closingDown()),mSearchDialog,SLOT(reject())); } // make sure the widget is on top again mSearchDialog->show(); mSearchDialog->raise(); } void CalendarView::action_mail() { #ifndef KORG_NOMAIL KOMailClient mailClient; Incidence *incidence = currentSelection(); if (!incidence) { KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); return; } if(incidence->attendeeCount() == 0 ) { KMessageBox::sorry(this, i18n("Can't generate mail:\nNo attendees defined.\n")); return; } mailClient.mailAttendees(currentSelection()); #endif #if 0 Event *anEvent = 0; if (mCurrentView->isEventView()) { anEvent = dynamic_cast((mCurrentView->getSelected()).first()); } if (!anEvent) { KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); return; } if(anEvent->attendeeCount() == 0 ) { KMessageBox::sorry(this, i18n("Can't generate mail:\nNo attendees defined.\n")); return; } mailobject.emailEvent(anEvent); #endif } void CalendarView::showWhatsNextView() { if (!mWhatsNextView) { mWhatsNextView = new KOWhatsNextView(mCalendar,mRightFrame, "CalendarView::WhatsNextView"); addView(mWhatsNextView); } showView(mWhatsNextView); } void CalendarView::showListView() { if (!mListView) { mListView = new KOListView(mCalendar, mRightFrame, "CalendarView::ListView"); addView(mListView); connect(mListView, SIGNAL(datesSelected(const QDateList)), mDateNavigator, SLOT(selectDates(const QDateList))); connect(mListView, SIGNAL(showEventSignal(Event *)), this, SLOT(showEvent(Event *))); connect(mListView, SIGNAL(editEventSignal(Event *)), this, SLOT(editEvent(Event *))); connect(mListView, SIGNAL(deleteEventSignal(Event *)), this, SLOT(deleteEvent(Event *))); connect(mListView,SIGNAL(eventsSelected(bool)), SLOT(processEventSelection(bool))); connect(this, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); } showView(mListView); } void CalendarView::showAgendaView() { if (!mAgendaView) { mAgendaView = new KOAgendaView(mCalendar, mRightFrame, "CalendarView::AgendaView"); addView(mAgendaView); connect(mAgendaView, SIGNAL(datesSelected(const QDateList)), mDateNavigator, SLOT(selectDates(const QDateList))); // SIGNALS/SLOTS FOR DAY/WEEK VIEW connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), this, SLOT(newEvent(QDateTime))); connect(mAgendaView,SIGNAL(newEventSignal(QDate)), this, SLOT(newEvent(QDate))); // connect(mAgendaView,SIGNAL(newEventSignal()), // this, SLOT(newEvent())); connect(mAgendaView, SIGNAL(editEventSignal(Event *)), this, SLOT(editEvent(Event *))); connect(mAgendaView, SIGNAL(showEventSignal(Event *)), this, SLOT(showEvent(Event *))); connect(mAgendaView, SIGNAL(deleteEventSignal(Event *)), this, SLOT(deleteEvent(Event *))); connect(mAgendaView,SIGNAL(eventsSelected(bool)), SLOT(processEventSelection(bool))); connect(this, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); mAgendaView->readSettings(); } showView(mAgendaView); } void CalendarView::showDayView() { showAgendaView(); changeAgendaView(KOAgendaView::DAY); } void CalendarView::showWorkWeekView() { showAgendaView(); changeAgendaView(KOAgendaView::WORKWEEK); } void CalendarView::showWeekView() { showAgendaView(); changeAgendaView(KOAgendaView::WEEK); } void CalendarView::showMonthView() { if (!mMonthView) { mMonthView = new KOMonthView(mCalendar, mRightFrame, "CalendarView::MonthView"); addView(mMonthView); connect(mMonthView, SIGNAL(datesSelected(const QDateList)), mDateNavigator, SLOT(selectDates(const QDateList))); // SIGNALS/SLOTS FOR MONTH VIEW connect(mMonthView, SIGNAL(showEventSignal(Event *)), this, SLOT(showEvent(Event *))); connect(mMonthView, SIGNAL(newEventSignal(QDate)), this, SLOT(newEvent(QDate))); connect(mMonthView, SIGNAL(editEventSignal(Event *)), this, SLOT(editEvent(Event *))); connect(mMonthView, SIGNAL(deleteEventSignal(Event *)), this, SLOT(deleteEvent(Event *))); connect(mMonthView,SIGNAL(eventsSelected(bool)), SLOT(processEventSelection(bool))); connect(this, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); } showView(mMonthView); } void CalendarView::showTodoView() { if (!mTodoView) { mTodoView = new KOTodoView(mCalendar, mRightFrame, "CalendarView::TodoView"); addView(mTodoView); // SIGNALS/SLOTS FOR TODO VIEW connect(mTodoView, SIGNAL(newTodoSignal()), this, SLOT(newTodo())); connect(mTodoView, SIGNAL(newSubTodoSignal(Todo *)), this, SLOT(newSubTodo(Todo *))); connect(mTodoView, SIGNAL(showTodoSignal(Todo *)), this, SLOT(showTodo(Todo *))); connect(mTodoView, SIGNAL(editTodoSignal(Todo *)), this, SLOT(editTodo(Todo *))); connect(mTodoView, SIGNAL(deleteTodoSignal(Todo *)), this, SLOT(deleteTodo(Todo *))); connect(this, SIGNAL(configChanged()), mTodoView, SLOT(updateConfig())); } - + showView(mTodoView); } void CalendarView::showProjectView() { #if 0 if (!mProjectView) { mProjectView = new KOProjectView(mCalendar,mRightFrame, "CalendarView::ProjectView"); addView(mProjectView); mProjectView->readSettings(); } showView(mProjectView); #endif } void CalendarView::showJournalView() { if (!mJournalView) { mJournalView = new KOJournalView(mCalendar,mRightFrame, "CalendarView::JournalView"); addView(mJournalView); } showView(mJournalView); } void CalendarView::schedule_outgoing() { createOutgoingDialog(); mOutgoingDialog->show(); mOutgoingDialog->raise(); } void CalendarView::schedule_incoming() { createIncomingDialog(); mIncomingDialog->show(); mIncomingDialog->raise(); } void CalendarView::schedule_publish() { Event *event = 0; if (mCurrentView->isEventView()) { event = dynamic_cast((mCurrentView->getSelected()).first()); } if (!event) { KMessageBox::sorry(this,i18n("No event selected.")); return; } - createOutgoingDialog(); mOutgoingDialog->addMessage(event,Scheduler::Publish,"dummy@nowhere.nil"); } void CalendarView::schedule_request() { schedule(Scheduler::Request); } void CalendarView::schedule_refresh() { schedule(Scheduler::Refresh); } void CalendarView::schedule_cancel() { schedule(Scheduler::Cancel); } void CalendarView::schedule_add() { schedule(Scheduler::Add); } void CalendarView::schedule_reply() { schedule(Scheduler::Reply); } void CalendarView::schedule_counter() { schedule(Scheduler::Counter); } void CalendarView::schedule_declinecounter() { schedule(Scheduler::Declinecounter); } void CalendarView::schedule(Scheduler::Method method) { Event *event = 0; if (mCurrentView->isEventView()) { event = dynamic_cast((mCurrentView->getSelected()).first()); } if (!event) { KMessageBox::sorry(this,i18n("No event selected.")); return; } - createOutgoingDialog(); mOutgoingDialog->addMessage(event,method); } void CalendarView::setModified(bool modified) { if (mModified != modified) { mModified = modified; emit modifiedChanged(mModified); } } bool CalendarView::isReadOnly() { return mReadOnly; } void CalendarView::setReadOnly(bool readOnly) { if (mReadOnly != readOnly) { mReadOnly = readOnly; emit readOnlyChanged(mReadOnly); } } bool CalendarView::isModified() { return mModified; } // TODO: Check, if this function is still needed void CalendarView::signalAlarmDaemon() { #if 0 QFile pidFile; QString tmpStr; pid_t pid; char pidStr[25]; tmpStr = locateLocal("appdata", "alarm.pid"); pidFile.setName(tmpStr); // only necessary if the file actually is opened if(pidFile.open(IO_ReadOnly)) { pidFile.readLine(pidStr, 24); pidFile.close(); pid = atoi(pidStr); if (pid > 0) kill(pid, SIGHUP); } #endif } void CalendarView::printSetup() { createPrinter(); mCalPrinter->setupPrinter(); } void CalendarView::print() { createPrinter(); QDateList tmpDateList(FALSE); tmpDateList = mDateNavigator->getSelected(); mCalPrinter->print(CalPrinter::Month, *tmpDateList.first(), *tmpDateList.last()); } void CalendarView::printPreview() { kdDebug() << "CalendarView::printPreview()" << endl; createPrinter(); QDateList tmpDateList(FALSE); tmpDateList = mDateNavigator->getSelected(); mCurrentView->printPreview(mCalPrinter,*tmpDateList.first(), *tmpDateList.last()); } void CalendarView::exportWeb() { #if 0 if (!mExportWebDialog) { mExportWebDialog = new ExportWebDialog(mCalendar); } mExportWebDialog->show(); mExportWebDialog->raise(); #endif } void CalendarView::exportICalendar() { QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); // Force correct extension if (filename.right(4) != ".ics") filename += ".ics"; CalFormat *format = new ICalFormat(mCalendar); mCalendar->save(filename,format); delete format; } void CalendarView::exportVCalendar() { if (mCalendar->journalList().count() > 0) { int result = KMessageBox::warningContinueCancel(this, i18n("The journal entries can not be exported to a vCalendar file."), i18n("Data Loss Warning"),i18n("Proceed"),"dontaskVCalExport", true); if (result != KMessageBox::Continue) return; } QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCaldendars"),this); // Force correct extension if (filename.right(4) != ".vcs") filename += ".vcs"; CalFormat *format = new VCalFormat(mCalendar); mCalendar->save(filename,format); delete format; } void CalendarView::eventUpdated(Incidence *) { setModified(); // Don't call updateView here. The code, which has caused the update of the // event is responsible for updating the view. // updateView(); } void CalendarView::selectWeek(QDate weekstart) { // kdDebug() << "CalendarView::selectWeek(): " << weekstart.toString() << endl; QDateList week; int n = 7; if (mCurrentView->currentDateCount() == 5) n = 5; int i; for(i=0;iselectDates(week); updateView(week); } void CalendarView::adaptNavigationUnits() { if (mCurrentView->isEventView()) { int days = mCurrentView->currentDateCount(); if (days == 1) { emit changeNavStringPrev(i18n("&Previous Day")); emit changeNavStringNext(i18n("&Next Day")); } else { emit changeNavStringPrev(i18n("&Previous Week")); emit changeNavStringNext(i18n("&Next Week")); } } } void CalendarView::processEventSelection(bool selected) { // Do nothing, if state hasn't changed // Disabled because initial state wasn't propagated correctly if (mEventsSelected == selected) return; mEventsSelected = selected; emit eventsSelected(mEventsSelected); } void CalendarView::emitEventsSelected() { emit eventsSelected(mEventsSelected); } void CalendarView::checkClipboard() { if (VCalDrag::canDecode(QApplication::clipboard()->data())) { kdDebug() << "CalendarView::checkClipboard() true" << endl; emit pasteEnabled(true); } else { kdDebug() << "CalendarView::checkClipboard() false" << endl; emit pasteEnabled(false); } } void CalendarView::selectDates(const QDateList selectedDates) { // kdDebug() << "CalendarView::selectDates()" << endl; if (mCurrentView->isEventView()) { updateView(selectedDates); } else { showAgendaView(); } } void CalendarView::editCategories() { mCategoryEditDialog->show(); } void CalendarView::editFilters() { // kdDebug() << "CalendarView::editFilters()" << endl; CalFilter *filter = mFilters.first(); while(filter) { kdDebug() << " Filter: " << filter->name() << endl; filter = mFilters.next(); } if (!mFilterEditDialog) { mFilterEditDialog = new FilterEditDialog(&mFilters,this); connect(mFilterEditDialog,SIGNAL(filterChanged()), SLOT(filterEdited())); } mFilterEditDialog->show(); mFilterEditDialog->raise(); } void CalendarView::showFilter(bool visible) { if (visible) mFilterView->show(); else mFilterView->hide(); } void CalendarView::updateFilter() { CalFilter *filter = mFilterView->selectedFilter(); if (filter) { if (mFilterView->filtersEnabled()) filter->setEnabled(true); else filter->setEnabled(false); mCalendar->setFilter(filter); updateView(); } } void CalendarView::filterEdited() { mFilterView->updateFilters(); updateFilter(); } KOEventEditor *CalendarView::getEventEditor() { KOEventEditor *eventEditor = new KOEventEditor(mCalendar); connect(eventEditor,SIGNAL(eventAdded(Event *)),SLOT(eventAdded(Event *))); connect(eventEditor,SIGNAL(eventChanged(Event *)),SLOT(eventChanged(Event *))); connect(eventEditor,SIGNAL(eventDeleted()),SLOT(eventDeleted())); connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), eventEditor,SLOT(updateCategoryConfig())); connect(eventEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show())); connect(this,SIGNAL(closingDown()),eventEditor,SLOT(reject())); return eventEditor; } KOTodoEditor *CalendarView::getTodoEditor() { KOTodoEditor *todoEditor = new KOTodoEditor(mCalendar); connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), todoEditor,SLOT(updateCategoryConfig())); connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show())); connect(todoEditor,SIGNAL(todoAdded(Todo *)),SLOT(updateTodoViews())); connect(todoEditor,SIGNAL(todoChanged(Todo *)),SLOT(updateTodoViews())); connect(todoEditor,SIGNAL(todoDeleted()),SLOT(updateTodoViews())); connect(this, SIGNAL(closingDown()),todoEditor,SLOT(reject())); return todoEditor; } Incidence *CalendarView::currentSelection() { if (!mCurrentView) return 0; return mCurrentView->getSelected().first(); } void CalendarView::takeOverEvent() { Incidence *incidence = currentSelection(); if (!incidence) return; incidence->setOrganizer(KOPrefs::instance()->email()); incidence->recreate(); incidence->setReadOnly(false); updateView(); } void CalendarView::takeOverCalendar() { // TODO: Create Calendar::allIncidences() function and use it here QPtrList events = mCalendar->getAllEvents(); for(uint i=0; isetOrganizer(KOPrefs::instance()->email()); events.at(i)->recreate(); events.at(i)->setReadOnly(false); } QPtrList todos = mCalendar->getTodoList(); for(uint i=0; isetOrganizer(KOPrefs::instance()->email()); todos.at(i)->recreate(); todos.at(i)->setReadOnly(false); } - + QPtrList journals = mCalendar->journalList(); for(uint i=0; isetOrganizer(KOPrefs::instance()->email()); journals.at(i)->recreate(); journals.at(i)->setReadOnly(false); } updateView(); } void CalendarView::showIntro() { kdDebug() << "To be implemented." << endl; } void CalendarView::configurePlugins() { #ifndef KORG_NOPLUGINS if (!mPluginDialog) { mPluginDialog = new PluginDialog(this); connect(mPluginDialog,SIGNAL(configChanged()),SLOT(updateConfig())); } mPluginDialog->show(); mPluginDialog->raise(); #endif } void CalendarView::addView(KOrg::BaseView *view) { mRightFrame->addWidget(view); } Index: trunk/kdepim/korganizer/koprefs.cpp =================================================================== --- trunk/kdepim/korganizer/koprefs.cpp (revision 123089) +++ trunk/kdepim/korganizer/koprefs.cpp (revision 123090) @@ -1,310 +1,311 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // $Id$ #include #include #include #include #include #include #include #include #include #include #include #include #include "koprefs.h" KOPrefs *KOPrefs::mInstance = 0; KOPrefs::KOPrefs() : KPrefs("korganizerrc") { mCategoryColors.setAutoDelete(true); mDefaultCategoryColor = QColor(196,196,196); QColor defaultHolidayColor = QColor("red"); QColor defaultHighlightColor = QColor("blue"); QColor defaultAgendaBgColor = QColor(128,128,128); QColor defaultWorkingHoursColor = QColor(160,160,160); mDefaultTimeBarFont = QFont("helvetica",12,QFont::Bold); mDefaultViewFont = QFont("helvetica",12); KPrefs::setCurrentGroup("General"); addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); addItemBool("Enable Project View",&mEnableProjectView,false); addItemBool("Auto Save",&mAutoSave,false); addItemInt("Auto Save Interval",&mAutoSaveInterval,10); addItemBool("Confirm Deletes",&mConfirm,true); addItemString("Archive File",&mArchiveFile); addItemString("Html Export File",&mHtmlExportFile, QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); KPrefs::setCurrentGroup("Personal Settings"); addItemInt("Mail Client",&mMailClient,MailClientKMail); addItemBool("Use Control Center Email",&mEmailControlCenter,false); addItemBool("Bcc",&mBcc,false); KPrefs::setCurrentGroup("Time & Date"); addItemString("Time Zone",&mTimeZone,"+0000"); addItemString("TimeZoneId",&mTimeZoneId); addItemInt("Default Start Time",&mStartTime,10); addItemInt("Default Duration",&mDefaultDuration,2); addItemInt("Default Alarm Time",&mAlarmTime,0); addItemInt("Daylight Savings",&mDaylightSavings,0); KPrefs::setCurrentGroup("AlarmDaemon"); addItemBool("Autostart",&mAlarmdAutostart,true); KPrefs::setCurrentGroup("Calendar"); addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); KPrefs::setCurrentGroup("Fonts"); addItemFont("TimeBar Font",&mTimeBarFont); addItemFont("MonthView Font",&mMonthViewFont); addItemFont("AgendaView Font",&mAgendaViewFont); addItemFont("MarcusBains Font",&mAgendaViewFont); KPrefs::setCurrentGroup("Colors"); addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); KPrefs::setCurrentGroup("Views"); addItemInt("Hour Size",&mHourSize,10); addItemBool("Show Daily Recurrences",&mDailyRecur,true); addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); addItemBool("Enable ToolTips",&mEnableToolTips,false); addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); addItemInt("Day Begins",&mDayBegins,7); addItemInt("Working Hours Start",&mWorkingHoursStart,8); addItemInt("Working Hours End",&mWorkingHoursEnd,17); addItemBool("Exclude Holidays",&mExcludeHolidays,true); addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); addItemBool("Full View Month",&mFullViewMonth,false); addItemBool("Full View Todo",&mFullViewTodo,true); KPrefs::setCurrentGroup("Printer"); addItemString("Preview",&mPrintPreview,"kghostview"); KPrefs::setCurrentGroup("KOrganizer Plugins"); addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); KPrefs::setCurrentGroup("Group Scheduling"); addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); + addItemInt("IMIPSend",&mIMIPSend,IMIPOutbox); } KOPrefs::~KOPrefs() { kdDebug() << "KOPrefs::~KOPrefs()" << endl; delete mInstance; mInstance = 0; } KOPrefs *KOPrefs::instance() { if (!mInstance) { mInstance = new KOPrefs(); mInstance->readConfig(); } return mInstance; } void KOPrefs::usrSetDefaults() { // Default should be set a bit smarter, respecting username and locale // settings for example. KEMailSettings settings; mName = settings.getSetting(KEMailSettings::RealName); mEmail = settings.getSetting(KEMailSettings::RealName); fillMailDefaults(); mHoliday = KGlobal::locale()->country(); mTimeZone = "+0000"; mTimeBarFont = mDefaultTimeBarFont; mMonthViewFont = mDefaultViewFont; mAgendaViewFont = mDefaultViewFont; mMarcusBainsFont = mDefaultViewFont; setCategoryDefaults(); setTimeZoneIdDefault(); } void KOPrefs::fillMailDefaults() { if (mName.isEmpty()) mName = i18n("Anonymous"); if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); } void KOPrefs::setTimeZoneIdDefault() { QString zone; char zonefilebuf[100]; int len = readlink("/etc/localtime",zonefilebuf,100); if (len > 0 && len < 100) { zonefilebuf[len] = '\0'; zone = zonefilebuf; zone = zone.mid(zone.find("zoneinfo/") + 9); } else { extern char *tzname[2]; tzset(); zone = tzname[0]; } kdDebug () << "----- time zone: " << zone << endl; mTimeZoneId = zone; } void KOPrefs::setCategoryDefaults() { mCustomCategories.clear(); mCustomCategories << i18n("Appointment") << i18n("Business") << i18n("Meeting") << i18n("Phone Call") << i18n("Education") << i18n("Holiday") << i18n("Vacation") << i18n("Special Occasion") << i18n("Personal") << i18n("Travel") << i18n("Miscellaneous") << i18n("Birthday"); QStringList::Iterator it; for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { setCategoryColor(*it,mDefaultCategoryColor); } } void KOPrefs::usrReadConfig() { config()->setGroup("General"); mCustomCategories = config()->readListEntry("Custom Categories"); if (mCustomCategories.isEmpty()) setCategoryDefaults(); config()->setGroup("Personal Settings"); mName = config()->readEntry("user_name",""); mEmail = config()->readEntry("user_email",""); fillMailDefaults(); mHoliday = config()->readEntry("Holidays", KGlobal::locale()->country()); config()->setGroup("Category Colors"); QStringList::Iterator it; for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); } if (mTimeZoneId.isEmpty()) { setTimeZoneIdDefault(); } } void KOPrefs::usrWriteConfig() { config()->setGroup("General"); config()->writeEntry("Custom Categories",mCustomCategories); config()->setGroup("Personal Settings"); config()->writeEntry("user_name",mName); config()->writeEntry("user_email",mEmail); config()->writeEntry("Holidays",mHoliday); config()->setGroup("Category Colors"); QDictIterator it(mCategoryColors); while (it.current()) { config()->writeEntry(it.currentKey(),*(it.current())); ++it; } } void KOPrefs::setCategoryColor(QString cat,const QColor & color) { mCategoryColors.replace(cat,new QColor(color)); } QColor *KOPrefs::categoryColor(QString cat) { QColor *color = 0; if (!cat.isEmpty()) color = mCategoryColors[cat]; if (color) return color; else return &mDefaultCategoryColor; } void KOPrefs::setFullName(const QString &name) { mName = name; } void KOPrefs::setEmail(const QString &email) { mEmail = email; } QString KOPrefs::fullName() { if (mEmailControlCenter) { KEMailSettings settings; return settings.getSetting(KEMailSettings::RealName); } else { return mName; } } QString KOPrefs::email() { if (mEmailControlCenter) { KEMailSettings settings; return settings.getSetting(KEMailSettings::EmailAddress); } else { return mEmail; } } Index: trunk/kdepim/korganizer/outgoingdialog.h =================================================================== --- trunk/kdepim/korganizer/outgoingdialog.h (revision 123089) +++ trunk/kdepim/korganizer/outgoingdialog.h (revision 123090) @@ -1,70 +1,71 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef OUTGOINGDIALOG_H #define OUTGOINGDIALOG_H // $Id$ #include #include #include "outgoingdialog_base.h" using namespace KCal; class ScheduleItemOut : public QListViewItem { public: ScheduleItemOut(QListView *parent,Event *ev,Scheduler::Method method, const QString &recipients=QString::null); virtual ~ScheduleItemOut() {} Event *event() { return mEvent; } Scheduler::Method method() { return mMethod; } QString recipients() { return mRecipients; } private: Event *mEvent; Scheduler::Method mMethod; QString mRecipients; }; class OutgoingDialog : public OutgoingDialog_base -{ +{ Q_OBJECT public: OutgoingDialog(Calendar *,QWidget* parent=0,const char* name=0, bool modal=false,WFlags fl=0); ~OutgoingDialog(); bool addMessage(Event *,Scheduler::Method); bool addMessage(Event *,Scheduler::Method,const QString &recipients); signals: void numMessagesChanged(int); protected slots: void send(); - + void showEvent(QListViewItem *); + private: Calendar *mCalendar; Scheduler *mScheduler; }; #endif // OUTGOINGDIALOG_H Index: trunk/kdepim/korganizer/incomingdialog.h =================================================================== --- trunk/kdepim/korganizer/incomingdialog.h (revision 123089) +++ trunk/kdepim/korganizer/incomingdialog.h (revision 123090) @@ -1,76 +1,97 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef INCOMINGDIALOG_H #define INCOMINGDIALOG_H // $Id$ #include #include #include #include "incomingdialog_base.h" using namespace KCal; class ScheduleItemIn : public QListViewItem { public: ScheduleItemIn(QListView *parent,Incidence *ev,Scheduler::Method method, ScheduleMessage::Status status); virtual ~ScheduleItemIn() {} Incidence *event() { return mEvent; } Scheduler::Method method() { return mMethod; } ScheduleMessage::Status status() { return mStatus; } private: Incidence *mEvent; Scheduler::Method mMethod; ScheduleMessage::Status mStatus; }; +/** + This class provides the initialisation of a ScheduleItemIn for calendar + components using the Incidence::Visitor. +*/ +class ScheduleItemVisitor : public Incidence::Visitor +{ + public: + ScheduleItemVisitor(ScheduleItemIn *); + ~ScheduleItemVisitor(); + + bool visit(Event *); + bool visit(Todo *); + bool visit(Journal *); + + private: + ScheduleItemIn *mItem; +}; + + + class IncomingDialog : public IncomingDialog_base -{ +{ Q_OBJECT public: IncomingDialog(Calendar *calendar,QWidget* parent=0,const char* name=0, bool modal=false,WFlags fl=0); ~IncomingDialog(); signals: void calendarUpdated(); void numMessagesChanged(int); protected slots: void retrieve(); void acceptAllMessages(); void acceptMessage(); void rejectMessage(); + void showEvent(QListViewItem *); protected: bool acceptMessage(ScheduleItemIn *item); private: Calendar *mCalendar; Scheduler *mScheduler; }; #endif // INCOMINGDIALOG_H Index: trunk/kdepim/korganizer/koprefsdialog.cpp =================================================================== --- trunk/kdepim/korganizer/koprefsdialog.cpp (revision 123089) +++ trunk/kdepim/korganizer/koprefsdialog.cpp (revision 123090) @@ -1,627 +1,636 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ // $Id$ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "koprefs.h" #include "koprefsdialog.h" #include "koprefsdialog.moc" KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : KPrefsDialog(KOPrefs::instance(),parent,name,modal) { mCategoryDict.setAutoDelete(true); setupMainTab(); setupTimeTab(); setupFontsTab(); setupColorsTab(); setupViewsTab(); setupPrinterTab(); setupGroupSchedulingTab(); } KOPrefsDialog::~KOPrefsDialog() { } void KOPrefsDialog::setupMainTab() { QFrame *topFrame = addPage(i18n("Personal"),0, DesktopIcon("identity",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,6,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); topLayout->addWidget(new QLabel(i18n("Your name:"),topFrame),0,0); mNameEdit = new QLineEdit(topFrame); topLayout->addWidget(mNameEdit,0,1); topLayout->addWidget(new QLabel(i18n("Email address:"),topFrame),1,0); mEmailEdit = new QLineEdit(topFrame); topLayout->addWidget(mEmailEdit,1,1); KPrefsWidBool *emailControlCenter = addWidBool(i18n("Use Email settings from Control Center"), &(KOPrefs::instance()->mEmailControlCenter),topFrame); topLayout->addMultiCellWidget(emailControlCenter->checkBox(),3,3,0,1); connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), SLOT(toggleEmailSettings(bool))); KPrefsWidBool *bcc = addWidBool(i18n("Send copy to owner when mailing events"), &(KOPrefs::instance()->mBcc),topFrame); topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); mHolidayList << QString::null; QStringList countryList = KGlobal::dirs()->findAllResources("data", "korganizer/holiday_*", false, true); for ( QStringList::Iterator it = countryList.begin(); it != countryList.end(); ++it ) mHolidayList << (*it).mid((*it).findRev('_') + 1); topLayout->addWidget(new QLabel(i18n("Holidays:"),topFrame),5,0); mHolidayCombo = new QComboBox(topFrame); mHolidayCombo->insertStringList(mHolidayList); topLayout->addWidget(mHolidayCombo,5,1); QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); addWidBool(i18n("Enable automatic saving of calendar"), &(KOPrefs::instance()->mAutoSave),autoSaveGroup); QHBox *intervalBox = new QHBox(autoSaveGroup); intervalBox->setSpacing(spacingHint()); (void)new QLabel(i18n("Save interval in minutes:"),intervalBox); mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); KPrefsWidBool *confirmCheck = addWidBool(i18n("Confirm Deletes"),&(KOPrefs::instance()->mConfirm), topFrame); topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); mEnableGroupScheduling = addWidBool(i18n("Enable Group Scheduling"), &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), SLOT(warningGroupScheduling())); mEnableProjectView = addWidBool(i18n("Enable Project View"), &(KOPrefs::instance()->mEnableProjectView),topFrame); topLayout->addWidget(mEnableProjectView->checkBox(),9,0); connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), SLOT(warningProjectView())); // Can't be disabled anymore mEnableGroupScheduling->checkBox()->hide(); // Disable setting, because this feature now becomes stable mEnableProjectView->checkBox()->hide(); KPrefsWidRadios *defaultFormatGroup = addWidRadios(i18n("Default Calendar Format"), &(KOPrefs::instance()->mDefaultFormat),topFrame); defaultFormatGroup->addRadio(i18n("vCalendar")); defaultFormatGroup->addRadio(i18n("iCalendar")); topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); // Default format unconditionally is iCalendar defaultFormatGroup->groupBox()->hide(); KPrefsWidRadios *mailClientGroup = addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), topFrame); mailClientGroup->addRadio(i18n("KMail")); mailClientGroup->addRadio(i18n("Sendmail")); topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); KPrefsWidBool *alarmdAutostart = addWidBool(i18n("Automatically Start Alarm Dameon on Login"), &(KOPrefs::instance()->mAlarmdAutostart),topFrame); topLayout->addMultiCellWidget(alarmdAutostart->checkBox(),12,12,0,1); topLayout->setRowStretch(13,1); } void KOPrefsDialog::setupTimeTab() { QFrame *topFrame = addPage(i18n("Time & Date"),0, DesktopIcon("clock",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); topLayout->addWidget(new QLabel(i18n("TimeZone:"),topFrame),0,0); mTimeZoneCombo = new QComboBox(topFrame); topLayout->addWidget(mTimeZoneCombo,0,1); FILE *f; char tempstring[101] = "Unknown"; char szCurrentlySet[101] = "Unknown"; QStrList list; // read the currently set time zone if((f = fopen("/etc/timezone", "r")) != NULL) { // get the currently set timezone fgets(szCurrentlySet, 100, f); fclose(f); } mTimeZoneCombo->insertItem(i18n("[No selection]")); // Read all system time zones f = popen("grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3","r"); if (!f) return; while(fgets(tempstring, 100, f) != NULL) { tempstring[strlen(tempstring)-1] = '\0'; list.inSort(tempstring); } pclose(f); mTimeZoneCombo->insertStrList(&list); topLayout->addWidget(new QLabel(i18n("Default Appointment Time:"), topFrame),1,0); mStartTimeSpin = new QSpinBox(0,23,1,topFrame); mStartTimeSpin->setSuffix(":00"); topLayout->addWidget(mStartTimeSpin,1,1); topLayout->addWidget(new QLabel(i18n("Default duration of new appointment:"), topFrame),2,0); mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); mDefaultDurationSpin->setSuffix(":00"); topLayout->addWidget(mDefaultDurationSpin,2,1); QStringList alarmList; alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") << i18n("15 minutes") << i18n("30 minutes"); topLayout->addWidget(new QLabel(i18n("Default Alarm Time:"),topFrame), 3,0); mAlarmTimeCombo = new QComboBox(topFrame); mAlarmTimeCombo->insertStringList(alarmList); topLayout->addWidget(mAlarmTimeCombo,3,1); QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, i18n("Working Hours"), topFrame); topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1); QHBox *workStartBox = new QHBox(workingHoursGroup); addWidTime(i18n("Daily Starting Hour:"), &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); QHBox *workEndBox = new QHBox(workingHoursGroup); addWidTime(i18n("Daily Ending Hour:"), &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); addWidBool(i18n("Exclude Holidays"), &(KOPrefs::instance()->mExcludeHolidays),workingHoursGroup); addWidBool(i18n("Exclude Saturdays"), &(KOPrefs::instance()->mExcludeSaturdays),workingHoursGroup); KPrefsWidBool *marcusBainsShowSeconds = addWidBool(i18n("Shows seconds on Marcus Bains Line"), &(KOPrefs::instance()->mMarcusBainsShowSeconds), topFrame); topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); topLayout->setRowStretch(6,1); } void KOPrefsDialog::setupViewsTab() { QFrame *topFrame = addPage(i18n("Views"),0, DesktopIcon("viewmag",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); QBoxLayout *dayBeginsLayout = new QHBoxLayout; topLayout->addLayout(dayBeginsLayout,1,0); KPrefsWidTime *dayBegins = addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), topFrame); dayBeginsLayout->addWidget(dayBegins->label()); dayBeginsLayout->addStretch(1); dayBeginsLayout->addWidget(dayBegins->spinBox()); // TODO: make hour size work QGroupBox *hourSizeGroup = new QGroupBox(1,Horizontal, i18n("Hour size in schedule view"), topFrame); mHourSizeSlider = new QSlider(0,100,5,10,Horizontal,hourSizeGroup); topLayout->addMultiCellWidget(hourSizeGroup,1,1,0,1); // Disable hour size setting because it is not used. Has to be fixed. hourSizeGroup->hide(); KPrefsWidBool *dailyRecur = addWidBool(i18n("Show events that recur daily in Date Navigator"), &(KOPrefs::instance()->mDailyRecur),topFrame); topLayout->addWidget(dailyRecur->checkBox(),2,0); KPrefsWidBool *weeklyRecur = addWidBool(i18n("Show events that recur weekly in Date Navigator"), &(KOPrefs::instance()->mWeeklyRecur),topFrame); topLayout->addWidget(weeklyRecur->checkBox(),3,0); KPrefsWidBool *enableToolTips = addWidBool(i18n("Enable ToolTips displaying summary of events"), &(KOPrefs::instance()->mEnableToolTips),topFrame); topLayout->addWidget(enableToolTips->checkBox(),4,0); KPrefsWidBool *enableMonthScroll = addWidBool(i18n("Enable Scrollbars in Month View cells"), &(KOPrefs::instance()->mEnableMonthScroll),topFrame); topLayout->addWidget(enableMonthScroll->checkBox(),5,0); KPrefsWidBool *fullViewMonth = addWidBool(i18n("Month View uses full window"), &(KOPrefs::instance()->mFullViewMonth),topFrame); topLayout->addWidget(fullViewMonth->checkBox(),8,0); KPrefsWidBool *fullViewTodo = addWidBool(i18n("Todo View uses full window"), &(KOPrefs::instance()->mFullViewTodo),topFrame); topLayout->addWidget(fullViewTodo->checkBox(),9,0); KPrefsWidBool *marcusBainsEnabled = addWidBool(i18n("Show Marcus Bains line."), &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); topLayout->addWidget(marcusBainsEnabled->checkBox(),10,0); topLayout->setRowStretch(11,1); } void KOPrefsDialog::setupFontsTab() { QFrame *topFrame = addPage(i18n("Fonts"),0, DesktopIcon("fonts",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); KPrefsWidFont *timeBarFont = addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time Bar"), &(KOPrefs::instance()->mTimeBarFont),topFrame); topLayout->addWidget(timeBarFont->preview(),0,0); topLayout->addWidget(timeBarFont->button(),0,1); KPrefsWidFont *monthViewFont = addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event Text"), i18n("Month View"),&(KOPrefs::instance()->mMonthViewFont),topFrame); topLayout->addWidget(monthViewFont->preview(),1,0); topLayout->addWidget(monthViewFont->button(),1,1); KPrefsWidFont *agendaViewFont = addWidFont(i18n("Event Text"),i18n("Agenda View"), &(KOPrefs::instance()->mAgendaViewFont),topFrame); topLayout->addWidget(agendaViewFont->preview(),2,0); topLayout->addWidget(agendaViewFont->button(),2,1); KPrefsWidFont *marcusBainsFont = addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("Marcus Bains Line"), &(KOPrefs::instance()->mMarcusBainsFont),topFrame); topLayout->addWidget(marcusBainsFont->preview(),3,0); topLayout->addWidget(marcusBainsFont->button(),3,1); topLayout->setRowStretch(4,1); } void KOPrefsDialog::setupColorsTab() { QFrame *topFrame = addPage(i18n("Colors"),0, DesktopIcon("colorize",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); // Holiday Color KPrefsWidColor *holidayColor = addWidColor(i18n("Holiday Color"), &(KOPrefs::instance()->mHolidayColor),topFrame); topLayout->addWidget(holidayColor->preview(),0,0); topLayout->addWidget(holidayColor->button(),0,1); // Highlight Color KPrefsWidColor *highlightColor = addWidColor(i18n("Highlight Color"), &(KOPrefs::instance()->mHighlightColor),topFrame); topLayout->addWidget(highlightColor->preview(),1,0); topLayout->addWidget(highlightColor->button(),1,1); // Event color KPrefsWidColor *eventColor = addWidColor(i18n("Default Event Color"), &(KOPrefs::instance()->mEventColor),topFrame); topLayout->addWidget(eventColor->preview(),2,0); topLayout->addWidget(eventColor->button(),2,1); // agenda view background color KPrefsWidColor *agendaBgColor = addWidColor(i18n("Agenda View Background Color"), &(KOPrefs::instance()->mAgendaBgColor),topFrame); topLayout->addWidget(agendaBgColor->preview(),3,0); topLayout->addWidget(agendaBgColor->button(),3,1); // working hours color KPrefsWidColor *workingHoursColor = addWidColor(i18n("Working Hours Color"), &(KOPrefs::instance()->mWorkingHoursColor),topFrame); topLayout->addWidget(workingHoursColor->preview(),4,0); topLayout->addWidget(workingHoursColor->button(),4,1); // categories colors QGroupBox *categoryGroup = new QGroupBox(1,Horizontal,i18n("Categories"), topFrame); topLayout->addMultiCellWidget(categoryGroup,5,5,0,1); mCategoryCombo = new QComboBox(categoryGroup); mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); QHBox *categoryBox = new QHBox(categoryGroup); categoryBox->setSpacing(spacingHint()); mCategoryColor = new QFrame(categoryBox); mCategoryColor->setFrameStyle(QFrame::Panel|QFrame::Plain); QPushButton *categoryButton = new QPushButton(i18n("Select Color"), categoryBox); connect(categoryButton,SIGNAL(clicked()),SLOT(selectCategoryColor())); updateCategoryColor(); topLayout->setRowStretch(6,1); } void KOPrefsDialog::selectCategoryColor() { QColor myColor(mCategoryColor->backgroundColor()); int result = KColorDialog::getColor( myColor ); if ( result == KColorDialog::Accepted ) { mCategoryColor->setBackgroundColor(myColor); mCategoryDict.insert(mCategoryCombo->currentText(),new QColor(myColor)); } } void KOPrefsDialog::updateCategoryColor() { QString cat = mCategoryCombo->currentText(); QColor *color = mCategoryDict.find(cat); if (!color) { color = KOPrefs::instance()->categoryColor(cat); } if (color) { mCategoryColor->setBackgroundColor(*color); } } void KOPrefsDialog::setupPrinterTab() { mPrinterTab = addPage(i18n("Printing"),0, DesktopIcon("fileprint",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); topLayout->addWidget(new QLabel(i18n("Preview Program:"),mPrinterTab),3,0); mPrintPreviewEdit = new KURLRequester(mPrinterTab); topLayout->addWidget(mPrintPreviewEdit,3,1); topLayout->setRowStretch(4,1); } void KOPrefsDialog::setupGroupSchedulingTab() { QFrame *topFrame = addPage(i18n("Group Scheduling"),0, DesktopIcon("personal",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,5,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); KPrefsWidRadios *schedulerGroup = - addWidRadios(i18n("Scheduler"),&(KOPrefs::instance()->mIMIPScheduler), + addWidRadios(i18n("Scheduler mail client"),&(KOPrefs::instance()->mIMIPScheduler), topFrame); schedulerGroup->addRadio(i18n("Dummy")); schedulerGroup->addRadio(i18n("Mail Client")); topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); - topLayout->setRowStretch(1,1); + KPrefsWidRadios *sendGroup = + addWidRadios(i18n("Scheduler mails should be"),&(KOPrefs::instance()->mIMIPSend), + topFrame); + sendGroup->addRadio(i18n("send to outbox")); + sendGroup->addRadio(i18n("send directly")); + + topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); + + + topLayout->setRowStretch(2,1); } void KOPrefsDialog::showPrinterTab() { showPage(pageIndex(mPrinterTab)); } void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, const QStringList *tags) { if (tags) { int i = tags->findIndex(text); if (i > 0) combo->setCurrentItem(i); } else { for(int i=0;icount();++i) { if (combo->text(i) == text) { combo->setCurrentItem(i); break; } } } } void KOPrefsDialog::usrReadConfig() { mNameEdit->setText(KOPrefs::instance()->fullName()); mEmailEdit->setText(KOPrefs::instance()->email()); mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); setCombo(mHolidayCombo,KOPrefs::instance()->mHoliday, &mHolidayList); setCombo(mTimeZoneCombo,KOPrefs::instance()->mTimeZoneId); mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); mHourSizeSlider->setValue(KOPrefs::instance()->mHourSize); mPrintPreviewEdit->lineEdit()->setText(KOPrefs::instance()->mPrintPreview); } void KOPrefsDialog::usrWriteConfig() { KOPrefs::instance()->setFullName(mNameEdit->text()); KOPrefs::instance()->setEmail(mEmailEdit->text()); KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); KOPrefs::instance()->mHoliday = *mHolidayList.at(mHolidayCombo->currentItem()); kdDebug() << "Holiday: " << KOPrefs::instance()->mHoliday << endl; KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); KOPrefs::instance()->mHourSize = mHourSizeSlider->value(); QDictIterator it(mCategoryDict); while (it.current()) { KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); ++it; } mCategoryDict.clear(); KOPrefs::instance()->mPrintPreview = mPrintPreviewEdit->lineEdit()->text(); } void KOPrefsDialog::updateCategories() { mCategoryCombo->clear(); mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); updateCategoryColor(); } void KOPrefsDialog::warningGroupScheduling() { warningExperimental(mEnableGroupScheduling->checkBox()->isChecked()); } void KOPrefsDialog::warningProjectView() { warningExperimental(mEnableProjectView->checkBox()->isChecked()); } void KOPrefsDialog::warningExperimental(bool on) { if (on) { KMessageBox::information(this,"This is an experimental feature. " "It may not work, it may do nothing useful and it may cause data loss. " "Use with care.\n" "You have to restart KOrganizer for this setting to take effect."); } else { KMessageBox::information(this, "You have to restart KOrganizer for this setting to take effect."); } } void KOPrefsDialog::toggleEmailSettings(bool on) { if (on) { mEmailEdit->setEnabled(false); mNameEdit->setEnabled(false); KEMailSettings settings; mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); } else { mEmailEdit->setEnabled(true); mNameEdit->setEnabled(true); } }