summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-18 10:41:31 (UTC)
committer zautrix <zautrix>2005-04-18 10:41:31 (UTC)
commit409e329447a7d00a93a56855fcddadbb0f793163 (patch) (side-by-side diff)
tree1c92498d2dfb4c89358c64a6944aca1300a27d11 /korganizer
parent0ff0dca7ccb94ebb1381351e4e4081fe0bac500a (diff)
downloadkdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.zip
kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.tar.gz
kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.tar.bz2
morefixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorgeneraltodo.cpp20
-rw-r--r--korganizer/kolistview.cpp53
-rw-r--r--korganizer/kotodoeditor.cpp53
-rw-r--r--korganizer/kotodoview.cpp11
4 files changed, 73 insertions, 64 deletions
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index 4a1576a..e86b4d0 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -30,24 +30,25 @@
#include <qwidgetstack.h>
#include <qdatetime.h>
#include <qapplication.h>
#include <kglobal.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <krestrictedline.h>
#include <kstandarddirs.h>
#include <kfiledialog.h>
+#include <kdialog.h>
#include <libkcal/todo.h>
#include <libkdepim/kdateedit.h>
#include "koprefs.h"
#include "ktimeedit.h"
#include "koeditorgeneraltodo.h"
#include "kolocationbox.h"
KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent,
@@ -79,54 +80,54 @@ void KOEditorGeneralTodo::finishSetup()
// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit);
mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
mSummaryEdit->setFocus();
}
void KOEditorGeneralTodo::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 );
+ timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() );
+ timeGroupBox->layout()->setMargin( KDialog::marginHint() );
QFrame *timeBoxFrame = new QFrame(timeGroupBox);
QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3);
- layoutTimeBox->setSpacing(topLayout->spacing());
+ layoutTimeBox->setSpacing(KDialog::spacingHintSmall());
layoutTimeBox->setColStretch( 1, 1 );
mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame);
- layoutTimeBox->addWidget(mDueCheck,0,0);
+ layoutTimeBox->addWidget(mDueCheck,1,0);
connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool)));
connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm()));
mDueDateEdit = new KDateEdit(timeBoxFrame);
- layoutTimeBox->addWidget(mDueDateEdit,0,1);
+ layoutTimeBox->addWidget(mDueDateEdit,1,1);
mDueTimeEdit = new KOTimeEdit(timeBoxFrame);
- layoutTimeBox->addWidget(mDueTimeEdit,0,2);
+ layoutTimeBox->addWidget(mDueTimeEdit,1,2);
mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame);
- layoutTimeBox->addWidget(mStartCheck,1,0);
+ layoutTimeBox->addWidget(mStartCheck,0,0);
connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool)));
mStartDateEdit = new KDateEdit(timeBoxFrame);
- layoutTimeBox->addWidget(mStartDateEdit,1,1);
+ layoutTimeBox->addWidget(mStartDateEdit,0,1);
mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
- layoutTimeBox->addWidget(mStartTimeEdit,1,2);
+ layoutTimeBox->addWidget(mStartTimeEdit,0,2);
mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame);
layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1);
connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool)));
connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime)));
connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime)));
// some more layouting
//layoutTimeBox->setColStretch(3,1);
}
@@ -332,25 +333,24 @@ void KOEditorGeneralTodo::writeTodo(Todo *todo)
tmpDate = mStartDateEdit->date();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
todo->setDtStart(tmpDT);
}
todo->setPriority(mPriorityCombo->currentItem()+1);
// set completion state
if ( mCompletedCombo->currentItem() == 5 ) {
QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() );
if ( comp.isValid () ) {
- todo->setPercentComplete(0);
todo->setPercentComplete(100);
todo->setCompleted(comp);
} else {
todo->setPercentComplete( 100 );
if ( mCompleted.isValid() )
todo->setCompleted(mCompleted);
}
} else {
todo->setPercentComplete(mCompletedCombo->currentItem() * 20);
}
mSummaryEdit->save(KOLocationBox::SUMMARYTODO);
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index bbf83d9..fd86095 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -362,26 +362,24 @@ void KOListView::addCat( )
{
setCategories( false );
}
void KOListView::setCat()
{
setCategories( true );
}
void KOListView::setAlarm()
{
KOAlarmPrefs kap( this);
if ( !kap.exec() )
return;
-
-
QStringList itemList;
QPtrList<KOListViewItem> sel ;
QListViewItem *qitem = mListView->firstChild ();
while ( qitem ) {
if ( qitem->isSelected() ) {
Incidence* inc = ((KOListViewItem *) qitem)->data();
if ( inc->type() != "Journal" ) {
if ( inc->type() == "Todo" ) {
if ( ((Todo*)inc)->hasDueDate() )
sel.append(((KOListViewItem *)qitem));
} else
sel.append(((KOListViewItem *)qitem));
@@ -419,80 +417,83 @@ void KOListView::setAlarm()
alarm->setType(Alarm::Invalid);
//alarm->setAudioAlarm("default");
// TODO: Deal with multiple alarms
break; // For now, stop after the first alarm
}
} else {
Alarm* alarm = inc->alarms().first();
if ( alarm ) {
alarm->setEnabled(false);
alarm->setType(Alarm::Invalid);
}
}
- temp = item;
- item = sel.next();
- mUidDict.remove( inc->uid() );
- delete temp;;
- addIncidence( inc );
+ ListItemVisitor v(item, mStartDate );
+ inc->accept(v);
+ item = sel.next();
}
topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
qDebug("KO: Set alarm for %d items", count);
calendar()->reInitAlarmSettings();
QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
}
void KOListView::setCategories( bool removeOld )
{
KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
+ csd->setColorEnabled();
if (! csd->exec()) {
delete csd;
return;
}
QStringList catList = csd->selectedCategories();
delete csd;
// if ( catList.count() == 0 )
// return;
- catList.sort();
+ //catList.sort();
QString categoriesStr = catList.join(",");
int i;
QStringList itemList;
QPtrList<KOListViewItem> sel ;
QListViewItem *qitem = mListView->firstChild ();
while ( qitem ) {
if ( qitem->isSelected() ) {
sel.append(((KOListViewItem *)qitem));
}
qitem = qitem->nextSibling();
}
KOListViewItem * item, *temp;
item = sel.first();
- Incidence* inc;
- while ( item ) {
- inc = item->data();
- if ( removeOld ) {
- inc->setCategories( categoriesStr );
- } else {
- itemList = QStringList::split (",", inc->categoriesStr() );
- for( i = 0; i< catList.count(); ++i ) {
- if ( !itemList.contains (catList[i]))
- itemList.append( catList[i] );
- }
- itemList.sort();
- inc->setCategories( itemList.join(",") );
+ if( item ) {
+ Incidence* inc = item->data() ;
+ bool setSub = false;
+ if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) {
+ int result = KMessageBox::warningYesNoCancel(this,
+ i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
+ i18n("Todo has subtodos"),
+ i18n("Yes"),
+ i18n("No"));
+ if (result == KMessageBox::Cancel) item = 0;
+ if (result == KMessageBox::Yes) setSub = true;
+ }
+ while ( item ) {
+ inc = item->data();
+ if ( removeOld ) {
+ inc->setCategories( catList, setSub );
+ } else {
+ inc->addCategories( catList, setSub );
+ }
+ ListItemVisitor v(item, mStartDate );
+ inc->accept(v);
+ item = sel.next();
}
- temp = item;
- item = sel.next();
- mUidDict.remove( inc->uid() );
- delete temp;;
- addIncidence( inc );
}
QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
}
void KOListView::beamSelected()
{
int icount = 0;
QPtrList<Incidence> delSel ;
QListViewItem *item = mListView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
delSel.append(((KOListViewItem *)item)->data());
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 6a05cc8..5513e8b 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -101,29 +101,29 @@ void KOTodoEditor::setupGeneral()
mGeneral = new KOEditorGeneralTodo(this);
connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
// connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
//connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
// mGeneral,SLOT(setCategories(const QString &)));
if (KOPrefs::instance()->mCompactDialogs) {
QFrame *topFrame = addPage(i18n("General"));
QBoxLayout *topLayout = new QVBoxLayout(topFrame);
if ( QApplication::desktop()->width() < 480 ) {
- topLayout->setMargin(1);
- topLayout->setSpacing(1);
+ topLayout->setMargin(marginHintSmall());
+ topLayout->setSpacing(spacingHintSmall());
} else {
- topLayout->setMargin(marginHint()-1);
- topLayout->setSpacing(spacingHint()-1);
+ topLayout->setMargin(marginHint());
+ topLayout->setSpacing(spacingHint());
}
mGeneral->initHeader(topFrame,topLayout);
mGeneral->initTime(topFrame,topLayout);
mGeneral->initAlarm(topFrame,topLayout);
mGeneral->enableAlarm( false );
QBoxLayout *priorityLayout;
if ( QApplication::desktop()->width() < 500 )
priorityLayout = new QVBoxLayout( topLayout );
else
priorityLayout = new QHBoxLayout( topLayout );
@@ -335,43 +335,50 @@ void KOTodoEditor::readTodo(Todo *todo)
{
mGeneral->readTodo(todo);
mDetails->readEvent(todo);
mRelatedTodo = 0;//todo->relatedTo();
// categories
// mCategoryDialog->setSelected(todo->categories());
// We should handle read-only events here.
}
void KOTodoEditor::writeTodo(Todo *event)
{
- mGeneral->writeTodo(event);
- mDetails->writeEvent(event);
-
- // set related event, i.e. parent to-do in this case.
- if (mRelatedTodo) {
- event->setRelatedTo(mRelatedTodo);
- }
- if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
- mRecurrence->writeEvent(event);
- if ( event->doesRecur() ) {
- event->setRecurrenceID( event->dtStart().addSecs(-1) );
- event->setRecurDates();
- } else {
- event->setHasRecurrenceID( false );
- }
- } else {
- event->setHasRecurrenceID( false );
- event->recurrence()->unsetRecurs();
- }
+ bool maybeComputeRecurrenceTime = false;
+ if( event->hasRecurrenceID() && event->percentComplete() < 100)
+ maybeComputeRecurrenceTime = true;
+ event->setHasRecurrenceID( false );
+ mGeneral->writeTodo(event);
+ mDetails->writeEvent(event);
+
+ // set related event, i.e. parent to-do in this case.
+ if (mRelatedTodo) {
+ event->setRelatedTo(mRelatedTodo);
+ }
+ if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
+ mRecurrence->writeEvent(event);
+ if ( event->doesRecur() ) {
+ int addSec = -1 ;
+ if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 )
+ addSec = 1;
+ event->setRecurrenceID( event->dtStart().addSecs( addSec ) );
+ event->setRecurDates();
+ } else {
+ event->setHasRecurrenceID( false );
+ }
+ } else {
+ event->setHasRecurrenceID( false );
+ event->recurrence()->unsetRecurs();
+ }
}
bool KOTodoEditor::validateInput()
{
if (!mGeneral->validateInput()) return false;
if (!mDetails->validateInput()) return false;
return true;
}
int KOTodoEditor::msgItemDelete()
{
return KMessageBox::warningContinueCancel(this,
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 25be63a..f26d16d 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -456,42 +456,42 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
mPercentageCompletedPopupMenu = new QPopupMenu(this);
for (int i = 0; i <= 100; i+=20) {
QString label = QString ("%1 %").arg (i);
mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
}
connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
mItemPopupMenu = new QPopupMenu(this);
- mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
- SLOT (toggleRunningItem()));
- mItemPopupMenu->insertSeparator();
mItemPopupMenu->insertItem(i18n("Show..."), this,
SLOT (showTodo()));
mItemPopupMenu->insertItem(i18n("Edit..."), this,
SLOT (editTodo()));
mItemPopupMenu->insertItem( i18n("Delete"), this,
SLOT (deleteTodo()));
mItemPopupMenu->insertItem( i18n("Clone..."), this,
SLOT (cloneTodo()));
mItemPopupMenu->insertItem( i18n("Move..."), this,
SLOT (moveTodo()));
mItemPopupMenu->insertItem( i18n("Beam..."), this,
SLOT (beamTodo()));
mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
SLOT (cancelTodo()));
mItemPopupMenu->insertSeparator();
+ mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
+ SLOT (toggleRunningItem()));
+ mItemPopupMenu->insertSeparator();
/*
mItemPopupMenu->insertItem( i18n("New Todo..."), this,
SLOT (newTodo()));
*/
mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
SLOT (newSubTodo()));
mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
SLOT (unparentTodo()),0,21);
mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
SLOT (reparentTodo()),0,22);
mItemPopupMenu->insertSeparator();
#if 0
@@ -503,34 +503,35 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
this, SLOT( toggleQuickTodo() ),0, 34 );
mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
this, SLOT( toggleRunning() ),0, 35 );
#endif
mPopupMenu = new QPopupMenu(this);
mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
SLOT (newTodo()),0,1);
mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
this, SLOT(purgeCompleted()),0,2);
mPopupMenu->insertItem(i18n("Show Completed"),
this, SLOT( toggleCompleted() ),0,3 );
- mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
- this, SLOT( toggleQuickTodo() ),0,4 );
mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
this, SLOT( toggleRunning() ),0,5 );
mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
this, SLOT( setAllOpen() ),0,6 );
mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
this, SLOT( setAllClose() ),0,7 );
mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
this, SLOT( setAllFlat() ),0,8 );
+ mPopupMenu->insertSeparator();
+ mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
+ this, SLOT( toggleQuickTodo() ),0,4 );
mDocPrefs = new DocPrefs( name );
mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
mPopupMenu->setCheckable( true );
mItemPopupMenu->setCheckable( true );
mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );