summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-27 04:48:41 (UTC)
committer zautrix <zautrix>2005-06-27 04:48:41 (UTC)
commit9b2bf31715226dfa8210f31843616a04f810f012 (patch) (unidiff)
treeb502c4a379b26f74621ba8fabb59fcb53f5a5679 /korganizer
parent2e566a307bb50ac595fe729ebed0f5336f2af5a8 (diff)
downloadkdepimpi-9b2bf31715226dfa8210f31843616a04f810f012.zip
kdepimpi-9b2bf31715226dfa8210f31843616a04f810f012.tar.gz
kdepimpi-9b2bf31715226dfa8210f31843616a04f810f012.tar.bz2
strat stop tod fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp60
-rw-r--r--korganizer/kotodoview.h14
2 files changed, 65 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
@@ -42,48 +42,78 @@
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"
63using namespace KOrg; 63using namespace KOrg;
64 64
65 65
66KOStartTodoPrefs::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}
91void KOStartTodoPrefs::doStop()
92{
93 mStopAll = false;
94 accept();
95}
66KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 96KOStopTodoPrefs::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 ) ) );
@@ -1178,83 +1208,95 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
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}
1214void KOTodoView::toggleRunningItem() 1244void 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
1240void KOTodoView::itemClicked(QListViewItem *item) 1282void 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 }
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 8f0c99e..1b31d0d 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -55,48 +55,62 @@ class KOTodoViewWhatsThis;
55class KDateEdit; 55class KDateEdit;
56class KOTimeEdit; 56class KOTimeEdit;
57 57
58class DocPrefs; 58class DocPrefs;
59 59
60 60
61class KOStopTodoPrefs : public QDialog 61class KOStopTodoPrefs : public QDialog
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 public: 64 public:
65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; 65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
66 66
67 67
68private slots: 68private slots:
69 void doNotSave(); 69 void doNotSave();
70 void accept(); 70 void accept();
71private: 71private:
72 Todo* mTodo; 72 Todo* mTodo;
73 QLineEdit* mComment; 73 QLineEdit* mComment;
74 KDateEdit *sde, *ede; 74 KDateEdit *sde, *ede;
75 KOTimeEdit *ste, *ete; 75 KOTimeEdit *ste, *ete;
76 76
77}; 77};
78 78
79class KOStartTodoPrefs : public QDialog
80{
81 Q_OBJECT
82 public:
83 KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ;
84
85 bool stopAll() { return mStopAll; }
86private slots:
87 void doStop();
88private:
89 bool mStopAll;
90
91};
92
79class KOTodoListView : public KListView 93class KOTodoListView : public KListView
80{ 94{
81 Q_OBJECT 95 Q_OBJECT
82 public: 96 public:
83 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 97 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
84 virtual ~KOTodoListView() {} 98 virtual ~KOTodoListView() {}
85 99
86 signals: 100 signals:
87 void paintNeeded(); 101 void paintNeeded();
88 void todoDropped(Todo *, int); 102 void todoDropped(Todo *, int);
89 void double_Clicked(QListViewItem *item); 103 void double_Clicked(QListViewItem *item);
90 void reparentTodoSignal( Todo *,Todo * ); 104 void reparentTodoSignal( Todo *,Todo * );
91 void unparentTodoSignal(Todo *); 105 void unparentTodoSignal(Todo *);
92 void deleteTodo( Todo * ); 106 void deleteTodo( Todo * );
93 protected: 107 protected:
94 void wheelEvent (QWheelEvent *e); 108 void wheelEvent (QWheelEvent *e);
95 void contentsDragEnterEvent(QDragEnterEvent *); 109 void contentsDragEnterEvent(QDragEnterEvent *);
96 void contentsDragMoveEvent(QDragMoveEvent *); 110 void contentsDragMoveEvent(QDragMoveEvent *);
97 void contentsDragLeaveEvent(QDragLeaveEvent *); 111 void contentsDragLeaveEvent(QDragLeaveEvent *);
98 void contentsDropEvent(QDropEvent *); 112 void contentsDropEvent(QDropEvent *);
99 113
100 void contentsMousePressEvent(QMouseEvent *); 114 void contentsMousePressEvent(QMouseEvent *);
101 void contentsMouseMoveEvent(QMouseEvent *); 115 void contentsMouseMoveEvent(QMouseEvent *);
102 void contentsMouseReleaseEvent(QMouseEvent *); 116 void contentsMouseReleaseEvent(QMouseEvent *);