summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index e95039d..8fe9999 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,76 +1,78 @@
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 28
29#include <qinputdialog.h>
30
29#include <qvbox.h> 31#include <qvbox.h>
30#include <kdebug.h> 32#include <kdebug.h>
31#include "koprefs.h" 33#include "koprefs.h"
32#include <klocale.h> 34#include <klocale.h>
33#include <kglobal.h> 35#include <kglobal.h>
34#include <kiconloader.h> 36#include <kiconloader.h>
35#include <kmessagebox.h> 37#include <kmessagebox.h>
36 38
37#include <libkcal/icaldrag.h> 39#include <libkcal/icaldrag.h>
38#include <libkcal/vcaldrag.h> 40#include <libkcal/vcaldrag.h>
39#include <libkcal/calfilter.h> 41#include <libkcal/calfilter.h>
40#include <libkcal/dndfactory.h> 42#include <libkcal/dndfactory.h>
41#include <libkcal/calendarresources.h> 43#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 44#include <libkcal/resourcecalendar.h>
43#include <kresources/resourceselectdialog.h> 45#include <kresources/resourceselectdialog.h>
44#include <libkcal/kincidenceformatter.h> 46#include <libkcal/kincidenceformatter.h>
45#ifndef DESKTOP_VERSION 47#ifndef DESKTOP_VERSION
46#include <qpe/qpeapplication.h> 48#include <qpe/qpeapplication.h>
47#else 49#else
48#include <qapplication.h> 50#include <qapplication.h>
49#endif 51#endif
50#ifndef KORG_NOPRINTER 52#ifndef KORG_NOPRINTER
51#include "calprinter.h" 53#include "calprinter.h"
52#endif 54#endif
53#include "docprefs.h" 55#include "docprefs.h"
54 56
55#include "kotodoview.h" 57#include "kotodoview.h"
56using namespace KOrg; 58using namespace KOrg;
57 59
58 60
59class KOTodoViewWhatsThis :public QWhatsThis 61class KOTodoViewWhatsThis :public QWhatsThis
60{ 62{
61public: 63public:
62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 64 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
63 65
64protected: 66protected:
65 virtual QString text( const QPoint& p) 67 virtual QString text( const QPoint& p)
66 { 68 {
67 return _view->getWhatsThisText(p) ; 69 return _view->getWhatsThisText(p) ;
68 } 70 }
69private: 71private:
70 QWidget* _wid; 72 QWidget* _wid;
71 KOTodoView * _view; 73 KOTodoView * _view;
72}; 74};
73 75
74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 76KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
75 const char *name) : 77 const char *name) :
76 KListView(parent,name) 78 KListView(parent,name)
@@ -1081,100 +1083,110 @@ void KOTodoView::changedCategories(int index)
1081 if ( !colcat.isEmpty() ) { 1083 if ( !colcat.isEmpty() ) {
1082 if ( categories.find ( colcat ) != categories.end () ) { 1084 if ( categories.find ( colcat ) != categories.end () ) {
1083 categories.remove( colcat ); 1085 categories.remove( colcat );
1084 categories.prepend( colcat ); 1086 categories.prepend( colcat );
1085 } 1087 }
1086 } 1088 }
1087 mActiveItem->todo()->setCategories (categories); 1089 mActiveItem->todo()->setCategories (categories);
1088 mActiveItem->construct(); 1090 mActiveItem->construct();
1089 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1091 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1090 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1092 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1091 } 1093 }
1092} 1094}
1093void KOTodoView::itemDoubleClicked(QListViewItem *item) 1095void KOTodoView::itemDoubleClicked(QListViewItem *item)
1094{ 1096{
1095 if ( pendingSubtodo != 0 ) { 1097 if ( pendingSubtodo != 0 ) {
1096 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1098 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1097 } 1099 }
1098 pendingSubtodo = 0; 1100 pendingSubtodo = 0;
1099 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1101 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1100 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1102 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1101 //qDebug("ROW %d ", row); 1103 //qDebug("ROW %d ", row);
1102 if (!item) { 1104 if (!item) {
1103 newTodo(); 1105 newTodo();
1104 return; 1106 return;
1105 } else { 1107 } else {
1106 if ( row == 2 || row == 1 ) { 1108 if ( row == 2 || row == 1 ) {
1107 mActiveItem = (KOTodoViewItem *) item; 1109 mActiveItem = (KOTodoViewItem *) item;
1108 newSubTodo(); 1110 newSubTodo();
1109 return; 1111 return;
1110 } 1112 }
1111 if ( row == 5 || row == 6 ) { 1113 if ( row == 5 || row == 6 ) {
1112 mActiveItem = (KOTodoViewItem *) item; 1114 mActiveItem = (KOTodoViewItem *) item;
1113 toggleRunningItem(); 1115 toggleRunningItem();
1114 return; 1116 return;
1115 } 1117 }
1116 } 1118 }
1117 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1119 if ( KOPrefs::instance()->mEditOnDoubleClick )
1118 editItem( item ); 1120 editItem( item );
1119 else 1121 else
1120 showItem( item , QPoint(), 0 ); 1122 showItem( item , QPoint(), 0 );
1121} 1123}
1122void KOTodoView::toggleRunningItem() 1124void KOTodoView::toggleRunningItem()
1123{ 1125{
1124 // qDebug("KOTodoView::toggleRunning() "); 1126 // qDebug("KOTodoView::toggleRunning() ");
1125 if ( ! mActiveItem ) 1127 if ( ! mActiveItem )
1126 return; 1128 return;
1127 Todo * t = mActiveItem->todo(); 1129 Todo * t = mActiveItem->todo();
1128 if ( t->isRunning() ) { 1130 if ( t->isRunning() ) {
1131#if 0
1129 int result = KMessageBox::warningContinueCancel(this, 1132 int result = KMessageBox::warningContinueCancel(this,
1130 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 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);
1131 if (result != KMessageBox::Continue) return; 1134#endif
1132 t->setRunning( false ); 1135
1136 int result = KMessageBox::warningYesNoCancel(this,
1137 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"));
1138 if (result == KMessageBox::Cancel) return;
1139 if ( result == KMessageBox::No ) {
1140 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") );
1141 t->setRunningFalse( comment );
1142 } else {
1143 t->setRunning( false );
1144 }
1133 mActiveItem->construct(); 1145 mActiveItem->construct();
1134 } else { 1146 } else {
1135 int result = KMessageBox::warningContinueCancel(this, 1147 int result = KMessageBox::warningContinueCancel(this,
1136 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 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);
1137 if (result != KMessageBox::Continue) return; 1149 if (result != KMessageBox::Continue) return;
1138 t->setRunning( true ); 1150 t->setRunning( true );
1139 mActiveItem->construct(); 1151 mActiveItem->construct();
1140 } 1152 }
1141} 1153}
1142 1154
1143void KOTodoView::itemClicked(QListViewItem *item) 1155void KOTodoView::itemClicked(QListViewItem *item)
1144{ 1156{
1145 //qDebug("KOTodoView::itemClicked %d", item); 1157 //qDebug("KOTodoView::itemClicked %d", item);
1146 if (!item) { 1158 if (!item) {
1147 if ( pendingSubtodo != 0 ) { 1159 if ( pendingSubtodo != 0 ) {
1148 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1160 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1149 } 1161 }
1150 pendingSubtodo = 0; 1162 pendingSubtodo = 0;
1151 return; 1163 return;
1152 } 1164 }
1153 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1165 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1154 if ( pendingSubtodo != 0 ) { 1166 if ( pendingSubtodo != 0 ) {
1155 bool allowReparent = true; 1167 bool allowReparent = true;
1156 QListViewItem *par = item; 1168 QListViewItem *par = item;
1157 while ( par ) { 1169 while ( par ) {
1158 if ( par == pendingSubtodo ) { 1170 if ( par == pendingSubtodo ) {
1159 allowReparent = false; 1171 allowReparent = false;
1160 break; 1172 break;
1161 } 1173 }
1162 par = par->parent(); 1174 par = par->parent();
1163 } 1175 }
1164 if ( !allowReparent ) { 1176 if ( !allowReparent ) {
1165 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1177 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1166 pendingSubtodo = 0; 1178 pendingSubtodo = 0;
1167 } else { 1179 } else {
1168 Todo* newParent = todoItem->todo(); 1180 Todo* newParent = todoItem->todo();
1169 Todo* newSub = pendingSubtodo->todo(); 1181 Todo* newSub = pendingSubtodo->todo();
1170 pendingSubtodo = 0; 1182 pendingSubtodo = 0;
1171 emit reparentTodoSignal( newParent,newSub ); 1183 emit reparentTodoSignal( newParent,newSub );
1172 return; 1184 return;
1173 } 1185 }
1174 } 1186 }
1175 1187
1176} 1188}
1177 1189
1178void KOTodoView::setDocumentId( const QString &id ) 1190void KOTodoView::setDocumentId( const QString &id )
1179{ 1191{
1180 1192