summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
authorzautrix <zautrix>2005-06-17 09:29:18 (UTC)
committer zautrix <zautrix>2005-06-17 09:29:18 (UTC)
commit160b471e4d254fd45dbbd161178de15a14163a0c (patch) (unidiff)
tree149a5bf6ef1eb0399c46c928a53d31fa298ac383 /korganizer/kotodoview.cpp
parentcd71ce2dd43e4cca3b3da3f599616e7b1b6b8deb (diff)
downloadkdepimpi-160b471e4d254fd45dbbd161178de15a14163a0c.zip
kdepimpi-160b471e4d254fd45dbbd161178de15a14163a0c.tar.gz
kdepimpi-160b471e4d254fd45dbbd161178de15a14163a0c.tar.bz2
fixxx
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp49
1 files changed, 37 insertions, 12 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index c5fae17..13e88ef 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -15,108 +15,133 @@
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>
40#include "ktimeedit.h"
39#include <kiconloader.h> 41#include <kiconloader.h>
40#include <kmessagebox.h> 42#include <kmessagebox.h>
41 43
42#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
43#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
44#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
45#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
46#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
47#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
48#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
49#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
50#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
51#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
52#else 54#else
53#include <qapplication.h> 55#include <qapplication.h>
54#endif 56#endif
55#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
56#include "calprinter.h" 58#include "calprinter.h"
57#endif 59#endif
58#include "docprefs.h" 60#include "docprefs.h"
59 61
60#include "kotodoview.h" 62#include "kotodoview.h"
61using namespace KOrg; 63using namespace KOrg;
62 64
63 65
64KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 66KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
65 QDialog( parent, name, true ) 67 QDialog( parent, name, true )
66{ 68{
67 mTodo = todo; 69 mTodo = todo;
68 setCaption( i18n("Stop todo") ); 70 setCaption( i18n("Stop todo") );
69 QVBoxLayout* lay = new QVBoxLayout( this ); 71 QVBoxLayout* lay = new QVBoxLayout( this );
70 lay->setSpacing( 3 ); 72 lay->setSpacing( 3 );
71 lay->setMargin( 3 ); 73 lay->setMargin( 3 );
72 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this ); 74 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this );
73 lay->addWidget( lab ); 75 lay->addWidget( lab );
74 lab->setAlignment( AlignHCenter ); 76 lab->setAlignment( AlignHCenter );
75 77 lab = new QLabel( i18n("Additional Comment:"), this );
78 lay->addWidget( lab );
79 mComment = new QLineEdit( this );
80 lay->addWidget( mComment );
81 QHBox * start = new QHBox ( this );
82 lay->addWidget( start );
83 lab = new QLabel( i18n("Start:"), start );
84 QHBox * end = new QHBox ( this );
85 lay->addWidget( end );
86 lab = new QLabel( i18n("End:"), end );
87 sde = new KDateEdit( start );
88 ste = new KOTimeEdit( start );
89 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
90 ede = new KDateEdit( end );
91 ete = new KOTimeEdit(end );
92 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
93 sde->setDate( mTodo->runStart().date() );
94 ste->setTime( mTodo->runStart().time() );
95 ede->setDate( QDate::currentDate());
96 ete->setTime( QTime::currentTime() );
76 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 97 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
77 lay->addWidget( ok ); 98 lay->addWidget( ok );
78 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 99 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
79 lay->addWidget( cancel ); 100 lay->addWidget( cancel );
80 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 101 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
81 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 102 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
82 ok = new QPushButton( i18n("Stop - do not save"), this ); 103 ok = new QPushButton( i18n("Stop - do not save"), this );
83 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 104 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
84 lay->addWidget( ok ); 105 lay->addWidget( ok );
85 resize( 200, 200 ); 106 if (QApplication::desktop()->width() < 320 )
107 resize( 240, 200 );
108 else
109 resize( 320, 200 );
110
86} 111}
87 112
88void KOStopTodoPrefs::accept() 113void KOStopTodoPrefs::accept()
89{ 114{
90 qDebug("KOStopTodoPrefs::accept() "); 115 QDateTime start = QDateTime( sde->date(), ste->getTime() );
91 116 QDateTime stop = QDateTime( ede->date(), ete->getTime() );
92 117 if ( start > stop ) {
93#if 0 118 KMessageBox::sorry(this,
94 t->setRunningFalse( comment ); 119 i18n("The start time is\nafter the end time!"),
95 120 i18n("Time mismatch!"));
96 t->setRunning( false ); 121 return;
97#endif 122 }
98 123 mTodo->saveRunningInfo( mComment->text(), start, stop );
99 QDialog::accept(); 124 QDialog::accept();
100} 125}
101void KOStopTodoPrefs::doNotSave() 126void KOStopTodoPrefs::doNotSave()
102{ 127{
103 int result = KMessageBox::warningContinueCancel(this, 128 int result = KMessageBox::warningContinueCancel(this,
104 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() ); 129 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() );
105 if (result != KMessageBox::Continue) return; 130 if (result != KMessageBox::Continue) return;
106 mTodo->stopRunning(); 131 mTodo->stopRunning();
107 QDialog::accept(); 132 QDialog::accept();
108} 133}
109 134
110 135
111class KOTodoViewWhatsThis :public QWhatsThis 136class KOTodoViewWhatsThis :public QWhatsThis
112{ 137{
113public: 138public:
114 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 139 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
115 140
116protected: 141protected:
117 virtual QString text( const QPoint& p) 142 virtual QString text( const QPoint& p)
118 { 143 {
119 return _view->getWhatsThisText(p) ; 144 return _view->getWhatsThisText(p) ;
120 } 145 }
121private: 146private:
122 QWidget* _wid; 147 QWidget* _wid;
@@ -1178,49 +1203,49 @@ void KOTodoView::toggleRunningItem()
1178 Todo * t = mActiveItem->todo(); 1203 Todo * t = mActiveItem->todo();
1179 if ( t->isRunning() ) { 1204 if ( t->isRunning() ) {
1180 1205
1181 1206
1182 KOStopTodoPrefs tp ( t, this ); 1207 KOStopTodoPrefs tp ( t, this );
1183 tp.exec(); 1208 tp.exec();
1184 1209
1185 1210
1186#if 0 1211#if 0
1187 int result = KMessageBox::warningYesNoCancel(this, 1212 int result = KMessageBox::warningYesNoCancel(this,
1188 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")); 1213 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"));
1189 if (result == KMessageBox::Cancel) return; 1214 if (result == KMessageBox::Cancel) return;
1190 if ( result == KMessageBox::No ) { 1215 if ( result == KMessageBox::No ) {
1191 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); 1216 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") );
1192 t->setRunningFalse( comment ); 1217 t->setRunningFalse( comment );
1193 } else { 1218 } else {
1194 t->setRunning( false ); 1219 t->setRunning( false );
1195 } 1220 }
1196 mActiveItem->construct(); 1221 mActiveItem->construct();
1197 1222
1198 1223
1199#endif 1224#endif
1200 } else { 1225 } else {
1201 int result = KMessageBox::warningContinueCancel(this, 1226 int result = KMessageBox::warningContinueCancel(this,
1202 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); 1227 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);
1203 if (result != KMessageBox::Continue) return; 1228 if (result != KMessageBox::Continue) return;
1204 t->setRunning( true ); 1229 t->setRunning( true );
1205 mActiveItem->construct(); 1230 mActiveItem->construct();
1206 } 1231 }
1207} 1232}
1208 1233
1209void KOTodoView::itemClicked(QListViewItem *item) 1234void KOTodoView::itemClicked(QListViewItem *item)
1210{ 1235{
1211 //qDebug("KOTodoView::itemClicked %d", item); 1236 //qDebug("KOTodoView::itemClicked %d", item);
1212 if (!item) { 1237 if (!item) {
1213 if ( pendingSubtodo != 0 ) { 1238 if ( pendingSubtodo != 0 ) {
1214 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1239 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1215 } 1240 }
1216 pendingSubtodo = 0; 1241 pendingSubtodo = 0;
1217 return; 1242 return;
1218 } 1243 }
1219 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1244 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1220 if ( pendingSubtodo != 0 ) { 1245 if ( pendingSubtodo != 0 ) {
1221 bool allowReparent = true; 1246 bool allowReparent = true;
1222 QListViewItem *par = item; 1247 QListViewItem *par = item;
1223 while ( par ) { 1248 while ( par ) {
1224 if ( par == pendingSubtodo ) { 1249 if ( par == pendingSubtodo ) {
1225 allowReparent = false; 1250 allowReparent = false;
1226 break; 1251 break;