summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-17 07:51:48 (UTC)
committer zautrix <zautrix>2005-06-17 07:51:48 (UTC)
commit825c34c11200f8ff0229cfb00b82b1880ef55b94 (patch) (unidiff)
tree243df776d77afe55ca36ca8a78586a9e2fca1888 /korganizer
parenta04fff3ce192e0bebf9243a1fbedb97cf7108d2b (diff)
downloadkdepimpi-825c34c11200f8ff0229cfb00b82b1880ef55b94.zip
kdepimpi-825c34c11200f8ff0229cfb00b82b1880ef55b94.tar.gz
kdepimpi-825c34c11200f8ff0229cfb00b82b1880ef55b94.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp56
-rw-r--r--korganizer/kotodoview.h18
-rw-r--r--korganizer/kotodoviewitem.cpp2
3 files changed, 71 insertions, 5 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index b2ff33b..99e6a3a 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,108 +1,151 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qdialog.h>
29#include <qlabel.h>
30#include <qpushbutton.h>
28 31
29#include <qinputdialog.h> 32#include <qinputdialog.h>
30 33
31#include <qvbox.h> 34#include <qvbox.h>
32#include <kdebug.h> 35#include <kdebug.h>
33#include "koprefs.h" 36#include "koprefs.h"
34#include <klocale.h> 37#include <klocale.h>
35#include <kglobal.h> 38#include <kglobal.h>
36#include <kiconloader.h> 39#include <kiconloader.h>
37#include <kmessagebox.h> 40#include <kmessagebox.h>
38 41
39#include <libkcal/icaldrag.h> 42#include <libkcal/icaldrag.h>
40#include <libkcal/vcaldrag.h> 43#include <libkcal/vcaldrag.h>
41#include <libkcal/calfilter.h> 44#include <libkcal/calfilter.h>
42#include <libkcal/dndfactory.h> 45#include <libkcal/dndfactory.h>
43#include <libkcal/calendarresources.h> 46#include <libkcal/calendarresources.h>
44#include <libkcal/resourcecalendar.h> 47#include <libkcal/resourcecalendar.h>
45#include <kresources/resourceselectdialog.h> 48#include <kresources/resourceselectdialog.h>
46#include <libkcal/kincidenceformatter.h> 49#include <libkcal/kincidenceformatter.h>
47#ifndef DESKTOP_VERSION 50#ifndef DESKTOP_VERSION
48#include <qpe/qpeapplication.h> 51#include <qpe/qpeapplication.h>
49#else 52#else
50#include <qapplication.h> 53#include <qapplication.h>
51#endif 54#endif
52#ifndef KORG_NOPRINTER 55#ifndef KORG_NOPRINTER
53#include "calprinter.h" 56#include "calprinter.h"
54#endif 57#endif
55#include "docprefs.h" 58#include "docprefs.h"
56 59
57#include "kotodoview.h" 60#include "kotodoview.h"
58using namespace KOrg; 61using namespace KOrg;
59 62
60 63
64KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
65 QDialog( parent, name, true )
66{
67 mTodo = todo;
68 setCaption( i18n("Stop todo") );
69 QVBoxLayout* lay = new QVBoxLayout( this );
70 lay->setSpacing( 3 );
71 lay->setMargin( 3 );
72 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this );
73 lay->addWidget( lab );
74 lab->setAlignment( AlignHCenter );
75
76 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
77 lay->addWidget( ok );
78 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
79 lay->addWidget( cancel );
80 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
81 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
82 ok = new QPushButton( i18n("Stop - do not save"), this );
83 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
84 lay->addWidget( ok );
85 resize( 200, 200 );
86}
87
88void KOStopTodoPrefs::accept()
89{
90 qDebug("KOStopTodoPrefs::accept() ");
91 QDialog::accept();
92}
93void KOStopTodoPrefs::doNotSave()
94{
95
96 int result = KMessageBox::warningContinueCancel(this,
97 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() );
98 if (result != KMessageBox::Continue) return;
99 mTodo->stopRunning();
100 QDialog::accept();
101}
102
103
61class KOTodoViewWhatsThis :public QWhatsThis 104class KOTodoViewWhatsThis :public QWhatsThis
62{ 105{
63public: 106public:
64 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 107 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
65 108
66protected: 109protected:
67 virtual QString text( const QPoint& p) 110 virtual QString text( const QPoint& p)
68 { 111 {
69 return _view->getWhatsThisText(p) ; 112 return _view->getWhatsThisText(p) ;
70 } 113 }
71private: 114private:
72 QWidget* _wid; 115 QWidget* _wid;
73 KOTodoView * _view; 116 KOTodoView * _view;
74}; 117};
75 118
76KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 119KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
77 const char *name) : 120 const char *name) :
78 KListView(parent,name) 121 KListView(parent,name)
79{ 122{
80 mName = QString ( name ); 123 mName = QString ( name );
81 mCalendar = calendar; 124 mCalendar = calendar;
82#ifndef DESKTOP_VERSION 125#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 126 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
84#endif 127#endif
85 mOldCurrent = 0; 128 mOldCurrent = 0;
86 mMousePressed = false; 129 mMousePressed = false;
87 130
88 setAcceptDrops(true); 131 setAcceptDrops(true);
89 viewport()->setAcceptDrops(true); 132 viewport()->setAcceptDrops(true);
90 int size = 16; 133 int size = 16;
91 if (qApp->desktop()->width() < 300 ) 134 if (qApp->desktop()->width() < 300 )
92 size = 12; 135 size = 12;
93 setTreeStepSize( size + 6 ); 136 setTreeStepSize( size + 6 );
94 137
95} 138}
96 139
97void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 140void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
98{ 141{
99#ifndef KORG_NODND 142#ifndef KORG_NODND
100// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 143// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
101 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 144 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
102 !QTextDrag::canDecode( e ) ) { 145 !QTextDrag::canDecode( e ) ) {
103 e->ignore(); 146 e->ignore();
104 return; 147 return;
105 } 148 }
106 149
107 mOldCurrent = currentItem(); 150 mOldCurrent = currentItem();
108#endif 151#endif
@@ -1082,111 +1125,116 @@ void KOTodoView::changedCategories(int index)
1082 if ( !colcat.isEmpty() ) { 1125 if ( !colcat.isEmpty() ) {
1083 if ( categories.find ( colcat ) != categories.end () ) { 1126 if ( categories.find ( colcat ) != categories.end () ) {
1084 categories.remove( colcat ); 1127 categories.remove( colcat );
1085 categories.prepend( colcat ); 1128 categories.prepend( colcat );
1086 } 1129 }
1087 } 1130 }
1088 mActiveItem->todo()->setCategories (categories); 1131 mActiveItem->todo()->setCategories (categories);
1089 mActiveItem->construct(); 1132 mActiveItem->construct();
1090 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1133 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1091 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1134 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1092 } 1135 }
1093} 1136}
1094void KOTodoView::itemDoubleClicked(QListViewItem *item) 1137void KOTodoView::itemDoubleClicked(QListViewItem *item)
1095{ 1138{
1096 if ( pendingSubtodo != 0 ) { 1139 if ( pendingSubtodo != 0 ) {
1097 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1140 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1098 } 1141 }
1099 pendingSubtodo = 0; 1142 pendingSubtodo = 0;
1100 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1143 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1101 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1144 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1102 //qDebug("ROW %d ", row); 1145 //qDebug("ROW %d ", row);
1103 if (!item) { 1146 if (!item) {
1104 newTodo(); 1147 newTodo();
1105 return; 1148 return;
1106 } else { 1149 } else {
1107 if ( row == 2 || row == 1 ) { 1150 if ( row == 2 || row == 1 ) {
1108 mActiveItem = (KOTodoViewItem *) item; 1151 mActiveItem = (KOTodoViewItem *) item;
1109 newSubTodo(); 1152 newSubTodo();
1110 return; 1153 return;
1111 } 1154 }
1112 if ( row == 5 || row == 6 ) { 1155 if ( row == 5 || row == 6 ) {
1113 mActiveItem = (KOTodoViewItem *) item; 1156 mActiveItem = (KOTodoViewItem *) item;
1114 toggleRunningItem(); 1157 toggleRunningItem();
1115 return; 1158 return;
1116 } 1159 }
1117 } 1160 }
1118 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1161 if ( KOPrefs::instance()->mEditOnDoubleClick )
1119 editItem( item ); 1162 editItem( item );
1120 else 1163 else
1121 showItem( item , QPoint(), 0 ); 1164 showItem( item , QPoint(), 0 );
1122} 1165}
1123void KOTodoView::toggleRunningItem() 1166void KOTodoView::toggleRunningItem()
1124{ 1167{
1125 // qDebug("KOTodoView::toggleRunning() "); 1168 // qDebug("KOTodoView::toggleRunning() ");
1126 if ( ! mActiveItem ) 1169 if ( ! mActiveItem )
1127 return; 1170 return;
1128 Todo * t = mActiveItem->todo(); 1171 Todo * t = mActiveItem->todo();
1129 if ( t->isRunning() ) { 1172 if ( t->isRunning() ) {
1130#if 0
1131 int result = KMessageBox::warningContinueCancel(this,
1132 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
1133#endif
1134 1173
1174
1175 KOStopTodoPrefs tp ( t, this );
1176 tp.exec();
1177
1178
1179#if 0
1135 int result = KMessageBox::warningYesNoCancel(this, 1180 int result = KMessageBox::warningYesNoCancel(this,
1136 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note")); 1181 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note"));
1137 if (result == KMessageBox::Cancel) return; 1182 if (result == KMessageBox::Cancel) return;
1138 if ( result == KMessageBox::No ) { 1183 if ( result == KMessageBox::No ) {
1139 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); 1184 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") );
1140 t->setRunningFalse( comment ); 1185 t->setRunningFalse( comment );
1141 } else { 1186 } else {
1142 t->setRunning( false ); 1187 t->setRunning( false );
1143 } 1188 }
1144 mActiveItem->construct(); 1189 mActiveItem->construct();
1190
1191
1192#endif
1145 } else { 1193 } else {
1146 int result = KMessageBox::warningContinueCancel(this, 1194 int result = KMessageBox::warningContinueCancel(this,
1147 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); 1195 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
1148 if (result != KMessageBox::Continue) return; 1196 if (result != KMessageBox::Continue) return;
1149 t->setRunning( true ); 1197 t->setRunning( true );
1150 mActiveItem->construct(); 1198 mActiveItem->construct();
1151 } 1199 }
1152} 1200}
1153 1201
1154void KOTodoView::itemClicked(QListViewItem *item) 1202void KOTodoView::itemClicked(QListViewItem *item)
1155{ 1203{
1156 //qDebug("KOTodoView::itemClicked %d", item); 1204 //qDebug("KOTodoView::itemClicked %d", item);
1157 if (!item) { 1205 if (!item) {
1158 if ( pendingSubtodo != 0 ) { 1206 if ( pendingSubtodo != 0 ) {
1159 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1207 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1160 } 1208 }
1161 pendingSubtodo = 0; 1209 pendingSubtodo = 0;
1162 return; 1210 return;
1163 } 1211 }
1164 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1212 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1165 if ( pendingSubtodo != 0 ) { 1213 if ( pendingSubtodo != 0 ) {
1166 bool allowReparent = true; 1214 bool allowReparent = true;
1167 QListViewItem *par = item; 1215 QListViewItem *par = item;
1168 while ( par ) { 1216 while ( par ) {
1169 if ( par == pendingSubtodo ) { 1217 if ( par == pendingSubtodo ) {
1170 allowReparent = false; 1218 allowReparent = false;
1171 break; 1219 break;
1172 } 1220 }
1173 par = par->parent(); 1221 par = par->parent();
1174 } 1222 }
1175 if ( !allowReparent ) { 1223 if ( !allowReparent ) {
1176 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1224 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1177 pendingSubtodo = 0; 1225 pendingSubtodo = 0;
1178 } else { 1226 } else {
1179 Todo* newParent = todoItem->todo(); 1227 Todo* newParent = todoItem->todo();
1180 Todo* newSub = pendingSubtodo->todo(); 1228 Todo* newSub = pendingSubtodo->todo();
1181 pendingSubtodo = 0; 1229 pendingSubtodo = 0;
1182 emit reparentTodoSignal( newParent,newSub ); 1230 emit reparentTodoSignal( newParent,newSub );
1183 return; 1231 return;
1184 } 1232 }
1185 } 1233 }
1186 1234
1187} 1235}
1188 1236
1189void KOTodoView::setDocumentId( const QString &id ) 1237void KOTodoView::setDocumentId( const QString &id )
1190{ 1238{
1191 1239
1192 mDocPrefs->setDoc( id ); 1240 mDocPrefs->setDoc( id );
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 1ffc34a..ceabdba 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,103 +1,121 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qdialog.h>
36#include <qlabel.h>
35#include <qlistview.h> 37#include <qlistview.h>
36#include <klistview.h> 38#include <klistview.h>
37 39
38#include <libkcal/calendar.h> 40#include <libkcal/calendar.h>
39#include <libkcal/todo.h> 41#include <libkcal/todo.h>
40 42
41#include <korganizer/baseview.h> 43#include <korganizer/baseview.h>
42 44
43#include "kotodoviewitem.h" 45#include "kotodoviewitem.h"
44#include "koprefs.h" 46#include "koprefs.h"
45#include "koglobals.h" 47#include "koglobals.h"
46#include "datenavigator.h" 48#include "datenavigator.h"
47 49
48class QDragEnterEvent; 50class QDragEnterEvent;
49class QDragMoveEvent; 51class QDragMoveEvent;
50class QDragLeaveEvent; 52class QDragLeaveEvent;
51class QDropEvent; 53class QDropEvent;
52class KOTodoViewWhatsThis; 54class KOTodoViewWhatsThis;
53 55
54class DocPrefs; 56class DocPrefs;
55 57
58
59class KOStopTodoPrefs : public QDialog
60{
61 Q_OBJECT
62 public:
63 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
64
65
66private slots:
67 void doNotSave();
68 void accept();
69private:
70 Todo* mTodo;
71
72};
73
56class KOTodoListView : public KListView 74class KOTodoListView : public KListView
57{ 75{
58 Q_OBJECT 76 Q_OBJECT
59 public: 77 public:
60 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 78 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
61 virtual ~KOTodoListView() {} 79 virtual ~KOTodoListView() {}
62 80
63 signals: 81 signals:
64 void paintNeeded(); 82 void paintNeeded();
65 void todoDropped(Todo *, int); 83 void todoDropped(Todo *, int);
66 void double_Clicked(QListViewItem *item); 84 void double_Clicked(QListViewItem *item);
67 void reparentTodoSignal( Todo *,Todo * ); 85 void reparentTodoSignal( Todo *,Todo * );
68 void unparentTodoSignal(Todo *); 86 void unparentTodoSignal(Todo *);
69 void deleteTodo( Todo * ); 87 void deleteTodo( Todo * );
70 protected: 88 protected:
71 void wheelEvent (QWheelEvent *e); 89 void wheelEvent (QWheelEvent *e);
72 void contentsDragEnterEvent(QDragEnterEvent *); 90 void contentsDragEnterEvent(QDragEnterEvent *);
73 void contentsDragMoveEvent(QDragMoveEvent *); 91 void contentsDragMoveEvent(QDragMoveEvent *);
74 void contentsDragLeaveEvent(QDragLeaveEvent *); 92 void contentsDragLeaveEvent(QDragLeaveEvent *);
75 void contentsDropEvent(QDropEvent *); 93 void contentsDropEvent(QDropEvent *);
76 94
77 void contentsMousePressEvent(QMouseEvent *); 95 void contentsMousePressEvent(QMouseEvent *);
78 void contentsMouseMoveEvent(QMouseEvent *); 96 void contentsMouseMoveEvent(QMouseEvent *);
79 void contentsMouseReleaseEvent(QMouseEvent *); 97 void contentsMouseReleaseEvent(QMouseEvent *);
80 void contentsMouseDoubleClickEvent(QMouseEvent *); 98 void contentsMouseDoubleClickEvent(QMouseEvent *);
81 99
82 private: 100 private:
83 void paintEvent(QPaintEvent * pevent); 101 void paintEvent(QPaintEvent * pevent);
84 bool internalDrop; 102 bool internalDrop;
85 QString mName; 103 QString mName;
86 Calendar *mCalendar; 104 Calendar *mCalendar;
87 QPoint mPressPos; 105 QPoint mPressPos;
88 bool mMousePressed; 106 bool mMousePressed;
89 QListViewItem *mOldCurrent; 107 QListViewItem *mOldCurrent;
90 bool mFlagKeyPressed; 108 bool mFlagKeyPressed;
91 void keyPressEvent ( QKeyEvent * ) ; 109 void keyPressEvent ( QKeyEvent * ) ;
92 void keyReleaseEvent ( QKeyEvent * ) ; 110 void keyReleaseEvent ( QKeyEvent * ) ;
93}; 111};
94 112
95 113
96/** 114/**
97 This is the line-edit on top of the todoview for fast addition of new todos 115 This is the line-edit on top of the todoview for fast addition of new todos
98*/ 116*/
99class KOQuickTodo : public QLineEdit 117class KOQuickTodo : public QLineEdit
100{ 118{
101 public: 119 public:
102 KOQuickTodo(QWidget *parent=0); 120 KOQuickTodo(QWidget *parent=0);
103 protected: 121 protected:
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index f62aab8..0cf6e4c 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -315,97 +315,97 @@ void KOTodoViewItem::stateChange(bool state)
315 mTodoView->setTodoModified( mTodo ); 315 mTodoView->setTodoModified( mTodo );
316} 316}
317 317
318bool KOTodoViewItem::isAlternate() 318bool KOTodoViewItem::isAlternate()
319{ 319{
320 320
321 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 321 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
322 if (lv && lv->alternateBackground().isValid()) 322 if (lv && lv->alternateBackground().isValid())
323 { 323 {
324 KOTodoViewItem *above = 0; 324 KOTodoViewItem *above = 0;
325 above = static_cast<KOTodoViewItem *>(itemAbove()); 325 above = static_cast<KOTodoViewItem *>(itemAbove());
326 m_known = above ? above->m_known : true; 326 m_known = above ? above->m_known : true;
327 if (m_known) 327 if (m_known)
328 { 328 {
329 m_odd = above ? !above->m_odd : false; 329 m_odd = above ? !above->m_odd : false;
330 } 330 }
331 else 331 else
332 { 332 {
333 KOTodoViewItem *item; 333 KOTodoViewItem *item;
334 bool previous = true; 334 bool previous = true;
335 if (QListViewItem::parent()) 335 if (QListViewItem::parent())
336 { 336 {
337 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); 337 item = static_cast<KOTodoViewItem *>(QListViewItem::parent());
338 if (item) 338 if (item)
339 previous = item->m_odd; 339 previous = item->m_odd;
340 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 340 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
341 } 341 }
342 else 342 else
343 { 343 {
344 item = static_cast<KOTodoViewItem *>(lv->firstChild()); 344 item = static_cast<KOTodoViewItem *>(lv->firstChild());
345 } 345 }
346 346
347 while(item) 347 while(item)
348 { 348 {
349 item->m_odd = previous = !previous; 349 item->m_odd = previous = !previous;
350 item->m_known = true; 350 item->m_known = true;
351 item = static_cast<KOTodoViewItem *>(item->nextSibling()); 351 item = static_cast<KOTodoViewItem *>(item->nextSibling());
352 } 352 }
353 } 353 }
354 return m_odd; 354 return m_odd;
355 } 355 }
356 return false; 356 return false;
357} 357}
358 358
359void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 359void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
360{ 360{
361 QColorGroup _cg = cg; 361 QColorGroup _cg = cg;
362 QColorGroup::ColorRole role; 362 QColorGroup::ColorRole role;
363 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 363 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning())
364 role = QColorGroup::Text; 364 role = QColorGroup::Text;
365 else 365 else
366 role = QColorGroup::Base; 366 role = QColorGroup::Base;
367 //#ifndef KORG_NOLVALTERNATION 367 //#ifndef KORG_NOLVALTERNATION
368 if (isAlternate()) 368 if (isAlternate())
369 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 369 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
370 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 370 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
371 QColor colorToSet; 371 QColor colorToSet;
372 if ( column == 0 && mTodo->calID() > 1 ) { 372 if ( column == 0 && mTodo->calID() > 1 ) {
373 setColor = true; 373 setColor = true;
374 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); 374 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() );
375 } else if ( setColor ) { 375 } else if ( setColor ) {
376 QStringList categories = mTodo->categories(); 376 QStringList categories = mTodo->categories();
377 QString cat = categories.first(); 377 QString cat = categories.first();
378 if ( !cat.isEmpty()) { 378 if ( !cat.isEmpty()) {
379 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 379 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
380 } else 380 } else
381 setColor = false; 381 setColor = false;
382 } 382 }
383 bool openMode = !isOpen(); 383 bool openMode = !isOpen();
384 // maybe we are in flat-display-mode 384 // maybe we are in flat-display-mode
385 if ( !firstChild() ) 385 if ( !firstChild() )
386 openMode = false; 386 openMode = false;
387 bool colorRunning = mTodo->isRunning(); 387 bool colorRunning = mTodo->isRunning();
388 if ( ! colorRunning && openMode ) 388 if ( ! colorRunning && openMode )
389 colorRunning = mTodo->hasRunningSub(); 389 colorRunning = mTodo->hasRunningSub();
390 if ( colorRunning ) { 390 if ( colorRunning ) {
391 setColor = true; 391 setColor = true;
392 colorToSet = KOPrefs::instance()->mTodoRunColor; 392 colorToSet = KOPrefs::instance()->mTodoRunColor;
393 } else { 393 } else {
394 int odue = mTodo->hasDueSubTodo( openMode ); 394 int odue = mTodo->hasDueSubTodo( openMode );
395 if (odue == 2) { 395 if (odue == 2) {
396 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 396 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
397 setColor = true; 397 setColor = true;
398 } else if ( odue == 1 ) { 398 } else if ( odue == 1 ) {
399 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 399 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
400 setColor = true; 400 setColor = true;
401 } 401 }
402 } 402 }
403 403
404 404
405 if ( setColor ) { 405 if ( setColor ) {
406 _cg.setColor(role,colorToSet ); 406 _cg.setColor(role,colorToSet );
407 if ( role == QColorGroup::Base) { 407 if ( role == QColorGroup::Base) {
408 int rgb = colorToSet.red(); 408 int rgb = colorToSet.red();
409 rgb += colorToSet.blue()/2; 409 rgb += colorToSet.blue()/2;
410 rgb += colorToSet.green(); 410 rgb += colorToSet.green();
411 if ( rgb < 200 ) 411 if ( rgb < 200 )