summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorgeneralevent.cpp26
-rw-r--r--korganizer/koeditorgeneralevent.h2
-rw-r--r--korganizer/koeventviewerdialog.cpp7
3 files changed, 19 insertions, 16 deletions
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp
index 3b2a276..af97ee9 100644
--- a/korganizer/koeditorgeneralevent.cpp
+++ b/korganizer/koeditorgeneralevent.cpp
@@ -49,268 +49,274 @@
KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent,
const char* name) :
KOEditorGeneral( parent, name)
{
mTemplate = false;
connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
SLOT(setDuration()));
connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
SLOT(emitDateTimeStr()));
}
KOEditorGeneralEvent::~KOEditorGeneralEvent()
{
}
void KOEditorGeneralEvent::finishSetup()
{
//disabled
// QWidget::setTabOrder( mSummaryEdit, mLocationEdit );
// QWidget::setTabOrder( mLocationEdit, mStartDateEdit );
// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit );
// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit );
// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit );
// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton );
// QWidget::setTabOrder( mNoTimeButton, mAlarmButton );
// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit );
// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton );
// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo );
// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit );
mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
mSummaryEdit->setFocus();
}
void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout)
{
QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
i18n("Date && Time"),parent);
timeLayout->addWidget(timeGroupBox);
timeGroupBox->layout()->setSpacing( 0 );
timeGroupBox->layout()->setMargin( 5 );
QFrame *timeBoxFrame = new QFrame(timeGroupBox);
QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3);
layoutTimeBox->setSpacing(topLayout->spacing());
mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame);
layoutTimeBox->addWidget(mStartDateLabel,0,0);
mStartDateEdit = new KDateEdit(timeBoxFrame);
layoutTimeBox->addWidget(mStartDateEdit,0,1);
mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
layoutTimeBox->addWidget(mStartTimeEdit,0,2);
mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame);
layoutTimeBox->addWidget(mEndDateLabel,1,0);
mEndDateEdit = new KDateEdit(timeBoxFrame);
layoutTimeBox->addWidget(mEndDateEdit,1,1);
mEndTimeEdit = new KOTimeEdit(timeBoxFrame);
layoutTimeBox->addWidget(mEndTimeEdit,1,2);
QWidget* duration = new QWidget( timeBoxFrame );
QHBoxLayout *flagsBox = new QHBoxLayout( duration );
mNoTimeButton = new QCheckBox(i18n("All day event"),duration);
flagsBox->addWidget(mNoTimeButton);
connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool)));
mDurationLabel = new QLabel( duration );
// if ( KOPrefs::instance()->mCompactDialogs ) {
//layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 );
//} else {
flagsBox->addWidget( mDurationLabel );
//}
flagsBox->setStretchFactor(mDurationLabel, 10 );
mDurationLabel->setAlignment( AlignRight | AlignVCenter);
layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 );
// time widgets are checked if they contain a valid time
connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)),
this, SLOT(startTimeChanged(QTime)));
connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)),
this, SLOT(endTimeChanged(QTime)));
// date widgets are checked if they contain a valid date
connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
this, SLOT(startDateChanged(QDate)));
connect(mEndDateEdit, SIGNAL(dateChanged(QDate)),
this, SLOT(endDateChanged(QDate)));
- connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime)));
- connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),mEndTimeEdit,SLOT(setTime(QTime)));
-
+ connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime)));
+ connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime)));
}
void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout)
{
QBoxLayout *classLayout = new QHBoxLayout(topLayout);
QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent);
classLayout->addWidget(freeTimeLabel);
mFreeTimeCombo = new QComboBox(false, parent);
mFreeTimeCombo->insertItem(i18n("Busy"));
mFreeTimeCombo->insertItem(i18n("Free"));
classLayout->addWidget(mFreeTimeCombo);
}
void KOEditorGeneralEvent::timeStuffDisable(bool disable)
{
mStartTimeEdit->setEnabled( !disable );
mEndTimeEdit->setEnabled( !disable );
setDuration();
emitDateTimeStr();
}
void KOEditorGeneralEvent::dontAssociateTime(bool noTime)
{
timeStuffDisable(noTime);
//if(alarmButton->isChecked()) alarmStuffDisable(noTime);
allDayChanged(noTime);
}
void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end)
{
// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl;
if ( !mTemplate )
mStartDateEdit->setDate(start.date());
// KTimeEdit seems to emit some signals when setTime() is called.
mStartTimeEdit->blockSignals( true );
mStartTimeEdit->setTime(start.time());
mStartTimeEdit->blockSignals( false );
if ( !mTemplate )
mEndDateEdit->setDate(end.date());
mEndTimeEdit->setTime(end.time());
mCurrStartDateTime = start;
mCurrEndDateTime = end;
setDuration();
emitDateTimeStr();
}
+void KOEditorGeneralEvent::sTimeChanged(QTime ti)
+{
+ mStartTimeEdit->setTime( ti );
+ startTimeChanged ( ti);
+}
+void KOEditorGeneralEvent::eTimeChanged(QTime ti )
+{
+ mEndTimeEdit->setTime( ti );
+ endTimeChanged( ti );
+}
void KOEditorGeneralEvent::startTimeChanged(QTime newtime)
{
- kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl;
int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime);
- mCurrStartDateTime.setTime(newtime);
-
+ mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) );
// adjust end time so that the event has the same duration as before.
- mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep);
+ if( secsep > 0 )
+ mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep);
mEndTimeEdit->setTime(mCurrEndDateTime.time());
mEndDateEdit->setDate(mCurrEndDateTime.date());
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::endTimeChanged(QTime newtime)
{
-// kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl;
- QDateTime newdt(mCurrEndDateTime.date(), newtime);
- mCurrEndDateTime = newdt;
+ mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0));
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::startDateChanged(QDate newdate)
{
int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime);
mCurrStartDateTime.setDate(newdate);
// adjust end date so that the event has the same duration as before
mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep));
mEndDateEdit->setDate(mCurrEndDateTime.date());
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::endDateChanged(QDate newdate)
{
QDateTime newdt(newdate, mCurrEndDateTime.time());
if(newdt < mCurrStartDateTime) {
// oops, we can't let that happen.
newdt = mCurrStartDateTime;
mEndDateEdit->setDate(newdt.date());
mEndTimeEdit->setTime(newdt.time());
}
mCurrEndDateTime = newdt;
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay)
{
mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
mLocationEdit->load(KOLocationBox::LOCATION);
KOEditorGeneral::setDefaults(allDay);
mNoTimeButton->setChecked(allDay);
timeStuffDisable(allDay);
mFreeTimeCombo->setCurrentItem( 0 );
setDateTimes(from,to);
}
void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl )
{
QString tmpStr;
mTemplate = tmpl;
// the rest is for the events only
mNoTimeButton->setChecked(event->doesFloat());
timeStuffDisable(event->doesFloat());
setDateTimes(event->dtStart(),event->dtEnd());
mTemplate = false;
switch( event->transparency() ) {
case Event::Transparent:
mFreeTimeCombo->setCurrentItem(1);
break;
case Event::Opaque:
mFreeTimeCombo->setCurrentItem(0);
break;
}
mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
mLocationEdit->load(KOLocationBox::LOCATION);
readIncidence(event);
}
void KOEditorGeneralEvent::writeEvent(Event *event)
{
// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl;
writeIncidence(event);
QDate tmpDate;
QTime tmpTime;
QDateTime tmpDT;
// temp. until something better happens.
QString tmpStr;
if (mNoTimeButton->isChecked()) {
event->setFloats(true);
// need to change this.
tmpDate = mStartDateEdit->date();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
event->setDtStart(tmpDT);
tmpDate = mEndDateEdit->date();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
diff --git a/korganizer/koeditorgeneralevent.h b/korganizer/koeditorgeneralevent.h
index 0174788..9649806 100644
--- a/korganizer/koeditorgeneralevent.h
+++ b/korganizer/koeditorgeneralevent.h
@@ -1,109 +1,111 @@
/*
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 _KOEDITORGENERALEVENT_H
#define _KOEDITORGENERALEVENT_H
#include <qframe.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qmultilineedit.h>
#include <qlistview.h>
#include <qradiobutton.h>
#include <krestrictedline.h>
#include "koeditorgeneral.h"
#include "ktimeedit.h"
class KDateEdit;
using namespace KCal;
class KOEditorGeneralEvent : public KOEditorGeneral
{
Q_OBJECT
public:
KOEditorGeneralEvent (QObject* parent=0,const char* name=0);
virtual ~KOEditorGeneralEvent();
void initTime(QWidget *,QBoxLayout *);
void initClass(QWidget *,QBoxLayout *);
void finishSetup();
/** Set widgets to default values */
void setDefaults(QDateTime from,QDateTime to,bool allDay);
/**
Read event object and setup widgets accordingly. If templ is true, the
event is read as template, i.e. the time and date information isn't set.
*/
void readEvent( Event *, bool tmpl = false );
/** Write event settings to event object */
void writeEvent(Event *);
/** Check if the input is valid. */
bool validateInput();
public slots:
void setDateTimes(QDateTime start, QDateTime end);
void setDuration();
protected slots:
void timeStuffDisable(bool disable);
void dontAssociateTime(bool noTime);
void startTimeChanged(QTime);
void startDateChanged(QDate);
void endTimeChanged(QTime);
void endDateChanged(QDate);
void emitDateTimeStr();
+ void sTimeChanged(QTime);
+ void eTimeChanged(QTime);
signals:
void dateTimesChanged(QDateTime start,QDateTime end);
void allDayChanged(bool);
void dateTimeStrChanged(const QString &);
private:
bool mTemplate;
QLabel *mStartDateLabel;
QLabel *mEndDateLabel;
KDateEdit *mStartDateEdit;
KDateEdit *mEndDateEdit;
KOTimeEdit *mStartTimeEdit;
KOTimeEdit *mEndTimeEdit;
QLabel *mDurationLabel;
QCheckBox *mNoTimeButton;
QComboBox *mFreeTimeCombo;
// current start and end date and time
QDateTime mCurrStartDateTime;
QDateTime mCurrEndDateTime;
};
#endif
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index baa11b5..e5ff8af 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -123,190 +123,185 @@ void KOEventViewerDialog::setColorMode( int m )
int KOEventViewerDialog::executeS( bool local )
{
mSyncResult = 3;
if ( local )
findButton( User1 )->setFocus();
else
findButton( Ok )->setFocus();
exec();
return mSyncResult;
}
void KOEventViewerDialog::updateConfig()
{
mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
}
void KOEventViewerDialog::setEvent(Event *event)
{
mEventViewer->setEvent(event);
mIncidence = event;
mEventViewer->setFocus();
//findButton( Close )->setFocus();
if ( !mSyncMode ) {
findButton( User1 )->setText( i18n("Agenda"));
}
}
void KOEventViewerDialog::setIncidence(Incidence *in )
{
if ( in->type() == "Event" )
setEvent( (Event*) in );
else if ( in->type() =="Todo" )
setTodo( (Todo*) in );
else if ( in->type() =="Journal" )
setJournal( (Journal*) in );
}
void KOEventViewerDialog::addIncidence(Incidence *in)
{
if ( in->type() == "Event" )
addEvent( (Event*) in );
else if ( in->type() =="Todo" )
mEventViewer->setTodo( (Todo*) in, false );
else if ( in->type() =="Journal" )
mEventViewer->setJournal( (Journal*) in, false );
if ( mSyncMode ) {
findButton( User1 )->setFocus();
setCaption(i18n("Conflict! Please choose entry"));
}
}
void KOEventViewerDialog::addEvent(Event *event)
{
mEventViewer->addEvent(event);
mIncidence = event;
mEventViewer->setFocus();
//findButton( Close )->setFocus();
if ( !mSyncMode ) {
findButton( User1 )->setText( i18n("Agenda"));
}
}
void KOEventViewerDialog::setTodo(Todo *event)
{
mEventViewer->setTodo(event);
mIncidence = (Incidence*)event;
mEventViewer->setFocus();
//findButton( Close )->setFocus();
if ( !mSyncMode ) {
findButton( User1 )->setText( i18n("Set complete"));
}
}
void KOEventViewerDialog::setJournal(Journal *j)
{
mEventViewer->setJournal(j);
mIncidence = (Incidence*)j;
mEventViewer->setFocus();
//findButton( Close )->setFocus();
if ( !mSyncMode ) {
findButton( User1 )->setText( i18n("Agenda"));
}
}
void KOEventViewerDialog::addText(QString text)
{
mEventViewer->addText(text);
mEventViewer->setFocus();
//findButton( Close )->setFocus();
}
void KOEventViewerDialog::editIncidence()
{
sendSignalViewerClosed = false;
if ( mSyncMode ) {
mSyncResult = 2;
accept();
return;
}
if ( mIncidence ){
-#ifndef DESKTOP_VERSION
- //hide();
close();
-#endif
emit editIncidence( mIncidence );
}
}
void KOEventViewerDialog::showIncidence()
{
sendSignalViewerClosed = false;
if ( mSyncMode ) {
mSyncResult = 1;
accept();
return;
}
if ( mIncidence ){
QDate date;
if ( mIncidence->type() == "Todo" ) {
/*
if ( ((Todo*)mIncidence)->hasDueDate() )
date = ((Todo*)mIncidence)->dtDue().date();
else {
globalFlagBlockAgenda = 2;
emit showAgendaView( false );
return;
}
*/
((Todo*)mIncidence)->setCompleted( true );
((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() );
emit todoCompleted(((Todo*)mIncidence));
} else {
date = mIncidence->dtStart().date();
globalFlagBlockAgenda = 1;
emit showAgendaView( false );
globalFlagBlockAgenda = 2;
emit jumpToTime( date );
}
-#ifndef DESKTOP_VERSION
- reject();
-#endif
+ close();
}
}
void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
{
switch ( e->key() ) {
case Qt::Key_A :
case Qt::Key_L :
showIncidence();
break;
case Qt::Key_E :
case Qt::Key_R :
editIncidence();
break;
case Qt::Key_C:
case Qt::Key_Escape:
sendSignalViewerClosed = true;
close();
break;
case Qt::Key_I:
#ifndef DESKTOP_VERSION
sendSignalViewerClosed = true;
close();
#else
sendSignalViewerClosed = true;
slotViewerClosed();
//accept();
#endif
break;
default:
KDialogBase::keyPressEvent ( e );
break;
}
}
void KOEventViewerDialog::hideEvent ( QHideEvent * e )
{
KDialogBase::hideEvent ( e );
QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) );
}
void KOEventViewerDialog::slotViewerClosed()
{
if ( mSyncMode )
return;
if ( sendSignalViewerClosed ) {
//qDebug("KOEventViewerDialog::hideEvent ");
emit signalViewerClosed();
}
sendSignalViewerClosed = true;
}