author | zautrix <zautrix> | 2005-06-27 04:48:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-27 04:48:41 (UTC) |
commit | 9b2bf31715226dfa8210f31843616a04f810f012 (patch) (unidiff) | |
tree | b502c4a379b26f74621ba8fabb59fcb53f5a5679 /korganizer/kotodoview.cpp | |
parent | 2e566a307bb50ac595fe729ebed0f5336f2af5a8 (diff) | |
download | kdepimpi-9b2bf31715226dfa8210f31843616a04f810f012.zip kdepimpi-9b2bf31715226dfa8210f31843616a04f810f012.tar.gz kdepimpi-9b2bf31715226dfa8210f31843616a04f810f012.tar.bz2 |
strat stop tod fixes
-rw-r--r-- | korganizer/kotodoview.cpp | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 7349d20..1bfdef9 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,161 +1,191 @@ | |||
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> | 28 | #include <qdialog.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | 31 | ||
32 | #include <qinputdialog.h> | 32 | #include <qinputdialog.h> |
33 | 33 | ||
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kdateedit.h> | 39 | #include <kdateedit.h> |
40 | #include "ktimeedit.h" | 40 | #include "ktimeedit.h" |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | #include <libkcal/icaldrag.h> | 44 | #include <libkcal/icaldrag.h> |
45 | #include <libkcal/vcaldrag.h> | 45 | #include <libkcal/vcaldrag.h> |
46 | #include <libkcal/calfilter.h> | 46 | #include <libkcal/calfilter.h> |
47 | #include <libkcal/dndfactory.h> | 47 | #include <libkcal/dndfactory.h> |
48 | #include <libkcal/calendarresources.h> | 48 | #include <libkcal/calendarresources.h> |
49 | #include <libkcal/resourcecalendar.h> | 49 | #include <libkcal/resourcecalendar.h> |
50 | #include <kresources/resourceselectdialog.h> | 50 | #include <kresources/resourceselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | #ifndef KORG_NOPRINTER | 57 | #ifndef KORG_NOPRINTER |
58 | #include "calprinter.h" | 58 | #include "calprinter.h" |
59 | #endif | 59 | #endif |
60 | #include "docprefs.h" | 60 | #include "docprefs.h" |
61 | 61 | ||
62 | #include "kotodoview.h" | 62 | #include "kotodoview.h" |
63 | using namespace KOrg; | 63 | using namespace KOrg; |
64 | 64 | ||
65 | 65 | ||
66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : | ||
67 | QDialog( parent, name, true ) | ||
68 | { | ||
69 | mStopAll = true; | ||
70 | setCaption( i18n("Start todo") ); | ||
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | ||
72 | lay->setSpacing( 3 ); | ||
73 | lay->setMargin( 3 ); | ||
74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); | ||
75 | lay->addWidget( lab ); | ||
76 | lab->setAlignment( AlignCenter ); | ||
77 | |||
78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); | ||
79 | lay->addWidget( ok ); | ||
80 | ok->setDefault( true ); | ||
81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); | ||
82 | lay->addWidget( start ); | ||
83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); | ||
84 | lay->addWidget( cancel ); | ||
85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | ||
86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); | ||
87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | ||
88 | resize( sizeHint() ); | ||
89 | |||
90 | } | ||
91 | void KOStartTodoPrefs::doStop() | ||
92 | { | ||
93 | mStopAll = false; | ||
94 | accept(); | ||
95 | } | ||
66 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : | 96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : |
67 | QDialog( parent, name, true ) | 97 | QDialog( parent, name, true ) |
68 | { | 98 | { |
69 | mTodo = todo; | 99 | mTodo = todo; |
70 | setCaption( i18n("Stop todo") ); | 100 | setCaption( i18n("Stop todo") ); |
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | 101 | QVBoxLayout* lay = new QVBoxLayout( this ); |
72 | lay->setSpacing( 3 ); | 102 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 103 | lay->setMargin( 3 ); |
74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); | 104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); |
75 | lay->addWidget( lab ); | 105 | lay->addWidget( lab ); |
76 | lab->setAlignment( AlignHCenter ); | 106 | lab->setAlignment( AlignHCenter ); |
77 | lab = new QLabel( i18n("Additional Comment:"), this ); | 107 | lab = new QLabel( i18n("Additional Comment:"), this ); |
78 | lay->addWidget( lab ); | 108 | lay->addWidget( lab ); |
79 | mComment = new QLineEdit( this ); | 109 | mComment = new QLineEdit( this ); |
80 | lay->addWidget( mComment ); | 110 | lay->addWidget( mComment ); |
81 | QHBox * start = new QHBox ( this ); | 111 | QHBox * start = new QHBox ( this ); |
82 | lay->addWidget( start ); | 112 | lay->addWidget( start ); |
83 | lab = new QLabel( i18n("Start:"), start ); | 113 | lab = new QLabel( i18n("Start:"), start ); |
84 | QHBox * end = new QHBox ( this ); | 114 | QHBox * end = new QHBox ( this ); |
85 | lay->addWidget( end ); | 115 | lay->addWidget( end ); |
86 | lab = new QLabel( i18n("End:"), end ); | 116 | lab = new QLabel( i18n("End:"), end ); |
87 | sde = new KDateEdit( start ); | 117 | sde = new KDateEdit( start ); |
88 | ste = new KOTimeEdit( start ); | 118 | ste = new KOTimeEdit( start ); |
89 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); | 119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); |
90 | ede = new KDateEdit( end ); | 120 | ede = new KDateEdit( end ); |
91 | ete = new KOTimeEdit(end ); | 121 | ete = new KOTimeEdit(end ); |
92 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); | 122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); |
93 | sde->setDate( mTodo->runStart().date() ); | 123 | sde->setDate( mTodo->runStart().date() ); |
94 | ste->setTime( mTodo->runStart().time() ); | 124 | ste->setTime( mTodo->runStart().time() ); |
95 | ede->setDate( QDate::currentDate()); | 125 | ede->setDate( QDate::currentDate()); |
96 | ete->setTime( QTime::currentTime() ); | 126 | ete->setTime( QTime::currentTime() ); |
97 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
98 | lay->addWidget( ok ); | 128 | lay->addWidget( ok ); |
99 | ok->setDefault( true ); | 129 | ok->setDefault( true ); |
100 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
101 | lay->addWidget( cancel ); | 131 | lay->addWidget( cancel ); |
102 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
103 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
104 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 134 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
105 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
106 | lay->addWidget( ok ); | 136 | lay->addWidget( ok ); |
107 | if (QApplication::desktop()->width() < 320 ) | 137 | if (QApplication::desktop()->width() < 320 ) |
108 | resize( 240, sizeHint().height() ); | 138 | resize( 240, sizeHint().height() ); |
109 | else | 139 | else |
110 | resize( 320, sizeHint().height() ); | 140 | resize( 320, sizeHint().height() ); |
111 | 141 | ||
112 | } | 142 | } |
113 | 143 | ||
114 | void KOStopTodoPrefs::accept() | 144 | void KOStopTodoPrefs::accept() |
115 | { | 145 | { |
116 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
117 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
118 | if ( start > stop ) { | 148 | if ( start > stop ) { |
119 | KMessageBox::sorry(this, | 149 | KMessageBox::sorry(this, |
120 | i18n("The start time is\nafter the end time!"), | 150 | i18n("The start time is\nafter the end time!"), |
121 | i18n("Time mismatch!")); | 151 | i18n("Time mismatch!")); |
122 | return; | 152 | return; |
123 | } | 153 | } |
124 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
125 | QDialog::accept(); | 155 | QDialog::accept(); |
126 | } | 156 | } |
127 | void KOStopTodoPrefs::doNotSave() | 157 | void KOStopTodoPrefs::doNotSave() |
128 | { | 158 | { |
129 | int result = KMessageBox::warningContinueCancel(this, | 159 | int result = KMessageBox::warningContinueCancel(this, |
130 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); | 160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); |
131 | if (result != KMessageBox::Continue) return; | 161 | if (result != KMessageBox::Continue) return; |
132 | mTodo->stopRunning(); | 162 | mTodo->stopRunning(); |
133 | QDialog::accept(); | 163 | QDialog::accept(); |
134 | } | 164 | } |
135 | 165 | ||
136 | 166 | ||
137 | class KOTodoViewWhatsThis :public QWhatsThis | 167 | class KOTodoViewWhatsThis :public QWhatsThis |
138 | { | 168 | { |
139 | public: | 169 | public: |
140 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
141 | 171 | ||
142 | protected: | 172 | protected: |
143 | virtual QString text( const QPoint& p) | 173 | virtual QString text( const QPoint& p) |
144 | { | 174 | { |
145 | return _view->getWhatsThisText(p) ; | 175 | return _view->getWhatsThisText(p) ; |
146 | } | 176 | } |
147 | private: | 177 | private: |
148 | QWidget* _wid; | 178 | QWidget* _wid; |
149 | KOTodoView * _view; | 179 | KOTodoView * _view; |
150 | }; | 180 | }; |
151 | 181 | ||
152 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
153 | const char *name) : | 183 | const char *name) : |
154 | KListView(parent,name) | 184 | KListView(parent,name) |
155 | { | 185 | { |
156 | mName = QString ( name ); | 186 | mName = QString ( name ); |
157 | mCalendar = calendar; | 187 | mCalendar = calendar; |
158 | #ifndef DESKTOP_VERSION | 188 | #ifndef DESKTOP_VERSION |
159 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
160 | #endif | 190 | #endif |
161 | mOldCurrent = 0; | 191 | mOldCurrent = 0; |
@@ -1106,227 +1136,239 @@ void KOTodoView::setNewPercentage(int index) | |||
1106 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1136 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1107 | 1137 | ||
1108 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1138 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1109 | mActiveItem->setOn( true ); | 1139 | mActiveItem->setOn( true ); |
1110 | return; | 1140 | return; |
1111 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1141 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1112 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1142 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1113 | if ( par && par->isOn() ) | 1143 | if ( par && par->isOn() ) |
1114 | par->setOn( false ); | 1144 | par->setOn( false ); |
1115 | } | 1145 | } |
1116 | if (mPercentage[index] == 100) { | 1146 | if (mPercentage[index] == 100) { |
1117 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1147 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1118 | } else { | 1148 | } else { |
1119 | mActiveItem->todo()->setCompleted(false); | 1149 | mActiveItem->todo()->setCompleted(false); |
1120 | } | 1150 | } |
1121 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1151 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1122 | mActiveItem->construct(); | 1152 | mActiveItem->construct(); |
1123 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1153 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1124 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1154 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1125 | } | 1155 | } |
1126 | } | 1156 | } |
1127 | 1157 | ||
1128 | 1158 | ||
1129 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1159 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1130 | { | 1160 | { |
1131 | QPopupMenu* tempMenu = new QPopupMenu (this); | 1161 | QPopupMenu* tempMenu = new QPopupMenu (this); |
1132 | QStringList checkedCategories = todoItem->todo()->categories (); | 1162 | QStringList checkedCategories = todoItem->todo()->categories (); |
1133 | 1163 | ||
1134 | tempMenu->setCheckable (true); | 1164 | tempMenu->setCheckable (true); |
1135 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1165 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1136 | it != KOPrefs::instance()->mCustomCategories.end (); | 1166 | it != KOPrefs::instance()->mCustomCategories.end (); |
1137 | ++it) { | 1167 | ++it) { |
1138 | int index = tempMenu->insertItem (*it); | 1168 | int index = tempMenu->insertItem (*it); |
1139 | mCategory[index] = *it; | 1169 | mCategory[index] = *it; |
1140 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 1170 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
1141 | } | 1171 | } |
1142 | 1172 | ||
1143 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1173 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1144 | return tempMenu; | 1174 | return tempMenu; |
1145 | 1175 | ||
1146 | 1176 | ||
1147 | } | 1177 | } |
1148 | void KOTodoView::changedCategories(int index) | 1178 | void KOTodoView::changedCategories(int index) |
1149 | { | 1179 | { |
1150 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1180 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1151 | QStringList categories = mActiveItem->todo()->categories (); | 1181 | QStringList categories = mActiveItem->todo()->categories (); |
1152 | QString colcat = categories.first(); | 1182 | QString colcat = categories.first(); |
1153 | if (categories.find (mCategory[index]) != categories.end ()) | 1183 | if (categories.find (mCategory[index]) != categories.end ()) |
1154 | categories.remove (mCategory[index]); | 1184 | categories.remove (mCategory[index]); |
1155 | else | 1185 | else |
1156 | categories.insert (categories.end(), mCategory[index]); | 1186 | categories.insert (categories.end(), mCategory[index]); |
1157 | categories.sort (); | 1187 | categories.sort (); |
1158 | if ( !colcat.isEmpty() ) { | 1188 | if ( !colcat.isEmpty() ) { |
1159 | if ( categories.find ( colcat ) != categories.end () ) { | 1189 | if ( categories.find ( colcat ) != categories.end () ) { |
1160 | categories.remove( colcat ); | 1190 | categories.remove( colcat ); |
1161 | categories.prepend( colcat ); | 1191 | categories.prepend( colcat ); |
1162 | } | 1192 | } |
1163 | } | 1193 | } |
1164 | mActiveItem->todo()->setCategories (categories); | 1194 | mActiveItem->todo()->setCategories (categories); |
1165 | mActiveItem->construct(); | 1195 | mActiveItem->construct(); |
1166 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1196 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1167 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1197 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1168 | } | 1198 | } |
1169 | } | 1199 | } |
1170 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1200 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1171 | { | 1201 | { |
1172 | if ( pendingSubtodo != 0 ) { | 1202 | if ( pendingSubtodo != 0 ) { |
1173 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1203 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1174 | } | 1204 | } |
1175 | pendingSubtodo = 0; | 1205 | pendingSubtodo = 0; |
1176 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1206 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1177 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1207 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1178 | //qDebug("ROW %d ", row); | 1208 | //qDebug("ROW %d ", row); |
1179 | if (!item) { | 1209 | if (!item) { |
1180 | newTodo(); | 1210 | newTodo(); |
1181 | return; | 1211 | return; |
1182 | } else { | 1212 | } else { |
1183 | if ( row == 1 ) { | 1213 | if ( row == 1 ) { |
1184 | mActiveItem = (KOTodoViewItem *) item; | 1214 | mActiveItem = (KOTodoViewItem *) item; |
1185 | newSubTodo(); | 1215 | newSubTodo(); |
1186 | return; | 1216 | return; |
1187 | } | 1217 | } |
1188 | if ( row == 5 || row == 6 || row == 2) { | 1218 | if ( row == 5 || row == 6 || row == 2) { |
1189 | mActiveItem = (KOTodoViewItem *) item; | 1219 | mActiveItem = (KOTodoViewItem *) item; |
1190 | Todo * t = mActiveItem->todo(); | 1220 | Todo * t = mActiveItem->todo(); |
1191 | if ( t->isRunning() ) { | 1221 | if ( t->isRunning() ) { |
1192 | if ( t->runTime() < 15) { | 1222 | if ( t->runTime() < 15) { |
1193 | t->stopRunning(); | 1223 | t->stopRunning(); |
1194 | mActiveItem->construct(); | 1224 | mActiveItem->construct(); |
1195 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1225 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1196 | return; | 1226 | return; |
1197 | } | 1227 | } |
1198 | else | 1228 | else |
1199 | toggleRunningItem(); | 1229 | toggleRunningItem(); |
1200 | return; | 1230 | return; |
1201 | } else { | 1231 | } else { |
1202 | t->setRunning( true ); | 1232 | t->setRunning( true ); |
1203 | mActiveItem->construct(); | 1233 | mActiveItem->construct(); |
1204 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1234 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1205 | return; | 1235 | return; |
1206 | } | 1236 | } |
1207 | } | 1237 | } |
1208 | } | 1238 | } |
1209 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1239 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1210 | editItem( item ); | 1240 | editItem( item ); |
1211 | else | 1241 | else |
1212 | showItem( item , QPoint(), 0 ); | 1242 | showItem( item , QPoint(), 0 ); |
1213 | } | 1243 | } |
1214 | void KOTodoView::toggleRunningItem() | 1244 | void KOTodoView::toggleRunningItem() |
1215 | { | 1245 | { |
1216 | // qDebug("KOTodoView::toggleRunning() "); | 1246 | // qDebug("KOTodoView::toggleRunning() "); |
1217 | if ( ! mActiveItem ) | 1247 | if ( ! mActiveItem ) |
1218 | return; | 1248 | return; |
1219 | Todo * t = mActiveItem->todo(); | 1249 | Todo * t = mActiveItem->todo(); |
1220 | if ( t->isRunning() ) { | 1250 | if ( t->isRunning() ) { |
1221 | KOStopTodoPrefs tp ( t, this ); | 1251 | KOStopTodoPrefs tp ( t, this ); |
1222 | if (QApplication::desktop()->width() < 800 ){ | 1252 | if (QApplication::desktop()->width() <= 800 ){ |
1223 | int wid = tp.width(); | 1253 | int wid = tp.width(); |
1224 | int hei = tp.height(); | 1254 | int hei = tp.height(); |
1225 | int xx = (QApplication::desktop()->width()-wid)/2; | 1255 | int xx = (QApplication::desktop()->width()-wid)/2; |
1226 | int yy = (QApplication::desktop()->height()-hei)/2; | 1256 | int yy = (QApplication::desktop()->height()-hei)/2; |
1227 | tp.setGeometry( xx,yy,wid,hei ); | 1257 | tp.setGeometry( xx,yy,wid,hei ); |
1228 | } | 1258 | } |
1229 | tp.exec(); | 1259 | tp.exec(); |
1230 | mActiveItem->construct(); | 1260 | mActiveItem->construct(); |
1231 | } else { | 1261 | } else { |
1232 | int result = KMessageBox::warningContinueCancel(this, | 1262 | KOStartTodoPrefs tp ( t->summary(), this ); |
1233 | i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),i18n("Start todo"),i18n("Cancel"), true); | 1263 | if (QApplication::desktop()->width() <= 800 ){ |
1234 | if (result != KMessageBox::Continue) return; | 1264 | int wid = tp.width(); |
1235 | t->setRunning( true ); | 1265 | int hei = tp.height(); |
1236 | mActiveItem->construct(); | 1266 | int xx = (QApplication::desktop()->width()-wid)/2; |
1267 | int yy = (QApplication::desktop()->height()-hei)/2; | ||
1268 | tp.setGeometry( xx,yy,wid,hei ); | ||
1269 | } | ||
1270 | if ( !tp.exec() ) return; | ||
1271 | if ( tp.stopAll() ) { | ||
1272 | mCalendar->stopAllTodos(); | ||
1273 | t->setRunning( true ); | ||
1274 | updateView(); | ||
1275 | } else { | ||
1276 | t->setRunning( true ); | ||
1277 | mActiveItem->construct(); | ||
1278 | } | ||
1237 | } | 1279 | } |
1238 | } | 1280 | } |
1239 | 1281 | ||
1240 | void KOTodoView::itemClicked(QListViewItem *item) | 1282 | void KOTodoView::itemClicked(QListViewItem *item) |
1241 | { | 1283 | { |
1242 | //qDebug("KOTodoView::itemClicked %d", item); | 1284 | //qDebug("KOTodoView::itemClicked %d", item); |
1243 | if (!item) { | 1285 | if (!item) { |
1244 | if ( pendingSubtodo != 0 ) { | 1286 | if ( pendingSubtodo != 0 ) { |
1245 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1287 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1246 | } | 1288 | } |
1247 | pendingSubtodo = 0; | 1289 | pendingSubtodo = 0; |
1248 | return; | 1290 | return; |
1249 | } | 1291 | } |
1250 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1292 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1251 | if ( pendingSubtodo != 0 ) { | 1293 | if ( pendingSubtodo != 0 ) { |
1252 | bool allowReparent = true; | 1294 | bool allowReparent = true; |
1253 | QListViewItem *par = item; | 1295 | QListViewItem *par = item; |
1254 | while ( par ) { | 1296 | while ( par ) { |
1255 | if ( par == pendingSubtodo ) { | 1297 | if ( par == pendingSubtodo ) { |
1256 | allowReparent = false; | 1298 | allowReparent = false; |
1257 | break; | 1299 | break; |
1258 | } | 1300 | } |
1259 | par = par->parent(); | 1301 | par = par->parent(); |
1260 | } | 1302 | } |
1261 | if ( !allowReparent ) { | 1303 | if ( !allowReparent ) { |
1262 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1304 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1263 | pendingSubtodo = 0; | 1305 | pendingSubtodo = 0; |
1264 | } else { | 1306 | } else { |
1265 | Todo* newParent = todoItem->todo(); | 1307 | Todo* newParent = todoItem->todo(); |
1266 | Todo* newSub = pendingSubtodo->todo(); | 1308 | Todo* newSub = pendingSubtodo->todo(); |
1267 | pendingSubtodo = 0; | 1309 | pendingSubtodo = 0; |
1268 | emit reparentTodoSignal( newParent,newSub ); | 1310 | emit reparentTodoSignal( newParent,newSub ); |
1269 | return; | 1311 | return; |
1270 | } | 1312 | } |
1271 | } | 1313 | } |
1272 | 1314 | ||
1273 | } | 1315 | } |
1274 | 1316 | ||
1275 | void KOTodoView::setDocumentId( const QString &id ) | 1317 | void KOTodoView::setDocumentId( const QString &id ) |
1276 | { | 1318 | { |
1277 | 1319 | ||
1278 | mDocPrefs->setDoc( id ); | 1320 | mDocPrefs->setDoc( id ); |
1279 | } | 1321 | } |
1280 | 1322 | ||
1281 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1323 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1282 | { | 1324 | { |
1283 | if (!item) return; | 1325 | if (!item) return; |
1284 | 1326 | ||
1285 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1327 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1286 | 1328 | ||
1287 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1329 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1288 | 1330 | ||
1289 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1331 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1290 | } | 1332 | } |
1291 | 1333 | ||
1292 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1334 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1293 | { | 1335 | { |
1294 | mTodoListView->saveLayout(config,group); | 1336 | mTodoListView->saveLayout(config,group); |
1295 | } | 1337 | } |
1296 | 1338 | ||
1297 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1339 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1298 | { | 1340 | { |
1299 | mTodoListView->restoreLayout(config,group); | 1341 | mTodoListView->restoreLayout(config,group); |
1300 | } | 1342 | } |
1301 | 1343 | ||
1302 | void KOTodoView::processSelectionChange() | 1344 | void KOTodoView::processSelectionChange() |
1303 | { | 1345 | { |
1304 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1346 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1305 | 1347 | ||
1306 | KOTodoViewItem *item = | 1348 | KOTodoViewItem *item = |
1307 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1349 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1308 | 1350 | ||
1309 | if ( !item ) { | 1351 | if ( !item ) { |
1310 | emit incidenceSelected( 0 ); | 1352 | emit incidenceSelected( 0 ); |
1311 | } else { | 1353 | } else { |
1312 | emit incidenceSelected( item->todo() ); | 1354 | emit incidenceSelected( item->todo() ); |
1313 | } | 1355 | } |
1314 | } | 1356 | } |
1315 | 1357 | ||
1316 | void KOTodoView::modified(bool b) | 1358 | void KOTodoView::modified(bool b) |
1317 | { | 1359 | { |
1318 | emit isModified(b); | 1360 | emit isModified(b); |
1319 | } | 1361 | } |
1320 | void KOTodoView::setTodoModified( Todo* todo ) | 1362 | void KOTodoView::setTodoModified( Todo* todo ) |
1321 | { | 1363 | { |
1322 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1364 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1323 | } | 1365 | } |
1324 | void KOTodoView::clearSelection() | 1366 | void KOTodoView::clearSelection() |
1325 | { | 1367 | { |
1326 | mTodoListView->selectAll( false ); | 1368 | mTodoListView->selectAll( false ); |
1327 | } | 1369 | } |
1328 | void KOTodoView::setAllOpen() | 1370 | void KOTodoView::setAllOpen() |
1329 | { | 1371 | { |
1330 | if ( isFlatDisplay ) { | 1372 | if ( isFlatDisplay ) { |
1331 | isFlatDisplay = false; | 1373 | isFlatDisplay = false; |
1332 | mPopupMenu->setItemChecked( 8,false ); | 1374 | mPopupMenu->setItemChecked( 8,false ); |