summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp1
-rw-r--r--korganizer/kotodoview.cpp9
-rw-r--r--korganizer/kotodoviewitem.cpp18
-rw-r--r--libkcal/todo.cpp6
4 files changed, 27 insertions, 7 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index bbc43e4..42a6f7c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1140,49 +1140,48 @@ void KOAgendaView::fillAgenda()
int startY = mAgenda->timeToY(event->dtStart().time());
int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
if (endY < startY) endY = startY;
mAgenda->insertItem(event,currentDate,curCol,startY,endY);
if (startY < mMinY[curCol]) mMinY[curCol] = startY;
if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
}
}
// ---------- [display Todos --------------
unsigned int numTodo;
for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
Todo *todo = todos.at(numTodo);
if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
// ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
// Already completed items can be displayed on their original due date
//if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
bool fillIn = false;
if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
fillIn = true;
if ( ! fillIn && !todo->hasCompletedDate() )
fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
- qDebug("refill todo ");
if ( fillIn ) {
if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
if ( KOPrefs::instance()->mShowTodoInAgenda )
mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
}
else {
QDateTime dt;
if ( todo->hasCompletedDate() )
dt = todo->completed();
else
dt = todo->dtDue();;
int endY = mAgenda->timeToY(dt.time()) - 1;
int hi = (18/KOPrefs::instance()->mHourSize);
//qDebug("hei %d ",KOPrefs::instance()->mHourSize);
int startY = endY -hi;
mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
if (startY < mMinY[curCol]) mMinY[curCol] = startY;
if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
}
}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 14e8b5c..902f3f4 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -837,48 +837,57 @@ void KOTodoView::showTodo()
emit showTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::deleteTodo()
{
if (mActiveItem) {
emit deleteTodoSignal(mActiveItem->todo());
}
}
void KOTodoView::setNewPriority(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
mActiveItem->todo()->setPriority(mPriority[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
void KOTodoView::setNewPercentage(int index)
{
if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
+
+ if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
+ mActiveItem->setOn( true );
+ return;
+ } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
+ KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
+ if ( par && par->isOn() )
+ par->setOn( false );
+ }
if (mPercentage[index] == 100) {
mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
} else {
mActiveItem->todo()->setCompleted(false);
}
mActiveItem->todo()->setPercentComplete(mPercentage[index]);
mActiveItem->construct();
todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
}
}
QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
{
QPopupMenu* tempMenu = new QPopupMenu (this);
QStringList checkedCategories = todoItem->todo()->categories ();
tempMenu->setCheckable (true);
for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
it != KOPrefs::instance()->mCustomCategories.end ();
++it) {
int index = tempMenu->insertItem (*it);
mCategory[index] = *it;
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 2822237..1edddac 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -182,92 +182,100 @@ void KOTodoViewItem::setMyPixmap()
p. drawPixmap ( 0, pixSize, pPix);
p.end();
pixSize += size;
}
if ( mTodo->isAlarmEnabled() ) {
pixi.resize(size, pixSize+size);
pPix.fill( Qt::red );
p.begin( &pixi );
p. drawPixmap ( 0, pixSize, pPix);
p.end();
pixSize += size;
}
// }
if ( pixi.width() > 1 ) {
setPixmap ( 0,pixi ) ;
} else {
setPixmap ( 0,QPixmap() ) ;
}
}
void KOTodoViewItem::stateChange(bool state)
{
// qDebug("KOTodoViewItem::stateChange ");
// do not change setting on startup
if ( m_init ) return;
- qDebug("KOTodoViewItem::stateChange ");
+ if (isOn()!=state) {
+ setOn(state);
+ //qDebug("SETON ");
+ return;
+ }
QString keyd = "==";
QString keyt = "==";
-
+ //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
mTodo->setCompleted(state);
if (state) mTodo->setCompleted(QDateTime::currentDateTime());
- if (isOn()!=state) {
- setOn(state);
- }
if (mTodo->hasDueDate()) {
setText(3, mTodo->dtDueDateStr());
QDate d = mTodo->dtDue().date();
keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
setSortKey(3,keyd);
if (mTodo->doesFloat()) {
setText(4,"");
}
else {
setText(4,mTodo->dtDueTimeStr());
QTime t = mTodo->dtDue().time();
keyt.sprintf("%02d%02d",t.hour(),t.minute());
setSortKey(4,keyt);
}
}
if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
if (mTodo->percentComplete()<100) {
if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
else setSortKey(2,QString::number(mTodo->percentComplete()));
}
else {
if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
else setSortKey(2,QString::number(99));
}
+ if ( state ) {
QListViewItem * myChild = firstChild();
KOTodoViewItem *item;
while( myChild ) {
+ //qDebug("stateCH ");
item = static_cast<KOTodoViewItem*>(myChild);
item->stateChange(state);
myChild = myChild->nextSibling();
}
+ } else {
+ QListViewItem * myChild = parent();
+ if ( myChild )
+ (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
+ }
mTodoView->modified(true);
setMyPixmap();
mTodoView->setTodoModified( mTodo );
}
bool KOTodoViewItem::isAlternate()
{
#ifndef KORG_NOLVALTERNATION
KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
if (lv && lv->alternateBackground().isValid())
{
KOTodoViewItem *above = 0;
above = dynamic_cast<KOTodoViewItem *>(itemAbove());
m_known = above ? above->m_known : true;
if (m_known)
{
m_odd = above ? !above->m_odd : false;
}
else
{
KOTodoViewItem *item;
bool previous = true;
if (QListViewItem::parent())
{
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7d04793..7f1de78 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -286,49 +286,53 @@ bool Todo::isCompleted() const
}
void Todo::setCompleted(bool completed)
{
if (completed) mPercentComplete = 100;
else {
mPercentComplete = 0;
mHasCompletedDate = false;
}
updated();
}
QDateTime Todo::completed() const
{
return mCompleted;
}
QString Todo::completedStr( bool shortF ) const
{
return KGlobal::locale()->formatDateTime(mCompleted, shortF);
}
void Todo::setCompleted(const QDateTime &completed)
{
- qDebug("Todo::setCompleted ");
+ //qDebug("Todo::setCompleted ");
+ if ( mHasCompletedDate ) {
+ // qDebug("has completed data - return ");
+ return;
+ }
mHasCompletedDate = true;
mPercentComplete = 100;
mCompleted = getEvenTime(completed);
updated();
}
bool Todo::hasCompletedDate() const
{
return mHasCompletedDate;
}
int Todo::percentComplete() const
{
return mPercentComplete;
}
void Todo::setPercentComplete(int v)
{
mPercentComplete = v;
if ( v != 100 )
mHasCompletedDate = false;
updated();
}
QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const