summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp60
1 files changed, 35 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 697093e..776cdd3 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -359,28 +359,27 @@ CalendarView::CalendarView( Calendar *calendar,
mEventEditor = 0;
mTodoEditor = 0;
init();
}
void CalendarView::init()
{
mNextAlarmDateTime = QDateTime::currentDateTime();
setFocusPolicy ( NoFocus );
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.
@@ -436,47 +435,50 @@ void CalendarView::init()
mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
} else {
//mainBoxLayout = new QHBoxLayout(mainBox);
//leftFrameLayout = new QVBoxLayout(leftFrame );
mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
}
mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
//QBoxLayout * leftFrameLayout;
+ mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this );
topLayout->addWidget( mMainFrame );
+ topLayout->addWidget( mDateScrollBar );
//mainBoxLayout->addWidget (mLeftFrame);
mDateNavigator = new DateNavigatorContainer( mLeftFrame,
"CalendarView::DateNavigator" );
#if 0
// FIXME
mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
"CalendarView::DateNavigator", QDate::currentDate());
#endif
// mDateNavigator->blockSignals( true );
//leftFrameLayout->addWidget( mDateNavigator );
mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
+ connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
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();
@@ -633,28 +635,51 @@ void CalendarView::init()
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::setScrollBarStep(int val )
+{
+ mDateScrollBar->setLineStep ( val );
+}
+void CalendarView::scrollBarValue(int val )
+{
+ static bool block = false;
+ if ( block ) return;
+ block = true;
+ val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
+ //qDebug("VAL %d ",val );
+ int count = mNavigator->selectedDates().count();
+ int year = mNavigator->selectedDates().first().year();
+ int day = mNavigator->selectedDates().first().dayOfYear();
+ if ( val == day -1 ) {
+ block = false;
+ return;
+ }
+ QDate d ( year,1,1 );
+ mNavigator->selectDates( d.addDays( val ), count );
+ block = false;
+
+}
+
void CalendarView::checkAlarms()
{
KConfig *config = KOGlobals::config();
config->setGroup( "AppRun" );
QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
int daysto = dt.daysTo( QDate::currentDate() );
int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
dt = dt.addDays( days );
int secto = dt.secsTo( QDateTime::currentDateTime() );
int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
//qDebug("KO: Reading program stop %d ", secs);
//secs -= ( 3600 * 24*3 ); // debug only
@@ -2458,45 +2483,27 @@ 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)
@@ -2568,24 +2575,25 @@ void CalendarView::changeEventDisplay(Event *which, int action)
void CalendarView::updateTodoViews()
{
mTodoList->updateView();
mViewManager->currentView()->updateView();
}
void CalendarView::updateView(const QDate &start, const QDate &end)
{
+ mDateScrollBar->setValue( start.dayOfYear()-1);
mTodoList->updateView();
mViewManager->updateView(start, end);
//mDateNavigator->updateView();
}
void CalendarView::clearAllViews()
{
mTodoList->clearList();
mViewManager->clearAllViews();
SearchDialog * sd = mDialogManager->getSearchDialog();
if ( sd ) {
KOListView* kol = sd->listview();
@@ -2835,61 +2843,63 @@ void CalendarView::beamCalendar()
QPtrList<Incidence> delSel = mCalendar->rawIncidences();
//qDebug("beamCalendar() ");
beamIncidenceList( delSel );
}
void CalendarView::beamFilteredCalendar()
{
QPtrList<Incidence> delSel = mCalendar->incidences();
//qDebug("beamFilteredCalendar() ");
beamIncidenceList( delSel );
}
void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
{
- if ( beamDialog->exec () == QDialog::Rejected )
+
+ KOBeamPrefs beamDialog;
+ if ( beamDialog.exec () == QDialog::Rejected )
return;
#ifdef DESKTOP_VERSION
QString fn = locateLocal( "tmp", "kopibeamfile" );
#else
QString fn = "/tmp/kopibeamfile";
#endif
QString mes;
bool createbup = true;
if ( createbup ) {
QString description = "\n";
CalendarLocal* cal = new CalendarLocal();
- if ( beamDialog->beamLocal() )
+ if ( beamDialog.beamLocal() )
cal->setLocalTime();
else
cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
Incidence *incidence = delSel.first();
bool addText = false;
if ( delSel.count() < 10 )
addText = true;
else {
description.sprintf(i18n(" %d items?"),delSel.count() );
}
while ( incidence ) {
Incidence *in = incidence->clone();
if ( ! in->summary().isEmpty() ) {
in->setDescription("");
} else {
in->setSummary( in->description().left(20));
in->setDescription("");
}
if ( addText )
description += in->summary() + "\n";
cal->addIncidence( in );
incidence = delSel.next();
}
- if ( beamDialog->beamVcal() ) {
+ if ( beamDialog.beamVcal() ) {
fn += ".vcs";
FileStorage storage( cal, fn, new VCalFormat );
storage.save();
} else {
fn += ".ics";
FileStorage storage( cal, fn, new ICalFormat( ) );
storage.save();
}
delete cal;
mes = i18n("KO/Pi: Ready for beaming");
topLevelWidget()->setCaption(mes);
KApplication::convert2latin1( fn );