-rw-r--r-- | korganizer/calendarview.cpp | 15 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kofilterview.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 7 |
5 files changed, 16 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 70a1d2d..678143d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -93,992 +93,997 @@ #include "calprinter.h" #endif #ifndef KORG_NOPLUGINS #include "kocore.h" #endif #include "koeventeditor.h" #include "kotodoeditor.h" #include "koprefs.h" #include "koeventviewerdialog.h" #include "publishdialog.h" #include "kofilterview.h" #include "koglobals.h" #include "koviewmanager.h" #include "koagendaview.h" #include "kodialogmanager.h" #include "outgoingdialog.h" #include "incomingdialog.h" #include "datenavigatorcontainer.h" #include "statusdialog.h" #include "kdatenavigator.h" #include "kotodoview.h" #include "datenavigator.h" #include "resourceview.h" #include "navigatorbar.h" #include "searchdialog.h" #include "mainwindow.h" #include "categoryeditdialog.h" #include "calendarview.h" #ifndef DESKTOP_VERSION #include <qtopia/alarmserver.h> #endif #ifndef _WIN32_ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #else #include <qprocess.h> #endif #ifdef DESKTOP_VERSION #include <kabc/stdaddressbook.h> #endif using namespace KOrg; using namespace KCal; extern int globalFlagBlockAgenda; extern int globalFlagBlockStartup; MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) { mAlarms = alarms; viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); QString mText = "<table width=\"100%\">\n"; //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; #ifdef DESKTOP_VERSION mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; #else mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; #endif // mText += "<img src=\""; // mText += ipath; // mText += "\">"; //mEventDate = QDate::currentDate(); #ifdef DESKTOP_VERSION mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; #else mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; #endif //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; Incidence * inc = getNextInc( start ); int time = 0; //mText += "<table>"; while ( inc ) { QDateTime dt ; QString tempText = "<a "; bool ok; dt = inc->getNextOccurence( start, &ok ); if ( !ok ) continue; if ( inc->typeID() == eventID ) { tempText += "href=\"event:"; } else if ( inc->typeID() == todoID ) { tempText += "href=\"todo:"; } tempText += inc->uid() + "\">"; if ( inc->typeID() == todoID ) tempText += i18n("Todo: "); if ( inc->summary().length() > 0 ) tempText += inc->summary(); else tempText += i18n("-no summary-"); QString timestr; if (!inc->doesFloat()) timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; else timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; if ( dt.date() < QDate::currentDate() && time == 0 ) { mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; mText += "<table>"; time = 1; } if ( dt.date() == QDate::currentDate() && time <= 1 ) { if ( time > 0 ) mText +="</table>"; mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; mText += "<table>"; time = 2; } if ( dt.date() > QDate::currentDate() && time <= 2 ) { if ( time > 0 ) mText +="</table>"; mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; mText += "<table>"; time = 3; } mText +="<tr><td><b>"; mText += timestr; mText += "</b></td><td>"; mText += tempText; mText += "</td></tr>\n"; inc = getNextInc( start ); } mText +="</table>"; setText( mText ); } MissedAlarmTextBrowser::~MissedAlarmTextBrowser() { //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); } Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) { QDateTime dt ; Incidence * retInc; Incidence * inc = mAlarms.first(); if ( inc == 0 ) return 0; bool ok; dt = inc->getNextOccurence( start, &ok ); if ( ! ok ) return 0; QDateTime dtn ; retInc = inc; inc = mAlarms.next(); while ( inc ) { dtn = inc->getNextOccurence( start, &ok ); if ( ! ok ) return 0; if ( dtn < dt ) { dt = dtn; retInc = inc; } inc = mAlarms.next(); } mAlarms.remove( retInc ); return retInc; } void MissedAlarmTextBrowser::setSource(const QString & n) { if (n.startsWith("event:")) { #ifdef DESKTOP_VERSION emit showIncidence(n.mid(8)); #else emit showIncidence(n.mid(6)); #endif return; } else if (n.startsWith("todo:")) { #ifdef DESKTOP_VERSION emit showIncidence(n.mid(7)); #else emit showIncidence(n.mid(5)); #endif return; } } class KOBeamPrefs : public QDialog { public: KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Beam Options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); lay->addWidget( time ); time->setExclusive ( true ) ; vcal = new QRadioButton(" vCalendar ", format ); ical = new QRadioButton(" iCalendar ", format ); vcal->setChecked( true ); tz = new QRadioButton(i18n(" With timezone "), time ); local = new QRadioButton(i18n(" Local time "), time ); tz->setChecked( true ); QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } bool beamVcal() { return vcal->isChecked(); } bool beamLocal() { return local->isChecked(); } private: QRadioButton* vcal, *ical, *local, *tz; }; class KOCatPrefs : public QDialog { public: KOCatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Manage new Categories") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; addCatBut = new QRadioButton(i18n("Add to category list"), format ); new QRadioButton(i18n("Remove from Events/Todos"), format ); addCatBut->setChecked( true ); QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } bool addCat() { return addCatBut->isChecked(); } private: QRadioButton* addCatBut; }; CalendarView::CalendarView( CalendarResources *calendar, QWidget *parent, const char *name ) : CalendarViewBase( parent, name ), mCalendar( calendar ), mResourceManager( calendar->resourceManager() ) { mEventEditor = 0; mTodoEditor = 0; init(); } CalendarView::CalendarView( Calendar *calendar, QWidget *parent, const char *name ) : CalendarViewBase( parent, name ), mCalendar( calendar ), mResourceManager( 0 ) { mEventEditor = 0; mTodoEditor = 0; init(); } void CalendarView::init() { mNextAlarmDateTime = QDateTime::currentDateTime(); setFocusPolicy ( NoFocus ); mViewerCallerIsSearchDialog = false; mBlockShowDates = false; mDatePickerMode = 0; mCurrentSyncDevice = ""; mViewManager = new KOViewManager( this ); mDialogManager = new KODialogManager( this ); mEventViewerDialog = 0; mModified = false; mReadOnly = false; mSelectedIncidence = 0; mCalPrinter = 0; mFilters.setAutoDelete(true); mCalendar->registerObserver( this ); // TODO: Make sure that view is updated, when calendar is changed. mStorage = new FileStorage( mCalendar ); mNavigator = new DateNavigator( this, "datevav", mViewManager ); QBoxLayout *topLayout = (QBoxLayout*)layout(); #ifndef KORG_NOSPLITTER // create the main layout frames. mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); topLayout->addWidget(mPanner); mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, "CalendarView::LeftFrame"); mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); mDateNavigator = new DateNavigatorContainer( mLeftSplitter, "CalendarView::DateNavigator" ); mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); mTodoList->setNavigator( mNavigator ); mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); #ifdef KORG_NORESOURCEVIEW mResourceView = 0; #else if ( mResourceManager ) { mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); mResourceView->updateView(); connect( mResourceView, SIGNAL( resourcesChanged() ), SLOT( updateView() ) ); } else { mResourceView = 0; } #endif QWidget *rightBox = new QWidget( mPanner ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mRightFrame, 1 ); mLeftFrame = mLeftSplitter; #else //QWidget *mainBox = new QWidget( this ); //QWidget *leftFrame = new QWidget( mainBox ); //QBoxLayout * mainBoxLayout; if ( KOPrefs::instance()->mVerticalScreen ) { //mainBoxLayout = new QVBoxLayout(mainBox); //leftFrameLayout = new QHBoxLayout(leftFrame ); mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); } else { //mainBoxLayout = new QHBoxLayout(mainBox); //leftFrameLayout = new QVBoxLayout(leftFrame ); mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); } mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); //QBoxLayout * leftFrameLayout; topLayout->addWidget( mMainFrame ); #ifdef DESKTOP_VERSION mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); topLayout->addWidget( mDateScrollBar ); connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); if ( QApplication::desktop()->width() < 800 ) mDateScrollBar->hide(); #endif //mainBoxLayout->addWidget (mLeftFrame); mDateNavigator = new DateNavigatorContainer( mLeftFrame, "CalendarView::DateNavigator" ); #if 0 // FIXME mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, "CalendarView::DateNavigator", QDate::currentDate()); #endif // mDateNavigator->blockSignals( true ); //leftFrameLayout->addWidget( mDateNavigator ); mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); + connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); mTodoList->setNavigator( mNavigator ); #if 0 if ( QApplication::desktop()->width() < 480 ) { leftFrameLayout->addWidget(mFilterView); leftFrameLayout->addWidget(mTodoList, 2 ); } else { leftFrameLayout->addWidget(mTodoList,2 ); leftFrameLayout->addWidget(mFilterView ); } #endif mFilterView->hide(); mCalEditView->hide(); QWidget *rightBox = new QWidget( mMainFrame ); //mainBoxLayout->addWidget ( rightBox, 10 ); QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); mRightFrame = new QWidgetStack( rightBox ); rightLayout->addWidget( mRightFrame, 10 ); //mLeftFrame = (QWidget *)leftFrame; if ( KOPrefs::instance()->mVerticalScreen ) { //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); } else { //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); } if ( !KOPrefs::instance()->mShowDateNavigator) mDateNavigator->hide(); //qDebug("Calendarview Size %d %d ", width(), height()); #endif connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( showDates( const KCal::DateList & ) ) ); connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), mViewManager, SLOT( showMonth( const QDate & ) ) ); connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), mNavigator, SLOT( selectWeek( const QDate & ) ) ); connect( mDateNavigator, SIGNAL( goPrevYear() ), mNavigator, SLOT( selectPreviousYear() ) ); connect( mDateNavigator, SIGNAL( goNextYear() ), mNavigator, SLOT( selectNextYear() ) ); connect( mDateNavigator, SIGNAL( goPrevMonth() ), mNavigator, SLOT( selectPreviousMonth() ) ); connect( mDateNavigator, SIGNAL( goNextMonth() ), mNavigator, SLOT( selectNextMonth() ) ); connect( mDateNavigator, SIGNAL( goPrevious() ), mNavigator, SLOT( selectPrevious() ) ); connect( mDateNavigator, SIGNAL( goNext() ), mNavigator, SLOT( selectNext() ) ); connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), mNavigator, SLOT( slotMonthSelect( int ) ) ); connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); #if 0 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), SLOT( incidenceAdded( Incidence *) ) ); #endif // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); connect( this, SIGNAL( configChanged() ), mDateNavigator, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( newTodoSignal() ), SLOT( newTodo() ) ); connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), SLOT( newSubTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), SLOT( editTodo( Todo * ) ) ); connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), SLOT( showTodo( Todo *) ) ); connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), SLOT( deleteTodo( Todo *) ) ); connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); connect( mTodoList, SIGNAL( purgeCompletedSignal() ), SLOT( purgeCompleted() ) ); connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), SIGNAL( todoModified( Todo *, int ) ) ); connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), this, SLOT ( cloneIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), this, SLOT (cancelIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), this, SLOT ( moveIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), this, SLOT ( beamIncidence( Incidence * ) ) ); connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), this, SLOT ( todo_unsub( Todo * ) ) ); connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), this, SLOT ( todo_resub( Todo *,Todo * ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, SLOT( updateTodo( Todo *, int ) ) ); connect( this, SIGNAL( todoModified( Todo *, int )), this, SLOT( changeTodoDisplay( Todo *, int ) ) ); connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); connect(QApplication::clipboard(),SIGNAL(dataChanged()), SLOT(checkClipboard())); connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processTodoListSelection( Incidence * ) ) ); connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); // kdDebug() << "CalendarView::CalendarView() done" << endl; mDateFrame = new QVBox(0,0,WType_Popup); //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); mDateFrame->setLineWidth(3); mDateFrame->hide(); mDateFrame->setCaption( i18n( "Pick a date to display")); mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); mEventEditor = mDialogManager->getEventEditor(); mTodoEditor = mDialogManager->getTodoEditor(); mFlagEditDescription = false; mSuspendTimer = new QTimer( this ); mAlarmTimer = new QTimer( this ); mRecheckAlarmTimer = new QTimer( this ); connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); mAlarmDialog = new AlarmDialog( this ); connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); mAlarmDialog->setServerNotification( false ); mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); #ifndef DESKTOP_VERSION //US listen for arriving address resultsets connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); #endif mDateNavigator->setCalendar( mCalendar ); } CalendarView::~CalendarView() { // kdDebug() << "~CalendarView()" << endl; //qDebug("CalendarView::~CalendarView() "); delete mDialogManager; delete mViewManager; delete mStorage; delete mDateFrame ; delete mEventViewerDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::setScrollBarStep(int val ) { #ifdef DESKTOP_VERSION mDateScrollBar->setLineStep ( val ); #endif } void CalendarView::scrollBarValue(int val ) { #ifdef DESKTOP_VERSION if ( QApplication::desktop()->width() < 800 ) return; static bool block = false; if ( block ) return; block = true; val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); //qDebug("VAL %d ",val ); int count = mNavigator->selectedDates().count(); int year = mNavigator->selectedDates().first().year(); int day = mNavigator->selectedDates().first().dayOfYear(); if ( val == day -1 ) { block = false; return; } QDate d ( year,1,1 ); mNavigator->selectDates( d.addDays( val ), count ); block = false; #endif } - -void CalendarView::checkAlarms() +void CalendarView::checkFiles() { - QString message; QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; KopiCalendarFile * cal = calendars.first(); while ( cal ) { if ( cal->mErrorOnLoad ) { message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; } cal = calendars.next(); } if ( !message.isEmpty() ) { - message = KGlobal::formatMessage( i18n("The loading of one or more calendar failed:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); - KMessageBox::error(this,message); + message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); + KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); + } + QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); } +void CalendarView::checkAlarms() +{ + + KConfig *config = KOGlobals::config(); config->setGroup( "AppRun" ); QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); int daysto = dt.daysTo( QDate::currentDate() ); int days = config->readNumEntry( "LatestProgramStopDays" , daysto); dt = dt.addDays( days ); int secto = dt.secsTo( QDateTime::currentDateTime() ); int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; //qDebug("KO: Reading program stop %d ", secs); //secs -= ( 3600 * 24*3 ); // debug only QDateTime latest = dt.addSecs ( secs ); qDebug("KO: Last termination on %s ", latest.toString().latin1()); //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); QPtrList<Incidence> el = mCalendar->rawIncidences(); QPtrList<Incidence> al; Incidence* inL = el.first(); QDateTime cur = QDateTime::currentDateTime().addSecs(-59); qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); while ( inL ) { bool ok = false; int offset = 0; QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; if ( ok ) { //qDebug("OK %s",next.toString().latin1()); if ( next < cur ) { al.append( inL ); //qDebug("found missed alarm: %s ", inL->summary().latin1() ); } } inL = el.next(); } if ( al.count() ) { QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); dia->setCaption( i18n("KO/Pi: Missing alarms!") ); QVBoxLayout* lay = new QVBoxLayout( dia ); lay->setSpacing( 0 ); lay->setMargin( 0 ); MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); lay->addWidget( matb ); if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { int wid = 210; int x = QApplication::desktop()->width() - wid - 7; int y = QApplication::desktop()->height() - wid - 70; dia->setGeometry ( x,y,wid,wid); } else { int si = 220; if ( QApplication::desktop()->width() > 470 ) si = 400; dia->resize(si,si/2); } dia->setBackgroundColor( QColor( 255, 255, 255 ) ); dia->show(); } } void CalendarView::showDay( QDate d ) { dateNavigator()->blockSignals( true ); dateNavigator()->selectDate( d ); dateNavigator()->blockSignals( false ); mViewManager->showDayView(); //dateNavigator()->selectDate( d ); } void CalendarView::timerAlarm() { //qDebug("CalendarView::timerAlarm() "); computeAlarm(mAlarmNotification ); } void CalendarView::suspendAlarm() { //qDebug(" CalendarView::suspendAlarm() "); computeAlarm(mSuspendAlarmNotification ); } void CalendarView::startAlarm( QString mess , QString filename) { topLevelWidget()->showNormal(); topLevelWidget()->setActiveWindow(); topLevelWidget()->raise(); mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); } void CalendarView::checkNextTimerAlarm() { mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::computeAlarm( QString msg ) { QString mess = msg; QString mAlarmMessage = mess.mid( 9 ); QString filename = MainWindow::resourcePath(); filename += "koalarm.wav"; QString tempfilename; if ( mess.left( 13 ) == "suspend_alarm") { bool error = false; int len = mess.mid( 13 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 13, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 13+len+3 ); //qDebug("suspend file %s ",tempfilename.latin1() ); startAlarm( mAlarmMessage, filename); return; } if ( mess.left( 11 ) == "timer_alarm") { //mTimerTime = 0; startAlarm( mess.mid( 11 ), filename ); return; } if ( mess.left( 10 ) == "proc_alarm") { bool error = false; int len = mess.mid( 10 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 10, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( error ) { mAlarmMessage = "Procedure Alarm\nError - File not found\n"; mAlarmMessage += mess.mid( 10+len+3+9 ); } else { //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); //qDebug("-----system command %s ",tempfilename.latin1() ); #ifndef _WIN32_ if ( vfork () == 0 ) { execl ( tempfilename.latin1(), 0 ); return; } #else QProcess* p = new QProcess(); p->addArgument( tempfilename.latin1() ); p->start(); return; #endif return; } //qDebug("+++++++system command %s ",tempfilename.latin1() ); } if ( mess.left( 11 ) == "audio_alarm") { bool error = false; int len = mess.mid( 11 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 11, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 11+len+3+9 ); //qDebug("audio file command %s ",tempfilename.latin1() ); } if ( mess.left( 9 ) == "cal_alarm") { mAlarmMessage = mess.mid( 9 ) ; } startAlarm( mAlarmMessage, filename ); } void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) { //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); mSuspendAlarmNotification = noti; int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); mSuspendTimer->start( ms , true ); } void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) { mNextAlarmDateTime = qdt; //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { #ifndef DESKTOP_VERSION AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); #endif return; } int maxSec; //maxSec = 5; //testing only maxSec = 86400+3600; // one day+1hour mAlarmNotification = noti; int sec = QDateTime::currentDateTime().secsTo( qdt ); if ( sec > maxSec ) { mRecheckAlarmTimer->start( maxSec * 1000 ); // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); return; } else { mRecheckAlarmTimer->stop(); } //qDebug("Alarm timer started with secs: %d ", sec); mAlarmTimer->start( sec *1000 , true ); } // called by mRecheckAlarmTimer to get next alarm // we need this, because a QTimer has only a max range of 25 days void CalendarView::recheckTimerAlarm() { mAlarmTimer->stop(); mRecheckAlarmTimer->stop(); mCalendar->checkAlarmForIncidence( 0, true ); } #ifndef DESKTOP_VERSION void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) #else void CalendarView::removeAlarm(const QDateTime &, const QString & ) #endif { //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { #ifndef DESKTOP_VERSION AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); #endif return; } mAlarmTimer->stop(); } void CalendarView::selectWeekNum ( int num ) { dateNavigator()->blockSignals( true ); dateNavigator()->selectWeek( num ); dateNavigator()->blockSignals( false ); mViewManager->showWeekView(); } KOViewManager *CalendarView::viewManager() { return mViewManager; } KODialogManager *CalendarView::dialogManager() { return mDialogManager; } QDate CalendarView::startDate() { DateList dates = mNavigator->selectedDates(); return dates.first(); } QDate CalendarView::endDate() { DateList dates = mNavigator->selectedDates(); return dates.last(); } void CalendarView::createPrinter() { #ifndef KORG_NOPRINTER if (!mCalPrinter) { mCalPrinter = new CalPrinter(this, mCalendar); connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); } #endif } //KOPrefs::instance()->mWriteBackFile //KOPrefs::instance()->mWriteBackExistingOnly // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) { // 0 equal // 1 take local // 2 take remote // 3 cancel QDateTime lastSync = mLastCalendarSync; QDateTime localMod = local->lastModified(); QDateTime remoteMod = remote->lastModified(); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { bool remCh, locCh; remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); //if ( remCh ) //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); locCh = ( localMod > mLastCalendarSync ); if ( !remCh && ! locCh ) { //qDebug("both not changed "); lastSync = localMod.addDays(1); if ( mode <= SYNC_PREF_ASK ) return 0; } else { if ( locCh ) { //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); lastSync = localMod.addDays( -1 ); if ( !remCh ) remoteMod = ( lastSync.addDays( -1 ) ); } else { //qDebug(" not loc changed "); lastSync = localMod.addDays( 1 ); if ( remCh ) remoteMod =( lastSync.addDays( 1 ) ); } } full = true; if ( mode < SYNC_PREF_ASK ) mode = SYNC_PREF_ASK; } else { if ( localMod == remoteMod ) // if ( local->revision() == remote->revision() ) return 0; } // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); //full = true; //debug only if ( full ) { bool equ = false; if ( local->typeID() == eventID ) { equ = (*((Event*) local) == *((Event*) remote)); } else if ( local->typeID() == todoID ) equ = (*((Todo*) local) == (*(Todo*) remote)); else if ( local->typeID() == journalID ) equ = (*((Journal*) local) == *((Journal*) remote)); if ( equ ) { //qDebug("equal "); if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); } if ( mode < SYNC_PREF_FORCE_LOCAL ) return 0; }//else //debug only //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); } int result; bool localIsNew; //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); // ************************************************ // ************************************************ // ************************************************ // We may have that lastSync > remoteMod AND lastSync > localMod // BUT remoteMod != localMod if ( full && mode < SYNC_PREF_NEWEST ) mode = SYNC_PREF_ASK; switch( mode ) { case SYNC_PREF_LOCAL: if ( lastSync > remoteMod ) return 1; diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index c9e9870..651194b 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -1,587 +1,588 @@ /* This file is part of KOrganizer. Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef CALENDARVIEW_H #define CALENDARVIEW_H #include <qframe.h> #include <qlayout.h> #include <qwidget.h> #include <qptrlist.h> #include <qvbox.h> #include <qmap.h> #include <qscrollbar.h> #ifndef DESKTOP_VERSION #include <qtopia/ir.h> #else #define Ir char #endif #include <libkcal/calendar.h> #include <libkcal/scheduler.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <KDGanttMinimizeSplitter.h> #include <korganizer/calendarviewbase.h> #include <ksyncmanager.h> //#include <koprefs.h> class QWidgetStack; class QSplitter; class KopiCalendarFile; class CalPrinter; class KOFilterView; class KOCalEditView; class KOViewManager; class KODialogManager; class KOTodoView; class KDateNavigator; class DateNavigatorContainer; class DateNavigator; class KOIncidenceEditor; class KDatePicker; class ResourceView; class KOEventEditor; class KOTodoEditor ; class KOEventViewerDialog; class KOBeamPrefs; class KSyncProfile; class AlarmDialog; class KCal::Attendee; namespace KCal { class FileStorage; } using namespace KCal; /** This is the main calendar widget. It provides the different vies on t he calendar data as well as the date navigator. It also handles synchronisation of the different views and controls the different dialogs like preferences, event editor, search dialog etc. @short main calendar view widget @author Cornelius Schumacher */ #include <qtextbrowser.h> #include <qtextcodec.h> class MissedAlarmTextBrowser : public QTextBrowser { Q_OBJECT public: MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); ~MissedAlarmTextBrowser(); void setSource(const QString & n); private: Incidence * getNextInc(QDateTime start ); QPtrList<Incidence> mAlarms; signals: void showIncidence( QString uid); }; class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface { Q_OBJECT public: /** Constructs a new calendar view widget. @param calendar calendar document @param parent parent window @param name Qt internal widget object name */ CalendarView( CalendarResources *calendar, QWidget *parent = 0, const char *name = 0 ); CalendarView( Calendar *calendar, QWidget *parent = 0, const char *name = 0 ); virtual ~CalendarView(); Calendar *calendar() { return mCalendar; } KOViewManager *viewManager(); KODialogManager *dialogManager(); QDate startDate(); QDate endDate(); QWidgetStack *viewStack(); QWidget *leftFrame(); DateNavigator *dateNavigator(); KDateNavigator *dateNavigatorWidget(); void addView(KOrg::BaseView *); void showView(KOrg::BaseView *); KOEventViewerDialog* getEventViewerDialog(); Incidence *currentSelection(); void checkSuspendAlarm(); signals: void save (); void saveStopTimer (); void tempDisableBR(bool); /** This todo has been modified */ void todoModified(Todo *, int); /** when change is made to options dialog, the topwidget will catch this * and emit this signal which notifies all widgets which have registered * for notification to update their settings. */ void configChanged(); /** emitted when the topwidget is closing down, so that any attached child windows can also close. */ void closingDown(); /** emitted right before we die */ void closed(QWidget *); /** Emitted when state of modified flag changes */ void modifiedChanged(bool); void signalmodified(); /** Emitted when state of read-only flag changes */ void readOnlyChanged(bool); /** Emitted when the unit of navigation changes */ void changeNavStringPrev(const QString &); void changeNavStringNext(const QString &); /** Emitted when state of events selection has changed and user is organizer*/ void organizerEventsSelected(bool); /** Emitted when state of events selection has changed and user is attendee*/ void groupEventsSelected(bool); /** Emitted when an incidence gets selected. If the selection is cleared the signal is emitted with 0 as argument. */ void incidenceSelected( Incidence * ); /** Emitted, when a todoitem is selected or deselected. */ void todoSelected( bool ); /** Emitted, when clipboard content changes. Parameter indicates if paste is possible or not. */ void pasteEnabled(bool); /** Emitted, when the number of incoming messages has changed. */ void numIncomingChanged(int); /** Emitted, when the number of outgoing messages has changed. */ void numOutgoingChanged(int); /** Send status message, which can e.g. be displayed in the status bar. */ void statusMessage(const QString &); void calendarViewExpanded( bool ); void updateSearchDialog(); void filtersUpdated(); public slots: void checkAlarms(); + void checkFiles(); void slotprintSelInc(); void showNextAlarms(); void showOpenError(); void watchSavedFile(); void recheckTimerAlarm(); void checkNextTimerAlarm(); void addAlarm(const QDateTime &qdt, const QString ¬i ); void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); void removeAlarm(const QDateTime &qdt, const QString ¬i ); /** options dialog made a changed to the configuration. we catch this * and notify all widgets which need to update their configuration. */ void updateConfig(); void insertBirthdays(const QString& uid, const QStringList& birthdayList, const QStringList& anniversaryList, const QStringList& realNameList, const QStringList& emailList, const QStringList& assembledNameList, const QStringList& uidList); /** Load calendar from file \a filename. If \a merge is true, load calendar into existing one, if it is false, clear calendar, before loading. Return true, if calendar could be successfully loaded. */ bool openCalendar(QString filename, bool merge=false); bool loadCalendars(); bool saveCalendars(); bool restoreCalendarSettings(); bool addCalendar( KopiCalendarFile * ); void addCalendarId( int id ); bool syncCalendar(QString filename,int mode = 0 ); /** Save calendar data to file. Return true if calendar could be successfully saved. */ bool saveCalendar(QString filename); /** Close calendar. Clear calendar data and reset views to display an empty calendar. */ void closeCalendar(); /** Archive old events of calendar */ void archiveCalendar(); void showIncidence(); void editIncidence(); void editIncidenceDescription(); void deleteIncidence(); void cloneIncidence(); void moveIncidence(); void beamIncidence(); void toggleCancelIncidence(); /** create an editeventwin with supplied date/time, and if bool is true, * make the event take all day. */ void newEvent(QDateTime, QDateTime, bool allDay ); void newEvent(QDateTime, QDateTime); void newEvent(QDateTime fh); void newEvent(QDate dt); /** create new event without having a date hint. Takes current date as default hint. */ void newEvent(); void newFloatingEvent(); /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ void showIncidence(Incidence *); void showIncidence(QString uid); /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ void editIncidence(Incidence *); /** Delete the supplied incidence. It calls the correct deleteXXX method*/ void deleteIncidence(Incidence *); void cloneIncidence(Incidence *); void cancelIncidence(Incidence *); /** Create an editor for the supplied event. */ void editEvent(Event *); /** Delete the supplied event. */ void deleteEvent(Event *); /** Delete the event with the given unique ID. Returns false, if event wasn't found. */ bool deleteEvent(const QString &uid); /** Create a read-only viewer dialog for the supplied event. */ void showEvent(Event *); void editJournal(Journal *); void showJournal(Journal *); void deleteJournal(Journal *); /** Create an editor dialog for a todo */ void editTodo(Todo *); /** Create a read-only viewer dialog for the supplied todo */ void showTodo(Todo *); /** create new todo */ void newTodo(); void newTodoDateTime(QDateTime, bool allday); /** create new todo with a parent todo */ void newSubTodo(); /** create new todo with a parent todo */ void newSubTodo(Todo *); /** Delete todo */ void deleteTodo(Todo *); /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is * emitted as result. */ void checkClipboard(); /** using the KConfig associated with the kapp variable, read in the * settings from the config file. */ void readSettings(); /** write current state to config file. */ void writeSettings(); /** read settings for calendar filters */ void readFilterSettings(KConfig *config); /** write settings for calendar filters */ void writeFilterSettings(KConfig *config); /** passes on the message that an event has changed to the currently * activated view so that it can make appropriate display changes. */ void changeEventDisplay(Event *, int); void changeIncidenceDisplay(Incidence *, int); void changeTodoDisplay(Todo *, int); void eventAdded(Event *); void eventChanged(Event *); void eventToBeDeleted(Event *); void eventDeleted(); void todoAdded(Todo *); void todoChanged(Todo *); void todoToBeDeleted(Todo *); void todoDeleted(); void updateView(const QDate &start, const QDate &end); void updateView(); void clearAllViews(); /** Full update of visible todo views */ void updateTodoViews(); void updateUnmanagedViews(); /** cut the current appointment to the clipboard */ void edit_cut(); /** copy the current appointment(s) to the clipboard */ void edit_copy(); /** paste the current vobject(s) in the clipboard buffer into calendar */ void edit_paste(); /** edit viewing and configuration options. */ void edit_options(); void edit_global_options(); /** Functions for printing, previewing a print, and setting up printing parameters. */ void print(); void printSetup(); void printPreview(); /** Export as iCalendar file */ void exportICalendar(); /** Export as vCalendar file */ bool exportVCalendar( QString fn); /** pop up a dialog to show an existing appointment. */ void appointment_show(); /** * pop up an Appointment Dialog to edit an existing appointment. Get * information on the appointment from the list of unique IDs that is * currently in the View, called currIds. */ void appointment_edit(); /** * pop up dialog confirming deletion of currently selected event in the * View. */ void appointment_delete(); /** mails the currently selected event to a particular user as a vCalendar attachment. */ void action_mail(); /* frees a subtodo from it's relation */ void todo_unsub( Todo * ); void todo_resub( Todo * parent, Todo * sub ); /** Take ownership of selected event. */ void takeOverEvent(); /** Take ownership of all events in calendar. */ void takeOverCalendar(); /** query whether or not the calendar is "dirty". */ bool isModified(); /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ void setModified(bool modified=true); /** query if the calendar is read-only. */ bool isReadOnly(); /** set state of calendar to read-only */ void setReadOnly(bool readOnly=true); void eventUpdated(Incidence *); /* iTIP scheduling actions */ void schedule_publish(Incidence *incidence = 0); void schedule_request(Incidence *incidence = 0); void schedule_refresh(Incidence *incidence = 0); void schedule_cancel(Incidence *incidence = 0); void schedule_add(Incidence *incidence = 0); void schedule_reply(Incidence *incidence = 0); void schedule_counter(Incidence *incidence = 0); void schedule_declinecounter(Incidence *incidence = 0); void schedule_publish_freebusy(int daysToPublish = 30); void openAddressbook(); void editFilters(); void toggleFilerEnabled(); QPtrList<CalFilter> filters(); void toggleFilter(); void showFilter(bool visible); void updateFilter(); void filterEdited(); void selectFilter( int ); KOFilterView *filterView(); void showIntro(); /** Move the curdatepient view date to today */ void goToday(); /** Move to the next date(s) in the current view */ void goNext(); /** Move to the previous date(s) in the current view */ void goPrevious(); /** Move to the next date(s) in the current view */ void goNextMonth(); /** Move to the previous date(s) in the current view */ void goPreviousMonth(); void toggleExpand(); void toggleDateNavigatorWidget(); void toggleAllDaySize(); /** Look for new messages in the inbox */ void lookForIncomingMessages(); /** Look for new messages in the outbox */ void lookForOutgoingMessages(); void processMainViewSelection( Incidence * ); void processTodoListSelection( Incidence * ); void processIncidenceSelection( Incidence * ); void purgeCompleted(); bool removeCompletedSubTodos( Todo* ); void slotCalendarChanged(); bool importBday(); bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); bool importQtopia( const QString &categoriesFile, const QString &datebookFile, const QString &tasklistFile ); void syncExternal( int mode ); void slotSelectPickerDate( QDate ) ; void showDatePicker() ; void showDatePickerPopup() ; void moveIncidence(Incidence *) ; void beamIncidence(Incidence *) ; void beamCalendar() ; void beamFilteredCalendar() ; void beamIncidenceList(QPtrList<Incidence>) ; void manageCategories(); void editCategories(); int addCategories(); void removeCategories(); void setSyncDevice( QString ); void setSyncName( QString ); void showDay( QDate ); void undo_delete(); protected slots: void resetFocus(); void scrollBarValue(int); void slotViewerClosed(); void timerAlarm(); void suspendAlarm(); void beamDone( Ir *ir ); /** Select a view or adapt the current view to display the specified dates. */ void showDates( const KCal::DateList & ); void selectWeekNum ( int ); public: // show a standard warning // returns KMsgBox::yesNoCancel() int msgCalModified(); virtual bool sync(KSyncManager* manager, QString filename, int mode); virtual bool syncExternal(KSyncManager* manager, QString resource); virtual void removeSyncInfo( QString syncProfile); void setSyncManager(KSyncManager* manager); void setLoadedFileVersion(QDateTime); bool checkFileVersion(QString fn); bool checkAllFileVersions(); bool checkFileChanged(QString fn); Event* getLastSyncEvent(); /** Adapt navigation units correpsonding to step size of navigation of the * current view. */ void adaptNavigationUnits(); bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); //Attendee* getYourAttendee(Event *event); void setBlockShowDates( bool b ) { mBlockShowDates = b ;} void setScrollBarStep(int val ); protected: void schedule(Scheduler::Method, Incidence *incidence = 0); // returns KMsgBox::OKCandel() int msgItemDelete(const QString name); void showEventEditor(); void showTodoEditor(); Todo *selectedTodo(); private: #ifdef DESKTOP_VERSION QScrollBar * mDateScrollBar; #endif QDateTime mNextAlarmDateTime; bool mViewerCallerIsSearchDialog; bool mBlockShowDates; KSyncManager* mSyncManager; AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; QTimer* mAlarmTimer; QTimer* mRecheckAlarmTimer; void computeAlarm( QString ); void startAlarm( QString, QString ); void setSyncEventsReadOnly(); QDateTime loadedFileVersion; void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); void checkExternalId( Incidence * inc ); int mGlobalSyncMode; QString mCurrentSyncDevice; QString mCurrentSyncName; void init(); int mDatePickerMode; bool mFlagEditDescription; QDateTime mLastCalendarSync; void createPrinter(); void calendarModified( bool, Calendar * ); CalPrinter *mCalPrinter; QSplitter *mPanner; QSplitter *mLeftSplitter; KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; QWidgetStack *mRightFrame; KDatePicker* mDatePicker; QVBox* mDateFrame; DateNavigatorContainer *mDateNavigator; // widget showing small month view. KOFilterView *mFilterView; KOCalEditView *mCalEditView; ResourceView *mResourceView; // calendar object for this viewing instance diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 3cde103..20118aa 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp @@ -1,454 +1,456 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qcheckbox.h> #include <qcombobox.h> #include <qpushbutton.h> #include <qlayout.h> #include <qlabel.h> #include <qdialog.h> #include <qtextstream.h> #include <qtextcodec.h> #include <libkcal/calfilter.h> #include "kofilterview.h" #include "koprefs.h" #include <kiconloader.h> #include <kglobal.h> #include <kcolorbutton.h> #include <kmessagebox.h> KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, const char* name,WFlags fl ) : KOFilterView_base(parent,name,fl) { mFilters = filterList; connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); } KOFilterView::~KOFilterView() { // no need to delete child widgets, Qt does it all for us } bool KOFilterView::filtersEnabled() { return mEnabledCheck->isChecked(); } void KOFilterView::setFiltersEnabled(bool set) { mEnabledCheck->setChecked(set); emit filterChanged(); } void KOFilterView::updateFilters() { mSelectionCombo->clear(); CalFilter *filter = mFilters->first(); while(filter) { mSelectionCombo->insertItem(filter->name()); filter = mFilters->next(); } } CalFilter *KOFilterView::selectedFilter() { CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); return f; } void KOFilterView::setSelectedFilter(QString filterName) { int filter_num = mSelectionCombo->count(); int i; for (i=0;i<filter_num;i++) { if (mSelectionCombo->text(i)==filterName) mSelectionCombo->setCurrentItem(i); } emit filterChanged(); } void KOFilterView::setSelectedFilter( int fil ) { if ( fil >= mSelectionCombo->count() ) return; mSelectionCombo->setCurrentItem( fil ); emit filterChanged(); } KOCalEditView::KOCalEditView(QWidget* parent, const char* name ) : QScrollView(parent,name) { mw = 0; setResizePolicy( AutoOneFit ); setFrameStyle ( QFrame::Panel | QFrame::Plain ); setLineWidth ( 1 ); setMidLineWidth ( 1 ); setFocusPolicy(NoFocus); } KOCalEditView::~KOCalEditView() { // no need to delete child widgets, Qt does it all for us } void KOCalEditView::selectCal(int id ,bool b) { KOPrefs::instance()->getCalendar( id )->isEnabled = b; emit calendarEnabled ( id, b ); emit needsUpdate(); } void KOCalEditView::selectStdCal( int id, bool b ) { if ( !b ) { KOCalCheckButton* it = (KOCalCheckButton*) sender(); if ( it ) { it->blockSignals( true ); it->setChecked( true ); it->blockSignals( false ); return; } return; } KOCalRadioButton* sen = (KOCalRadioButton*) sender(); KOCalRadioButton* it = mStdandardB.first(); while ( it ) { if ( it->isChecked() ) { if ( it != sen ) { it->blockSignals( true ); it->setChecked( false ); it->blockSignals( false ); break; } } it = mStdandardB.next(); } KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); while ( kkf ) { kkf->isStandard = false; kkf = KOPrefs::instance()->mCalendars.next(); } KOPrefs::instance()->getCalendar( id )->isStandard = true; emit setCalendarDefault ( id ); } void KOCalEditView::selectCalAlarm(int id ,bool b ) { KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; emit alarmEnabled ( id , b ); emit needsUpdate(); } void KOCalEditView::selectReadOnly(int id ,bool b ) { KOPrefs::instance()->getCalendar( id )->isReadOnly = b; emit calendarReadonly ( id , b ); if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { KOPrefs::instance()->getCalendar( id )->isStandard = false; KOPrefs::instance()->getCalendar( 1 )->isStandard = true; mStdandardB.at(0)->setChecked( true ); mStdandardB.at(id-1)->setChecked( false ); emit setCalendarDefault ( 1 ); } mStdandardB.at(id-1)->setEnabled( !b ); emit needsUpdate(); } void KOCalEditView::setColor( const QColor& c, int id ) { KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; emit needsUpdate(); } void KOCalEditView::deleteCal( int id ) { KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); QString name = kkf->mName; QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; if ( kkf->isStandard ) selectStdCal( 1, true ); emit removeCalendar ( id ); KOPrefs::instance()->mCalendars.remove ( kkf ); emit needsUpdate(); QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); } void KOCalEditView::infoCal( int id ) { QString name = KOPrefs::instance()->getCalendar( id )->mName; QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { emit calendarAdded( id ); emit needsUpdate(); QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); + QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); } } else KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); } void KOCalEditView::readConfig() { mStdandardB.clear(); mEnabledB.clear(); mAlarmB.clear(); mROB.clear(); if ( mw ) delete mw; mw = new QWidget ( viewport() ); addChild(mw); int ii = 0; mainLayout = new QGridLayout ( mw , 2, 8 ); mainLayout->setMargin( 2 ); mainLayout->setSpacing( 2 ); QPushButton * addBut = new QPushButton ( mw ); addBut->setFocusPolicy(NoFocus); mainLayout->addWidget( addBut,0,0 ); addBut->setText( "D"); connect(addBut,SIGNAL(clicked()),SLOT(defaultInfo())); //addBut->setPixmap ( SmallIcon("greenhook16")); addBut->setMaximumWidth( addBut->sizeHint().height() ); int max = addBut->sizeHint().height(); addBut = new QPushButton ( mw ); addBut->setFocusPolicy(NoFocus); mainLayout->addWidget( addBut,0,++ii ); addBut->setPixmap ( SmallIcon("eye")); connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); addBut->setMaximumWidth( addBut->sizeHint().height() ); QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); mainLayout->addWidget( lab,0,++ii ); //lab = new QLabel ( i18n(" "), mw ); //mainLayout->addWidget( lab,0,++ii ); //lab->setFixedWidth( 1 ); addBut = new QPushButton ( mw ); addBut->setFocusPolicy(NoFocus); mainLayout->addWidget( addBut,0,++ii ); addBut->setPixmap ( SmallIcon("bell")); connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); addBut->setMaximumWidth( addBut->sizeHint().height() ); addBut = new QPushButton ( mw ); addBut->setFocusPolicy(NoFocus); mainLayout->addWidget( addBut,0,++ii ); addBut->setPixmap ( SmallIcon("pencil")); connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); addBut->setMaximumWidth( addBut->sizeHint().height() ); lab = new QLabel ( "", mw ); mainLayout->addWidget( lab,0,++ii ); addBut = new QPushButton ( mw ); addBut->setFocusPolicy(NoFocus); mainLayout->addWidget( addBut,0,++ii ); addBut->setPixmap ( SmallIcon("plus")); connect(addBut,SIGNAL(clicked()),SLOT(addCal())); lab = new QLabel ( " ", mw ); mainLayout->addWidget( lab,0,++ii ); KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); int row = 1; while ( kkf ) { int iii = 0; KOCalRadioButton* rb = new KOCalRadioButton( mw ); mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); rb->setChecked( kkf->isStandard ); rb->setNum( kkf->mCalNumber ); connect (rb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); if ( kkf->mErrorOnLoad || kkf->isReadOnly ) rb->setEnabled( false ); KOCalCheckButton* cb = new KOCalCheckButton( mw ); mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); cb->setChecked( kkf->isEnabled ); cb->setNum( kkf->mCalNumber ); if ( kkf->mErrorOnLoad ) cb->setEnabled( false ); connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); KOCalButton* name = new KOCalButton( mw ); name->setNum( kkf->mCalNumber ); name->setText( kkf->mName ); mainLayout->addWidget( name,row,++iii ); connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); //lab = new QLabel (" ", mw ); //mainLayout->addWidget( lab,row,++iii ); cb = new KOCalCheckButton( mw ); mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); cb->setChecked( kkf->isAlarmEnabled ); cb->setNum( kkf->mCalNumber ); connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); if ( kkf->mErrorOnLoad ) cb->setEnabled( false ); cb = new KOCalCheckButton( mw ); mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); cb->setChecked( kkf->isReadOnly ); cb->setNum( kkf->mCalNumber ); connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); if ( kkf->mErrorOnLoad ) cb->setEnabled( false ); if ( row > 1) { KColorButton *colb = new KColorButton( mw ); mainLayout->addWidget( colb,row,++iii ); colb->setID( kkf->mCalNumber ); colb->setColor( kkf->mDefaultColor ); connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); KOCalButton* calb = new KOCalButton( mw ); mainLayout->addWidget( calb,row,++iii ); calb->setNum( kkf->mCalNumber ); calb->setPixmap ( SmallIcon("minus")); connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); int hei = calb->sizeHint().height(); //calb->setMaximumSize( hei*9/10, hei*9/10 ); } ++row; kkf = KOPrefs::instance()->mCalendars.next(); } lab = new QLabel ( "", mw ); mainLayout->addWidget( lab,row,0 ); mw->show(); } void KOCalEditView::defaultInfo() { KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); } void KOCalEditView::addCal() { bool tryagain = true; QString name, file; while ( tryagain ) { KONewCalPrefs prefs ( this ); prefs.nameE->setText( name ); prefs.url->setURL( file ); if ( ! prefs.exec() ) return; name = prefs.calName(); file = prefs.calFileName(); tryagain = false; KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); while ( kkf ) { if ( kkf->mName == name ) { KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); name = ""; tryagain = true; break; } if ( kkf->mFileName == file ) { KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); tryagain = true; file = ""; break; } kkf = KOPrefs::instance()->mCalendars.next(); } } addCalendar ( name, file ); + QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); } int KOCalEditView::addCalendar( QString name, QString file, bool ask ) { QFileInfo fi ( file ); if (!fi.exists() ) { if ( ask ) if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) return 0; QFile fileIn( file ); if (!fileIn.open( IO_WriteOnly ) ) { KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); return 0; } QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; fileIn.close(); } KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); kkf->mName = name; kkf->mFileName = file; emit calendarAdded( kkf->mCalNumber ); if ( ask ) emit needsUpdate(); QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); return kkf->mCalNumber; } int KOCalEditView::getBirtdayID() { KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); while ( kkf ) { if ( kkf->mName == i18n("Birthdays") ) return kkf->mCalNumber; kkf = KOPrefs::instance()->mCalendars.next(); } QString file = locateLocal( "data", "korganizer/birthdays.ics" ); return addCalendar( i18n("Birthdays"), file, false ); } void KOCalEditView::enableAll() { toggleList( mEnabledB ); } void KOCalEditView::enableAlarm() { toggleList( mAlarmB ); } void KOCalEditView::disableRO() { toggleList( mROB ); } void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) { bool dis = false; KOCalCheckButton* it = list.first(); while ( it ) { if ( !it->isChecked() ) { dis = true; break; } it = list.next(); } it = list.first(); while ( it ) { it->setChecked(dis); it = list.next(); } } void KOCalEditView::deleteAll() { qDebug("delteAll"); } diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h index 54fe2c5..02107cf 100644 --- a/korganizer/kofilterview.h +++ b/korganizer/kofilterview.h @@ -1,249 +1,250 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KOFILTERVIEW_H #define KOFILTERVIEW_H #include <qstring.h> #include <qcheckbox.h> #include <qradiobutton.h> #include <qlayout.h> #include <qlabel.h> #include <qdialog.h> #include <qscrollview.h> #include <qpushbutton.h> #include <kconfig.h> #include "kofilterview_base.h" #include <libkcal/calfilter.h> #include <kurlrequester.h> #include <klineedit.h> #include <kglobal.h> #include <kmessagebox.h> class QGridLayout; using namespace KCal; class KONewCalPrefs : public QDialog { Q_OBJECT public: KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Add new Calendar") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); lay->addWidget( lab ); nameE = new KLineEdit( this ); lay->addWidget( nameE ); lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); lay->addWidget( lab ); url = new KURLRequester ( this ); lay->addWidget( url ); QPushButton * ok = new QPushButton( i18n("OK"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); setMinimumWidth( 220 ); resize(sizeHint() ); } QString calName() { return nameE->text(); } QString calFileName() { return url->url(); } public slots: void checkValid() { if ( nameE->text().isEmpty() ) { KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); return; } if ( url->url().isEmpty() ) { KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); return; } accept(); } public: KLineEdit* nameE; KURLRequester *url; }; class KOCalButton : public QPushButton { Q_OBJECT public: KOCalButton( QWidget *parent=0, const char *name=0 ) : QPushButton( parent, name) { connect( this, SIGNAL( clicked() ), SLOT( bottonClicked() )); mNumber = -1; setFocusPolicy(NoFocus); } void setNum ( int num ) {mNumber = num; } signals: void selectNum ( int ); private: int mNumber; void keyPressEvent ( QKeyEvent * e ) { e->ignore(); } private slots : void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } }; class KOCalCheckButton : public QCheckBox { Q_OBJECT public: KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : QCheckBox( parent, name) { connect( this, SIGNAL( toggled ( bool ) ), SLOT( bottonClicked( bool ) )); mNumber = -1; setFocusPolicy(NoFocus); //setMaximumWidth( 10 ); } void setNum ( int num ) {mNumber = num; } signals: void selectNum ( int, bool ); private: int mNumber; void keyPressEvent ( QKeyEvent * e ) { e->ignore(); } private slots : void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } }; class KOCalRadioButton : public QRadioButton { Q_OBJECT public: KOCalRadioButton( QWidget *parent=0, const char *name=0 ) : QRadioButton( parent, name) { connect( this, SIGNAL( toggled ( bool ) ), SLOT( bottonClicked( bool ) )); mNumber = -1; setFocusPolicy(NoFocus); //setMaximumWidth( 10 ); } void setNum ( int num ) {mNumber = num; } signals: void selectNum ( int, bool ); private: int mNumber; void keyPressEvent ( QKeyEvent * e ) { e->ignore(); } private slots : void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } }; class KOFilterView : public KOFilterView_base { Q_OBJECT public: KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); ~KOFilterView(); void updateFilters(); bool filtersEnabled(); void setFiltersEnabled(bool); CalFilter *selectedFilter(); void setSelectedFilter(QString); void setSelectedFilter( int ); signals: void filterChanged(); void editFilters(); private: QPtrList<CalFilter> *mFilters; }; class KOCalEditView : public QScrollView { Q_OBJECT public: KOCalEditView( QWidget* parent=0,const char* name=0); ~KOCalEditView(); int addCalendar( QString calName, QString fileName, bool ask = true ); int getBirtdayID(); public slots: void addCal(); void enableAll(); void enableAlarm(); void disableRO(); void deleteAll(); void selectStdCal(int,bool ); void selectCal(int,bool ); void selectCalAlarm(int,bool ); void selectReadOnly(int,bool ); void setColor(const QColor &,int) ; void deleteCal(int) ; void infoCal(int) ; void readConfig(); void defaultInfo(); signals: void alarmEnabled ( int cal, bool enable ); void calendarEnabled ( int cal, bool enable ); void calendarReadonly ( int cal, bool readonly ); void setCalendarDefault ( int cal ); void removeCalendar ( int cal ); void calendarAdded( int ); void needsUpdate(); + void checkCalendar(); private: QWidget *mw; void toggleList ( QPtrList<KOCalCheckButton> ); QPtrList<KOCalRadioButton> mStdandardB; QPtrList<KOCalCheckButton> mEnabledB; QPtrList<KOCalCheckButton> mAlarmB; QPtrList<KOCalCheckButton> mROB; QGridLayout* mainLayout; }; #endif // KOFILTERVIEW_H diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index b797d8c..501eed5 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -17,773 +17,770 @@ #include <qcheckbox.h> #include <qmap.h> #include <qwmatrix.h> #include <qtextbrowser.h> #include <qtextstream.h> #ifndef DESKTOP_VERSION #include <qpe/global.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qtopia/alarmserver.h> #include <qtopia/qcopenvelope_qws.h> #include <unistd.h> // for sleep #else #include <qmenubar.h> #include <qtoolbar.h> #include <qapplication.h> //#include <resource.h> #endif #include <libkcal/calendarlocal.h> #include <libkcal/todo.h> #include <libkcal/phoneformat.h> #include <libkdepim/ksyncprofile.h> #include <libkdepim/phoneaccess.h> #include <libkcal/kincidenceformatter.h> #include <libkdepim/kpimglobalprefs.h> #include "calendarview.h" #include "koviewmanager.h" #include "datenavigator.h" #include "koagendaview.h" #include "kojournalview.h" #include "koagenda.h" #include "kodialogmanager.h" #include "kdialogbase.h" #include "kapplication.h" #include "kofilterview.h" #include "kstandarddirs.h" #include "koprefs.h" #include "kfiledialog.h" #include "koglobals.h" #include "kglobal.h" #include "ktoolbar.h" #include "klocale.h" #include "kconfig.h" #include "externalapphandler.h" #include <kglobalsettings.h> using namespace KCal; #ifndef _WIN32_ #include <unistd.h> #else #ifdef _OL_IMPORT_ #include "koimportoldialog.h" #endif #endif #include "mainwindow.h" class KOex2phonePrefs : public QDialog { public: KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Export to phone options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel *lab; lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); lab->setAlignment (AlignHCenter ); QHBox* temphb; temphb = new QHBox( this ); new QLabel( i18n("I/O device: "), temphb ); mPhoneDevice = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Connection: "), temphb ); mPhoneConnection = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Model(opt.): "), temphb ); mPhoneModel = new QLineEdit( temphb); lay->addWidget( temphb ); mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); mWriteBackFuture->setChecked( true ); lay->addWidget( mWriteBackFuture ); temphb = new QHBox( this ); new QLabel( i18n("Max. weeks in future: ") , temphb ); mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); mWriteBackFutureWeeks->setValue( 8 ); lay->addWidget( temphb ); lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); lab->setAlignment (AlignHCenter ); QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 220, 240 ); qApp->processEvents(); int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); move( (dw-width())/2, (dh - height() )/2 ); } public: QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; QCheckBox* mWriteBackFuture; QSpinBox* mWriteBackFutureWeeks; }; QPixmap* sgListViewCompletedPix[6]; int globalFlagBlockStartup; MainWindow::MainWindow( QWidget *parent, const char *name ) : QMainWindow( parent, name ) { sgListViewCompletedPix[5] = &listviewPix; sgListViewCompletedPix[0] = &listviewPix0; sgListViewCompletedPix[1] = &listviewPix20; sgListViewCompletedPix[2] = &listviewPix40; sgListViewCompletedPix[3] = &listviewPix60; sgListViewCompletedPix[4] = &listviewPix80; if ( sgListViewCompletedPix[5]->height() < 5 ) { //int size = 12; sgListViewCompletedPix[5]->resize( 11, 11 ); sgListViewCompletedPix[5]->fill( Qt::white ); QPainter p ( sgListViewCompletedPix[5] ); p.drawRect( 0,0,11,11); p.drawLine ( 2, 5, 4 , 7 ) ; p.drawLine ( 4 , 7 , 8, 3) ; int iii = 0; for ( iii = 0; iii < 5; ++iii ) { sgListViewCompletedPix[iii]->resize( 11, 11 ); sgListViewCompletedPix[iii]->fill( Qt::white ); QPainter p ( sgListViewCompletedPix[iii] ); p.drawRect( 0,0,11,11); if ( iii ) p.fillRect( 1,1,iii*2,9,Qt::gray ); } } mClosed = false; //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; QString confFile = locateLocal("config","korganizerrc"); QFileInfo finf ( confFile ); bool showWarning = !finf.exists(); setIcon(SmallIcon( "ko24" ) ); mBlockAtStartup = true; mFlagKeyPressed = false; setCaption("KO/Pi"); KOPrefs *p = KOPrefs::instance(); //KPimGlobalPrefs::instance()->setGlobalConfig(); p->mCurrentDisplayedView = 0; if ( p->mHourSize > 22 ) p->mHourSize = 22; QMainWindow::ToolBarDock tbd; if ( p->mToolBarHor ) { if ( p->mToolBarUp ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUp ) tbd = Right; else tbd = Left; } if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); globalFlagBlockStartup = 1; iconToolBar = new QPEToolBar( this ); addToolBar (iconToolBar , tbd ); #ifdef DESKTOP_VERSION if ( KOPrefs::instance()->mShowIconFilter ) #else if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) #endif { if ( p->mToolBarHorF ) { if ( p->mToolBarUpF ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpF ) tbd = Right; else tbd = Left; } filterToolBar = new QPEToolBar ( this ); filterMenubar = new QMenuBar( 0 ); QFontMetrics fm ( filterMenubar->font() ); filterPopupMenu = new QPopupMenu( this ); filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); QString addTest = "A"; filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); #ifdef DESKTOP_VERSION addTest = "AAABBBCCCx"; #else addTest = "AAx"; #endif filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); addToolBar (filterToolBar , tbd ); connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) filterToolBar->hide(); } else { filterToolBar = 0; filterMenubar = 0; filterPopupMenu = 0; } if ( p->mShowIconOnetoolbar ) { viewToolBar = iconToolBar ; navigatorToolBar = iconToolBar ; } else { #ifndef DESKTOP_VERSION setToolBarsMovable( false ); #endif if ( p->mToolBarHorV ) { if ( p->mToolBarUpV ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpV ) tbd = Right; else tbd = Left; } viewToolBar = new QPEToolBar( this ); addToolBar (viewToolBar , tbd ); if ( p->mToolBarHorN ) { if ( p->mToolBarUpN ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUpN ) tbd = Right; else tbd = Left; } navigatorToolBar = new QPEToolBar( this ); addToolBar (navigatorToolBar , tbd ); } mCalendarModifiedFlag = false; QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); splash->setAlignment ( AlignCenter ); setCentralWidget( splash ); #ifndef DESKTOP_VERSION showMaximized(); #endif //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); setDefaultPreferences(); mCalendar = new CalendarLocal(); mView = new CalendarView( mCalendar, this,"mCalendar " ); mView->hide(); //mView->resize(splash->size() ); initActions(); mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); mSyncManager->setBlockSave(false); mView->setSyncManager(mSyncManager); #ifndef DESKTOP_VERSION iconToolBar->show(); qApp->processEvents(); #endif //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); int vh = height() ; int vw = width(); //qDebug("Toolbar hei %d ",iconToolBar->height() ); if ( iconToolBar->orientation () == Qt:: Horizontal ) { vh -= iconToolBar->height(); } else { vw -= iconToolBar->height(); } //mView->setMaximumSize( splash->size() ); //mView->resize( splash->size() ); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); mView->readSettings(); bool newFile = false; if( !QFile::exists( defaultFileName() ) ) { QFileInfo finfo ( defaultFileName() ); QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } else { oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } } mView->saveCalendar( defaultFileName() ); newFile = true; } QTime neededSaveTime = QDateTime::currentDateTime().time(); mView->loadCalendars(); int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Calendar loading time: %d ms",msNeeded ); if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { KOPrefs::instance()->setAllDefaults(); } processIncidenceSelection( 0 ); connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processIncidenceSelection( Incidence * ) ) ); connect( mView, SIGNAL( modifiedChanged( bool ) ), SLOT( slotModifiedChanged( bool ) ) ); connect( mView, SIGNAL( tempDisableBR(bool) ), SLOT( disableBR(bool) ) ); connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); mView->setModified( false ); mBlockAtStartup = false; mView->setModified( false ); setCentralWidget( mView ); globalFlagBlockStartup = 0; mView->show(); delete splash; if ( newFile ) mView->updateConfig(); // qApp->processEvents(); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); //fillSyncMenu(); connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); mSyncManager->setDefaultFileName( sentSyncFile()); connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); mSyncManager->fillSyncMenu(); mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); if ( showWarning ) { KMessageBox::information( this, "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); qApp->processEvents(); mView->dialogManager()->showSyncOptions(); } //US listen for result adressed from Ka/Pi #ifndef DESKTOP_VERSION connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); #endif #ifndef DESKTOP_VERSION infrared = 0; #endif updateFilterToolbar(); updateWeek( mView->startDate() ); connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( updateWeekNum( const KCal::DateList & ) ) ); mBRdisabled = false; //toggleBeamReceive(); - int tiint= 3000; -#ifndef DESKTOP_VERSION - tiint = 5000; -#endif - QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() )); + + QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); } MainWindow::~MainWindow() { //qDebug("MainWindow::~MainWindow() "); //save toolbar location delete mCalendar; delete mSyncManager; #ifndef DESKTOP_VERSION if ( infrared ) delete infrared; #endif } void MainWindow::disableBR(bool b) { #ifndef DESKTOP_VERSION if ( b ) { if ( infrared ) { toggleBeamReceive(); mBRdisabled = true; } mBRdisabled = true; } else { if ( mBRdisabled ) { mBRdisabled = false; //makes no sense,because other cal ap is probably running // toggleBeamReceive(); } } #endif } bool MainWindow::beamReceiveEnabled() { #ifndef DESKTOP_VERSION return ( infrared != 0 ); #endif return false; } void MainWindow::toggleBeamReceive() { if ( mBRdisabled ) return; #ifndef DESKTOP_VERSION if ( infrared ) { qDebug("KO: Disable BeamReceive "); delete infrared; infrared = 0; brAction->setOn(false); return; } qDebug("KO: Enable BeamReceive "); brAction->setOn(true); infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); #endif } void MainWindow::showMaximized () { #ifndef DESKTOP_VERSION if ( ! globalFlagBlockStartup ) if ( mClosed ) mView->goToday(); #endif QWidget::showMaximized () ; mClosed = false; } void MainWindow::closeEvent( QCloseEvent* ce ) { if ( ! KOPrefs::instance()->mAskForQuit ) { saveOnClose(); mClosed = true; ce->accept(); return; } switch( QMessageBox::information( this, "KO/Pi", i18n("Do you really want\nto close KO/Pi?"), i18n("Close"), i18n("No"), 0, 0 ) ) { case 0: saveOnClose(); mClosed = true; ce->accept(); break; case 1: ce->ignore(); break; case 2: default: break; } } void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) { QDataStream stream( data, IO_ReadOnly ); // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); //QString datamess; //qDebug("message "); qDebug("KO: QCOP message received: %s ", cmsg.data() ); if ( cmsg == "setDocument(QString)" ) { QDataStream stream( data, IO_ReadOnly ); QString fileName; stream >> fileName; //qDebug("filename %s ", fileName.latin1()); showMaximized(); raise(); KOPrefs::instance()->mLastSyncedLocalFile = fileName ; mSyncManager->slotSyncMenu( 1002 ); return; } if ( cmsg == "-writeFile" ) { // I made from the "-writeFile" an "-writeAlarm" mView->viewManager()->showWhatsNextView(); mCalendar->checkAlarmForIncidence( 0, true); showMaximized(); raise(); return; } if ( cmsg == "-writeFileSilent" ) { // I made from the "-writeFile" an "-writeAlarm" // mView->viewManager()->showWhatsNextView(); mCalendar->checkAlarmForIncidence( 0, true); //showMaximized(); //raise(); hide(); return; } if ( cmsg == "-newCountdown" ) { qDebug("newCountdown "); } QString msg ; QString allmsg = cmsg; while ( allmsg.length() > 0 ) { int nextC = allmsg.find( "-", 1 ); if ( nextC == -1 ) { msg = allmsg; allmsg = ""; } else{ msg = allmsg.left( nextC ); allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); } //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); if ( msg == "-newEvent" ) { QTimer::singleShot( 0, mView, SLOT ( newEvent())); } if ( msg == "-newTodo" ) { QTimer::singleShot( 0, mView, SLOT ( newTodo())); } if ( msg == "-showWN" ) { mView->viewManager()->showWhatsNextView(); } if ( msg == "-showTodo" ) { mView->viewManager()->showTodoView(); } if ( msg == "-showList" ) { mView->viewManager()->showListView(); } else if ( msg == "-showDay" ) { mView->viewManager()->showDayView(); } else if ( msg == "-showWWeek" ) { mView->viewManager()->showWorkWeekView(); } else if ( msg == "-ringSync" ) { QTimer::singleShot( 0, this, SLOT (startMultiSync())); } else if ( msg == "-showWeek" ) { mView->viewManager()->showWeekView(); } else if ( msg == "-showTodo" ) { mView->viewManager()->showTodoView(); } else if ( msg == "-showJournal" ) { mView->dateNavigator()->selectDates( 1 ); mView->dateNavigator()->selectToday(); mView->viewManager()->showJournalView(); } else if ( msg == "-showKO" ) { mView->viewManager()->showNextXView(); } else if ( msg == "-showWNext" ) { mView->viewManager()->showWhatsNextView(); } else if ( msg == "nextView()" ) { mView->viewManager()->showNextView(); } else if ( msg == "-showNextXView" ) { mView->viewManager()->showNextXView(); } } showMaximized(); raise(); } void MainWindow::startMultiSync() { QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), question, i18n("Yes"), i18n("No"), 0, 0 ) != 0 ) { setCaption(i18n("Aborted! Nothing synced!")); return; } mSyncManager->multiSync( false ); #ifndef DESKTOP_VERSION QCopEnvelope e("QPE/Application/kapi", "doRingSync"); #endif } QPixmap MainWindow::loadPixmap( QString name ) { return SmallIcon( name ); } void MainWindow::setUsesBigPixmaps ( bool b ) { qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); if ( b ) qDebug("KO: BigPixmaps are not supported "); } void MainWindow::initActions() { //KOPrefs::instance()->mShowFullMenu iconToolBar->clear(); KOPrefs *p = KOPrefs::instance(); //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); QPopupMenu *viewMenu = new QPopupMenu( this ); QPopupMenu *actionMenu = new QPopupMenu( this ); mCurrentItemMenu = new QPopupMenu ( this ); QPopupMenu *importMenu = new QPopupMenu( this ); QPopupMenu *importMenu_X = new QPopupMenu( this ); QPopupMenu *exportMenu_X = new QPopupMenu( this ); QPopupMenu *beamMenu_X = new QPopupMenu( this ); selectFilterMenu = new QPopupMenu( this ); selectFilterMenu->setCheckable( true ); syncMenu = new QPopupMenu( this ); configureAgendaMenu = new QPopupMenu( this ); configureToolBarMenu = new QPopupMenu( this ); QPopupMenu *helpMenu = new QPopupMenu( this ); QIconSet icon; int pixWid = 22, pixHei = 22; QString pathString = ""; if ( !p->mToolBarMiniIcons ) { if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { pathString += "icons16/"; pixWid = 18; pixHei = 16; } } else { pathString += "iconsmini/"; pixWid = 18; pixHei = 16; } if ( KOPrefs::instance()->mShowFullMenu ) { QMenuBar *menuBar1; menuBar1 = menuBar(); menuBar1->insertItem( i18n("File"), importMenu ); menuBar1->insertItem( i18n("View"), viewMenu ); menuBar1->insertItem( i18n("Actions"), actionMenu ); #ifdef DESKTOP_VERSION menuBar1->insertItem( i18n("Synchronize"), syncMenu ); menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); #else menuBar1->insertItem( i18n("Sync"), syncMenu ); menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); #endif //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); menuBar1->insertItem( i18n("Help"), helpMenu ); } else { QPEMenuBar *menuBar1; menuBar1 = new QPEMenuBar( iconToolBar ); QPopupMenu *menuBar = new QPopupMenu( this ); icon = loadPixmap( pathString + "z_menu" ); menuBar1->insertItem( icon.pixmap(), menuBar); //menuBar1->insertItem( i18n("ME"), menuBar); menuBar->insertItem( i18n("File"), importMenu ); menuBar->insertItem( i18n("View"), viewMenu ); menuBar->insertItem( i18n("Actions"), actionMenu ); menuBar->insertItem( i18n("Synchronize"), syncMenu ); menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); menuBar->insertItem( i18n("Filter"),selectFilterMenu ); menuBar->insertItem( i18n("Help"), helpMenu ); //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); menuBar1->setMaximumSize( menuBar1->sizeHint( )); } connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); mWeekBgColor = iconToolBar->backgroundColor(); mWeekPixmap.resize( pixWid , pixHei ); mWeekPixmap.fill( mWeekBgColor ); icon = mWeekPixmap; mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); if ( p-> mShowIconWeekNum ) mWeekAction->addTo( iconToolBar ); mWeekFont = font(); int fontPoint = mWeekFont.pointSize(); QFontMetrics f( mWeekFont ); int fontWid = f.width( "30" ); while ( fontWid > pixWid ) { --fontPoint; mWeekFont.setPointSize( fontPoint ); QFontMetrics f( mWeekFont ); fontWid = f.width( "30" ); //qDebug("dec-- "); } connect( mWeekAction, SIGNAL( activated() ), this, SLOT( weekAction() ) ); connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); if ( p->mShowIconFilterview ) { icon = loadPixmap( pathString + "filter" ); actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); connect( actionFilterMenuTB, SIGNAL( activated() ), this, SLOT( fillFilterMenuTB() ) ); actionFilterMenuTB->addTo( iconToolBar ); selectFilterMenuTB = new QPopupMenu( this ); selectFilterMenuTB->setCheckable( true ); connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); } //#endif // ****************** QAction *action; // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); configureToolBarMenu->setCheckable( true ); configureAgendaMenu->setCheckable( true ); int iii ; for ( iii = 1;iii<= 10 ;++iii ){ configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); } //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); connect( configureAgendaMenu, SIGNAL( aboutToShow()), this, SLOT( showConfigureAgenda( ) ) ); icon = loadPixmap( pathString + "today" ); QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); today_action->addTo( actionMenu ); connect( today_action, SIGNAL( activated() ), mView, SLOT( goToday() ) ); icon = loadPixmap( pathString + "picker" ); QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); dPickerAction->addTo( actionMenu ); connect( dPickerAction, SIGNAL( activated() ), mView, SLOT( showDatePicker() ) ); icon = loadPixmap( pathString + "search" ); QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); search_action->addTo( actionMenu ); connect( search_action, SIGNAL( activated() ), mView->dialogManager(), SLOT( showSearchDialog() ) ); actionMenu->insertSeparator(); action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); action->addTo( actionMenu ); connect( action, SIGNAL( activated() ), |