summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp76
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/datenavigatorcontainer.cpp36
-rw-r--r--korganizer/kdatenavigator.cpp40
-rw-r--r--korganizer/kdatenavigator.h8
-rw-r--r--korganizer/kodaymatrix.cpp11
-rw-r--r--korganizer/kodaymatrix.h1
-rw-r--r--korganizer/navigatorbar.cpp67
-rw-r--r--korganizer/navigatorbar.h1
9 files changed, 184 insertions, 58 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3ce123c..ab59d00 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,737 +1,741 @@
/*
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, 2002
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.
*/
#include <stdlib.h>
#include <qapplication.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
#include <qlayout.h>
#include <qclipboard.h>
#include <qcursor.h>
#include <qmessagebox.h>
#include <qprogressbar.h>
#include <qmultilineedit.h>
#include <qtimer.h>
#include <qwidgetstack.h>
#include <qptrlist.h>
#include <qregexp.h>
#include <qgroupbox.h>
#include <qfile.h>
#include <qdir.h>
#ifndef KORG_NOSPLITTER
#include <qsplitter.h>
#endif
#include <kglobal.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <knotifyclient.h>
#include <kconfig.h>
#include <libkdepim/ksyncprefsdialog.h>
#include <krun.h>
#include <kdirwatch.h>
#include <libkdepim/kdatepicker.h>
#include <libkdepim/ksyncprofile.h>
#include <libkdepim/kpimglobalprefs.h>
#include <libkcal/vcaldrag.h>
#include <libkcal/icaldrag.h>
#include <libkcal/icalformat.h>
#include <libkcal/vcalformat.h>
#include <libkcal/scheduler.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/journal.h>
#include <libkcal/calfilter.h>
#include <libkcal/attendee.h>
#include <libkcal/dndfactory.h>
#include <libkcal/freebusy.h>
#include <libkcal/filestorage.h>
#include <libkcal/calendarresources.h>
#include <libkcal/qtopiaformat.h>
#include "../kalarmd/alarmdialog.h"
#ifndef DESKTOP_VERSION
#include <libkcal/sharpformat.h>
#include <externalapphandler.h>
#endif
#include <libkcal/phoneformat.h>
#ifndef KORG_NOMAIL
#include "komailclient.h"
#endif
#ifndef KORG_NOPRINTER
#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 "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;
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\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), 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("OK"), 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()
{
setFocusPolicy ( WheelFocus );
mViewerCallerIsSearchDialog = false;
mBlockShowDates = false;
beamDialog = new KOBeamPrefs();
mDatePickerMode = 0;
mCurrentSyncDevice = "";
writeLocale();
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 *mainBox = new QWidget( this );
//QWidget *leftFrame = new QWidget( mainBox );
- QBoxLayout * mainBoxLayout;
+ //QBoxLayout * mainBoxLayout;
if ( KOPrefs::instance()->mVerticalScreen ) {
- mainBoxLayout = new QVBoxLayout(mainBox);
+ //mainBoxLayout = new QVBoxLayout(mainBox);
//leftFrameLayout = new QHBoxLayout(leftFrame );
- mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);;
- mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left );
+ 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);
+ //mainBoxLayout = new QHBoxLayout(mainBox);
//leftFrameLayout = new QVBoxLayout(leftFrame );
- mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);;
+ mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
+ mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
+ mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
}
//QBoxLayout * leftFrameLayout;
- topLayout->addWidget( mainBox );
- mainBoxLayout->addWidget (mLeftFrame);
+ topLayout->addWidget( mMainFrame );
+ //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");
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();
- QWidget *rightBox = new QWidget( mainBox );
- mainBoxLayout->addWidget ( rightBox, 10 );
+ 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->setFixedHeight( mDateNavigator->sizeHint().height() );
//mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
- mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
+ //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
//leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
} else {
- mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
- mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
+ //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( 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 beamDialog;
delete mEventViewerDialog;
//kdDebug() << "~CalendarView() done" << endl;
}
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)
{
mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
QTimer::singleShot( 3000, 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 &noti )
{
//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 &noti )
{
//qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
#ifndef DESKTOP_VERSION
AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
#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 );
}
void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
{
//qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
#ifndef DESKTOP_VERSION
AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
#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
@@ -1454,862 +1458,894 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
//qDebug("CalView 1 %i", count);
QProgressBar bar(count,0 );
int w = 300;
if ( QApplication::desktop()->width() < 320 )
w = 220;
int h = bar.sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
bar.show();
bar.setCaption (i18n("inserting birthdays - close to abort!") );
qApp->processEvents();
QDate birthday;
QDate anniversary;
QString realName;
QString email;
QString assembledName;
QString uid;
bool ok = true;
for ( int i = 0; i < count; i++)
{
if ( ! bar.isVisible() )
return;
bar.setProgress( i );
qApp->processEvents();
birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
if (!ok) {
;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
}
anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
if (!ok) {
;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
}
realName = realNameList[i];
email = emailList[i];
assembledName = assembledNameList[i];
uid = uidList[i];
//qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
if ( birthday.isValid() ){
a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
KCal::Attendee::ReqParticipant,uid) ;
if ( addAnniversary( birthday, assembledName, a, true ) )
++addCount;
}
if ( anniversary.isValid() ){
a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
KCal::Attendee::ReqParticipant,uid) ;
if ( addAnniversary( anniversary, assembledName, a, false ) )
++addCount;
}
}
updateView();
topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
}
}
bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
{
//qDebug("addAnni ");
Event * ev = new Event();
ev->setOrganizer(KOPrefs::instance()->email());
if ( a ) {
ev->addAttendee( a );
}
QString kind;
if ( birthday ) {
kind = i18n( "Birthday" );
ev->setSummary( name + " (" + QString::number(date.year()) +")");
}
else {
kind = i18n( "Anniversary" );
ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
}
ev->setCategories( kind );
ev->setDtStart( QDateTime(date) );
ev->setDtEnd( QDateTime(date) );
ev->setFloats( true );
Recurrence * rec = ev->recurrence();
rec->setYearly(Recurrence::rYearlyMonth,1,-1);
rec->addYearlyNum( date.month() );
if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
delete ev;
return false;
}
return true;
}
bool CalendarView::importQtopia( const QString &categories,
const QString &datebook,
const QString &todolist )
{
QtopiaFormat qtopiaFormat;
qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
updateView();
return true;
#if 0
mGlobalSyncMode = SYNC_MODE_QTOPIA;
mCurrentSyncDevice = "qtopia-XML";
if ( mSyncManager->mAskForPreferences )
edit_sync_options();
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
bool syncOK = false;
QtopiaFormat qtopiaFormat;
qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
bool loadOk = true;
if ( !categories.isEmpty() )
loadOk = qtopiaFormat.load( calendar, categories );
if ( loadOk && !datebook.isEmpty() )
loadOk = qtopiaFormat.load( calendar, datebook );
if ( loadOk && !todolist.isEmpty() )
loadOk = qtopiaFormat.load( calendar, todolist );
if ( loadOk ) {
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
getEventViewerDialog()->setSyncMode( false );
qApp->processEvents();
if ( syncOK ) {
if ( mSyncManager->mWriteBackFile )
{
// write back XML file
}
setModified( true );
}
} else {
QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
question, i18n("Ok")) ;
}
delete calendar;
updateView();
return syncOK;
#endif
}
void CalendarView::setSyncEventsReadOnly()
{
Event * ev;
QPtrList<Event> eL = mCalendar->rawEvents();
ev = eL.first();
while ( ev ) {
if ( ev->uid().left(15) == QString("last-syncEvent-") )
ev->setReadOnly( true );
ev = eL.next();
}
}
bool CalendarView::openCalendar(QString filename, bool merge)
{
if (filename.isEmpty()) {
return false;
}
if (!QFile::exists(filename)) {
KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
return false;
}
globalFlagBlockAgenda = 1;
if (!merge) mCalendar->close();
mStorage->setFileName( filename );
if ( mStorage->load() ) {
if ( merge ) ;//setModified( true );
else {
//setModified( true );
mViewManager->setDocumentId( filename );
mDialogManager->setDocumentId( filename );
mTodoList->setDocumentId( filename );
}
globalFlagBlockAgenda = 2;
// if ( getLastSyncEvent() )
// getLastSyncEvent()->setReadOnly( true );
mCalendar->reInitAlarmSettings();
setSyncEventsReadOnly();
updateUnmanagedViews();
updateView();
if ( filename != MainWindow::defaultFileName() ) {
saveCalendar( MainWindow::defaultFileName() );
} else {
QFileInfo finf ( MainWindow::defaultFileName());
if ( finf.exists() ) {
setLoadedFileVersion( finf.lastModified () );
}
}
return true;
} else {
// while failing to load, the calendar object could
// have become partially populated. Clear it out.
if ( !merge ) {
mCalendar->close();
mViewManager->setDocumentId( filename );
mDialogManager->setDocumentId( filename );
mTodoList->setDocumentId( filename );
}
//KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
globalFlagBlockAgenda = 2;
mCalendar->reInitAlarmSettings();
setSyncEventsReadOnly();
updateUnmanagedViews();
updateView();
}
return false;
}
void CalendarView::showOpenError()
{
KMessageBox::error(this,i18n("Couldn't load calendar\n."));
}
void CalendarView::setLoadedFileVersion(QDateTime dt)
{
loadedFileVersion = dt;
}
bool CalendarView::checkFileChanged(QString fn)
{
QFileInfo finf ( fn );
if ( !finf.exists() )
return true;
QDateTime dt = finf.lastModified ();
if ( dt <= loadedFileVersion )
return false;
return true;
}
void CalendarView::watchSavedFile()
{
QFileInfo finf ( MainWindow::defaultFileName());
if ( !finf.exists() )
return;
QDateTime dt = finf.lastModified ();
if ( dt < loadedFileVersion ) {
//qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
return;
}
loadedFileVersion = dt;
}
bool CalendarView::checkFileVersion(QString fn)
{
QFileInfo finf ( fn );
if ( !finf.exists() )
return true;
QDateTime dt = finf.lastModified ();
//qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
//qDebug("file on disk version %s",dt.toString().latin1());
if ( dt <= loadedFileVersion )
return true;
int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
i18n("KO/Pi Warning"),i18n("Overwrite"),
i18n("Sync+save"));
if ( km == KMessageBox::Cancel )
return false;
if ( km == KMessageBox::Yes )
return true;
setSyncDevice("deleteaftersync" );
mSyncManager->mAskForPreferences = true;
mSyncManager->mSyncAlgoPrefs = 3;
mSyncManager->mWriteBackFile = false;
mSyncManager->mWriteBackExistingOnly = false;
mSyncManager->mShowSyncSummary = false;
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
mCalendar->deleteEvent ( e );
updateView();
return true;
}
bool CalendarView::saveCalendar( QString filename )
{
// Store back all unsaved data into calendar object
// qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
if ( mViewManager->currentView() )
mViewManager->currentView()->flushView();
QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
mStorage->setSaveFormat( new ICalFormat() );
mStorage->setFileName( filename );
bool success;
success = mStorage->save();
if ( !success ) {
return false;
}
if ( filename == MainWindow::defaultFileName() ) {
setLoadedFileVersion( lfv );
watchSavedFile();
}
return true;
}
void CalendarView::closeCalendar()
{
// child windows no longer valid
emit closingDown();
mCalendar->close();
setModified(false);
updateView();
}
void CalendarView::archiveCalendar()
{
mDialogManager->showArchiveDialog();
}
void CalendarView::readSettings()
{
// mViewManager->showAgendaView();
QString str;
//qDebug("CalendarView::readSettings() ");
// read settings from the KConfig, supplying reasonable
// defaults where none are to be found
KConfig *config = KOGlobals::config();
#ifndef KORG_NOSPLITTER
config->setGroup("KOrganizer Geometry");
QValueList<int> sizes = config->readIntListEntry("Separator1");
if (sizes.count() != 2) {
sizes << mDateNavigator->minimumSizeHint().width();
sizes << 300;
}
mPanner->setSizes(sizes);
sizes = config->readIntListEntry("Separator2");
if ( ( mResourceView && sizes.count() == 4 ) ||
( !mResourceView && sizes.count() == 3 ) ) {
mLeftSplitter->setSizes(sizes);
}
#endif
globalFlagBlockAgenda = 1;
mViewManager->showAgendaView();
//mViewManager->readSettings( config );
mTodoList->restoreLayout(config,QString("Todo Layout"));
readFilterSettings(config);
config->setGroup( "Views" );
int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
int resetval = 0;
int maxVal = 0;
if (sizes.count() != 3) {
if ( KOPrefs::instance()->mVerticalScreen ) {
resetval = mDateNavigator->sizeHint().width()+2;
} else {
resetval = mDateNavigator->sizeHint().height()+2;
}
}
if ( !resetval ){// i.e. sizes.count() == 3
if ( KOPrefs::instance()->mVerticalScreen ) {
- if ( sizes[0] < mDateNavigator->sizeHint().width()+1 )
- resetval = mDateNavigator->sizeHint().width()+2;
+ if ( sizes[0] < mDateNavigator->sizeHint().width()+1 )
+ resetval = mDateNavigator->sizeHint().width()+2;
} else {
- if ( sizes[0] < mDateNavigator->sizeHint().height()+1 )
- resetval = mDateNavigator->sizeHint().height()+2;
+ if ( sizes[0] < mDateNavigator->sizeHint().height()+1 )
+ resetval = mDateNavigator->sizeHint().height()+2;
}
}
if ( resetval ) {
sizes.clear();
if ( KOPrefs::instance()->mVerticalScreen ) {
maxVal = QApplication::desktop()->width() -10;
} else {
maxVal = QApplication::desktop()->height()-10;
}
sizes << resetval;
if ( maxVal < resetval + resetval)
resetval = maxVal - resetval;
sizes << resetval;
sizes << 100;
}
mLeftFrame->setSizes(sizes);
+ sizes = config->readIntListEntry("Main Splitter Frame");
+ if (sizes.count() != 3) {
+ if ( !KOPrefs::instance()->mVerticalScreen ) {
+ resetval = mDateNavigator->sizeHint().width()+2;
+ } else {
+ resetval = mDateNavigator->sizeHint().height()+2;
+ }
+ }
+ if ( !resetval ){// i.e. sizes.count() == 3
+ if ( !KOPrefs::instance()->mVerticalScreen ) {
+ if ( sizes[0] < mDateNavigator->sizeHint().width()+1 )
+ resetval = mDateNavigator->sizeHint().width()+2;
+ } else {
+ if ( sizes[0] < mDateNavigator->sizeHint().height()+1 )
+ resetval = mDateNavigator->sizeHint().height()+2;
+ }
+ }
+ if ( resetval ) {
+ sizes.clear();
+ if ( !KOPrefs::instance()->mVerticalScreen ) {
+ maxVal = QApplication::desktop()->width() -10;
+ } else {
+ maxVal = QApplication::desktop()->height()-10;
+ }
+ sizes << resetval;
+ if ( maxVal < resetval + resetval)
+ resetval = maxVal - resetval;
+ sizes << resetval;
+ }
+ mMainFrame->setSizes(sizes);
+
if ( dateCount == 5 ) mNavigator->selectWorkWeek();
else if ( dateCount == 7 ) mNavigator->selectWeek();
else mNavigator->selectDates( dateCount );
// mViewManager->readSettings( config );
updateConfig();
globalFlagBlockAgenda = 2;
mViewManager->readSettings( config );
#ifdef DESKTOP_VERSION
config->setGroup("WidgetLayout");
QStringList list;
list = config->readListEntry("MainLayout");
int x,y,w,h;
if ( ! list.isEmpty() ) {
x = list[0].toInt();
y = list[1].toInt();
w = list[2].toInt();
h = list[3].toInt();
topLevelWidget()->setGeometry(x,y,w,h);
} else {
topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
}
list = config->readListEntry("EditEventLayout");
if ( ! list.isEmpty() ) {
x = list[0].toInt();
y = list[1].toInt();
w = list[2].toInt();
h = list[3].toInt();
mEventEditor->setGeometry(x,y,w,h);
}
list = config->readListEntry("EditTodoLayout");
if ( ! list.isEmpty() ) {
x = list[0].toInt();
y = list[1].toInt();
w = list[2].toInt();
h = list[3].toInt();
mTodoEditor->setGeometry(x,y,w,h);
}
list = config->readListEntry("ViewerLayout");
if ( ! list.isEmpty() ) {
x = list[0].toInt();
y = list[1].toInt();
w = list[2].toInt();
h = list[3].toInt();
getEventViewerDialog()->setGeometry(x,y,w,h);
}
#endif
}
void CalendarView::writeSettings()
{
// kdDebug() << "CalendarView::writeSettings" << endl;
KConfig *config = KOGlobals::config();
mViewManager->writeSettings( config );
mTodoList->saveLayout(config,QString("Todo Layout"));
mDialogManager->writeSettings( config );
//KOPrefs::instance()->usrWriteConfig();
KOPrefs::instance()->writeConfig();
writeFilterSettings(config);
config->setGroup( "Views" );
config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
QValueList<int> listINT = mLeftFrame->sizes();
config->writeEntry("Left Splitter Frame",listINT);
-
+ listINT = mMainFrame->sizes();
+ config->writeEntry("Main Splitter Frame",listINT);
#ifdef DESKTOP_VERSION
config->setGroup("WidgetLayout");
QStringList list ;//= config->readListEntry("MainLayout");
int x,y,w,h;
QWidget* wid;
wid = topLevelWidget();
x = wid->geometry().x();
y = wid->geometry().y();
w = wid->width();
h = wid->height();
list.clear();
list << QString::number( x );
list << QString::number( y );
list << QString::number( w );
list << QString::number( h );
config->writeEntry("MainLayout",list );
wid = mEventEditor;
x = wid->geometry().x();
y = wid->geometry().y();
w = wid->width();
h = wid->height();
list.clear();
list << QString::number( x );
list << QString::number( y );
list << QString::number( w );
list << QString::number( h );
config->writeEntry("EditEventLayout",list );
wid = mTodoEditor;
x = wid->geometry().x();
y = wid->geometry().y();
w = wid->width();
h = wid->height();
list.clear();
list << QString::number( x );
list << QString::number( y );
list << QString::number( w );
list << QString::number( h );
config->writeEntry("EditTodoLayout",list );
wid = getEventViewerDialog();
x = wid->geometry().x();
y = wid->geometry().y();
w = wid->width();
h = wid->height();
list.clear();
list << QString::number( x );
list << QString::number( y );
list << QString::number( w );
list << QString::number( h );
config->writeEntry("ViewerLayout",list );
wid = mDialogManager->getSearchDialog();
if ( wid ) {
x = wid->geometry().x();
y = wid->geometry().y();
w = wid->width();
h = wid->height();
list.clear();
list << QString::number( x );
list << QString::number( y );
list << QString::number( w );
list << QString::number( h );
config->writeEntry("SearchLayout",list );
}
#endif
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));
//qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
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();
config->setGroup("FilterView");
mFilterView->blockSignals(true);
mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
mFilterView->blockSignals(false);
// We do it manually to avoid it being done twice by the above calls
updateFilter();
}
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);
config->setGroup("FilterView");
config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
}
void CalendarView::goToday()
{
if ( mViewManager->currentView()->isMonthView() )
mNavigator->selectTodayMonth();
else
mNavigator->selectToday();
}
void CalendarView::goNext()
{
mNavigator->selectNext();
}
void CalendarView::goPrevious()
{
mNavigator->selectPrevious();
}
void CalendarView::goNextMonth()
{
mNavigator->selectNextMonth();
}
void CalendarView::goPreviousMonth()
{
mNavigator->selectPreviousMonth();
}
void CalendarView::writeLocale()
{
//KPimGlobalPrefs::instance()->setGlobalConfig();
#if 0
KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
QString dummy = KOPrefs::instance()->mUserDateFormatLong;
KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
dummy = KOPrefs::instance()->mUserDateFormatShort;
KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
KOPrefs::instance()->mDaylightsavingStart,
KOPrefs::instance()->mDaylightsavingEnd );
KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
#endif
}
void CalendarView::updateConfig()
{
writeLocale();
if ( KOPrefs::instance()->mUseAppColors )
QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
emit configChanged();
mTodoList->updateConfig();
// mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
// To make the "fill window" configurations work
//mViewManager->raiseCurrentView();
}
void CalendarView::eventChanged(Event *event)
{
changeEventDisplay(event,KOGlobals::EVENTEDITED);
//updateUnmanagedViews();
}
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);
}
void CalendarView::changeTodoDisplay(Todo *which, int action)
{
changeIncidenceDisplay((Incidence *)which, action);
mDateNavigator->updateView(); //LR
//mDialogManager->updateSearchDialog();
if (which) {
mViewManager->updateWNview();
//mTodoList->updateView();
}
}
void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
{
updateUnmanagedViews();
//qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
if ( action == KOGlobals::EVENTDELETED ) { //delete
mCalendar->checkAlarmForIncidence( 0, true );
if ( mEventViewerDialog )
mEventViewerDialog->hide();
}
else
mCalendar->checkAlarmForIncidence( which , false );
}
// 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;
changeIncidenceDisplay((Incidence *)which, action);
mDateNavigator->updateView();
//mDialogManager->updateSearchDialog();
if (which) {
// If there is an event view visible update the display
mViewManager->currentView()->changeEventDisplay(which,action);
// TODO: check, if update needed
// if (which->getTodoStatus()) {
mTodoList->updateView();
// }
} else {
mViewManager->currentView()->updateView();
}
}
void CalendarView::updateTodoViews()
{
mTodoList->updateView();
mViewManager->currentView()->updateView();
}
void CalendarView::updateView(const QDate &start, const QDate &end)
{
mTodoList->updateView();
mViewManager->updateView(start, end);
//mDateNavigator->updateView();
}
void CalendarView::updateView()
{
DateList tmpList = mNavigator->selectedDates();
if ( KOPrefs::instance()->mHideNonStartedTodos )
mTodoList->updateView();
// We assume that the navigator only selects consecutive days.
updateView( tmpList.first(), tmpList.last() );
}
void CalendarView::updateUnmanagedViews()
{
mDateNavigator->updateDayMatrix();
}
int CalendarView::msgItemDelete(const QString name)
{
return KMessageBox::warningContinueCancel(this,name +"\n\n"+
i18n("This item will be\npermanently deleted."),
i18n("KO/Pi Confirmation"),i18n("Delete"));
}
void CalendarView::edit_cut()
{
Event *anEvent=0;
Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
if (mViewManager->currentView()->isEventView()) {
if ( incidence && incidence->type() == "Event" ) {
anEvent = static_cast<Event *>(incidence);
}
}
if (!anEvent) {
KNotifyClient::beep();
return;
}
DndFactory factory( mCalendar );
factory.cutIncidence(anEvent);
changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
}
void CalendarView::edit_copy()
{
Event *anEvent=0;
Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
if (mViewManager->currentView()->isEventView()) {
if ( incidence && incidence->type() == "Event" ) {
anEvent = static_cast<Event *>(incidence);
}
}
if (!anEvent) {
KNotifyClient::beep();
return;
}
DndFactory factory( mCalendar );
factory.copyIncidence(anEvent);
}
void CalendarView::edit_paste()
{
QDate date = mNavigator->selectedDates().first();
DndFactory factory( mCalendar );
Event *pastedEvent = (Event *)factory.pasteIncidence( date );
changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
}
void CalendarView::edit_options()
{
QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
emit save();
emit saveStopTimer();
mDialogManager->showOptionsDialog();
if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
emit saveStopTimer();
if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
i18n("Timezone settings"),i18n("Reload"))) {
qDebug("KO: TZ reload cancelled ");
return;
}
qDebug("KO: Timezone change ");
openCalendar( MainWindow::defaultFileName() );
setModified(true);
}
else
qDebug("KO: No tz change ");
}
void CalendarView::slotSelectPickerDate( QDate d)
{
mDateFrame->hide();
if ( mDatePickerMode == 1 ) {
mNavigator->slotDaySelect( d );
} else if ( mDatePickerMode == 2 ) {
if ( mMoveIncidence->type() == "Todo" ) {
Todo * to = (Todo *) mMoveIncidence;
QTime tim;
int len = 0;
if ( to->hasStartDate() && to->hasDueDate() )
len = to->dtStart().secsTo( to->dtDue());
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index fac9a9e..16e671f 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -150,468 +150,468 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
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();
public slots:
void showOpenError();
void watchSavedFile();
void recheckTimerAlarm();
void checkNextTimerAlarm();
void addAlarm(const QDateTime &qdt, const QString &noti );
void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
void removeAlarm(const QDateTime &qdt, const QString &noti );
/** 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 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 *);
/** 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();
/** 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();
/**
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();
void dialogClosing(Incidence *);
/** 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();
int addCategories();
void removeCategories();
void setSyncDevice( QString );
void setSyncName( QString );
void showDay( QDate );
void undo_delete();
protected slots:
void resetFocus();
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 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 ;}
protected:
void schedule(Scheduler::Method, Incidence *incidence = 0);
// returns KMsgBox::OKCandel()
int msgItemDelete(const QString name);
void showEventEditor();
void showTodoEditor();
void writeLocale();
Todo *selectedTodo();
private:
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;
KOBeamPrefs* beamDialog;
void init();
int mDatePickerMode;
bool mFlagEditDescription;
QDateTime mLastCalendarSync;
void createPrinter();
void calendarModified( bool, Calendar * );
CalPrinter *mCalPrinter;
QSplitter *mPanner;
QSplitter *mLeftSplitter;
- KDGanttMinimizeSplitter *mLeftFrame;
+ KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
QWidgetStack *mRightFrame;
KDatePicker* mDatePicker;
QVBox* mDateFrame;
DateNavigatorContainer *mDateNavigator; // widget showing small month view.
KOFilterView *mFilterView;
ResourceView *mResourceView;
// calendar object for this viewing instance
Calendar *mCalendar;
CalendarResourceManager *mResourceManager;
FileStorage *mStorage;
DateNavigator *mNavigator;
KOViewManager *mViewManager;
KODialogManager *mDialogManager;
// Calendar filters
QPtrList<CalFilter> mFilters;
// various housekeeping variables.
bool mModified; // flag indicating if calendar is modified
bool mReadOnly; // flag indicating if calendar is read-only
QDate mSaveSingleDate;
Incidence *mSelectedIncidence;
Incidence *mMoveIncidence;
QDate mMoveIncidenceOldDate;
KOTodoView *mTodoList;
KOEventEditor * mEventEditor;
KOTodoEditor * mTodoEditor;
KOEventViewerDialog * mEventViewerDialog;
void keyPressEvent ( QKeyEvent *e) ;
//QMap<Incidence*,KOIncidenceEditor*> mDialogList;
};
class CalendarViewVisitor : public Incidence::Visitor
{
public:
CalendarViewVisitor() : mView( 0 ) {}
bool act( Incidence *incidence, CalendarView *view )
{
mView = view;
return incidence->accept( *this );
}
protected:
CalendarView *mView;
};
class ShowIncidenceVisitor : public CalendarViewVisitor
{
protected:
bool visit( Event *event ) { mView->showEvent( event ); return true; }
bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
bool visit( Journal * j ) { mView->showJournal( j );return true; }
};
class EditIncidenceVisitor : public CalendarViewVisitor
{
protected:
bool visit( Event *event ) { mView->editEvent( event ); return true; }
bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
bool visit( Journal *j ) { mView->editJournal( j); return true; }
};
class DeleteIncidenceVisitor : public CalendarViewVisitor
{
protected:
bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
};
#endif
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index b9bd1b9..3358ecf 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,229 +1,257 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
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 <kdebug.h>
#include <klocale.h>
//#include "koglobals.h"
#include "navigatorbar.h"
#include "kdatenavigator.h"
#include <kcalendarsystem.h>
#include "datenavigatorcontainer.h"
+#include "koprefs.h"
DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
const char *name )
: QWidget( parent, name ), mCalendar( 0 ),
mHorizontalCount( 1 ), mVerticalCount( 1 )
{
mExtraViews.setAutoDelete( true );
mNavigatorView = new KDateNavigator( this, name );
connectNavigatorView( mNavigatorView );
}
DateNavigatorContainer::~DateNavigatorContainer()
{
}
void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
{
connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
SIGNAL( datesSelected( const KCal::DateList & ) ) );
#if 0
connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
#endif
connect( v, SIGNAL( weekClicked( const QDate & ) ),
SIGNAL( weekClicked( const QDate & ) ) );
connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
}
void DateNavigatorContainer::setCalendar( Calendar *cal )
{
mCalendar = cal;
mNavigatorView->setCalendar( cal );
KDateNavigator *n;
for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
n->setCalendar( cal );
}
}
void DateNavigatorContainer::updateDayMatrix()
{
mNavigatorView->updateDayMatrix();
KDateNavigator *n;
for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
n->updateDayMatrix();
}
}
void DateNavigatorContainer::updateToday()
{
qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
#if 0
mNavigatorView->updateToday();
KDateNavigator *n;
for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
n->updateToday();
}
#endif
}
void DateNavigatorContainer::updateView()
{
mNavigatorView->updateView();
KDateNavigator *n;
for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
n->updateView();
}
}
void DateNavigatorContainer::updateConfig()
{
mNavigatorView->updateConfig();
KDateNavigator *n;
for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
n->updateConfig();
}
}
void DateNavigatorContainer::selectDates( const DateList &dateList )
{
mNavigatorView->selectDates( dateList );
setBaseDates();
if ( mExtraViews.count() ) {
KDateNavigator *view = mExtraViews.at( 0 );
view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
view->dayMatrix()->repaint();
}
}
void DateNavigatorContainer::setBaseDates()
{
KCal::DateList dateList = mNavigatorView->selectedDates();
if ( dateList.isEmpty() ) {
kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
}
QDate baseDate = dateList.first();
KDateNavigator *n;
bool doRepaint = false; // skip first repaint
for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
n->setBaseDate( baseDate, doRepaint );
doRepaint = true;
}
}
void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
{
#if 0
kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
#endif
QSize minSize = mNavigatorView->yourSizeHint();
// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
int verticalCount = size().height() / minSize.height();
int horizontalCount = size().width() / minSize.width();
//qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
//qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
+ bool fontchange = false;
+ QFont fo;
if ( horizontalCount != mHorizontalCount ||
verticalCount != mVerticalCount ) {
uint count = horizontalCount * verticalCount;
if ( count == 0 ) {
- mNavigatorView->resize( minSize );
- return;
+ bool ok;
+ fo = mNavigatorView->yourFontHint( size() , &ok);
+ //mNavigatorView->resize( size() );
+ //if ( ! ok )
+ // return;
+ minSize = mNavigatorView->sizeHint();
+ verticalCount = size().height() / minSize.height();
+ horizontalCount = size().width() / minSize.width();
+ if ( horizontalCount == 0 )
+ horizontalCount = 1;
+ if ( verticalCount == 0 )
+ verticalCount = 1;
+ fontchange = true;
+ count = horizontalCount * verticalCount;
+ } else {
+ if ( mNavigatorView->fontChanged() ) {
+ fontchange = true;
+ fo = KOPrefs::instance()->mDateNavigatorFont;
+ mNavigatorView->changeFont( fo );
+ mNavigatorView->unsetFontChanged();
+ }
}
while ( count > ( mExtraViews.count() + 1 ) ) {
KDateNavigator *n = new KDateNavigator( this );
n->setMonthSignalOffset ( mExtraViews.count()+1 );
mExtraViews.append( n );
n->setCalendar( mCalendar );
setBaseDates();
connectNavigatorView( n );
n->show();
}
while ( count < ( mExtraViews.count() + 1 ) ) {
mExtraViews.removeLast();
}
-
+ if ( fontchange ) {
+ //mNavigatorView->changeFont( fo );
+ uint i;
+ for( i = 0; i < mExtraViews.count(); ++i ) {
+ KDateNavigator *view = mExtraViews.at( i );
+ view->changeFont( fo );
+ }
+ }
mHorizontalCount = horizontalCount;
mVerticalCount = verticalCount;
}
-
int height = size().height() / verticalCount;
int width = size().width() / horizontalCount;
NavigatorBar *bar = mNavigatorView->navigatorBar();
if ( horizontalCount > 1 ) bar->showButtons( true, false );
else bar->showButtons( true, true );
mNavigatorView->setGeometry(0,
0, width, height );
for( uint i = 0; i < mExtraViews.count(); ++i ) {
int x = ( i + 1 ) % horizontalCount;
int y = ( i + 1 ) / horizontalCount;
KDateNavigator *view = mExtraViews.at( i );
bar = view->navigatorBar();
if ( y > 0 ) bar->showButtons( false, false );
else {
if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
else bar->showButtons( false, false );
}
view->setGeometry( x * width,
y * height, width, height );
}
}
QSize DateNavigatorContainer::minimumSizeHint() const
{
return mNavigatorView->minimumSizeHint();
}
QSize DateNavigatorContainer::sizeHint() const
{
return mNavigatorView->sizeHint();
}
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index b097dc1..92a0ac2 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,390 +1,430 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001,2002 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 <qstring.h>
#include <qkeycode.h>
#include <qlayout.h>
#include <qtimer.h>
#include <qframe.h>
#include <qlabel.h>
#include <qapplication.h>
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
#include "koglobals.h"
#include "koprefs.h"
#ifndef KORG_NOPLUGINS
#include "kocore.h"
#endif
#include <kcalendarsystem.h>
#include "navigatorbar.h"
#include "kdatenavigator.h"
KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
: QFrame(parent, name),
updateTimer(0L)
{
setFrameStyle(QFrame::NoFrame);
QDate startDate = QDate::currentDate();
QGridLayout *topLayout = new QGridLayout(this,8,8);
if (! startDate.isValid()) {
qDebug("KDateNavigator::invalid startdate ");
startDate = QDate::currentDate();
}
mMonthSignalOffset = 0;
mSelectedDates.append(startDate);
m_MthYr = startDate;
m_bShowWeekNums = true;
setFont( KOPrefs::instance()->mDateNavigatorFont );
mNavigatorBar = new NavigatorBar( startDate, this );
topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
//mNavigatorBar->resize( 1,1);
connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
// get the day of the week on the first day
QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
m_fstDayOfWk = dayone.dayOfWeek();
int i;
// Set up the heading fields.
for( i = 0; i < 7; i++ ) {
headings[i] = new QLabel("",this);
//headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
headings[i]->setAlignment(AlignCenter);
topLayout->addWidget(headings[i],1,i+1);
}
// Create the weeknumber labels
for( i = 0; i < 6; i++ ) {
weeknos[i] = new QLabel(this);
weeknos[i]->setAlignment(AlignCenter);
//weeknos[i]->setFont(QFont("Arial", 10));
if(!m_bShowWeekNums) {
weeknos[i]->hide();
}
weeknos[i]->installEventFilter(this);
topLayout->addWidget(weeknos[i],i+2,0);
}
daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
daymatrix->setLineWidth(1);
connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
SIGNAL( datesSelected( const KCal::DateList & ) ) );
connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
SIGNAL( eventDropped( Event * ) ) );
topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
// read settings from configuration file.
updateConfig();
enableRollover(FollowMonth);
mySizeHint = sizeHint();
+ mFontChanged = false;
+}
+void KDateNavigator::changeFont ( QFont fo )
+{
+ setFont( fo );
+ mNavigatorBar->resetFont( fo );
+}
+QFont KDateNavigator::yourFontHint( QSize si , bool *b)
+{
+ QFont fo = KOPrefs::instance()->mDateNavigatorFont;
+ *b = false;
+ int fontPoint = fo.pointSize();
+ while ( fontPoint > 5 ) {
+ --fontPoint;
+ fo.setPointSize( fontPoint );
+ setFont( fo );
+ mFontChanged = true;
+ mNavigatorBar->resetFont( fo );
+ QSize sh = sizeHint();
+ //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
+ if ( si.width() > sh.width() && si.height() > sh.height()) {
+ *b = true;
+ //qDebug("fooooooooooooooooooooooouuuuund ");
+ break;
+ }
+ }
+ //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
+ return fo;
+}
+QSize KDateNavigator::sizeHint() const
+{
+ QFontMetrics fm ( font() );
+ QSize day = daymatrix->sizeHint();
+ QSize nav = mNavigatorBar->sizeHint();
+ int wid = fm.width( "30") + day.width()+3;
+ int hei = fm.height() +day.height()+nav.height()+2;
+ if ( wid < nav.width() )
+ wid = nav.width() ;
+ //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
+ return QSize ( wid, hei );
}
void KDateNavigator::slotMonthSelected( int m )
{
if ( m_MthYr.month() <= mMonthSignalOffset)
m += 12;
int mo = m - mMonthSignalOffset;
emit monthSelected( m - mMonthSignalOffset );
}
void KDateNavigator::setCalendar( Calendar *cal )
{
daymatrix->setCalendar( cal );
}
void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
{
m_MthYr = date;
updateDates();
updateView();
KCal::DateList dates;
dates.append( date );
mNavigatorBar->selectDates( dates );
daymatrix->clearSelection();
if ( doRepaint )
daymatrix->repaint();
}
void KDateNavigator::enableRollover(RolloverType r)
{
switch(r)
{
case None :
if (updateTimer)
{
updateTimer->stop();
delete updateTimer;
updateTimer=0L;
}
break;
case FollowDay :
case FollowMonth :
if (!updateTimer)
{
updateTimer = new QTimer(this);
QObject::connect(updateTimer,SIGNAL(timeout()),
this,SLOT(possiblyPastMidnight()));
}
updateTimer->start(0,true);
lastDayChecked = QDate::currentDate();
}
updateRollover=r;
}
KDateNavigator::~KDateNavigator()
{
}
void KDateNavigator::passedMidnight()
{
QDate today = QDate::currentDate();
bool emitMonth = false;
if (today.month() != lastDayChecked.month())
{
if (updateRollover==FollowMonth &&
daymatrix->isEndOfMonth()) {
goNextMonth();
emitMonth=true;
}
}
daymatrix->recalculateToday();
daymatrix->repaint();
emit dayPassed(today);
if (emitMonth) { emit monthPassed(today); }
}
/* slot */ void KDateNavigator::possiblyPastMidnight()
{
if (lastDayChecked!=QDate::currentDate())
{
passedMidnight();
lastDayChecked=QDate::currentDate();
}
// Set the timer to go off 1 second after midnight
// or after 8 minutes, whichever comes first.
if (updateTimer)
{
QTime now = QTime::currentTime();
QTime midnight = QTime(23,59,59);
int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
// qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
// .arg(now.toString()).arg(midnight.toString()));
updateTimer->stop();
updateTimer->start(msecsWait,true);
}
}
void KDateNavigator::updateDates()
{
// Find the first day of the week of the current month.
//int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
//int di = d1 - d2 + 1;
dayone = dayone.addDays( -d2 + 1 );
int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
// If month begins on Monday and Monday is first day of week,
// month should begin on second line. Sunday doesn't have this problem.
int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
// update the matrix dates
int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
daymatrix->updateView(dayone.addDays(index));
//each updateDates is followed by an updateView -> repaint is issued there !
// daymatrix->repaint();
}
void KDateNavigator::updateDayMatrix()
{
daymatrix->updateView();
//daymatrix->repaint();
}
void KDateNavigator::updateView()
{
setUpdatesEnabled( false );
int i;
// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
daymatrix->updateView();
// set the week numbers.
for(i = 0; i < 6; i++) {
QString weeknum;
// remember, according to ISO 8601, the first week of the year is the
// first week that contains a thursday. Thus we must subtract off 4,
// not just 1.
//ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
int add = 0;
if ( ! KGlobal::locale()->weekStartsMonday() )
++add;
if (dayOfYear % 7 != 0)
weeknum.setNum(dayOfYear / 7 + 1+add);
else
weeknum.setNum(dayOfYear / 7 +add);
weeknos[i]->setText(weeknum);
}
setUpdatesEnabled( true );
// kdDebug() << "updateView() -> repaint()" << endl;
repaint();
// daymatrix->repaint();
}
void KDateNavigator::updateConfig()
{
int day;
for(int i=0; i<7; i++) {
// take the first letter of the day name to be the abbreviation
if (KGlobal::locale()->weekStartsMonday()) {
day = i+1;
} else {
if (i==0) day = 7;
else day = i;
}
QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
true );
if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
headings[i]->setText( dayName );
}
updateDates();
updateView();
}
void KDateNavigator::setShowWeekNums(bool enabled)
{
m_bShowWeekNums = enabled;
for(int i=0; i<6; i++) {
if(enabled)
weeknos[i]->show();
else
weeknos[i]->hide();
}
resize(size());
}
void KDateNavigator::selectDates(const DateList& dateList)
{
if (dateList.count() > 0) {
mNavigatorBar->selectDates( dateList );
mSelectedDates = dateList;
// set our record of the month and year that this datetbl is
// displaying.
m_MthYr = mSelectedDates.first();
// set our record of the first day of the week of the current
// month. This needs to be done before calling dayToIndex, since it
// relies on this information being up to date.
QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
m_fstDayOfWk = dayone.dayOfWeek();
updateDates();
daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
updateView();
}
}
int KDateNavigator::dayNum(int row, int col)
{
return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
}
int KDateNavigator::dayToIndex(int dayNum)
{
int row, col;
row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
row++;
col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
return row * 7 + col;
}
void KDateNavigator::wheelEvent (QWheelEvent *e)
{
if(e->delta()>0) emit goPrevious();
else emit goNext();
e->accept();
}
bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
{
if (e->type() == QEvent::MouseButtonPress) {
int i;
for(i=0;i<6;++i) {
if (o == weeknos[i]) {
QDate weekstart = daymatrix->getDate(i*7);
emit weekClicked(weekstart);
break;
}
}
return true;
} else {
return false;
}
}
//#include "kdatenavigator.moc"
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h
index 292e71c..3177687 100644
--- a/korganizer/kdatenavigator.h
+++ b/korganizer/kdatenavigator.h
@@ -1,154 +1,160 @@
/*
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 KDATENAVIGATOR_H
#define KDATENAVIGATOR_H
#include <qframe.h>
#include <qdatetime.h>
#include <qlabel.h>
#include <libkcal/calendar.h>
#include "kodaymatrix.h"
class QPushButton;
class QTimer;
class KCalendarSystem;
class NavigatorBar;
class KDateNavigator: public QFrame
{
Q_OBJECT
public:
KDateNavigator( QWidget *parent = 0,const char *name = 0 );
~KDateNavigator();
/** The DateNavigator automatically checks for
* the passage of midnight. If rollover type is
* set to None, no signals are emitted and no
* processing is done. With rollover set to
* FollowDay, the day highlighter changes at
* midnight and dayPassed() is emitted.
* With FollowMonth, it has the same effect
* as FollowDay but also adjusts the month that is
* visible and emits monthPassed() when the month changes.
*/
enum RolloverType { None, FollowDay, FollowMonth } ;
void enableRollover( RolloverType );
void setShowWeekNums( bool enabled );
void setCalendar( Calendar * );
void setBaseDate( const QDate & , bool doRepaint = true );
KCal::DateList selectedDates() const { return mSelectedDates; }
NavigatorBar *navigatorBar() const { return mNavigatorBar; }
void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;}
QSize yourSizeHint() { return mySizeHint; }
- KODayMatrix *dayMatrix() { return daymatrix ;}
+ QFont yourFontHint( QSize , bool * b);
+ bool fontChanged() {return mFontChanged; }
+ void unsetFontChanged() { mFontChanged = false; }
+ KODayMatrix *dayMatrix() { return daymatrix ;}
+ QSize sizeHint() const;
+ void changeFont ( QFont fo );
public slots:
void selectDates( const KCal::DateList & );
void updateView();
void updateConfig();
void updateDayMatrix();
signals:
void datesSelected( const KCal::DateList & );
void eventDropped( Event * );
void weekClicked( const QDate &);
void goPrevious();
void goNext();
void goNextMonth();
void goPrevMonth();
void goNextYear();
void goPrevYear();
void monthSelected( int );
// Signals emitted at midnight carrying the new date.
void dayPassed( QDate );
void monthPassed( QDate );
protected slots:
/**
* Called regularly to see if we need to update the view
* wrt. the today box and the month box. Only important
* if you leave KOrganizer idle for long periods of time.
*
* Until we have a reliable way of setting QTimers to go
* off at a particular wall-clock time, we need this,
* which calls passedMidnight() at the right moments.
*/
void possiblyPastMidnight();
/** handles updating the view when midnight has come by due to idle time.
*
*/
void passedMidnight();
void slotMonthSelected( int m );
protected:
void updateDates();
void wheelEvent (QWheelEvent *);
bool eventFilter (QObject *,QEvent *);
private:
QSize mySizeHint;
+ bool mFontChanged;
int mMonthSignalOffset;
NavigatorBar *mNavigatorBar;
QFrame *headingSep;
QFrame *weeknumSep;
QLabel *headings[7];
QLabel *weeknos[7];
KODayMatrix *daymatrix;
KCal::DateList mSelectedDates;
QDate m_MthYr;
int m_fstDayOfWk;
bool m_bShowWeekNums;
int dayNum(int row, int col);
int dayToIndex(int dayNum);
Calendar *mCalendar;
KCalendarSystem *mCalendarSystem;
const QString *curHeaders;
/** used to update the day view periodically, in particular every
* midnight to move the "today" rectangle.
*/
QTimer *updateTimer;
QDate lastDayChecked;
RolloverType updateRollover;
// Disabling copy constructor and assignment operator
KDateNavigator(const KDateNavigator & );
KDateNavigator &operator=(const KDateNavigator &);
};
#endif
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 619ae39..9181936 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -415,384 +415,395 @@ void KODayMatrix::updateEvents()
if ( ( recurType == Recurrence::rDaily &&
!KOPrefs::instance()->mDailyRecur ) ||
( recurType == Recurrence::rWeekly &&
!KOPrefs::instance()->mWeeklyRecur ) ) {
numEvents--;
}
}
events[ i ] = numEvents;
}
}
const QDate& KODayMatrix::getDate(int offset)
{
if (offset < 0 || offset > NUMDAYS-1) {
qDebug("Wrong offset2 ");
return days[0];
}
return days[offset];
}
QString KODayMatrix::getHolidayLabel(int offset)
{
if (offset < 0 || offset > NUMDAYS-1) {
qDebug("Wrong offset1 ");
return 0;
}
return mHolidays[offset];
}
int KODayMatrix::getDayIndexFrom(int x, int y)
{
return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
6 - x/daysize.width() : x/daysize.width());
}
// ----------------------------------------------------------------------------
// M O U S E E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::mousePressEvent (QMouseEvent* e)
{
if ( e->button() == LeftButton )
mouseDown = true;
mSelStart = getDayIndexFrom(e->x(), e->y());
if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
mSelInit = mSelStart;
}
void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
{
if ( e->button() == LeftButton )
if ( ! mouseDown ) {
return;
}
else
mouseDown = false;
int tmp = getDayIndexFrom(e->x(), e->y());
if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
if (mSelInit > tmp) {
mSelEnd = mSelInit;
if (tmp != mSelStart) {
mSelStart = tmp;
repaint(false);
}
} else {
mSelStart = mSelInit;
//repaint only if selection has changed
if (tmp != mSelEnd) {
mSelEnd = tmp;
repaint(false);
}
}
DateList daylist;
if ( mSelStart < 0 )
mSelStart = 0;
for (int i = mSelStart; i <= mSelEnd; i++) {
daylist.append(days[i]);
}
emit selected((const DateList)daylist);
}
void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
{
if ( ! mouseDown ) {
return;
}
int tmp = getDayIndexFrom(e->x(), e->y());
if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
if (mSelInit > tmp) {
mSelEnd = mSelInit;
if (tmp != mSelStart) {
mSelStart = tmp;
repaint(false);
}
} else {
mSelStart = mSelInit;
//repaint only if selection has changed
if (tmp != mSelEnd) {
mSelEnd = tmp;
repaint(false);
}
}
}
// ----------------------------------------------------------------------------
// D R A G ' N D R O P H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
{
#ifndef KORG_NODND
if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
e->ignore();
return;
}
// some visual feedback
// oldPalette = palette();
// setPalette(my_HilitePalette);
// update();
#endif
}
void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
{
#ifndef KORG_NODND
if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
e->ignore();
return;
}
e->accept();
#endif
}
void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
{
#ifndef KORG_NODND
// setPalette(oldPalette);
// update();
#endif
}
void KODayMatrix::dropEvent(QDropEvent *e)
{
#ifndef KORG_NODND
// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
e->ignore();
return;
}
DndFactory factory( mCalendar );
Event *event = factory.createDrop(e);
if (event) {
e->acceptAction();
Event *existingEvent = mCalendar->event(event->uid());
if(existingEvent) {
// uniquify event
event->recreate();
/*
KMessageBox::sorry(this,
i18n("Event already exists in this calendar."),
i18n("Drop Event"));
delete event;
return;
*/
}
// kdDebug() << "Drop new Event" << endl;
// Adjust date
QDateTime start = event->dtStart();
QDateTime end = event->dtEnd();
int duration = start.daysTo(end);
int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
start.setDate(days[idx]);
end.setDate(days[idx].addDays(duration));
event->setDtStart(start);
event->setDtEnd(end);
mCalendar->addEvent(event);
emit eventDropped(event);
} else {
// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
e->ignore();
}
#endif
}
// ----------------------------------------------------------------------------
// P A I N T E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
if ( width() <= 0 || height() <= 0 )
return;
if ( mPendingUpdateBeforeRepaint ) {
updateViewTimed();
mPendingUpdateBeforeRepaint = false;
}
if ( myPix.width() != width() || myPix.height()!=height() ) {
myPix.resize(size() );
}
QPainter p(&myPix);
p.setFont(font());
QRect sz = frameRect();
int dheight = daysize.height();
int dwidth = daysize.width();
int row,col;
int selw, selh;
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
p.fillRect(pevent->rect(), mDefaultBackColor);
p.setPen(mDefaultTextColor);
p.drawRect(0, 0, sz.width()+1, sz.height()+1);
int mSelStartT = mSelStart;
int mSelEndT = mSelEnd;
if ( mSelEndT >= NUMDAYS )
mSelEndT = NUMDAYS-1;
// draw selected days with highlighted background color
if (mSelStart != NOSELECTION) {
bool skip = false;
if ( ! mouseDown ) {
int mo = days[20].month();
//qDebug("-- %d %d ", mSelStartT, mSelEndT);
//qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) {
skip = true;
} else {
if ( days[mSelStartT].month() != mo ) {
int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
mSelStartT += add +1;
}
if ( days[mSelEndT].month() != mo ) {
int sub = days[mSelEndT].day();
mSelEndT -= sub ;
}
}
}
if ( ! skip ) {
row = mSelStartT/7;
col = mSelStartT -row*7;
QColor selcol = KOPrefs::instance()->mHighlightColor;
if (row == mSelEndT/7) {
// Single row selection
p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth,
row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol);
} else {
// draw first row to the right
p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
dheight, selcol);
// draw full block till last line
selh = mSelEndT/7-row;
if (selh > 1) {
p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
}
// draw last block from left to mSelEndT
selw = mSelEndT-7*(mSelEndT/7)+1;
p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
selw*dwidth, dheight, selcol);
}
}
}
// iterate over all days in the matrix and draw the day label in appropriate colors
QColor actcol = mDefaultTextColorShaded;
p.setPen(actcol);
QPen tmppen;
for(int i = 0; i < NUMDAYS; i++) {
row = i/7;
col = isRTL ? 6-(i-row*7) : i-row*7;
// if it is the first day of a month switch color from normal to shaded and vice versa
if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
if (actcol == mDefaultTextColorShaded) {
actcol = mDefaultTextColor;
} else {
actcol = mDefaultTextColorShaded;
}
p.setPen(actcol);
}
if (actcol == mDefaultTextColorShaded) {
if ( ! mouseDown ) {
continue;
}
}
//Reset pen color after selected days block
if (i == mSelEndT+1) {
p.setPen(actcol);
}
// if today then draw rectangle around day
if (today == i) {
tmppen = p.pen();
QPen mTodayPen(p.pen());
mTodayPen.setWidth(mTodayMarginWidth);
//draw red rectangle for holidays
if (!mHolidays[i].isNull()) {
if (actcol == mDefaultTextColor) {
mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
} else {
mTodayPen.setColor(mHolidayColorShaded);
}
}
//draw gray rectangle for today if in selection
if (i >= mSelStartT && i <= mSelEndT) {
QColor grey("grey");
mTodayPen.setColor(grey);
}
p.setPen(mTodayPen);
p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
p.setPen(tmppen);
}
// if any events are on that day then draw it using a bold font
if (events[i] > 0) {
QFont myFont = font();
myFont.setBold(true);
p.setFont(myFont);
}
// if it is a holiday then use the default holiday color
if (!mHolidays[i].isNull()) {
if ( bDays.testBit(i) ) {
p.setPen(Qt::green);
} else {
if (actcol == mDefaultTextColor) {
p.setPen(KOPrefs::instance()->mHolidayColor);
} else {
p.setPen(mHolidayColorShaded);
}
}
}
// draw selected days with special color
// DO NOT specially highlight holidays in selection !
if (i >= mSelStartT && i <= mSelEndT) {
;//p.setPen(mSelectedDaysColor);
}
p.drawText(col*dwidth, row*dheight, dwidth, dheight,
Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
// reset color to actual color
if (!mHolidays[i].isNull()) {
p.setPen(actcol);
}
// reset bold font to plain font
if (events[i] > 0) {
QFont myFont = font();
myFont.setBold(false);
p.setFont(myFont);
}
}
bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
}
// ----------------------------------------------------------------------------
// R E SI Z E E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::resizeEvent(QResizeEvent *)
{
QRect sz = frameRect();
daysize.setHeight(sz.height()*7 / NUMDAYS);
daysize.setWidth(sz.width() / 7);
}
+
+QSize KODayMatrix::sizeHint() const
+{
+
+ QFontMetrics fm ( font() );
+ int wid = fm.width( "30") *7+7;
+ int hei = fm.height() * 6+4;
+ //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
+ return QSize ( wid, hei );
+
+}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index c049942..39946de 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -1,321 +1,322 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
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 _KODAYMAT_H
#define _KODAYMAT_H
#include <libkcal/calendar.h>
#include <qstring.h>
#include <qframe.h>
#include <qcolor.h>
#include <qpen.h>
#include <qdatetime.h>
#include <qtooltip.h>
#include <qpixmap.h>
#include <qbitarray.h>
#include <qmap.h>
class QDragEnterEvent;
class QDragMoveEvent;
class QDragLeaveEvent;
class QDropEvent;
class KODayMatrix;
using namespace KCal;
/**
* small helper class to dynamically show tooltips inside the day matrix.
* This class asks the day matrix object for a appropriate label which
* is in our special case the name of the holiday or null if this day is no holiday.
*/
class DynamicTip : public QToolTip
{
public:
/**
* Constructor that expects a KODayMatrix object as parent.
*
* @param parent the parent KODayMatrix control.
*/
DynamicTip(QWidget* parent );
protected:
/**
* Qt's callback to ask the object to provide an approrpiate text for the
* tooltip to be shown.
*
* @param pos coordinates of the mouse.
*/
void maybeTip( const QPoint & pos);
private:
/** the parent control this tooltip is designed for. */
KODayMatrix* matrix;
};
/**
* replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
* Cornelius thought this was a waste of memory and a lot of overhead.
* In addition the selection was not very intuitive so I decided to rewrite it using a QFrame
* that draws the labels and allows for dragging selection while maintaining nearly full
* compatibility in behaviour with its predecessor.
*
* The following functionality has been changed:
*
* o when shifting events in the agenda view from one day to another the day matrix is updated now
* o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date.
* o no support for Ctrl+click to create groups of dates
* (This has not really been supported in the predecessor. It was not very intuitive nor was it
* user friendly.)
* This feature has been replaced with dragging a selection on the matrix. The matrix will
* automatically choose the appropriate selection (e.g. you are not any longer able to select
* two distinct groups of date selections as in the old class)
* o now that you can select more then a week it can happen that not all selected days are
* displayed in the matrix. However this is preferred to the alternative which would mean to
* adjust the selection and leave some days undisplayed while scrolling through the months
*
* @short day matrix widget of the KDateNavigator
*
* @author Eitzenberger Thomas
*/
class KODayMatrix: public QFrame {
Q_OBJECT
public:
/** constructor to create a day matrix widget.
*
* @param parent widget that is the parent of the day matrix. Normally this should
* be a KDateNavigator
* @param calendar instance of a calendar on which all calculations are based
* @param date start date of the matrix (is expected to be already fixed). It is
* assumed that this date is the first week day to be shown in the matrix.
* @param name name of the widget
*/
KODayMatrix( QWidget *parent, const char *name );
//KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
/** destructor that deallocates all dynamically allocated private members.
*/
~KODayMatrix();
/** updates the day matrix to start with the given date. Does all the necessary
* checks for holidays or events on a day and stores them for display later on.
* Does NOT update the view visually. Call repaint() for this.
*
* @param actdate recalculates the day matrix to show NUMDAYS starting from this
* date.
*/
void updateView(QDate actdate);
void updateEvents();
/** returns the QDate object associated with day indexed by the
* supplied offset.
*/
const QDate& getDate(int offset);
void setCalendar( Calendar * );
/** returns the official name of this holy day or 0 if there is no label
* for this day.
*/
QString getHolidayLabel(int offset);
/** adds all actual selected days from mSelStart to mSelEnd to the supplied
* DateList.
*/
void addSelectedDaysTo(DateList&);
/** sets the actual to be displayed selection in the day matrix starting from
* start and ending with end. Theview must be manually updated by calling
* repaint. (?)
*/
void setSelectedDaysFrom(const QDate& start, const QDate& end);
void clearSelection();
/** Is today visible in the view? Keep this in sync with
* the values today (below) can take.
*/
bool isTodayVisible() const { return today>=0; } ;
/** If today is visible, then we can find out if today is
* near the beginning or the end of the month.
* This is dependent on today remaining the index
* in the array of visible dates and going from
* top left (0) to bottom right (41).
*/
bool isBeginningOfMonth() const { return today<=8; } ;
bool isEndOfMonth() const { return today>=27; } ;
QString getWhatsThisText( QPoint ) ;
+ QSize sizeHint() const;
public slots:
/** Recalculates all the flags of the days in the matrix like holidays or events
* on a day (Actually calls above method with the actual startdate).
*/
void updateView();
void updateViewTimed();
void repaintViewTimed();
/**
* Calculate which square in the matrix should be
* hilighted to indicate it's today.
*/
void recalculateToday();
/*
void setStartDate(QDate);
*/
signals:
/** emitted if the user selects a block of days with the mouse by dragging a rectangle
* inside the matrix
*
* @param daylist list of days that have been selected by the user
*/
void selected( const KCal::DateList &daylist );
/** emitted if the user has dropped an event inside the matrix
*
* @param event the dropped calendar event
*/
void eventDropped(Event *event);
protected:
void paintEvent(QPaintEvent *ev);
void mousePressEvent (QMouseEvent* e);
void mouseReleaseEvent (QMouseEvent* e);
void mouseMoveEvent (QMouseEvent* e);
void dragEnterEvent(QDragEnterEvent *);
void dragMoveEvent(QDragMoveEvent *);
void dragLeaveEvent(QDragLeaveEvent *);
void dropEvent(QDropEvent *);
void resizeEvent(QResizeEvent *);
private:
bool mouseDown;
QBitArray bDays;
QPixmap myPix;
QTimer* mUpdateTimer;
QTimer* mRepaintTimer;
bool mDayChanged;
bool mPendingUpdateBeforeRepaint;
/** returns the index of the day located at the matrix's widget (x,y) position.
*
* @param x horizontal coordinate
* @param y vertical coordinate
*/
int getDayIndexFrom(int x, int y);
/** calculates a "shaded" color from the supplied color object.
* (Copied from Cornelius's kdpdatebutton.cpp)
*
* @param color source based on which a shaded color should be calculated.
*/
QColor getShadedColor(QColor color);
/** number of days to be displayed. For now there is no support for any other number then 42.
so change it at your own risk :o) */
static const int NUMDAYS;
/** calendar instance to be queried for holidays, events, ... */
Calendar *mCalendar;
/** starting date of the matrix */
QDate startdate;
/** array of day labels to optimeize drawing performance. */
QString *daylbls;
/** array of days displayed to reduce memory consumption by
subsequently calling QDate::addDays(). */
QDate *days;
/** array of storing the number of events on a given day.
* used for drawing a bold font if there is at least one event on that day.
*/
int *events;
/** stores holiday names of the days shown in the matrix. */
QMap<int,QString> mHolidays;
/** indey of today or -1 if today is not visible in the matrix. */
int today;
/** index of day where dragged selection was initiated.
used to detect "negative" timely selections */
int mSelInit;
/** if mSelStart has this value it indicates that there is no
actual selection in the matrix. */
static const int NOSELECTION;
/** index of first selected day. */
int mSelStart;
/** index of last selected day. */
int mSelEnd;
/** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */
DynamicTip* mToolTip;
/** default background colour of the matrix. */
QColor mDefaultBackColor;
/** default text color of the matrix. */
QColor mDefaultTextColor;
/** default text color for days not in the actual month. */
QColor mDefaultTextColorShaded;
/** default text color for holidays not in the actual month. */
QColor mHolidayColorShaded;
/** text color for selected days. */
QColor mSelectedDaysColor;
/** default width of the frame drawn around today if it is visible in the matrix. */
int mTodayMarginWidth;
/** stores actual size of each day in the widget so that I dont need to ask this data
* on every repaint.
*/
QRect daysize;
};
#endif
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index 27d4d17..4a51bba 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -1,244 +1,247 @@
/*
This file is part of KOrganizer.
Copyright (c) 2003 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 <qstring.h>
#include <qtooltip.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qframe.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qapplication.h>
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
#include <kiconloader.h>
#include "libkdepim/kdatepicker.h"
#include <knotifyclient.h>
#include "kdatetbl.h"
#include "koglobals.h"
#include <kglobalsettings.h>
#include "koprefs.h"
#ifndef KORG_NOPLUGINS
#include "kocore.h"
#endif
#include <kcalendarsystem.h>
#include "navigatorbar.h"
NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
: QWidget( parent, name )
{
QBoxLayout *topLayout = new QHBoxLayout( this );
// Set up the control buttons and date label
mCtrlFrame = new QFrame( this );
mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
mCtrlFrame->setLineWidth(1);
topLayout->addWidget( mCtrlFrame );
- QFont tfont = font();
- if ( QApplication::desktop()->width() >= 480 )
- tfont.setPointSize(tfont.pointSize()+2);
- tfont.setBold(true);
+
bool isRTL = KOGlobals::self()->reverseLayout();
#ifndef DESKTOP_VERSION
bool isDesktop = false;
#else
bool isDesktop = true;
#endif
if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
isDesktop = true;
// Create backward navigation buttons
mPrevYear = new QPushButton( mCtrlFrame );
mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
QToolTip::add( mPrevYear, i18n("Previous Year") );
mPrevMonth = new QPushButton( mCtrlFrame );
mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
QToolTip::add( mPrevMonth, i18n("Previous Month") );
// Create forward navigation buttons
mNextMonth = new QPushButton( mCtrlFrame );
mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
QToolTip::add( mNextMonth, i18n("Next Month") );
mPrevWeek = new QPushButton( mCtrlFrame );
mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
QToolTip::add( mPrevWeek, i18n("Previous Week") );
// Create forward navigation buttons
mNextWeek = new QPushButton( mCtrlFrame );
mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
QToolTip::add( mNextWeek, i18n("Next Week") );
mNextYear = new QPushButton( mCtrlFrame );
mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
QToolTip::add( mNextYear, i18n("Next Year") );
mSelectMonth = new QPushButton( mCtrlFrame );
// Create month name label
//selectMonth->setFont( tfont );
// selectMonth->setAlignment( AlignCenter );
//mDateLabel = new QLabel( selectMonth );
//mDateLabel->setFont( tfont );
//mDateLabel->setAlignment( AlignCenter );
if ( QString ( name ) == QString("useBigPixmaps") ) {
mNextMonth->setFlat( true);
mNextWeek->setFlat( true);
mNextYear->setFlat( true);
mSelectMonth->setFlat( true);
mPrevYear->setFlat( true);
mPrevMonth->setFlat( true);
mPrevWeek->setFlat( true);
} else {
mPrevWeek->hide();
mNextWeek->hide();
}
- mSelectMonth->setFont( tfont );
- // Set minimum width to width of widest month name label
- int i;
- int maxwidth = 0;
- QFontMetrics fm ( mSelectMonth->font() );
- int width = fm.width("September '00" );
-// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
-// ++i ) {
-// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
-// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
-// int width = fm.width("September 2000" );
-// if ( width > maxwidth ) maxwidth = width;
-// }
- maxwidth = width+2;
- int size = fm.height()+2;
- if ( QApplication::desktop()->width() >= 480 ) {
- size += 6;
- maxwidth+= 6;
- }
- mSelectMonth->setFixedWidth( maxwidth );
- mSelectMonth->setFixedHeight( size );
- mPrevYear->setFixedHeight( size );
- mPrevMonth->setFixedHeight( size );
- mPrevWeek->setFixedHeight( size );
- mNextMonth->setFixedHeight( size );
- mNextWeek->setFixedHeight( size );
- mNextYear->setFixedHeight ( size );
+ resetFont( font() );
+
+
// set up control frame layout
QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
ctrlLayout->addWidget( mPrevYear, 3 );
ctrlLayout->addWidget( mPrevMonth, 3 );
ctrlLayout->addWidget( mPrevWeek, 3 );
//ctrlLayout->addStretch( 1 );
// ctrlLayout->addSpacing( 1 );
// ctrlLayout->addWidget( mDateLabel );
ctrlLayout->addWidget( mSelectMonth );
// ctrlLayout->addSpacing( 1 );
// ctrlLayout->addStretch( 1 );
ctrlLayout->addWidget( mNextWeek, 3 );
ctrlLayout->addWidget( mNextMonth, 3 );
ctrlLayout->addWidget( mNextYear, 3 );
connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) );
connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) );
connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
mPrevYear->setFocusPolicy(NoFocus);
mPrevMonth->setFocusPolicy(NoFocus);
mNextMonth->setFocusPolicy(NoFocus);
mPrevWeek->setFocusPolicy(NoFocus);
mNextWeek->setFocusPolicy(NoFocus);
mNextYear->setFocusPolicy(NoFocus);
mSelectMonth->setFocusPolicy(NoFocus);
setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
}
NavigatorBar::~NavigatorBar()
{
}
+void NavigatorBar::resetFont ( QFont fo )
+{
+
+ QFont tfont = fo;
+ if ( QApplication::desktop()->width() >= 480 )
+ tfont.setPointSize(tfont.pointSize()+2);
+ tfont.setBold(true);
+
+ mSelectMonth->setFont( tfont );
+ // Set minimum width to width of widest month name label
+ int i;
+ int maxwidth = 0;
+ QFontMetrics fm ( mSelectMonth->font() );
+ int width = fm.width("September '00" );
+ maxwidth = width+2;
+ int size = fm.height()+2;
+ if ( QApplication::desktop()->width() >= 480 ) {
+ size += 6;
+ maxwidth+= 6;
+ }
+ mSelectMonth->setMinimumWidth( maxwidth );
+ mSelectMonth->setFixedHeight( size );
+ mPrevYear->setFixedHeight( size );
+ mPrevMonth->setFixedHeight( size );
+ mPrevWeek->setFixedHeight( size );
+ mNextMonth->setFixedHeight( size );
+ mNextWeek->setFixedHeight( size );
+ mNextYear->setFixedHeight ( size );
+}
+
void NavigatorBar::showButtons( bool left, bool right )
{
if ( left ) {
mPrevYear->show();
mPrevMonth->show();
} else {
mPrevYear->hide();
mPrevMonth->hide();
}
if ( right ) {
mNextYear->show();
mNextMonth->show();
} else {
mNextYear->hide();
mNextMonth->hide();
}
if ( !left && !right ) {
- mSelectMonth->setMaximumWidth( 1024 );
+ //mSelectMonth->setMaximumWidth( 1024 );
mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
}
}
void NavigatorBar::selectMonth()
{
int month;
KPopupFrame* popup = new KPopupFrame(this);
KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup);
// -----
picker->resize(picker->sizeHint());
popup->setMainWidget(picker);
picker->setFocus();
connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
{
month = picker->getResult();
emit monthSelected ( month );
} else {
KNotifyClient::beep();
}
delete popup;
}
void NavigatorBar::selectDates( const KCal::DateList &dateList )
{
if (dateList.count() > 0) {
QDate date = dateList.first();
const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
// compute the label at the top of the navigator
QString dtstr = i18n(calSys->monthName( date )) + " '" +
QString::number( calSys->year( date ) ).right(2);
mSelectMonth->setText( dtstr );
}
}
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h
index 4442caa..0b2f60b 100644
--- a/korganizer/navigatorbar.h
+++ b/korganizer/navigatorbar.h
@@ -1,70 +1,71 @@
/*
This file is part of KOrganizer.
Copyright (c) 2003 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 NAVIGATORBAR_H
#define NAVIGATORBAR_H
#include <libkcal/incidencebase.h>
#include <qwidget.h>
class QPushButton;
class QFrame;
class QLabel;
class NavigatorBar: public QWidget
{
Q_OBJECT
public:
NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 );
~NavigatorBar();
void showButtons( bool left, bool right );
+ void resetFont ( QFont fo );
public slots:
void selectDates( const KCal::DateList & );
void selectMonth();
signals:
void goNextMonth();
void goPrevMonth();
void goNextWeek();
void goPrevWeek();
void goNextYear();
void goPrevYear();
void monthSelected( int );
private:
QFrame *mCtrlFrame;
QPushButton *mPrevYear;
QPushButton *mPrevMonth;
QPushButton *mNextMonth;
QPushButton *mPrevWeek;
QPushButton *mNextWeek;
QPushButton *mNextYear;
QPushButton *mSelectMonth;
//QLabel *mDateLabel;
};
#endif