summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--korganizer/koagenda.cpp195
-rw-r--r--korganizer/koagenda.h6
-rw-r--r--korganizer/koagendaitem.cpp2
-rw-r--r--korganizer/koagendaview.cpp14
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/kolistview.cpp55
-rw-r--r--korganizer/kolistview.h7
-rw-r--r--microkde/kdeui/klistview.cpp5
-rw-r--r--microkde/kdeui/klistview.h2
10 files changed, 265 insertions, 24 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 6f8b041..d5d1f76 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,189 +1,191 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.0.21 ************ 3********** VERSION 2.0.21 ************
4 4
5Fixed another SMTP problem in OM/Pi. 5Fixed another SMTP problem in OM/Pi.
6Some small changed in the new datenavigator in KO/Pi. 6Some small changed in the new datenavigator in KO/Pi.
7Changed default setting for new filter in KA/Pi to "exclude categories". 7Changed default setting for new filter in KA/Pi to "exclude categories".
8Changed the default font size for 640x480 display . 8Changed the default font size for 640x480 display .
9Changed popup menu behaviour in agenda and list view. 9Changed popup menu behaviour in agenda and list view.
10Fixed some layout problems of the date label size in the month view. 10Fixed some layout problems of the date label size in the month view.
11Made month view update faster. 11Made month view update faster.
12Made first datenavigator repainting faster. 12Made first datenavigator repainting faster.
13Changed the title of the event/todo edit dialogs. 13Changed the title of the event/todo edit dialogs.
14Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course).
15Please report, if there are layout problems with the new timelabels.
14 16
15 17
16********** VERSION 2.0.20 ************ 18********** VERSION 2.0.20 ************
17 19
18Two small fixes in OM/Pi. 20Two small fixes in OM/Pi.
19 21
20Better resizing of the new datenavigator in KO/Pi. 22Better resizing of the new datenavigator in KO/Pi.
21 23
22********** VERSION 2.0.19 ************ 24********** VERSION 2.0.19 ************
23KO/Pi: 25KO/Pi:
24Enhancements and bugfixes in the new datenavigator. 26Enhancements and bugfixes in the new datenavigator.
25Bugfix in this changelog: 27Bugfix in this changelog:
26The datenavigator was changed in version 2.0.18, not the datepicker. 28The datenavigator was changed in version 2.0.18, not the datepicker.
27 29
28********** VERSION 2.0.18 ************ 30********** VERSION 2.0.18 ************
29KO/Pi: 31KO/Pi:
30Fixed some minor problems. 32Fixed some minor problems.
31Cleaned up the KO/Pi config dialog. 33Cleaned up the KO/Pi config dialog.
32Fixed problem moving events in aganda view. 34Fixed problem moving events in aganda view.
33Made datepicker scaleable, i.e. if the datenavigator shows now a 35Made datepicker scaleable, i.e. if the datenavigator shows now a
34datenavigator matrix depending on its size. 36datenavigator matrix depending on its size.
35Birthdays are now displayed green in the datenavigator. 37Birthdays are now displayed green in the datenavigator.
36What'sThis Help in datenavigator shows all events of the day. 38What'sThis Help in datenavigator shows all events of the day.
37 39
38OM/Pi: 40OM/Pi:
39Updated the backend mail library to the latest version. 41Updated the backend mail library to the latest version.
40Please backup your mail before using this version. 42Please backup your mail before using this version.
41 43
42********** VERSION 2.0.17 ************ 44********** VERSION 2.0.17 ************
43 45
44KO/Pi: 46KO/Pi:
45Tooltips in month view were not sorted. Fixed. 47Tooltips in month view were not sorted. Fixed.
46Daylabel in agenda view ( for display of one day ) was too short. Fixed. 48Daylabel in agenda view ( for display of one day ) was too short. Fixed.
47Conflict display dialog for syncing was not on top of other windows. Fixed. 49Conflict display dialog for syncing was not on top of other windows. Fixed.
48Fixed some minor problems. 50Fixed some minor problems.
49 51
50Fixed an endless loop when importing vcs file with RESOURCES entry. 52Fixed an endless loop when importing vcs file with RESOURCES entry.
51 53
52********** VERSION 2.0.16 ************ 54********** VERSION 2.0.16 ************
53OM/Pi: 55OM/Pi:
54Fixed the SMTP account setting the option. 56Fixed the SMTP account setting the option.
55Fixed something in mail sending. 57Fixed something in mail sending.
56 58
57KO/Pi: 59KO/Pi:
58Added possibility to export selected events/todos as vcal file. 60Added possibility to export selected events/todos as vcal file.
59 61
60********** VERSION 2.0.15 ************ 62********** VERSION 2.0.15 ************
61 63
62PwM/Pi: 64PwM/Pi:
63Added keyboard shorcuts for 65Added keyboard shorcuts for
64- toggling summary view (space bar) 66- toggling summary view (space bar)
65- delete item (delete + backspace key) 67- delete item (delete + backspace key)
66- add new item ( i + n key) 68- add new item ( i + n key)
67Fixed length of info in the title. 69Fixed length of info in the title.
68 70
69KO/Pi-KA/Pi: 71KO/Pi-KA/Pi:
70Changed "ME" menu bar entry to an icon. 72Changed "ME" menu bar entry to an icon.
71 73
72KO/Pi: 74KO/Pi:
73Fixed two minor bugs in displaying todos. 75Fixed two minor bugs in displaying todos.
74If in month view a cell is selected, the key shortcut "d" shows now that date. 76If in month view a cell is selected, the key shortcut "d" shows now that date.
75Added complete info for a todo in month view as an icon left of the text. 77Added complete info for a todo in month view as an icon left of the text.
76Fixed problems of displaying data when "<" or ">" are used in summary/location/description. 78Fixed problems of displaying data when "<" or ">" are used in summary/location/description.
77Fixed problem of search dialog size when switching displays. 79Fixed problem of search dialog size when switching displays.
78Cancel key now closes date picker. 80Cancel key now closes date picker.
79Rearranged KO/Pi file menu structure. 81Rearranged KO/Pi file menu structure.
80 82
81OM/Pi: 83OM/Pi:
82Added to the SMTP account setting the option 84Added to the SMTP account setting the option
83"No secure connection". 85"No secure connection".
84You have to configure your SMTP accounts again, sorry. 86You have to configure your SMTP accounts again, sorry.
85 87
86KA/Pi: 88KA/Pi:
87Added support for importing quoted-printable. 89Added support for importing quoted-printable.
88Support was added by Peter P.. Thanks, Peter! 90Support was added by Peter P.. Thanks, Peter!
89 91
90 92
91********** VERSION 2.0.14 ************ 93********** VERSION 2.0.14 ************
92 94
93Made Passwordmanager PwM/Pi more userfriendly: 95Made Passwordmanager PwM/Pi more userfriendly:
94Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 96Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
95Fixed bug in KO/Pi todo printing. 97Fixed bug in KO/Pi todo printing.
96Made Qtopia calendar import possible on desktop . 98Made Qtopia calendar import possible on desktop .
97 99
98********** VERSION 2.0.13 ************ 100********** VERSION 2.0.13 ************
99 101
100Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. 102Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter.
101 103
102In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". 104In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down".
103 105
104OM/Pi: 106OM/Pi:
105Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. 107Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails.
106Added missing German translation. 108Added missing German translation.
107Added warning if path is specified in local folder settings of account config. 109Added warning if path is specified in local folder settings of account config.
108 110
109********** VERSION 2.0.12 ************ 111********** VERSION 2.0.12 ************
110 112
111KO/Pi: 113KO/Pi:
112Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. 114Fixed a bug in todo start/due date handling for non recurring todos with a start and due date.
113Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. 115Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes.
114Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. 116Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer.
115 117
116Fixed problem in pi-sync mode when wrong password was sent. 118Fixed problem in pi-sync mode when wrong password was sent.
117 119
118OM/Pi: 120OM/Pi:
119Fixed a crash when displaying mails with "Show mail as html" was checked in the config. 121Fixed a crash when displaying mails with "Show mail as html" was checked in the config.
120Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. 122Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled.
121 123
122********** VERSION 2.0.11 ************ 124********** VERSION 2.0.11 ************
123 125
124Fixed some problems in pi-sync mode 126Fixed some problems in pi-sync mode
125(e.g. details of events were not synced properly) 127(e.g. details of events were not synced properly)
126 128
127********** VERSION 2.0.10 ************ 129********** VERSION 2.0.10 ************
128 130
129KO/Pi: 131KO/Pi:
130In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. 132In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view.
131This is fixed. 133This is fixed.
132Changed the search dialog a bit to make it more user friendly. 134Changed the search dialog a bit to make it more user friendly.
133(E.g.: Removed message box about "no items found" and set key focus to search line edit after search). 135(E.g.: Removed message box about "no items found" and set key focus to search line edit after search).
134 136
135Added config option to hide the week number in KO/Pi toolbar. 137Added config option to hide the week number in KO/Pi toolbar.
136 138
137********** VERSION 2.0.9 ************ 139********** VERSION 2.0.9 ************
138 140
139Made month view icons for multiday events a bit nicer. 141Made month view icons for multiday events a bit nicer.
140Some minor fixes in KO/Pi 142Some minor fixes in KO/Pi
141(e.g. go to today did not work for new week view properly). 143(e.g. go to today did not work for new week view properly).
142 144
143 145
144********** VERSION 2.0.8 ************ 146********** VERSION 2.0.8 ************
145 147
146Fixed a problem in dependency info in the ipk files for the Zaurus. 148Fixed a problem in dependency info in the ipk files for the Zaurus.
147 149
148Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. 150Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar.
149 151
150Added a "go today" button to the datepicker. 152Added a "go today" button to the datepicker.
151 153
152Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) 154Added "created" and "last modified" to event/todo viewer (and What'sThis viewer)
153and made it configureable to show these values. 155and made it configureable to show these values.
154 156
155Fixed a problem for events (from external iCal files) that do have a duration but no end date. 157Fixed a problem for events (from external iCal files) that do have a duration but no end date.
156 158
157 159
158********** VERSION 2.0.7 ************ 160********** VERSION 2.0.7 ************
159 161
160Added global application font settings 162Added global application font settings
161(for all KDE-Pim/Pi apps) to the general settings. 163(for all KDE-Pim/Pi apps) to the general settings.
162 164
163Fixed a problem in OM/Pi when trying to login to some IMAP servers 165Fixed a problem in OM/Pi when trying to login to some IMAP servers
164(like the IMAP server of Apple: mail.mac.com ) 166(like the IMAP server of Apple: mail.mac.com )
165 167
166Added recurring todos to KO/Pi. 168Added recurring todos to KO/Pi.
167 169
168 170
169********** VERSION 2.0.6 ************ 171********** VERSION 2.0.6 ************
170 172
171Stable release 2.0.6! 173Stable release 2.0.6!
172 174
173Some bugfixes in the pi-sync mode. 175Some bugfixes in the pi-sync mode.
174Added German translation for pi-sync mode. 176Added German translation for pi-sync mode.
175 177
176KO/Pi: 178KO/Pi:
177Made the todolist using alternate background. 179Made the todolist using alternate background.
178 180
179Other minor fixes in KO/Pi. 181Other minor fixes in KO/Pi.
180 182
181 183
182You can find the complete changelog 184You can find the complete changelog
183from version 1.7.7 to 2.0.5 185from version 1.7.7 to 2.0.5
184in the source package or on 186in the source package or on
185 187
186http://www.pi-sync.net/html/changelog.html 188http://www.pi-sync.net/html/changelog.html
187 189
188 190
189 191
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 66ad4ec..14f52b8 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,945 +1,1130 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 66{
67 setLineWidth(0); 67 setLineWidth(0);
68 setMargin(0); 68 setMargin(0);
69 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 70 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 72 minutes->start(0, true);
73
74 mTimeBox = new QLabel(this); 73 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 75 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 76 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 77 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 78 //mTimeBox->setAutoMask(true);
80 79
81 agenda->addChild(mTimeBox); 80 agenda->addChild(mTimeBox);
82 81
83 oldToday = -1; 82 oldToday = -1;
84} 83}
85 84
86MarcusBains::~MarcusBains() 85MarcusBains::~MarcusBains()
87{ 86{
88 delete minutes; 87 delete minutes;
89} 88}
90 89
91int MarcusBains::todayColumn() 90int MarcusBains::todayColumn()
92{ 91{
93 QDate currentDate = QDate::currentDate(); 92 QDate currentDate = QDate::currentDate();
94 93
95 DateList dateList = agenda->dateList(); 94 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 95 DateList::ConstIterator it;
97 int col = 0; 96 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 97 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 98 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 99 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 100 agenda->columns() - 1 - col : col;
102 ++col; 101 ++col;
103 } 102 }
104 103
105 return -1; 104 return -1;
106} 105}
107void MarcusBains::updateLoc() 106void MarcusBains::updateLoc()
108{ 107{
109 updateLocation(); 108 updateLocation();
110} 109}
111void MarcusBains::updateLocation(bool recalculate) 110void MarcusBains::updateLocation(bool recalculate)
112{ 111{
113 112
114 QTime tim = QTime::currentTime(); 113 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 115 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 116 recalculate = true;
118 117
119 int mins = tim.hour()*60 + tim.minute(); 118 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 119 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 120 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 121 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 122 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 124
126 oldTime = tim; 125 oldTime = tim;
127 oldToday = today; 126 oldToday = today;
128 127
129 if(disabled || (today<0)) { 128 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 129 hide(); mTimeBox->hide();
131 return; 130 return;
132 } else { 131 } else {
133 show(); mTimeBox->show(); 132 show(); mTimeBox->show();
134 } 133 }
135 134
136 if(recalculate) 135 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 136 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 137 agenda->moveChild(this, x, y);
139 raise(); 138 raise();
140 139
141 if(recalculate) 140 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 141 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 143
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 145 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 146 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 147 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 148 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 149 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 150 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 152 y-mTimeBox->height());
154 153
155 mTimeBox->raise(); 154 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 156 minutes->start(5000,true);
158} 157}
159 158
160 159
161//////////////////////////////////////////////////////////////////////////// 160////////////////////////////////////////////////////////////////////////////
162 161
163 162
164/* 163/*
165 Create an agenda widget with rows rows and columns columns. 164 Create an agenda widget with rows rows and columns columns.
166*/ 165*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 167 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 168 QScrollView(parent,name,f)
170{ 169{
171 170
172 171
173 mColumns = columns; 172 mColumns = columns;
174 mRows = rows; 173 mRows = rows;
175 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
176 mAllDayMode = false; 175 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
178 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 178#endif
180 mHolidayMask = 0; 179 mHolidayMask = 0;
181 init(); 180 init();
182} 181}
183 182
184/* 183/*
185 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
186 all-day events. 185 all-day events.
187*/ 186*/
188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
189 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
190{ 189{
191 blockResize = false; 190 blockResize = false;
192 mColumns = columns; 191 mColumns = columns;
193 mRows = 1; 192 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 193 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 194 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 195 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 196#ifndef DESKTOP_VERSION
198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 197 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 198#endif
200 mHolidayMask = 0; 199 mHolidayMask = 0;
201 init(); 200 init();
202} 201}
203 202
204 203
205KOAgenda::~KOAgenda() 204KOAgenda::~KOAgenda()
206{ 205{
207 if(mMarcusBains) delete mMarcusBains; 206 if(mMarcusBains) delete mMarcusBains;
208 207
209} 208}
210 209
211Incidence *KOAgenda::selectedIncidence() const 210Incidence *KOAgenda::selectedIncidence() const
212{ 211{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 212 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 213}
215 214
216 215
217QDate KOAgenda::selectedIncidenceDate() const 216QDate KOAgenda::selectedIncidenceDate() const
218{ 217{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 218 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 219}
221 220
222 221
223void KOAgenda::init() 222void KOAgenda::init()
224{ 223{
224 mPopupTimer = new QTimer(this);
225 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
226
225 mNewItemPopup = new QPopupMenu( this ); 227 mNewItemPopup = new QPopupMenu( this );
226 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 228 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
227 QString pathString = ""; 229 QString pathString = "";
228 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 230 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
229 if ( QApplication::desktop()->width() < 480 ) 231 if ( QApplication::desktop()->width() < 480 )
230 pathString += "icons16/"; 232 pathString += "icons16/";
231 } else 233 } else
232 pathString += "iconsmini/"; 234 pathString += "iconsmini/";
233 235
234 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 236 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
235 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
236 mNewItemPopup->insertSeparator ( ); 238 mNewItemPopup->insertSeparator ( );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
243#ifndef _WIN32_ 245#ifndef _WIN32_
244 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
245 viewport()->setWFlags ( wflags); 247 viewport()->setWFlags ( wflags);
246#endif 248#endif
247 mGridSpacingX = 80; 249 mGridSpacingX = 80;
248 mResizeBorderWidth = 8; 250 mResizeBorderWidth = 8;
249 mScrollBorderWidth = 8; 251 mScrollBorderWidth = 8;
250 mScrollDelay = 30; 252 mScrollDelay = 30;
251 mScrollOffset = 10; 253 mScrollOffset = 10;
252 mPaintPixmap.resize( 20,20); 254 mPaintPixmap.resize( 20,20);
253 //enableClipper(true); 255 //enableClipper(true);
254 256
255 // Grab key strokes for keyboard navigation of agenda. Seems to have no 257 // Grab key strokes for keyboard navigation of agenda. Seems to have no
256 // effect. Has to be fixed. 258 // effect. Has to be fixed.
257 setFocusPolicy(WheelFocus); 259 setFocusPolicy(WheelFocus);
258 260
259 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
260 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
261 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
262 264
263 mStartCellX = 0; 265 mStartCellX = 0;
264 mStartCellY = 0; 266 mStartCellY = 0;
265 mCurrentCellX = 0; 267 mCurrentCellX = 0;
266 mCurrentCellY = 0; 268 mCurrentCellY = 0;
267 269
268 mSelectionCellX = 0; 270 mSelectionCellX = 0;
269 mSelectionYTop = 0; 271 mSelectionYTop = 0;
270 mSelectionHeight = 0; 272 mSelectionHeight = 0;
271 273
272 mOldLowerScrollValue = -1; 274 mOldLowerScrollValue = -1;
273 mOldUpperScrollValue = -1; 275 mOldUpperScrollValue = -1;
274 276
275 mClickedItem = 0; 277 mClickedItem = 0;
276 278
277 mActionItem = 0; 279 mActionItem = 0;
278 mActionType = NOP; 280 mActionType = NOP;
279 mItemMoved = false; 281 mItemMoved = false;
280 282
281 mSelectedItem = 0; 283 mSelectedItem = 0;
282 284
283 // mItems.setAutoDelete(true); 285 // mItems.setAutoDelete(true);
284 286
285 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
286 288
287 viewport()->update(); 289 viewport()->update();
288 290
289 setMinimumSize(30, 1); 291 setMinimumSize(30, 1);
290// setMaximumHeight(mGridSpacingY * mRows + 5); 292// setMaximumHeight(mGridSpacingY * mRows + 5);
291 293
292 // Disable horizontal scrollbar. This is a hack. The geometry should be 294 // Disable horizontal scrollbar. This is a hack. The geometry should be
293 // controlled in a way that the contents horizontally always fits. Then it is 295 // controlled in a way that the contents horizontally always fits. Then it is
294 // not necessary to turn off the scrollbar. 296 // not necessary to turn off the scrollbar.
295 setHScrollBarMode(AlwaysOff); 297 setHScrollBarMode(AlwaysOff);
296 if ( ! mAllDayMode ) 298 if ( ! mAllDayMode )
297 setVScrollBarMode(AlwaysOn); 299 setVScrollBarMode(AlwaysOn);
298 else 300 else
299 setVScrollBarMode(AlwaysOff); 301 setVScrollBarMode(AlwaysOff);
300 302
301 setStartHour(KOPrefs::instance()->mDayBegins); 303 setStartHour(KOPrefs::instance()->mDayBegins);
302 304
303 calculateWorkingHours(); 305 calculateWorkingHours();
304 306
305 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
306 SLOT(checkScrollBoundaries(int))); 308 SLOT(checkScrollBoundaries(int)));
307 309
308 // Create the Marcus Bains line. 310 // Create the Marcus Bains line.
309 if(mAllDayMode) 311 if(mAllDayMode)
310 mMarcusBains = 0; 312 mMarcusBains = 0;
311 else { 313 else {
312 mMarcusBains = new MarcusBains(this); 314 mMarcusBains = new MarcusBains(this);
313 addChild(mMarcusBains); 315 addChild(mMarcusBains);
314 } 316 }
317 mPopupKind = 0;
318 mPopupItem = 0;
315} 319}
316 320
317void KOAgenda::clear() 321void KOAgenda::clear()
318{ 322{
319 KOAgendaItem *item; 323 KOAgendaItem *item;
320 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 324 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
321 mUnusedItems.append( item ); 325 mUnusedItems.append( item );
322 //item->hide(); 326 //item->hide();
323 } 327 }
324 mItems.clear(); 328 mItems.clear();
325 mSelectedItem = 0; 329 mSelectedItem = 0;
326 clearSelection(); 330 clearSelection();
327} 331}
328 332
329void KOAgenda::clearSelection() 333void KOAgenda::clearSelection()
330{ 334{
331 mSelectionCellX = 0; 335 mSelectionCellX = 0;
332 mSelectionYTop = 0; 336 mSelectionYTop = 0;
333 mSelectionHeight = 0; 337 mSelectionHeight = 0;
334} 338}
335 339
336void KOAgenda::marcus_bains() 340void KOAgenda::marcus_bains()
337{ 341{
338 if(mMarcusBains) mMarcusBains->updateLocation(true); 342 if(mMarcusBains) mMarcusBains->updateLocation(true);
339} 343}
340 344
341 345
342void KOAgenda::changeColumns(int columns) 346void KOAgenda::changeColumns(int columns)
343{ 347{
344 if (columns == 0) { 348 if (columns == 0) {
345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 349 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
346 return; 350 return;
347 } 351 }
348 352
349 clear(); 353 clear();
350 354
351 mColumns = columns; 355 mColumns = columns;
352// setMinimumSize(mColumns * 10, mGridSpacingY + 1); 356// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
353// init(); 357// init();
354// update(); 358// update();
355 //qDebug("KOAgenda::changeColumns "); 359 //qDebug("KOAgenda::changeColumns ");
356 computeSizes(); 360 computeSizes();
357 // QResizeEvent event( size(), size() ); 361 // QResizeEvent event( size(), size() );
358 362
359 //QApplication::sendEvent( this, &event ); 363 //QApplication::sendEvent( this, &event );
360} 364}
361 365
362/* 366/*
363 This is the eventFilter function, which gets all events from the KOAgendaItems 367 This is the eventFilter function, which gets all events from the KOAgendaItems
364 contained in the agenda. It has to handle moving and resizing for all items. 368 contained in the agenda. It has to handle moving and resizing for all items.
365*/ 369*/
366bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 370bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
367{ 371{
368// kdDebug() << "KOAgenda::eventFilter" << endl; 372// kdDebug() << "KOAgenda::eventFilter" << endl;
369 switch(event->type()) { 373 switch(event->type()) {
370 case QEvent::MouseButtonPress: 374 case QEvent::MouseButtonPress:
371 case QEvent::MouseButtonDblClick: 375 case QEvent::MouseButtonDblClick:
372 case QEvent::MouseButtonRelease: 376 case QEvent::MouseButtonRelease:
373 case QEvent::MouseMove: 377 case QEvent::MouseMove:
374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 378 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
375 379
376 case (QEvent::Leave): 380 case (QEvent::Leave):
377 if (!mActionItem) 381 if (!mActionItem)
378 setCursor(arrowCursor); 382 setCursor(arrowCursor);
379 return true; 383 return true;
380 384
381 default: 385 default:
382 return QScrollView::eventFilter(object,event); 386 return QScrollView::eventFilter(object,event);
383 } 387 }
384} 388}
385 389void KOAgenda::popupMenu()
390{
391 mPopupTimer->stop();
392 if ( mPopupKind == 1 ) {
393 if (mActionItem ) {
394 endItemAction();
395 }
396 mLeftMouseDown = false; // no more leftMouse computation
397 if (mPopupItem) {
398 selectItem(mPopupItem);
399 emit showIncidencePopupSignal(mPopupItem->incidence());
400
401 }
402 } else if ( mPopupKind == 2 ) {
403 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
404 endSelectAction( false ); // do not emit new event signal
405 mLeftMouseDown = false; // no more leftMouse computation
406 }
407 mNewItemPopup->popup( mPopupPos);
408 }
409 mLeftMouseDown = false;
410 mPopupItem = 0;
411 mPopupKind = 0;
412}
386 413
387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 414bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
388{ 415{
416 //qDebug("KOAgenda::eventFilter_mous ");
417 QPoint viewportPos;
418 if (object != viewport()) {
419 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
420 } else {
421 viewportPos = me->pos();
422 }
423 static int startX = 0;
424 static int startY = 0;
425 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
426 static bool blockMoving = true;
427 switch (me->type()) {
428 case QEvent::MouseButtonPress:
429 if (me->button() == LeftButton) {
430 mPopupTimer->start( 600 );
431 mLeftMouseDown = true;
432 }
433 blockMoving = true;
434 startX = viewportPos.x();
435 startY = viewportPos.y();
436 if (object != viewport()) {
437 mPopupItem = (KOAgendaItem *)object;
438 mPopupKind = 1;
439 if (me->button() == RightButton) {
440 popupMenu();
441 } else if (me->button() == LeftButton) {
442 mActionItem = (KOAgendaItem *)object;
443 if (mActionItem) {
444 if ( mSelectionHeight > 0 ) {
445 int selectionCellX = mSelectionCellX * mGridSpacingX;
446 int selectionYTop = mSelectionYTop;
447 int gridSpacingX = mGridSpacingX;
448 int selectionHeight = mSelectionHeight;
449 clearSelection();
450 repaintContents( selectionCellX, selectionYTop,
451 gridSpacingX, selectionHeight,false );
452 }
453 selectItem(mActionItem);
454 Incidence *incidence = mActionItem->incidence();
455 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
456 mActionItem = 0;
457 } else {
458 startItemAction(viewportPos);
459 }
460 }
461 }
462 } else { // ---------- viewport()
463 mPopupItem = 0;
464 mPopupKind = 2;
465 selectItem(0);
466 mActionItem = 0;
467 mPopupPos = viewport()->mapToGlobal( me->pos() );
468 if (me->button() == RightButton) {
469 popupMenu();
470 } else if (me->button() == LeftButton) {
471 setCursor(arrowCursor);
472 startSelectAction(viewportPos);
473 }
474 }
475 break;
476
477 case QEvent::MouseButtonRelease:
478 if (me->button() == LeftButton ) {
479 mPopupTimer->stop();
480 }
481 if (object != viewport()) {
482 if (me->button() == LeftButton && mLeftMouseDown) {
483 if (mActionItem) {
484 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
485 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
486 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
487 mScrollUpTimer.stop();
488 mScrollDownTimer.stop();
489 mActionItem->resetMove();
490 placeSubCells( mActionItem );
491 // emit startDragSignal( mActionItem->incidence() );
492 setCursor( arrowCursor );
493 mActionItem = 0;
494 mActionType = NOP;
495 mItemMoved = 0;
496 mLeftMouseDown = false;
497 return true;
498 }
499 endItemAction();
500 }
501 }
502
503 } else { // ---------- viewport()
504 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
505 endSelectAction( true ); // emit new event signal
506 }
507 }
508 if (me->button() == LeftButton)
509 mLeftMouseDown = false;
510
511 break;
512
513 case QEvent::MouseMove:
514 if ( !mLeftMouseDown )
515 return true;
516 if ( blockMoving ) {
517 int dX, dY;
518 dX = startX - viewportPos.x();
519 if ( dX < 0 )
520 dX = -dX;
521 dY = viewportPos.y() - startY;
522 if ( dY < 0 )
523 dY = -dY;
524 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
525 if ( dX > blockmoveDist || dY > blockmoveDist ) {
526 blockMoving = false;
527 }
528 }
529 if ( ! blockMoving )
530 mPopupTimer->stop();
531 if (object != viewport()) {
532 KOAgendaItem *moveItem = (KOAgendaItem *)object;
533 if (!moveItem->incidence()->isReadOnly() ) {
534 if (!mActionItem)
535 setNoActionCursor(moveItem,viewportPos);
536 else {
537 if ( !blockMoving )
538 performItemAction(viewportPos);
539 }
540 }
541 } else { // ---------- viewport()
542 mPopupPos = viewport()->mapToGlobal( me->pos() );
543 if ( mActionType == SELECT ) {
544 performSelectAction( viewportPos );
545 }
546 }
547 break;
548
549 case QEvent::MouseButtonDblClick:
550 mPopupTimer->stop();
551 if (object == viewport()) {
552 selectItem(0);
553 int x,y;
554 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
555 int gx,gy;
556 contentsToGrid(x,y,gx,gy);
557 emit newEventSignal(gx,gy);
558 } else {
559 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
560 selectItem(doubleClickedItem);
561 if ( KOPrefs::instance()->mEditOnDoubleClick )
562 emit editIncidenceSignal(doubleClickedItem->incidence());
563 else
564 emit showIncidenceSignal(doubleClickedItem->incidence());
565 }
566 break;
567
568 default:
569 break;
570 }
571 return true;
572#if 0
389 //qDebug("KOAgenda::eventFilter_mous "); 573 //qDebug("KOAgenda::eventFilter_mous ");
390 QPoint viewportPos; 574 QPoint viewportPos;
391 if (object != viewport()) { 575 if (object != viewport()) {
392 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 576 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
393 } else { 577 } else {
394 viewportPos = me->pos(); 578 viewportPos = me->pos();
395 } 579 }
396 static int startX = 0; 580 static int startX = 0;
397 static int startY = 0; 581 static int startY = 0;
398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 582 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
399 static bool blockMoving = true; 583 static bool blockMoving = true;
400 static bool leftMouseDown = false; 584 static bool leftMouseDown = false;
401 bool rightButtonPressed = false; 585 bool rightButtonPressed = false;
402 switch (me->type()) { 586 switch (me->type()) {
403 case QEvent::MouseButtonPress: 587 case QEvent::MouseButtonPress:
404 if (me->button() == LeftButton) { 588 if (me->button() == LeftButton) {
405 leftMouseDown = true; 589 leftMouseDown = true;
406 } 590 }
407 else if (me->button() == RightButton) { 591 else if (me->button() == RightButton) {
408 leftMouseDown = false; 592 leftMouseDown = false;
409 } 593 }
410 blockMoving = true; 594 blockMoving = true;
411 startX = viewportPos.x(); 595 startX = viewportPos.x();
412 startY = viewportPos.y(); 596 startY = viewportPos.y();
413 if (object != viewport()) { // item clicked ************** 597 if (object != viewport()) { // item clicked **************
414 if (me->button() == RightButton) { 598 if (me->button() == RightButton) {
415 leftMouseDown = false; 599 leftMouseDown = false;
416 mClickedItem = (KOAgendaItem *)object; 600 mClickedItem = (KOAgendaItem *)object;
417 if (mActionItem ) { 601 if (mActionItem ) {
418 endItemAction(); 602 endItemAction();
419 } 603 }
420 if (mClickedItem) { 604 if (mClickedItem) {
421 selectItem(mClickedItem); 605 selectItem(mClickedItem);
422 emit showIncidencePopupSignal(mClickedItem->incidence()); 606 emit showIncidencePopupSignal(mClickedItem->incidence());
423 } 607 }
424 return true; 608 return true;
425 } else if (me->button() == LeftButton) { 609 } else if (me->button() == LeftButton) {
426 mActionItem = (KOAgendaItem *)object; 610 mActionItem = (KOAgendaItem *)object;
427 if (mActionItem) { 611 if (mActionItem) {
428 if ( mSelectionHeight > 0 ) { 612 if ( mSelectionHeight > 0 ) {
429 int selectionCellX = mSelectionCellX * mGridSpacingX; 613 int selectionCellX = mSelectionCellX * mGridSpacingX;
430 int selectionYTop = mSelectionYTop; 614 int selectionYTop = mSelectionYTop;
431 int gridSpacingX = mGridSpacingX; 615 int gridSpacingX = mGridSpacingX;
432 int selectionHeight = mSelectionHeight; 616 int selectionHeight = mSelectionHeight;
433 clearSelection(); 617 clearSelection();
434 repaintContents( selectionCellX, selectionYTop, 618 repaintContents( selectionCellX, selectionYTop,
435 gridSpacingX, selectionHeight,false ); 619 gridSpacingX, selectionHeight,false );
436 } 620 }
437 selectItem(mActionItem); 621 selectItem(mActionItem);
438 Incidence *incidence = mActionItem->incidence(); 622 Incidence *incidence = mActionItem->incidence();
439 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 623 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
440 mActionItem = 0; 624 mActionItem = 0;
441 } else { 625 } else {
442 startItemAction(viewportPos); 626 startItemAction(viewportPos);
443 } 627 }
444 } 628 }
445 } 629 }
446 } else { // ---------- viewport() 630 } else { // ---------- viewport()
447 selectItem(0); 631 selectItem(0);
448 mActionItem = 0; 632 mActionItem = 0;
449 if (me->button() == LeftButton ) { 633 if (me->button() == LeftButton ) {
450 setCursor(arrowCursor); 634 setCursor(arrowCursor);
451 startSelectAction(viewportPos); 635 startSelectAction(viewportPos);
452 } else if (me->button() == RightButton ) { 636 } else if (me->button() == RightButton ) {
453 setCursor(arrowCursor); 637 setCursor(arrowCursor);
454 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action 638 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
455 endSelectAction( false ); // do not emit new event signal 639 endSelectAction( false ); // do not emit new event signal
456 leftMouseDown = false; // no more leftMouse computation 640 leftMouseDown = false; // no more leftMouse computation
457 } 641 }
458 int x,y; 642 int x,y;
459 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 643 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
460 int gx,gy; 644 int gx,gy;
461 contentsToGrid(x,y,gx,gy); 645 contentsToGrid(x,y,gx,gy);
462 mCurrentCellX = gx; 646 mCurrentCellX = gx;
463 mCurrentCellY = gy; 647 mCurrentCellY = gy;
464 mStartCellX = gx; 648 mStartCellX = gx;
465 mStartCellY = gy; 649 mStartCellY = gy;
466 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 650 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
467 } 651 }
468 } 652 }
469 break; 653 break;
470 654
471 case QEvent::MouseButtonRelease: 655 case QEvent::MouseButtonRelease:
472 656
473 if (object != viewport()) { 657 if (object != viewport()) {
474 if (me->button() == LeftButton && leftMouseDown) { 658 if (me->button() == LeftButton && leftMouseDown) {
475 if (mActionItem) { 659 if (mActionItem) {
476 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 660 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
477 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 661 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
478 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 662 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
479 mScrollUpTimer.stop(); 663 mScrollUpTimer.stop();
480 mScrollDownTimer.stop(); 664 mScrollDownTimer.stop();
481 mActionItem->resetMove(); 665 mActionItem->resetMove();
482 placeSubCells( mActionItem ); 666 placeSubCells( mActionItem );
483 // emit startDragSignal( mActionItem->incidence() ); 667 // emit startDragSignal( mActionItem->incidence() );
484 setCursor( arrowCursor ); 668 setCursor( arrowCursor );
485 mActionItem = 0; 669 mActionItem = 0;
486 mActionType = NOP; 670 mActionType = NOP;
487 mItemMoved = 0; 671 mItemMoved = 0;
488 leftMouseDown = false; 672 leftMouseDown = false;
489 return true; 673 return true;
490 } 674 }
491 endItemAction(); 675 endItemAction();
492 } 676 }
493 } 677 }
494 678
495 } else { // ---------- viewport() 679 } else { // ---------- viewport()
496 if (me->button() == LeftButton && leftMouseDown ) { //left click 680 if (me->button() == LeftButton && leftMouseDown ) { //left click
497 endSelectAction( true ); // emit new event signal 681 endSelectAction( true ); // emit new event signal
498 } 682 }
499 } 683 }
500 if (me->button() == LeftButton) 684 if (me->button() == LeftButton)
501 leftMouseDown = false; 685 leftMouseDown = false;
502 686
503 break; 687 break;
504 688
505 case QEvent::MouseMove: 689 case QEvent::MouseMove:
506 if ( !leftMouseDown ) 690 if ( !leftMouseDown )
507 return true; 691 return true;
508 if ( blockMoving ) { 692 if ( blockMoving ) {
509 int dX, dY; 693 int dX, dY;
510 dX = startX - viewportPos.x(); 694 dX = startX - viewportPos.x();
511 if ( dX < 0 ) 695 if ( dX < 0 )
512 dX = -dX; 696 dX = -dX;
513 dY = viewportPos.y() - startY; 697 dY = viewportPos.y() - startY;
514 if ( dY < 0 ) 698 if ( dY < 0 )
515 dY = -dY; 699 dY = -dY;
516 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 700 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
517 if ( dX > blockmoveDist || dY > blockmoveDist ) { 701 if ( dX > blockmoveDist || dY > blockmoveDist ) {
518 blockMoving = false; 702 blockMoving = false;
519 } 703 }
520 } 704 }
521 if (object != viewport()) { 705 if (object != viewport()) {
522 KOAgendaItem *moveItem = (KOAgendaItem *)object; 706 KOAgendaItem *moveItem = (KOAgendaItem *)object;
523 if (!moveItem->incidence()->isReadOnly() ) { 707 if (!moveItem->incidence()->isReadOnly() ) {
524 if (!mActionItem) 708 if (!mActionItem)
525 setNoActionCursor(moveItem,viewportPos); 709 setNoActionCursor(moveItem,viewportPos);
526 else { 710 else {
527 if ( !blockMoving ) 711 if ( !blockMoving )
528 performItemAction(viewportPos); 712 performItemAction(viewportPos);
529 } 713 }
530 } 714 }
531 } else { // ---------- viewport() 715 } else { // ---------- viewport()
532 if ( mActionType == SELECT ) { 716 if ( mActionType == SELECT ) {
533 performSelectAction( viewportPos ); 717 performSelectAction( viewportPos );
534 } 718 }
535 } 719 }
536 break; 720 break;
537 721
538 case QEvent::MouseButtonDblClick: 722 case QEvent::MouseButtonDblClick:
539 blockMoving = false; 723 blockMoving = false;
540 leftMouseDown = false; 724 leftMouseDown = false;
541 if (object == viewport()) { 725 if (object == viewport()) {
542 selectItem(0); 726 selectItem(0);
543 int x,y; 727 int x,y;
544 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 728 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
545 int gx,gy; 729 int gx,gy;
546 contentsToGrid(x,y,gx,gy); 730 contentsToGrid(x,y,gx,gy);
547 emit newEventSignal(gx,gy); 731 emit newEventSignal(gx,gy);
548 } else { 732 } else {
549 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 733 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
550 selectItem(doubleClickedItem); 734 selectItem(doubleClickedItem);
551 if ( KOPrefs::instance()->mEditOnDoubleClick ) 735 if ( KOPrefs::instance()->mEditOnDoubleClick )
552 emit editIncidenceSignal(doubleClickedItem->incidence()); 736 emit editIncidenceSignal(doubleClickedItem->incidence());
553 else 737 else
554 emit showIncidenceSignal(doubleClickedItem->incidence()); 738 emit showIncidenceSignal(doubleClickedItem->incidence());
555 } 739 }
556 break; 740 break;
557 741
558 default: 742 default:
559 break; 743 break;
560 } 744 }
561 return true; 745 return true;
746#endif
562} 747}
563 748
564void KOAgenda::newItem( int item ) 749void KOAgenda::newItem( int item )
565{ 750{
566 if ( item == 1 ) { //new event 751 if ( item == 1 ) { //new event
567 newEventSignal(mStartCellX ,mStartCellY ); 752 newEventSignal(mStartCellX ,mStartCellY );
568 } else 753 } else
569 if ( item == 2 ) { //new event 754 if ( item == 2 ) { //new event
570 newTodoSignal(mStartCellX ,mStartCellY ); 755 newTodoSignal(mStartCellX ,mStartCellY );
571 } else 756 } else
572 { 757 {
573 QDate day = mSelectedDates[mStartCellX]; 758 QDate day = mSelectedDates[mStartCellX];
574 emit showDateView( item, day ); 759 emit showDateView( item, day );
575 // 3Day view 760 // 3Day view
576 // 4Week view 761 // 4Week view
577 // 5Month view 762 // 5Month view
578 // 6Journal view 763 // 6Journal view
579 } 764 }
580} 765}
581void KOAgenda::startSelectAction(QPoint viewportPos) 766void KOAgenda::startSelectAction(QPoint viewportPos)
582{ 767{
583 //emit newStartSelectSignal(); 768 //emit newStartSelectSignal();
584 769
585 mActionType = SELECT; 770 mActionType = SELECT;
586 771
587 int x,y; 772 int x,y;
588 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 773 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
589 int gx,gy; 774 int gx,gy;
590 contentsToGrid(x,y,gx,gy); 775 contentsToGrid(x,y,gx,gy);
591 776
592 mStartCellX = gx; 777 mStartCellX = gx;
593 mStartCellY = gy; 778 mStartCellY = gy;
594 mCurrentCellX = gx; 779 mCurrentCellX = gx;
595 mCurrentCellY = gy; 780 mCurrentCellY = gy;
596 781
597 // Store coordinates of old selection 782 // Store coordinates of old selection
598 int selectionX = mSelectionCellX * mGridSpacingX; 783 int selectionX = mSelectionCellX * mGridSpacingX;
599 int selectionYTop = mSelectionYTop; 784 int selectionYTop = mSelectionYTop;
600 int selectionHeight = mSelectionHeight; 785 int selectionHeight = mSelectionHeight;
601 786
602 // Store new selection 787 // Store new selection
603 mSelectionCellX = gx; 788 mSelectionCellX = gx;
604 mSelectionYTop = gy * mGridSpacingY; 789 mSelectionYTop = gy * mGridSpacingY;
605 mSelectionHeight = mGridSpacingY; 790 mSelectionHeight = mGridSpacingY;
606 791
607 // Clear old selection 792 // Clear old selection
608 repaintContents( selectionX, selectionYTop, 793 repaintContents( selectionX, selectionYTop,
609 mGridSpacingX, selectionHeight,false ); 794 mGridSpacingX, selectionHeight,false );
610 795
611 // Paint new selection 796 // Paint new selection
612 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 797 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
613 // mGridSpacingX, mSelectionHeight ); 798 // mGridSpacingX, mSelectionHeight );
614} 799}
615 800
616void KOAgenda::performSelectAction(QPoint viewportPos) 801void KOAgenda::performSelectAction(QPoint viewportPos)
617{ 802{
618 int x,y; 803 int x,y;
619 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 804 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
620 int gx,gy; 805 int gx,gy;
621 contentsToGrid(x,y,gx,gy); 806 contentsToGrid(x,y,gx,gy);
622 807
623 QPoint clipperPos = clipper()-> 808 QPoint clipperPos = clipper()->
624 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 809 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
625 810
626 // Scroll if cursor was moved to upper or lower end of agenda. 811 // Scroll if cursor was moved to upper or lower end of agenda.
627 if (clipperPos.y() < mScrollBorderWidth) { 812 if (clipperPos.y() < mScrollBorderWidth) {
628 mScrollUpTimer.start(mScrollDelay); 813 mScrollUpTimer.start(mScrollDelay);
629 } else if (visibleHeight() - clipperPos.y() < 814 } else if (visibleHeight() - clipperPos.y() <
630 mScrollBorderWidth) { 815 mScrollBorderWidth) {
631 mScrollDownTimer.start(mScrollDelay); 816 mScrollDownTimer.start(mScrollDelay);
632 } else { 817 } else {
633 mScrollUpTimer.stop(); 818 mScrollUpTimer.stop();
634 mScrollDownTimer.stop(); 819 mScrollDownTimer.stop();
635 } 820 }
636 821
637 if ( gy > mCurrentCellY ) { 822 if ( gy > mCurrentCellY ) {
638 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 823 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
639 824
640#if 0 825#if 0
641 // FIXME: Repaint only the newly selected region 826 // FIXME: Repaint only the newly selected region
642 repaintContents( mSelectionCellX * mGridSpacingX, 827 repaintContents( mSelectionCellX * mGridSpacingX,
643 mCurrentCellY + mGridSpacingY, 828 mCurrentCellY + mGridSpacingY,
644 mGridSpacingX, 829 mGridSpacingX,
645 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 830 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
646#else 831#else
647 repaintContents( (KOGlobals::self()->reverseLayout() ? 832 repaintContents( (KOGlobals::self()->reverseLayout() ?
648 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 833 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
649 mGridSpacingX, mSelectionYTop, 834 mGridSpacingX, mSelectionYTop,
650 mGridSpacingX, mSelectionHeight , false); 835 mGridSpacingX, mSelectionHeight , false);
651#endif 836#endif
652 837
653 mCurrentCellY = gy; 838 mCurrentCellY = gy;
654 } else if ( gy < mCurrentCellY ) { 839 } else if ( gy < mCurrentCellY ) {
655 if ( gy >= mStartCellY ) { 840 if ( gy >= mStartCellY ) {
656 int selectionHeight = mSelectionHeight; 841 int selectionHeight = mSelectionHeight;
657 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 842 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
658 843
659 repaintContents( (KOGlobals::self()->reverseLayout() ? 844 repaintContents( (KOGlobals::self()->reverseLayout() ?
660 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 845 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
661 mGridSpacingX, mSelectionYTop, 846 mGridSpacingX, mSelectionYTop,
662 mGridSpacingX, selectionHeight,false ); 847 mGridSpacingX, selectionHeight,false );
663 848
664 mCurrentCellY = gy; 849 mCurrentCellY = gy;
665 } else { 850 } else {
666 } 851 }
667 } 852 }
668} 853}
669 854
670void KOAgenda::endSelectAction( bool emitNewEvent ) 855void KOAgenda::endSelectAction( bool emitNewEvent )
671{ 856{
672 mActionType = NOP; 857 mActionType = NOP;
673 mScrollUpTimer.stop(); 858 mScrollUpTimer.stop();
674 mScrollDownTimer.stop(); 859 mScrollDownTimer.stop();
675 860
676 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 861 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
677 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 862 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
678 qDebug("ew event signal "); 863 qDebug("ew event signal ");
679 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 864 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
680 } 865 }
681} 866}
682 867
683void KOAgenda::startItemAction(QPoint viewportPos) 868void KOAgenda::startItemAction(QPoint viewportPos)
684{ 869{
685 int x,y; 870 int x,y;
686 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 871 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
687 int gx,gy; 872 int gx,gy;
688 contentsToGrid(x,y,gx,gy); 873 contentsToGrid(x,y,gx,gy);
689 874
690 mStartCellX = gx; 875 mStartCellX = gx;
691 mStartCellY = gy; 876 mStartCellY = gy;
692 mCurrentCellX = gx; 877 mCurrentCellX = gx;
693 mCurrentCellY = gy; 878 mCurrentCellY = gy;
694 879
695 if (mAllDayMode) { 880 if (mAllDayMode) {
696 int gridDistanceX = (x - gx * mGridSpacingX); 881 int gridDistanceX = (x - gx * mGridSpacingX);
697 if (gridDistanceX < mResizeBorderWidth && 882 if (gridDistanceX < mResizeBorderWidth &&
698 mActionItem->cellX() == mCurrentCellX) { 883 mActionItem->cellX() == mCurrentCellX) {
699 mActionType = RESIZELEFT; 884 mActionType = RESIZELEFT;
700 setCursor(sizeHorCursor); 885 setCursor(sizeHorCursor);
701 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 886 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
702 mActionItem->cellXWidth() == mCurrentCellX) { 887 mActionItem->cellXWidth() == mCurrentCellX) {
703 mActionType = RESIZERIGHT; 888 mActionType = RESIZERIGHT;
704 setCursor(sizeHorCursor); 889 setCursor(sizeHorCursor);
705 } else { 890 } else {
706 mActionType = MOVE; 891 mActionType = MOVE;
707 mActionItem->startMove(); 892 mActionItem->startMove();
708 setCursor(sizeAllCursor); 893 setCursor(sizeAllCursor);
709 } 894 }
710 } else { 895 } else {
711 int gridDistanceY = (y - gy * mGridSpacingY); 896 int gridDistanceY = (y - gy * mGridSpacingY);
712 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 897 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
713 if (allowResize && gridDistanceY < mResizeBorderWidth && 898 if (allowResize && gridDistanceY < mResizeBorderWidth &&
714 mActionItem->cellYTop() == mCurrentCellY && 899 mActionItem->cellYTop() == mCurrentCellY &&
715 !mActionItem->firstMultiItem()) { 900 !mActionItem->firstMultiItem()) {
716 mActionType = RESIZETOP; 901 mActionType = RESIZETOP;
717 setCursor(sizeVerCursor); 902 setCursor(sizeVerCursor);
718 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 903 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
719 mActionItem->cellYBottom() == mCurrentCellY && 904 mActionItem->cellYBottom() == mCurrentCellY &&
720 !mActionItem->lastMultiItem()) { 905 !mActionItem->lastMultiItem()) {
721 mActionType = RESIZEBOTTOM; 906 mActionType = RESIZEBOTTOM;
722 setCursor(sizeVerCursor); 907 setCursor(sizeVerCursor);
723 } else { 908 } else {
724 mActionType = MOVE; 909 mActionType = MOVE;
725 mActionItem->startMove(); 910 mActionItem->startMove();
726 setCursor(sizeAllCursor); 911 setCursor(sizeAllCursor);
727 } 912 }
728 } 913 }
729} 914}
730 915
731void KOAgenda::performItemAction(QPoint viewportPos) 916void KOAgenda::performItemAction(QPoint viewportPos)
732{ 917{
733// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 918// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
734// QPoint point = viewport()->mapToGlobal(viewportPos); 919// QPoint point = viewport()->mapToGlobal(viewportPos);
735// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 920// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
736// point = clipper()->mapFromGlobal(point); 921// point = clipper()->mapFromGlobal(point);
737// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 922// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
738// kdDebug() << "visible height: " << visibleHeight() << endl; 923// kdDebug() << "visible height: " << visibleHeight() << endl;
739 int x,y; 924 int x,y;
740 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 925 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
741// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 926// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
742 int gx,gy; 927 int gx,gy;
743 contentsToGrid(x,y,gx,gy); 928 contentsToGrid(x,y,gx,gy);
744 QPoint clipperPos = clipper()-> 929 QPoint clipperPos = clipper()->
745 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 930 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
746 931
747 // Cursor left active agenda area. 932 // Cursor left active agenda area.
748 // This starts a drag. 933 // This starts a drag.
749 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 934 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
750 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 935 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
751 if ( mActionType == MOVE ) { 936 if ( mActionType == MOVE ) {
752 mScrollUpTimer.stop(); 937 mScrollUpTimer.stop();
753 mScrollDownTimer.stop(); 938 mScrollDownTimer.stop();
754 mActionItem->resetMove(); 939 mActionItem->resetMove();
755 placeSubCells( mActionItem ); 940 placeSubCells( mActionItem );
756 // emit startDragSignal( mActionItem->incidence() ); 941 // emit startDragSignal( mActionItem->incidence() );
757 setCursor( arrowCursor ); 942 setCursor( arrowCursor );
758 mActionItem = 0; 943 mActionItem = 0;
759 mActionType = NOP; 944 mActionType = NOP;
760 mItemMoved = 0; 945 mItemMoved = 0;
761 return; 946 return;
762 } 947 }
763 } else { 948 } else {
764 switch ( mActionType ) { 949 switch ( mActionType ) {
765 case MOVE: 950 case MOVE:
766 setCursor( sizeAllCursor ); 951 setCursor( sizeAllCursor );
767 break; 952 break;
768 case RESIZETOP: 953 case RESIZETOP:
769 case RESIZEBOTTOM: 954 case RESIZEBOTTOM:
770 setCursor( sizeVerCursor ); 955 setCursor( sizeVerCursor );
771 break; 956 break;
772 case RESIZELEFT: 957 case RESIZELEFT:
773 case RESIZERIGHT: 958 case RESIZERIGHT:
774 setCursor( sizeHorCursor ); 959 setCursor( sizeHorCursor );
775 break; 960 break;
776 default: 961 default:
777 setCursor( arrowCursor ); 962 setCursor( arrowCursor );
778 } 963 }
779 } 964 }
780 965
781 // Scroll if item was moved to upper or lower end of agenda. 966 // Scroll if item was moved to upper or lower end of agenda.
782 if (clipperPos.y() < mScrollBorderWidth) { 967 if (clipperPos.y() < mScrollBorderWidth) {
783 mScrollUpTimer.start(mScrollDelay); 968 mScrollUpTimer.start(mScrollDelay);
784 } else if (visibleHeight() - clipperPos.y() < 969 } else if (visibleHeight() - clipperPos.y() <
785 mScrollBorderWidth) { 970 mScrollBorderWidth) {
786 mScrollDownTimer.start(mScrollDelay); 971 mScrollDownTimer.start(mScrollDelay);
787 } else { 972 } else {
788 mScrollUpTimer.stop(); 973 mScrollUpTimer.stop();
789 mScrollDownTimer.stop(); 974 mScrollDownTimer.stop();
790 } 975 }
791 976
792 // Move or resize item if necessary 977 // Move or resize item if necessary
793 if (mCurrentCellX != gx || mCurrentCellY != gy) { 978 if (mCurrentCellX != gx || mCurrentCellY != gy) {
794 mItemMoved = true; 979 mItemMoved = true;
795 mActionItem->raise(); 980 mActionItem->raise();
796 if (mActionType == MOVE) { 981 if (mActionType == MOVE) {
797 // Move all items belonging to a multi item 982 // Move all items belonging to a multi item
798 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 983 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
799 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 984 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
800 if (!moveItem) moveItem = mActionItem; 985 if (!moveItem) moveItem = mActionItem;
801 while (moveItem) { 986 while (moveItem) {
802 int dy; 987 int dy;
803 if (isMultiItem) dy = 0; 988 if (isMultiItem) dy = 0;
804 else dy = gy - mCurrentCellY; 989 else dy = gy - mCurrentCellY;
805 moveItem->moveRelative(gx - mCurrentCellX,dy); 990 moveItem->moveRelative(gx - mCurrentCellX,dy);
806 int x,y; 991 int x,y;
807 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 992 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
808 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 993 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
809 mGridSpacingY * moveItem->cellHeight()); 994 mGridSpacingY * moveItem->cellHeight());
810 moveChild(moveItem,x,y); 995 moveChild(moveItem,x,y);
811 moveItem = moveItem->nextMultiItem(); 996 moveItem = moveItem->nextMultiItem();
812 } 997 }
813 } else if (mActionType == RESIZETOP) { 998 } else if (mActionType == RESIZETOP) {
814 if (mCurrentCellY <= mActionItem->cellYBottom()) { 999 if (mCurrentCellY <= mActionItem->cellYBottom()) {
815 mActionItem->expandTop(gy - mCurrentCellY); 1000 mActionItem->expandTop(gy - mCurrentCellY);
816 mActionItem->resize(mActionItem->width(), 1001 mActionItem->resize(mActionItem->width(),
817 mGridSpacingY * mActionItem->cellHeight()); 1002 mGridSpacingY * mActionItem->cellHeight());
818 int x,y; 1003 int x,y;
819 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 1004 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
820 //moveChild(mActionItem,childX(mActionItem),y); 1005 //moveChild(mActionItem,childX(mActionItem),y);
821 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 1006 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
822 } 1007 }
823 } else if (mActionType == RESIZEBOTTOM) { 1008 } else if (mActionType == RESIZEBOTTOM) {
824 if (mCurrentCellY >= mActionItem->cellYTop()) { 1009 if (mCurrentCellY >= mActionItem->cellYTop()) {
825 mActionItem->expandBottom(gy - mCurrentCellY); 1010 mActionItem->expandBottom(gy - mCurrentCellY);
826 mActionItem->resize(mActionItem->width(), 1011 mActionItem->resize(mActionItem->width(),
827 mGridSpacingY * mActionItem->cellHeight()); 1012 mGridSpacingY * mActionItem->cellHeight());
828 } 1013 }
829 } else if (mActionType == RESIZELEFT) { 1014 } else if (mActionType == RESIZELEFT) {
830 if (mCurrentCellX <= mActionItem->cellXWidth()) { 1015 if (mCurrentCellX <= mActionItem->cellXWidth()) {
831 mActionItem->expandLeft(gx - mCurrentCellX); 1016 mActionItem->expandLeft(gx - mCurrentCellX);
832 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 1017 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
833 mActionItem->height()); 1018 mActionItem->height());
834 int x,y; 1019 int x,y;
835 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 1020 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
836 moveChild(mActionItem,x,childY(mActionItem)); 1021 moveChild(mActionItem,x,childY(mActionItem));
837 } 1022 }
838 } else if (mActionType == RESIZERIGHT) { 1023 } else if (mActionType == RESIZERIGHT) {
839 if (mCurrentCellX >= mActionItem->cellX()) { 1024 if (mCurrentCellX >= mActionItem->cellX()) {
840 mActionItem->expandRight(gx - mCurrentCellX); 1025 mActionItem->expandRight(gx - mCurrentCellX);
841 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 1026 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
842 mActionItem->height()); 1027 mActionItem->height());
843 } 1028 }
844 } 1029 }
845 mCurrentCellX = gx; 1030 mCurrentCellX = gx;
846 mCurrentCellY = gy; 1031 mCurrentCellY = gy;
847 } 1032 }
848} 1033}
849 1034
850void KOAgenda::endItemAction() 1035void KOAgenda::endItemAction()
851{ 1036{
852 1037
853 if ( mItemMoved ) { 1038 if ( mItemMoved ) {
854 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 1039 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
855 if ( !placeItem ) { 1040 if ( !placeItem ) {
856 placeItem = mActionItem; 1041 placeItem = mActionItem;
857 } 1042 }
858 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 1043 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
859 Incidence* oldInc = placeItem->incidence(); 1044 Incidence* oldInc = placeItem->incidence();
860 placeItem->recreateIncidence(); 1045 placeItem->recreateIncidence();
861 emit addToCalSignal(placeItem->incidence(), oldInc ); 1046 emit addToCalSignal(placeItem->incidence(), oldInc );
862 } 1047 }
863 int type = mActionType; 1048 int type = mActionType;
864 if ( mAllDayMode ) 1049 if ( mAllDayMode )
865 type = -1; 1050 type = -1;
866 KOAgendaItem *modifiedItem = placeItem; 1051 KOAgendaItem *modifiedItem = placeItem;
867 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1052 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
868 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1053 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
869 KOAgendaItem *item; 1054 KOAgendaItem *item;
870 1055
871 if ( placeItem->incidence()->type() == "Todo" ) { 1056 if ( placeItem->incidence()->type() == "Todo" ) {
872 mSelectedItem = 0; 1057 mSelectedItem = 0;
873 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1058 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
874 modifiedItem->mLastMoveXPos = mCurrentCellX; 1059 modifiedItem->mLastMoveXPos = mCurrentCellX;
875 emit itemModified( modifiedItem, mActionType ); 1060 emit itemModified( modifiedItem, mActionType );
876 } 1061 }
877 else { 1062 else {
878#if 0 1063#if 0
879 for ( item=oldconflictItems.first(); item != 0; 1064 for ( item=oldconflictItems.first(); item != 0;
880 item=oldconflictItems.next() ) { 1065 item=oldconflictItems.next() ) {
881 placeSubCells(item); 1066 placeSubCells(item);
882 } 1067 }
883 while ( placeItem ) { 1068 while ( placeItem ) {
884 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1069 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
885 placeSubCells( placeItem ); 1070 placeSubCells( placeItem );
886 placeItem = placeItem->nextMultiItem(); 1071 placeItem = placeItem->nextMultiItem();
887 } 1072 }
888#endif 1073#endif
889 1074
890 globalFlagBlockAgendaItemPaint = 1; 1075 globalFlagBlockAgendaItemPaint = 1;
891 for ( item=oldconflictItems.first(); item != 0; 1076 for ( item=oldconflictItems.first(); item != 0;
892 item=oldconflictItems.next() ) { 1077 item=oldconflictItems.next() ) {
893 placeSubCells(item); 1078 placeSubCells(item);
894 } 1079 }
895 while ( placeItem ) { 1080 while ( placeItem ) {
896 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1081 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
897 oldconflictItems = placeItem->conflictItems(); 1082 oldconflictItems = placeItem->conflictItems();
898 for ( item=oldconflictItems.first(); item != 0; 1083 for ( item=oldconflictItems.first(); item != 0;
899 item=oldconflictItems.next() ) { 1084 item=oldconflictItems.next() ) {
900 placeSubCells(item); 1085 placeSubCells(item);
901 } 1086 }
902 placeSubCells( placeItem ); 1087 placeSubCells( placeItem );
903 placeItem = placeItem->nextMultiItem(); 1088 placeItem = placeItem->nextMultiItem();
904 } 1089 }
905 globalFlagBlockAgendaItemPaint = 0; 1090 globalFlagBlockAgendaItemPaint = 0;
906 for ( item=oldconflictItems.first(); item != 0; 1091 for ( item=oldconflictItems.first(); item != 0;
907 item=oldconflictItems.next() ) { 1092 item=oldconflictItems.next() ) {
908 globalFlagBlockAgendaItemUpdate = 0; 1093 globalFlagBlockAgendaItemUpdate = 0;
909 item->repaintMe(); 1094 item->repaintMe();
910 globalFlagBlockAgendaItemUpdate = 1; 1095 globalFlagBlockAgendaItemUpdate = 1;
911 item->repaint( false ); 1096 item->repaint( false );
912 } 1097 }
913 placeItem = modifiedItem; 1098 placeItem = modifiedItem;
914 1099
915 while ( placeItem ) { 1100 while ( placeItem ) {
916 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1101 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
917 globalFlagBlockAgendaItemUpdate = 0; 1102 globalFlagBlockAgendaItemUpdate = 0;
918 placeItem->repaintMe(); 1103 placeItem->repaintMe();
919 globalFlagBlockAgendaItemUpdate = 1; 1104 globalFlagBlockAgendaItemUpdate = 1;
920 placeItem->repaint(false); 1105 placeItem->repaint(false);
921 placeItem = placeItem->nextMultiItem(); 1106 placeItem = placeItem->nextMultiItem();
922 } 1107 }
923 emit itemModified( modifiedItem, mActionType ); 1108 emit itemModified( modifiedItem, mActionType );
924 1109
925 1110
926 placeItem = modifiedItem; 1111 placeItem = modifiedItem;
927 while ( placeItem ) { 1112 while ( placeItem ) {
928 oldconflictItems = placeItem->conflictItems(); 1113 oldconflictItems = placeItem->conflictItems();
929 for ( item=oldconflictItems.first(); item != 0; 1114 for ( item=oldconflictItems.first(); item != 0;
930 item=oldconflictItems.next() ) { 1115 item=oldconflictItems.next() ) {
931 placeSubCells(item); 1116 placeSubCells(item);
932 } 1117 }
933 placeSubCells( placeItem ); 1118 placeSubCells( placeItem );
934 placeItem = placeItem->nextMultiItem(); 1119 placeItem = placeItem->nextMultiItem();
935 1120
936 } 1121 }
937 placeItem = modifiedItem; 1122 placeItem = modifiedItem;
938 while ( placeItem ) { 1123 while ( placeItem ) {
939 oldconflictItems = placeItem->conflictItems(); 1124 oldconflictItems = placeItem->conflictItems();
940 for ( item=oldconflictItems.first(); item != 0; 1125 for ( item=oldconflictItems.first(); item != 0;
941 item=oldconflictItems.next() ) { 1126 item=oldconflictItems.next() ) {
942 globalFlagBlockAgendaItemUpdate = 0; 1127 globalFlagBlockAgendaItemUpdate = 0;
943 item->repaintMe(); 1128 item->repaintMe();
944 globalFlagBlockAgendaItemUpdate = 1; 1129 globalFlagBlockAgendaItemUpdate = 1;
945 item->repaint(false); 1130 item->repaint(false);
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index f3f1772..3d33ae5 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,290 +1,296 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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 KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34 34
35class QPopupMenu; 35class QPopupMenu;
36class QTime; 36class QTime;
37class KConfig; 37class KConfig;
38class QFrame; 38class QFrame;
39class KOAgenda; 39class KOAgenda;
40class KCal::Event; 40class KCal::Event;
41class KCal::Todo; 41class KCal::Todo;
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45class MarcusBains : public QFrame { 45class MarcusBains : public QFrame {
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 MarcusBains(KOAgenda *agenda=0,const char *name=0); 48 MarcusBains(KOAgenda *agenda=0,const char *name=0);
49 virtual ~MarcusBains(); 49 virtual ~MarcusBains();
50 50
51 public slots: 51 public slots:
52 void updateLocation(bool recalculate=false); 52 void updateLocation(bool recalculate=false);
53 void updateLoc(); 53 void updateLoc();
54 54
55 private: 55 private:
56 int todayColumn(); 56 int todayColumn();
57 QTimer *minutes; 57 QTimer *minutes;
58 QLabel *mTimeBox; 58 QLabel *mTimeBox;
59 KOAgenda *agenda; 59 KOAgenda *agenda;
60 QTime oldTime; 60 QTime oldTime;
61 int oldToday; 61 int oldToday;
62}; 62};
63 63
64 64
65class KOAgenda : public QScrollView 65class KOAgenda : public QScrollView
66{ 66{
67 Q_OBJECT 67 Q_OBJECT
68 public: 68 public:
69 enum MouseActionType { NOP, MOVE, SELECT, 69 enum MouseActionType { NOP, MOVE, SELECT,
70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
71 71
72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
73 const char * name=0, WFlags f=0 ); 73 const char * name=0, WFlags f=0 );
74 KOAgenda ( int columns, QWidget * parent=0, 74 KOAgenda ( int columns, QWidget * parent=0,
75 const char * name=0, WFlags f=0 ); 75 const char * name=0, WFlags f=0 );
76 virtual ~KOAgenda(); 76 virtual ~KOAgenda();
77 77
78 Incidence *selectedIncidence() const; 78 Incidence *selectedIncidence() const;
79 QDate selectedIncidenceDate() const; 79 QDate selectedIncidenceDate() const;
80 80
81 virtual bool eventFilter ( QObject *, QEvent * ); 81 virtual bool eventFilter ( QObject *, QEvent * );
82 82
83 void contentsToGrid (int x, int y, int& gx, int& gy); 83 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y); 84 void gridToContents (int gx, int gy, int& x, int& y);
85 85
86 int timeToY (const QTime &time); 86 int timeToY (const QTime &time);
87 QTime gyToTime (int y); 87 QTime gyToTime (int y);
88 88
89 void setStartHour(int startHour); 89 void setStartHour(int startHour);
90 90
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom); 94 int YTop,int YBottom);
95 95
96 void changeColumns(int columns); 96 void changeColumns(int columns);
97 97
98 int columns() { return mColumns; } 98 int columns() { return mColumns; }
99 int rows() { return mRows; } 99 int rows() { return mRows; }
100 100
101 int gridSpacingX() const { return mGridSpacingX; } 101 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; } 102 int gridSpacingY() const { return mGridSpacingY; }
103 103
104// virtual QSizePolicy sizePolicy() const; 104// virtual QSizePolicy sizePolicy() const;
105 105
106 void clear(); 106 void clear();
107 107
108 void clearSelection(); 108 void clearSelection();
109 void hideUnused(); 109 void hideUnused();
110 110
111 /** Calculates the minimum width */ 111 /** Calculates the minimum width */
112 virtual int minimumWidth() const; 112 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */ 113 /** Update configuration from preference settings */
114 void updateConfig(); 114 void updateConfig();
115 115
116 void checkScrollBoundaries(); 116 void checkScrollBoundaries();
117 117
118 void setHolidayMask(QMemArray<bool> *); 118 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates); 119 void setDateList(const DateList &selectedDates);
120 DateList dateList() const; 120 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate(); 122 void finishUpdate();
123 void printSelection(); 123 void printSelection();
124 void storePosition(); 124 void storePosition();
125 void restorePosition(); 125 void restorePosition();
126 126
127 127
128 public slots: 128 public slots:
129 void popupMenu();
129 void newItem( int ); 130 void newItem( int );
130 void moveChild( QWidget *, int, int ); 131 void moveChild( QWidget *, int, int );
131 void scrollUp(); 132 void scrollUp();
132 void scrollDown(); 133 void scrollDown();
133 void updateTodo( Todo * t, int , bool ); 134 void updateTodo( Todo * t, int , bool );
134 void popupAlarm(); 135 void popupAlarm();
135 136
136 void checkScrollBoundaries(int); 137 void checkScrollBoundaries(int);
137 138
138 /** Deselect selected items. This function does not emit any signals. */ 139 /** Deselect selected items. This function does not emit any signals. */
139 void deselectItem(); 140 void deselectItem();
140 /** Select item. If the argument is 0, the currently selected item gets 141 /** Select item. If the argument is 0, the currently selected item gets
141 deselected. This function emits the itemSelected(bool) signal to inform 142 deselected. This function emits the itemSelected(bool) signal to inform
142 about selection/deseelction of events. */ 143 about selection/deseelction of events. */
143 void selectItem(KOAgendaItem *); 144 void selectItem(KOAgendaItem *);
144 void finishResize(); 145 void finishResize();
145 146
146 signals: 147 signals:
147 void showDateView( int, QDate ); 148 void showDateView( int, QDate );
148 void newEventSignal(); 149 void newEventSignal();
149 void newEventSignal(int gx,int gy); 150 void newEventSignal(int gx,int gy);
150 void newTodoSignal(int gx,int gy); 151 void newTodoSignal(int gx,int gy);
151 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 152 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
152 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 153 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
153 void newStartSelectSignal(); 154 void newStartSelectSignal();
154 void showIncidenceSignal(Incidence *); 155 void showIncidenceSignal(Incidence *);
155 void editIncidenceSignal(Incidence *); 156 void editIncidenceSignal(Incidence *);
156 void deleteIncidenceSignal(Incidence *); 157 void deleteIncidenceSignal(Incidence *);
157 void showIncidencePopupSignal(Incidence *); 158 void showIncidencePopupSignal(Incidence *);
158 159
159 void itemModified(KOAgendaItem *item, int ); 160 void itemModified(KOAgendaItem *item, int );
160 void incidenceSelected(Incidence *); 161 void incidenceSelected(Incidence *);
161 162
162 void lowerYChanged(int); 163 void lowerYChanged(int);
163 void upperYChanged(int); 164 void upperYChanged(int);
164 165
165 void startDragSignal(Incidence *); 166 void startDragSignal(Incidence *);
166 void addToCalSignal(Incidence *, Incidence *); 167 void addToCalSignal(Incidence *, Incidence *);
167 void resizedSignal(); 168 void resizedSignal();
168 169
169 protected: 170 protected:
170 QPainter mPixPainter; 171 QPainter mPixPainter;
171 QPixmap mPaintPixmap; 172 QPixmap mPaintPixmap;
172 QPixmap mHighlightPixmap; 173 QPixmap mHighlightPixmap;
173 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 174 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
174 virtual void resizeEvent ( QResizeEvent * ); 175 virtual void resizeEvent ( QResizeEvent * );
175 176
176 /** Handles mouse events. Called from eventFilter */ 177 /** Handles mouse events. Called from eventFilter */
177 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 178 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
178 179
179 /** Start selecting time span. */ 180 /** Start selecting time span. */
180 void startSelectAction(QPoint viewportPos); 181 void startSelectAction(QPoint viewportPos);
181 182
182 /** Select time span. */ 183 /** Select time span. */
183 void performSelectAction(QPoint viewportPos); 184 void performSelectAction(QPoint viewportPos);
184 185
185 /** Emd selecting time span. */ 186 /** Emd selecting time span. */
186 void endSelectAction( bool emitNewEvent = false ); 187 void endSelectAction( bool emitNewEvent = false );
187 188
188 /** Start moving/resizing agenda item */ 189 /** Start moving/resizing agenda item */
189 void startItemAction(QPoint viewportPos); 190 void startItemAction(QPoint viewportPos);
190 191
191 /** Move/resize agenda item */ 192 /** Move/resize agenda item */
192 void performItemAction(QPoint viewportPos); 193 void performItemAction(QPoint viewportPos);
193 194
194 /** End moving/resizing agenda item */ 195 /** End moving/resizing agenda item */
195 void endItemAction(); 196 void endItemAction();
196 197
197 /** Set cursor, when no item action is in progress */ 198 /** Set cursor, when no item action is in progress */
198 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 199 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
199 200
200 /** Place agenda item in agenda and adjust other cells if necessary */ 201 /** Place agenda item in agenda and adjust other cells if necessary */
201 void placeSubCells(KOAgendaItem *placeItem); 202 void placeSubCells(KOAgendaItem *placeItem);
202 203
203 /** Process the keyevent, including the ignored keyevents of eventwidgets. 204 /** Process the keyevent, including the ignored keyevents of eventwidgets.
204 * Implements pgup/pgdn and cursor key navigation in the view. 205 * Implements pgup/pgdn and cursor key navigation in the view.
205 */ 206 */
206 void keyPressEvent( QKeyEvent * ); 207 void keyPressEvent( QKeyEvent * );
207 208
208 void calculateWorkingHours(); 209 void calculateWorkingHours();
209 210
210 virtual void contentsMousePressEvent ( QMouseEvent * ); 211 virtual void contentsMousePressEvent ( QMouseEvent * );
211 212
212 private: 213 private:
213 void init(); 214 void init();
214 void marcus_bains(); 215 void marcus_bains();
215 bool mAllDayMode; 216 bool mAllDayMode;
216 bool blockResize; 217 bool blockResize;
218 bool mLeftMouseDown;
219 KOAgendaItem *mPopupItem;
220 QTimer* mPopupTimer;
221 int mPopupKind;
222 QPoint mPopupPos;
217 QTimer mResizeTimer; 223 QTimer mResizeTimer;
218 double mContentPosition; 224 double mContentPosition;
219 225
220 // Width and height of agenda cells 226 // Width and height of agenda cells
221 int mGridSpacingX; 227 int mGridSpacingX;
222 int mGridSpacingY; 228 int mGridSpacingY;
223 229
224 // size of border, where mouse action will resize the KOAgendaItem 230 // size of border, where mouse action will resize the KOAgendaItem
225 int mResizeBorderWidth; 231 int mResizeBorderWidth;
226 232
227 // size of border, where mouse mve will cause a scroll of the agenda 233 // size of border, where mouse mve will cause a scroll of the agenda
228 int mScrollBorderWidth; 234 int mScrollBorderWidth;
229 int mScrollDelay; 235 int mScrollDelay;
230 int mScrollOffset; 236 int mScrollOffset;
231 237
232 QTimer mScrollUpTimer; 238 QTimer mScrollUpTimer;
233 QTimer mScrollDownTimer; 239 QTimer mScrollDownTimer;
234 240
235 // Number of Columns/Rows of agenda grid 241 // Number of Columns/Rows of agenda grid
236 int mColumns; 242 int mColumns;
237 int mRows; 243 int mRows;
238 244
239 // Cells to store Move and Resize coordiantes 245 // Cells to store Move and Resize coordiantes
240 int mStartCellX; 246 int mStartCellX;
241 int mStartCellY; 247 int mStartCellY;
242 int mCurrentCellX; 248 int mCurrentCellX;
243 int mCurrentCellY; 249 int mCurrentCellY;
244 250
245 // Working Hour coordiantes 251 // Working Hour coordiantes
246 bool mWorkingHoursEnable; 252 bool mWorkingHoursEnable;
247 int mWorkingHoursYTop; 253 int mWorkingHoursYTop;
248 int mWorkingHoursYBottom; 254 int mWorkingHoursYBottom;
249 255
250 // Selection 256 // Selection
251 int mSelectionCellX; 257 int mSelectionCellX;
252 int mSelectionYTop; 258 int mSelectionYTop;
253 int mSelectionHeight; 259 int mSelectionHeight;
254 260
255 // List of dates to be displayed 261 // List of dates to be displayed
256 DateList mSelectedDates; 262 DateList mSelectedDates;
257 263
258 // The KOAgendaItem, which has been right-clicked last 264 // The KOAgendaItem, which has been right-clicked last
259 KOAgendaItem *mClickedItem; 265 KOAgendaItem *mClickedItem;
260 266
261 // The KOAgendaItem, which is being moved/resized 267 // The KOAgendaItem, which is being moved/resized
262 QGuardedPtr<KOAgendaItem> mActionItem; 268 QGuardedPtr<KOAgendaItem> mActionItem;
263 269
264 // Currently selected item 270 // Currently selected item
265 QGuardedPtr<KOAgendaItem> mSelectedItem; 271 QGuardedPtr<KOAgendaItem> mSelectedItem;
266 272
267 // The Marcus Bains Line widget. 273 // The Marcus Bains Line widget.
268 MarcusBains *mMarcusBains; 274 MarcusBains *mMarcusBains;
269 void computeSizes(); 275 void computeSizes();
270 276
271 MouseActionType mActionType; 277 MouseActionType mActionType;
272 278
273 bool mItemMoved; 279 bool mItemMoved;
274 280
275 // List of all Items contained in agenda 281 // List of all Items contained in agenda
276 QPtrList<KOAgendaItem> mItems; 282 QPtrList<KOAgendaItem> mItems;
277 QPtrList<KOAgendaItem> mUnusedItems; 283 QPtrList<KOAgendaItem> mUnusedItems;
278 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 284 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
279 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 285 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
280 QPopupMenu *mNewItemPopup; 286 QPopupMenu *mNewItemPopup;
281 287
282 int mOldLowerScrollValue; 288 int mOldLowerScrollValue;
283 int mOldUpperScrollValue; 289 int mOldUpperScrollValue;
284 KOAgendaItem * getItemForTodo ( Todo * todo ); 290 KOAgendaItem * getItemForTodo ( Todo * todo );
285 QMemArray<bool> *mHolidayMask; 291 QMemArray<bool> *mHolidayMask;
286 int mCurPixWid; 292 int mCurPixWid;
287 int mCurPixHei; 293 int mCurPixHei;
288}; 294};
289 295
290#endif // KOAGENDA_H 296#endif // KOAGENDA_H
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 905c1bf..b30ad75 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,462 +1,462 @@
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 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#define AGENDA_ICON_SIZE 7 38#define AGENDA_ICON_SIZE 7
39#endif 39#endif
40#include <libkcal/icaldrag.h> 40#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h> 41#include <libkcal/vcaldrag.h>
42#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
43extern int globalFlagBlockAgenda; 43extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint; 44extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate; 45extern int globalFlagBlockAgendaItemUpdate;
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koagendaitem.h" 49#include "koagendaitem.h"
50//#include "koagendaitem.moc" 50//#include "koagendaitem.moc"
51 51
52 52
53//-------------------------------------------------------------------------- 53//--------------------------------------------------------------------------
54 54
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 56
57//-------------------------------------------------------------------------- 57//--------------------------------------------------------------------------
58 58
59class KOAgendaItemWhatsThis :public QWhatsThis 59class KOAgendaItemWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& ) 65 virtual QString text( const QPoint& )
66 { 66 {
67 return _view->getWhatsThisText() ; 67 return _view->getWhatsThisText() ;
68 } 68 }
69private: 69private:
70 KOAgendaItem * _view; 70 KOAgendaItem * _view;
71}; 71};
72 72
73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
74 const char *name,WFlags) : 74 const char *name,WFlags) :
75 QWidget(parent, name), mIncidence(incidence), mDate(qd) 75 QWidget(parent, name), mIncidence(incidence), mDate(qd)
76{ 76{
77#ifndef DESKTOP_VERSION 77#ifndef DESKTOP_VERSION
78 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 78 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
79#endif 79#endif
80 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 80 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
82 setWFlags ( wflags); 82 setWFlags ( wflags);
83 mAllDay = allday; 83 mAllDay = allday;
84 init ( incidence, qd ); 84 init ( incidence, qd );
85 //setMouseTracking(true); 85 //setMouseTracking(true);
86 //setAcceptDrops(true); 86 //setAcceptDrops(true);
87 xPaintCoord = -1; 87 xPaintCoord = -1;
88 yPaintCoord = -1; 88 yPaintCoord = -1;
89} 89}
90QString KOAgendaItem::getWhatsThisText() 90QString KOAgendaItem::getWhatsThisText()
91{ 91{
92 if ( mIncidence ) 92 if ( mIncidence )
93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
94 KOPrefs::instance()->mWTshowDetails, 94 KOPrefs::instance()->mWTshowDetails,
95 KOPrefs::instance()->mWTshowCreated, 95 KOPrefs::instance()->mWTshowCreated,
96 KOPrefs::instance()->mWTshowChanged); 96 KOPrefs::instance()->mWTshowChanged);
97 return "KOAgendaItem::getWhatsThisText()::internal error"; 97 return "KOAgendaItem::getWhatsThisText()::internal error";
98} 98}
99void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 99void KOAgendaItem::init ( Incidence *incidence, QDate qd )
100{ 100{
101 mIncidence = incidence; 101 mIncidence = incidence;
102 mDate = qd; 102 mDate = qd;
103 mFirstMultiItem = 0; 103 mFirstMultiItem = 0;
104 mNextMultiItem = 0; 104 mNextMultiItem = 0;
105 mLastMultiItem = 0; 105 mLastMultiItem = 0;
106 computeText(); 106 computeText();
107 107
108 if ( (incidence->type() == "Todo") && 108 if ( (incidence->type() == "Todo") &&
109 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 109 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
113 else 113 else
114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
115 } 115 }
116 else { 116 else {
117 QStringList categories = mIncidence->categories(); 117 QStringList categories = mIncidence->categories();
118 QString cat = categories.first(); 118 QString cat = categories.first();
119 if (cat.isEmpty()) { 119 if (cat.isEmpty()) {
120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) )
121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
122 else 122 else
123 mBackgroundColor =KOPrefs::instance()->mEventColor; 123 mBackgroundColor =KOPrefs::instance()->mEventColor;
124 } else { 124 } else {
125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
129 } 129 }
130 } 130 }
131 131
132 } 132 }
133 mColorGroup = QColorGroup( mBackgroundColor.light(), 133 mColorGroup = QColorGroup( mBackgroundColor.light(),
134 mBackgroundColor.dark(),mBackgroundColor.light(), 134 mBackgroundColor.dark(),mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
137 137
138 mConflictItems.clear(); 138 mConflictItems.clear();
139 setCellXY(0,0,1); 139 setCellXY(0,0,1);
140 setCellXWidth(0); 140 setCellXWidth(0);
141 setSubCell(0); 141 setSubCell(0);
142 setSubCells(1); 142 setSubCells(1);
143 setMultiItem(0,0,0); 143 setMultiItem(0,0,0);
144 startMove(); 144 startMove();
145 mSelected = true; 145 mSelected = true;
146 select(false); 146 select(false);
147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
148 mFontPixelSize = fontinf.height();; 148 mFontPixelSize = fontinf.height();;
149 hide(); 149 hide();
150 xPaintCoord = -1; 150 xPaintCoord = -1;
151 yPaintCoord = -1; 151 yPaintCoord = -1;
152} 152}
153 153
154 154
155KOAgendaItem::~KOAgendaItem() 155KOAgendaItem::~KOAgendaItem()
156{ 156{
157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
158 // delete mKOAgendaItemWhatsThis; 158 // delete mKOAgendaItemWhatsThis;
159} 159}
160 160
161void KOAgendaItem::recreateIncidence() 161void KOAgendaItem::recreateIncidence()
162{ 162{
163#if 0 163#if 0
164 Incidence* newInc = mIncidence->clone(); 164 Incidence* newInc = mIncidence->clone();
165 newInc->recreate(); 165 newInc->recreate();
166 if ( mIncidence->doesRecur() ) { 166 if ( mIncidence->doesRecur() ) {
167 mIncidence->addExDate( mDate ); 167 mIncidence->addExDate( mDate );
168 newInc->recurrence()->unsetRecurs(); 168 newInc->recurrence()->unsetRecurs();
169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
170 QTime tim = mIncidence->dtStart().time(); 170 QTime tim = mIncidence->dtStart().time();
171 newInc->setDtStart( QDateTime(mDate, tim) ); 171 newInc->setDtStart( QDateTime(mDate, tim) );
172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
173 } 173 }
174#endif 174#endif
175 mIncidence = mIncidence->recreateCloneException( mDate ); 175 mIncidence = mIncidence->recreateCloneException( mDate );
176} 176}
177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
178{ 178{
179 int size = AGENDA_ICON_SIZE; 179 int size = AGENDA_ICON_SIZE;
180 180
181 int yOff = 0; 181 int yOff = 0;
182 int xOff = 0; 182 int xOff = 0;
183 int x = pos().x() +3; 183 int x = pos().x() +3;
184 int y; 184 int y;
185 if ( mAllDay ) 185 if ( mAllDay )
186 y = pos().y()+3; 186 y = pos().y()+3;
187 else 187 else
188 y = mCellYTop * ( height() / cellHeight() ) +3; 188 y = mCellYTop * ( height() / cellHeight() ) +3;
189 if (mIncidence->cancelled()) { 189 if (mIncidence->cancelled()) {
190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
194 if ( horLayout ) 194 if ( horLayout )
195 ++xOff; 195 ++xOff;
196 else 196 else
197 ++yOff; 197 ++yOff;
198 } 198 }
199 if (mIncidence->isAlarmEnabled()) { 199 if (mIncidence->isAlarmEnabled()) {
200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
201 if ( horLayout ) 201 if ( horLayout )
202 ++xOff; 202 ++xOff;
203 else 203 else
204 ++yOff; 204 ++yOff;
205 } 205 }
206 if (mIncidence->recurrence()->doesRecur()) { 206 if (mIncidence->recurrence()->doesRecur()) {
207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
208 if ( horLayout ) 208 if ( horLayout )
209 ++xOff; 209 ++xOff;
210 else 210 else
211 ++yOff; 211 ++yOff;
212 } 212 }
213 if (mIncidence->description().length() > 0) { 213 if (mIncidence->description().length() > 0) {
214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
215 if ( horLayout ) 215 if ( horLayout )
216 ++xOff; 216 ++xOff;
217 else 217 else
218 ++yOff; 218 ++yOff;
219 } 219 }
220 if (mIncidence->isReadOnly()) { 220 if (mIncidence->isReadOnly()) {
221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
222 if ( horLayout ) 222 if ( horLayout )
223 ++xOff; 223 ++xOff;
224 else 224 else
225 ++yOff; 225 ++yOff;
226 } 226 }
227 227
228 if (mIncidence->attendeeCount()>0) { 228 if (mIncidence->attendeeCount()>0) {
229 229
230 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 230 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
232 if ( horLayout ) 232 if ( horLayout )
233 ++xOff; 233 ++xOff;
234 else 234 else
235 ++yOff; 235 ++yOff;
236 } else { 236 } else {
237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
238 if (me!=0) { 238 if (me!=0) {
239 239
240 240
241 } else { 241 } else {
242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
243 if ( horLayout ) 243 if ( horLayout )
244 ++xOff; 244 ++xOff;
245 else 245 else
246 ++yOff; 246 ++yOff;
247 247
248 } 248 }
249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
250 if ( horLayout ) 250 if ( horLayout )
251 ++xOff; 251 ++xOff;
252 else 252 else
253 ++yOff; 253 ++yOff;
254 254
255 } 255 }
256 256
257 } 257 }
258 return ( yOff || xOff ); 258 return ( yOff || xOff );
259} 259}
260 260
261 261
262void KOAgendaItem::select(bool selected) 262void KOAgendaItem::select(bool selected)
263{ 263{
264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
265 if (mSelected == selected) return; 265 if (mSelected == selected) return;
266 mSelected = selected; 266 mSelected = selected;
267 if ( ! isVisible() ) 267 if ( ! isVisible() )
268 return; 268 return;
269 if ( firstMultiItem() ) 269 if ( firstMultiItem() )
270 firstMultiItem()->select( selected ); 270 firstMultiItem()->select( selected );
271 if ( !firstMultiItem() && nextMultiItem() ) { 271 if ( !firstMultiItem() && nextMultiItem() ) {
272 KOAgendaItem * placeItem = nextMultiItem(); 272 KOAgendaItem * placeItem = nextMultiItem();
273 while ( placeItem ) { 273 while ( placeItem ) {
274 placeItem->select( selected ); 274 placeItem->select( selected );
275 placeItem = placeItem->nextMultiItem(); 275 placeItem = placeItem->nextMultiItem();
276 } 276 }
277 } 277 }
278 globalFlagBlockAgendaItemUpdate = 0; 278 globalFlagBlockAgendaItemUpdate = 0;
279 paintMe( selected ); 279 paintMe( selected );
280 globalFlagBlockAgendaItemUpdate = 1; 280 globalFlagBlockAgendaItemUpdate = 1;
281 repaint( false ); 281 repaint( false );
282} 282}
283 283
284 284
285/* 285/*
286 The eventFilter has to filter the mouse events of the agenda item childs. The 286 The eventFilter has to filter the mouse events of the agenda item childs. The
287 events are fed into the event handling method of KOAgendaItem. This allows the 287 events are fed into the event handling method of KOAgendaItem. This allows the
288 KOAgenda to handle the KOAgendaItems by using an eventFilter. 288 KOAgenda to handle the KOAgendaItems by using an eventFilter.
289*/ 289*/
290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
291{ 291{
292 if (e->type() == QEvent::MouseButtonPress || 292 if (e->type() == QEvent::MouseButtonPress ||
293 e->type() == QEvent::MouseButtonDblClick || 293 e->type() == QEvent::MouseButtonDblClick ||
294 e->type() == QEvent::MouseButtonRelease || 294 e->type() == QEvent::MouseButtonRelease ||
295 e->type() == QEvent::MouseMove) { 295 e->type() == QEvent::MouseMove) {
296 QMouseEvent *me = (QMouseEvent *)e; 296 QMouseEvent *me = (QMouseEvent *)e;
297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
298 mapToGlobal(me->pos())); 298 mapToGlobal(me->pos()));
299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
300 return event(&returnEvent); 300 return event(&returnEvent);
301 } else { 301 } else {
302 return false; 302 return false;
303 } 303 }
304} 304}
305void KOAgendaItem::repaintMe( ) 305void KOAgendaItem::repaintMe( )
306{ 306{
307 paintMe ( mSelected ); 307 paintMe ( mSelected );
308} 308}
309void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 309void KOAgendaItem::paintMe( bool selected, QPainter* paint )
310{ 310{
311 if ( globalFlagBlockAgendaItemUpdate && ! selected) 311 if ( globalFlagBlockAgendaItemUpdate && ! selected)
312 return; 312 return;
313 QPainter pa; 313 QPainter pa;
314 314
315 if ( mSelected ) { 315 if ( mSelected ) {
316 pa.begin( paintPixSel() ); 316 pa.begin( paintPixSel() );
317 } else { 317 } else {
318 if ( mAllDay ) 318 if ( mAllDay )
319 pa.begin( paintPixAllday() ); 319 pa.begin( paintPixAllday() );
320 else 320 else
321 pa.begin( paintPix() ); 321 pa.begin( paintPix() );
322 } 322 }
323 int x, yy, w, h; 323 int x, yy, w, h;
324 float nfh = 7.0; 324 float nfh = 7.0;
325 x = pos().x(); w = width(); h = height (); 325 x = pos().x(); w = width(); h = height ();
326 if ( mAllDay ) 326 if ( mAllDay )
327 yy = y(); 327 yy = y();
328 else 328 else
329 yy = mCellYTop * ( height() / cellHeight() ); 329 yy = mCellYTop * ( height() / cellHeight() );
330 xPaintCoord= x; 330 xPaintCoord= x;
331 yPaintCoord = yy; 331 yPaintCoord = yy;
332 wPaintCoord = width(); 332 wPaintCoord = width();
333 hPaintCoord = height(); 333 hPaintCoord = height();
334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
335 if ( paint == 0 ) 335 if ( paint == 0 )
336 paint = &pa; 336 paint = &pa;
337 bool horLayout = ( w < h ); 337 bool horLayout = ( w < h );
338 int maxhei = mFontPixelSize+4; 338 int maxhei = mFontPixelSize+4;
339 if ( horLayout ) 339 if ( horLayout )
340 maxhei += AGENDA_ICON_SIZE -4; 340 maxhei += AGENDA_ICON_SIZE -4;
341 bool small = ( h < maxhei ); 341 bool small = ( h < maxhei );
342 if ( ! small ) 342 if ( ! small )
343 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 343 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
344 else { 344 else {
345 QFont f = KOPrefs::instance()->mAgendaViewFont; 345 QFont f = KOPrefs::instance()->mAgendaViewFont;
346 f.setBold( false ); 346 f.setBold( false );
347 int fh = f.pointSize(); 347 int fh = f.pointSize();
348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
349 if ( nfh < 6 ) 349 if ( nfh < 6 )
350 nfh = 6; 350 nfh = 6;
351 f.setPointSize( nfh ); 351 f.setPointSize( nfh );
352 paint->setFont(f); 352 paint->setFont(f);
353 } 353 }
354 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 354 paint->fillRect ( x, yy, w, h, mBackgroundColor );
355 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 355 static const QPixmap completedPxmp = SmallIcon("greenhook16");
356 static const QPixmap overduePxmp = SmallIcon("redcross16"); 356 static const QPixmap overduePxmp = SmallIcon("redcross16");
357 if ( mIncidence->type() == "Todo" ) { 357 if ( mIncidence->type() == "Todo" ) {
358 Todo* tempTodo = static_cast<Todo*>(mIncidence); 358 Todo* tempTodo = static_cast<Todo*>(mIncidence);
359 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 359 int xx = pos().x()+(width()-completedPxmp.width()-3 );
360 int yyy = yy+3; 360 int yyy = yy+3;
361 if ( tempTodo->isCompleted() ) 361 if ( tempTodo->isCompleted() )
362 paint->drawPixmap ( xx, yyy, completedPxmp ); 362 paint->drawPixmap ( xx, yyy, completedPxmp );
363 else { 363 else {
364 paint->drawPixmap ( xx, yyy, overduePxmp ); 364 paint->drawPixmap ( xx, yyy, overduePxmp );
365 365
366 } 366 }
367 } 367 }
368 bool addIcon = false; 368 bool addIcon = false;
369 if ( ! small || w > 3 * h || h > 3* w ) 369 if ( ! small || w > 3 * h || h > 3* w )
370 addIcon = updateIcons( paint, horLayout ); 370 addIcon = updateIcons( paint, horLayout );
371 371
372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
374 if ( ! small ) { 374 if ( ! small ) {
375 x += 3; yy += 3;w -= 6; h-= 5; 375 x += 3; yy += 3;w -= 6; h-= 5;
376 } else { 376 } else {
377 x += 2; yy += 1;w -= 4; h-= 4; 377 x += 2; yy += 1;w -= 4; h-= 4;
378 if ( nfh < 6.01 ) { 378 if ( nfh < 6.01 ) {
379 yy -= 2; 379 yy -= 2;
380 h += 4; 380 h += 4;
381 } 381 }
382 else 382 else
383 if ( nfh < h -2 ) 383 if ( nfh < h -2 )
384 ++yy; 384 ++yy;
385 } 385 }
386 int align; 386 int align;
387#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
388 align = ( AlignLeft|WordBreak|AlignTop); 388 align = ( AlignLeft|WordBreak|AlignTop);
389#else 389#else
390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
391#endif 391#endif
392 if ( addIcon ) { 392 if ( addIcon ) {
393 if ( ! horLayout ) { 393 if ( ! horLayout ) {
394 x += AGENDA_ICON_SIZE+3; 394 x += AGENDA_ICON_SIZE+3;
395 w -= (AGENDA_ICON_SIZE+3); 395 w -= (AGENDA_ICON_SIZE+3);
396 } 396 }
397 else { 397 else {
398 yy+= AGENDA_ICON_SIZE+2; 398 yy+= AGENDA_ICON_SIZE+2;
399 h -=(AGENDA_ICON_SIZE+3); 399 h -=(AGENDA_ICON_SIZE+3);
400 } 400 }
401 } 401 }
402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
403 if ( colsum < 250 ) 403 if ( colsum < 250 )
404 paint->setPen ( white); 404 paint->setPen ( white);
405 if ( x < 0 ) { 405 if ( x < 0 ) {
406 w = w+x-3; 406 w = w+x-3;
407 x = 3; 407 x = 3;
408 if ( w > parentWidget()->width() ){ 408 if ( w > parentWidget()->width() ){
409 w = parentWidget()->width() - 6; 409 w = parentWidget()->width() - 6;
410#ifndef DESKTOP_VERSION 410#ifndef DESKTOP_VERSION
411 align = ( AlignHCenter|WordBreak|AlignTop); 411 align = ( AlignHCenter|WordBreak|AlignTop);
412#else 412#else
413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
414#endif 414#endif
415 415
416 } 416 }
417 } 417 }
418 QRect dr; 418 QRect dr;
419 if ( w + x > parentWidget()->width() ) 419 if ( w + x > parentWidget()->width() )
420 w = parentWidget()->width()-x; 420 w = parentWidget()->width()-x;
421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
422 //qDebug("%d %d %d %d ", x, yy, w, h ); 422 //qDebug("%d %d %d %d ", x, yy, w, h );
423 if ( mIncidence->cancelled() ){ 423 if ( mIncidence->cancelled() ){
424 if ( ! small ) { 424 if ( ! small ) {
425 QFontMetrics fm ( paint->font() ); 425 QFontMetrics fm ( paint->font() );
426 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 426 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
427 } 427 }
428 428
429 } 429 }
430 pa.end(); 430 pa.end();
431 431
432} 432}
433void KOAgendaItem::resizePixmap( int w , int h ) 433void KOAgendaItem::resizePixmap( int w , int h )
434{ 434{
435 paintPix()->resize( w, h ); 435 paintPix()->resize( w, h );
436 paintPixSel()->resize( w, h ); 436 paintPixSel()->resize( w, h );
437 437
438} 438}
439QPixmap * KOAgendaItem::paintPix() 439QPixmap * KOAgendaItem::paintPix()
440{ 440{
441 static QPixmap* mPaintPix = 0; 441 static QPixmap* mPaintPix = 0;
442 if ( ! mPaintPix ) 442 if ( ! mPaintPix )
443 mPaintPix = new QPixmap(1,1); 443 mPaintPix = new QPixmap(1,1);
444 return mPaintPix ; 444 return mPaintPix ;
445} 445}
446QPixmap * KOAgendaItem::paintPixAllday() 446QPixmap * KOAgendaItem::paintPixAllday()
447{ 447{
448 static QPixmap* mPaintPixA = 0; 448 static QPixmap* mPaintPixA = 0;
449 if ( ! mPaintPixA ) 449 if ( ! mPaintPixA )
450 mPaintPixA = new QPixmap(1,1); 450 mPaintPixA = new QPixmap(1,1);
451 return mPaintPixA ; 451 return mPaintPixA ;
452} 452}
453QPixmap * KOAgendaItem::paintPixSel() 453QPixmap * KOAgendaItem::paintPixSel()
454{ 454{
455 static QPixmap* mPaintPixSel = 0; 455 static QPixmap* mPaintPixSel = 0;
456 if ( ! mPaintPixSel ) 456 if ( ! mPaintPixSel )
457 mPaintPixSel = new QPixmap(1,1); 457 mPaintPixSel = new QPixmap(1,1);
458 return mPaintPixSel ; 458 return mPaintPixSel ;
459} 459}
460void KOAgendaItem::paintEvent ( QPaintEvent *e ) 460void KOAgendaItem::paintEvent ( QPaintEvent *e )
461{ 461{
462 462
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 957ac52..b9c7dec 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,584 +1,576 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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 <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 mRows = rows; 84 mRows = rows;
85 85
86 setMinimumHeight( 20 ); 86 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 87 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 88
89 enableClipper(true); 89 enableClipper(true);
90 90
91 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
93 93
94 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
95 95
96 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
97} 97}
98 98
99void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
100{ 100{
101 mCellHeight = height; 101 mCellHeight = height;
102} 102}
103 103
104/* 104/*
105 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 109{
110 110
111 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
112 // return; 112 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 115 // code assumes the latter...
116 116
117 // now, for a workaround... 117 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 119 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
121 // end of workaround 121 // end of workaround
122 122
123 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
126 QString hour; 126 QString hour;
127 QString suffix; 127 QString suffix;
128 QString fullTime; 128 QString fullTime;
129 int tW = fm.width("24:00i"); 129 int tW = fm.width("24:00i");
130 int timeHeight = fm.height(); 130 int timeHeight = fm.height();
131 timeHeight -= (timeHeight/4-2); 131 timeHeight -= (timeHeight/4-2);
132 int borderWidth = 5; 132 int borderWidth = 2;
133 QFont nFont = p->font(); 133 QFont nFont = p->font();
134 QFont sFont = nFont; 134 QFont sFont = nFont;
135 sFont.setPointSize( sFont.pointSize()/2+2 ); 135 sFont.setPointSize( sFont.pointSize()/2+2 );
136 if (!KGlobal::locale()->use12Clock()) 136 if (!KGlobal::locale()->use12Clock())
137 suffix = "00"; 137 suffix = "00";
138 QFontMetrics fmS( sFont ); 138 QFontMetrics fmS( sFont );
139 int sHei = fmS.height(); 139 int sHei = fmS.height();
140 if ( timeHeight > mCellHeight ) { 140 if ( timeHeight > mCellHeight ) {
141 timeHeight = mCellHeight-1; 141 timeHeight = mCellHeight-1;
142 sHei -= 2; 142 sHei -= 2;
143 } 143 }
144 144
145 while (y < cy + ch) { 145 while (y < cy + ch) {
146 p->drawLine(cx,y,cx+tW,y); 146 p->drawLine(cx,y,cx+tW,y);
147 hour.setNum(cell); 147 hour.setNum(cell);
148 148
149 // handle 24h and am/pm time formats 149 // handle 24h and am/pm time formats
150 if (KGlobal::locale()->use12Clock()) { 150 if (KGlobal::locale()->use12Clock()) {
151 if (cell > 11) suffix = "pm"; 151 if (cell > 11) suffix = "pm";
152 else 152 else
153 suffix = "am"; 153 suffix = "am";
154 if (cell == 0) hour.setNum(12); 154 if (cell == 0) hour.setNum(12);
155 if (cell > 12) hour.setNum(cell - 12); 155 if (cell > 12) hour.setNum(cell - 12);
156 } 156 }
157 157
158 // create string in format of "XX:XX" or "XXpm/am" 158 // create string in format of "XX:XX" or "XXpm/am"
159 fullTime = hour;// + suffix; 159 fullTime = hour;// + suffix;
160 160
161 // center and draw the time label 161 // center and draw the time label
162 int timeWidth = fm.width(fullTime+"i"); 162 int timeWidth = fm.width(fullTime+"i");
163 int tw2 = fm.width(suffix); 163 int tw2 = fm.width(suffix);
164 int offset = this->width() - timeWidth - tw2; 164 int offset = this->width() - timeWidth - tw2;
165 p->setFont( nFont ); 165 p->setFont( nFont );
166 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); 166 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime);
167 p->setFont( sFont ); 167 p->setFont( sFont );
168 offset += timeWidth; 168 offset += timeWidth;
169 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 169 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
170 170
171 // increment indices 171 // increment indices
172 y += mCellHeight; 172 y += mCellHeight;
173 cell++; 173 cell++;
174 } 174 }
175} 175}
176 176
177/** 177/**
178 Calculates the minimum width. 178 Calculates the minimum width.
179*/ 179*/
180int TimeLabels::minimumWidth() const 180int TimeLabels::minimumWidth() const
181{ 181{
182 QFontMetrics fm = fontMetrics(); 182 return mMiniWidth;
183
184 //TODO: calculate this value
185 int borderWidth = 4;
186
187 // the maximum width possible
188 int width = fm.width("88:88x") + borderWidth;
189
190 return width;
191} 183}
192 184
193/** updates widget's internal state */ 185/** updates widget's internal state */
194void TimeLabels::updateConfig() 186void TimeLabels::updateConfig()
195{ 187{
196 // set the font 188 // set the font
197 // config->setGroup("Fonts"); 189 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 190 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 191 setFont(KOPrefs::instance()->mTimeBarFont);
200 192 mMiniWidth = fontMetrics().width("88:88") + 2 ;
201 // update geometry restrictions based on new settings 193 // update geometry restrictions based on new settings
202 setFixedWidth(minimumWidth()); 194 setFixedWidth(minimumWidth());
203 195
204 // update HourSize 196 // update HourSize
205 mCellHeight = KOPrefs::instance()->mHourSize*4; 197 mCellHeight = KOPrefs::instance()->mHourSize*4;
206 resizeContents(50,mRows * mCellHeight); 198 resizeContents(50,mRows * mCellHeight);
207} 199}
208 200
209/** update time label positions */ 201/** update time label positions */
210void TimeLabels::positionChanged() 202void TimeLabels::positionChanged()
211{ 203{
212 int adjustment = mAgenda->contentsY(); 204 int adjustment = mAgenda->contentsY();
213 setContentsPos(0, adjustment); 205 setContentsPos(0, adjustment);
214} 206}
215 207
216/** */ 208/** */
217void TimeLabels::setAgenda(KOAgenda* agenda) 209void TimeLabels::setAgenda(KOAgenda* agenda)
218{ 210{
219 mAgenda = agenda; 211 mAgenda = agenda;
220} 212}
221 213
222void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 214void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
223{ 215{
224 mMouseDownY = e->pos().y(); 216 mMouseDownY = e->pos().y();
225 mOrgCap = topLevelWidget()->caption(); 217 mOrgCap = topLevelWidget()->caption();
226} 218}
227 219
228void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 220void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
229{ 221{
230 int diff = mMouseDownY - e->pos().y(); 222 int diff = mMouseDownY - e->pos().y();
231 if ( diff < 10 && diff > -10 ) 223 if ( diff < 10 && diff > -10 )
232 return; 224 return;
233 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 225 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
234 if ( tSize < 4 ) 226 if ( tSize < 4 )
235 tSize = 4; 227 tSize = 4;
236 if ( tSize > 22 ) 228 if ( tSize > 22 )
237 tSize = 22; 229 tSize = 22;
238 tSize = (tSize-2)/2; 230 tSize = (tSize-2)/2;
239 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 231 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
240 232
241} 233}
242void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 234void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
243{ 235{
244 topLevelWidget()->setCaption( mOrgCap ); 236 topLevelWidget()->setCaption( mOrgCap );
245 int diff = mMouseDownY - e->pos().y(); 237 int diff = mMouseDownY - e->pos().y();
246 if ( diff < 10 && diff > -10 ) 238 if ( diff < 10 && diff > -10 )
247 return; 239 return;
248 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 240 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
249 if ( tSize < 4 ) 241 if ( tSize < 4 )
250 tSize = 4; 242 tSize = 4;
251 if ( tSize > 22 ) 243 if ( tSize > 22 )
252 tSize = 22; 244 tSize = 22;
253 tSize = (tSize/2)*2; 245 tSize = (tSize/2)*2;
254 if ( tSize == KOPrefs::instance()->mHourSize ) 246 if ( tSize == KOPrefs::instance()->mHourSize )
255 return; 247 return;
256 KOPrefs::instance()->mHourSize = tSize; 248 KOPrefs::instance()->mHourSize = tSize;
257 emit scaleChanged(); 249 emit scaleChanged();
258} 250}
259 251
260/** This is called in response to repaint() */ 252/** This is called in response to repaint() */
261void TimeLabels::paintEvent(QPaintEvent*) 253void TimeLabels::paintEvent(QPaintEvent*)
262{ 254{
263 255
264 // kdDebug() << "paintevent..." << endl; 256 // kdDebug() << "paintevent..." << endl;
265 // this is another hack! 257 // this is another hack!
266 // QPainter painter(this); 258 // QPainter painter(this);
267 //QString c 259 //QString c
268 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 260 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
269} 261}
270 262
271//////////////////////////////////////////////////////////////////////////// 263////////////////////////////////////////////////////////////////////////////
272 264
273EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 265EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
274 : QFrame(parent,name) 266 : QFrame(parent,name)
275{ 267{
276 mColumns = 1; 268 mColumns = 1;
277 mTopBox = 0; 269 mTopBox = 0;
278 mLocation = loc; 270 mLocation = loc;
279 mTopLayout = 0; 271 mTopLayout = 0;
280 mPaintWidget = 0; 272 mPaintWidget = 0;
281 mXOffset = 0; 273 mXOffset = 0;
282 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 274 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
283 else mPixmap = SmallIcon("1downarrow"); 275 else mPixmap = SmallIcon("1downarrow");
284 mEnabled.resize(mColumns); 276 mEnabled.resize(mColumns);
285 mEnabled.fill( false ); 277 mEnabled.fill( false );
286 setMinimumHeight(mPixmap.height()); 278 setMinimumHeight(mPixmap.height());
287} 279}
288 280
289EventIndicator::~EventIndicator() 281EventIndicator::~EventIndicator()
290{ 282{
291} 283}
292 284
293void EventIndicator::drawContents(QPainter *p) 285void EventIndicator::drawContents(QPainter *p)
294{ 286{
295 287
296 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 288 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
297 KDGanttSplitterHandle* han = 0; 289 KDGanttSplitterHandle* han = 0;
298 if ( mPaintWidget ) 290 if ( mPaintWidget )
299 han = mPaintWidget->firstHandle(); 291 han = mPaintWidget->firstHandle();
300 if ( ! han ) { 292 if ( ! han ) {
301 int i; 293 int i;
302 for(i=0;i<mColumns;++i) { 294 for(i=0;i<mColumns;++i) {
303 if (mEnabled[i]) { 295 if (mEnabled[i]) {
304 int cellWidth = contentsRect().right()/mColumns; 296 int cellWidth = contentsRect().right()/mColumns;
305 int xOffset = KOGlobals::self()->reverseLayout() ? 297 int xOffset = KOGlobals::self()->reverseLayout() ?
306 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 298 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
307 i*cellWidth + (cellWidth -mPixmap.width()) /2; 299 i*cellWidth + (cellWidth -mPixmap.width()) /2;
308 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 300 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
309 } 301 }
310 } 302 }
311 } else { 303 } else {
312 han->repaint(); 304 han->repaint();
313 //mPaintWidget->setBackgroundColor( red ); 305 //mPaintWidget->setBackgroundColor( red );
314 306
315 QPainter pa( han ); 307 QPainter pa( han );
316 int i; 308 int i;
317 bool setColor = false; 309 bool setColor = false;
318 for(i=0;i<mColumns;++i) { 310 for(i=0;i<mColumns;++i) {
319 if (mEnabled[i]) { 311 if (mEnabled[i]) {
320 setColor = true; 312 setColor = true;
321 313
322 int cellWidth = contentsRect().right()/mColumns; 314 int cellWidth = contentsRect().right()/mColumns;
323 int xOffset = KOGlobals::self()->reverseLayout() ? 315 int xOffset = KOGlobals::self()->reverseLayout() ?
324 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 316 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
325 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 317 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
326 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 318 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
327 //qDebug("222draw pix %d ",xOffset ); 319 //qDebug("222draw pix %d ",xOffset );
328 320
329 } 321 }
330 322
331 } 323 }
332 pa.end(); 324 pa.end();
333 325
334 } 326 }
335} 327}
336 328
337void EventIndicator::setXOffset( int x ) 329void EventIndicator::setXOffset( int x )
338{ 330{
339 mXOffset = x; 331 mXOffset = x;
340} 332}
341void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 333void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
342{ 334{
343 mPaintWidget = w; 335 mPaintWidget = w;
344 setMaximumHeight(0); 336 setMaximumHeight(0);
345 setMinimumHeight(0); 337 setMinimumHeight(0);
346} 338}
347void EventIndicator::changeColumns(int columns) 339void EventIndicator::changeColumns(int columns)
348{ 340{
349 mColumns = columns; 341 mColumns = columns;
350 mEnabled.resize(mColumns); 342 mEnabled.resize(mColumns);
351 343
352 update(); 344 update();
353} 345}
354 346
355void EventIndicator::enableColumn(int column, bool enable) 347void EventIndicator::enableColumn(int column, bool enable)
356{ 348{
357 mEnabled[column] = enable; 349 mEnabled[column] = enable;
358} 350}
359 351
360 352
361//////////////////////////////////////////////////////////////////////////// 353////////////////////////////////////////////////////////////////////////////
362//////////////////////////////////////////////////////////////////////////// 354////////////////////////////////////////////////////////////////////////////
363//////////////////////////////////////////////////////////////////////////// 355////////////////////////////////////////////////////////////////////////////
364 356
365KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 357KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
366 KOEventView (cal,parent,name) 358 KOEventView (cal,parent,name)
367{ 359{
368 mBlockUpdating = true; 360 mBlockUpdating = true;
369 mStartHour = 8; 361 mStartHour = 8;
370 mSelectedDates.append(QDate::currentDate()); 362 mSelectedDates.append(QDate::currentDate());
371 363
372 mLayoutDayLabels = 0; 364 mLayoutDayLabels = 0;
373 mDayLabelsFrame = 0; 365 mDayLabelsFrame = 0;
374 mDayLabels = 0; 366 mDayLabels = 0;
375 bool isRTL = KOGlobals::self()->reverseLayout(); 367 bool isRTL = KOGlobals::self()->reverseLayout();
376 368
377 if ( KOPrefs::instance()->mVerticalScreen ) { 369 if ( KOPrefs::instance()->mVerticalScreen ) {
378 mExpandedPixmap = SmallIcon( "1downarrow" ); 370 mExpandedPixmap = SmallIcon( "1downarrow" );
379 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 371 mNotExpandedPixmap = SmallIcon( "1uparrow" );
380 } else { 372 } else {
381 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 373 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
382 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 374 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
383 } 375 }
384 376
385 QBoxLayout *topLayout = new QVBoxLayout(this); 377 QBoxLayout *topLayout = new QVBoxLayout(this);
386 378
387 // Create day name labels for agenda columns 379 // Create day name labels for agenda columns
388 // Create agenda splitter 380 // Create agenda splitter
389 381
390 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 382 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
391 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 383 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
392 topLayout->addWidget( mSplitterAgenda ); 384 topLayout->addWidget( mSplitterAgenda );
393 mAllDayFrame = new QHBox(mSplitterAgenda); 385 mAllDayFrame = new QHBox(mSplitterAgenda);
394 mAllDayFrame->setFocusPolicy(NoFocus); 386 mAllDayFrame->setFocusPolicy(NoFocus);
395 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 387 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
396 agendaFrame->setFocusPolicy(NoFocus); 388 agendaFrame->setFocusPolicy(NoFocus);
397 389
398 // Create all-day agenda widget 390 // Create all-day agenda widget
399 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 391 mDummyAllDayLeft = new QVBox( mAllDayFrame );
400 392
401 mExpandButton = new QPushButton(mDummyAllDayLeft); 393 mExpandButton = new QPushButton(mDummyAllDayLeft);
402 mExpandButton->setPixmap( mNotExpandedPixmap ); 394 mExpandButton->setPixmap( mNotExpandedPixmap );
403 int widebut = mExpandButton->sizeHint().width(); 395 int widebut = mExpandButton->sizeHint().width();
404 if ( QApplication::desktop()->width() < 480 ) 396 if ( QApplication::desktop()->width() < 480 )
405 widebut = widebut*2; 397 widebut = widebut*2;
406 else 398 else
407 widebut = (widebut*3) / 2; 399 widebut = (widebut*3) / 2;
408 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 400 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
409 // QSizePolicy::Fixed ) ); 401 // QSizePolicy::Fixed ) );
410 mExpandButton->setFixedSize( widebut, widebut); 402 mExpandButton->setFixedSize( widebut, widebut);
411 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 403 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
412 mExpandButton->setFocusPolicy(NoFocus); 404 mExpandButton->setFocusPolicy(NoFocus);
413 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 405 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
414 mAllDayAgenda->setFocusPolicy(NoFocus); 406 mAllDayAgenda->setFocusPolicy(NoFocus);
415 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 407 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
416 408
417 // Create event context menu for all day agenda 409 // Create event context menu for all day agenda
418 mAllDayAgendaPopup = eventPopup(); 410 mAllDayAgendaPopup = eventPopup();
419 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 411 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
420 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 412 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
421 413
422 // Create agenda frame 414 // Create agenda frame
423 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 415 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
424 // QHBox *agendaFrame = new QHBox(splitterAgenda); 416 // QHBox *agendaFrame = new QHBox(splitterAgenda);
425 417
426 // create event indicator bars 418 // create event indicator bars
427 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 419 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
428#ifndef DESKTOP_VERSION 420#ifndef DESKTOP_VERSION
429 // FIX 421 // FIX
430 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 422 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
431#endif 423#endif
432 mDayLabelsFrame = new QHBox(agendaFrame); 424 mDayLabelsFrame = new QHBox(agendaFrame);
433 //topLayout->addWidget(mDayLabelsFrame); 425 //topLayout->addWidget(mDayLabelsFrame);
434 mDayLabels = new QFrame (mDayLabelsFrame); 426 mDayLabels = new QFrame (mDayLabelsFrame);
435 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 427 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
436 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 428 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
437 agendaLayout->addWidget(mEventIndicatorTop,1,1); 429 agendaLayout->addWidget(mEventIndicatorTop,1,1);
438 430
439 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 431 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
440 agendaFrame); 432 agendaFrame);
441 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 433 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
442 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 434 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
443 agendaLayout->addWidget(dummyAgendaRight,1,2); 435 agendaLayout->addWidget(dummyAgendaRight,1,2);
444 436
445 // Create time labels 437 // Create time labels
446 mTimeLabels = new TimeLabels(24,agendaFrame); 438 mTimeLabels = new TimeLabels(24,agendaFrame);
447 agendaLayout->addWidget(mTimeLabels,2,0); 439 agendaLayout->addWidget(mTimeLabels,2,0);
448 connect(mTimeLabels,SIGNAL( scaleChanged()), 440 connect(mTimeLabels,SIGNAL( scaleChanged()),
449 this,SLOT(updateConfig())); 441 this,SLOT(updateConfig()));
450 442
451 // Create agenda 443 // Create agenda
452 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 444 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
453 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 445 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
454 agendaLayout->setColStretch(1,1); 446 agendaLayout->setColStretch(1,1);
455 mAgenda->setFocusPolicy(NoFocus); 447 mAgenda->setFocusPolicy(NoFocus);
456 // Create event context menu for agenda 448 // Create event context menu for agenda
457 mAgendaPopup = eventPopup(); 449 mAgendaPopup = eventPopup();
458 450
459 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 451 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
460 i18n("Toggle Alarm"),mAgenda, 452 i18n("Toggle Alarm"),mAgenda,
461 SLOT(popupAlarm()),true); 453 SLOT(popupAlarm()),true);
462 454
463 455
464 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 456 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
465 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 457 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
466 458
467 // make connections between dependent widgets 459 // make connections between dependent widgets
468 mTimeLabels->setAgenda(mAgenda); 460 mTimeLabels->setAgenda(mAgenda);
469 461
470 // Update widgets to reflect user preferences 462 // Update widgets to reflect user preferences
471 // updateConfig(); 463 // updateConfig();
472 464
473 // createDayLabels(); 465 // createDayLabels();
474 466
475 // these blank widgets make the All Day Event box line up with the agenda 467 // these blank widgets make the All Day Event box line up with the agenda
476 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 468 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
477 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 469 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
478 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 470 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
479 471
480 // Scrolling 472 // Scrolling
481 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 473 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
482 mTimeLabels, SLOT(positionChanged())); 474 mTimeLabels, SLOT(positionChanged()));
483 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 475 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
484 SLOT(setContentsPos(int))); 476 SLOT(setContentsPos(int)));
485 477
486 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 478 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
487 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 479 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
488 480
489 // Create/Show/Edit/Delete Event 481 // Create/Show/Edit/Delete Event
490 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 482 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
491 SLOT(newEvent(int,int))); 483 SLOT(newEvent(int,int)));
492 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 484 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
493 SLOT(newTodo(int,int))); 485 SLOT(newTodo(int,int)));
494 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 486 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
495 SLOT(newEvent(int,int,int,int))); 487 SLOT(newEvent(int,int,int,int)));
496 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 488 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
497 SLOT(newEventAllDay(int,int))); 489 SLOT(newEventAllDay(int,int)));
498 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 490 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
499 SLOT(newTodoAllDay(int,int))); 491 SLOT(newTodoAllDay(int,int)));
500 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 492 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
501 SLOT(newEventAllDay(int,int))); 493 SLOT(newEventAllDay(int,int)));
502 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 494 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
503 SLOT(newTimeSpanSelected(int,int,int,int))); 495 SLOT(newTimeSpanSelected(int,int,int,int)));
504 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 496 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
505 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 497 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
506 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 498 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
507 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 499 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
508 500
509 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 501 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
510 SIGNAL(editIncidenceSignal(Incidence *))); 502 SIGNAL(editIncidenceSignal(Incidence *)));
511 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 503 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
512 SIGNAL(editIncidenceSignal(Incidence *))); 504 SIGNAL(editIncidenceSignal(Incidence *)));
513 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 505 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
514 SIGNAL(showIncidenceSignal(Incidence *))); 506 SIGNAL(showIncidenceSignal(Incidence *)));
515 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 507 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
516 SIGNAL(showIncidenceSignal(Incidence *))); 508 SIGNAL(showIncidenceSignal(Incidence *)));
517 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 509 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
518 SIGNAL(deleteIncidenceSignal(Incidence *))); 510 SIGNAL(deleteIncidenceSignal(Incidence *)));
519 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 511 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
520 SIGNAL(deleteIncidenceSignal(Incidence *))); 512 SIGNAL(deleteIncidenceSignal(Incidence *)));
521 513
522 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 514 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
523 SLOT(updateEventDates(KOAgendaItem *, int ))); 515 SLOT(updateEventDates(KOAgendaItem *, int )));
524 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 516 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
525 SLOT(updateEventDates(KOAgendaItem *, int))); 517 SLOT(updateEventDates(KOAgendaItem *, int)));
526 518
527 // event indicator update 519 // event indicator update
528 connect(mAgenda,SIGNAL(lowerYChanged(int)), 520 connect(mAgenda,SIGNAL(lowerYChanged(int)),
529 SLOT(updateEventIndicatorTop(int))); 521 SLOT(updateEventIndicatorTop(int)));
530 connect(mAgenda,SIGNAL(upperYChanged(int)), 522 connect(mAgenda,SIGNAL(upperYChanged(int)),
531 SLOT(updateEventIndicatorBottom(int))); 523 SLOT(updateEventIndicatorBottom(int)));
532 // drag signals 524 // drag signals
533 /* 525 /*
534 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 526 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
535 SLOT(startDrag(Event *))); 527 SLOT(startDrag(Event *)));
536 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 528 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
537 SLOT(startDrag(Event *))); 529 SLOT(startDrag(Event *)));
538 */ 530 */
539 // synchronize selections 531 // synchronize selections
540 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 532 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
541 mAllDayAgenda, SLOT( deselectItem() ) ); 533 mAllDayAgenda, SLOT( deselectItem() ) );
542 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 534 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
543 mAgenda, SLOT( deselectItem() ) ); 535 mAgenda, SLOT( deselectItem() ) );
544 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 536 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
545 SIGNAL( incidenceSelected( Incidence * ) ) ); 537 SIGNAL( incidenceSelected( Incidence * ) ) );
546 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 538 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
547 SIGNAL( incidenceSelected( Incidence * ) ) ); 539 SIGNAL( incidenceSelected( Incidence * ) ) );
548 connect( mAgenda, SIGNAL( resizedSignal() ), 540 connect( mAgenda, SIGNAL( resizedSignal() ),
549 SLOT( updateConfig( ) ) ); 541 SLOT( updateConfig( ) ) );
550 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 542 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
551 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 543 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
552 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 544 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
553 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 545 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
554 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 546 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
555 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 547 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
556 548
557 549
558} 550}
559 551
560void KOAgendaView::toggleAllDay() 552void KOAgendaView::toggleAllDay()
561{ 553{
562 if ( mSplitterAgenda->firstHandle() ) 554 if ( mSplitterAgenda->firstHandle() )
563 mSplitterAgenda->firstHandle()->toggle(); 555 mSplitterAgenda->firstHandle()->toggle();
564} 556}
565void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 557void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
566{ 558{
567 calendar()->addIncidence( inc ); 559 calendar()->addIncidence( inc );
568 560
569 if ( incOld ) { 561 if ( incOld ) {
570 if ( incOld->type() == "Todo" ) 562 if ( incOld->type() == "Todo" )
571 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 563 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
572 else 564 else
573 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 565 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
574 } 566 }
575 567
576} 568}
577 569
578KOAgendaView::~KOAgendaView() 570KOAgendaView::~KOAgendaView()
579{ 571{
580 delete mAgendaPopup; 572 delete mAgendaPopup;
581 delete mAllDayAgendaPopup; 573 delete mAllDayAgendaPopup;
582 delete KOAgendaItem::paintPix(); 574 delete KOAgendaItem::paintPix();
583 delete KOAgendaItem::paintPixSel(); 575 delete KOAgendaItem::paintPixSel();
584} 576}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 8b8bac0..0cb9310 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,291 +1,292 @@
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 KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 int mMiniWidth;
104 int mMouseDownY; 105 int mMouseDownY;
105 QString mOrgCap; 106 QString mOrgCap;
106 int mRows; 107 int mRows;
107 int mCellHeight; 108 int mCellHeight;
108 109
109 /** */ 110 /** */
110 KOAgenda* mAgenda; 111 KOAgenda* mAgenda;
111}; 112};
112 113
113class EventIndicator : public QFrame { 114class EventIndicator : public QFrame {
114 Q_OBJECT 115 Q_OBJECT
115 public: 116 public:
116 enum Location { Top, Bottom }; 117 enum Location { Top, Bottom };
117 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 118 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
118 virtual ~EventIndicator(); 119 virtual ~EventIndicator();
119 120
120 void changeColumns(int columns); 121 void changeColumns(int columns);
121 void setPaintWidget( KDGanttMinimizeSplitter* ); 122 void setPaintWidget( KDGanttMinimizeSplitter* );
122 void setXOffset( int ); 123 void setXOffset( int );
123 void enableColumn(int column, bool enable); 124 void enableColumn(int column, bool enable);
124 125
125 protected: 126 protected:
126 void drawContents(QPainter *); 127 void drawContents(QPainter *);
127 128
128 private: 129 private:
129 int mXOffset; 130 int mXOffset;
130 KDGanttMinimizeSplitter* mPaintWidget; 131 KDGanttMinimizeSplitter* mPaintWidget;
131 int mColumns; 132 int mColumns;
132 QHBox *mTopBox; 133 QHBox *mTopBox;
133 QBoxLayout *mTopLayout; 134 QBoxLayout *mTopLayout;
134 Location mLocation; 135 Location mLocation;
135 QPixmap mPixmap; 136 QPixmap mPixmap;
136 QMemArray<bool> mEnabled; 137 QMemArray<bool> mEnabled;
137}; 138};
138 139
139/** 140/**
140 KOAgendaView is the agenda-like view used to display events in an one or 141 KOAgendaView is the agenda-like view used to display events in an one or
141 multi-day view. 142 multi-day view.
142*/ 143*/
143class KOAgendaView : public KOEventView { 144class KOAgendaView : public KOEventView {
144 Q_OBJECT 145 Q_OBJECT
145 public: 146 public:
146 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 147 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
147 virtual ~KOAgendaView(); 148 virtual ~KOAgendaView();
148 void setStartHour( int ); 149 void setStartHour( int );
149 void toggleAllDay(); 150 void toggleAllDay();
150 151
151 152
152 /** Returns maximum number of days supported by the koagendaview */ 153 /** Returns maximum number of days supported by the koagendaview */
153 virtual int maxDatesHint(); 154 virtual int maxDatesHint();
154 155
155 /** Returns number of currently shown dates. */ 156 /** Returns number of currently shown dates. */
156 virtual int currentDateCount(); 157 virtual int currentDateCount();
157 158
158 /** returns the currently selected events */ 159 /** returns the currently selected events */
159 virtual QPtrList<Incidence> selectedIncidences(); 160 virtual QPtrList<Incidence> selectedIncidences();
160 161
161 /** returns the currently selected events */ 162 /** returns the currently selected events */
162 virtual DateList selectedDates(); 163 virtual DateList selectedDates();
163 164
164 /** Remove all events from view */ 165 /** Remove all events from view */
165 void clearView(); 166 void clearView();
166 KOAgenda *agenda() { return mAgenda;} 167 KOAgenda *agenda() { return mAgenda;}
167 virtual void printPreview(CalPrinter *calPrinter, 168 virtual void printPreview(CalPrinter *calPrinter,
168 const QDate &, const QDate &); 169 const QDate &, const QDate &);
169 170
170 /** start-datetime of selection */ 171 /** start-datetime of selection */
171 QDateTime selectionStart() {return mTimeSpanBegin;} 172 QDateTime selectionStart() {return mTimeSpanBegin;}
172 /** end-datetime of selection */ 173 /** end-datetime of selection */
173 QDateTime selectionEnd() {return mTimeSpanEnd;} 174 QDateTime selectionEnd() {return mTimeSpanEnd;}
174 /** returns true if selection is for whole day */ 175 /** returns true if selection is for whole day */
175 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 176 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
176 /** make selected start/end invalid */ 177 /** make selected start/end invalid */
177 void deleteSelectedDateTime(); 178 void deleteSelectedDateTime();
178 void repaintAgenda(); 179 void repaintAgenda();
179 public slots: 180 public slots:
180 void setInitStartHour(); 181 void setInitStartHour();
181 virtual void updateView(); 182 virtual void updateView();
182 virtual void updateConfig(); 183 virtual void updateConfig();
183 virtual void showDates(const QDate &start, const QDate &end); 184 virtual void showDates(const QDate &start, const QDate &end);
184 virtual void showEvents(QPtrList<Event> eventList); 185 virtual void showEvents(QPtrList<Event> eventList);
185 186
186 void updateTodo( Todo *, int ); 187 void updateTodo( Todo *, int );
187 void changeEventDisplay(Event *, int); 188 void changeEventDisplay(Event *, int);
188 189
189 void clearSelection(); 190 void clearSelection();
190 191
191 void newTodo(int gx,int gy); 192 void newTodo(int gx,int gy);
192 void newEvent(int gx,int gy); 193 void newEvent(int gx,int gy);
193 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 194 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
194 void newEventAllDay(int gx, int gy); 195 void newEventAllDay(int gx, int gy);
195 void newTodoAllDay(int gx, int gy); 196 void newTodoAllDay(int gx, int gy);
196 197
197 void startDrag(Event *); 198 void startDrag(Event *);
198 199
199 void readSettings(); 200 void readSettings();
200 void readSettings(KConfig *); 201 void readSettings(KConfig *);
201 void writeSettings(KConfig *); 202 void writeSettings(KConfig *);
202 203
203 void setContentsPos(int y); 204 void setContentsPos(int y);
204 205
205 void setExpandedButton( bool expanded ); 206 void setExpandedButton( bool expanded );
206 void scrollOneHourUp(); 207 void scrollOneHourUp();
207 void scrollOneHourDown(); 208 void scrollOneHourDown();
208 void addToCalSlot(Incidence *, Incidence *); 209 void addToCalSlot(Incidence *, Incidence *);
209 210
210 signals: 211 signals:
211 void showDateView( int, QDate ); 212 void showDateView( int, QDate );
212 void newTodoSignal( QDateTime ,bool ); 213 void newTodoSignal( QDateTime ,bool );
213 void toggleExpand(); 214 void toggleExpand();
214 void selectWeekNum( int ); 215 void selectWeekNum( int );
215 void todoMoved( Todo *, int ); 216 void todoMoved( Todo *, int );
216 void incidenceChanged(Incidence * , int ); 217 void incidenceChanged(Incidence * , int );
217 // void cloneIncidenceSignal(Incidence *); 218 // void cloneIncidenceSignal(Incidence *);
218 219
219 protected: 220 protected:
220 KOAgendaButton* getNewDaylabel(); 221 KOAgendaButton* getNewDaylabel();
221 bool mBlockUpdating; 222 bool mBlockUpdating;
222 int mUpcomingWidth; 223 int mUpcomingWidth;
223 /** Fill agenda beginning with date startDate */ 224 /** Fill agenda beginning with date startDate */
224 void fillAgenda(const QDate &startDate); 225 void fillAgenda(const QDate &startDate);
225 void resizeEvent( QResizeEvent* e ); 226 void resizeEvent( QResizeEvent* e );
226 /** Fill agenda using the current set value for the start date */ 227 /** Fill agenda using the current set value for the start date */
227 void fillAgenda(); 228 void fillAgenda();
228 229
229 /** Create labels for the selected dates. */ 230 /** Create labels for the selected dates. */
230 void createDayLabels(); 231 void createDayLabels();
231 232
232 /** 233 /**
233 Set the masks on the agenda widgets indicating, which days are holidays. 234 Set the masks on the agenda widgets indicating, which days are holidays.
234 */ 235 */
235 void setHolidayMasks(); 236 void setHolidayMasks();
236 237
237 protected slots: 238 protected slots:
238 void slotDaylabelClicked( int ); 239 void slotDaylabelClicked( int );
239 /** Update event belonging to agenda item */ 240 /** Update event belonging to agenda item */
240 void updateEventDates(KOAgendaItem *item, int mode = -1); 241 void updateEventDates(KOAgendaItem *item, int mode = -1);
241 //void updateMovedTodo(); 242 //void updateMovedTodo();
242 243
243 void updateEventIndicatorTop(int newY); 244 void updateEventIndicatorTop(int newY);
244 void updateEventIndicatorBottom(int newY); 245 void updateEventIndicatorBottom(int newY);
245 246
246 /** Updates data for selected timespan */ 247 /** Updates data for selected timespan */
247 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 248 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
248 /** Updates data for selected timespan for all day event*/ 249 /** Updates data for selected timespan for all day event*/
249 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 250 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
250 251
251 private: 252 private:
252 // view widgets 253 // view widgets
253 QFrame *mDayLabels; 254 QFrame *mDayLabels;
254 QHBox *mDayLabelsFrame; 255 QHBox *mDayLabelsFrame;
255 QBoxLayout *mLayoutDayLabels; 256 QBoxLayout *mLayoutDayLabels;
256 QFrame *mAllDayFrame; 257 QFrame *mAllDayFrame;
257 KOAgenda *mAllDayAgenda; 258 KOAgenda *mAllDayAgenda;
258 KOAgenda *mAgenda; 259 KOAgenda *mAgenda;
259 TimeLabels *mTimeLabels; 260 TimeLabels *mTimeLabels;
260 QWidget *mDummyAllDayLeft; 261 QWidget *mDummyAllDayLeft;
261 262
262 KDGanttMinimizeSplitter* mSplitterAgenda; 263 KDGanttMinimizeSplitter* mSplitterAgenda;
263 QPushButton *mExpandButton; 264 QPushButton *mExpandButton;
264 265
265 DateList mSelectedDates; // List of dates to be displayed 266 DateList mSelectedDates; // List of dates to be displayed
266 int mViewType; 267 int mViewType;
267 268
268 bool mWeekStartsMonday; 269 bool mWeekStartsMonday;
269 int mStartHour; 270 int mStartHour;
270 271
271 KOEventPopupMenu *mAgendaPopup; 272 KOEventPopupMenu *mAgendaPopup;
272 KOEventPopupMenu *mAllDayAgendaPopup; 273 KOEventPopupMenu *mAllDayAgendaPopup;
273 274
274 EventIndicator *mEventIndicatorTop; 275 EventIndicator *mEventIndicatorTop;
275 EventIndicator *mEventIndicatorBottom; 276 EventIndicator *mEventIndicatorBottom;
276 277
277 QMemArray<int> mMinY; 278 QMemArray<int> mMinY;
278 QMemArray<int> mMaxY; 279 QMemArray<int> mMaxY;
279 280
280 QMemArray<bool> mHolidayMask; 281 QMemArray<bool> mHolidayMask;
281 282
282 QPixmap mExpandedPixmap; 283 QPixmap mExpandedPixmap;
283 QPixmap mNotExpandedPixmap; 284 QPixmap mNotExpandedPixmap;
284 QPtrList<KOAgendaButton> mDayLabelsList; 285 QPtrList<KOAgendaButton> mDayLabelsList;
285 QDateTime mTimeSpanBegin; 286 QDateTime mTimeSpanBegin;
286 QDateTime mTimeSpanEnd; 287 QDateTime mTimeSpanEnd;
287 bool mTimeSpanInAllDay; 288 bool mTimeSpanInAllDay;
288 void keyPressEvent ( QKeyEvent * e ); 289 void keyPressEvent ( QKeyEvent * e );
289}; 290};
290 291
291#endif // KOAGENDAVIEW_H 292#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 6b63d7f..09d70f1 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -773,423 +773,470 @@ QPtrList<Incidence> KOListView::selectedIncidences()
773 item = item->nextSibling(); 773 item = item->nextSibling();
774 } 774 }
775 775
776 // // QListViewItem *item = mListView->selectedItem(); 776 // // QListViewItem *item = mListView->selectedItem();
777 //if (item) eventList.append(((KOListViewItem *)item)->data()); 777 //if (item) eventList.append(((KOListViewItem *)item)->data());
778 778
779 return eventList; 779 return eventList;
780} 780}
781 781
782DateList KOListView::selectedDates() 782DateList KOListView::selectedDates()
783{ 783{
784 DateList eventList; 784 DateList eventList;
785 return eventList; 785 return eventList;
786} 786}
787 787
788void KOListView::showDates(bool show) 788void KOListView::showDates(bool show)
789{ 789{
790 // Shouldn't we set it to a value greater 0? When showDates is called with 790 // Shouldn't we set it to a value greater 0? When showDates is called with
791 // show == true at first, then the columnwidths are set to zero. 791 // show == true at first, then the columnwidths are set to zero.
792 static int oldColWidth1 = 0; 792 static int oldColWidth1 = 0;
793 static int oldColWidth3 = 0; 793 static int oldColWidth3 = 0;
794 794
795 if (!show) { 795 if (!show) {
796 oldColWidth1 = mListView->columnWidth(1); 796 oldColWidth1 = mListView->columnWidth(1);
797 oldColWidth3 = mListView->columnWidth(3); 797 oldColWidth3 = mListView->columnWidth(3);
798 mListView->setColumnWidth(1, 0); 798 mListView->setColumnWidth(1, 0);
799 mListView->setColumnWidth(3, 0); 799 mListView->setColumnWidth(3, 0);
800 } else { 800 } else {
801 mListView->setColumnWidth(1, oldColWidth1); 801 mListView->setColumnWidth(1, oldColWidth1);
802 mListView->setColumnWidth(3, oldColWidth3); 802 mListView->setColumnWidth(3, oldColWidth3);
803 } 803 }
804 mListView->repaint(); 804 mListView->repaint();
805} 805}
806 806
807void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 807void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
808 const QDate &td) 808 const QDate &td)
809{ 809{
810#ifndef KORG_NOPRINTER 810#ifndef KORG_NOPRINTER
811 calPrinter->preview(CalPrinter::Day, fd, td); 811 calPrinter->preview(CalPrinter::Day, fd, td);
812#endif 812#endif
813} 813}
814 814
815void KOListView::showDates() 815void KOListView::showDates()
816{ 816{
817 showDates(true); 817 showDates(true);
818} 818}
819 819
820void KOListView::hideDates() 820void KOListView::hideDates()
821{ 821{
822 showDates(false); 822 showDates(false);
823} 823}
824void KOListView::resetFocus() 824void KOListView::resetFocus()
825{ 825{
826 mListView->setFocus(); 826 mListView->setFocus();
827} 827}
828void KOListView::updateView() 828void KOListView::updateView()
829{ 829{
830 mListView->setFocus(); 830 mListView->setFocus();
831 if ( mListView->firstChild () ) 831 if ( mListView->firstChild () )
832 mListView->setCurrentItem( mListView->firstChild () ); 832 mListView->setCurrentItem( mListView->firstChild () );
833} 833}
834void KOListView::updateConfig() 834void KOListView::updateConfig()
835{ 835{
836 836
837 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 837 mListView->setFont ( KOPrefs::instance()->mListViewFont );
838 updateView(); 838 updateView();
839 839
840} 840}
841void KOListView::setStartDate(const QDate &start) 841void KOListView::setStartDate(const QDate &start)
842{ 842{
843 mStartDate = start; 843 mStartDate = start;
844} 844}
845 845
846void KOListView::showDates(const QDate &start, const QDate &end) 846void KOListView::showDates(const QDate &start, const QDate &end)
847{ 847{
848 clear(); 848 clear();
849 mStartDate = start; 849 mStartDate = start;
850 QDate date = start; 850 QDate date = start;
851 QPtrList<Journal> j_list; 851 QPtrList<Journal> j_list;
852 while( date <= end ) { 852 while( date <= end ) {
853 addEvents(calendar()->events(date)); 853 addEvents(calendar()->events(date));
854 addTodos(calendar()->todos(date)); 854 addTodos(calendar()->todos(date));
855 Journal* jo = calendar()->journal(date); 855 Journal* jo = calendar()->journal(date);
856 if ( jo ) 856 if ( jo )
857 j_list.append( jo ); 857 j_list.append( jo );
858 date = date.addDays( 1 ); 858 date = date.addDays( 1 );
859 } 859 }
860 addJournals(j_list); 860 addJournals(j_list);
861 emit incidenceSelected( 0 ); 861 emit incidenceSelected( 0 );
862 updateView(); 862 updateView();
863 863
864} 864}
865 865
866void KOListView::addEvents(QPtrList<Event> eventList) 866void KOListView::addEvents(QPtrList<Event> eventList)
867{ 867{
868 Event *ev; 868 Event *ev;
869 for(ev = eventList.first(); ev; ev = eventList.next()) { 869 for(ev = eventList.first(); ev; ev = eventList.next()) {
870 addIncidence(ev); 870 addIncidence(ev);
871 } 871 }
872 if ( !mListView->currentItem() ){ 872 if ( !mListView->currentItem() ){
873 updateView(); 873 updateView();
874 } 874 }
875} 875}
876 876
877void KOListView::addTodos(QPtrList<Todo> eventList) 877void KOListView::addTodos(QPtrList<Todo> eventList)
878{ 878{
879 Todo *ev; 879 Todo *ev;
880 for(ev = eventList.first(); ev; ev = eventList.next()) { 880 for(ev = eventList.first(); ev; ev = eventList.next()) {
881 addIncidence(ev); 881 addIncidence(ev);
882 } 882 }
883 if ( !mListView->currentItem() ){ 883 if ( !mListView->currentItem() ){
884 updateView(); 884 updateView();
885 } 885 }
886} 886}
887void KOListView::addJournals(QPtrList<Journal> eventList) 887void KOListView::addJournals(QPtrList<Journal> eventList)
888{ 888{
889 Journal *ev; 889 Journal *ev;
890 for(ev = eventList.first(); ev; ev = eventList.next()) { 890 for(ev = eventList.first(); ev; ev = eventList.next()) {
891 addIncidence(ev); 891 addIncidence(ev);
892 } 892 }
893 if ( !mListView->currentItem() ){ 893 if ( !mListView->currentItem() ){
894 updateView(); 894 updateView();
895 } 895 }
896} 896}
897 897
898void KOListView::addIncidence(Incidence *incidence) 898void KOListView::addIncidence(Incidence *incidence)
899{ 899{
900 if ( mUidDict.find( incidence->uid() ) ) return; 900 if ( mUidDict.find( incidence->uid() ) ) return;
901 901
902 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 902 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
903 mUidDict.insert( incidence->uid(), incidence ); 903 mUidDict.insert( incidence->uid(), incidence );
904 904
905 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 905 KOListViewItem *item = new KOListViewItem( incidence, mListView );
906 ListItemVisitor v(item, mStartDate ); 906 ListItemVisitor v(item, mStartDate );
907 if (incidence->accept(v)) return; 907 if (incidence->accept(v)) return;
908 else delete item; 908 else delete item;
909 //qDebug("delete item "); 909 //qDebug("delete item ");
910} 910}
911 911
912void KOListView::showEvents(QPtrList<Event> eventList) 912void KOListView::showEvents(QPtrList<Event> eventList)
913{ 913{
914 clear(); 914 clear();
915 915
916 addEvents(eventList); 916 addEvents(eventList);
917 917
918 // After new creation of list view no events are selected. 918 // After new creation of list view no events are selected.
919 emit incidenceSelected( 0 ); 919 emit incidenceSelected( 0 );
920} 920}
921int KOListView::count() 921int KOListView::count()
922{ 922{
923 return mListView->childCount(); 923 return mListView->childCount();
924} 924}
925 925
926void KOListView::changeEventDisplay(Event *event, int action) 926void KOListView::changeEventDisplay(Event *event, int action)
927{ 927{
928 KOListViewItem *item; 928 KOListViewItem *item;
929 929
930 switch(action) { 930 switch(action) {
931 case KOGlobals::EVENTADDED: 931 case KOGlobals::EVENTADDED:
932 addIncidence( event ); 932 addIncidence( event );
933 break; 933 break;
934 case KOGlobals::EVENTEDITED: 934 case KOGlobals::EVENTEDITED:
935 item = getItemForEvent(event); 935 item = getItemForEvent(event);
936 if (item) { 936 if (item) {
937 mUidDict.remove( event->uid() ); 937 mUidDict.remove( event->uid() );
938 delete item; 938 delete item;
939 addIncidence( event ); 939 addIncidence( event );
940 } 940 }
941 break; 941 break;
942 case KOGlobals::EVENTDELETED: 942 case KOGlobals::EVENTDELETED:
943 item = getItemForEvent(event); 943 item = getItemForEvent(event);
944 if (item) { 944 if (item) {
945 mUidDict.remove( event->uid() ); 945 mUidDict.remove( event->uid() );
946 delete item; 946 delete item;
947 } 947 }
948 break; 948 break;
949 default: 949 default:
950 ; 950 ;
951 } 951 }
952} 952}
953 953
954KOListViewItem *KOListView::getItemForEvent(Event *event) 954KOListViewItem *KOListView::getItemForEvent(Event *event)
955{ 955{
956 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 956 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
957 while (item) { 957 while (item) {
958 if (item->data() == event) return item; 958 if (item->data() == event) return item;
959 item = (KOListViewItem *)item->nextSibling(); 959 item = (KOListViewItem *)item->nextSibling();
960 } 960 }
961 return 0; 961 return 0;
962} 962}
963 963
964void KOListView::defaultItemAction(QListViewItem *i) 964void KOListView::defaultItemAction(QListViewItem *i)
965{ 965{
966 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 966 KOListViewItem *item = static_cast<KOListViewItem *>( i );
967 if ( item ) defaultAction( item->data() ); 967 if ( item ) defaultAction( item->data() );
968 968
969} 969}
970 970
971void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 971void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
972{ 972{
973 mActiveItem = (KOListViewItem *)item; 973 mActiveItem = (KOListViewItem *)item;
974 if (mActiveItem) { 974 if (mActiveItem) {
975 Incidence *incidence = mActiveItem->data(); 975 Incidence *incidence = mActiveItem->data();
976 mPopupMenu->showIncidencePopup(incidence); 976 mPopupMenu->showIncidencePopup(incidence);
977 977
978 /* 978 /*
979 if ( incidence && incidence->type() == "Event" ) { 979 if ( incidence && incidence->type() == "Event" ) {
980 Event *event = static_cast<Event *>( incidence ); 980 Event *event = static_cast<Event *>( incidence );
981 mPopupMenu->showEventPopup(event); 981 mPopupMenu->showEventPopup(event);
982 } 982 }
983 */ 983 */
984 } 984 }
985} 985}
986 986
987void KOListView::readSettings(KConfig *config, QString setting) 987void KOListView::readSettings(KConfig *config, QString setting)
988{ 988{
989 // qDebug("KOListView::readSettings "); 989 // qDebug("KOListView::readSettings ");
990 mListView->restoreLayout(config,setting); 990 mListView->restoreLayout(config,setting);
991} 991}
992 992
993void KOListView::writeSettings(KConfig *config, QString setting) 993void KOListView::writeSettings(KConfig *config, QString setting)
994{ 994{
995 // qDebug("KOListView::writeSettings "); 995 // qDebug("KOListView::writeSettings ");
996 mListView->saveLayout(config, setting); 996 mListView->saveLayout(config, setting);
997} 997}
998 998
999void KOListView::processSelectionChange(QListViewItem *) 999void KOListView::processSelectionChange(QListViewItem *)
1000{ 1000{
1001 1001
1002 KOListViewItem *item = 1002 KOListViewItem *item =
1003 static_cast<KOListViewItem *>( mListView->currentItem() ); 1003 static_cast<KOListViewItem *>( mListView->currentItem() );
1004 1004
1005 if ( !item ) { 1005 if ( !item ) {
1006 emit incidenceSelected( 0 ); 1006 emit incidenceSelected( 0 );
1007 } else { 1007 } else {
1008 emit incidenceSelected( item->data() ); 1008 emit incidenceSelected( item->data() );
1009 } 1009 }
1010} 1010}
1011 1011
1012void KOListView::clearSelection() 1012void KOListView::clearSelection()
1013{ 1013{
1014 mListView->selectAll( false ); 1014 mListView->selectAll( false );
1015} 1015}
1016void KOListView::allSelection() 1016void KOListView::allSelection()
1017{ 1017{
1018 mListView->selectAll( true ); 1018 mListView->selectAll( true );
1019} 1019}
1020 1020
1021void KOListView::clear() 1021void KOListView::clear()
1022{ 1022{
1023 mListView->clear(); 1023 mListView->clear();
1024 mUidDict.clear(); 1024 mUidDict.clear();
1025} 1025}
1026 1026
1027Incidence* KOListView::currentItem() 1027Incidence* KOListView::currentItem()
1028{ 1028{
1029 if ( mListView->currentItem() ) 1029 if ( mListView->currentItem() )
1030 return ((KOListViewItem*) mListView->currentItem())->data(); 1030 return ((KOListViewItem*) mListView->currentItem())->data();
1031 return 0; 1031 return 0;
1032} 1032}
1033void KOListView::keyPressEvent ( QKeyEvent *e) 1033void KOListView::keyPressEvent ( QKeyEvent *e)
1034{ 1034{
1035 1035
1036 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1036 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1037 deleteAll(); 1037 deleteAll();
1038 return; 1038 return;
1039 } 1039 }
1040 1040
1041 e->ignore(); 1041 e->ignore();
1042} 1042}
1043void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1043void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1044{ 1044{
1045 1045
1046 switch ( e->key() ) { 1046 switch ( e->key() ) {
1047 case Qt::Key_Down: 1047 case Qt::Key_Down:
1048 if ( e->state() == ShiftButton ) { 1048 if ( e->state() == ShiftButton ) {
1049 QListViewItem* cn = currentItem(); 1049 QListViewItem* cn = currentItem();
1050 if ( !cn ) 1050 if ( !cn )
1051 cn = firstChild(); 1051 cn = firstChild();
1052 if ( !cn ) 1052 if ( !cn )
1053 return; 1053 return;
1054 while ( cn->nextSibling() ) 1054 while ( cn->nextSibling() )
1055 cn = cn->nextSibling(); 1055 cn = cn->nextSibling();
1056 setCurrentItem ( cn ); 1056 setCurrentItem ( cn );
1057 ensureItemVisible ( cn ); 1057 ensureItemVisible ( cn );
1058 1058
1059 e->accept(); 1059 e->accept();
1060 return; 1060 return;
1061 } 1061 }
1062 if ( e->state() == ControlButton ) { 1062 if ( e->state() == ControlButton ) {
1063 int count = childCount (); 1063 int count = childCount ();
1064 int jump = count / 5; 1064 int jump = count / 5;
1065 QListViewItem* cn; 1065 QListViewItem* cn;
1066 cn = currentItem(); 1066 cn = currentItem();
1067 if ( ! cn ) 1067 if ( ! cn )
1068 return; 1068 return;
1069 if ( jump == 0 ) 1069 if ( jump == 0 )
1070 jump = 1; 1070 jump = 1;
1071 while ( jump && cn->nextSibling() ) { 1071 while ( jump && cn->nextSibling() ) {
1072 cn = cn->nextSibling(); 1072 cn = cn->nextSibling();
1073 --jump; 1073 --jump;
1074 } 1074 }
1075 setCurrentItem ( cn ); 1075 setCurrentItem ( cn );
1076 ensureItemVisible ( cn ); 1076 ensureItemVisible ( cn );
1077 1077
1078 } else 1078 } else
1079 QListView::keyPressEvent ( e ) ; 1079 QListView::keyPressEvent ( e ) ;
1080 e->accept(); 1080 e->accept();
1081 break; 1081 break;
1082 1082
1083 case Qt::Key_Up: 1083 case Qt::Key_Up:
1084 if ( e->state() == ShiftButton ) { 1084 if ( e->state() == ShiftButton ) {
1085 QListViewItem* cn = firstChild(); 1085 QListViewItem* cn = firstChild();
1086 if ( cn ) { 1086 if ( cn ) {
1087 setCurrentItem ( cn ); 1087 setCurrentItem ( cn );
1088 ensureItemVisible ( cn ); 1088 ensureItemVisible ( cn );
1089 } 1089 }
1090 e->accept(); 1090 e->accept();
1091 return; 1091 return;
1092 } 1092 }
1093 if ( e->state() == ControlButton ) { 1093 if ( e->state() == ControlButton ) {
1094 int count = childCount (); 1094 int count = childCount ();
1095 int jump = count / 5; 1095 int jump = count / 5;
1096 QListViewItem* cn; 1096 QListViewItem* cn;
1097 cn = currentItem(); 1097 cn = currentItem();
1098 if ( ! cn ) 1098 if ( ! cn )
1099 return; 1099 return;
1100 if ( jump == 0 ) 1100 if ( jump == 0 )
1101 jump = 1; 1101 jump = 1;
1102 while ( jump && cn->itemAbove ()) { 1102 while ( jump && cn->itemAbove ()) {
1103 cn = cn->itemAbove (); 1103 cn = cn->itemAbove ();
1104 --jump; 1104 --jump;
1105 } 1105 }
1106 setCurrentItem ( cn ); 1106 setCurrentItem ( cn );
1107 ensureItemVisible ( cn ); 1107 ensureItemVisible ( cn );
1108 } else 1108 } else
1109 QListView::keyPressEvent ( e ) ; 1109 QListView::keyPressEvent ( e ) ;
1110 e->accept(); 1110 e->accept();
1111 break; 1111 break;
1112 case Qt::Key_I: { 1112 case Qt::Key_I: {
1113 QListViewItem* cn; 1113 QListViewItem* cn;
1114 cn = currentItem(); 1114 cn = currentItem();
1115 if ( cn ) { 1115 if ( cn ) {
1116 KOListViewItem* ci = (KOListViewItem*)( cn ); 1116 KOListViewItem* ci = (KOListViewItem*)( cn );
1117 if ( ci ){ 1117 if ( ci ){
1118 //emit showIncidence( ci->data()); 1118 //emit showIncidence( ci->data());
1119 cn = cn->nextSibling(); 1119 cn = cn->nextSibling();
1120 if ( cn ) { 1120 if ( cn ) {
1121 setCurrentItem ( cn ); 1121 setCurrentItem ( cn );
1122 ensureItemVisible ( cn ); 1122 ensureItemVisible ( cn );
1123 } 1123 }
1124 emit showIncidence( ci->data()); 1124 emit showIncidence( ci->data());
1125 } 1125 }
1126 } 1126 }
1127 e->accept(); 1127 e->accept();
1128 } 1128 }
1129 break; 1129 break;
1130 case Qt::Key_Return: 1130 case Qt::Key_Return:
1131 case Qt::Key_Enter: 1131 case Qt::Key_Enter:
1132 { 1132 {
1133 QListViewItem* cn; 1133 QListViewItem* cn;
1134 cn = currentItem(); 1134 cn = currentItem();
1135 if ( cn ) { 1135 if ( cn ) {
1136 KOListViewItem* ci = (KOListViewItem*)( cn ); 1136 KOListViewItem* ci = (KOListViewItem*)( cn );
1137 if ( ci ){ 1137 if ( ci ){
1138 if ( e->state() == ShiftButton ) 1138 if ( e->state() == ShiftButton )
1139 ci->setSelected( false ); 1139 ci->setSelected( false );
1140 else 1140 else
1141 ci->setSelected( true ); 1141 ci->setSelected( true );
1142 cn = cn->nextSibling(); 1142 cn = cn->nextSibling();
1143 if ( cn ) { 1143 if ( cn ) {
1144 setCurrentItem ( cn ); 1144 setCurrentItem ( cn );
1145 ensureItemVisible ( cn ); 1145 ensureItemVisible ( cn );
1146 } 1146 }
1147 } 1147 }
1148 } 1148 }
1149 e->accept(); 1149 e->accept();
1150 } 1150 }
1151 break; 1151 break;
1152 default: 1152 default:
1153 e->ignore(); 1153 e->ignore();
1154 } 1154 }
1155} 1155}
1156KOListViewListView::KOListViewListView(KOListView * lv ) 1156KOListViewListView::KOListViewListView(KOListView * lv )
1157 : KListView( lv ) 1157 : KListView( lv, "kolistlistview", false )
1158{ 1158{
1159 mPopupTimer = new QTimer(this);
1160 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1159#ifndef DESKTOP_VERSION 1161#ifndef DESKTOP_VERSION
1160 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1162 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1161#endif 1163#endif
1162 setSelectionMode( QListView::Multi ); 1164 setSelectionMode( QListView::Multi );
1163 setMultiSelection( true); 1165 setMultiSelection( true);
1164} 1166}
1165void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1167void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1166{ 1168{
1167 if (!e) return; 1169 if (!e) return;
1168 QPoint vp = contentsToViewport(e->pos()); 1170 QPoint vp = contentsToViewport(e->pos());
1169 QListViewItem *item = itemAt(vp); 1171 QListViewItem *item = itemAt(vp);
1170 if (!item) { 1172 if (!item) {
1171 emit newEvent(); 1173 emit newEvent();
1172 return; 1174 return;
1173 } 1175 }
1174 KListView::contentsMouseDoubleClickEvent(e); 1176 KListView::contentsMouseDoubleClickEvent(e);
1175} 1177}
1176 1178#if 0
1177void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1179void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1178{ 1180{
1179 //qDebug("contentsMousePressEvent++++ "); 1181 //qDebug("contentsMousePressEvent++++ ");
1180 KListView::contentsMousePressEvent( e ); 1182 KListView::contentsMousePressEvent( e );
1181 if ( e->button() == RightButton ) { 1183 if ( e->button() == RightButton ) {
1182 QListViewItem* ci = currentItem(); 1184 QListViewItem* ci = currentItem();
1183 clearSelection () ; 1185 clearSelection () ;
1184 if ( ci ) 1186 if ( ci )
1185 ci->setSelected( true ); 1187 ci->setSelected( true );
1186 } 1188 }
1187} 1189}
1188void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1190void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1189{ 1191{
1190 KListView::contentsMouseReleaseEvent(e); 1192 KListView::contentsMouseReleaseEvent(e);
1191} 1193}
1192void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1194void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1193{ 1195{
1194 KListView::contentsMouseMoveEvent(e); 1196 KListView::contentsMouseMoveEvent(e);
1195} 1197}
1198#endif
1199void KOListViewListView::popupMenu()
1200{
1201 mPopupTimer->stop();
1202 //qDebug("HUUUUUUUUUUUUUUUUUUUU ");
1203 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1204 QApplication::postEvent( this->viewport(), e );
1205}
1206void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1207{
1208 //qDebug("contentsMousePressEvent++++ ");
1209 mYMousePos = mapToGlobal( (e->pos())).y();
1210 if ( e->button() == LeftButton ) {
1211 mPopupTimer->start( 600 );
1212 mEventPos = e->pos();
1213 mEventGlobalPos = e->globalPos();
1214 }
1215 KListView::contentsMousePressEvent( e );
1216 if ( e->button() == RightButton ) {
1217 QListViewItem* ci = currentItem();
1218 clearSelection();
1219 if ( ci )
1220 ci->setSelected( true );
1221 }
1222}
1223void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1224{
1225 mPopupTimer->stop();
1226 KListView::contentsMouseReleaseEvent(e);
1227}
1228void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1229{
1230 // qDebug("contentsMouseMoveEv....... ");
1231 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1232 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1233 if ( diff < 0 ) diff = -diff;
1234 if ( diff > 15 )
1235 mPopupTimer->stop();
1236 else {
1237 mEventPos = e->pos();
1238 mEventGlobalPos = e->globalPos();
1239 }
1240 KListView::contentsMouseMoveEvent(e);
1241}
1242
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index eca71e2..bb0e23e 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,304 +1,311 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef _KOLISTVIEW_H 24#ifndef _KOLISTVIEW_H
25#define _KOLISTVIEW_H 25#define _KOLISTVIEW_H
26 26
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qmap.h> 28#include <qmap.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include <klistview.h> 31#include <klistview.h>
32 32
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/incidence.h> 38#include <libkcal/incidence.h>
39 39
40#include "koeventview.h" 40#include "koeventview.h"
41#include "customlistviewitem.h" 41#include "customlistviewitem.h"
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45 45
46 46
47#include <qpushbutton.h> 47#include <qpushbutton.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qdialog.h> 49#include <qdialog.h>
50#include <qtimer.h>
50#include <qcombobox.h> 51#include <qcombobox.h>
51#include <qspinbox.h> 52#include <qspinbox.h>
52#include <qtooltip.h> 53#include <qtooltip.h>
53#include <qcheckbox.h> 54#include <qcheckbox.h>
54#include <qhbox.h> 55#include <qhbox.h>
55#include <qlabel.h> 56#include <qlabel.h>
56#include <kiconloader.h> 57#include <kiconloader.h>
57#include "kfiledialog.h" 58#include "kfiledialog.h"
58#include "koprefs.h" 59#include "koprefs.h"
59class KOAlarmPrefs : public QDialog 60class KOAlarmPrefs : public QDialog
60{ 61{
61 Q_OBJECT 62 Q_OBJECT
62 public: 63 public:
63 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : 64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) :
64 QDialog( par, name, true ) 65 QDialog( par, name, true )
65 { 66 {
66 setCaption( i18n("Alarm Options") ); 67 setCaption( i18n("Alarm Options") );
67 QVBoxLayout* alarmLayout = new QVBoxLayout( this ); 68 QVBoxLayout* alarmLayout = new QVBoxLayout( this );
68 alarmLayout->setSpacing( 3 ); 69 alarmLayout->setSpacing( 3 );
69 alarmLayout->setMargin( 3 ); 70 alarmLayout->setMargin( 3 );
70 QWidget *parent = this; 71 QWidget *parent = this;
71 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); 72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent);
72 alarmLayout->addWidget(mAlarmButton); 73 alarmLayout->addWidget(mAlarmButton);
73 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
74 mAlarmTimeEdit->setValue( 15 ); 75 mAlarmTimeEdit->setValue( 15 );
75 alarmLayout->addWidget(mAlarmTimeEdit); 76 alarmLayout->addWidget(mAlarmTimeEdit);
76 mAlarmIncrCombo = new QComboBox(false, parent); 77 mAlarmIncrCombo = new QComboBox(false, parent);
77 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 78 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
78 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 79 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
79 mAlarmIncrCombo->insertItem(i18n("day(s)")); 80 mAlarmIncrCombo->insertItem(i18n("day(s)"));
80 alarmLayout->addWidget(mAlarmIncrCombo); 81 alarmLayout->addWidget(mAlarmIncrCombo);
81 QHBox * hb = new QHBox ( parent ); 82 QHBox * hb = new QHBox ( parent );
82 alarmLayout->addWidget(hb); 83 alarmLayout->addWidget(hb);
83 mAlarmSoundButton = new QPushButton(hb); 84 mAlarmSoundButton = new QPushButton(hb);
84 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 85 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
85 mAlarmSoundButton->setToggleButton(true); 86 mAlarmSoundButton->setToggleButton(true);
86 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
87 mAlarmProgramButton = new QPushButton(hb); 88 mAlarmProgramButton = new QPushButton(hb);
88 mAlarmProgramButton->setPixmap(SmallIcon("run")); 89 mAlarmProgramButton->setPixmap(SmallIcon("run"));
89 mAlarmProgramButton->setToggleButton(true); 90 mAlarmProgramButton->setToggleButton(true);
90 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
91 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
92 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
93 mAlarmLabel = new QLabel( this ); 94 mAlarmLabel = new QLabel( this );
94 alarmLayout->addWidget( mAlarmLabel ); 95 alarmLayout->addWidget( mAlarmLabel );
95 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); 96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) );
96 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
97 mAlarmSoundButton->setOn( true ); 98 mAlarmSoundButton->setOn( true );
98 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); 99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this );
99 alarmLayout->addWidget( ok ); 100 alarmLayout->addWidget( ok );
100 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
101 alarmLayout->addWidget( cancel ); 102 alarmLayout->addWidget( cancel );
102 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
103 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
104 resize( 200, 200 ); 105 resize( 200, 200 );
105 106
106 } 107 }
107 108
108 109
109 110
110 QString mAlarmSound, mAlarmProgram ; 111 QString mAlarmSound, mAlarmProgram ;
111 QCheckBox* mAlarmButton; 112 QCheckBox* mAlarmButton;
112 QSpinBox* mAlarmTimeEdit; 113 QSpinBox* mAlarmTimeEdit;
113 QLabel* mAlarmLabel; 114 QLabel* mAlarmLabel;
114 QComboBox* mAlarmIncrCombo ; 115 QComboBox* mAlarmIncrCombo ;
115 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
116private slots: 117private slots:
117 118
118void pickAlarmSound() 119void pickAlarmSound()
119{ 120{
120 //QString prefix = mAlarmSound; 121 //QString prefix = mAlarmSound;
121 if (!mAlarmSoundButton->isOn()) { 122 if (!mAlarmSoundButton->isOn()) {
122 //mAlarmSound = ""; 123 //mAlarmSound = "";
123 QToolTip::remove(mAlarmSoundButton); 124 QToolTip::remove(mAlarmSoundButton);
124 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 125 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
125 mAlarmProgramButton->setOn(true); 126 mAlarmProgramButton->setOn(true);
126 mAlarmSoundButton->setOn(false); 127 mAlarmSoundButton->setOn(false);
127 } else { 128 } else {
128 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
129 i18n("*.wav|Wav Files"), 0)); 130 i18n("*.wav|Wav Files"), 0));
130 if (!fileName.isEmpty()) { 131 if (!fileName.isEmpty()) {
131 mAlarmSound = fileName; 132 mAlarmSound = fileName;
132 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 133 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
133 QToolTip::remove(mAlarmSoundButton); 134 QToolTip::remove(mAlarmSoundButton);
134 QString dispStr = i18n("Playing '%1'").arg(fileName); 135 QString dispStr = i18n("Playing '%1'").arg(fileName);
135 QToolTip::add(mAlarmSoundButton, dispStr); 136 QToolTip::add(mAlarmSoundButton, dispStr);
136 mAlarmProgramButton->setOn(false); 137 mAlarmProgramButton->setOn(false);
137 mAlarmSoundButton->setOn(true); 138 mAlarmSoundButton->setOn(true);
138 } else { 139 } else {
139 mAlarmProgramButton->setOn(true); 140 mAlarmProgramButton->setOn(true);
140 mAlarmSoundButton->setOn(false); 141 mAlarmSoundButton->setOn(false);
141 142
142 } 143 }
143 } 144 }
144}; 145};
145 146
146void pickAlarmProgram() 147void pickAlarmProgram()
147{ 148{
148 if (!mAlarmProgramButton->isOn()) { 149 if (!mAlarmProgramButton->isOn()) {
149 //mAlarmProgram = ""; 150 //mAlarmProgram = "";
150 QToolTip::remove(mAlarmProgramButton); 151 QToolTip::remove(mAlarmProgramButton);
151 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 152 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
152 mAlarmProgramButton->setOn(false); 153 mAlarmProgramButton->setOn(false);
153 mAlarmSoundButton->setOn(true); 154 mAlarmSoundButton->setOn(true);
154 } else { 155 } else {
155 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
156 if (!fileName.isEmpty()) { 157 if (!fileName.isEmpty()) {
157 mAlarmProgram = fileName; 158 mAlarmProgram = fileName;
158 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 159 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
159 QToolTip::remove(mAlarmProgramButton); 160 QToolTip::remove(mAlarmProgramButton);
160 QString dispStr = i18n("Running '%1'").arg(fileName); 161 QString dispStr = i18n("Running '%1'").arg(fileName);
161 QToolTip::add(mAlarmProgramButton, dispStr); 162 QToolTip::add(mAlarmProgramButton, dispStr);
162 mAlarmSoundButton->setOn(false); 163 mAlarmSoundButton->setOn(false);
163 mAlarmProgramButton->setOn(true); 164 mAlarmProgramButton->setOn(true);
164 } else { 165 } else {
165 mAlarmProgramButton->setOn(false); 166 mAlarmProgramButton->setOn(false);
166 mAlarmSoundButton->setOn(true); 167 mAlarmSoundButton->setOn(true);
167 } 168 }
168 } 169 }
169}; 170};
170 171
171}; 172};
172 173
173 174
174 175
175 176
176 177
177 178
178 179
179typedef CustomListViewItem<Incidence *> KOListViewItem; 180typedef CustomListViewItem<Incidence *> KOListViewItem;
180 181
181/** 182/**
182 This class provides the initialisation of a KOListViewItem for calendar 183 This class provides the initialisation of a KOListViewItem for calendar
183 components using the Incidence::Visitor. 184 components using the Incidence::Visitor.
184*/ 185*/
185class ListItemVisitor : public Incidence::Visitor 186class ListItemVisitor : public Incidence::Visitor
186{ 187{
187 public: 188 public:
188 ListItemVisitor(KOListViewItem *, QDate d); 189 ListItemVisitor(KOListViewItem *, QDate d);
189 ~ListItemVisitor(); 190 ~ListItemVisitor();
190 191
191 bool visit(Event *); 192 bool visit(Event *);
192 bool visit(Todo *); 193 bool visit(Todo *);
193 bool visit(Journal *); 194 bool visit(Journal *);
194 195
195 private: 196 private:
196 KOListViewItem *mItem; 197 KOListViewItem *mItem;
197 QDate mDate; 198 QDate mDate;
198}; 199};
199 200
200/** 201/**
201 This class provides a multi-column list view of events. It can 202 This class provides a multi-column list view of events. It can
202 display events from one particular day or several days, it doesn't 203 display events from one particular day or several days, it doesn't
203 matter. To use a view that only handles one day at a time, use 204 matter. To use a view that only handles one day at a time, use
204 KODayListView. 205 KODayListView.
205 206
206 @short multi-column list view of various events. 207 @short multi-column list view of various events.
207 @author Preston Brown <pbrown@kde.org> 208 @author Preston Brown <pbrown@kde.org>
208 @see KOBaseView, KODayListView 209 @see KOBaseView, KODayListView
209*/ 210*/
210class KOListView; 211class KOListView;
211 212
212class KOListViewListView : public KListView 213class KOListViewListView : public KListView
213{ 214{
214 Q_OBJECT 215 Q_OBJECT
215 public: 216 public:
216 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
217 signals: 218 signals:
218 void newEvent(); 219 void newEvent();
219 void showIncidence( Incidence* ); 220 void showIncidence( Incidence* );
221 public slots:
222 void popupMenu();
220 private: 223 private:
224 QPoint mEventPos;
225 QPoint mEventGlobalPos;
226 QTimer* mPopupTimer;
227 int mYMousePos;
221 void keyPressEvent ( QKeyEvent * ) ; 228 void keyPressEvent ( QKeyEvent * ) ;
222 void contentsMouseDoubleClickEvent(QMouseEvent *e); 229 void contentsMouseDoubleClickEvent(QMouseEvent *e);
223 void contentsMousePressEvent(QMouseEvent *e); 230 void contentsMousePressEvent(QMouseEvent *e);
224 void contentsMouseReleaseEvent(QMouseEvent *e); 231 void contentsMouseReleaseEvent(QMouseEvent *e);
225 void contentsMouseMoveEvent(QMouseEvent *e); 232 void contentsMouseMoveEvent(QMouseEvent *e);
226 bool mMouseDown; 233 bool mMouseDown;
227}; 234};
228 235
229class KOListView : public KOEventView 236class KOListView : public KOEventView
230{ 237{
231 Q_OBJECT 238 Q_OBJECT
232 public: 239 public:
233 KOListView(Calendar *calendar, QWidget *parent = 0, 240 KOListView(Calendar *calendar, QWidget *parent = 0,
234 const char *name = 0); 241 const char *name = 0);
235 ~KOListView(); 242 ~KOListView();
236 243
237 virtual int maxDatesHint(); 244 virtual int maxDatesHint();
238 virtual int currentDateCount(); 245 virtual int currentDateCount();
239 virtual QPtrList<Incidence> selectedIncidences(); 246 virtual QPtrList<Incidence> selectedIncidences();
240 virtual DateList selectedDates(); 247 virtual DateList selectedDates();
241 248
242 void showDates(bool show); 249 void showDates(bool show);
243 Incidence* currentItem(); 250 Incidence* currentItem();
244 void addTodos(QPtrList<Todo> eventList); 251 void addTodos(QPtrList<Todo> eventList);
245 void addJournals(QPtrList<Journal> eventList); 252 void addJournals(QPtrList<Journal> eventList);
246 virtual void printPreview(CalPrinter *calPrinter, 253 virtual void printPreview(CalPrinter *calPrinter,
247 const QDate &, const QDate &); 254 const QDate &, const QDate &);
248 255
249 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 256 void readSettings(KConfig *config, QString setting = "KOListView Layout");
250 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 257 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
251 void updateList(); 258 void updateList();
252 void setStartDate(const QDate &start); 259 void setStartDate(const QDate &start);
253 int count(); 260 int count();
254 QString getWhatsThisText(QPoint p); 261 QString getWhatsThisText(QPoint p);
255 void resetFocus(); 262 void resetFocus();
256 signals: 263 signals:
257 void signalNewEvent(); 264 void signalNewEvent();
258 void beamIncidenceList(QPtrList<Incidence>); 265 void beamIncidenceList(QPtrList<Incidence>);
259 266
260 public slots: 267 public slots:
261 virtual void updateView(); 268 virtual void updateView();
262 virtual void showDates(const QDate &start, const QDate &end); 269 virtual void showDates(const QDate &start, const QDate &end);
263 virtual void showEvents(QPtrList<Event> eventList); 270 virtual void showEvents(QPtrList<Event> eventList);
264 void clearSelection(); 271 void clearSelection();
265 void allSelection(); 272 void allSelection();
266 273
267 void clear(); 274 void clear();
268 void beamDone( Ir *ir ); 275 void beamDone( Ir *ir );
269 void showDates(); 276 void showDates();
270 void hideDates(); 277 void hideDates();
271 void deleteAll(); 278 void deleteAll();
272 void saveToFile(); 279 void saveToFile();
273 void saveToFileVCS(); 280 void saveToFileVCS();
274 void saveDescriptionToFile(); 281 void saveDescriptionToFile();
275 void beamSelected(); 282 void beamSelected();
276 void updateConfig(); 283 void updateConfig();
277 void addCat(); 284 void addCat();
278 void setCat(); 285 void setCat();
279 void setAlarm(); 286 void setAlarm();
280 void setCategories( bool removeOld ); 287 void setCategories( bool removeOld );
281 void changeEventDisplay(Event *, int); 288 void changeEventDisplay(Event *, int);
282 289
283 void defaultItemAction(QListViewItem *item); 290 void defaultItemAction(QListViewItem *item);
284 void popupMenu(QListViewItem *item,const QPoint &,int); 291 void popupMenu(QListViewItem *item,const QPoint &,int);
285 292
286 protected slots: 293 protected slots:
287 void processSelectionChange(QListViewItem *); 294 void processSelectionChange(QListViewItem *);
288 295
289 protected: 296 protected:
290 void writeToFile( bool iCal ); 297 void writeToFile( bool iCal );
291 void addEvents(QPtrList<Event> eventList); 298 void addEvents(QPtrList<Event> eventList);
292 void addIncidence(Incidence *); 299 void addIncidence(Incidence *);
293 KOListViewItem *getItemForEvent(Event *event); 300 KOListViewItem *getItemForEvent(Event *event);
294 301
295 private: 302 private:
296 KOListViewListView *mListView; 303 KOListViewListView *mListView;
297 KOEventPopupMenu *mPopupMenu; 304 KOEventPopupMenu *mPopupMenu;
298 KOListViewItem *mActiveItem; 305 KOListViewItem *mActiveItem;
299 QDict<Incidence> mUidDict; 306 QDict<Incidence> mUidDict;
300 QDate mStartDate; 307 QDate mStartDate;
301 void keyPressEvent ( QKeyEvent * ) ; 308 void keyPressEvent ( QKeyEvent * ) ;
302}; 309};
303 310
304#endif 311#endif
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp
index 154cd02..31e2053 100644
--- a/microkde/kdeui/klistview.cpp
+++ b/microkde/kdeui/klistview.cpp
@@ -24,774 +24,775 @@
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qstyle.h> 26#include <qstyle.h>
27#include <qpainter.h> 27#include <qpainter.h>
28 28
29#include <kglobalsettings.h> 29#include <kglobalsettings.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kconfigbase.h> 31#include <kconfigbase.h>
32//US #include <kcursor.h> 32//US #include <kcursor.h>
33#include <kapplication.h> 33#include <kapplication.h>
34//US #include <kipc.h> 34//US #include <kipc.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#ifdef _WIN32_ 36#ifdef _WIN32_
37#define Q_WS_QWS 37#define Q_WS_QWS
38#endif 38#endif
39#ifndef _WIN32_ 39#ifndef _WIN32_
40#define private public 40#define private public
41#include <qlistview.h> 41#include <qlistview.h>
42#undef private 42#undef private
43#endif 43#endif
44#include "klistview.h" 44#include "klistview.h"
45//US #include "klistviewlineedit.h" 45//US #include "klistviewlineedit.h"
46#ifndef DESKTOP_VERSION 46#ifndef DESKTOP_VERSION
47#include <qpe/qpeapplication.h> 47#include <qpe/qpeapplication.h>
48#endif 48#endif
49 49
50// /*US 50// /*US
51class KListView::Tooltip : public QToolTip 51class KListView::Tooltip : public QToolTip
52{ 52{
53public: 53public:
54 Tooltip (KListView* parent, QToolTipGroup* group = 0L); 54 Tooltip (KListView* parent, QToolTipGroup* group = 0L);
55 virtual ~Tooltip () {} 55 virtual ~Tooltip () {}
56 56
57protected: 57protected:
58 // */ 58 // */
59 /** 59 /**
60 * Reimplemented from QToolTip for internal reasons. 60 * Reimplemented from QToolTip for internal reasons.
61 */ 61 */
62 // /*US 62 // /*US
63 virtual void maybeTip (const QPoint&); 63 virtual void maybeTip (const QPoint&);
64 64
65private: 65private:
66 KListView* mParent; 66 KListView* mParent;
67}; 67};
68 68
69KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) 69KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group)
70 : QToolTip (parent, group), 70 : QToolTip (parent, group),
71 mParent (parent) 71 mParent (parent)
72{ 72{
73} 73}
74 74
75void KListView::Tooltip::maybeTip (const QPoint&) 75void KListView::Tooltip::maybeTip (const QPoint&)
76{ 76{
77 // FIXME 77 // FIXME
78} 78}
79// */ 79// */
80 80
81class KListView::KListViewPrivate 81class KListView::KListViewPrivate
82{ 82{
83public: 83public:
84 KListViewPrivate (KListView* listview) 84 KListViewPrivate (KListView* listview)
85 : pCurrentItem (0L), 85 : pCurrentItem (0L),
86 autoSelectDelay(1), 86 autoSelectDelay(1),
87//US dragDelay (KGlobalSettings::dndEventDelay()), 87//US dragDelay (KGlobalSettings::dndEventDelay()),
88 88
89 dragDelay (10), 89 dragDelay (10),
90//US editor (new KListViewLineEdit (listview)), 90//US editor (new KListViewLineEdit (listview)),
91 cursorInExecuteArea(false), 91 cursorInExecuteArea(false),
92 bUseSingle(false), 92 bUseSingle(false),
93 bChangeCursorOverItem(false), 93 bChangeCursorOverItem(false),
94 itemsMovable (true), 94 itemsMovable (true),
95 selectedBySimpleMove(false), 95 selectedBySimpleMove(false),
96 selectedUsingMouse(false), 96 selectedUsingMouse(false),
97 itemsRenameable (false), 97 itemsRenameable (false),
98 validDrag (false), 98 validDrag (false),
99 dragEnabled (false), 99 dragEnabled (false),
100 autoOpen (true), 100 autoOpen (true),
101 dropVisualizer (true), 101 dropVisualizer (true),
102 dropHighlighter (false), 102 dropHighlighter (false),
103 createChildren (true), 103 createChildren (true),
104 pressedOnSelected (false), 104 pressedOnSelected (false),
105 wasShiftEvent (false), 105 wasShiftEvent (false),
106 fullWidth (false), 106 fullWidth (false),
107 sortAscending(true), 107 sortAscending(true),
108 tabRename(true), 108 tabRename(true),
109 sortColumn(0), 109 sortColumn(0),
110 selectionDirection(0), 110 selectionDirection(0),
111 tooltipColumn (0), 111 tooltipColumn (0),
112 selectionMode (Single), 112 selectionMode (Single),
113 contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()), 113 contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()),
114 showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), 114 showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()),
115 mDropVisualizerWidth (4) 115 mDropVisualizerWidth (4)
116 { 116 {
117 renameable += 0; 117 renameable += 0;
118//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); 118//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int)));
119 } 119 }
120 120
121 ~KListViewPrivate () 121 ~KListViewPrivate ()
122 { 122 {
123//US delete editor; 123//US delete editor;
124 } 124 }
125 125
126 QListViewItem* pCurrentItem; 126 QListViewItem* pCurrentItem;
127 127
128 QTimer autoSelect; 128 QTimer autoSelect;
129 int autoSelectDelay; 129 int autoSelectDelay;
130 130
131 QTimer dragExpand; 131 QTimer dragExpand;
132 QListViewItem* dragOverItem; 132 QListViewItem* dragOverItem;
133 QPoint dragOverPoint; 133 QPoint dragOverPoint;
134 134
135 QPoint startDragPos; 135 QPoint startDragPos;
136 int dragDelay; 136 int dragDelay;
137 137
138//US KListViewLineEdit *editor; 138//US KListViewLineEdit *editor;
139 QValueList<int> renameable; 139 QValueList<int> renameable;
140 140
141 bool cursorInExecuteArea:1; 141 bool cursorInExecuteArea:1;
142 bool bUseSingle:1; 142 bool bUseSingle:1;
143 bool bChangeCursorOverItem:1; 143 bool bChangeCursorOverItem:1;
144 bool itemsMovable:1; 144 bool itemsMovable:1;
145 bool selectedBySimpleMove : 1; 145 bool selectedBySimpleMove : 1;
146 bool selectedUsingMouse:1; 146 bool selectedUsingMouse:1;
147 bool itemsRenameable:1; 147 bool itemsRenameable:1;
148 bool validDrag:1; 148 bool validDrag:1;
149 bool dragEnabled:1; 149 bool dragEnabled:1;
150 bool autoOpen:1; 150 bool autoOpen:1;
151 bool dropVisualizer:1; 151 bool dropVisualizer:1;
152 bool dropHighlighter:1; 152 bool dropHighlighter:1;
153 bool createChildren:1; 153 bool createChildren:1;
154 bool pressedOnSelected:1; 154 bool pressedOnSelected:1;
155 bool wasShiftEvent:1; 155 bool wasShiftEvent:1;
156 bool fullWidth:1; 156 bool fullWidth:1;
157 bool sortAscending:1; 157 bool sortAscending:1;
158 bool tabRename:1; 158 bool tabRename:1;
159 159
160 int sortColumn; 160 int sortColumn;
161 161
162 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX 162 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX
163 int selectionDirection; 163 int selectionDirection;
164 int tooltipColumn; 164 int tooltipColumn;
165 165
166 SelectionModeExt selectionMode; 166 SelectionModeExt selectionMode;
167 int contextMenuKey; 167 int contextMenuKey;
168 bool showContextMenusOnPress; 168 bool showContextMenusOnPress;
169 169
170 QRect mOldDropVisualizer; 170 QRect mOldDropVisualizer;
171 int mDropVisualizerWidth; 171 int mDropVisualizerWidth;
172 QRect mOldDropHighlighter; 172 QRect mOldDropHighlighter;
173 QListViewItem *afterItemDrop; 173 QListViewItem *afterItemDrop;
174 QListViewItem *parentItemDrop; 174 QListViewItem *parentItemDrop;
175 175
176 QColor alternateBackground; 176 QColor alternateBackground;
177}; 177};
178 178
179/*US 179/*US
180KListViewLineEdit::KListViewLineEdit(KListView *parent) 180KListViewLineEdit::KListViewLineEdit(KListView *parent)
181 : KLineEdit(parent->viewport()), item(0), col(0), p(parent) 181 : KLineEdit(parent->viewport()), item(0), col(0), p(parent)
182{ 182{
183 setFrame( false ); 183 setFrame( false );
184 hide(); 184 hide();
185 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); 185 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() ));
186} 186}
187 187
188KListViewLineEdit::~KListViewLineEdit() 188KListViewLineEdit::~KListViewLineEdit()
189{ 189{
190} 190}
191 191
192void KListViewLineEdit::load(QListViewItem *i, int c) 192void KListViewLineEdit::load(QListViewItem *i, int c)
193{ 193{
194 item=i; 194 item=i;
195 col=c; 195 col=c;
196 196
197 QRect rect(p->itemRect(i)); 197 QRect rect(p->itemRect(i));
198 setText(item->text(c)); 198 setText(item->text(c));
199 199
200 int fieldX = rect.x() - 1; 200 int fieldX = rect.x() - 1;
201 int fieldW = p->columnWidth(col) + 2; 201 int fieldW = p->columnWidth(col) + 2;
202 202
203 int pos = p->header()->mapToIndex(col); 203 int pos = p->header()->mapToIndex(col);
204 for ( int index = 0; index < pos; index++ ) 204 for ( int index = 0; index < pos; index++ )
205 fieldX += p->columnWidth( p->header()->mapToSection( index )); 205 fieldX += p->columnWidth( p->header()->mapToSection( index ));
206 206
207 if ( col == 0 ) { 207 if ( col == 0 ) {
208 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); 208 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0);
209 d *= p->treeStepSize(); 209 d *= p->treeStepSize();
210 fieldX += d; 210 fieldX += d;
211 fieldW -= d; 211 fieldW -= d;
212 } 212 }
213 213
214 if ( i->pixmap( col ) ) {// add width of pixmap 214 if ( i->pixmap( col ) ) {// add width of pixmap
215 int d = i->pixmap( col )->width(); 215 int d = i->pixmap( col )->width();
216 fieldX += d; 216 fieldX += d;
217 fieldW -= d; 217 fieldW -= d;
218 } 218 }
219 219
220 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); 220 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2);
221 show(); 221 show();
222 setFocus(); 222 setFocus();
223} 223}
224*/ 224*/
225 /*Helper functions to for 225 /*Helper functions to for
226 *tabOrderedRename functionality. 226 *tabOrderedRename functionality.
227 */ 227 */
228 228
229static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) 229static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir)
230{ 230{
231 if (pi) 231 if (pi)
232 { 232 {
233 //Find the next renameable column in the current row 233 //Find the next renameable column in the current row
234 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) 234 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir)
235 if (pl->isRenameable(start)) 235 if (pl->isRenameable(start))
236 return start; 236 return start;
237 } 237 }
238 238
239 return -1; 239 return -1;
240} 240}
241 241
242static QListViewItem *prevItem (QListViewItem *pi) 242static QListViewItem *prevItem (QListViewItem *pi)
243{ 243{
244 QListViewItem *pa = pi->itemAbove(); 244 QListViewItem *pa = pi->itemAbove();
245 245
246 /*Does what the QListViewItem::previousSibling() 246 /*Does what the QListViewItem::previousSibling()
247 *of my dreams would do. 247 *of my dreams would do.
248 */ 248 */
249 if (pa && pa->parent() == pi->parent()) 249 if (pa && pa->parent() == pi->parent())
250 return pa; 250 return pa;
251 251
252 return NULL; 252 return NULL;
253} 253}
254 254
255static QListViewItem *lastQChild (QListViewItem *pi) 255static QListViewItem *lastQChild (QListViewItem *pi)
256{ 256{
257 if (pi) 257 if (pi)
258 { 258 {
259 /*Since there's no QListViewItem::lastChild(). 259 /*Since there's no QListViewItem::lastChild().
260 *This finds the last sibling for the given 260 *This finds the last sibling for the given
261 *item. 261 *item.
262 */ 262 */
263 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) 263 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling())
264 pi = pt; 264 pi = pt;
265 } 265 }
266 266
267 return pi; 267 return pi;
268} 268}
269/*US 269/*US
270void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) 270void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward)
271{ 271{
272 const int ncols = p->columns(); 272 const int ncols = p->columns();
273 const int dir = forward ? +1 : -1; 273 const int dir = forward ? +1 : -1;
274 const int restart = forward ? 0 : (ncols - 1); 274 const int restart = forward ? 0 : (ncols - 1);
275 QListViewItem *top = (pitem && pitem->parent()) 275 QListViewItem *top = (pitem && pitem->parent())
276 ? pitem->parent()->firstChild() 276 ? pitem->parent()->firstChild()
277 : p->firstChild(); 277 : p->firstChild();
278 QListViewItem *pi = pitem; 278 QListViewItem *pi = pitem;
279 279
280 terminate(); //Save current changes 280 terminate(); //Save current changes
281 281
282 do 282 do
283 { 283 {
284*/ 284*/
285 /*Check the rest of the current row for an editable column, 285 /*Check the rest of the current row for an editable column,
286 *if that fails, check the entire next/previous row. The 286 *if that fails, check the entire next/previous row. The
287 *last case goes back to the first item in the current branch 287 *last case goes back to the first item in the current branch
288 *or the last item in the current branch depending on the 288 *or the last item in the current branch depending on the
289 *direction. 289 *direction.
290 */ 290 */
291/*US 291/*US
292 if ((column = nextCol(p, pi, column + dir, dir)) != -1 || 292 if ((column = nextCol(p, pi, column + dir, dir)) != -1 ||
293 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || 293 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 ||
294 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) 294 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1)
295 { 295 {
296 if (pi) 296 if (pi)
297 { 297 {
298 p->setCurrentItem(pi); //Calls terminate 298 p->setCurrentItem(pi); //Calls terminate
299 p->rename(pi, column); 299 p->rename(pi, column);
300*/ 300*/
301 /*Some listviews may override rename() to 301 /*Some listviews may override rename() to
302 *prevent certain items from being renamed, 302 *prevent certain items from being renamed,
303 *if this is done, [m_]item will be NULL 303 *if this is done, [m_]item will be NULL
304 *after the rename() call... try again. 304 *after the rename() call... try again.
305 */ 305 */
306/*US 306/*US
307 if (!item) 307 if (!item)
308 continue; 308 continue;
309 309
310 break; 310 break;
311 } 311 }
312 } 312 }
313 } 313 }
314 while (pi && !item); 314 while (pi && !item);
315} 315}
316*/ 316*/
317 317
318/*US 318/*US
319#ifdef KeyPress 319#ifdef KeyPress
320#undef KeyPress 320#undef KeyPress
321#endif 321#endif
322 322
323bool KListViewLineEdit::event (QEvent *pe) 323bool KListViewLineEdit::event (QEvent *pe)
324{ 324{
325 if (pe->type() == QEvent::KeyPress) 325 if (pe->type() == QEvent::KeyPress)
326 { 326 {
327 QKeyEvent *k = (QKeyEvent *) pe; 327 QKeyEvent *k = (QKeyEvent *) pe;
328 328
329 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && 329 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
330 p->tabOrderedRenaming() && p->itemsRenameable() && 330 p->tabOrderedRenaming() && p->itemsRenameable() &&
331 !(k->state() & ControlButton || k->state() & AltButton)) 331 !(k->state() & ControlButton || k->state() & AltButton))
332 { 332 {
333 selectNextCell(item, col, 333 selectNextCell(item, col,
334 (k->key() == Key_Tab && !(k->state() & ShiftButton))); 334 (k->key() == Key_Tab && !(k->state() & ShiftButton)));
335 return true; 335 return true;
336 } 336 }
337 } 337 }
338 338
339 return KLineEdit::event(pe); 339 return KLineEdit::event(pe);
340} 340}
341 341
342void KListViewLineEdit::keyPressEvent(QKeyEvent *e) 342void KListViewLineEdit::keyPressEvent(QKeyEvent *e)
343{ 343{
344 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) 344 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
345 terminate(true); 345 terminate(true);
346 else if(e->key() == Qt::Key_Escape) 346 else if(e->key() == Qt::Key_Escape)
347 terminate(false); 347 terminate(false);
348 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) 348 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up)
349 { 349 {
350 terminate(true); 350 terminate(true);
351 KLineEdit::keyPressEvent(e); 351 KLineEdit::keyPressEvent(e);
352 } 352 }
353 else 353 else
354 KLineEdit::keyPressEvent(e); 354 KLineEdit::keyPressEvent(e);
355} 355}
356 356
357void KListViewLineEdit::terminate() 357void KListViewLineEdit::terminate()
358{ 358{
359 terminate(true); 359 terminate(true);
360} 360}
361 361
362void KListViewLineEdit::terminate(bool commit) 362void KListViewLineEdit::terminate(bool commit)
363{ 363{
364 if ( item ) 364 if ( item )
365 { 365 {
366 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; 366 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl;
367 if (commit) 367 if (commit)
368 item->setText(col, text()); 368 item->setText(col, text());
369 int c=col; 369 int c=col;
370 QListViewItem *i=item; 370 QListViewItem *i=item;
371 col=0; 371 col=0;
372 item=0; 372 item=0;
373 hide(); // will call focusOutEvent, that's why we set item=0 before 373 hide(); // will call focusOutEvent, that's why we set item=0 before
374 emit done(i,c); 374 emit done(i,c);
375 } 375 }
376} 376}
377 377
378void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) 378void KListViewLineEdit::focusOutEvent(QFocusEvent *ev)
379{ 379{
380 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); 380 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev);
381 // Don't let a RMB close the editor 381 // Don't let a RMB close the editor
382 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) 382 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow)
383 terminate(true); 383 terminate(true);
384} 384}
385 385
386void KListViewLineEdit::paintEvent( QPaintEvent *e ) 386void KListViewLineEdit::paintEvent( QPaintEvent *e )
387{ 387{
388 KLineEdit::paintEvent( e ); 388 KLineEdit::paintEvent( e );
389 389
390 if ( !frame() ) { 390 if ( !frame() ) {
391 QPainter p( this ); 391 QPainter p( this );
392 p.setClipRegion( e->region() ); 392 p.setClipRegion( e->region() );
393 p.drawRect( rect() ); 393 p.drawRect( rect() );
394 } 394 }
395} 395}
396 396
397// selection changed -> terminate. As our "item" can be already deleted, 397// selection changed -> terminate. As our "item" can be already deleted,
398// we can't call terminate(false), because that would emit done() with 398// we can't call terminate(false), because that would emit done() with
399// a dangling pointer to "item". 399// a dangling pointer to "item".
400void KListViewLineEdit::slotSelectionChanged() 400void KListViewLineEdit::slotSelectionChanged()
401{ 401{
402 item = 0; 402 item = 0;
403 col = 0; 403 col = 0;
404 hide(); 404 hide();
405} 405}
406*/ 406*/
407 407
408KListView::KListView( QWidget *parent, const char *name ) 408KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse )
409 : QListView( parent, name ), 409 : QListView( parent, name ),
410 d (new KListViewPrivate (this)) 410 d (new KListViewPrivate (this))
411{ 411{
412#ifndef DESKTOP_VERSION 412#ifndef DESKTOP_VERSION
413 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 413 if ( emulateRightMouse )
414 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
414#endif 415#endif
415//US setDragAutoScroll(true); 416//US setDragAutoScroll(true);
416 417
417 connect( this, SIGNAL( onViewport() ), 418 connect( this, SIGNAL( onViewport() ),
418 this, SLOT( slotOnViewport() ) ); 419 this, SLOT( slotOnViewport() ) );
419 connect( this, SIGNAL( onItem( QListViewItem * ) ), 420 connect( this, SIGNAL( onItem( QListViewItem * ) ),
420 this, SLOT( slotOnItem( QListViewItem * ) ) ); 421 this, SLOT( slotOnItem( QListViewItem * ) ) );
421 422
422 connect (this, SIGNAL(contentsMoving(int,int)), 423 connect (this, SIGNAL(contentsMoving(int,int)),
423 this, SLOT(cleanDropVisualizer())); 424 this, SLOT(cleanDropVisualizer()));
424 connect (this, SIGNAL(contentsMoving(int,int)), 425 connect (this, SIGNAL(contentsMoving(int,int)),
425 this, SLOT(cleanItemHighlighter())); 426 this, SLOT(cleanItemHighlighter()));
426 427
427/*US 428/*US
428 slotSettingsChanged(KApplication::SETTINGS_MOUSE); 429 slotSettingsChanged(KApplication::SETTINGS_MOUSE);
429 430
430 if (kapp) 431 if (kapp)
431 { 432 {
432 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); 433 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) );
433 kapp->addKipcEventMask( KIPC::SettingsChanged ); 434 kapp->addKipcEventMask( KIPC::SettingsChanged );
434 } 435 }
435*/ 436*/
436 slotSettingsChanged(1); //US do this to initialize the connections 437 slotSettingsChanged(1); //US do this to initialize the connections
437 438
438 439
439 connect(&d->autoSelect, SIGNAL( timeout() ), 440 connect(&d->autoSelect, SIGNAL( timeout() ),
440 this, SLOT( slotAutoSelect() ) ); 441 this, SLOT( slotAutoSelect() ) );
441 connect(&d->dragExpand, SIGNAL( timeout() ), 442 connect(&d->dragExpand, SIGNAL( timeout() ),
442 this, SLOT( slotDragExpand() ) ); 443 this, SLOT( slotDragExpand() ) );
443 444
444 // context menu handling 445 // context menu handling
445 if (d->showContextMenusOnPress) 446 if (d->showContextMenusOnPress)
446 { 447 {
447 connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 448 connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)),
448 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 449 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
449 } 450 }
450 else 451 else
451 { 452 {
452 connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 453 connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)),
453 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 454 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
454 } 455 }
455 456
456 connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), 457 connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)),
457 this, SLOT (emitContextMenu (KListView*, QListViewItem*))); 458 this, SLOT (emitContextMenu (KListView*, QListViewItem*)));
458 459
459 460
460 //qDebug("KListView::KListView make alternate color configurable"); 461 //qDebug("KListView::KListView make alternate color configurable");
461//US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); 462//US d->alternateBackground = KGlobalSettings::alternateBackgroundColor();
462 d->alternateBackground = QColor(240, 240, 240); 463 d->alternateBackground = QColor(240, 240, 240);
463} 464}
464 465
465 466
466 467
467KListView::~KListView() 468KListView::~KListView()
468{ 469{
469 delete d; 470 delete d;
470} 471}
471 472
472bool KListView::isExecuteArea( const QPoint& point ) 473bool KListView::isExecuteArea( const QPoint& point )
473{ 474{
474 if ( itemAt( point ) ) 475 if ( itemAt( point ) )
475 return isExecuteArea( point.x() ); 476 return isExecuteArea( point.x() );
476 477
477 return false; 478 return false;
478} 479}
479 480
480bool KListView::isExecuteArea( int x ) 481bool KListView::isExecuteArea( int x )
481{ 482{
482 if( allColumnsShowFocus() ) 483 if( allColumnsShowFocus() )
483 return true; 484 return true;
484 else { 485 else {
485 int offset = 0; 486 int offset = 0;
486 int width = columnWidth( 0 ); 487 int width = columnWidth( 0 );
487 int pos = header()->mapToIndex( 0 ); 488 int pos = header()->mapToIndex( 0 );
488 489
489 for ( int index = 0; index < pos; index++ ) 490 for ( int index = 0; index < pos; index++ )
490 offset += columnWidth( header()->mapToSection( index ) ); 491 offset += columnWidth( header()->mapToSection( index ) );
491 492
492 x += contentsX(); // in case of a horizontal scrollbar 493 x += contentsX(); // in case of a horizontal scrollbar
493 return ( x > offset && x < ( offset + width ) ); 494 return ( x > offset && x < ( offset + width ) );
494 } 495 }
495} 496}
496 497
497void KListView::slotOnItem( QListViewItem *item ) 498void KListView::slotOnItem( QListViewItem *item )
498{ 499{
499 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); 500 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() );
500 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { 501 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) {
501 d->autoSelect.start( d->autoSelectDelay, true ); 502 d->autoSelect.start( d->autoSelectDelay, true );
502 d->pCurrentItem = item; 503 d->pCurrentItem = item;
503 } 504 }
504} 505}
505 506
506void KListView::slotOnViewport() 507void KListView::slotOnViewport()
507{ 508{
508 if ( d->bChangeCursorOverItem ) 509 if ( d->bChangeCursorOverItem )
509 viewport()->unsetCursor(); 510 viewport()->unsetCursor();
510 511
511 d->autoSelect.stop(); 512 d->autoSelect.stop();
512 d->pCurrentItem = 0L; 513 d->pCurrentItem = 0L;
513} 514}
514 515
515void KListView::slotSettingsChanged(int category) 516void KListView::slotSettingsChanged(int category)
516{ 517{
517 //qDebug("KListView::slotSettingsChanged has to be verified"); 518 //qDebug("KListView::slotSettingsChanged has to be verified");
518 519
519 520
520 switch (category) 521 switch (category)
521 { 522 {
522 //US I create my private category (=1) to set the settings 523 //US I create my private category (=1) to set the settings
523 case 1: 524 case 1:
524 d->dragDelay = 2; 525 d->dragDelay = 2;
525 //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); 526 //US set explicitly d->bUseSingle = KGlobalSettings::singleClick();
526 // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); 527 // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle);
527 528
528 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 529 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
529 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); 530 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int)));
530 531
531 if( d->bUseSingle ) 532 if( d->bUseSingle )
532 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 533 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
533 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 534 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int)));
534 535
535 //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 536 //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
536 //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); 537 //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
537 538
538 if( !d->bUseSingle || !d->bChangeCursorOverItem ) 539 if( !d->bUseSingle || !d->bChangeCursorOverItem )
539 viewport()->unsetCursor(); 540 viewport()->unsetCursor();
540 541
541 break; 542 break;
542 543
543 /*US 544 /*US
544 case KApplication::SETTINGS_MOUSE: 545 case KApplication::SETTINGS_MOUSE:
545 d->dragDelay = KGlobalSettings::dndEventDelay(); 546 d->dragDelay = KGlobalSettings::dndEventDelay();
546 d->bUseSingle = KGlobalSettings::singleClick(); 547 d->bUseSingle = KGlobalSettings::singleClick();
547 548
548 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 549 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
549 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); 550 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int)));
550 551
551 if( d->bUseSingle ) 552 if( d->bUseSingle )
552 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 553 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
553 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 554 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int)));
554 555
555 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 556 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
556 d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); 557 d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
557 558
558 if( !d->bUseSingle || !d->bChangeCursorOverItem ) 559 if( !d->bUseSingle || !d->bChangeCursorOverItem )
559 viewport()->unsetCursor(); 560 viewport()->unsetCursor();
560 561
561 break; 562 break;
562 case KApplication::SETTINGS_POPUPMENU: 563 case KApplication::SETTINGS_POPUPMENU:
563 d->contextMenuKey = KGlobalSettings::contextMenuKey (); 564 d->contextMenuKey = KGlobalSettings::contextMenuKey ();
564 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); 565 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress ();
565 566
566 if (d->showContextMenusOnPress) 567 if (d->showContextMenusOnPress)
567 { 568 {
568 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 569 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
569 570
570 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 571 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)),
571 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 572 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
572 } 573 }
573 else 574 else
574 { 575 {
575 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 576 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
576 577
577 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 578 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)),
578 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 579 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
579 } 580 }
580 break; 581 break;
581 */ 582 */
582 583
583 default: 584 default:
584 break; 585 break;
585 } 586 }
586 587
587} 588}
588 589
589void KListView::slotAutoSelect() 590void KListView::slotAutoSelect()
590{ 591{
591 // check that the item still exists 592 // check that the item still exists
592 if( itemIndex( d->pCurrentItem ) == -1 ) 593 if( itemIndex( d->pCurrentItem ) == -1 )
593 return; 594 return;
594 595
595 if (!isActiveWindow()) 596 if (!isActiveWindow())
596 { 597 {
597 d->autoSelect.stop(); 598 d->autoSelect.stop();
598 return; 599 return;
599 } 600 }
600 601
601 //Give this widget the keyboard focus. 602 //Give this widget the keyboard focus.
602 if( !hasFocus() ) 603 if( !hasFocus() )
603 setFocus(); 604 setFocus();
604 605
605 QListViewItem* previousItem = currentItem(); 606 QListViewItem* previousItem = currentItem();
606 setCurrentItem( d->pCurrentItem ); 607 setCurrentItem( d->pCurrentItem );
607 608
608#if 0 609#if 0
609#ifndef Q_WS_QWS 610#ifndef Q_WS_QWS
610 // FIXME(E): Implement for Qt Embedded 611 // FIXME(E): Implement for Qt Embedded
611 if( d->pCurrentItem ) { 612 if( d->pCurrentItem ) {
612 //Shift pressed? 613 //Shift pressed?
613 if( (keybstate & ShiftMask) ) { 614 if( (keybstate & ShiftMask) ) {
614 bool block = signalsBlocked(); 615 bool block = signalsBlocked();
615 blockSignals( true ); 616 blockSignals( true );
616 617
617 //No Ctrl? Then clear before! 618 //No Ctrl? Then clear before!
618 if( !(keybstate & ControlMask) ) 619 if( !(keybstate & ControlMask) )
619 clearSelection(); 620 clearSelection();
620 621
621 bool select = !d->pCurrentItem->isSelected(); 622 bool select = !d->pCurrentItem->isSelected();
622 bool update = viewport()->isUpdatesEnabled(); 623 bool update = viewport()->isUpdatesEnabled();
623 viewport()->setUpdatesEnabled( false ); 624 viewport()->setUpdatesEnabled( false );
624 625
625 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); 626 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos();
626 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); 627 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem );
627 for ( ; lit.current(); ++lit ) { 628 for ( ; lit.current(); ++lit ) {
628 if ( down && lit.current() == d->pCurrentItem ) { 629 if ( down && lit.current() == d->pCurrentItem ) {
629 d->pCurrentItem->setSelected( select ); 630 d->pCurrentItem->setSelected( select );
630 break; 631 break;
631 } 632 }
632 if ( !down && lit.current() == previousItem ) { 633 if ( !down && lit.current() == previousItem ) {
633 previousItem->setSelected( select ); 634 previousItem->setSelected( select );
634 break; 635 break;
635 } 636 }
636 lit.current()->setSelected( select ); 637 lit.current()->setSelected( select );
637 } 638 }
638 639
639 blockSignals( block ); 640 blockSignals( block );
640 viewport()->setUpdatesEnabled( update ); 641 viewport()->setUpdatesEnabled( update );
641 triggerUpdate(); 642 triggerUpdate();
642 643
643 emit selectionChanged(); 644 emit selectionChanged();
644 645
645 if( selectionMode() == QListView::Single ) 646 if( selectionMode() == QListView::Single )
646 emit selectionChanged( d->pCurrentItem ); 647 emit selectionChanged( d->pCurrentItem );
647 } 648 }
648 else if( (keybstate & ControlMask) ) 649 else if( (keybstate & ControlMask) )
649 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); 650 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() );
650 else { 651 else {
651 bool block = signalsBlocked(); 652 bool block = signalsBlocked();
652 blockSignals( true ); 653 blockSignals( true );
653 654
654 if( !d->pCurrentItem->isSelected() ) 655 if( !d->pCurrentItem->isSelected() )
655 clearSelection(); 656 clearSelection();
656 657
657 blockSignals( block ); 658 blockSignals( block );
658 659
659 setSelected( d->pCurrentItem, true ); 660 setSelected( d->pCurrentItem, true );
660 } 661 }
661 } 662 }
662 else 663 else
663 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; 664 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl;
664#endif 665#endif
665#endif 666#endif
666} 667}
667 668
668void KListView::slotHeaderChanged() 669void KListView::slotHeaderChanged()
669{ 670{
670 if (d->fullWidth && columns()) 671 if (d->fullWidth && columns())
671 { 672 {
672 int w = 0; 673 int w = 0;
673 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); 674 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i);
674 setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); 675 setColumnWidth( columns() - 1, viewport()->width() - w - 1 );
675 } 676 }
676} 677}
677 678
678void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) 679void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c)
679{ 680{
680 // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); 681 // qDebug("KListView::emitExecute buttonstate=%i", buttonstate);
681 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { 682 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) {
682 683
683 // Double click mode ? 684 // Double click mode ?
684 if ( !d->bUseSingle ) 685 if ( !d->bUseSingle )
685 { 686 {
686 emit executed( item ); 687 emit executed( item );
687 emit executed( item, pos, c ); 688 emit executed( item, pos, c );
688 } 689 }
689 else 690 else
690 { 691 {
691 //US special implementation for embedded systems 692 //US special implementation for embedded systems
692 d->autoSelect.stop(); 693 d->autoSelect.stop();
693 694
694 //Dont emit executed if in SC mode and Shift or Ctrl are pressed 695 //Dont emit executed if in SC mode and Shift or Ctrl are pressed
695 if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { 696 if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) {
696 // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { 697 // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) {
697 698
698 emit executed( item ); 699 emit executed( item );
699 emit executed( item, pos, c ); 700 emit executed( item, pos, c );
700 } 701 }
701 } 702 }
702 } 703 }
703} 704}
704 705
705void KListView::focusInEvent( QFocusEvent *fe ) 706void KListView::focusInEvent( QFocusEvent *fe )
706{ 707{
707 // kdDebug()<<"KListView::focusInEvent()"<<endl; 708 // kdDebug()<<"KListView::focusInEvent()"<<endl;
708 QListView::focusInEvent( fe ); 709 QListView::focusInEvent( fe );
709 if ((d->selectedBySimpleMove) 710 if ((d->selectedBySimpleMove)
710 && (d->selectionMode == FileManager) 711 && (d->selectionMode == FileManager)
711 && (fe->reason()!=QFocusEvent::Popup) 712 && (fe->reason()!=QFocusEvent::Popup)
712 && (fe->reason()!=QFocusEvent::ActiveWindow) 713 && (fe->reason()!=QFocusEvent::ActiveWindow)
713 && (currentItem()!=0)) 714 && (currentItem()!=0))
714 { 715 {
715 currentItem()->setSelected(true); 716 currentItem()->setSelected(true);
716 currentItem()->repaint(); 717 currentItem()->repaint();
717 emit selectionChanged(); 718 emit selectionChanged();
718 }; 719 };
719} 720}
720 721
721void KListView::focusOutEvent( QFocusEvent *fe ) 722void KListView::focusOutEvent( QFocusEvent *fe )
722{ 723{
723 cleanDropVisualizer(); 724 cleanDropVisualizer();
724 cleanItemHighlighter(); 725 cleanItemHighlighter();
725 726
726 d->autoSelect.stop(); 727 d->autoSelect.stop();
727 728
728 if ((d->selectedBySimpleMove) 729 if ((d->selectedBySimpleMove)
729 && (d->selectionMode == FileManager) 730 && (d->selectionMode == FileManager)
730 && (fe->reason()!=QFocusEvent::Popup) 731 && (fe->reason()!=QFocusEvent::Popup)
731 && (fe->reason()!=QFocusEvent::ActiveWindow) 732 && (fe->reason()!=QFocusEvent::ActiveWindow)
732 && (currentItem()!=0) 733 && (currentItem()!=0)
733/*US && (!d->editor->isVisible()) */ 734/*US && (!d->editor->isVisible()) */
734 ) 735 )
735 { 736 {
736 currentItem()->setSelected(false); 737 currentItem()->setSelected(false);
737 currentItem()->repaint(); 738 currentItem()->repaint();
738 emit selectionChanged(); 739 emit selectionChanged();
739 }; 740 };
740 741
741 QListView::focusOutEvent( fe ); 742 QListView::focusOutEvent( fe );
742} 743}
743 744
744void KListView::leaveEvent( QEvent *e ) 745void KListView::leaveEvent( QEvent *e )
745{ 746{
746 d->autoSelect.stop(); 747 d->autoSelect.stop();
747 748
748 QListView::leaveEvent( e ); 749 QListView::leaveEvent( e );
749} 750}
750 751
751bool KListView::event( QEvent *e ) 752bool KListView::event( QEvent *e )
752{ 753{
753 if (e->type() == QEvent::ApplicationPaletteChange) { 754 if (e->type() == QEvent::ApplicationPaletteChange) {
754 //qDebug("KListView::event make alternate color configurable"); 755 //qDebug("KListView::event make alternate color configurable");
755//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); 756//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor();
756 d->alternateBackground = QColor(240, 240, 240); 757 d->alternateBackground = QColor(240, 240, 240);
757 } 758 }
758 759
759 return QListView::event(e); 760 return QListView::event(e);
760} 761}
761 762
762void KListView::contentsMousePressEvent( QMouseEvent *e ) 763void KListView::contentsMousePressEvent( QMouseEvent *e )
763{ 764{
764 //qDebug("KListView::contentsMousePressEvent"); 765 //qDebug("KListView::contentsMousePressEvent");
765 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) 766 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) )
766 { 767 {
767 bool block = signalsBlocked(); 768 bool block = signalsBlocked();
768 blockSignals( true ); 769 blockSignals( true );
769 770
770 clearSelection(); 771 clearSelection();
771 772
772 blockSignals( block ); 773 blockSignals( block );
773 } 774 }
774 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) 775 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove))
775 { 776 {
776 d->selectedBySimpleMove=false; 777 d->selectedBySimpleMove=false;
777 d->selectedUsingMouse=true; 778 d->selectedUsingMouse=true;
778 if (currentItem()!=0) 779 if (currentItem()!=0)
779 { 780 {
780 currentItem()->setSelected(false); 781 currentItem()->setSelected(false);
781 currentItem()->repaint(); 782 currentItem()->repaint();
782// emit selectionChanged(); 783// emit selectionChanged();
783 }; 784 };
784 }; 785 };
785 786
786 QPoint p( contentsToViewport( e->pos() ) ); 787 QPoint p( contentsToViewport( e->pos() ) );
787 QListViewItem *at = itemAt (p); 788 QListViewItem *at = itemAt (p);
788 789
789 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 790 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
790 bool rootDecoClicked = at 791 bool rootDecoClicked = at
791 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 792 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
792 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 793 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
793 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 794 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
794 795
795 if (e->button() == LeftButton && !rootDecoClicked) 796 if (e->button() == LeftButton && !rootDecoClicked)
796 { 797 {
797 //Start a drag 798 //Start a drag
diff --git a/microkde/kdeui/klistview.h b/microkde/kdeui/klistview.h
index d559ce7..0058416 100644
--- a/microkde/kdeui/klistview.h
+++ b/microkde/kdeui/klistview.h
@@ -1,510 +1,510 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2000 Charles Samuels <charles@kde.org> 3 Copyright (C) 2000 Charles Samuels <charles@kde.org>
4 Copyright (C) 2000 Peter Putzer <putzer@kde.org> 4 Copyright (C) 2000 Peter Putzer <putzer@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KLISTVIEW_H 20#ifndef KLISTVIEW_H
21#define KLISTVIEW_H 21#define KLISTVIEW_H
22 22
23#include <qlistview.h> 23#include <qlistview.h>
24 24
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27//US 27//US
28class QDropEvent; 28class QDropEvent;
29class QDragLeaveEvent; 29class QDragLeaveEvent;
30class QDragMoveEvent; 30class QDragMoveEvent;
31class QDragEnterEvent; 31class QDragEnterEvent;
32 32
33class QDragObject; 33class QDragObject;
34class KConfig; 34class KConfig;
35class KLineEdit; 35class KLineEdit;
36/** 36/**
37 * This Widget extends the functionality of QListView to honor the system 37 * This Widget extends the functionality of QListView to honor the system
38 * wide settings for Single Click/Double Click mode, AutoSelection and 38 * wide settings for Single Click/Double Click mode, AutoSelection and
39 * ChangeCursorOverLink (TM). 39 * ChangeCursorOverLink (TM).
40 * 40 *
41 * There is a new signal executed(). It gets connected to either 41 * There is a new signal executed(). It gets connected to either
42 * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE 42 * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE
43 * wide Single Click/Double Click settings. It is strongly recommended that 43 * wide Single Click/Double Click settings. It is strongly recommended that
44 * you use this signal instead of the above mentioned. This way you dont 44 * you use this signal instead of the above mentioned. This way you dont
45 * need to care about the current settings. 45 * need to care about the current settings.
46 * If you want to get informed when the user selects something connect to the 46 * If you want to get informed when the user selects something connect to the
47 * QListView::selectionChanged() signal. 47 * QListView::selectionChanged() signal.
48 * 48 *
49 * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) 49 * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true)
50 * and connect it to a suitable slot. 50 * and connect it to a suitable slot.
51 * To see where you are dropping, @ref setDropVisualizer(true). 51 * To see where you are dropping, @ref setDropVisualizer(true).
52 * And also you'll need @ref acceptDrag(QDropEvent*) 52 * And also you'll need @ref acceptDrag(QDropEvent*)
53 * 53 *
54 * KListView is drag-enabled, too: to benefit from that you've got derive from it. 54 * KListView is drag-enabled, too: to benefit from that you've got derive from it.
55 * Reimplement @ref dragObject() and (possibly) @ref startDrag(), 55 * Reimplement @ref dragObject() and (possibly) @ref startDrag(),
56 * and @ref setDragEnabled(true). 56 * and @ref setDragEnabled(true).
57 * 57 *
58 * @version $Id$ 58 * @version $Id$
59 */ 59 */
60class KListView : public QListView 60class KListView : public QListView
61{ 61{
62 Q_OBJECT 62 Q_OBJECT
63 Q_ENUMS( SelectionModeExt ) 63 Q_ENUMS( SelectionModeExt )
64 Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) 64 Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth )
65 Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) 65 Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable )
66 Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) 66 Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable )
67 Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) 67 Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled )
68 Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) 68 Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen )
69 Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) 69 Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer )
70//US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) 70//US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn )
71 Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) 71 Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth )
72 Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) 72 Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground )
73 73
74 Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) 74 Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt )
75 75
76public: 76public:
77 /** 77 /**
78 * Possible selection modes. 78 * Possible selection modes.
79 * 79 *
80 * The first four correspond directly to QListView::SelectionMode, while 80 * The first four correspond directly to QListView::SelectionMode, while
81 * the FileManager selection mode is defined as follows: 81 * the FileManager selection mode is defined as follows:
82 * @li home: move to the first 82 * @li home: move to the first
83 * @li end: move to the last 83 * @li end: move to the last
84 * @li PgUp/PgDn: move one page up/down 84 * @li PgUp/PgDn: move one page up/down
85 * @li up/down: move one item up/down 85 * @li up/down: move one item up/down
86 * @li insert: toggle selection of current and move to the next 86 * @li insert: toggle selection of current and move to the next
87 * @li space: toggle selection of the current 87 * @li space: toggle selection of the current
88 * @li CTRL+up: move to the previous item and toggle selection of this one 88 * @li CTRL+up: move to the previous item and toggle selection of this one
89 * @li CTRL+down: toggle selection of the current item and move to the next 89 * @li CTRL+down: toggle selection of the current item and move to the next
90 * @li CTRL+end: toggle selection from (including) the current 90 * @li CTRL+end: toggle selection from (including) the current
91 * item to (including) the last item 91 * item to (including) the last item
92 * @li CTRL+home: toggle selection from (including) the current 92 * @li CTRL+home: toggle selection from (including) the current
93 * item to the (including) the first item 93 * item to the (including) the first item
94 * @li CTRL+PgDn: toggle selection from (including) the current 94 * @li CTRL+PgDn: toggle selection from (including) the current
95 * item to (excluding) the item one page down 95 * item to (excluding) the item one page down
96 * @li CTRL+PgUp: toggle selection from (excluding) the current 96 * @li CTRL+PgUp: toggle selection from (excluding) the current
97 * item to (including) the item one page up 97 * item to (including) the item one page up
98 * 98 *
99 * The combinations work the same with SHIFT instead of CTRL, except 99 * The combinations work the same with SHIFT instead of CTRL, except
100 * that if you start selecting something using SHIFT everything selected 100 * that if you start selecting something using SHIFT everything selected
101 * before will be deselected first. 101 * before will be deselected first.
102 * 102 *
103 * Additionally the current item is always selected automatically when 103 * Additionally the current item is always selected automatically when
104 * navigating using the keyboard, except other items were selected explicitely. 104 * navigating using the keyboard, except other items were selected explicitely.
105 * 105 *
106 * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected 106 * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected
107 */ 107 */
108 enum SelectionModeExt { 108 enum SelectionModeExt {
109 Single = QListView::Single, 109 Single = QListView::Single,
110 Multi = QListView::Multi, 110 Multi = QListView::Multi,
111 Extended = QListView::Extended, 111 Extended = QListView::Extended,
112 NoSelection = QListView::NoSelection, 112 NoSelection = QListView::NoSelection,
113 FileManager 113 FileManager
114 }; 114 };
115 void repaintContents( bool erase = true ) 115 void repaintContents( bool erase = true )
116 { 116 {
117 QScrollView::repaintContents( contentsX(), contentsY(), 117 QScrollView::repaintContents( contentsX(), contentsY(),
118 visibleWidth(), visibleHeight(), erase ); 118 visibleWidth(), visibleHeight(), erase );
119 }; 119 };
120 /** 120 /**
121 * Constructor. 121 * Constructor.
122 * 122 *
123 * The parameters @p parent and @p name are handled by 123 * The parameters @p parent and @p name are handled by
124 * @ref QListView, as usual. 124 * @ref QListView, as usual.
125 */ 125 */
126 KListView (QWidget *parent = 0, const char *name = 0); 126 KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true );
127 127
128 /** 128 /**
129 * Destructor. 129 * Destructor.
130 */ 130 */
131 virtual ~KListView(); 131 virtual ~KListView();
132 132
133 /** 133 /**
134 * Reimplemented for internal reasons. 134 * Reimplemented for internal reasons.
135 * Further reimplementations should call this function or else 135 * Further reimplementations should call this function or else
136 * some features may not work correctly. 136 * some features may not work correctly.
137 * 137 *
138 * The API is unaffected. 138 * The API is unaffected.
139 */ 139 */
140 virtual void setAcceptDrops (bool); 140 virtual void setAcceptDrops (bool);
141 141
142 /** 142 /**
143 * This function determines whether the given coordinates are within the 143 * This function determines whether the given coordinates are within the
144 * execute area. The execute area is the part of a @ref QListViewItem where mouse 144 * execute area. The execute area is the part of a @ref QListViewItem where mouse
145 * clicks or double clicks respectively generate a @ref #executed() signal. 145 * clicks or double clicks respectively generate a @ref #executed() signal.
146 * Depending on @ref QListView::allColumnsShowFocus() this is either the 146 * Depending on @ref QListView::allColumnsShowFocus() this is either the
147 * whole item or only the first column. 147 * whole item or only the first column.
148 * @return true if point is inside execute area of an item, false in all 148 * @return true if point is inside execute area of an item, false in all
149 * other cases including the case that it is over the viewport. 149 * other cases including the case that it is over the viewport.
150 */ 150 */
151 virtual bool isExecuteArea( const QPoint& point ); 151 virtual bool isExecuteArea( const QPoint& point );
152 152
153 /** 153 /**
154 * Same thing, but from an x coordinate only. This only checks if x is in 154 * Same thing, but from an x coordinate only. This only checks if x is in
155 * the first column (if all columns don't show focus), without testing if 155 * the first column (if all columns don't show focus), without testing if
156 * the y coordinate is over an item or not. 156 * the y coordinate is over an item or not.
157 */ 157 */
158 bool isExecuteArea( int x ); 158 bool isExecuteArea( int x );
159 159
160 /** 160 /**
161 * @return a list containing the currently selected items. 161 * @return a list containing the currently selected items.
162 */ 162 */
163 QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) 163 QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?)
164 164
165 /** 165 /**
166 * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. 166 * Arbitrarily move @p item to @p parent, positioned immediately after item @p after.
167 */ 167 */
168 void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); 168 void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after);
169 169
170 /** 170 /**
171 * @return the last item (not child!) of this listview. 171 * @return the last item (not child!) of this listview.
172 * 172 *
173 * @see lastChild() 173 * @see lastChild()
174 */ 174 */
175 QListViewItem *lastItem() const; 175 QListViewItem *lastItem() const;
176 176
177 /** 177 /**
178 * @return the last child of this listview. 178 * @return the last child of this listview.
179 * 179 *
180 * @see lastItem() 180 * @see lastItem()
181 */ 181 */
182 QListViewItem* lastChild () const; 182 QListViewItem* lastChild () const;
183 183
184 /** 184 /**
185 * @return the lineedit used for inline renaming. 185 * @return the lineedit used for inline renaming.
186 * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit 186 * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit
187 * 187 *
188 * @since 3.2 188 * @since 3.2
189 */ 189 */
190 KLineEdit* renameLineEdit() const; 190 KLineEdit* renameLineEdit() const;
191 191
192 /** 192 /**
193 * @returns if it is legal to move items in the list view. True by default. 193 * @returns if it is legal to move items in the list view. True by default.
194 * 194 *
195 * @see #setDragEnabled() 195 * @see #setDragEnabled()
196 * @see #setItemsMovable() 196 * @see #setItemsMovable()
197 */ 197 */
198 bool itemsMovable() const; 198 bool itemsMovable() const;
199 199
200 /** 200 /**
201 * @return whether inplace-renaming has been enabled. False by default. 201 * @return whether inplace-renaming has been enabled. False by default.
202 * 202 *
203 * @see #setItemsRenameable() 203 * @see #setItemsRenameable()
204 */ 204 */
205 bool itemsRenameable() const; 205 bool itemsRenameable() const;
206 206
207 /** 207 /**
208 * @return whether dragging is enabled. False by default. 208 * @return whether dragging is enabled. False by default.
209 * 209 *
210 * @see #setDragEnabled() 210 * @see #setDragEnabled()
211 */ 211 */
212 bool dragEnabled() const; 212 bool dragEnabled() const;
213 213
214 /** 214 /**
215 * @return true if AutoOpen is enabled (not implemented currently). 215 * @return true if AutoOpen is enabled (not implemented currently).
216 * 216 *
217 * @see #setAutoOpen() 217 * @see #setAutoOpen()
218 */ 218 */
219 bool autoOpen() const; 219 bool autoOpen() const;
220 220
221 /** 221 /**
222 * @return true if @p column is renamable. 222 * @return true if @p column is renamable.
223 * 223 *
224 * @see #setRenameable() 224 * @see #setRenameable()
225 */ 225 */
226 bool isRenameable (int column) const; 226 bool isRenameable (int column) const;
227 227
228 /** 228 /**
229 * @return true if drawing of the drop-visualizer has been enabled. True by default. 229 * @return true if drawing of the drop-visualizer has been enabled. True by default.
230 * 230 *
231 * @see #setDropVisualizer() 231 * @see #setDropVisualizer()
232 */ 232 */
233 bool dropVisualizer() const; 233 bool dropVisualizer() const;
234 234
235 /** 235 /**
236 * @return the column for which tooltips are displayed (or -1 if none set). 236 * @return the column for which tooltips are displayed (or -1 if none set).
237 * 237 *
238 * @see #setTooltipColumn() 238 * @see #setTooltipColumn()
239 */ 239 */
240 int tooltipColumn() const; 240 int tooltipColumn() const;
241 241
242 /** 242 /**
243 * For future expansions. 243 * For future expansions.
244 * 244 *
245 * Do not use. 245 * Do not use.
246 * @deprecated 246 * @deprecated
247 */ 247 */
248 bool createChildren() const; 248 bool createChildren() const;
249 249
250 /** 250 /**
251 * @return true if drawing of the drop-highlighter has been enabled. False by default. 251 * @return true if drawing of the drop-highlighter has been enabled. False by default.
252 * 252 *
253 * @see #setDropHighlighter() 253 * @see #setDropHighlighter()
254 */ 254 */
255 bool dropHighlighter() const; 255 bool dropHighlighter() const;
256 256
257 /** 257 /**
258 * The dropVisualizerWidth defaults to 4. 258 * The dropVisualizerWidth defaults to 4.
259 * 259 *
260 * @see #setDropVisualizerWidth() 260 * @see #setDropVisualizerWidth()
261 * @return the current width of the drop-visualizer. 261 * @return the current width of the drop-visualizer.
262 */ 262 */
263 int dropVisualizerWidth () const; 263 int dropVisualizerWidth () const;
264 264
265 /** 265 /**
266 * @return the "extended" selection mode of this listview. 266 * @return the "extended" selection mode of this listview.
267 * 267 *
268 * @see SelectionModeExt 268 * @see SelectionModeExt
269 * @see setSelectionModeExt 269 * @see setSelectionModeExt
270 */ 270 */
271 SelectionModeExt selectionModeExt () const; 271 SelectionModeExt selectionModeExt () const;
272 272
273 /** 273 /**
274 * Returns the index of @p item within the item tree or -1 if 274 * Returns the index of @p item within the item tree or -1 if
275 * @p item doesn't exist in this list view. This function takes 275 * @p item doesn't exist in this list view. This function takes
276 * all items into account not only the visible ones. 276 * all items into account not only the visible ones.
277 */ 277 */
278 int itemIndex( const QListViewItem *item ) const; 278 int itemIndex( const QListViewItem *item ) const;
279 279
280 /** 280 /**
281 * Returns the item of @p index within the item tree or 0 if 281 * Returns the item of @p index within the item tree or 0 if
282 * @p index doesn't exist in this list view. This function takes 282 * @p index doesn't exist in this list view. This function takes
283 * all items into account not only the visible ones. 283 * all items into account not only the visible ones.
284 */ 284 */
285 QListViewItem* itemAtIndex(int index); 285 QListViewItem* itemAtIndex(int index);
286 286
287 /** 287 /**
288 * @deprecated 288 * @deprecated
289 * @see #setFullWidth() 289 * @see #setFullWidth()
290 */ 290 */
291 void setFullWidth(); 291 void setFullWidth();
292 292
293 /** 293 /**
294 * Let the last column fit exactly all the available width. 294 * Let the last column fit exactly all the available width.
295 * 295 *
296 * @see #fullWidth() 296 * @see #fullWidth()
297 */ 297 */
298 void setFullWidth(bool fullWidth); 298 void setFullWidth(bool fullWidth);
299 299
300 /** 300 /**
301 * Returns whether the last column is set to fit the available width. 301 * Returns whether the last column is set to fit the available width.
302 * 302 *
303 * @see #setFullWidth() 303 * @see #setFullWidth()
304 */ 304 */
305 bool fullWidth() const; 305 bool fullWidth() const;
306 306
307 /** 307 /**
308 * Reimplemented for full width support 308 * Reimplemented for full width support
309 * 309 *
310 * @see #removeColumn() 310 * @see #removeColumn()
311 */ 311 */
312 virtual int addColumn(const QString& label, int width = -1); 312 virtual int addColumn(const QString& label, int width = -1);
313 /** 313 /**
314 * Reimplemented for full width support 314 * Reimplemented for full width support
315 */ 315 */
316 virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); 316 virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1);
317 /** 317 /**
318 * Reimplemented for full width support 318 * Reimplemented for full width support
319 * 319 *
320 * @see #addColumn() 320 * @see #addColumn()
321 */ 321 */
322 virtual void removeColumn(int index); 322 virtual void removeColumn(int index);
323 323
324 /** 324 /**
325 * sets the alternate background background color. 325 * sets the alternate background background color.
326 * This only has an effect if the items are KListViewItems 326 * This only has an effect if the items are KListViewItems
327 * 327 *
328 * @param c the color to use for every other item. Set to an invalid 328 * @param c the color to use for every other item. Set to an invalid
329 * colour to disable alternate colours. 329 * colour to disable alternate colours.
330 * 330 *
331 * @see #alternateBackground() 331 * @see #alternateBackground()
332 **/ 332 **/
333 void setAlternateBackground(const QColor &c); 333 void setAlternateBackground(const QColor &c);
334 /** 334 /**
335 * @return the alternate background color 335 * @return the alternate background color
336 * 336 *
337 * @see #setAlternateBackground() 337 * @see #setAlternateBackground()
338 */ 338 */
339 const QColor &alternateBackground() const; 339 const QColor &alternateBackground() const;
340 340
341 /** 341 /**
342 * Saves the list view's layout (column widtsh, column order, sort column) 342 * Saves the list view's layout (column widtsh, column order, sort column)
343 * to a KConfig group 343 * to a KConfig group
344 * 344 *
345 * @param config the @ref KConfig object to write to 345 * @param config the @ref KConfig object to write to
346 * @param group the config group to use 346 * @param group the config group to use
347 */ 347 */
348 void saveLayout(KConfig *config, const QString &group) const; 348 void saveLayout(KConfig *config, const QString &group) const;
349 /** 349 /**
350 * Reads the list view's layout from a KConfig group as stored with 350 * Reads the list view's layout from a KConfig group as stored with
351 * @ref #saveLayout 351 * @ref #saveLayout
352 * 352 *
353 * @param config the @ref KConfig object to read from 353 * @param config the @ref KConfig object to read from
354 * @param group the config group to use 354 * @param group the config group to use
355 */ 355 */
356 void restoreLayout(KConfig *config, const QString &group); 356 void restoreLayout(KConfig *config, const QString &group);
357 /** 357 /**
358 * Reimplemented to remember the current sort column and order. 358 * Reimplemented to remember the current sort column and order.
359 * @param column is the column to be sorted, or -1 to sort in order of 359 * @param column is the column to be sorted, or -1 to sort in order of
360 * insertion 360 * insertion
361 * @param whether to sort ascending (or descending) 361 * @param whether to sort ascending (or descending)
362 */ 362 */
363 virtual void setSorting(int column, bool ascending = true); 363 virtual void setSorting(int column, bool ascending = true);
364 364
365 /** 365 /**
366 * @return the currently sorted column, or -1 if none is sorted 366 * @return the currently sorted column, or -1 if none is sorted
367 */ 367 */
368 int columnSorted(void) const; 368 int columnSorted(void) const;
369 369
370 /** 370 /**
371 * @return whether the current sort is ascending (or descending) 371 * @return whether the current sort is ascending (or descending)
372 */ 372 */
373 bool ascendingSort(void) const; 373 bool ascendingSort(void) const;
374 374
375 //US we do not have a "global KDE" variable to setup singleClick functionality 375 //US we do not have a "global KDE" variable to setup singleClick functionality
376 void setSingleClick(bool s); 376 void setSingleClick(bool s);
377 377
378 378
379signals: 379signals:
380 380
381 /** 381 /**
382 * This signal is emitted whenever the user executes an listview item. 382 * This signal is emitted whenever the user executes an listview item.
383 * That means depending on the KDE wide Single Click/Double Click 383 * That means depending on the KDE wide Single Click/Double Click
384 * setting the user clicked or double clicked on that item. 384 * setting the user clicked or double clicked on that item.
385 * @param item is the pointer to the executed listview item. 385 * @param item is the pointer to the executed listview item.
386 * 386 *
387 * Note that you may not delete any @ref QListViewItem objects in slots 387 * Note that you may not delete any @ref QListViewItem objects in slots
388 * connected to this signal. 388 * connected to this signal.
389 */ 389 */
390 void executed( QListViewItem *item ); 390 void executed( QListViewItem *item );
391 391
392 /** 392 /**
393 * This signal is emitted whenever the user executes an listview item. 393 * This signal is emitted whenever the user executes an listview item.
394 * That means depending on the KDE wide Single Click/Double Click 394 * That means depending on the KDE wide Single Click/Double Click
395 * setting the user clicked or double clicked on that item. 395 * setting the user clicked or double clicked on that item.
396 * @param item is the pointer to the executed listview item. 396 * @param item is the pointer to the executed listview item.
397 * @param pos is the position where the user has clicked 397 * @param pos is the position where the user has clicked
398 * @param c is the column into which the user clicked. 398 * @param c is the column into which the user clicked.
399 * 399 *
400 * Note that you may not delete any @ref QListViewItem objects in slots 400 * Note that you may not delete any @ref QListViewItem objects in slots
401 * connected to this signal. 401 * connected to this signal.
402 */ 402 */
403 void executed( QListViewItem *item, const QPoint &pos, int c ); 403 void executed( QListViewItem *item, const QPoint &pos, int c );
404 404
405 /** 405 /**
406 * This signal gets emitted whenever the user double clicks into the 406 * This signal gets emitted whenever the user double clicks into the
407 * listview. 407 * listview.
408 * @param item is the pointer to the clicked listview item. 408 * @param item is the pointer to the clicked listview item.
409 * @param pos is the position where the user has clicked, and 409 * @param pos is the position where the user has clicked, and
410 * @param c is the column into which the user clicked. 410 * @param c is the column into which the user clicked.
411 * 411 *
412 * Note that you may not delete any @ref QListViewItem objects in slots 412 * Note that you may not delete any @ref QListViewItem objects in slots
413 * connected to this signal. 413 * connected to this signal.
414 * 414 *
415 * This signal is more or less here for the sake of completeness. 415 * This signal is more or less here for the sake of completeness.
416 * You should normally not need to use this. In most cases its better 416 * You should normally not need to use this. In most cases its better
417 * to use @ref #executed() instead. 417 * to use @ref #executed() instead.
418 */ 418 */
419 void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); 419 void doubleClicked( QListViewItem *item, const QPoint &pos, int c );
420 void contextRequest( QListViewItem *item, const QPoint &pos, int c ); 420 void contextRequest( QListViewItem *item, const QPoint &pos, int c );
421 421
422 /** 422 /**
423 * This signal gets emitted whenever something acceptable is 423 * This signal gets emitted whenever something acceptable is
424 * dropped onto the listview. 424 * dropped onto the listview.
425 * 425 *
426 * @param e is the drop event itself (it has already been accepted) 426 * @param e is the drop event itself (it has already been accepted)
427 * @param after is the item after which the drop occured (or 0L, if 427 * @param after is the item after which the drop occured (or 0L, if
428 * the drop was above all items) 428 * the drop was above all items)
429 * 429 *
430 * @see #acceptDrop() 430 * @see #acceptDrop()
431 */ 431 */
432 void dropped (QDropEvent * e, QListViewItem *after); 432 void dropped (QDropEvent * e, QListViewItem *after);
433 433
434 /** 434 /**
435 * This signal gets emitted whenever something acceptable is 435 * This signal gets emitted whenever something acceptable is
436 * dropped onto the listview. 436 * dropped onto the listview.
437 * 437 *
438 * This is an overloaded version of the above (provided to simplify 438 * This is an overloaded version of the above (provided to simplify
439 * processing drops outside of the class). 439 * processing drops outside of the class).
440 * 440 *
441 * @param list is the listview 441 * @param list is the listview
442 * @param e is the drop event itself (it has already been accepted) 442 * @param e is the drop event itself (it has already been accepted)
443 * @param after is the item after which the drop occured (or 0L, if 443 * @param after is the item after which the drop occured (or 0L, if
444 * the drop was above all items 444 * the drop was above all items
445 */ 445 */
446 void dropped (KListView* list, QDropEvent* e, QListViewItem* after); 446 void dropped (KListView* list, QDropEvent* e, QListViewItem* after);
447 447
448 /** 448 /**
449 * This signal gets emitted whenever something acceptable is 449 * This signal gets emitted whenever something acceptable is
450 * dropped onto the listview. 450 * dropped onto the listview.
451 * 451 *
452 * This function also provides a parent, in the event that your listview 452 * This function also provides a parent, in the event that your listview
453 * is a tree 453 * is a tree
454 * @param list is the listview 454 * @param list is the listview
455 * @param e is the drop event itself (it has already been accepted) 455 * @param e is the drop event itself (it has already been accepted)
456 * @param parent the item that is to be the parent of the new item 456 * @param parent the item that is to be the parent of the new item
457 * @param after is the item after which the drop occured (or 0L, if 457 * @param after is the item after which the drop occured (or 0L, if
458 * the drop was above all items 458 * the drop was above all items
459 */ 459 */
460 void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); 460 void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after);
461 461
462 /** 462 /**
463 * This signal gets emitted whenever something acceptable is 463 * This signal gets emitted whenever something acceptable is
464 * dropped onto the listview. 464 * dropped onto the listview.
465 * 465 *
466 * This function also provides a parent, in the event that your listview 466 * This function also provides a parent, in the event that your listview
467 * is a tree 467 * is a tree
468 * @param e is the drop event itself (it has already been accepted) 468 * @param e is the drop event itself (it has already been accepted)
469 * @param parent the item that is to be the parent of the new item 469 * @param parent the item that is to be the parent of the new item
470 * @param after is the item after which the drop occured (or 0L, if 470 * @param after is the item after which the drop occured (or 0L, if
471 * the drop was above all items 471 * the drop was above all items
472 */ 472 */
473 void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); 473 void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after);
474 474
475 /** 475 /**
476 * This signal is emitted when ever the user moves an item in the list via 476 * This signal is emitted when ever the user moves an item in the list via
477 * DnD. 477 * DnD.
478 * If more than one item is moved at the same time, this signal is only emitted 478 * If more than one item is moved at the same time, this signal is only emitted
479 * once. 479 * once.
480 */ 480 */
481 void moved(); 481 void moved();
482 482
483 /** 483 /**
484 * Connect to this signal if you want to do some preprocessing before 484 * Connect to this signal if you want to do some preprocessing before
485 * a move is made, for example, to disable sorting 485 * a move is made, for example, to disable sorting
486 * 486 *
487 * This is sent only once per each groups of moves. That is, for each 487 * This is sent only once per each groups of moves. That is, for each
488 * drop that is a move this will be emitted once, before KListView calls 488 * drop that is a move this will be emitted once, before KListView calls
489 * @see moveItem() 489 * @see moveItem()
490 */ 490 */
491 void aboutToMove(); 491 void aboutToMove();
492 492
493 /** 493 /**
494 * This signal is emitted when ever the user moves an item in the list via 494 * This signal is emitted when ever the user moves an item in the list via
495 * DnD. 495 * DnD.
496 * If more than one item is moved at the same time, @p afterFirst and 496 * If more than one item is moved at the same time, @p afterFirst and
497 * @p afterNow will reflect what was true before the move. 497 * @p afterNow will reflect what was true before the move.
498 * This differs from @ref moved(), so be careful. All the items will have been 498 * This differs from @ref moved(), so be careful. All the items will have been
499 * moved before @ref moved() is emitted, which is not true in this method. // FIXME 499 * moved before @ref moved() is emitted, which is not true in this method. // FIXME
500 * @param item the item that was moved 500 * @param item the item that was moved
501 * @param afterFirst the item that parameter item was in before the move, in the list 501 * @param afterFirst the item that parameter item was in before the move, in the list
502 * @param afterNow the item it's currently after. 502 * @param afterNow the item it's currently after.
503 */ 503 */
504 void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); 504 void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow);
505 505
506 506
507 /** 507 /**
508 * This signal is emitted after all the items have been moved. It reports info for 508 * This signal is emitted after all the items have been moved. It reports info for
509 * each and every item moved, in order. The first element in @p items associates 509 * each and every item moved, in order. The first element in @p items associates
510 * with the first of afterFirst and afterNow. 510 * with the first of afterFirst and afterNow.