-rw-r--r-- | bin/kdepim/WhatsNew.txt | 2 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 195 | ||||
-rw-r--r-- | korganizer/koagenda.h | 6 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 14 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 55 | ||||
-rw-r--r-- | korganizer/kolistview.h | 7 | ||||
-rw-r--r-- | microkde/kdeui/klistview.cpp | 5 | ||||
-rw-r--r-- | microkde/kdeui/klistview.h | 2 |
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 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.0.21 ************ | 3 | ********** VERSION 2.0.21 ************ |
4 | 4 | ||
5 | Fixed another SMTP problem in OM/Pi. | 5 | Fixed another SMTP problem in OM/Pi. |
6 | Some small changed in the new datenavigator in KO/Pi. | 6 | Some small changed in the new datenavigator in KO/Pi. |
7 | Changed default setting for new filter in KA/Pi to "exclude categories". | 7 | Changed default setting for new filter in KA/Pi to "exclude categories". |
8 | Changed the default font size for 640x480 display . | 8 | Changed the default font size for 640x480 display . |
9 | Changed popup menu behaviour in agenda and list view. | 9 | Changed popup menu behaviour in agenda and list view. |
10 | Fixed some layout problems of the date label size in the month view. | 10 | Fixed some layout problems of the date label size in the month view. |
11 | Made month view update faster. | 11 | Made month view update faster. |
12 | Made first datenavigator repainting faster. | 12 | Made first datenavigator repainting faster. |
13 | Changed the title of the event/todo edit dialogs. | 13 | Changed the title of the event/todo edit dialogs. |
14 | Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). | ||
15 | Please 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 | ||
18 | Two small fixes in OM/Pi. | 20 | Two small fixes in OM/Pi. |
19 | 21 | ||
20 | Better resizing of the new datenavigator in KO/Pi. | 22 | Better resizing of the new datenavigator in KO/Pi. |
21 | 23 | ||
22 | ********** VERSION 2.0.19 ************ | 24 | ********** VERSION 2.0.19 ************ |
23 | KO/Pi: | 25 | KO/Pi: |
24 | Enhancements and bugfixes in the new datenavigator. | 26 | Enhancements and bugfixes in the new datenavigator. |
25 | Bugfix in this changelog: | 27 | Bugfix in this changelog: |
26 | The datenavigator was changed in version 2.0.18, not the datepicker. | 28 | The datenavigator was changed in version 2.0.18, not the datepicker. |
27 | 29 | ||
28 | ********** VERSION 2.0.18 ************ | 30 | ********** VERSION 2.0.18 ************ |
29 | KO/Pi: | 31 | KO/Pi: |
30 | Fixed some minor problems. | 32 | Fixed some minor problems. |
31 | Cleaned up the KO/Pi config dialog. | 33 | Cleaned up the KO/Pi config dialog. |
32 | Fixed problem moving events in aganda view. | 34 | Fixed problem moving events in aganda view. |
33 | Made datepicker scaleable, i.e. if the datenavigator shows now a | 35 | Made datepicker scaleable, i.e. if the datenavigator shows now a |
34 | datenavigator matrix depending on its size. | 36 | datenavigator matrix depending on its size. |
35 | Birthdays are now displayed green in the datenavigator. | 37 | Birthdays are now displayed green in the datenavigator. |
36 | What'sThis Help in datenavigator shows all events of the day. | 38 | What'sThis Help in datenavigator shows all events of the day. |
37 | 39 | ||
38 | OM/Pi: | 40 | OM/Pi: |
39 | Updated the backend mail library to the latest version. | 41 | Updated the backend mail library to the latest version. |
40 | Please backup your mail before using this version. | 42 | Please backup your mail before using this version. |
41 | 43 | ||
42 | ********** VERSION 2.0.17 ************ | 44 | ********** VERSION 2.0.17 ************ |
43 | 45 | ||
44 | KO/Pi: | 46 | KO/Pi: |
45 | Tooltips in month view were not sorted. Fixed. | 47 | Tooltips in month view were not sorted. Fixed. |
46 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. | 48 | Daylabel in agenda view ( for display of one day ) was too short. Fixed. |
47 | Conflict display dialog for syncing was not on top of other windows. Fixed. | 49 | Conflict display dialog for syncing was not on top of other windows. Fixed. |
48 | Fixed some minor problems. | 50 | Fixed some minor problems. |
49 | 51 | ||
50 | Fixed an endless loop when importing vcs file with RESOURCES entry. | 52 | Fixed an endless loop when importing vcs file with RESOURCES entry. |
51 | 53 | ||
52 | ********** VERSION 2.0.16 ************ | 54 | ********** VERSION 2.0.16 ************ |
53 | OM/Pi: | 55 | OM/Pi: |
54 | Fixed the SMTP account setting the option. | 56 | Fixed the SMTP account setting the option. |
55 | Fixed something in mail sending. | 57 | Fixed something in mail sending. |
56 | 58 | ||
57 | KO/Pi: | 59 | KO/Pi: |
58 | Added possibility to export selected events/todos as vcal file. | 60 | Added possibility to export selected events/todos as vcal file. |
59 | 61 | ||
60 | ********** VERSION 2.0.15 ************ | 62 | ********** VERSION 2.0.15 ************ |
61 | 63 | ||
62 | PwM/Pi: | 64 | PwM/Pi: |
63 | Added keyboard shorcuts for | 65 | Added 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) |
67 | Fixed length of info in the title. | 69 | Fixed length of info in the title. |
68 | 70 | ||
69 | KO/Pi-KA/Pi: | 71 | KO/Pi-KA/Pi: |
70 | Changed "ME" menu bar entry to an icon. | 72 | Changed "ME" menu bar entry to an icon. |
71 | 73 | ||
72 | KO/Pi: | 74 | KO/Pi: |
73 | Fixed two minor bugs in displaying todos. | 75 | Fixed two minor bugs in displaying todos. |
74 | If in month view a cell is selected, the key shortcut "d" shows now that date. | 76 | If in month view a cell is selected, the key shortcut "d" shows now that date. |
75 | Added complete info for a todo in month view as an icon left of the text. | 77 | Added complete info for a todo in month view as an icon left of the text. |
76 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. | 78 | Fixed problems of displaying data when "<" or ">" are used in summary/location/description. |
77 | Fixed problem of search dialog size when switching displays. | 79 | Fixed problem of search dialog size when switching displays. |
78 | Cancel key now closes date picker. | 80 | Cancel key now closes date picker. |
79 | Rearranged KO/Pi file menu structure. | 81 | Rearranged KO/Pi file menu structure. |
80 | 82 | ||
81 | OM/Pi: | 83 | OM/Pi: |
82 | Added to the SMTP account setting the option | 84 | Added to the SMTP account setting the option |
83 | "No secure connection". | 85 | "No secure connection". |
84 | You have to configure your SMTP accounts again, sorry. | 86 | You have to configure your SMTP accounts again, sorry. |
85 | 87 | ||
86 | KA/Pi: | 88 | KA/Pi: |
87 | Added support for importing quoted-printable. | 89 | Added support for importing quoted-printable. |
88 | Support was added by Peter P.. Thanks, Peter! | 90 | Support was added by Peter P.. Thanks, Peter! |
89 | 91 | ||
90 | 92 | ||
91 | ********** VERSION 2.0.14 ************ | 93 | ********** VERSION 2.0.14 ************ |
92 | 94 | ||
93 | Made Passwordmanager PwM/Pi more userfriendly: | 95 | Made Passwordmanager PwM/Pi more userfriendly: |
94 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. | 96 | Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. |
95 | Fixed bug in KO/Pi todo printing. | 97 | Fixed bug in KO/Pi todo printing. |
96 | Made Qtopia calendar import possible on desktop . | 98 | Made Qtopia calendar import possible on desktop . |
97 | 99 | ||
98 | ********** VERSION 2.0.13 ************ | 100 | ********** VERSION 2.0.13 ************ |
99 | 101 | ||
100 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. | 102 | Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. |
101 | 103 | ||
102 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". | 104 | In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". |
103 | 105 | ||
104 | OM/Pi: | 106 | OM/Pi: |
105 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. | 107 | Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. |
106 | Added missing German translation. | 108 | Added missing German translation. |
107 | Added warning if path is specified in local folder settings of account config. | 109 | Added 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 | ||
111 | KO/Pi: | 113 | KO/Pi: |
112 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. | 114 | Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. |
113 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. | 115 | Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. |
114 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. | 116 | Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. |
115 | 117 | ||
116 | Fixed problem in pi-sync mode when wrong password was sent. | 118 | Fixed problem in pi-sync mode when wrong password was sent. |
117 | 119 | ||
118 | OM/Pi: | 120 | OM/Pi: |
119 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. | 121 | Fixed a crash when displaying mails with "Show mail as html" was checked in the config. |
120 | Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. | 122 | Added 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 | ||
124 | Fixed some problems in pi-sync mode | 126 | Fixed 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 | ||
129 | KO/Pi: | 131 | KO/Pi: |
130 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. | 132 | In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. |
131 | This is fixed. | 133 | This is fixed. |
132 | Changed the search dialog a bit to make it more user friendly. | 134 | Changed 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 | ||
135 | Added config option to hide the week number in KO/Pi toolbar. | 137 | Added 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 | ||
139 | Made month view icons for multiday events a bit nicer. | 141 | Made month view icons for multiday events a bit nicer. |
140 | Some minor fixes in KO/Pi | 142 | Some 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 | ||
146 | Fixed a problem in dependency info in the ipk files for the Zaurus. | 148 | Fixed a problem in dependency info in the ipk files for the Zaurus. |
147 | 149 | ||
148 | Added 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. | 150 | Added 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 | ||
150 | Added a "go today" button to the datepicker. | 152 | Added a "go today" button to the datepicker. |
151 | 153 | ||
152 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) | 154 | Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) |
153 | and made it configureable to show these values. | 155 | and made it configureable to show these values. |
154 | 156 | ||
155 | Fixed a problem for events (from external iCal files) that do have a duration but no end date. | 157 | Fixed 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 | ||
160 | Added global application font settings | 162 | Added 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 | ||
163 | Fixed a problem in OM/Pi when trying to login to some IMAP servers | 165 | Fixed 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 | ||
166 | Added recurring todos to KO/Pi. | 168 | Added recurring todos to KO/Pi. |
167 | 169 | ||
168 | 170 | ||
169 | ********** VERSION 2.0.6 ************ | 171 | ********** VERSION 2.0.6 ************ |
170 | 172 | ||
171 | Stable release 2.0.6! | 173 | Stable release 2.0.6! |
172 | 174 | ||
173 | Some bugfixes in the pi-sync mode. | 175 | Some bugfixes in the pi-sync mode. |
174 | Added German translation for pi-sync mode. | 176 | Added German translation for pi-sync mode. |
175 | 177 | ||
176 | KO/Pi: | 178 | KO/Pi: |
177 | Made the todolist using alternate background. | 179 | Made the todolist using alternate background. |
178 | 180 | ||
179 | Other minor fixes in KO/Pi. | 181 | Other minor fixes in KO/Pi. |
180 | 182 | ||
181 | 183 | ||
182 | You can find the complete changelog | 184 | You can find the complete changelog |
183 | from version 1.7.7 to 2.0.5 | 185 | from version 1.7.7 to 2.0.5 |
184 | in the source package or on | 186 | in the source package or on |
185 | 187 | ||
186 | http://www.pi-sync.net/html/changelog.html | 188 | http://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,2053 +1,2238 @@ | |||
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; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::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 | ||
86 | MarcusBains::~MarcusBains() | 85 | MarcusBains::~MarcusBains() |
87 | { | 86 | { |
88 | delete minutes; | 87 | delete minutes; |
89 | } | 88 | } |
90 | 89 | ||
91 | int MarcusBains::todayColumn() | 90 | int 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 | } |
107 | void MarcusBains::updateLoc() | 106 | void MarcusBains::updateLoc() |
108 | { | 107 | { |
109 | updateLocation(); | 108 | updateLocation(); |
110 | } | 109 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 110 | void 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 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 166 | KOAgenda::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 | */ |
188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 187 | KOAgenda::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 | ||
205 | KOAgenda::~KOAgenda() | 204 | KOAgenda::~KOAgenda() |
206 | { | 205 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 206 | if(mMarcusBains) delete mMarcusBains; |
208 | 207 | ||
209 | } | 208 | } |
210 | 209 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 210 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 211 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 212 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 213 | } |
215 | 214 | ||
216 | 215 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 216 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 217 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 218 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 219 | } |
221 | 220 | ||
222 | 221 | ||
223 | void KOAgenda::init() | 222 | void 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 | ||
317 | void KOAgenda::clear() | 321 | void 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 | ||
329 | void KOAgenda::clearSelection() | 333 | void 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 | ||
336 | void KOAgenda::marcus_bains() | 340 | void KOAgenda::marcus_bains() |
337 | { | 341 | { |
338 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 342 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
339 | } | 343 | } |
340 | 344 | ||
341 | 345 | ||
342 | void KOAgenda::changeColumns(int columns) | 346 | void 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 | */ |
366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 370 | bool 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 | 389 | void 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 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 414 | bool 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 | ||
564 | void KOAgenda::newItem( int item ) | 749 | void 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 | } |
581 | void KOAgenda::startSelectAction(QPoint viewportPos) | 766 | void 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 | ||
616 | void KOAgenda::performSelectAction(QPoint viewportPos) | 801 | void 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 | ||
670 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 855 | void 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 | ||
683 | void KOAgenda::startItemAction(QPoint viewportPos) | 868 | void 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 | ||
731 | void KOAgenda::performItemAction(QPoint viewportPos) | 916 | void 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 | ||
850 | void KOAgenda::endItemAction() | 1035 | void 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); |
946 | } | 1131 | } |
947 | placeItem = placeItem->nextMultiItem(); | 1132 | placeItem = placeItem->nextMultiItem(); |
948 | } | 1133 | } |
949 | /* | 1134 | /* |
950 | 1135 | ||
951 | oldconflictItems = modifiedItem->conflictItems(); | 1136 | oldconflictItems = modifiedItem->conflictItems(); |
952 | for ( item=oldconflictItems.first(); item != 0; | 1137 | for ( item=oldconflictItems.first(); item != 0; |
953 | item=oldconflictItems.next() ) { | 1138 | item=oldconflictItems.next() ) { |
954 | globalFlagBlockAgendaItemUpdate = 0; | 1139 | globalFlagBlockAgendaItemUpdate = 0; |
955 | item->paintMe(false); | 1140 | item->paintMe(false); |
956 | globalFlagBlockAgendaItemUpdate = 1; | 1141 | globalFlagBlockAgendaItemUpdate = 1; |
957 | item->repaint(false); | 1142 | item->repaint(false); |
958 | } | 1143 | } |
959 | */ | 1144 | */ |
960 | 1145 | ||
961 | 1146 | ||
962 | } | 1147 | } |
963 | 1148 | ||
964 | } | 1149 | } |
965 | 1150 | ||
966 | mScrollUpTimer.stop(); | 1151 | mScrollUpTimer.stop(); |
967 | mScrollDownTimer.stop(); | 1152 | mScrollDownTimer.stop(); |
968 | setCursor( arrowCursor ); | 1153 | setCursor( arrowCursor ); |
969 | mActionItem = 0; | 1154 | mActionItem = 0; |
970 | mActionType = NOP; | 1155 | mActionType = NOP; |
971 | mItemMoved = 0; | 1156 | mItemMoved = 0; |
972 | 1157 | ||
973 | } | 1158 | } |
974 | 1159 | ||
975 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1160 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
976 | { | 1161 | { |
977 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1162 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
978 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1163 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
979 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1164 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
980 | // point = clipper()->mapFromGlobal(point); | 1165 | // point = clipper()->mapFromGlobal(point); |
981 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1166 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
982 | 1167 | ||
983 | int x,y; | 1168 | int x,y; |
984 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1169 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
985 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1170 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
986 | int gx,gy; | 1171 | int gx,gy; |
987 | contentsToGrid(x,y,gx,gy); | 1172 | contentsToGrid(x,y,gx,gy); |
988 | 1173 | ||
989 | // Change cursor to resize cursor if appropriate | 1174 | // Change cursor to resize cursor if appropriate |
990 | if (mAllDayMode) { | 1175 | if (mAllDayMode) { |
991 | int gridDistanceX = (x - gx * mGridSpacingX); | 1176 | int gridDistanceX = (x - gx * mGridSpacingX); |
992 | if (gridDistanceX < mResizeBorderWidth && | 1177 | if (gridDistanceX < mResizeBorderWidth && |
993 | moveItem->cellX() == gx) { | 1178 | moveItem->cellX() == gx) { |
994 | setCursor(sizeHorCursor); | 1179 | setCursor(sizeHorCursor); |
995 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1180 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
996 | moveItem->cellXWidth() == gx) { | 1181 | moveItem->cellXWidth() == gx) { |
997 | setCursor(sizeHorCursor); | 1182 | setCursor(sizeHorCursor); |
998 | } else { | 1183 | } else { |
999 | setCursor(arrowCursor); | 1184 | setCursor(arrowCursor); |
1000 | } | 1185 | } |
1001 | } else { | 1186 | } else { |
1002 | int gridDistanceY = (y - gy * mGridSpacingY); | 1187 | int gridDistanceY = (y - gy * mGridSpacingY); |
1003 | if (gridDistanceY < mResizeBorderWidth && | 1188 | if (gridDistanceY < mResizeBorderWidth && |
1004 | moveItem->cellYTop() == gy && | 1189 | moveItem->cellYTop() == gy && |
1005 | !moveItem->firstMultiItem()) { | 1190 | !moveItem->firstMultiItem()) { |
1006 | setCursor(sizeVerCursor); | 1191 | setCursor(sizeVerCursor); |
1007 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1192 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1008 | moveItem->cellYBottom() == gy && | 1193 | moveItem->cellYBottom() == gy && |
1009 | !moveItem->lastMultiItem()) { | 1194 | !moveItem->lastMultiItem()) { |
1010 | setCursor(sizeVerCursor); | 1195 | setCursor(sizeVerCursor); |
1011 | } else { | 1196 | } else { |
1012 | setCursor(arrowCursor); | 1197 | setCursor(arrowCursor); |
1013 | } | 1198 | } |
1014 | } | 1199 | } |
1015 | } | 1200 | } |
1016 | 1201 | ||
1017 | 1202 | ||
1018 | /* | 1203 | /* |
1019 | Place item in cell and take care that multiple items using the same cell do | 1204 | Place item in cell and take care that multiple items using the same cell do |
1020 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1205 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1021 | it can get in all cases. | 1206 | it can get in all cases. |
1022 | At the moment the method has a bug: When an item is placed only the sub cell | 1207 | At the moment the method has a bug: When an item is placed only the sub cell |
1023 | widths of the items are changed, which are within the Y region the item to | 1208 | widths of the items are changed, which are within the Y region the item to |
1024 | place spans. When the sub cell width change of one of this items affects a | 1209 | place spans. When the sub cell width change of one of this items affects a |
1025 | cell, where other items are, which do not overlap in Y with the item to place, | 1210 | cell, where other items are, which do not overlap in Y with the item to place, |
1026 | the display gets corrupted, although the corruption looks quite nice. | 1211 | the display gets corrupted, although the corruption looks quite nice. |
1027 | */ | 1212 | */ |
1028 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1213 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1029 | { | 1214 | { |
1030 | 1215 | ||
1031 | QPtrList<KOAgendaItem> conflictItems; | 1216 | QPtrList<KOAgendaItem> conflictItems; |
1032 | int maxSubCells = 0; | 1217 | int maxSubCells = 0; |
1033 | QIntDict<KOAgendaItem> subCellDict(5); | 1218 | QIntDict<KOAgendaItem> subCellDict(5); |
1034 | 1219 | ||
1035 | KOAgendaItem *item; | 1220 | KOAgendaItem *item; |
1036 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1221 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1037 | if (item != placeItem) { | 1222 | if (item != placeItem) { |
1038 | if (placeItem->cellX() <= item->cellXWidth() && | 1223 | if (placeItem->cellX() <= item->cellXWidth() && |
1039 | placeItem->cellXWidth() >= item->cellX()) { | 1224 | placeItem->cellXWidth() >= item->cellX()) { |
1040 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1225 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1041 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1226 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1042 | conflictItems.append(item); | 1227 | conflictItems.append(item); |
1043 | if (item->subCells() > maxSubCells) | 1228 | if (item->subCells() > maxSubCells) |
1044 | maxSubCells = item->subCells(); | 1229 | maxSubCells = item->subCells(); |
1045 | subCellDict.insert(item->subCell(),item); | 1230 | subCellDict.insert(item->subCell(),item); |
1046 | } | 1231 | } |
1047 | } | 1232 | } |
1048 | } | 1233 | } |
1049 | } | 1234 | } |
1050 | 1235 | ||
1051 | if (conflictItems.count() > 0) { | 1236 | if (conflictItems.count() > 0) { |
1052 | // Look for unused sub cell and insert item | 1237 | // Look for unused sub cell and insert item |
1053 | int i; | 1238 | int i; |
1054 | for(i=0;i<maxSubCells;++i) { | 1239 | for(i=0;i<maxSubCells;++i) { |
1055 | if (!subCellDict.find(i)) { | 1240 | if (!subCellDict.find(i)) { |
1056 | placeItem->setSubCell(i); | 1241 | placeItem->setSubCell(i); |
1057 | break; | 1242 | break; |
1058 | } | 1243 | } |
1059 | } | 1244 | } |
1060 | if (i == maxSubCells) { | 1245 | if (i == maxSubCells) { |
1061 | placeItem->setSubCell(maxSubCells); | 1246 | placeItem->setSubCell(maxSubCells); |
1062 | maxSubCells++; // add new item to number of sub cells | 1247 | maxSubCells++; // add new item to number of sub cells |
1063 | } | 1248 | } |
1064 | 1249 | ||
1065 | // Prepare for sub cell geometry adjustment | 1250 | // Prepare for sub cell geometry adjustment |
1066 | int newSubCellWidth; | 1251 | int newSubCellWidth; |
1067 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1252 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1068 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1253 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1069 | conflictItems.append(placeItem); | 1254 | conflictItems.append(placeItem); |
1070 | 1255 | ||
1071 | 1256 | ||
1072 | // Adjust sub cell geometry of all direct conflict items | 1257 | // Adjust sub cell geometry of all direct conflict items |
1073 | for ( item=conflictItems.first(); item != 0; | 1258 | for ( item=conflictItems.first(); item != 0; |
1074 | item=conflictItems.next() ) { | 1259 | item=conflictItems.next() ) { |
1075 | item->setSubCells(maxSubCells); | 1260 | item->setSubCells(maxSubCells); |
1076 | if (mAllDayMode) { | 1261 | if (mAllDayMode) { |
1077 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1262 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1078 | } else { | 1263 | } else { |
1079 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1264 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1080 | } | 1265 | } |
1081 | int x,y; | 1266 | int x,y; |
1082 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1267 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1083 | if (mAllDayMode) { | 1268 | if (mAllDayMode) { |
1084 | y += item->subCell() * newSubCellWidth; | 1269 | y += item->subCell() * newSubCellWidth; |
1085 | } else { | 1270 | } else { |
1086 | x += item->subCell() * newSubCellWidth; | 1271 | x += item->subCell() * newSubCellWidth; |
1087 | } | 1272 | } |
1088 | moveChild(item,x,y); | 1273 | moveChild(item,x,y); |
1089 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1274 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1090 | //item->updateItem(); | 1275 | //item->updateItem(); |
1091 | } | 1276 | } |
1092 | // Adjust sub cell geometry of all conflict items of all conflict items | 1277 | // Adjust sub cell geometry of all conflict items of all conflict items |
1093 | for ( item=conflictItems.first(); item != 0; | 1278 | for ( item=conflictItems.first(); item != 0; |
1094 | item=conflictItems.next() ) { | 1279 | item=conflictItems.next() ) { |
1095 | if ( placeItem != item ) { | 1280 | if ( placeItem != item ) { |
1096 | KOAgendaItem *item2; | 1281 | KOAgendaItem *item2; |
1097 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1282 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1098 | for ( item2=conflictItems2.first(); item2 != 0; | 1283 | for ( item2=conflictItems2.first(); item2 != 0; |
1099 | item2=conflictItems2.next() ) { | 1284 | item2=conflictItems2.next() ) { |
1100 | if ( item2->subCells() != maxSubCells) { | 1285 | if ( item2->subCells() != maxSubCells) { |
1101 | item2->setSubCells(maxSubCells); | 1286 | item2->setSubCells(maxSubCells); |
1102 | if (mAllDayMode) { | 1287 | if (mAllDayMode) { |
1103 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1288 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1104 | } else { | 1289 | } else { |
1105 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1290 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1106 | } | 1291 | } |
1107 | int x,y; | 1292 | int x,y; |
1108 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1293 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1109 | if (mAllDayMode) { | 1294 | if (mAllDayMode) { |
1110 | y += item2->subCell() * newSubCellWidth; | 1295 | y += item2->subCell() * newSubCellWidth; |
1111 | } else { | 1296 | } else { |
1112 | x += item2->subCell() * newSubCellWidth; | 1297 | x += item2->subCell() * newSubCellWidth; |
1113 | } | 1298 | } |
1114 | moveChild(item2,x,y); | 1299 | moveChild(item2,x,y); |
1115 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1300 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1116 | } | 1301 | } |
1117 | } | 1302 | } |
1118 | } | 1303 | } |
1119 | } | 1304 | } |
1120 | } else { | 1305 | } else { |
1121 | placeItem->setSubCell(0); | 1306 | placeItem->setSubCell(0); |
1122 | placeItem->setSubCells(1); | 1307 | placeItem->setSubCells(1); |
1123 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1308 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1124 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1309 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1125 | int x,y; | 1310 | int x,y; |
1126 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1311 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1127 | moveChild(placeItem,x,y); | 1312 | moveChild(placeItem,x,y); |
1128 | } | 1313 | } |
1129 | placeItem->setConflictItems(conflictItems); | 1314 | placeItem->setConflictItems(conflictItems); |
1130 | // for ( item=conflictItems.first(); item != 0; | 1315 | // for ( item=conflictItems.first(); item != 0; |
1131 | // item=conflictItems.next() ) { | 1316 | // item=conflictItems.next() ) { |
1132 | // //item->updateItem(); | 1317 | // //item->updateItem(); |
1133 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1318 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1134 | // } | 1319 | // } |
1135 | // placeItem->updateItem(); | 1320 | // placeItem->updateItem(); |
1136 | } | 1321 | } |
1137 | 1322 | ||
1138 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1323 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1139 | { | 1324 | { |
1140 | if ( globalFlagBlockAgenda ) | 1325 | if ( globalFlagBlockAgenda ) |
1141 | return; | 1326 | return; |
1142 | //qDebug("KOAgenda::drawContents "); | 1327 | //qDebug("KOAgenda::drawContents "); |
1143 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1328 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1144 | ;//drawContentsToPainter(); | 1329 | ;//drawContentsToPainter(); |
1145 | 1330 | ||
1146 | QPaintDevice* pd = p->device(); | 1331 | QPaintDevice* pd = p->device(); |
1147 | p->end(); | 1332 | p->end(); |
1148 | int vx, vy; | 1333 | int vx, vy; |
1149 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1334 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1150 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1335 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1151 | mSelectionCellX * mGridSpacingX; | 1336 | mSelectionCellX * mGridSpacingX; |
1152 | contentsToViewport ( cx, cy, vx,vy); | 1337 | contentsToViewport ( cx, cy, vx,vy); |
1153 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1338 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1154 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1339 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1155 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1340 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1156 | 1341 | ||
1157 | if ( mSelectionHeight > 0 ) { | 1342 | if ( mSelectionHeight > 0 ) { |
1158 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1343 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1159 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1344 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1160 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1345 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1161 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1346 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1162 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1347 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1163 | } | 1348 | } |
1164 | } | 1349 | } |
1165 | //qDebug("btbl "); | 1350 | //qDebug("btbl "); |
1166 | p->begin( pd ); | 1351 | p->begin( pd ); |
1167 | //qDebug("end "); | 1352 | //qDebug("end "); |
1168 | } | 1353 | } |
1169 | 1354 | ||
1170 | void KOAgenda::finishUpdate() | 1355 | void KOAgenda::finishUpdate() |
1171 | { | 1356 | { |
1172 | 1357 | ||
1173 | KOAgendaItem *item; | 1358 | KOAgendaItem *item; |
1174 | globalFlagBlockAgendaItemPaint = 1; | 1359 | globalFlagBlockAgendaItemPaint = 1; |
1175 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1360 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1176 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1361 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1177 | if ( !item->checkLayout() ) { | 1362 | if ( !item->checkLayout() ) { |
1178 | //qDebug(" conflictitem found "); | 1363 | //qDebug(" conflictitem found "); |
1179 | int newSubCellWidth; | 1364 | int newSubCellWidth; |
1180 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1365 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1181 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1366 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1182 | 1367 | ||
1183 | if (mAllDayMode) { | 1368 | if (mAllDayMode) { |
1184 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1369 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1185 | } else { | 1370 | } else { |
1186 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1371 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1187 | } | 1372 | } |
1188 | int x,y; | 1373 | int x,y; |
1189 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1374 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1190 | if (mAllDayMode) { | 1375 | if (mAllDayMode) { |
1191 | y += item->subCell() * newSubCellWidth; | 1376 | y += item->subCell() * newSubCellWidth; |
1192 | } else { | 1377 | } else { |
1193 | x += item->subCell() * newSubCellWidth; | 1378 | x += item->subCell() * newSubCellWidth; |
1194 | } | 1379 | } |
1195 | moveChild(item,x,y); | 1380 | moveChild(item,x,y); |
1196 | } | 1381 | } |
1197 | } | 1382 | } |
1198 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1383 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1199 | if ( !item->isVisible() ) | 1384 | if ( !item->isVisible() ) |
1200 | item->show(); | 1385 | item->show(); |
1201 | 1386 | ||
1202 | } | 1387 | } |
1203 | globalFlagBlockAgendaItemUpdate = 0; | 1388 | globalFlagBlockAgendaItemUpdate = 0; |
1204 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1389 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1205 | item->repaintMe( ); | 1390 | item->repaintMe( ); |
1206 | } | 1391 | } |
1207 | globalFlagBlockAgendaItemUpdate = 1; | 1392 | globalFlagBlockAgendaItemUpdate = 1; |
1208 | qApp->processEvents(); | 1393 | qApp->processEvents(); |
1209 | globalFlagBlockAgendaItemPaint = 0; | 1394 | globalFlagBlockAgendaItemPaint = 0; |
1210 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1395 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1211 | item->repaint( false ); | 1396 | item->repaint( false ); |
1212 | } | 1397 | } |
1213 | 1398 | ||
1214 | } | 1399 | } |
1215 | 1400 | ||
1216 | /* | 1401 | /* |
1217 | Draw grid in the background of the agenda. | 1402 | Draw grid in the background of the agenda. |
1218 | */ | 1403 | */ |
1219 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1404 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1220 | { | 1405 | { |
1221 | 1406 | ||
1222 | 1407 | ||
1223 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1408 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1224 | return; | 1409 | return; |
1225 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1410 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1226 | return; | 1411 | return; |
1227 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1412 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1228 | if ( ch < 1 ) | 1413 | if ( ch < 1 ) |
1229 | ch = 1; | 1414 | ch = 1; |
1230 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1415 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1231 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1416 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1232 | } | 1417 | } |
1233 | mCurPixWid = contentsWidth(); | 1418 | mCurPixWid = contentsWidth(); |
1234 | mCurPixHei = ch; | 1419 | mCurPixHei = ch; |
1235 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1420 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1236 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1421 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1237 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1422 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1238 | } | 1423 | } |
1239 | mPixPainter.begin( &mPaintPixmap) ; | 1424 | mPixPainter.begin( &mPaintPixmap) ; |
1240 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1425 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1241 | QPainter * p ; | 1426 | QPainter * p ; |
1242 | if (paint == 0) { | 1427 | if (paint == 0) { |
1243 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1428 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1244 | p = &mPixPainter; | 1429 | p = &mPixPainter; |
1245 | } | 1430 | } |
1246 | else | 1431 | else |
1247 | p = paint ; | 1432 | p = paint ; |
1248 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1433 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1249 | 1434 | ||
1250 | //--cx;++cw; | 1435 | //--cx;++cw; |
1251 | int lGridSpacingY = mGridSpacingY*2; | 1436 | int lGridSpacingY = mGridSpacingY*2; |
1252 | int selDay; | 1437 | int selDay; |
1253 | if ( !backgroundOnly ) | 1438 | if ( !backgroundOnly ) |
1254 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1439 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1255 | { | 1440 | { |
1256 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1441 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1257 | int x1 = cx; | 1442 | int x1 = cx; |
1258 | int y1 = 0; | 1443 | int y1 = 0; |
1259 | if (y1 < cy) y1 = cy; | 1444 | if (y1 < cy) y1 = cy; |
1260 | int x2 = cx+cw-1; | 1445 | int x2 = cx+cw-1; |
1261 | int y2 = contentsHeight(); | 1446 | int y2 = contentsHeight(); |
1262 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1447 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1263 | if (x2 >= x1 && y2 >= y1) { | 1448 | if (x2 >= x1 && y2 >= y1) { |
1264 | int gxStart = selDay; | 1449 | int gxStart = selDay; |
1265 | int gxEnd = gxStart ; | 1450 | int gxEnd = gxStart ; |
1266 | int xStart = KOGlobals::self()->reverseLayout() ? | 1451 | int xStart = KOGlobals::self()->reverseLayout() ? |
1267 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1452 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1268 | gxStart*mGridSpacingX; | 1453 | gxStart*mGridSpacingX; |
1269 | if (xStart < x1) xStart = x1; | 1454 | if (xStart < x1) xStart = x1; |
1270 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1455 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1271 | (mColumns - gxStart)*mGridSpacingX-1 : | 1456 | (mColumns - gxStart)*mGridSpacingX-1 : |
1272 | (gxStart+1)*mGridSpacingX-1; | 1457 | (gxStart+1)*mGridSpacingX-1; |
1273 | if (xEnd > x2) xEnd = x2; | 1458 | if (xEnd > x2) xEnd = x2; |
1274 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1459 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1275 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1460 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1276 | KOPrefs::instance()->mAgendaBgColor.light()); | 1461 | KOPrefs::instance()->mAgendaBgColor.light()); |
1277 | else | 1462 | else |
1278 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1463 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1279 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1464 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1280 | 1465 | ||
1281 | } | 1466 | } |
1282 | } | 1467 | } |
1283 | } | 1468 | } |
1284 | // Highlight working hours | 1469 | // Highlight working hours |
1285 | 1470 | ||
1286 | if ( !backgroundOnly ) | 1471 | if ( !backgroundOnly ) |
1287 | if (mWorkingHoursEnable) { | 1472 | if (mWorkingHoursEnable) { |
1288 | int x1 = cx; | 1473 | int x1 = cx; |
1289 | int y1 = mWorkingHoursYTop; | 1474 | int y1 = mWorkingHoursYTop; |
1290 | if (y1 < cy) y1 = cy; | 1475 | if (y1 < cy) y1 = cy; |
1291 | int x2 = cx+cw-1; | 1476 | int x2 = cx+cw-1; |
1292 | // int x2 = mGridSpacingX * 5 - 1; | 1477 | // int x2 = mGridSpacingX * 5 - 1; |
1293 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1478 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1294 | int y2 = mWorkingHoursYBottom; | 1479 | int y2 = mWorkingHoursYBottom; |
1295 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1480 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1296 | 1481 | ||
1297 | if (x2 >= x1 && y2 >= y1) { | 1482 | if (x2 >= x1 && y2 >= y1) { |
1298 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1483 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1299 | int gxStart = x1/mGridSpacingX; | 1484 | int gxStart = x1/mGridSpacingX; |
1300 | int gxEnd = x2/mGridSpacingX; | 1485 | int gxEnd = x2/mGridSpacingX; |
1301 | while(gxStart <= gxEnd) { | 1486 | while(gxStart <= gxEnd) { |
1302 | if (gxStart < int(mHolidayMask->count()) && | 1487 | if (gxStart < int(mHolidayMask->count()) && |
1303 | !mHolidayMask->at(gxStart)) { | 1488 | !mHolidayMask->at(gxStart)) { |
1304 | int xStart = KOGlobals::self()->reverseLayout() ? | 1489 | int xStart = KOGlobals::self()->reverseLayout() ? |
1305 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1490 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1306 | gxStart*mGridSpacingX; | 1491 | gxStart*mGridSpacingX; |
1307 | if (xStart < x1) xStart = x1; | 1492 | if (xStart < x1) xStart = x1; |
1308 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1493 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1309 | (mColumns - gxStart)*mGridSpacingX-1 : | 1494 | (mColumns - gxStart)*mGridSpacingX-1 : |
1310 | (gxStart+1)*mGridSpacingX-1; | 1495 | (gxStart+1)*mGridSpacingX-1; |
1311 | if (xEnd > x2) xEnd = x2; | 1496 | if (xEnd > x2) xEnd = x2; |
1312 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1497 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1313 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1498 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1314 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1499 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1315 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1500 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1316 | else | 1501 | else |
1317 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1502 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1318 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1503 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1319 | } else { | 1504 | } else { |
1320 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1505 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1321 | KOPrefs::instance()->mWorkingHoursColor); | 1506 | KOPrefs::instance()->mWorkingHoursColor); |
1322 | } | 1507 | } |
1323 | } | 1508 | } |
1324 | ++gxStart; | 1509 | ++gxStart; |
1325 | } | 1510 | } |
1326 | } | 1511 | } |
1327 | } | 1512 | } |
1328 | /* | 1513 | /* |
1329 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1514 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1330 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1515 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1331 | mSelectionCellX * mGridSpacingX; | 1516 | mSelectionCellX * mGridSpacingX; |
1332 | 1517 | ||
1333 | // Draw selection | 1518 | // Draw selection |
1334 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1519 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1335 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1520 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1336 | // TODO: paint only part within cx,cy,cw,ch | 1521 | // TODO: paint only part within cx,cy,cw,ch |
1337 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1522 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1338 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1523 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1339 | } | 1524 | } |
1340 | */ | 1525 | */ |
1341 | // Draw vertical lines of grid | 1526 | // Draw vertical lines of grid |
1342 | 1527 | ||
1343 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1528 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1344 | if ( mGridSpacingX > 0 ) { | 1529 | if ( mGridSpacingX > 0 ) { |
1345 | while (x < cx + cw) { | 1530 | while (x < cx + cw) { |
1346 | p->drawLine(x,cy,x,cy+ch); | 1531 | p->drawLine(x,cy,x,cy+ch); |
1347 | x+=mGridSpacingX; | 1532 | x+=mGridSpacingX; |
1348 | } | 1533 | } |
1349 | } | 1534 | } |
1350 | // Draw horizontal lines of grid | 1535 | // Draw horizontal lines of grid |
1351 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1536 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1352 | if ( lGridSpacingY > 0 ) { | 1537 | if ( lGridSpacingY > 0 ) { |
1353 | while (y < cy + ch) { | 1538 | while (y < cy + ch) { |
1354 | p->setPen( SolidLine ); | 1539 | p->setPen( SolidLine ); |
1355 | p->drawLine(cx,y,cx+cw,y); | 1540 | p->drawLine(cx,y,cx+cw,y); |
1356 | y+=lGridSpacingY; | 1541 | y+=lGridSpacingY; |
1357 | p->setPen( DotLine ); | 1542 | p->setPen( DotLine ); |
1358 | p->drawLine(cx,y,cx+cw,y); | 1543 | p->drawLine(cx,y,cx+cw,y); |
1359 | y+=lGridSpacingY; | 1544 | y+=lGridSpacingY; |
1360 | } | 1545 | } |
1361 | p->setPen( SolidLine ); | 1546 | p->setPen( SolidLine ); |
1362 | } | 1547 | } |
1363 | mPixPainter.end() ; | 1548 | mPixPainter.end() ; |
1364 | } | 1549 | } |
1365 | 1550 | ||
1366 | /* | 1551 | /* |
1367 | Convert srcollview contents coordinates to agenda grid coordinates. | 1552 | Convert srcollview contents coordinates to agenda grid coordinates. |
1368 | */ | 1553 | */ |
1369 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1554 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1370 | { | 1555 | { |
1371 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1556 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1372 | x/mGridSpacingX; | 1557 | x/mGridSpacingX; |
1373 | gy = y/mGridSpacingY; | 1558 | gy = y/mGridSpacingY; |
1374 | } | 1559 | } |
1375 | 1560 | ||
1376 | /* | 1561 | /* |
1377 | Convert agenda grid coordinates to scrollview contents coordinates. | 1562 | Convert agenda grid coordinates to scrollview contents coordinates. |
1378 | */ | 1563 | */ |
1379 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1564 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1380 | { | 1565 | { |
1381 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1566 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1382 | gx*mGridSpacingX; | 1567 | gx*mGridSpacingX; |
1383 | y = gy*mGridSpacingY; | 1568 | y = gy*mGridSpacingY; |
1384 | } | 1569 | } |
1385 | 1570 | ||
1386 | 1571 | ||
1387 | /* | 1572 | /* |
1388 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1573 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1389 | the grid. | 1574 | the grid. |
1390 | */ | 1575 | */ |
1391 | int KOAgenda::timeToY(const QTime &time) | 1576 | int KOAgenda::timeToY(const QTime &time) |
1392 | { | 1577 | { |
1393 | int minutesPerCell = 24 * 60 / mRows; | 1578 | int minutesPerCell = 24 * 60 / mRows; |
1394 | int timeMinutes = time.hour() * 60 + time.minute(); | 1579 | int timeMinutes = time.hour() * 60 + time.minute(); |
1395 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1580 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1396 | return Y; | 1581 | return Y; |
1397 | } | 1582 | } |
1398 | 1583 | ||
1399 | 1584 | ||
1400 | /* | 1585 | /* |
1401 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1586 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1402 | fit into the grid. | 1587 | fit into the grid. |
1403 | */ | 1588 | */ |
1404 | QTime KOAgenda::gyToTime(int gy) | 1589 | QTime KOAgenda::gyToTime(int gy) |
1405 | { | 1590 | { |
1406 | 1591 | ||
1407 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1592 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1408 | 1593 | ||
1409 | int timeSeconds = secondsPerCell * gy; | 1594 | int timeSeconds = secondsPerCell * gy; |
1410 | 1595 | ||
1411 | QTime time( 0, 0, 0 ); | 1596 | QTime time( 0, 0, 0 ); |
1412 | if ( timeSeconds < 24 * 60 * 60 ) { | 1597 | if ( timeSeconds < 24 * 60 * 60 ) { |
1413 | time = time.addSecs(timeSeconds); | 1598 | time = time.addSecs(timeSeconds); |
1414 | } else { | 1599 | } else { |
1415 | time.setHMS( 23, 59, 59 ); | 1600 | time.setHMS( 23, 59, 59 ); |
1416 | } | 1601 | } |
1417 | 1602 | ||
1418 | return time; | 1603 | return time; |
1419 | } | 1604 | } |
1420 | 1605 | ||
1421 | void KOAgenda::setStartHour(int startHour) | 1606 | void KOAgenda::setStartHour(int startHour) |
1422 | { | 1607 | { |
1423 | int startCell = startHour * mRows / 24; | 1608 | int startCell = startHour * mRows / 24; |
1424 | setContentsPos(0,startCell * gridSpacingY()); | 1609 | setContentsPos(0,startCell * gridSpacingY()); |
1425 | } | 1610 | } |
1426 | void KOAgenda::hideUnused() | 1611 | void KOAgenda::hideUnused() |
1427 | { | 1612 | { |
1428 | // experimental only | 1613 | // experimental only |
1429 | // return; | 1614 | // return; |
1430 | KOAgendaItem *item; | 1615 | KOAgendaItem *item; |
1431 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1616 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1432 | item->hide(); | 1617 | item->hide(); |
1433 | } | 1618 | } |
1434 | } | 1619 | } |
1435 | 1620 | ||
1436 | 1621 | ||
1437 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1622 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1438 | { | 1623 | { |
1439 | 1624 | ||
1440 | KOAgendaItem *fi; | 1625 | KOAgendaItem *fi; |
1441 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1626 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1442 | if ( fi->incidence() == event ) { | 1627 | if ( fi->incidence() == event ) { |
1443 | mUnusedItems.remove(); | 1628 | mUnusedItems.remove(); |
1444 | fi->init( event, qd ); | 1629 | fi->init( event, qd ); |
1445 | return fi; | 1630 | return fi; |
1446 | } | 1631 | } |
1447 | } | 1632 | } |
1448 | fi=mUnusedItems.first(); | 1633 | fi=mUnusedItems.first(); |
1449 | if ( fi ) { | 1634 | if ( fi ) { |
1450 | mUnusedItems.remove(); | 1635 | mUnusedItems.remove(); |
1451 | fi->init( event, qd ); | 1636 | fi->init( event, qd ); |
1452 | return fi; | 1637 | return fi; |
1453 | } | 1638 | } |
1454 | // qDebug("new KOAgendaItem "); | 1639 | // qDebug("new KOAgendaItem "); |
1455 | 1640 | ||
1456 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1641 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1457 | agendaItem->installEventFilter(this); | 1642 | agendaItem->installEventFilter(this); |
1458 | addChild(agendaItem,0,0); | 1643 | addChild(agendaItem,0,0); |
1459 | return agendaItem; | 1644 | return agendaItem; |
1460 | } | 1645 | } |
1461 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1646 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1462 | { | 1647 | { |
1463 | KOAgendaItem *item; | 1648 | KOAgendaItem *item; |
1464 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1649 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1465 | if ( item->incidence() == todo ) { | 1650 | if ( item->incidence() == todo ) { |
1466 | mItems.remove(); | 1651 | mItems.remove(); |
1467 | return item; | 1652 | return item; |
1468 | } | 1653 | } |
1469 | } | 1654 | } |
1470 | return 0; | 1655 | return 0; |
1471 | } | 1656 | } |
1472 | 1657 | ||
1473 | 1658 | ||
1474 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1659 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1475 | { | 1660 | { |
1476 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1661 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1477 | KOAgendaItem *item; | 1662 | KOAgendaItem *item; |
1478 | item = getItemForTodo ( todo ); | 1663 | item = getItemForTodo ( todo ); |
1479 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1664 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1480 | if ( item ) { | 1665 | if ( item ) { |
1481 | blockSignals( true ); | 1666 | blockSignals( true ); |
1482 | //qDebug("item found "); | 1667 | //qDebug("item found "); |
1483 | item->hide(); | 1668 | item->hide(); |
1484 | item->setCellX(-2, -1 ); | 1669 | item->setCellX(-2, -1 ); |
1485 | item->select(false); | 1670 | item->select(false); |
1486 | mUnusedItems.append( item ); | 1671 | mUnusedItems.append( item ); |
1487 | mItems.remove( item ); | 1672 | mItems.remove( item ); |
1488 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1673 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1489 | KOAgendaItem *itemit; | 1674 | KOAgendaItem *itemit; |
1490 | //globalFlagBlockAgendaItemPaint = 1; | 1675 | //globalFlagBlockAgendaItemPaint = 1; |
1491 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1676 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1492 | itemit=oldconflictItems.next() ) { | 1677 | itemit=oldconflictItems.next() ) { |
1493 | if ( itemit != item ) | 1678 | if ( itemit != item ) |
1494 | placeSubCells(itemit); | 1679 | placeSubCells(itemit); |
1495 | } | 1680 | } |
1496 | qApp->processEvents(); | 1681 | qApp->processEvents(); |
1497 | //globalFlagBlockAgendaItemPaint = 0; | 1682 | //globalFlagBlockAgendaItemPaint = 0; |
1498 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1683 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1499 | itemit=oldconflictItems.next() ) { | 1684 | itemit=oldconflictItems.next() ) { |
1500 | globalFlagBlockAgendaItemUpdate = 0; | 1685 | globalFlagBlockAgendaItemUpdate = 0; |
1501 | if ( itemit != item ) | 1686 | if ( itemit != item ) |
1502 | itemit->repaintMe(); | 1687 | itemit->repaintMe(); |
1503 | globalFlagBlockAgendaItemUpdate = 1; | 1688 | globalFlagBlockAgendaItemUpdate = 1; |
1504 | itemit->repaint(); | 1689 | itemit->repaint(); |
1505 | } | 1690 | } |
1506 | blockSignals( false ); | 1691 | blockSignals( false ); |
1507 | } | 1692 | } |
1508 | if ( remove ) { | 1693 | if ( remove ) { |
1509 | //qDebug("remove****************************************** "); | 1694 | //qDebug("remove****************************************** "); |
1510 | return; | 1695 | return; |
1511 | } | 1696 | } |
1512 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1697 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1513 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1698 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1514 | QDate currentDate; | 1699 | QDate currentDate; |
1515 | QDateTime dt; | 1700 | QDateTime dt; |
1516 | if ( todo->hasCompletedDate() ) | 1701 | if ( todo->hasCompletedDate() ) |
1517 | dt = todo->completed(); | 1702 | dt = todo->completed(); |
1518 | else | 1703 | else |
1519 | dt = todo->dtDue(); | 1704 | dt = todo->dtDue(); |
1520 | if ( overdue ) { | 1705 | if ( overdue ) { |
1521 | currentDate = QDate::currentDate(); | 1706 | currentDate = QDate::currentDate(); |
1522 | days += todo->dtDue().date().daysTo( currentDate ); | 1707 | days += todo->dtDue().date().daysTo( currentDate ); |
1523 | } | 1708 | } |
1524 | else | 1709 | else |
1525 | currentDate = dt.date(); | 1710 | currentDate = dt.date(); |
1526 | 1711 | ||
1527 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1712 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1528 | if ( ! mAllDayMode ) return; | 1713 | if ( ! mAllDayMode ) return; |
1529 | // aldayagenda | 1714 | // aldayagenda |
1530 | globalFlagBlockAgendaItemPaint = 1; | 1715 | globalFlagBlockAgendaItemPaint = 1; |
1531 | item = insertAllDayItem(todo, currentDate,days, days); | 1716 | item = insertAllDayItem(todo, currentDate,days, days); |
1532 | item->show(); | 1717 | item->show(); |
1533 | 1718 | ||
1534 | } | 1719 | } |
1535 | else { | 1720 | else { |
1536 | if ( mAllDayMode ) return; | 1721 | if ( mAllDayMode ) return; |
1537 | // mAgenda | 1722 | // mAgenda |
1538 | globalFlagBlockAgendaItemPaint = 1; | 1723 | globalFlagBlockAgendaItemPaint = 1; |
1539 | int endY = timeToY(dt.time()) - 1; | 1724 | int endY = timeToY(dt.time()) - 1; |
1540 | int hi = 12/KOPrefs::instance()->mHourSize; | 1725 | int hi = 12/KOPrefs::instance()->mHourSize; |
1541 | int startY = endY - 1-hi; | 1726 | int startY = endY - 1-hi; |
1542 | item = insertItem(todo,currentDate,days,startY,endY); | 1727 | item = insertItem(todo,currentDate,days,startY,endY); |
1543 | item->show(); | 1728 | item->show(); |
1544 | } | 1729 | } |
1545 | qApp->processEvents(); | 1730 | qApp->processEvents(); |
1546 | globalFlagBlockAgendaItemPaint = 0; | 1731 | globalFlagBlockAgendaItemPaint = 0; |
1547 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1732 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1548 | KOAgendaItem *itemit; | 1733 | KOAgendaItem *itemit; |
1549 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1734 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1550 | itemit=oldconflictItems.next() ) { | 1735 | itemit=oldconflictItems.next() ) { |
1551 | globalFlagBlockAgendaItemUpdate = 0; | 1736 | globalFlagBlockAgendaItemUpdate = 0; |
1552 | itemit->repaintMe(); | 1737 | itemit->repaintMe(); |
1553 | globalFlagBlockAgendaItemUpdate = 1; | 1738 | globalFlagBlockAgendaItemUpdate = 1; |
1554 | itemit->repaint(); | 1739 | itemit->repaint(); |
1555 | } | 1740 | } |
1556 | globalFlagBlockAgendaItemUpdate = 0; | 1741 | globalFlagBlockAgendaItemUpdate = 0; |
1557 | item->repaintMe(); | 1742 | item->repaintMe(); |
1558 | globalFlagBlockAgendaItemUpdate = 1; | 1743 | globalFlagBlockAgendaItemUpdate = 1; |
1559 | item->repaint(); | 1744 | item->repaint(); |
1560 | } | 1745 | } |
1561 | /* | 1746 | /* |
1562 | Insert KOAgendaItem into agenda. | 1747 | Insert KOAgendaItem into agenda. |
1563 | */ | 1748 | */ |
1564 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1749 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1565 | { | 1750 | { |
1566 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1751 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1567 | 1752 | ||
1568 | if (mAllDayMode) { | 1753 | if (mAllDayMode) { |
1569 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1754 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1570 | return 0; | 1755 | return 0; |
1571 | } | 1756 | } |
1572 | 1757 | ||
1573 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1758 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1574 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1759 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1575 | 1760 | ||
1576 | int YSize = YBottom - YTop + 1; | 1761 | int YSize = YBottom - YTop + 1; |
1577 | if (YSize < 0) { | 1762 | if (YSize < 0) { |
1578 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1763 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1579 | YSize = 1; | 1764 | YSize = 1; |
1580 | } | 1765 | } |
1581 | int iheight = mGridSpacingY * YSize; | 1766 | int iheight = mGridSpacingY * YSize; |
1582 | 1767 | ||
1583 | agendaItem->resize(mGridSpacingX,iheight ); | 1768 | agendaItem->resize(mGridSpacingX,iheight ); |
1584 | agendaItem->setCellXY(X,YTop,YBottom); | 1769 | agendaItem->setCellXY(X,YTop,YBottom); |
1585 | agendaItem->setCellXWidth(X); | 1770 | agendaItem->setCellXWidth(X); |
1586 | 1771 | ||
1587 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1772 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1588 | mItems.append(agendaItem); | 1773 | mItems.append(agendaItem); |
1589 | 1774 | ||
1590 | placeSubCells(agendaItem); | 1775 | placeSubCells(agendaItem); |
1591 | 1776 | ||
1592 | //agendaItem->show(); | 1777 | //agendaItem->show(); |
1593 | 1778 | ||
1594 | marcus_bains(); | 1779 | marcus_bains(); |
1595 | 1780 | ||
1596 | return agendaItem; | 1781 | return agendaItem; |
1597 | } | 1782 | } |
1598 | 1783 | ||
1599 | 1784 | ||
1600 | /* | 1785 | /* |
1601 | Insert all-day KOAgendaItem into agenda. | 1786 | Insert all-day KOAgendaItem into agenda. |
1602 | */ | 1787 | */ |
1603 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1788 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1604 | { | 1789 | { |
1605 | if (!mAllDayMode) { | 1790 | if (!mAllDayMode) { |
1606 | return 0; | 1791 | return 0; |
1607 | } | 1792 | } |
1608 | 1793 | ||
1609 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1794 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1610 | 1795 | ||
1611 | agendaItem->setCellXY(XBegin,0,0); | 1796 | agendaItem->setCellXY(XBegin,0,0); |
1612 | agendaItem->setCellXWidth(XEnd); | 1797 | agendaItem->setCellXWidth(XEnd); |
1613 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1798 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1614 | 1799 | ||
1615 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1800 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1616 | mItems.append(agendaItem); | 1801 | mItems.append(agendaItem); |
1617 | 1802 | ||
1618 | placeSubCells(agendaItem); | 1803 | placeSubCells(agendaItem); |
1619 | 1804 | ||
1620 | //agendaItem->show(); | 1805 | //agendaItem->show(); |
1621 | 1806 | ||
1622 | return agendaItem; | 1807 | return agendaItem; |
1623 | } | 1808 | } |
1624 | 1809 | ||
1625 | 1810 | ||
1626 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1811 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1627 | int YTop,int YBottom) | 1812 | int YTop,int YBottom) |
1628 | { | 1813 | { |
1629 | if (mAllDayMode) { | 1814 | if (mAllDayMode) { |
1630 | ; | 1815 | ; |
1631 | return; | 1816 | return; |
1632 | } | 1817 | } |
1633 | 1818 | ||
1634 | int cellX,cellYTop,cellYBottom; | 1819 | int cellX,cellYTop,cellYBottom; |
1635 | QString newtext; | 1820 | QString newtext; |
1636 | int width = XEnd - XBegin + 1; | 1821 | int width = XEnd - XBegin + 1; |
1637 | int count = 0; | 1822 | int count = 0; |
1638 | KOAgendaItem *current = 0; | 1823 | KOAgendaItem *current = 0; |
1639 | QPtrList<KOAgendaItem> multiItems; | 1824 | QPtrList<KOAgendaItem> multiItems; |
1640 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1825 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1641 | if (cellX == XBegin) cellYTop = YTop; | 1826 | if (cellX == XBegin) cellYTop = YTop; |
1642 | else cellYTop = 0; | 1827 | else cellYTop = 0; |
1643 | if (cellX == XEnd) cellYBottom = YBottom; | 1828 | if (cellX == XEnd) cellYBottom = YBottom; |
1644 | else cellYBottom = rows() - 1; | 1829 | else cellYBottom = rows() - 1; |
1645 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1830 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1646 | newtext.append(event->summary()); | 1831 | newtext.append(event->summary()); |
1647 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1832 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1648 | current->setText(newtext); | 1833 | current->setText(newtext); |
1649 | multiItems.append(current); | 1834 | multiItems.append(current); |
1650 | } | 1835 | } |
1651 | 1836 | ||
1652 | KOAgendaItem *next = 0; | 1837 | KOAgendaItem *next = 0; |
1653 | KOAgendaItem *last = multiItems.last(); | 1838 | KOAgendaItem *last = multiItems.last(); |
1654 | KOAgendaItem *first = multiItems.first(); | 1839 | KOAgendaItem *first = multiItems.first(); |
1655 | KOAgendaItem *setFirst,*setLast; | 1840 | KOAgendaItem *setFirst,*setLast; |
1656 | current = first; | 1841 | current = first; |
1657 | while (current) { | 1842 | while (current) { |
1658 | next = multiItems.next(); | 1843 | next = multiItems.next(); |
1659 | if (current == first) setFirst = 0; | 1844 | if (current == first) setFirst = 0; |
1660 | else setFirst = first; | 1845 | else setFirst = first; |
1661 | if (current == last) setLast = 0; | 1846 | if (current == last) setLast = 0; |
1662 | else setLast = last; | 1847 | else setLast = last; |
1663 | 1848 | ||
1664 | current->setMultiItem(setFirst,next,setLast); | 1849 | current->setMultiItem(setFirst,next,setLast); |
1665 | current = next; | 1850 | current = next; |
1666 | } | 1851 | } |
1667 | 1852 | ||
1668 | marcus_bains(); | 1853 | marcus_bains(); |
1669 | } | 1854 | } |
1670 | 1855 | ||
1671 | 1856 | ||
1672 | //QSizePolicy KOAgenda::sizePolicy() const | 1857 | //QSizePolicy KOAgenda::sizePolicy() const |
1673 | //{ | 1858 | //{ |
1674 | // Thought this would make the all-day event agenda minimum size and the | 1859 | // Thought this would make the all-day event agenda minimum size and the |
1675 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1860 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1676 | // don´t seem to think that an Expanding widget needs more space than a | 1861 | // don´t seem to think that an Expanding widget needs more space than a |
1677 | // Preferred one. | 1862 | // Preferred one. |
1678 | // But it doesn´t hurt, so it stays. | 1863 | // But it doesn´t hurt, so it stays. |
1679 | // if (mAllDayMode) { | 1864 | // if (mAllDayMode) { |
1680 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1865 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1681 | // } else { | 1866 | // } else { |
1682 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1867 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1683 | // } | 1868 | // } |
1684 | //} | 1869 | //} |
1685 | void KOAgenda::finishResize ( ) | 1870 | void KOAgenda::finishResize ( ) |
1686 | { | 1871 | { |
1687 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1872 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1688 | if ( globalFlagBlockAgenda == 0 ) { | 1873 | if ( globalFlagBlockAgenda == 0 ) { |
1689 | finishUpdate(); | 1874 | finishUpdate(); |
1690 | //qDebug("finishUpdate() called "); | 1875 | //qDebug("finishUpdate() called "); |
1691 | } | 1876 | } |
1692 | } | 1877 | } |
1693 | /* | 1878 | /* |
1694 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1879 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1695 | */ | 1880 | */ |
1696 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1881 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1697 | { | 1882 | { |
1698 | 1883 | ||
1699 | mResizeTimer.start( 150 , true ); | 1884 | mResizeTimer.start( 150 , true ); |
1700 | computeSizes(); | 1885 | computeSizes(); |
1701 | return; | 1886 | return; |
1702 | 1887 | ||
1703 | } | 1888 | } |
1704 | void KOAgenda::computeSizes() | 1889 | void KOAgenda::computeSizes() |
1705 | { | 1890 | { |
1706 | if ( globalFlagBlockStartup ) | 1891 | if ( globalFlagBlockStartup ) |
1707 | return; | 1892 | return; |
1708 | 1893 | ||
1709 | if (mAllDayMode) { | 1894 | if (mAllDayMode) { |
1710 | mGridSpacingX = (width()-3) / mColumns; | 1895 | mGridSpacingX = (width()-3) / mColumns; |
1711 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1896 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1712 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1897 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1713 | // mGridSpacingY = height(); | 1898 | // mGridSpacingY = height(); |
1714 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1899 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1715 | 1900 | ||
1716 | KOAgendaItem *item; | 1901 | KOAgendaItem *item; |
1717 | int subCellWidth; | 1902 | int subCellWidth; |
1718 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1903 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1719 | subCellWidth = mGridSpacingY / item->subCells(); | 1904 | subCellWidth = mGridSpacingY / item->subCells(); |
1720 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1905 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1721 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1906 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1722 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1907 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1723 | item->cellX() * mGridSpacingX, | 1908 | item->cellX() * mGridSpacingX, |
1724 | item->subCell() * subCellWidth); | 1909 | item->subCell() * subCellWidth); |
1725 | } | 1910 | } |
1726 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1911 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1727 | } else { | 1912 | } else { |
1728 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1913 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; |
1729 | if (height() > mGridSpacingY * mRows + 1 ) { | 1914 | if (height() > mGridSpacingY * mRows + 1 ) { |
1730 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1915 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1731 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1916 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1732 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1917 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1733 | emit resizedSignal(); | 1918 | emit resizedSignal(); |
1734 | } else | 1919 | } else |
1735 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1920 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1736 | KOAgendaItem *item; | 1921 | KOAgendaItem *item; |
1737 | int subCellWidth; | 1922 | int subCellWidth; |
1738 | 1923 | ||
1739 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1924 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1740 | subCellWidth = mGridSpacingX / item->subCells(); | 1925 | subCellWidth = mGridSpacingX / item->subCells(); |
1741 | item->resize(subCellWidth,item->height()); | 1926 | item->resize(subCellWidth,item->height()); |
1742 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1927 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1743 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1928 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1744 | item->cellX() * mGridSpacingX) + | 1929 | item->cellX() * mGridSpacingX) + |
1745 | item->subCell() * subCellWidth,childY(item)); | 1930 | item->subCell() * subCellWidth,childY(item)); |
1746 | } | 1931 | } |
1747 | } | 1932 | } |
1748 | int cw = contentsWidth(); | 1933 | int cw = contentsWidth(); |
1749 | int ch = contentsHeight(); | 1934 | int ch = contentsHeight(); |
1750 | if ( mAllDayMode ) { | 1935 | if ( mAllDayMode ) { |
1751 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1936 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1752 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1937 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1753 | paintPixAll->resize( cw, ch ); | 1938 | paintPixAll->resize( cw, ch ); |
1754 | } else { | 1939 | } else { |
1755 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1940 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1756 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1941 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1757 | KOAgendaItem::resizePixmap( cw , ch ); | 1942 | KOAgendaItem::resizePixmap( cw , ch ); |
1758 | } | 1943 | } |
1759 | 1944 | ||
1760 | checkScrollBoundaries(); | 1945 | checkScrollBoundaries(); |
1761 | marcus_bains(); | 1946 | marcus_bains(); |
1762 | drawContentsToPainter(); | 1947 | drawContentsToPainter(); |
1763 | viewport()->repaint(false); | 1948 | viewport()->repaint(false); |
1764 | } | 1949 | } |
1765 | 1950 | ||
1766 | void KOAgenda::scrollUp() | 1951 | void KOAgenda::scrollUp() |
1767 | { | 1952 | { |
1768 | scrollBy(0,-mScrollOffset); | 1953 | scrollBy(0,-mScrollOffset); |
1769 | } | 1954 | } |
1770 | 1955 | ||
1771 | 1956 | ||
1772 | void KOAgenda::scrollDown() | 1957 | void KOAgenda::scrollDown() |
1773 | { | 1958 | { |
1774 | scrollBy(0,mScrollOffset); | 1959 | scrollBy(0,mScrollOffset); |
1775 | } | 1960 | } |
1776 | 1961 | ||
1777 | void KOAgenda::popupAlarm() | 1962 | void KOAgenda::popupAlarm() |
1778 | { | 1963 | { |
1779 | if (!mClickedItem) { | 1964 | if (!mClickedItem) { |
1780 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1965 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1781 | return; | 1966 | return; |
1782 | } | 1967 | } |
1783 | // TODO: deal correctly with multiple alarms | 1968 | // TODO: deal correctly with multiple alarms |
1784 | Alarm* alarm; | 1969 | Alarm* alarm; |
1785 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1970 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1786 | for(alarm=list.first();alarm;alarm=list.next()) { | 1971 | for(alarm=list.first();alarm;alarm=list.next()) { |
1787 | alarm->toggleAlarm(); | 1972 | alarm->toggleAlarm(); |
1788 | } | 1973 | } |
1789 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1974 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1790 | mClickedItem->paintMe( true ); | 1975 | mClickedItem->paintMe( true ); |
1791 | mClickedItem->repaint( false ); | 1976 | mClickedItem->repaint( false ); |
1792 | } | 1977 | } |
1793 | 1978 | ||
1794 | /* | 1979 | /* |
1795 | Calculates the minimum width | 1980 | Calculates the minimum width |
1796 | */ | 1981 | */ |
1797 | int KOAgenda::minimumWidth() const | 1982 | int KOAgenda::minimumWidth() const |
1798 | { | 1983 | { |
1799 | // TODO:: develop a way to dynamically determine the minimum width | 1984 | // TODO:: develop a way to dynamically determine the minimum width |
1800 | int min = 100; | 1985 | int min = 100; |
1801 | 1986 | ||
1802 | return min; | 1987 | return min; |
1803 | } | 1988 | } |
1804 | 1989 | ||
1805 | void KOAgenda::updateConfig() | 1990 | void KOAgenda::updateConfig() |
1806 | { | 1991 | { |
1807 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1992 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1808 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1993 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1809 | if ( mAllDayMode ) { | 1994 | if ( mAllDayMode ) { |
1810 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1995 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1811 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1996 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1812 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1997 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1813 | // setMaximumHeight( mGridSpacingY+1 ); | 1998 | // setMaximumHeight( mGridSpacingY+1 ); |
1814 | viewport()->repaint( false ); | 1999 | viewport()->repaint( false ); |
1815 | //setFixedHeight( mGridSpacingY+1 ); | 2000 | //setFixedHeight( mGridSpacingY+1 ); |
1816 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2001 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1817 | } | 2002 | } |
1818 | else { | 2003 | else { |
1819 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2004 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1820 | calculateWorkingHours(); | 2005 | calculateWorkingHours(); |
1821 | marcus_bains(); | 2006 | marcus_bains(); |
1822 | } | 2007 | } |
1823 | } | 2008 | } |
1824 | 2009 | ||
1825 | void KOAgenda::checkScrollBoundaries() | 2010 | void KOAgenda::checkScrollBoundaries() |
1826 | { | 2011 | { |
1827 | // Invalidate old values to force update | 2012 | // Invalidate old values to force update |
1828 | mOldLowerScrollValue = -1; | 2013 | mOldLowerScrollValue = -1; |
1829 | mOldUpperScrollValue = -1; | 2014 | mOldUpperScrollValue = -1; |
1830 | 2015 | ||
1831 | checkScrollBoundaries(verticalScrollBar()->value()); | 2016 | checkScrollBoundaries(verticalScrollBar()->value()); |
1832 | } | 2017 | } |
1833 | 2018 | ||
1834 | void KOAgenda::checkScrollBoundaries(int v) | 2019 | void KOAgenda::checkScrollBoundaries(int v) |
1835 | { | 2020 | { |
1836 | if ( mGridSpacingY == 0 ) | 2021 | if ( mGridSpacingY == 0 ) |
1837 | return; | 2022 | return; |
1838 | int yMin = v/mGridSpacingY; | 2023 | int yMin = v/mGridSpacingY; |
1839 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2024 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1840 | 2025 | ||
1841 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2026 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1842 | 2027 | ||
1843 | if (yMin != mOldLowerScrollValue) { | 2028 | if (yMin != mOldLowerScrollValue) { |
1844 | mOldLowerScrollValue = yMin; | 2029 | mOldLowerScrollValue = yMin; |
1845 | emit lowerYChanged(yMin); | 2030 | emit lowerYChanged(yMin); |
1846 | } | 2031 | } |
1847 | if (yMax != mOldUpperScrollValue) { | 2032 | if (yMax != mOldUpperScrollValue) { |
1848 | mOldUpperScrollValue = yMax; | 2033 | mOldUpperScrollValue = yMax; |
1849 | emit upperYChanged(yMax); | 2034 | emit upperYChanged(yMax); |
1850 | } | 2035 | } |
1851 | } | 2036 | } |
1852 | 2037 | ||
1853 | void KOAgenda::deselectItem() | 2038 | void KOAgenda::deselectItem() |
1854 | { | 2039 | { |
1855 | if (mSelectedItem.isNull()) return; | 2040 | if (mSelectedItem.isNull()) return; |
1856 | mSelectedItem->select(false); | 2041 | mSelectedItem->select(false); |
1857 | mSelectedItem = 0; | 2042 | mSelectedItem = 0; |
1858 | } | 2043 | } |
1859 | 2044 | ||
1860 | void KOAgenda::selectItem(KOAgendaItem *item) | 2045 | void KOAgenda::selectItem(KOAgendaItem *item) |
1861 | { | 2046 | { |
1862 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2047 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1863 | deselectItem(); | 2048 | deselectItem(); |
1864 | if (item == 0) { | 2049 | if (item == 0) { |
1865 | emit incidenceSelected( 0 ); | 2050 | emit incidenceSelected( 0 ); |
1866 | return; | 2051 | return; |
1867 | } | 2052 | } |
1868 | mSelectedItem = item; | 2053 | mSelectedItem = item; |
1869 | mSelectedItem->select(); | 2054 | mSelectedItem->select(); |
1870 | emit incidenceSelected( mSelectedItem->incidence() ); | 2055 | emit incidenceSelected( mSelectedItem->incidence() ); |
1871 | } | 2056 | } |
1872 | 2057 | ||
1873 | // This function seems never be called. | 2058 | // This function seems never be called. |
1874 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2059 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1875 | { | 2060 | { |
1876 | switch(kev->key()) { | 2061 | switch(kev->key()) { |
1877 | case Key_PageDown: | 2062 | case Key_PageDown: |
1878 | verticalScrollBar()->addPage(); | 2063 | verticalScrollBar()->addPage(); |
1879 | break; | 2064 | break; |
1880 | case Key_PageUp: | 2065 | case Key_PageUp: |
1881 | verticalScrollBar()->subtractPage(); | 2066 | verticalScrollBar()->subtractPage(); |
1882 | break; | 2067 | break; |
1883 | case Key_Down: | 2068 | case Key_Down: |
1884 | verticalScrollBar()->addLine(); | 2069 | verticalScrollBar()->addLine(); |
1885 | break; | 2070 | break; |
1886 | case Key_Up: | 2071 | case Key_Up: |
1887 | verticalScrollBar()->subtractLine(); | 2072 | verticalScrollBar()->subtractLine(); |
1888 | break; | 2073 | break; |
1889 | default: | 2074 | default: |
1890 | ; | 2075 | ; |
1891 | } | 2076 | } |
1892 | } | 2077 | } |
1893 | 2078 | ||
1894 | void KOAgenda::calculateWorkingHours() | 2079 | void KOAgenda::calculateWorkingHours() |
1895 | { | 2080 | { |
1896 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2081 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1897 | mWorkingHoursEnable = !mAllDayMode; | 2082 | mWorkingHoursEnable = !mAllDayMode; |
1898 | 2083 | ||
1899 | mWorkingHoursYTop = mGridSpacingY * | 2084 | mWorkingHoursYTop = mGridSpacingY * |
1900 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2085 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1901 | mWorkingHoursYBottom = mGridSpacingY * | 2086 | mWorkingHoursYBottom = mGridSpacingY * |
1902 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2087 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1903 | } | 2088 | } |
1904 | 2089 | ||
1905 | 2090 | ||
1906 | DateList KOAgenda::dateList() const | 2091 | DateList KOAgenda::dateList() const |
1907 | { | 2092 | { |
1908 | return mSelectedDates; | 2093 | return mSelectedDates; |
1909 | } | 2094 | } |
1910 | 2095 | ||
1911 | void KOAgenda::setDateList(const DateList &selectedDates) | 2096 | void KOAgenda::setDateList(const DateList &selectedDates) |
1912 | { | 2097 | { |
1913 | mSelectedDates = selectedDates; | 2098 | mSelectedDates = selectedDates; |
1914 | marcus_bains(); | 2099 | marcus_bains(); |
1915 | } | 2100 | } |
1916 | 2101 | ||
1917 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2102 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1918 | { | 2103 | { |
1919 | mHolidayMask = mask; | 2104 | mHolidayMask = mask; |
1920 | 2105 | ||
1921 | /* | 2106 | /* |
1922 | kdDebug() << "HolidayMask: "; | 2107 | kdDebug() << "HolidayMask: "; |
1923 | for(uint i=0;i<mask->count();++i) { | 2108 | for(uint i=0;i<mask->count();++i) { |
1924 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2109 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1925 | } | 2110 | } |
1926 | kdDebug() << endl; | 2111 | kdDebug() << endl; |
1927 | */ | 2112 | */ |
1928 | } | 2113 | } |
1929 | 2114 | ||
1930 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2115 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1931 | { | 2116 | { |
1932 | 2117 | ||
1933 | QScrollView::contentsMousePressEvent(event); | 2118 | QScrollView::contentsMousePressEvent(event); |
1934 | } | 2119 | } |
1935 | 2120 | ||
1936 | void KOAgenda::storePosition() | 2121 | void KOAgenda::storePosition() |
1937 | { | 2122 | { |
1938 | //mContentPosition | 2123 | //mContentPosition |
1939 | int max = mGridSpacingY*4*24; | 2124 | int max = mGridSpacingY*4*24; |
1940 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2125 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1941 | mContentPosition = 0; | 2126 | mContentPosition = 0; |
1942 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2127 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1943 | mContentPosition = -1.0; | 2128 | mContentPosition = -1.0; |
1944 | else | 2129 | else |
1945 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2130 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1946 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2131 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1947 | 2132 | ||
1948 | } | 2133 | } |
1949 | void KOAgenda::restorePosition() | 2134 | void KOAgenda::restorePosition() |
1950 | { | 2135 | { |
1951 | int posY; | 2136 | int posY; |
1952 | int max = mGridSpacingY*4*24; | 2137 | int max = mGridSpacingY*4*24; |
1953 | if ( mContentPosition < 0 ) | 2138 | if ( mContentPosition < 0 ) |
1954 | posY = max-viewport()->height(); | 2139 | posY = max-viewport()->height(); |
1955 | else | 2140 | else |
1956 | if ( mContentPosition == 0 ) | 2141 | if ( mContentPosition == 0 ) |
1957 | posY = 0; | 2142 | posY = 0; |
1958 | else | 2143 | else |
1959 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2144 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1960 | setContentsPos (0, posY ); | 2145 | setContentsPos (0, posY ); |
1961 | //qDebug("posY %d hei %d", posY, max); | 2146 | //qDebug("posY %d hei %d", posY, max); |
1962 | 2147 | ||
1963 | } | 2148 | } |
1964 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2149 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1965 | { | 2150 | { |
1966 | ++x; | 2151 | ++x; |
1967 | QScrollView::moveChild( w, x , y ); | 2152 | QScrollView::moveChild( w, x , y ); |
1968 | } | 2153 | } |
1969 | #include <qmessagebox.h> | 2154 | #include <qmessagebox.h> |
1970 | #ifdef DESKTOP_VERSION | 2155 | #ifdef DESKTOP_VERSION |
1971 | #include <qprinter.h> | 2156 | #include <qprinter.h> |
1972 | #include <qpainter.h> | 2157 | #include <qpainter.h> |
1973 | #include <qpaintdevicemetrics.h> | 2158 | #include <qpaintdevicemetrics.h> |
1974 | 2159 | ||
1975 | #endif | 2160 | #endif |
1976 | void KOAgenda::printSelection() | 2161 | void KOAgenda::printSelection() |
1977 | { | 2162 | { |
1978 | #ifdef DESKTOP_VERSION | 2163 | #ifdef DESKTOP_VERSION |
1979 | if ( mStartCellY == mCurrentCellY ) { | 2164 | if ( mStartCellY == mCurrentCellY ) { |
1980 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2165 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1981 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2166 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1982 | i18n("OK"), 0, 0, | 2167 | i18n("OK"), 0, 0, |
1983 | 0, 1 ); | 2168 | 0, 1 ); |
1984 | return; | 2169 | return; |
1985 | } | 2170 | } |
1986 | 2171 | ||
1987 | float dx, dy; | 2172 | float dx, dy; |
1988 | int x,y,w,h; | 2173 | int x,y,w,h; |
1989 | x= 0; | 2174 | x= 0; |
1990 | w= contentsWidth()+2; | 2175 | w= contentsWidth()+2; |
1991 | // h= contentsHeight(); | 2176 | // h= contentsHeight(); |
1992 | y = mGridSpacingY*mStartCellY; | 2177 | y = mGridSpacingY*mStartCellY; |
1993 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2178 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1994 | 2179 | ||
1995 | //return; | 2180 | //return; |
1996 | QPrinter* printer = new QPrinter(); | 2181 | QPrinter* printer = new QPrinter(); |
1997 | if ( !printer->setup()) { | 2182 | if ( !printer->setup()) { |
1998 | delete printer; | 2183 | delete printer; |
1999 | return; | 2184 | return; |
2000 | } | 2185 | } |
2001 | QPainter p( printer ); | 2186 | QPainter p( printer ); |
2002 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2187 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2003 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2188 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2004 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2189 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2005 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2190 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2006 | // p.drawText( 0, 0, date ); | 2191 | // p.drawText( 0, 0, date ); |
2007 | int offset = m.width()/8; | 2192 | int offset = m.width()/8; |
2008 | // compute the scale | 2193 | // compute the scale |
2009 | dx = ((float) m.width()-offset) / (float)w; | 2194 | dx = ((float) m.width()-offset) / (float)w; |
2010 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2195 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2011 | float scale; | 2196 | float scale; |
2012 | // scale to fit the width or height of the paper | 2197 | // scale to fit the width or height of the paper |
2013 | if ( dx < dy ) | 2198 | if ( dx < dy ) |
2014 | scale = dx; | 2199 | scale = dx; |
2015 | else | 2200 | else |
2016 | scale = dy; | 2201 | scale = dy; |
2017 | // set the scale | 2202 | // set the scale |
2018 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2203 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2019 | 2204 | ||
2020 | int selDay; | 2205 | int selDay; |
2021 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2206 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2022 | float startX = 1; | 2207 | float startX = 1; |
2023 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2208 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2024 | { | 2209 | { |
2025 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2210 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2026 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2211 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2027 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2212 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2028 | startX += widOffset; | 2213 | startX += widOffset; |
2029 | 2214 | ||
2030 | } | 2215 | } |
2031 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2216 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2032 | p.scale( scale, scale ); | 2217 | p.scale( scale, scale ); |
2033 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2218 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2034 | // now printing with y offset: 2 hei | 2219 | // now printing with y offset: 2 hei |
2035 | // p.translate( 0, -y*scale); | 2220 | // p.translate( 0, -y*scale); |
2036 | 2221 | ||
2037 | drawContentsToPainter(&p, true ); | 2222 | drawContentsToPainter(&p, true ); |
2038 | globalFlagBlockAgendaItemUpdate = false; | 2223 | globalFlagBlockAgendaItemUpdate = false; |
2039 | KOAgendaItem *item; | 2224 | KOAgendaItem *item; |
2040 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2225 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2041 | item->select(false); | 2226 | item->select(false); |
2042 | item->paintMe( false, &p ); | 2227 | item->paintMe( false, &p ); |
2043 | } | 2228 | } |
2044 | globalFlagBlockAgendaItemUpdate = true; | 2229 | globalFlagBlockAgendaItemUpdate = true; |
2045 | p.end(); | 2230 | p.end(); |
2046 | delete printer; | 2231 | delete printer; |
2047 | #else | 2232 | #else |
2048 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2233 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2049 | i18n("Not supported \non PDA!\n"), | 2234 | i18n("Not supported \non PDA!\n"), |
2050 | i18n("OK"), 0, 0, | 2235 | i18n("OK"), 0, 0, |
2051 | 0, 1 ); | 2236 | 0, 1 ); |
2052 | #endif | 2237 | #endif |
2053 | } | 2238 | } |
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 | ||
35 | class QPopupMenu; | 35 | class QPopupMenu; |
36 | class QTime; | 36 | class QTime; |
37 | class KConfig; | 37 | class KConfig; |
38 | class QFrame; | 38 | class QFrame; |
39 | class KOAgenda; | 39 | class KOAgenda; |
40 | class KCal::Event; | 40 | class KCal::Event; |
41 | class KCal::Todo; | 41 | class KCal::Todo; |
42 | 42 | ||
43 | using namespace KCal; | 43 | using namespace KCal; |
44 | 44 | ||
45 | class MarcusBains : public QFrame { | 45 | class 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 | ||
65 | class KOAgenda : public QScrollView | 65 | class 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,804 +1,804 @@ | |||
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> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern 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 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::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 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString 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 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void 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 | ||
155 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
156 | { | 156 | { |
157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
158 | // delete mKOAgendaItemWhatsThis; | 158 | // delete mKOAgendaItemWhatsThis; |
159 | } | 159 | } |
160 | 160 | ||
161 | void KOAgendaItem::recreateIncidence() | 161 | void 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 | } |
177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool 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 | ||
262 | void KOAgendaItem::select(bool selected) | 262 | void 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 | */ |
290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 290 | bool 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 | } |
305 | void KOAgendaItem::repaintMe( ) | 305 | void KOAgendaItem::repaintMe( ) |
306 | { | 306 | { |
307 | paintMe ( mSelected ); | 307 | paintMe ( mSelected ); |
308 | } | 308 | } |
309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 309 | void 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 | } |
433 | void KOAgendaItem::resizePixmap( int w , int h ) | 433 | void 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 | } |
439 | QPixmap * KOAgendaItem::paintPix() | 439 | QPixmap * 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 | } |
446 | QPixmap * KOAgendaItem::paintPixAllday() | 446 | QPixmap * 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 | } |
453 | QPixmap * KOAgendaItem::paintPixSel() | 453 | QPixmap * 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 | } |
460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
461 | { | 461 | { |
462 | 462 | ||
463 | if ( globalFlagBlockAgendaItemPaint ) | 463 | if ( globalFlagBlockAgendaItemPaint ) |
464 | return; | 464 | return; |
465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
466 | return; | 466 | return; |
467 | int yy; | 467 | int yy; |
468 | if ( mAllDay ) | 468 | if ( mAllDay ) |
469 | yy = y(); | 469 | yy = y(); |
470 | else | 470 | else |
471 | yy = mCellYTop * ( height() / cellHeight() ); | 471 | yy = mCellYTop * ( height() / cellHeight() ); |
472 | int xx = x(); | 472 | int xx = x(); |
473 | 473 | ||
474 | if ( xPaintCoord != xx || yPaintCoord != yy || | 474 | if ( xPaintCoord != xx || yPaintCoord != yy || |
475 | wPaintCoord != width() || hPaintCoord != height()) { | 475 | wPaintCoord != width() || hPaintCoord != height()) { |
476 | xPaintCoord= xx; | 476 | xPaintCoord= xx; |
477 | yPaintCoord = yy; | 477 | yPaintCoord = yy; |
478 | wPaintCoord = width(); | 478 | wPaintCoord = width(); |
479 | hPaintCoord = height(); | 479 | hPaintCoord = height(); |
480 | globalFlagBlockAgendaItemUpdate = 0; | 480 | globalFlagBlockAgendaItemUpdate = 0; |
481 | paintMe( mSelected ); | 481 | paintMe( mSelected ); |
482 | //qDebug("calling paintMe "); | 482 | //qDebug("calling paintMe "); |
483 | globalFlagBlockAgendaItemUpdate = 1; | 483 | globalFlagBlockAgendaItemUpdate = 1; |
484 | } | 484 | } |
485 | int rx, ry, rw, rh; | 485 | int rx, ry, rw, rh; |
486 | rx = e->rect().x(); | 486 | rx = e->rect().x(); |
487 | ry = e->rect().y(); | 487 | ry = e->rect().y(); |
488 | rw = e->rect().width(); | 488 | rw = e->rect().width(); |
489 | rh = e->rect().height(); | 489 | rh = e->rect().height(); |
490 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 490 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
491 | 491 | ||
492 | QPixmap* paintFrom ; | 492 | QPixmap* paintFrom ; |
493 | if ( mSelected ) { | 493 | if ( mSelected ) { |
494 | paintFrom = paintPixSel(); | 494 | paintFrom = paintPixSel(); |
495 | } else { | 495 | } else { |
496 | if ( mAllDay ) | 496 | if ( mAllDay ) |
497 | paintFrom = paintPixAllday(); | 497 | paintFrom = paintPixAllday(); |
498 | else | 498 | else |
499 | paintFrom = paintPix(); | 499 | paintFrom = paintPix(); |
500 | } | 500 | } |
501 | xx += rx; | 501 | xx += rx; |
502 | 502 | ||
503 | if ( xx < 0 ) { | 503 | if ( xx < 0 ) { |
504 | rw = rw + xx; | 504 | rw = rw + xx; |
505 | rx -= xx; | 505 | rx -= xx; |
506 | xx = 0; | 506 | xx = 0; |
507 | if ( rw <= 1 ) { | 507 | if ( rw <= 1 ) { |
508 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 508 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
509 | return; | 509 | return; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | if ( paintFrom->width() < xx+rw ) { | 512 | if ( paintFrom->width() < xx+rw ) { |
513 | rw = paintFrom->width() - xx; | 513 | rw = paintFrom->width() - xx; |
514 | if ( rw <= 1 ) { | 514 | if ( rw <= 1 ) { |
515 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 515 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
516 | return; | 516 | return; |
517 | } | 517 | } |
518 | } | 518 | } |
519 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 519 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
520 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 520 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
521 | } | 521 | } |
522 | void KOAgendaItem::computeText() | 522 | void KOAgendaItem::computeText() |
523 | { | 523 | { |
524 | 524 | ||
525 | mDisplayedText = mIncidence->summary(); | 525 | mDisplayedText = mIncidence->summary(); |
526 | if ( (mIncidence->type() == "Todo") ) { | 526 | if ( (mIncidence->type() == "Todo") ) { |
527 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 527 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
528 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 528 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
529 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 529 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
530 | else if ( !(mIncidence->doesFloat())) | 530 | else if ( !(mIncidence->doesFloat())) |
531 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 531 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
532 | } | 532 | } |
533 | } else { | 533 | } else { |
534 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 534 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
535 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 535 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
536 | 536 | ||
537 | if ( mAllDay ) { | 537 | if ( mAllDay ) { |
538 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 538 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
539 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 539 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | } | 543 | } |
544 | 544 | ||
545 | if ( !mIncidence->location().isEmpty() ) { | 545 | if ( !mIncidence->location().isEmpty() ) { |
546 | if ( mAllDay ) | 546 | if ( mAllDay ) |
547 | mDisplayedText += " ("; | 547 | mDisplayedText += " ("; |
548 | else | 548 | else |
549 | mDisplayedText += "\n("; | 549 | mDisplayedText += "\n("; |
550 | mDisplayedText += mIncidence->location() +")"; | 550 | mDisplayedText += mIncidence->location() +")"; |
551 | } | 551 | } |
552 | 552 | ||
553 | QString tipText = mIncidence->summary(); | 553 | QString tipText = mIncidence->summary(); |
554 | if ( !mIncidence->doesFloat() ) { | 554 | if ( !mIncidence->doesFloat() ) { |
555 | if ( mIncidence->type() == "Event" ) { | 555 | if ( mIncidence->type() == "Event" ) { |
556 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 556 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
557 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 557 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
558 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 558 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
559 | } | 559 | } |
560 | else { | 560 | else { |
561 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 561 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
562 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 562 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
563 | } | 563 | } |
564 | } | 564 | } |
565 | else if ( mIncidence->type() == "Todo" ) { | 565 | else if ( mIncidence->type() == "Todo" ) { |
566 | if (mIncidence->hasStartDate()) | 566 | if (mIncidence->hasStartDate()) |
567 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 567 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
568 | if (((Todo*)mIncidence)->hasDueDate()) | 568 | if (((Todo*)mIncidence)->hasDueDate()) |
569 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 569 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
570 | } | 570 | } |
571 | } else if ( mIncidence->type() == "Todo" ) { | 571 | } else if ( mIncidence->type() == "Todo" ) { |
572 | if (mIncidence->hasStartDate()) | 572 | if (mIncidence->hasStartDate()) |
573 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 573 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
574 | if (((Todo*)mIncidence)->hasDueDate()) | 574 | if (((Todo*)mIncidence)->hasDueDate()) |
575 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 575 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
576 | } | 576 | } |
577 | 577 | ||
578 | if (!mIncidence->location().isEmpty()) { | 578 | if (!mIncidence->location().isEmpty()) { |
579 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 579 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
580 | } | 580 | } |
581 | QToolTip::add(this,tipText,toolTipGroup(),""); | 581 | QToolTip::add(this,tipText,toolTipGroup(),""); |
582 | 582 | ||
583 | } | 583 | } |
584 | void KOAgendaItem::updateItem() | 584 | void KOAgendaItem::updateItem() |
585 | { | 585 | { |
586 | computeText(); | 586 | computeText(); |
587 | 587 | ||
588 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 588 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
589 | paintMe( mSelected ); | 589 | paintMe( mSelected ); |
590 | repaint( false); | 590 | repaint( false); |
591 | } | 591 | } |
592 | 592 | ||
593 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 593 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
594 | { | 594 | { |
595 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 595 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
596 | paintMe( mSelected ); | 596 | paintMe( mSelected ); |
597 | repaint( false ); | 597 | repaint( false ); |
598 | } | 598 | } |
599 | 599 | ||
600 | /* | 600 | /* |
601 | Return height of item in units of agenda cells | 601 | Return height of item in units of agenda cells |
602 | */ | 602 | */ |
603 | int KOAgendaItem::cellHeight() | 603 | int KOAgendaItem::cellHeight() |
604 | { | 604 | { |
605 | int ret = mCellYBottom - mCellYTop + 1; | 605 | int ret = mCellYBottom - mCellYTop + 1; |
606 | if ( ret <= 0 ) { | 606 | if ( ret <= 0 ) { |
607 | ret = 1; | 607 | ret = 1; |
608 | mCellYBottom = 0; | 608 | mCellYBottom = 0; |
609 | mCellYTop = 0; | 609 | mCellYTop = 0; |
610 | } | 610 | } |
611 | return ret; | 611 | return ret; |
612 | } | 612 | } |
613 | 613 | ||
614 | /* | 614 | /* |
615 | Return height of item in units of agenda cells | 615 | Return height of item in units of agenda cells |
616 | */ | 616 | */ |
617 | int KOAgendaItem::cellWidth() | 617 | int KOAgendaItem::cellWidth() |
618 | { | 618 | { |
619 | return mCellXWidth - mCellX + 1; | 619 | return mCellXWidth - mCellX + 1; |
620 | } | 620 | } |
621 | 621 | ||
622 | void KOAgendaItem::setItemDate(QDate qd) | 622 | void KOAgendaItem::setItemDate(QDate qd) |
623 | { | 623 | { |
624 | mDate = qd; | 624 | mDate = qd; |
625 | } | 625 | } |
626 | 626 | ||
627 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 627 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
628 | { | 628 | { |
629 | mCellX = X; | 629 | mCellX = X; |
630 | mCellYTop = YTop; | 630 | mCellYTop = YTop; |
631 | mCellYBottom = YBottom; | 631 | mCellYBottom = YBottom; |
632 | } | 632 | } |
633 | 633 | ||
634 | void KOAgendaItem::setCellXWidth(int xwidth) | 634 | void KOAgendaItem::setCellXWidth(int xwidth) |
635 | { | 635 | { |
636 | mCellXWidth = xwidth; | 636 | mCellXWidth = xwidth; |
637 | } | 637 | } |
638 | 638 | ||
639 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 639 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
640 | { | 640 | { |
641 | mCellX = XLeft; | 641 | mCellX = XLeft; |
642 | mCellXWidth = XRight; | 642 | mCellXWidth = XRight; |
643 | } | 643 | } |
644 | 644 | ||
645 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 645 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
646 | { | 646 | { |
647 | mCellYTop = YTop; | 647 | mCellYTop = YTop; |
648 | mCellYBottom = YBottom; | 648 | mCellYBottom = YBottom; |
649 | } | 649 | } |
650 | 650 | ||
651 | void KOAgendaItem::setSubCell(int subCell) | 651 | void KOAgendaItem::setSubCell(int subCell) |
652 | { | 652 | { |
653 | mSubCell = subCell; | 653 | mSubCell = subCell; |
654 | } | 654 | } |
655 | 655 | ||
656 | void KOAgendaItem::setSubCells(int subCells) | 656 | void KOAgendaItem::setSubCells(int subCells) |
657 | { | 657 | { |
658 | mSubCells = subCells; | 658 | mSubCells = subCells; |
659 | } | 659 | } |
660 | 660 | ||
661 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 661 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
662 | KOAgendaItem *last) | 662 | KOAgendaItem *last) |
663 | { | 663 | { |
664 | mFirstMultiItem = first; | 664 | mFirstMultiItem = first; |
665 | mNextMultiItem = next; | 665 | mNextMultiItem = next; |
666 | mLastMultiItem = last; | 666 | mLastMultiItem = last; |
667 | } | 667 | } |
668 | 668 | ||
669 | void KOAgendaItem::startMove() | 669 | void KOAgendaItem::startMove() |
670 | { | 670 | { |
671 | mStartCellX = mCellX; | 671 | mStartCellX = mCellX; |
672 | mStartCellXWidth = mCellXWidth; | 672 | mStartCellXWidth = mCellXWidth; |
673 | mStartCellYTop = mCellYTop; | 673 | mStartCellYTop = mCellYTop; |
674 | mStartCellYBottom = mCellYBottom; | 674 | mStartCellYBottom = mCellYBottom; |
675 | } | 675 | } |
676 | 676 | ||
677 | void KOAgendaItem::resetMove() | 677 | void KOAgendaItem::resetMove() |
678 | { | 678 | { |
679 | mCellX = mStartCellX; | 679 | mCellX = mStartCellX; |
680 | mCellXWidth = mStartCellXWidth; | 680 | mCellXWidth = mStartCellXWidth; |
681 | mCellYTop = mStartCellYTop; | 681 | mCellYTop = mStartCellYTop; |
682 | mCellYBottom = mStartCellYBottom; | 682 | mCellYBottom = mStartCellYBottom; |
683 | } | 683 | } |
684 | 684 | ||
685 | void KOAgendaItem::moveRelative(int dx, int dy) | 685 | void KOAgendaItem::moveRelative(int dx, int dy) |
686 | { | 686 | { |
687 | int newX = cellX() + dx; | 687 | int newX = cellX() + dx; |
688 | int newXWidth = cellXWidth() + dx; | 688 | int newXWidth = cellXWidth() + dx; |
689 | int newYTop = cellYTop() + dy; | 689 | int newYTop = cellYTop() + dy; |
690 | int newYBottom = cellYBottom() + dy; | 690 | int newYBottom = cellYBottom() + dy; |
691 | setCellXY(newX,newYTop,newYBottom); | 691 | setCellXY(newX,newYTop,newYBottom); |
692 | setCellXWidth(newXWidth); | 692 | setCellXWidth(newXWidth); |
693 | } | 693 | } |
694 | 694 | ||
695 | void KOAgendaItem::expandTop(int dy) | 695 | void KOAgendaItem::expandTop(int dy) |
696 | { | 696 | { |
697 | int newYTop = cellYTop() + dy; | 697 | int newYTop = cellYTop() + dy; |
698 | int newYBottom = cellYBottom(); | 698 | int newYBottom = cellYBottom(); |
699 | if (newYTop > newYBottom) newYTop = newYBottom; | 699 | if (newYTop > newYBottom) newYTop = newYBottom; |
700 | setCellY(newYTop, newYBottom); | 700 | setCellY(newYTop, newYBottom); |
701 | } | 701 | } |
702 | 702 | ||
703 | void KOAgendaItem::expandBottom(int dy) | 703 | void KOAgendaItem::expandBottom(int dy) |
704 | { | 704 | { |
705 | int newYTop = cellYTop(); | 705 | int newYTop = cellYTop(); |
706 | int newYBottom = cellYBottom() + dy; | 706 | int newYBottom = cellYBottom() + dy; |
707 | if (newYBottom < newYTop) newYBottom = newYTop; | 707 | if (newYBottom < newYTop) newYBottom = newYTop; |
708 | setCellY(newYTop, newYBottom); | 708 | setCellY(newYTop, newYBottom); |
709 | } | 709 | } |
710 | 710 | ||
711 | void KOAgendaItem::expandLeft(int dx) | 711 | void KOAgendaItem::expandLeft(int dx) |
712 | { | 712 | { |
713 | int newX = cellX() + dx; | 713 | int newX = cellX() + dx; |
714 | int newXWidth = cellXWidth(); | 714 | int newXWidth = cellXWidth(); |
715 | if (newX > newXWidth) newX = newXWidth; | 715 | if (newX > newXWidth) newX = newXWidth; |
716 | setCellX(newX,newXWidth); | 716 | setCellX(newX,newXWidth); |
717 | } | 717 | } |
718 | 718 | ||
719 | void KOAgendaItem::expandRight(int dx) | 719 | void KOAgendaItem::expandRight(int dx) |
720 | { | 720 | { |
721 | int newX = cellX(); | 721 | int newX = cellX(); |
722 | int newXWidth = cellXWidth() + dx; | 722 | int newXWidth = cellXWidth() + dx; |
723 | if (newXWidth < newX) newXWidth = newX; | 723 | if (newXWidth < newX) newXWidth = newX; |
724 | setCellX(newX,newXWidth); | 724 | setCellX(newX,newXWidth); |
725 | } | 725 | } |
726 | 726 | ||
727 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 727 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
728 | { | 728 | { |
729 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 729 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
730 | return mToolTipGroup; | 730 | return mToolTipGroup; |
731 | } | 731 | } |
732 | 732 | ||
733 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 733 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
734 | { | 734 | { |
735 | #ifndef KORG_NODND | 735 | #ifndef KORG_NODND |
736 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 736 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
737 | !QTextDrag::canDecode( e ) ) { | 737 | !QTextDrag::canDecode( e ) ) { |
738 | e->ignore(); | 738 | e->ignore(); |
739 | return; | 739 | return; |
740 | } | 740 | } |
741 | e->accept(); | 741 | e->accept(); |
742 | #endif | 742 | #endif |
743 | } | 743 | } |
744 | 744 | ||
745 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 745 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
746 | { | 746 | { |
747 | #ifndef KORG_NODND | 747 | #ifndef KORG_NODND |
748 | QString text; | 748 | QString text; |
749 | if(QTextDrag::decode(e,text)) | 749 | if(QTextDrag::decode(e,text)) |
750 | { | 750 | { |
751 | kdDebug() << "Dropped : " << text << endl; | 751 | kdDebug() << "Dropped : " << text << endl; |
752 | QStringList emails = QStringList::split(",",text); | 752 | QStringList emails = QStringList::split(",",text); |
753 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 753 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
754 | kdDebug() << " Email: " << (*it) << endl; | 754 | kdDebug() << " Email: " << (*it) << endl; |
755 | int pos = (*it).find("<"); | 755 | int pos = (*it).find("<"); |
756 | QString name = (*it).left(pos); | 756 | QString name = (*it).left(pos); |
757 | QString email = (*it).mid(pos); | 757 | QString email = (*it).mid(pos); |
758 | if (!email.isEmpty()) { | 758 | if (!email.isEmpty()) { |
759 | mIncidence->addAttendee(new Attendee(name,email)); | 759 | mIncidence->addAttendee(new Attendee(name,email)); |
760 | } | 760 | } |
761 | } | 761 | } |
762 | } | 762 | } |
763 | #endif | 763 | #endif |
764 | } | 764 | } |
765 | 765 | ||
766 | 766 | ||
767 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 767 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
768 | { | 768 | { |
769 | return mConflictItems; | 769 | return mConflictItems; |
770 | } | 770 | } |
771 | 771 | ||
772 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 772 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
773 | { | 773 | { |
774 | mConflictItems = ci; | 774 | mConflictItems = ci; |
775 | KOAgendaItem *item; | 775 | KOAgendaItem *item; |
776 | for ( item=mConflictItems.first(); item != 0; | 776 | for ( item=mConflictItems.first(); item != 0; |
777 | item=mConflictItems.next() ) { | 777 | item=mConflictItems.next() ) { |
778 | item->addConflictItem(this); | 778 | item->addConflictItem(this); |
779 | } | 779 | } |
780 | } | 780 | } |
781 | 781 | ||
782 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 782 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
783 | { | 783 | { |
784 | if (mConflictItems.find(ci)<0) | 784 | if (mConflictItems.find(ci)<0) |
785 | mConflictItems.append(ci); | 785 | mConflictItems.append(ci); |
786 | } | 786 | } |
787 | 787 | ||
788 | bool KOAgendaItem::checkLayout() | 788 | bool KOAgendaItem::checkLayout() |
789 | { | 789 | { |
790 | if ( !mConflictItems.count() ) | 790 | if ( !mConflictItems.count() ) |
791 | return true; | 791 | return true; |
792 | int max = 0; | 792 | int max = 0; |
793 | KOAgendaItem *item; | 793 | KOAgendaItem *item; |
794 | for ( item=mConflictItems.first(); item != 0; | 794 | for ( item=mConflictItems.first(); item != 0; |
795 | item=mConflictItems.next() ) { | 795 | item=mConflictItems.next() ) { |
796 | if ( item->subCells() > max ) | 796 | if ( item->subCells() > max ) |
797 | max = item->subCells(); | 797 | max = item->subCells(); |
798 | } | 798 | } |
799 | if ( max > subCells() ) { | 799 | if ( max > subCells() ) { |
800 | setSubCells( max ); | 800 | setSubCells( max ); |
801 | return false; | 801 | return false; |
802 | } | 802 | } |
803 | return true; | 803 | return true; |
804 | } | 804 | } |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 957ac52..b9c7dec 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1589 +1,1581 @@ | |||
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; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::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 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void 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 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void 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 | */ |
180 | int TimeLabels::minimumWidth() const | 180 | int 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 */ |
194 | void TimeLabels::updateConfig() | 186 | void 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 */ |
210 | void TimeLabels::positionChanged() | 202 | void 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 | /** */ |
217 | void TimeLabels::setAgenda(KOAgenda* agenda) | 209 | void TimeLabels::setAgenda(KOAgenda* agenda) |
218 | { | 210 | { |
219 | mAgenda = agenda; | 211 | mAgenda = agenda; |
220 | } | 212 | } |
221 | 213 | ||
222 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 214 | void 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 | ||
228 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 220 | void 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 | } |
242 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 234 | void 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() */ |
261 | void TimeLabels::paintEvent(QPaintEvent*) | 253 | void 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 | ||
273 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 265 | EventIndicator::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 | ||
289 | EventIndicator::~EventIndicator() | 281 | EventIndicator::~EventIndicator() |
290 | { | 282 | { |
291 | } | 283 | } |
292 | 284 | ||
293 | void EventIndicator::drawContents(QPainter *p) | 285 | void 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 | ||
337 | void EventIndicator::setXOffset( int x ) | 329 | void EventIndicator::setXOffset( int x ) |
338 | { | 330 | { |
339 | mXOffset = x; | 331 | mXOffset = x; |
340 | } | 332 | } |
341 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 333 | void 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 | } |
347 | void EventIndicator::changeColumns(int columns) | 339 | void 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 | ||
355 | void EventIndicator::enableColumn(int column, bool enable) | 347 | void 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 | ||
365 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 357 | KOAgendaView::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 | ||
560 | void KOAgendaView::toggleAllDay() | 552 | void KOAgendaView::toggleAllDay() |
561 | { | 553 | { |
562 | if ( mSplitterAgenda->firstHandle() ) | 554 | if ( mSplitterAgenda->firstHandle() ) |
563 | mSplitterAgenda->firstHandle()->toggle(); | 555 | mSplitterAgenda->firstHandle()->toggle(); |
564 | } | 556 | } |
565 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 557 | void 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 | ||
578 | KOAgendaView::~KOAgendaView() | 570 | KOAgendaView::~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 | } |
585 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 577 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
586 | { | 578 | { |
587 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 579 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
588 | bool uc = false; | 580 | bool uc = false; |
589 | int ow = e->oldSize().width(); | 581 | int ow = e->oldSize().width(); |
590 | int oh = e->oldSize().height(); | 582 | int oh = e->oldSize().height(); |
591 | int w = e->size().width(); | 583 | int w = e->size().width(); |
592 | int h = e->size().height(); | 584 | int h = e->size().height(); |
593 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 585 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
594 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 586 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
595 | uc = true; | 587 | uc = true; |
596 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 588 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
597 | } | 589 | } |
598 | mUpcomingWidth = e->size().width() ; | 590 | mUpcomingWidth = e->size().width() ; |
599 | if ( mBlockUpdating || uc ) { | 591 | if ( mBlockUpdating || uc ) { |
600 | mBlockUpdating = false; | 592 | mBlockUpdating = false; |
601 | //mAgenda->setMinimumSize(800 , 600 ); | 593 | //mAgenda->setMinimumSize(800 , 600 ); |
602 | //qDebug("mAgenda->resize+++++++++++++++ "); | 594 | //qDebug("mAgenda->resize+++++++++++++++ "); |
603 | updateConfig(); | 595 | updateConfig(); |
604 | //qDebug("KOAgendaView::Updating now possible "); | 596 | //qDebug("KOAgendaView::Updating now possible "); |
605 | } else | 597 | } else |
606 | createDayLabels(); | 598 | createDayLabels(); |
607 | //qDebug("resizeEvent end "); | 599 | //qDebug("resizeEvent end "); |
608 | 600 | ||
609 | } | 601 | } |
610 | void KOAgendaView::slotDaylabelClicked( int num ) | 602 | void KOAgendaView::slotDaylabelClicked( int num ) |
611 | { | 603 | { |
612 | 604 | ||
613 | QDate firstDate = mSelectedDates.first(); | 605 | QDate firstDate = mSelectedDates.first(); |
614 | if ( num == -1 ) | 606 | if ( num == -1 ) |
615 | emit showDateView( 6, firstDate ); | 607 | emit showDateView( 6, firstDate ); |
616 | else if (num >= 0 ) { | 608 | else if (num >= 0 ) { |
617 | if ( mSelectedDates.count() == 1) | 609 | if ( mSelectedDates.count() == 1) |
618 | emit showDateView( 9, firstDate.addDays( num ) ); | 610 | emit showDateView( 9, firstDate.addDays( num ) ); |
619 | else | 611 | else |
620 | emit showDateView( 3, firstDate.addDays( num ) ); | 612 | emit showDateView( 3, firstDate.addDays( num ) ); |
621 | } | 613 | } |
622 | else | 614 | else |
623 | showDateView( 10, firstDate.addDays(1) ); | 615 | showDateView( 10, firstDate.addDays(1) ); |
624 | } | 616 | } |
625 | 617 | ||
626 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 618 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
627 | { | 619 | { |
628 | 620 | ||
629 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 621 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
630 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 622 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
631 | mDayLabelsList.append( dayLabel ); | 623 | mDayLabelsList.append( dayLabel ); |
632 | mLayoutDayLabels->addWidget(dayLabel); | 624 | mLayoutDayLabels->addWidget(dayLabel); |
633 | return dayLabel ; | 625 | return dayLabel ; |
634 | } | 626 | } |
635 | 627 | ||
636 | void KOAgendaView::createDayLabels() | 628 | void KOAgendaView::createDayLabels() |
637 | { | 629 | { |
638 | 630 | ||
639 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 631 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
640 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 632 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
641 | return; | 633 | return; |
642 | 634 | ||
643 | } | 635 | } |
644 | int newHight; | 636 | int newHight; |
645 | 637 | ||
646 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 638 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
647 | // It would remove some flickering and gain speed (since this is called by | 639 | // It would remove some flickering and gain speed (since this is called by |
648 | // each updateView() call) | 640 | // each updateView() call) |
649 | 641 | ||
650 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 642 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
651 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 643 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
652 | if ( maxWid < 0 ) | 644 | if ( maxWid < 0 ) |
653 | maxWid = 20; | 645 | maxWid = 20; |
654 | 646 | ||
655 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 647 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
656 | QFontMetrics fm ( dlf ); | 648 | QFontMetrics fm ( dlf ); |
657 | int selCount = mSelectedDates.count(); | 649 | int selCount = mSelectedDates.count(); |
658 | QString dayTest = "Mon 20"; | 650 | QString dayTest = "Mon 20"; |
659 | //QString dayTest = "Mon 20"; | 651 | //QString dayTest = "Mon 20"; |
660 | int wid = fm.width( dayTest ); | 652 | int wid = fm.width( dayTest ); |
661 | //maxWid -= ( selCount * 3 ); //working for QLabels | 653 | //maxWid -= ( selCount * 3 ); //working for QLabels |
662 | maxWid -= ( selCount * 3 ); //working for QPushButton | 654 | maxWid -= ( selCount * 3 ); //working for QPushButton |
663 | if ( maxWid < 0 ) | 655 | if ( maxWid < 0 ) |
664 | maxWid = 20; | 656 | maxWid = 20; |
665 | int needWid = wid * selCount; | 657 | int needWid = wid * selCount; |
666 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 658 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
667 | //if ( needWid > maxWid ) | 659 | //if ( needWid > maxWid ) |
668 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 660 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
669 | while ( needWid > maxWid ) { | 661 | while ( needWid > maxWid ) { |
670 | dayTest = dayTest.left( dayTest.length() - 1 ); | 662 | dayTest = dayTest.left( dayTest.length() - 1 ); |
671 | wid = fm.width( dayTest ); | 663 | wid = fm.width( dayTest ); |
672 | needWid = wid * selCount; | 664 | needWid = wid * selCount; |
673 | } | 665 | } |
674 | int maxLen = dayTest.length(); | 666 | int maxLen = dayTest.length(); |
675 | int fontPoint = dlf.pointSize(); | 667 | int fontPoint = dlf.pointSize(); |
676 | if ( maxLen < 2 ) { | 668 | if ( maxLen < 2 ) { |
677 | int fontPoint = dlf.pointSize(); | 669 | int fontPoint = dlf.pointSize(); |
678 | while ( fontPoint > 4 ) { | 670 | while ( fontPoint > 4 ) { |
679 | --fontPoint; | 671 | --fontPoint; |
680 | dlf.setPointSize( fontPoint ); | 672 | dlf.setPointSize( fontPoint ); |
681 | QFontMetrics f( dlf ); | 673 | QFontMetrics f( dlf ); |
682 | wid = f.width( "30" ); | 674 | wid = f.width( "30" ); |
683 | needWid = wid * selCount; | 675 | needWid = wid * selCount; |
684 | if ( needWid < maxWid ) | 676 | if ( needWid < maxWid ) |
685 | break; | 677 | break; |
686 | } | 678 | } |
687 | maxLen = 2; | 679 | maxLen = 2; |
688 | } | 680 | } |
689 | //qDebug("Max len %d ", dayTest.length() ); | 681 | //qDebug("Max len %d ", dayTest.length() ); |
690 | 682 | ||
691 | QFontMetrics tempF( dlf ); | 683 | QFontMetrics tempF( dlf ); |
692 | newHight = tempF.height(); | 684 | newHight = tempF.height(); |
693 | mDayLabels->setFont( dlf ); | 685 | mDayLabels->setFont( dlf ); |
694 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 686 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
695 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 687 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
696 | //mLayoutDayLabels->addSpacing( 2 ); | 688 | //mLayoutDayLabels->addSpacing( 2 ); |
697 | // QFont lFont = dlf; | 689 | // QFont lFont = dlf; |
698 | bool appendLabels = false; | 690 | bool appendLabels = false; |
699 | KOAgendaButton *dayLabel; | 691 | KOAgendaButton *dayLabel; |
700 | dayLabel = mDayLabelsList.first(); | 692 | dayLabel = mDayLabelsList.first(); |
701 | if ( !dayLabel ) { | 693 | if ( !dayLabel ) { |
702 | appendLabels = true; | 694 | appendLabels = true; |
703 | dayLabel = getNewDaylabel(); | 695 | dayLabel = getNewDaylabel(); |
704 | } | 696 | } |
705 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 697 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
706 | dayLabel->setFont( dlf ); | 698 | dayLabel->setFont( dlf ); |
707 | dayLabel->setNum( -1 ); | 699 | dayLabel->setNum( -1 ); |
708 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 700 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
709 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 701 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
710 | dayLabel->show(); | 702 | dayLabel->show(); |
711 | DateList::ConstIterator dit; | 703 | DateList::ConstIterator dit; |
712 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 704 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
713 | int counter = -1; | 705 | int counter = -1; |
714 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 706 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
715 | ++counter; | 707 | ++counter; |
716 | QDate date = *dit; | 708 | QDate date = *dit; |
717 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 709 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
718 | if ( ! appendLabels ) { | 710 | if ( ! appendLabels ) { |
719 | dayLabel = mDayLabelsList.next(); | 711 | dayLabel = mDayLabelsList.next(); |
720 | if ( !dayLabel ) | 712 | if ( !dayLabel ) |
721 | appendLabels = true; | 713 | appendLabels = true; |
722 | } | 714 | } |
723 | if ( appendLabels ) { | 715 | if ( appendLabels ) { |
724 | dayLabel = getNewDaylabel(); | 716 | dayLabel = getNewDaylabel(); |
725 | } | 717 | } |
726 | dayLabel->setMinimumWidth( 1 ); | 718 | dayLabel->setMinimumWidth( 1 ); |
727 | dayLabel->setMaximumWidth( 10240 ); | 719 | dayLabel->setMaximumWidth( 10240 ); |
728 | dayLabel->setFont( dlf ); | 720 | dayLabel->setFont( dlf ); |
729 | dayLabel->show(); | 721 | dayLabel->show(); |
730 | dayLabel->setNum( counter ); | 722 | dayLabel->setNum( counter ); |
731 | QString str; | 723 | QString str; |
732 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 724 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
733 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 725 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
734 | switch ( maxLen ) { | 726 | switch ( maxLen ) { |
735 | case 2: | 727 | case 2: |
736 | str = QString::number( date.day() ); | 728 | str = QString::number( date.day() ); |
737 | break; | 729 | break; |
738 | 730 | ||
739 | case 3: | 731 | case 3: |
740 | str = dayName.left( 1 ) +QString::number( date.day()); | 732 | str = dayName.left( 1 ) +QString::number( date.day()); |
741 | 733 | ||
742 | break; | 734 | break; |
743 | case 4: | 735 | case 4: |
744 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 736 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
745 | 737 | ||
746 | break; | 738 | break; |
747 | case 5: | 739 | case 5: |
748 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 740 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
749 | 741 | ||
750 | break; | 742 | break; |
751 | case 6: | 743 | case 6: |
752 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 744 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
753 | break; | 745 | break; |
754 | 746 | ||
755 | default: | 747 | default: |
756 | break; | 748 | break; |
757 | } | 749 | } |
758 | if ( oneday ) { | 750 | if ( oneday ) { |
759 | QString addString; | 751 | QString addString; |
760 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 752 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
761 | addString = i18n("Today"); | 753 | addString = i18n("Today"); |
762 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 754 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
763 | addString = i18n("Tomorrow"); | 755 | addString = i18n("Tomorrow"); |
764 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 756 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
765 | addString = i18n("Yesterday"); | 757 | addString = i18n("Yesterday"); |
766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 758 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
767 | addString = i18n("Day before yesterday"); | 759 | addString = i18n("Day before yesterday"); |
768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 760 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
769 | addString = i18n("Day after tomorrow"); | 761 | addString = i18n("Day after tomorrow"); |
770 | if ( !addString.isEmpty() ) { | 762 | if ( !addString.isEmpty() ) { |
771 | str = addString+", " + str; | 763 | str = addString+", " + str; |
772 | } | 764 | } |
773 | } | 765 | } |
774 | dayLabel->setText(str); | 766 | dayLabel->setText(str); |
775 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 767 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
776 | if (date == QDate::currentDate()) { | 768 | if (date == QDate::currentDate()) { |
777 | QFont bFont = dlf; | 769 | QFont bFont = dlf; |
778 | bFont.setBold( true ); | 770 | bFont.setBold( true ); |
779 | dayLabel->setFont(bFont); | 771 | dayLabel->setFont(bFont); |
780 | } | 772 | } |
781 | //dayLayout->addWidget(dayLabel); | 773 | //dayLayout->addWidget(dayLabel); |
782 | 774 | ||
783 | #ifndef KORG_NOPLUGINS | 775 | #ifndef KORG_NOPLUGINS |
784 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 776 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
785 | CalendarDecoration *it; | 777 | CalendarDecoration *it; |
786 | for(it = cds.first(); it; it = cds.next()) { | 778 | for(it = cds.first(); it; it = cds.next()) { |
787 | QString text = it->shortText( date ); | 779 | QString text = it->shortText( date ); |
788 | if ( !text.isEmpty() ) { | 780 | if ( !text.isEmpty() ) { |
789 | QLabel *label = new QLabel(text,mDayLabels); | 781 | QLabel *label = new QLabel(text,mDayLabels); |
790 | label->setAlignment(AlignCenter); | 782 | label->setAlignment(AlignCenter); |
791 | dayLayout->addWidget(label); | 783 | dayLayout->addWidget(label); |
792 | } | 784 | } |
793 | } | 785 | } |
794 | 786 | ||
795 | for(it = cds.first(); it; it = cds.next()) { | 787 | for(it = cds.first(); it; it = cds.next()) { |
796 | QWidget *wid = it->smallWidget(mDayLabels,date); | 788 | QWidget *wid = it->smallWidget(mDayLabels,date); |
797 | if ( wid ) { | 789 | if ( wid ) { |
798 | // wid->setHeight(20); | 790 | // wid->setHeight(20); |
799 | dayLayout->addWidget(wid); | 791 | dayLayout->addWidget(wid); |
800 | } | 792 | } |
801 | } | 793 | } |
802 | #endif | 794 | #endif |
803 | } | 795 | } |
804 | if ( ! appendLabels ) { | 796 | if ( ! appendLabels ) { |
805 | dayLabel = mDayLabelsList.next(); | 797 | dayLabel = mDayLabelsList.next(); |
806 | if ( !dayLabel ) | 798 | if ( !dayLabel ) |
807 | appendLabels = true; | 799 | appendLabels = true; |
808 | } | 800 | } |
809 | if ( appendLabels ) { | 801 | if ( appendLabels ) { |
810 | dayLabel = getNewDaylabel(); | 802 | dayLabel = getNewDaylabel(); |
811 | } | 803 | } |
812 | //dayLabel->hide();//test only | 804 | //dayLabel->hide();//test only |
813 | 805 | ||
814 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 806 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
815 | if ( offset < 0 ) offset = 0; | 807 | if ( offset < 0 ) offset = 0; |
816 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 808 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
817 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 809 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
818 | dayLabel->setFont( dlf ); | 810 | dayLabel->setFont( dlf ); |
819 | dayLabel->show(); | 811 | dayLabel->show(); |
820 | dayLabel->setNum( -2 ); | 812 | dayLabel->setNum( -2 ); |
821 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 813 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
822 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 814 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
823 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 815 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
824 | if ( !appendLabels ) { | 816 | if ( !appendLabels ) { |
825 | dayLabel = mDayLabelsList.next(); | 817 | dayLabel = mDayLabelsList.next(); |
826 | while ( dayLabel ) { | 818 | while ( dayLabel ) { |
827 | //qDebug("!dayLabel %d",dayLabel ); | 819 | //qDebug("!dayLabel %d",dayLabel ); |
828 | dayLabel->hide(); | 820 | dayLabel->hide(); |
829 | dayLabel = mDayLabelsList.next(); | 821 | dayLabel = mDayLabelsList.next(); |
830 | } | 822 | } |
831 | } | 823 | } |
832 | //mDayLabelsFrame->show(); | 824 | //mDayLabelsFrame->show(); |
833 | //mDayLabels->show(); | 825 | //mDayLabels->show(); |
834 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 826 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
835 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 827 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
836 | mDayLabelsFrame->setFixedHeight( newHight ); | 828 | mDayLabelsFrame->setFixedHeight( newHight ); |
837 | } | 829 | } |
838 | 830 | ||
839 | int KOAgendaView::maxDatesHint() | 831 | int KOAgendaView::maxDatesHint() |
840 | { | 832 | { |
841 | // Not sure about the max number of events, so return 0 for now. | 833 | // Not sure about the max number of events, so return 0 for now. |
842 | return 0; | 834 | return 0; |
843 | } | 835 | } |
844 | 836 | ||
845 | int KOAgendaView::currentDateCount() | 837 | int KOAgendaView::currentDateCount() |
846 | { | 838 | { |
847 | return mSelectedDates.count(); | 839 | return mSelectedDates.count(); |
848 | } | 840 | } |
849 | 841 | ||
850 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 842 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
851 | { | 843 | { |
852 | QPtrList<Incidence> selected; | 844 | QPtrList<Incidence> selected; |
853 | Incidence *incidence; | 845 | Incidence *incidence; |
854 | 846 | ||
855 | incidence = mAgenda->selectedIncidence(); | 847 | incidence = mAgenda->selectedIncidence(); |
856 | if (incidence) selected.append(incidence); | 848 | if (incidence) selected.append(incidence); |
857 | 849 | ||
858 | incidence = mAllDayAgenda->selectedIncidence(); | 850 | incidence = mAllDayAgenda->selectedIncidence(); |
859 | if (incidence) selected.append(incidence); | 851 | if (incidence) selected.append(incidence); |
860 | 852 | ||
861 | return selected; | 853 | return selected; |
862 | } | 854 | } |
863 | 855 | ||
864 | DateList KOAgendaView::selectedDates() | 856 | DateList KOAgendaView::selectedDates() |
865 | { | 857 | { |
866 | DateList selected; | 858 | DateList selected; |
867 | QDate qd; | 859 | QDate qd; |
868 | 860 | ||
869 | qd = mAgenda->selectedIncidenceDate(); | 861 | qd = mAgenda->selectedIncidenceDate(); |
870 | if (qd.isValid()) selected.append(qd); | 862 | if (qd.isValid()) selected.append(qd); |
871 | 863 | ||
872 | qd = mAllDayAgenda->selectedIncidenceDate(); | 864 | qd = mAllDayAgenda->selectedIncidenceDate(); |
873 | if (qd.isValid()) selected.append(qd); | 865 | if (qd.isValid()) selected.append(qd); |
874 | 866 | ||
875 | return selected; | 867 | return selected; |
876 | } | 868 | } |
877 | 869 | ||
878 | 870 | ||
879 | void KOAgendaView::updateView() | 871 | void KOAgendaView::updateView() |
880 | { | 872 | { |
881 | if ( mBlockUpdating ) | 873 | if ( mBlockUpdating ) |
882 | return; | 874 | return; |
883 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 875 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
884 | fillAgenda(); | 876 | fillAgenda(); |
885 | 877 | ||
886 | } | 878 | } |
887 | 879 | ||
888 | 880 | ||
889 | /* | 881 | /* |
890 | Update configuration settings for the agenda view. This method is not | 882 | Update configuration settings for the agenda view. This method is not |
891 | complete. | 883 | complete. |
892 | */ | 884 | */ |
893 | void KOAgendaView::updateConfig() | 885 | void KOAgendaView::updateConfig() |
894 | { | 886 | { |
895 | if ( mBlockUpdating ) | 887 | if ( mBlockUpdating ) |
896 | return; | 888 | return; |
897 | 889 | ||
898 | // update config for children | 890 | // update config for children |
899 | mTimeLabels->updateConfig(); | 891 | mTimeLabels->updateConfig(); |
900 | mAgenda->storePosition(); | 892 | mAgenda->storePosition(); |
901 | mAgenda->updateConfig(); | 893 | mAgenda->updateConfig(); |
902 | mAllDayAgenda->updateConfig(); | 894 | mAllDayAgenda->updateConfig(); |
903 | // widget synchronization | 895 | // widget synchronization |
904 | //TODO: find a better way, maybe signal/slot | 896 | //TODO: find a better way, maybe signal/slot |
905 | mTimeLabels->positionChanged(); | 897 | mTimeLabels->positionChanged(); |
906 | 898 | ||
907 | // for some reason, this needs to be called explicitly | 899 | // for some reason, this needs to be called explicitly |
908 | mTimeLabels->repaint(); | 900 | mTimeLabels->repaint(); |
909 | 901 | ||
910 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 902 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
911 | 903 | ||
912 | // ToolTips displaying summary of events | 904 | // ToolTips displaying summary of events |
913 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 905 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
914 | ->mEnableToolTips); | 906 | ->mEnableToolTips); |
915 | 907 | ||
916 | //setHolidayMasks(); | 908 | //setHolidayMasks(); |
917 | 909 | ||
918 | //createDayLabels(); called by via updateView(); | 910 | //createDayLabels(); called by via updateView(); |
919 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 911 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
920 | updateView(); | 912 | updateView(); |
921 | mAgenda->restorePosition(); | 913 | mAgenda->restorePosition(); |
922 | } | 914 | } |
923 | 915 | ||
924 | 916 | ||
925 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 917 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
926 | { | 918 | { |
927 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 919 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
928 | //qDebug("KOAgendaView::updateEventDates "); | 920 | //qDebug("KOAgendaView::updateEventDates "); |
929 | QDateTime startDt,endDt; | 921 | QDateTime startDt,endDt; |
930 | QDate startDate; | 922 | QDate startDate; |
931 | int lenInSecs; | 923 | int lenInSecs; |
932 | // if ( type == KOAgenda::RESIZETOP ) | 924 | // if ( type == KOAgenda::RESIZETOP ) |
933 | // qDebug("RESIZETOP "); | 925 | // qDebug("RESIZETOP "); |
934 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 926 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
935 | // qDebug("RESIZEBOTTOM "); | 927 | // qDebug("RESIZEBOTTOM "); |
936 | // if ( type == KOAgenda::MOVE ) | 928 | // if ( type == KOAgenda::MOVE ) |
937 | // qDebug("MOVE "); | 929 | // qDebug("MOVE "); |
938 | if ( item->incidence()->type() == "Event" ) { | 930 | if ( item->incidence()->type() == "Event" ) { |
939 | startDt =item->incidence()->dtStart(); | 931 | startDt =item->incidence()->dtStart(); |
940 | endDt = item->incidence()->dtEnd(); | 932 | endDt = item->incidence()->dtEnd(); |
941 | lenInSecs = startDt.secsTo( endDt ); | 933 | lenInSecs = startDt.secsTo( endDt ); |
942 | } | 934 | } |
943 | 935 | ||
944 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 936 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
945 | 937 | ||
946 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 938 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
947 | startDate = mSelectedDates[item->mLastMoveXPos]; | 939 | startDate = mSelectedDates[item->mLastMoveXPos]; |
948 | } else { | 940 | } else { |
949 | if (item->cellX() < 0) { | 941 | if (item->cellX() < 0) { |
950 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 942 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
951 | } else { | 943 | } else { |
952 | startDate = mSelectedDates[item->cellX()]; | 944 | startDate = mSelectedDates[item->cellX()]; |
953 | } | 945 | } |
954 | } | 946 | } |
955 | startDt.setDate(startDate); | 947 | startDt.setDate(startDate); |
956 | 948 | ||
957 | if (item->incidence()->doesFloat()) { | 949 | if (item->incidence()->doesFloat()) { |
958 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 950 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
959 | } else { | 951 | } else { |
960 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 952 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
961 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 953 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
962 | if ( item->incidence()->type() == "Event" ) { | 954 | if ( item->incidence()->type() == "Event" ) { |
963 | if ( type == KOAgenda::MOVE ) { | 955 | if ( type == KOAgenda::MOVE ) { |
964 | endDt = startDt.addSecs(lenInSecs); | 956 | endDt = startDt.addSecs(lenInSecs); |
965 | 957 | ||
966 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 958 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
967 | if (item->lastMultiItem()) { | 959 | if (item->lastMultiItem()) { |
968 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 960 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
969 | endDt.setDate(startDate. | 961 | endDt.setDate(startDate. |
970 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 962 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
971 | } else { | 963 | } else { |
972 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 964 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
973 | endDt.setDate(startDate); | 965 | endDt.setDate(startDate); |
974 | } | 966 | } |
975 | } | 967 | } |
976 | } else { | 968 | } else { |
977 | // todo | 969 | // todo |
978 | if (item->lastMultiItem()) { | 970 | if (item->lastMultiItem()) { |
979 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 971 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
980 | endDt.setDate(startDate. | 972 | endDt.setDate(startDate. |
981 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 973 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
982 | } else { | 974 | } else { |
983 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 975 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
984 | if ( item->cellYBottom() > 0 ) | 976 | if ( item->cellYBottom() > 0 ) |
985 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 977 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
986 | else | 978 | else |
987 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 979 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
988 | endDt.setDate(startDate); | 980 | endDt.setDate(startDate); |
989 | } | 981 | } |
990 | } | 982 | } |
991 | } | 983 | } |
992 | if ( item->incidence()->type() == "Event" ) { | 984 | if ( item->incidence()->type() == "Event" ) { |
993 | item->incidence()->setDtStart(startDt); | 985 | item->incidence()->setDtStart(startDt); |
994 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 986 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
995 | } else if ( item->incidence()->type() == "Todo" ) { | 987 | } else if ( item->incidence()->type() == "Todo" ) { |
996 | Todo* to = static_cast<Todo*>(item->incidence()); | 988 | Todo* to = static_cast<Todo*>(item->incidence()); |
997 | 989 | ||
998 | to->setDtDue(endDt); | 990 | to->setDtDue(endDt); |
999 | if ( to->hasStartDate() ) { | 991 | if ( to->hasStartDate() ) { |
1000 | if (to->dtStart() >= to->dtDue() ) | 992 | if (to->dtStart() >= to->dtDue() ) |
1001 | to->setDtStart(to->dtDue().addDays( -2 )); | 993 | to->setDtStart(to->dtDue().addDays( -2 )); |
1002 | } | 994 | } |
1003 | 995 | ||
1004 | } | 996 | } |
1005 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 997 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1006 | item->incidence()->setRevision(item->incidence()->revision()+1); | 998 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1007 | item->setItemDate(startDt.date()); | 999 | item->setItemDate(startDt.date()); |
1008 | //item->updateItem(); | 1000 | //item->updateItem(); |
1009 | if ( item->incidence()->type() == "Todo" ) { | 1001 | if ( item->incidence()->type() == "Todo" ) { |
1010 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1002 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1011 | 1003 | ||
1012 | } | 1004 | } |
1013 | else | 1005 | else |
1014 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1006 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1015 | item->updateItem(); | 1007 | item->updateItem(); |
1016 | } | 1008 | } |
1017 | 1009 | ||
1018 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1010 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1019 | { | 1011 | { |
1020 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1012 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1021 | 1013 | ||
1022 | mSelectedDates.clear(); | 1014 | mSelectedDates.clear(); |
1023 | // qDebug("KOAgendaView::showDates "); | 1015 | // qDebug("KOAgendaView::showDates "); |
1024 | QDate d = start; | 1016 | QDate d = start; |
1025 | while (d <= end) { | 1017 | while (d <= end) { |
1026 | mSelectedDates.append(d); | 1018 | mSelectedDates.append(d); |
1027 | d = d.addDays( 1 ); | 1019 | d = d.addDays( 1 ); |
1028 | } | 1020 | } |
1029 | 1021 | ||
1030 | // and update the view | 1022 | // and update the view |
1031 | fillAgenda(); | 1023 | fillAgenda(); |
1032 | } | 1024 | } |
1033 | 1025 | ||
1034 | 1026 | ||
1035 | void KOAgendaView::showEvents(QPtrList<Event>) | 1027 | void KOAgendaView::showEvents(QPtrList<Event>) |
1036 | { | 1028 | { |
1037 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1029 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1038 | } | 1030 | } |
1039 | 1031 | ||
1040 | void KOAgendaView::changeEventDisplay(Event *, int) | 1032 | void KOAgendaView::changeEventDisplay(Event *, int) |
1041 | { | 1033 | { |
1042 | // qDebug("KOAgendaView::changeEventDisplay "); | 1034 | // qDebug("KOAgendaView::changeEventDisplay "); |
1043 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1035 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1044 | // this should be re-written to be MUCH smarter. Right now we | 1036 | // this should be re-written to be MUCH smarter. Right now we |
1045 | // are just playing dumb. | 1037 | // are just playing dumb. |
1046 | fillAgenda(); | 1038 | fillAgenda(); |
1047 | } | 1039 | } |
1048 | 1040 | ||
1049 | void KOAgendaView::fillAgenda(const QDate &) | 1041 | void KOAgendaView::fillAgenda(const QDate &) |
1050 | { | 1042 | { |
1051 | // qDebug("KOAgendaView::fillAgenda "); | 1043 | // qDebug("KOAgendaView::fillAgenda "); |
1052 | fillAgenda(); | 1044 | fillAgenda(); |
1053 | } | 1045 | } |
1054 | 1046 | ||
1055 | void KOAgendaView::fillAgenda() | 1047 | void KOAgendaView::fillAgenda() |
1056 | { | 1048 | { |
1057 | if ( globalFlagBlockStartup ) | 1049 | if ( globalFlagBlockStartup ) |
1058 | return; | 1050 | return; |
1059 | if ( globalFlagBlockAgenda == 1 ) | 1051 | if ( globalFlagBlockAgenda == 1 ) |
1060 | return; | 1052 | return; |
1061 | //if ( globalFlagBlockAgenda == 2 ) | 1053 | //if ( globalFlagBlockAgenda == 2 ) |
1062 | //globalFlagBlockAgenda = 0; | 1054 | //globalFlagBlockAgenda = 0; |
1063 | // globalFlagBlockPainting = false; | 1055 | // globalFlagBlockPainting = false; |
1064 | if ( globalFlagBlockAgenda == 0 ) | 1056 | if ( globalFlagBlockAgenda == 0 ) |
1065 | globalFlagBlockAgenda = 1; | 1057 | globalFlagBlockAgenda = 1; |
1066 | // clearView(); | 1058 | // clearView(); |
1067 | //qDebug("fillAgenda()++++ "); | 1059 | //qDebug("fillAgenda()++++ "); |
1068 | globalFlagBlockAgendaItemPaint = 1; | 1060 | globalFlagBlockAgendaItemPaint = 1; |
1069 | 1061 | ||
1070 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1062 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1071 | mAgenda->changeColumns(mSelectedDates.count()); | 1063 | mAgenda->changeColumns(mSelectedDates.count()); |
1072 | qApp->processEvents(); | 1064 | qApp->processEvents(); |
1073 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1065 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1074 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1066 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1075 | setHolidayMasks(); | 1067 | setHolidayMasks(); |
1076 | 1068 | ||
1077 | //mAgenda->hideUnused(); | 1069 | //mAgenda->hideUnused(); |
1078 | //mAllDayAgenda->hideUnused(); | 1070 | //mAllDayAgenda->hideUnused(); |
1079 | 1071 | ||
1080 | // mAgenda->blockNextRepaint( false ); | 1072 | // mAgenda->blockNextRepaint( false ); |
1081 | // mAgenda->viewport()->repaint(); | 1073 | // mAgenda->viewport()->repaint(); |
1082 | // mAgenda->blockNextRepaint( true ); | 1074 | // mAgenda->blockNextRepaint( true ); |
1083 | mMinY.resize(mSelectedDates.count()); | 1075 | mMinY.resize(mSelectedDates.count()); |
1084 | mMaxY.resize(mSelectedDates.count()); | 1076 | mMaxY.resize(mSelectedDates.count()); |
1085 | 1077 | ||
1086 | QPtrList<Event> dayEvents; | 1078 | QPtrList<Event> dayEvents; |
1087 | 1079 | ||
1088 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1080 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1089 | // Therefore, gtodoset all of them. | 1081 | // Therefore, gtodoset all of them. |
1090 | QPtrList<Todo> todos = calendar()->todos(); | 1082 | QPtrList<Todo> todos = calendar()->todos(); |
1091 | 1083 | ||
1092 | mAgenda->setDateList(mSelectedDates); | 1084 | mAgenda->setDateList(mSelectedDates); |
1093 | 1085 | ||
1094 | QDate today = QDate::currentDate(); | 1086 | QDate today = QDate::currentDate(); |
1095 | 1087 | ||
1096 | DateList::ConstIterator dit; | 1088 | DateList::ConstIterator dit; |
1097 | int curCol = 0; | 1089 | int curCol = 0; |
1098 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1090 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1099 | QDate currentDate = *dit; | 1091 | QDate currentDate = *dit; |
1100 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1092 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1101 | // << endl; | 1093 | // << endl; |
1102 | 1094 | ||
1103 | dayEvents = calendar()->events(currentDate,true); | 1095 | dayEvents = calendar()->events(currentDate,true); |
1104 | 1096 | ||
1105 | // Default values, which can never be reached | 1097 | // Default values, which can never be reached |
1106 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1098 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1107 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1099 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1108 | 1100 | ||
1109 | unsigned int numEvent; | 1101 | unsigned int numEvent; |
1110 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1102 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1111 | Event *event = dayEvents.at(numEvent); | 1103 | Event *event = dayEvents.at(numEvent); |
1112 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1104 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1113 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1105 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1114 | continue; | 1106 | continue; |
1115 | // kdDebug() << " Event: " << event->summary() << endl; | 1107 | // kdDebug() << " Event: " << event->summary() << endl; |
1116 | 1108 | ||
1117 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1109 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1118 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1110 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1119 | 1111 | ||
1120 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1112 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1121 | 1113 | ||
1122 | if (event->doesFloat()) { | 1114 | if (event->doesFloat()) { |
1123 | if (event->recurrence()->doesRecur()) { | 1115 | if (event->recurrence()->doesRecur()) { |
1124 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1116 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1125 | } else { | 1117 | } else { |
1126 | if (beginX <= 0 && curCol == 0) { | 1118 | if (beginX <= 0 && curCol == 0) { |
1127 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1119 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1128 | } else if (beginX == curCol) { | 1120 | } else if (beginX == curCol) { |
1129 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1121 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1130 | } | 1122 | } |
1131 | } | 1123 | } |
1132 | } else if (event->isMultiDay()) { | 1124 | } else if (event->isMultiDay()) { |
1133 | if ( event->doesRecur () ) { | 1125 | if ( event->doesRecur () ) { |
1134 | QDate dateit = currentDate; | 1126 | QDate dateit = currentDate; |
1135 | int count = 0; | 1127 | int count = 0; |
1136 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1128 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1137 | while (! event->recursOn( dateit ) && count <= max ) { | 1129 | while (! event->recursOn( dateit ) && count <= max ) { |
1138 | ++count; | 1130 | ++count; |
1139 | dateit = dateit.addDays( -1 ); | 1131 | dateit = dateit.addDays( -1 ); |
1140 | } | 1132 | } |
1141 | bool ok; | 1133 | bool ok; |
1142 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1134 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1143 | if ( ok ) | 1135 | if ( ok ) |
1144 | { | 1136 | { |
1145 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1137 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1146 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1138 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1147 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1139 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1148 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1140 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1149 | 1141 | ||
1150 | } | 1142 | } |
1151 | } | 1143 | } |
1152 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1144 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1153 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1145 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1154 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1146 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1155 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1147 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1156 | //qDebug("insert!!! "); | 1148 | //qDebug("insert!!! "); |
1157 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1149 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1158 | } | 1150 | } |
1159 | if (beginX == curCol) { | 1151 | if (beginX == curCol) { |
1160 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1152 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1161 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1153 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1162 | } else if (endX == curCol) { | 1154 | } else if (endX == curCol) { |
1163 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1155 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1164 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1156 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1165 | } else { | 1157 | } else { |
1166 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1158 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1167 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1159 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1168 | } | 1160 | } |
1169 | } else { | 1161 | } else { |
1170 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1162 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1171 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1163 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1172 | if (endY < startY) endY = startY; | 1164 | if (endY < startY) endY = startY; |
1173 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1165 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1174 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1166 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1175 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1167 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1176 | } | 1168 | } |
1177 | } | 1169 | } |
1178 | // ---------- [display Todos -------------- | 1170 | // ---------- [display Todos -------------- |
1179 | unsigned int numTodo; | 1171 | unsigned int numTodo; |
1180 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1172 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1181 | Todo *todo = todos.at(numTodo); | 1173 | Todo *todo = todos.at(numTodo); |
1182 | 1174 | ||
1183 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1175 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1184 | 1176 | ||
1185 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1177 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1186 | // Already completed items can be displayed on their original due date | 1178 | // Already completed items can be displayed on their original due date |
1187 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1179 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1188 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1180 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1189 | bool fillIn = false; | 1181 | bool fillIn = false; |
1190 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1182 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1191 | fillIn = true; | 1183 | fillIn = true; |
1192 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1184 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1193 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1185 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1194 | if ( fillIn ) { | 1186 | if ( fillIn ) { |
1195 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1187 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1196 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1188 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1197 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1189 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1198 | } | 1190 | } |
1199 | else { | 1191 | else { |
1200 | QDateTime dt; | 1192 | QDateTime dt; |
1201 | if ( todo->hasCompletedDate() ) | 1193 | if ( todo->hasCompletedDate() ) |
1202 | dt = todo->completed(); | 1194 | dt = todo->completed(); |
1203 | else | 1195 | else |
1204 | dt = todo->dtDue();; | 1196 | dt = todo->dtDue();; |
1205 | 1197 | ||
1206 | 1198 | ||
1207 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1199 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1208 | int hi = (18/KOPrefs::instance()->mHourSize); | 1200 | int hi = (18/KOPrefs::instance()->mHourSize); |
1209 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1201 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1210 | int startY = endY -hi; | 1202 | int startY = endY -hi; |
1211 | 1203 | ||
1212 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1204 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1213 | 1205 | ||
1214 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1206 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1215 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1207 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1216 | } | 1208 | } |
1217 | } | 1209 | } |
1218 | } | 1210 | } |
1219 | // ---------- display Todos] -------------- | 1211 | // ---------- display Todos] -------------- |
1220 | 1212 | ||
1221 | ++curCol; | 1213 | ++curCol; |
1222 | } | 1214 | } |
1223 | mAgenda->hideUnused(); | 1215 | mAgenda->hideUnused(); |
1224 | mAllDayAgenda->hideUnused(); | 1216 | mAllDayAgenda->hideUnused(); |
1225 | mAgenda->checkScrollBoundaries(); | 1217 | mAgenda->checkScrollBoundaries(); |
1226 | 1218 | ||
1227 | deleteSelectedDateTime(); | 1219 | deleteSelectedDateTime(); |
1228 | 1220 | ||
1229 | createDayLabels(); | 1221 | createDayLabels(); |
1230 | emit incidenceSelected( 0 ); | 1222 | emit incidenceSelected( 0 ); |
1231 | 1223 | ||
1232 | if ( globalFlagBlockAgenda == 2 ) { | 1224 | if ( globalFlagBlockAgenda == 2 ) { |
1233 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1225 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1234 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1226 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1235 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1227 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1236 | setStartHour( QTime::currentTime ().hour() ); | 1228 | setStartHour( QTime::currentTime ().hour() ); |
1237 | // qApp->processEvents(); | 1229 | // qApp->processEvents(); |
1238 | } | 1230 | } |
1239 | qApp->processEvents(); | 1231 | qApp->processEvents(); |
1240 | //qDebug("qApp->processEvents(); END "); | 1232 | //qDebug("qApp->processEvents(); END "); |
1241 | globalFlagBlockAgenda = 0; | 1233 | globalFlagBlockAgenda = 0; |
1242 | 1234 | ||
1243 | // mAgenda->hideUnused(); | 1235 | // mAgenda->hideUnused(); |
1244 | //mAllDayAgenda->hideUnused(); | 1236 | //mAllDayAgenda->hideUnused(); |
1245 | mAllDayAgenda->drawContentsToPainter(); | 1237 | mAllDayAgenda->drawContentsToPainter(); |
1246 | mAgenda->drawContentsToPainter(); | 1238 | mAgenda->drawContentsToPainter(); |
1247 | repaintAgenda(); | 1239 | repaintAgenda(); |
1248 | // mAgenda->finishUpdate(); | 1240 | // mAgenda->finishUpdate(); |
1249 | //mAllDayAgenda->finishUpdate(); | 1241 | //mAllDayAgenda->finishUpdate(); |
1250 | 1242 | ||
1251 | // repaintAgenda(); | 1243 | // repaintAgenda(); |
1252 | //qApp->processEvents(); | 1244 | //qApp->processEvents(); |
1253 | // globalFlagBlockAgenda = 0; | 1245 | // globalFlagBlockAgenda = 0; |
1254 | } | 1246 | } |
1255 | void KOAgendaView::repaintAgenda() | 1247 | void KOAgendaView::repaintAgenda() |
1256 | { | 1248 | { |
1257 | // mAllDayAgenda->drawContentsToPainter(); | 1249 | // mAllDayAgenda->drawContentsToPainter(); |
1258 | // mAllDayAgenda->viewport()->repaint( false ); | 1250 | // mAllDayAgenda->viewport()->repaint( false ); |
1259 | // mAgenda->drawContentsToPainter(); | 1251 | // mAgenda->drawContentsToPainter(); |
1260 | // mAgenda->viewport()->repaint( false ); | 1252 | // mAgenda->viewport()->repaint( false ); |
1261 | // qApp->processEvents(); | 1253 | // qApp->processEvents(); |
1262 | 1254 | ||
1263 | //qDebug("KOAgendaView::repaintAgenda() "); | 1255 | //qDebug("KOAgendaView::repaintAgenda() "); |
1264 | //qApp->processEvents(); | 1256 | //qApp->processEvents(); |
1265 | mAgenda->viewport()->repaint( false ); | 1257 | mAgenda->viewport()->repaint( false ); |
1266 | mAllDayAgenda->viewport()->repaint( false ); | 1258 | mAllDayAgenda->viewport()->repaint( false ); |
1267 | mAgenda->finishUpdate(); | 1259 | mAgenda->finishUpdate(); |
1268 | mAllDayAgenda->finishUpdate(); | 1260 | mAllDayAgenda->finishUpdate(); |
1269 | } | 1261 | } |
1270 | 1262 | ||
1271 | 1263 | ||
1272 | void KOAgendaView::clearView() | 1264 | void KOAgendaView::clearView() |
1273 | { | 1265 | { |
1274 | // kdDebug() << "ClearView" << endl; | 1266 | // kdDebug() << "ClearView" << endl; |
1275 | mAllDayAgenda->clear(); | 1267 | mAllDayAgenda->clear(); |
1276 | mAgenda->clear(); | 1268 | mAgenda->clear(); |
1277 | } | 1269 | } |
1278 | 1270 | ||
1279 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1271 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1280 | const QDate &td) | 1272 | const QDate &td) |
1281 | { | 1273 | { |
1282 | #ifndef KORG_NOPRINTER | 1274 | #ifndef KORG_NOPRINTER |
1283 | if (fd == td) | 1275 | if (fd == td) |
1284 | calPrinter->preview(CalPrinter::Day, fd, td); | 1276 | calPrinter->preview(CalPrinter::Day, fd, td); |
1285 | else | 1277 | else |
1286 | calPrinter->preview(CalPrinter::Week, fd, td); | 1278 | calPrinter->preview(CalPrinter::Week, fd, td); |
1287 | #endif | 1279 | #endif |
1288 | } | 1280 | } |
1289 | 1281 | ||
1290 | // void KOAgendaView::updateMovedTodo() | 1282 | // void KOAgendaView::updateMovedTodo() |
1291 | // { | 1283 | // { |
1292 | // // updateConfig(); | 1284 | // // updateConfig(); |
1293 | // // emit updateTodoViews(); | 1285 | // // emit updateTodoViews(); |
1294 | // } | 1286 | // } |
1295 | 1287 | ||
1296 | void KOAgendaView::newEvent(int gx, int gy) | 1288 | void KOAgendaView::newEvent(int gx, int gy) |
1297 | { | 1289 | { |
1298 | if (!mSelectedDates.count()) return; | 1290 | if (!mSelectedDates.count()) return; |
1299 | 1291 | ||
1300 | QDate day = mSelectedDates[gx]; | 1292 | QDate day = mSelectedDates[gx]; |
1301 | 1293 | ||
1302 | QTime time = mAgenda->gyToTime(gy); | 1294 | QTime time = mAgenda->gyToTime(gy); |
1303 | QDateTime dt(day,time); | 1295 | QDateTime dt(day,time); |
1304 | // if ( dt < QDateTime::currentDateTime () ) | 1296 | // if ( dt < QDateTime::currentDateTime () ) |
1305 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1297 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1306 | emit newEventSignal(dt); | 1298 | emit newEventSignal(dt); |
1307 | } | 1299 | } |
1308 | 1300 | ||
1309 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1301 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1310 | { | 1302 | { |
1311 | if (!mSelectedDates.count()) return; | 1303 | if (!mSelectedDates.count()) return; |
1312 | 1304 | ||
1313 | QDate dayStart = mSelectedDates[gxStart]; | 1305 | QDate dayStart = mSelectedDates[gxStart]; |
1314 | QDate dayEnd = mSelectedDates[gxEnd]; | 1306 | QDate dayEnd = mSelectedDates[gxEnd]; |
1315 | 1307 | ||
1316 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1308 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1317 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1309 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1318 | 1310 | ||
1319 | QDateTime dtStart(dayStart,timeStart); | 1311 | QDateTime dtStart(dayStart,timeStart); |
1320 | QDateTime dtEnd(dayEnd,timeEnd); | 1312 | QDateTime dtEnd(dayEnd,timeEnd); |
1321 | 1313 | ||
1322 | emit newEventSignal(dtStart,dtEnd); | 1314 | emit newEventSignal(dtStart,dtEnd); |
1323 | } | 1315 | } |
1324 | 1316 | ||
1325 | void KOAgendaView::newEventAllDay(int gx, int ) | 1317 | void KOAgendaView::newEventAllDay(int gx, int ) |
1326 | { | 1318 | { |
1327 | if (!mSelectedDates.count()) return; | 1319 | if (!mSelectedDates.count()) return; |
1328 | 1320 | ||
1329 | QDate day = mSelectedDates[gx]; | 1321 | QDate day = mSelectedDates[gx]; |
1330 | 1322 | ||
1331 | emit newEventSignal(day); | 1323 | emit newEventSignal(day); |
1332 | } | 1324 | } |
1333 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1325 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1334 | { | 1326 | { |
1335 | if (!mSelectedDates.count()) return; | 1327 | if (!mSelectedDates.count()) return; |
1336 | 1328 | ||
1337 | QDateTime day (mSelectedDates[gx] ); | 1329 | QDateTime day (mSelectedDates[gx] ); |
1338 | emit newTodoSignal(day, true); | 1330 | emit newTodoSignal(day, true); |
1339 | } | 1331 | } |
1340 | void KOAgendaView::newTodo(int gx, int gy ) | 1332 | void KOAgendaView::newTodo(int gx, int gy ) |
1341 | { | 1333 | { |
1342 | if (!mSelectedDates.count()) return; | 1334 | if (!mSelectedDates.count()) return; |
1343 | QDate dayStart = mSelectedDates[gx]; | 1335 | QDate dayStart = mSelectedDates[gx]; |
1344 | QTime timeStart = mAgenda->gyToTime(gy); | 1336 | QTime timeStart = mAgenda->gyToTime(gy); |
1345 | QDateTime dt (dayStart,timeStart); | 1337 | QDateTime dt (dayStart,timeStart); |
1346 | emit newTodoSignal( dt, false ); | 1338 | emit newTodoSignal( dt, false ); |
1347 | } | 1339 | } |
1348 | 1340 | ||
1349 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1341 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1350 | { | 1342 | { |
1351 | uint i; | 1343 | uint i; |
1352 | for(i=0;i<mMinY.size();++i) { | 1344 | for(i=0;i<mMinY.size();++i) { |
1353 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1345 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1354 | else mEventIndicatorTop->enableColumn(i,false); | 1346 | else mEventIndicatorTop->enableColumn(i,false); |
1355 | } | 1347 | } |
1356 | 1348 | ||
1357 | mEventIndicatorTop->update(); | 1349 | mEventIndicatorTop->update(); |
1358 | } | 1350 | } |
1359 | 1351 | ||
1360 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1352 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1361 | { | 1353 | { |
1362 | uint i; | 1354 | uint i; |
1363 | for(i=0;i<mMaxY.size();++i) { | 1355 | for(i=0;i<mMaxY.size();++i) { |
1364 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1356 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1365 | else mEventIndicatorBottom->enableColumn(i,false); | 1357 | else mEventIndicatorBottom->enableColumn(i,false); |
1366 | } | 1358 | } |
1367 | 1359 | ||
1368 | mEventIndicatorBottom->update(); | 1360 | mEventIndicatorBottom->update(); |
1369 | } | 1361 | } |
1370 | 1362 | ||
1371 | void KOAgendaView::startDrag(Event *event) | 1363 | void KOAgendaView::startDrag(Event *event) |
1372 | { | 1364 | { |
1373 | #ifndef KORG_NODND | 1365 | #ifndef KORG_NODND |
1374 | DndFactory factory( calendar() ); | 1366 | DndFactory factory( calendar() ); |
1375 | ICalDrag *vd = factory.createDrag(event,this); | 1367 | ICalDrag *vd = factory.createDrag(event,this); |
1376 | if (vd->drag()) { | 1368 | if (vd->drag()) { |
1377 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1369 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1378 | } | 1370 | } |
1379 | #endif | 1371 | #endif |
1380 | } | 1372 | } |
1381 | 1373 | ||
1382 | void KOAgendaView::readSettings() | 1374 | void KOAgendaView::readSettings() |
1383 | { | 1375 | { |
1384 | readSettings(KOGlobals::config()); | 1376 | readSettings(KOGlobals::config()); |
1385 | } | 1377 | } |
1386 | 1378 | ||
1387 | void KOAgendaView::readSettings(KConfig *config) | 1379 | void KOAgendaView::readSettings(KConfig *config) |
1388 | { | 1380 | { |
1389 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1381 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1390 | 1382 | ||
1391 | config->setGroup("Views"); | 1383 | config->setGroup("Views"); |
1392 | 1384 | ||
1393 | //#ifndef KORG_NOSPLITTER | 1385 | //#ifndef KORG_NOSPLITTER |
1394 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1386 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1395 | if (sizes.count() == 2) { | 1387 | if (sizes.count() == 2) { |
1396 | if ( sizes[0] < 20 ) { | 1388 | if ( sizes[0] < 20 ) { |
1397 | sizes[1] = sizes[1] +20 - sizes[0]; | 1389 | sizes[1] = sizes[1] +20 - sizes[0]; |
1398 | sizes[0] = 20; | 1390 | sizes[0] = 20; |
1399 | } | 1391 | } |
1400 | mSplitterAgenda->setSizes(sizes); | 1392 | mSplitterAgenda->setSizes(sizes); |
1401 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1393 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1402 | } | 1394 | } |
1403 | //#endif | 1395 | //#endif |
1404 | 1396 | ||
1405 | // updateConfig(); | 1397 | // updateConfig(); |
1406 | } | 1398 | } |
1407 | 1399 | ||
1408 | void KOAgendaView::writeSettings(KConfig *config) | 1400 | void KOAgendaView::writeSettings(KConfig *config) |
1409 | { | 1401 | { |
1410 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1402 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1411 | 1403 | ||
1412 | config->setGroup("Views"); | 1404 | config->setGroup("Views"); |
1413 | 1405 | ||
1414 | //#ifndef KORG_NOSPLITTER | 1406 | //#ifndef KORG_NOSPLITTER |
1415 | QValueList<int> list = mSplitterAgenda->sizes(); | 1407 | QValueList<int> list = mSplitterAgenda->sizes(); |
1416 | config->writeEntry("Separator AgendaView",list); | 1408 | config->writeEntry("Separator AgendaView",list); |
1417 | //qDebug("write %d %d ", list[0],list[1] ); | 1409 | //qDebug("write %d %d ", list[0],list[1] ); |
1418 | //#endif | 1410 | //#endif |
1419 | } | 1411 | } |
1420 | 1412 | ||
1421 | void KOAgendaView::setHolidayMasks() | 1413 | void KOAgendaView::setHolidayMasks() |
1422 | { | 1414 | { |
1423 | mHolidayMask.resize(mSelectedDates.count()); | 1415 | mHolidayMask.resize(mSelectedDates.count()); |
1424 | 1416 | ||
1425 | uint i; | 1417 | uint i; |
1426 | for(i=0;i<mSelectedDates.count();++i) { | 1418 | for(i=0;i<mSelectedDates.count();++i) { |
1427 | QDate date = mSelectedDates[i]; | 1419 | QDate date = mSelectedDates[i]; |
1428 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1420 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1429 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1421 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1430 | bool showHoliday = false; | 1422 | bool showHoliday = false; |
1431 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1423 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1432 | QPtrList<Event> events = calendar()->events( date, true ); | 1424 | QPtrList<Event> events = calendar()->events( date, true ); |
1433 | Event *event; | 1425 | Event *event; |
1434 | for( event = events.first(); event; event = events.next() ) { | 1426 | for( event = events.first(); event; event = events.next() ) { |
1435 | if ( event->isHoliday()) { | 1427 | if ( event->isHoliday()) { |
1436 | showHoliday = true; | 1428 | showHoliday = true; |
1437 | break; | 1429 | break; |
1438 | } | 1430 | } |
1439 | } | 1431 | } |
1440 | 1432 | ||
1441 | } | 1433 | } |
1442 | 1434 | ||
1443 | #ifndef KORG_NOPLUGINS | 1435 | #ifndef KORG_NOPLUGINS |
1444 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1436 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1445 | !KOCore::self()->holiday(date).isEmpty(); | 1437 | !KOCore::self()->holiday(date).isEmpty(); |
1446 | #endif | 1438 | #endif |
1447 | bool showDay = showSaturday || showSunday || showHoliday; | 1439 | bool showDay = showSaturday || showSunday || showHoliday; |
1448 | 1440 | ||
1449 | if (showDay) { | 1441 | if (showDay) { |
1450 | mHolidayMask.at(i) = true; | 1442 | mHolidayMask.at(i) = true; |
1451 | } else { | 1443 | } else { |
1452 | mHolidayMask.at(i) = false; | 1444 | mHolidayMask.at(i) = false; |
1453 | } | 1445 | } |
1454 | } | 1446 | } |
1455 | 1447 | ||
1456 | mAgenda->setHolidayMask(&mHolidayMask); | 1448 | mAgenda->setHolidayMask(&mHolidayMask); |
1457 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1449 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1458 | } | 1450 | } |
1459 | 1451 | ||
1460 | void KOAgendaView::setContentsPos(int y) | 1452 | void KOAgendaView::setContentsPos(int y) |
1461 | { | 1453 | { |
1462 | mAgenda->setContentsPos(0,y); | 1454 | mAgenda->setContentsPos(0,y); |
1463 | } | 1455 | } |
1464 | 1456 | ||
1465 | void KOAgendaView::setExpandedButton( bool expanded ) | 1457 | void KOAgendaView::setExpandedButton( bool expanded ) |
1466 | { | 1458 | { |
1467 | if ( expanded ) { | 1459 | if ( expanded ) { |
1468 | mExpandButton->setPixmap( mExpandedPixmap ); | 1460 | mExpandButton->setPixmap( mExpandedPixmap ); |
1469 | } else { | 1461 | } else { |
1470 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1462 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1471 | } | 1463 | } |
1472 | } | 1464 | } |
1473 | 1465 | ||
1474 | void KOAgendaView::clearSelection() | 1466 | void KOAgendaView::clearSelection() |
1475 | { | 1467 | { |
1476 | mAgenda->deselectItem(); | 1468 | mAgenda->deselectItem(); |
1477 | mAllDayAgenda->deselectItem(); | 1469 | mAllDayAgenda->deselectItem(); |
1478 | } | 1470 | } |
1479 | 1471 | ||
1480 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1472 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1481 | int gxEnd, int gyEnd) | 1473 | int gxEnd, int gyEnd) |
1482 | { | 1474 | { |
1483 | mTimeSpanInAllDay = true; | 1475 | mTimeSpanInAllDay = true; |
1484 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1476 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1485 | } | 1477 | } |
1486 | 1478 | ||
1487 | 1479 | ||
1488 | 1480 | ||
1489 | 1481 | ||
1490 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1482 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1491 | int gxEnd, int gyEnd) | 1483 | int gxEnd, int gyEnd) |
1492 | { | 1484 | { |
1493 | if (!mSelectedDates.count()) return; | 1485 | if (!mSelectedDates.count()) return; |
1494 | 1486 | ||
1495 | QDate dayStart = mSelectedDates[gxStart]; | 1487 | QDate dayStart = mSelectedDates[gxStart]; |
1496 | QDate dayEnd = mSelectedDates[gxEnd]; | 1488 | QDate dayEnd = mSelectedDates[gxEnd]; |
1497 | 1489 | ||
1498 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1490 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1499 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1491 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1500 | 1492 | ||
1501 | QDateTime dtStart(dayStart,timeStart); | 1493 | QDateTime dtStart(dayStart,timeStart); |
1502 | QDateTime dtEnd(dayEnd,timeEnd); | 1494 | QDateTime dtEnd(dayEnd,timeEnd); |
1503 | 1495 | ||
1504 | mTimeSpanBegin = dtStart; | 1496 | mTimeSpanBegin = dtStart; |
1505 | mTimeSpanEnd = dtEnd; | 1497 | mTimeSpanEnd = dtEnd; |
1506 | 1498 | ||
1507 | } | 1499 | } |
1508 | 1500 | ||
1509 | void KOAgendaView::deleteSelectedDateTime() | 1501 | void KOAgendaView::deleteSelectedDateTime() |
1510 | { | 1502 | { |
1511 | mTimeSpanBegin.setDate(QDate()); | 1503 | mTimeSpanBegin.setDate(QDate()); |
1512 | mTimeSpanEnd.setDate(QDate()); | 1504 | mTimeSpanEnd.setDate(QDate()); |
1513 | mTimeSpanInAllDay = false; | 1505 | mTimeSpanInAllDay = false; |
1514 | } | 1506 | } |
1515 | 1507 | ||
1516 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1508 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1517 | { | 1509 | { |
1518 | e->ignore(); | 1510 | e->ignore(); |
1519 | } | 1511 | } |
1520 | 1512 | ||
1521 | void KOAgendaView::scrollOneHourUp() | 1513 | void KOAgendaView::scrollOneHourUp() |
1522 | { | 1514 | { |
1523 | 1515 | ||
1524 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1516 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1525 | } | 1517 | } |
1526 | void KOAgendaView::scrollOneHourDown() | 1518 | void KOAgendaView::scrollOneHourDown() |
1527 | { | 1519 | { |
1528 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1520 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1529 | } | 1521 | } |
1530 | 1522 | ||
1531 | void KOAgendaView::setStartHour( int h ) | 1523 | void KOAgendaView::setStartHour( int h ) |
1532 | { | 1524 | { |
1533 | mAgenda->setStartHour( h ); | 1525 | mAgenda->setStartHour( h ); |
1534 | 1526 | ||
1535 | } | 1527 | } |
1536 | void KOAgendaView::setInitStartHour() | 1528 | void KOAgendaView::setInitStartHour() |
1537 | { | 1529 | { |
1538 | 1530 | ||
1539 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1531 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1540 | setStartHour( QTime::currentTime ().hour() ); | 1532 | setStartHour( QTime::currentTime ().hour() ); |
1541 | else | 1533 | else |
1542 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1534 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1543 | 1535 | ||
1544 | } | 1536 | } |
1545 | 1537 | ||
1546 | 1538 | ||
1547 | void KOAgendaView::updateTodo( Todo * t, int ) | 1539 | void KOAgendaView::updateTodo( Todo * t, int ) |
1548 | { | 1540 | { |
1549 | if ( !isVisible() ) | 1541 | if ( !isVisible() ) |
1550 | return; | 1542 | return; |
1551 | bool remove = false; | 1543 | bool remove = false; |
1552 | bool removeAD = false; | 1544 | bool removeAD = false; |
1553 | QDate da; | 1545 | QDate da; |
1554 | if ( t->hasCompletedDate() ) | 1546 | if ( t->hasCompletedDate() ) |
1555 | da = t->completed().date(); | 1547 | da = t->completed().date(); |
1556 | else | 1548 | else |
1557 | da = t->dtDue().date(); | 1549 | da = t->dtDue().date(); |
1558 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1550 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1559 | remove = true; | 1551 | remove = true; |
1560 | removeAD = true; | 1552 | removeAD = true; |
1561 | } | 1553 | } |
1562 | else { | 1554 | else { |
1563 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1555 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1564 | if ( overdue && | 1556 | if ( overdue && |
1565 | QDate::currentDate() >= mSelectedDates.first() && | 1557 | QDate::currentDate() >= mSelectedDates.first() && |
1566 | QDate::currentDate() <= mSelectedDates.last()) { | 1558 | QDate::currentDate() <= mSelectedDates.last()) { |
1567 | removeAD = false; | 1559 | removeAD = false; |
1568 | remove = true; | 1560 | remove = true; |
1569 | } | 1561 | } |
1570 | else { | 1562 | else { |
1571 | 1563 | ||
1572 | if ( da < mSelectedDates.first() || | 1564 | if ( da < mSelectedDates.first() || |
1573 | da > mSelectedDates.last() ) { | 1565 | da > mSelectedDates.last() ) { |
1574 | remove = true; | 1566 | remove = true; |
1575 | removeAD = true; | 1567 | removeAD = true; |
1576 | } else { | 1568 | } else { |
1577 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1569 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1578 | removeAD = !remove; | 1570 | removeAD = !remove; |
1579 | } | 1571 | } |
1580 | } | 1572 | } |
1581 | } | 1573 | } |
1582 | int days = mSelectedDates.first().daysTo( da ); | 1574 | int days = mSelectedDates.first().daysTo( da ); |
1583 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1575 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1584 | mAgenda->updateTodo( t , days, remove); | 1576 | mAgenda->updateTodo( t , days, remove); |
1585 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1577 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1586 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1578 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1587 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1579 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1588 | 1580 | ||
1589 | } | 1581 | } |
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 | ||
39 | class QHBox; | 39 | class QHBox; |
40 | class QFrame; | 40 | class QFrame; |
41 | class QLabel; | 41 | class QLabel; |
42 | class QPushButton; | 42 | class QPushButton; |
43 | class CalendarView; | 43 | class CalendarView; |
44 | class KOAgenda; | 44 | class KOAgenda; |
45 | class KOAgendaItem; | 45 | class KOAgendaItem; |
46 | class KConfig; | 46 | class KConfig; |
47 | class KDGanttMinimizeSplitter; | 47 | class KDGanttMinimizeSplitter; |
48 | 48 | ||
49 | class KOAgendaButton : public QPushButton | 49 | class 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; } |
65 | private slots: | 65 | private slots: |
66 | void bClicked() {emit numClicked( mNum);} | 66 | void bClicked() {emit numClicked( mNum);} |
67 | signals: | 67 | signals: |
68 | void numClicked( int ); | 68 | void numClicked( int ); |
69 | private: | 69 | private: |
70 | int mNum; | 70 | int mNum; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | class TimeLabels : public QScrollView { | 73 | class 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 | ||
113 | class EventIndicator : public QFrame { | 114 | class 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 | */ |
143 | class KOAgendaView : public KOEventView { | 144 | class 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 | |||
@@ -1,1195 +1,1242 @@ | |||
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 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | 37 | ||
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | #include <kglobal.h> | 41 | #include <kglobal.h> |
42 | 42 | ||
43 | #include <libkdepim/kpimglobalprefs.h> | 43 | #include <libkdepim/kpimglobalprefs.h> |
44 | #include <libkcal/calendar.h> | 44 | #include <libkcal/calendar.h> |
45 | #include <libkcal/calendarlocal.h> | 45 | #include <libkcal/calendarlocal.h> |
46 | #include <libkcal/icalformat.h> | 46 | #include <libkcal/icalformat.h> |
47 | #include <libkcal/vcalformat.h> | 47 | #include <libkcal/vcalformat.h> |
48 | #include <libkcal/recurrence.h> | 48 | #include <libkcal/recurrence.h> |
49 | #include <libkcal/filestorage.h> | 49 | #include <libkcal/filestorage.h> |
50 | #include <libkdepim/categoryselectdialog.h> | 50 | #include <libkdepim/categoryselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #ifndef KORG_NOPRINTER | 58 | #ifndef KORG_NOPRINTER |
59 | #include "calprinter.h" | 59 | #include "calprinter.h" |
60 | #endif | 60 | #endif |
61 | #include "koglobals.h" | 61 | #include "koglobals.h" |
62 | #include "koprefs.h" | 62 | #include "koprefs.h" |
63 | #include "kfiledialog.h" | 63 | #include "kfiledialog.h" |
64 | 64 | ||
65 | #include "kolistview.h" | 65 | #include "kolistview.h" |
66 | 66 | ||
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | class KOListViewWhatsThis :public QWhatsThis | 70 | class KOListViewWhatsThis :public QWhatsThis |
71 | { | 71 | { |
72 | public: | 72 | public: |
73 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 73 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
74 | 74 | ||
75 | protected: | 75 | protected: |
76 | virtual QString text( const QPoint& p) | 76 | virtual QString text( const QPoint& p) |
77 | { | 77 | { |
78 | return _view->getWhatsThisText(p) ; | 78 | return _view->getWhatsThisText(p) ; |
79 | } | 79 | } |
80 | private: | 80 | private: |
81 | QWidget* _wid; | 81 | QWidget* _wid; |
82 | KOListView * _view; | 82 | KOListView * _view; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | 85 | ||
86 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 86 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
87 | { | 87 | { |
88 | mItem = item; | 88 | mItem = item; |
89 | mDate = date; | 89 | mDate = date; |
90 | } | 90 | } |
91 | 91 | ||
92 | ListItemVisitor::~ListItemVisitor() | 92 | ListItemVisitor::~ListItemVisitor() |
93 | { | 93 | { |
94 | } | 94 | } |
95 | 95 | ||
96 | bool ListItemVisitor::visit(Event *e) | 96 | bool ListItemVisitor::visit(Event *e) |
97 | { | 97 | { |
98 | 98 | ||
99 | bool ok = false; | 99 | bool ok = false; |
100 | QString start, end; | 100 | QString start, end; |
101 | QDate ds, de; | 101 | QDate ds, de; |
102 | if ( e->doesRecur() ) { | 102 | if ( e->doesRecur() ) { |
103 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 103 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
104 | if ( ok ) { | 104 | if ( ok ) { |
105 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 105 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
106 | start = KGlobal::locale()->formatDate(ds,true); | 106 | start = KGlobal::locale()->formatDate(ds,true); |
107 | de = ds.addDays( days); | 107 | de = ds.addDays( days); |
108 | end = KGlobal::locale()->formatDate(de,true); | 108 | end = KGlobal::locale()->formatDate(de,true); |
109 | } | 109 | } |
110 | 110 | ||
111 | } | 111 | } |
112 | if ( ! ok ) { | 112 | if ( ! ok ) { |
113 | start =e->dtStartDateStr(); | 113 | start =e->dtStartDateStr(); |
114 | end = e->dtEndDateStr(); | 114 | end = e->dtEndDateStr(); |
115 | ds = e->dtStart().date(); | 115 | ds = e->dtStart().date(); |
116 | de = e->dtEnd().date(); | 116 | de = e->dtEnd().date(); |
117 | } | 117 | } |
118 | mItem->setText(0,e->summary()); | 118 | mItem->setText(0,e->summary()); |
119 | mItem->setText(1,start); | 119 | mItem->setText(1,start); |
120 | mItem->setText(2,e->dtStartTimeStr()); | 120 | mItem->setText(2,e->dtStartTimeStr()); |
121 | mItem->setText(3,end); | 121 | mItem->setText(3,end); |
122 | mItem->setText(4,e->dtEndTimeStr()); | 122 | mItem->setText(4,e->dtEndTimeStr()); |
123 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 123 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
124 | mItem->setText(6, e->recurrence()->recurrenceText()); | 124 | mItem->setText(6, e->recurrence()->recurrenceText()); |
125 | mItem->setText(7,"---"); | 125 | mItem->setText(7,"---"); |
126 | mItem->setText(8,"---"); | 126 | mItem->setText(8,"---"); |
127 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 127 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
128 | mItem->setText(10,e->categoriesStr()); | 128 | mItem->setText(10,e->categoriesStr()); |
129 | 129 | ||
130 | QString key; | 130 | QString key; |
131 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 131 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
132 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 132 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
133 | mItem->setSortKey(1,key); | 133 | mItem->setSortKey(1,key); |
134 | 134 | ||
135 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 135 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
136 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 136 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
137 | mItem->setSortKey(3,key); | 137 | mItem->setSortKey(3,key); |
138 | 138 | ||
139 | return true; | 139 | return true; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool ListItemVisitor::visit(Todo *t) | 142 | bool ListItemVisitor::visit(Todo *t) |
143 | { | 143 | { |
144 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); | 144 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); |
145 | if (t->hasStartDate()) { | 145 | if (t->hasStartDate()) { |
146 | mItem->setText(1,t->dtStartDateStr()); | 146 | mItem->setText(1,t->dtStartDateStr()); |
147 | if (t->doesFloat()) { | 147 | if (t->doesFloat()) { |
148 | mItem->setText(2,"---"); | 148 | mItem->setText(2,"---"); |
149 | } else { | 149 | } else { |
150 | mItem->setText(2,t->dtStartTimeStr()); | 150 | mItem->setText(2,t->dtStartTimeStr()); |
151 | } | 151 | } |
152 | } else { | 152 | } else { |
153 | mItem->setText(1,"---"); | 153 | mItem->setText(1,"---"); |
154 | mItem->setText(2,"---"); | 154 | mItem->setText(2,"---"); |
155 | } | 155 | } |
156 | mItem->setText(3,"---"); | 156 | mItem->setText(3,"---"); |
157 | mItem->setText(4,"---"); | 157 | mItem->setText(4,"---"); |
158 | mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 158 | mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
159 | mItem->setText(6, t->recurrence()->recurrenceText()); | 159 | mItem->setText(6, t->recurrence()->recurrenceText()); |
160 | if (t->hasDueDate()) { | 160 | if (t->hasDueDate()) { |
161 | mItem->setText(7,t->dtDueDateStr()); | 161 | mItem->setText(7,t->dtDueDateStr()); |
162 | if (t->doesFloat()) { | 162 | if (t->doesFloat()) { |
163 | mItem->setText(8,"---"); | 163 | mItem->setText(8,"---"); |
164 | } else { | 164 | } else { |
165 | mItem->setText(8,t->dtDueTimeStr()); | 165 | mItem->setText(8,t->dtDueTimeStr()); |
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | mItem->setText(7,"---"); | 168 | mItem->setText(7,"---"); |
169 | mItem->setText(8,"---"); | 169 | mItem->setText(8,"---"); |
170 | } | 170 | } |
171 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 171 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
172 | mItem->setText(10,t->categoriesStr()); | 172 | mItem->setText(10,t->categoriesStr()); |
173 | 173 | ||
174 | QString key; | 174 | QString key; |
175 | QDate d; | 175 | QDate d; |
176 | if (t->hasDueDate()) { | 176 | if (t->hasDueDate()) { |
177 | d = t->dtDue().date(); | 177 | d = t->dtDue().date(); |
178 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 178 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
179 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 179 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
180 | mItem->setSortKey(7,key); | 180 | mItem->setSortKey(7,key); |
181 | } | 181 | } |
182 | if ( t->hasStartDate() ) { | 182 | if ( t->hasStartDate() ) { |
183 | d = t->dtStart().date(); | 183 | d = t->dtStart().date(); |
184 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 184 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
185 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 185 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
186 | mItem->setSortKey(1,key); | 186 | mItem->setSortKey(1,key); |
187 | } | 187 | } |
188 | return true; | 188 | return true; |
189 | } | 189 | } |
190 | 190 | ||
191 | bool ListItemVisitor::visit(Journal * j) | 191 | bool ListItemVisitor::visit(Journal * j) |
192 | { | 192 | { |
193 | QString des = j->description().left(30); | 193 | QString des = j->description().left(30); |
194 | des = des.simplifyWhiteSpace (); | 194 | des = des.simplifyWhiteSpace (); |
195 | des.replace (QRegExp ("\\n"),"" ); | 195 | des.replace (QRegExp ("\\n"),"" ); |
196 | des.replace (QRegExp ("\\r"),"" ); | 196 | des.replace (QRegExp ("\\r"),"" ); |
197 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 197 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
198 | mItem->setText(1,j->dtStartDateStr()); | 198 | mItem->setText(1,j->dtStartDateStr()); |
199 | mItem->setText(2,"---"); | 199 | mItem->setText(2,"---"); |
200 | mItem->setText(3,"---"); | 200 | mItem->setText(3,"---"); |
201 | mItem->setText(4,"---"); | 201 | mItem->setText(4,"---"); |
202 | mItem->setText(5,"---"); | 202 | mItem->setText(5,"---"); |
203 | mItem->setText(6,"---"); | 203 | mItem->setText(6,"---"); |
204 | mItem->setText(7,j->dtStartDateStr()); | 204 | mItem->setText(7,j->dtStartDateStr()); |
205 | mItem->setText(8,"---"); | 205 | mItem->setText(8,"---"); |
206 | mItem->setText(9,"---"); | 206 | mItem->setText(9,"---"); |
207 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 207 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
208 | 208 | ||
209 | QString key; | 209 | QString key; |
210 | QDate d = j->dtStart().date(); | 210 | QDate d = j->dtStart().date(); |
211 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 211 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
212 | mItem->setSortKey(1,key); | 212 | mItem->setSortKey(1,key); |
213 | mItem->setSortKey(7,key); | 213 | mItem->setSortKey(7,key); |
214 | 214 | ||
215 | return true; | 215 | return true; |
216 | } | 216 | } |
217 | 217 | ||
218 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 218 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
219 | const char *name) | 219 | const char *name) |
220 | : KOEventView(calendar, parent, name) | 220 | : KOEventView(calendar, parent, name) |
221 | { | 221 | { |
222 | mActiveItem = 0; | 222 | mActiveItem = 0; |
223 | mListView = new KOListViewListView(this); | 223 | mListView = new KOListViewListView(this); |
224 | mListView->addColumn(i18n("Summary")); | 224 | mListView->addColumn(i18n("Summary")); |
225 | mListView->addColumn(i18n("Start Date")); | 225 | mListView->addColumn(i18n("Start Date")); |
226 | mListView->addColumn(i18n("Start Time")); | 226 | mListView->addColumn(i18n("Start Time")); |
227 | mListView->addColumn(i18n("End Date")); | 227 | mListView->addColumn(i18n("End Date")); |
228 | mListView->addColumn(i18n("End Time")); | 228 | mListView->addColumn(i18n("End Time")); |
229 | mListView->addColumn(i18n("Alarm")); // alarm set? | 229 | mListView->addColumn(i18n("Alarm")); // alarm set? |
230 | mListView->addColumn(i18n("Recurs")); // recurs? | 230 | mListView->addColumn(i18n("Recurs")); // recurs? |
231 | mListView->addColumn(i18n("Due Date")); | 231 | mListView->addColumn(i18n("Due Date")); |
232 | mListView->addColumn(i18n("Due Time")); | 232 | mListView->addColumn(i18n("Due Time")); |
233 | mListView->addColumn(i18n("Cancelled")); | 233 | mListView->addColumn(i18n("Cancelled")); |
234 | mListView->addColumn(i18n("Categories")); | 234 | mListView->addColumn(i18n("Categories")); |
235 | 235 | ||
236 | mListView->setColumnAlignment(0,AlignLeft); | 236 | mListView->setColumnAlignment(0,AlignLeft); |
237 | mListView->setColumnAlignment(1,AlignLeft); | 237 | mListView->setColumnAlignment(1,AlignLeft); |
238 | mListView->setColumnAlignment(2,AlignHCenter); | 238 | mListView->setColumnAlignment(2,AlignHCenter); |
239 | mListView->setColumnAlignment(3,AlignLeft); | 239 | mListView->setColumnAlignment(3,AlignLeft); |
240 | mListView->setColumnAlignment(4,AlignHCenter); | 240 | mListView->setColumnAlignment(4,AlignHCenter); |
241 | mListView->setColumnAlignment(5,AlignLeft); | 241 | mListView->setColumnAlignment(5,AlignLeft); |
242 | mListView->setColumnAlignment(6,AlignLeft); | 242 | mListView->setColumnAlignment(6,AlignLeft); |
243 | mListView->setColumnAlignment(7,AlignLeft); | 243 | mListView->setColumnAlignment(7,AlignLeft); |
244 | mListView->setColumnAlignment(8,AlignLeft); | 244 | mListView->setColumnAlignment(8,AlignLeft); |
245 | mListView->setColumnAlignment(9,AlignLeft); | 245 | mListView->setColumnAlignment(9,AlignLeft); |
246 | mListView->setColumnAlignment(10,AlignLeft); | 246 | mListView->setColumnAlignment(10,AlignLeft); |
247 | mListView->setColumnWidthMode(10, QListView::Manual); | 247 | mListView->setColumnWidthMode(10, QListView::Manual); |
248 | new KOListViewWhatsThis(mListView->viewport(),this); | 248 | new KOListViewWhatsThis(mListView->viewport(),this); |
249 | 249 | ||
250 | int iii = 0; | 250 | int iii = 0; |
251 | for ( iii = 0; iii< 10 ; ++iii ) | 251 | for ( iii = 0; iii< 10 ; ++iii ) |
252 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 252 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
253 | 253 | ||
254 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 254 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
255 | layoutTop->addWidget(mListView); | 255 | layoutTop->addWidget(mListView); |
256 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 256 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
257 | mPopupMenu = eventPopup(); | 257 | mPopupMenu = eventPopup(); |
258 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 258 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
259 | i18n("Select all"),this, | 259 | i18n("Select all"),this, |
260 | SLOT(allSelection()),true); | 260 | SLOT(allSelection()),true); |
261 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 261 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
262 | i18n("Deselect all"),this, | 262 | i18n("Deselect all"),this, |
263 | SLOT(clearSelection()),true); | 263 | SLOT(clearSelection()),true); |
264 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 264 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
265 | i18n("Delete all selected"),this, | 265 | i18n("Delete all selected"),this, |
266 | SLOT(deleteAll()),true); | 266 | SLOT(deleteAll()),true); |
267 | mPopupMenu->insertSeparator(); | 267 | mPopupMenu->insertSeparator(); |
268 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 268 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
269 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 269 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
270 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 270 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
271 | SLOT(saveToFile())); | 271 | SLOT(saveToFile())); |
272 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 272 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
273 | SLOT(saveToFileVCS())); | 273 | SLOT(saveToFileVCS())); |
274 | exportPO->insertItem( i18n("Journal/Details..."),this, | 274 | exportPO->insertItem( i18n("Journal/Details..."),this, |
275 | SLOT(saveDescriptionToFile())); | 275 | SLOT(saveDescriptionToFile())); |
276 | // mPopupMenu->insertSeparator(); | 276 | // mPopupMenu->insertSeparator(); |
277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
278 | i18n("Add Categ. to selected..."),this, | 278 | i18n("Add Categ. to selected..."),this, |
279 | SLOT(addCat()),true); | 279 | SLOT(addCat()),true); |
280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
281 | i18n("Set Categ. for selected..."),this, | 281 | i18n("Set Categ. for selected..."),this, |
282 | SLOT(setCat()),true); | 282 | SLOT(setCat()),true); |
283 | //mPopupMenu->insertSeparator(); | 283 | //mPopupMenu->insertSeparator(); |
284 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 284 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
285 | i18n("Set alarm for selected..."),this, | 285 | i18n("Set alarm for selected..."),this, |
286 | SLOT(setAlarm()),true); | 286 | SLOT(setAlarm()),true); |
287 | 287 | ||
288 | 288 | ||
289 | #ifndef DESKTOP_VERSION | 289 | #ifndef DESKTOP_VERSION |
290 | mPopupMenu->insertSeparator(); | 290 | mPopupMenu->insertSeparator(); |
291 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 291 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
292 | i18n("Beam selected via IR"),this, | 292 | i18n("Beam selected via IR"),this, |
293 | SLOT(beamSelected()),true); | 293 | SLOT(beamSelected()),true); |
294 | #endif | 294 | #endif |
295 | /* | 295 | /* |
296 | mPopupMenu = new QPopupMenu; | 296 | mPopupMenu = new QPopupMenu; |
297 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 297 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
298 | SLOT (editEvent())); | 298 | SLOT (editEvent())); |
299 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 299 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
300 | SLOT (deleteEvent())); | 300 | SLOT (deleteEvent())); |
301 | mPopupMenu->insertSeparator(); | 301 | mPopupMenu->insertSeparator(); |
302 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 302 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
303 | SLOT(showDates())); | 303 | SLOT(showDates())); |
304 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 304 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
305 | SLOT(hideDates())); | 305 | SLOT(hideDates())); |
306 | */ | 306 | */ |
307 | QObject::connect(mListView,SIGNAL( newEvent()), | 307 | QObject::connect(mListView,SIGNAL( newEvent()), |
308 | this,SIGNAL(signalNewEvent())); | 308 | this,SIGNAL(signalNewEvent())); |
309 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 309 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
310 | this,SLOT(defaultItemAction(QListViewItem *))); | 310 | this,SLOT(defaultItemAction(QListViewItem *))); |
311 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 311 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
312 | const QPoint &, int )), | 312 | const QPoint &, int )), |
313 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 313 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
314 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 314 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
315 | SLOT(processSelectionChange(QListViewItem *))); | 315 | SLOT(processSelectionChange(QListViewItem *))); |
316 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 316 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
317 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 317 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
318 | 318 | ||
319 | readSettings(KOGlobals::config(),"KOListView Layout"); | 319 | readSettings(KOGlobals::config(),"KOListView Layout"); |
320 | } | 320 | } |
321 | 321 | ||
322 | KOListView::~KOListView() | 322 | KOListView::~KOListView() |
323 | { | 323 | { |
324 | delete mPopupMenu; | 324 | delete mPopupMenu; |
325 | } | 325 | } |
326 | QString KOListView::getWhatsThisText(QPoint p) | 326 | QString KOListView::getWhatsThisText(QPoint p) |
327 | { | 327 | { |
328 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 328 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
329 | if ( item ) | 329 | if ( item ) |
330 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 330 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
331 | KOPrefs::instance()->mWTshowDetails, | 331 | KOPrefs::instance()->mWTshowDetails, |
332 | KOPrefs::instance()->mWTshowCreated, | 332 | KOPrefs::instance()->mWTshowCreated, |
333 | KOPrefs::instance()->mWTshowChanged); | 333 | KOPrefs::instance()->mWTshowChanged); |
334 | return i18n("That is the list view" ); | 334 | return i18n("That is the list view" ); |
335 | 335 | ||
336 | } | 336 | } |
337 | 337 | ||
338 | void KOListView::updateList() | 338 | void KOListView::updateList() |
339 | { | 339 | { |
340 | // qDebug(" KOListView::updateList() "); | 340 | // qDebug(" KOListView::updateList() "); |
341 | 341 | ||
342 | } | 342 | } |
343 | 343 | ||
344 | void KOListView::addCat( ) | 344 | void KOListView::addCat( ) |
345 | { | 345 | { |
346 | setCategories( false ); | 346 | setCategories( false ); |
347 | } | 347 | } |
348 | void KOListView::setCat() | 348 | void KOListView::setCat() |
349 | { | 349 | { |
350 | setCategories( true ); | 350 | setCategories( true ); |
351 | } | 351 | } |
352 | void KOListView::setAlarm() | 352 | void KOListView::setAlarm() |
353 | { | 353 | { |
354 | KOAlarmPrefs kap( this); | 354 | KOAlarmPrefs kap( this); |
355 | if ( !kap.exec() ) | 355 | if ( !kap.exec() ) |
356 | return; | 356 | return; |
357 | 357 | ||
358 | 358 | ||
359 | QStringList itemList; | 359 | QStringList itemList; |
360 | QPtrList<KOListViewItem> sel ; | 360 | QPtrList<KOListViewItem> sel ; |
361 | QListViewItem *qitem = mListView->firstChild (); | 361 | QListViewItem *qitem = mListView->firstChild (); |
362 | while ( qitem ) { | 362 | while ( qitem ) { |
363 | if ( qitem->isSelected() ) { | 363 | if ( qitem->isSelected() ) { |
364 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 364 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
365 | if ( inc->type() != "Journal" ) { | 365 | if ( inc->type() != "Journal" ) { |
366 | if ( inc->type() == "Todo" ) { | 366 | if ( inc->type() == "Todo" ) { |
367 | if ( ((Todo*)inc)->hasDueDate() ) | 367 | if ( ((Todo*)inc)->hasDueDate() ) |
368 | sel.append(((KOListViewItem *)qitem)); | 368 | sel.append(((KOListViewItem *)qitem)); |
369 | } else | 369 | } else |
370 | sel.append(((KOListViewItem *)qitem)); | 370 | sel.append(((KOListViewItem *)qitem)); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | qitem = qitem->nextSibling(); | 373 | qitem = qitem->nextSibling(); |
374 | } | 374 | } |
375 | int count = 0; | 375 | int count = 0; |
376 | KOListViewItem * item, *temp; | 376 | KOListViewItem * item, *temp; |
377 | item = sel.first(); | 377 | item = sel.first(); |
378 | Incidence* inc; | 378 | Incidence* inc; |
379 | while ( item ) { | 379 | while ( item ) { |
380 | inc = item->data(); | 380 | inc = item->data(); |
381 | ++count; | 381 | ++count; |
382 | if (kap.mAlarmButton->isChecked()) { | 382 | if (kap.mAlarmButton->isChecked()) { |
383 | if (inc->alarms().count() == 0) | 383 | if (inc->alarms().count() == 0) |
384 | inc->newAlarm(); | 384 | inc->newAlarm(); |
385 | QPtrList<Alarm> alarms = inc->alarms(); | 385 | QPtrList<Alarm> alarms = inc->alarms(); |
386 | Alarm *alarm; | 386 | Alarm *alarm; |
387 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 387 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
388 | alarm->setEnabled(true); | 388 | alarm->setEnabled(true); |
389 | int j = kap.mAlarmTimeEdit->value()* -60; | 389 | int j = kap.mAlarmTimeEdit->value()* -60; |
390 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 390 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
391 | j = j * 60; | 391 | j = j * 60; |
392 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 392 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
393 | j = j * (60 * 24); | 393 | j = j * (60 * 24); |
394 | alarm->setStartOffset( j ); | 394 | alarm->setStartOffset( j ); |
395 | 395 | ||
396 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 396 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
397 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 397 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
398 | } | 398 | } |
399 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 399 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
400 | alarm->setAudioAlarm(kap.mAlarmSound); | 400 | alarm->setAudioAlarm(kap.mAlarmSound); |
401 | else | 401 | else |
402 | alarm->setType(Alarm::Invalid); | 402 | alarm->setType(Alarm::Invalid); |
403 | //alarm->setAudioAlarm("default"); | 403 | //alarm->setAudioAlarm("default"); |
404 | // TODO: Deal with multiple alarms | 404 | // TODO: Deal with multiple alarms |
405 | break; // For now, stop after the first alarm | 405 | break; // For now, stop after the first alarm |
406 | } | 406 | } |
407 | } else { | 407 | } else { |
408 | Alarm* alarm = inc->alarms().first(); | 408 | Alarm* alarm = inc->alarms().first(); |
409 | if ( alarm ) { | 409 | if ( alarm ) { |
410 | alarm->setEnabled(false); | 410 | alarm->setEnabled(false); |
411 | alarm->setType(Alarm::Invalid); | 411 | alarm->setType(Alarm::Invalid); |
412 | } | 412 | } |
413 | } | 413 | } |
414 | temp = item; | 414 | temp = item; |
415 | item = sel.next(); | 415 | item = sel.next(); |
416 | mUidDict.remove( inc->uid() ); | 416 | mUidDict.remove( inc->uid() ); |
417 | delete temp;; | 417 | delete temp;; |
418 | addIncidence( inc ); | 418 | addIncidence( inc ); |
419 | } | 419 | } |
420 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); | 420 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); |
421 | qDebug("KO: Set alarm for %d items", count); | 421 | qDebug("KO: Set alarm for %d items", count); |
422 | calendar()->reInitAlarmSettings(); | 422 | calendar()->reInitAlarmSettings(); |
423 | } | 423 | } |
424 | void KOListView::setCategories( bool removeOld ) | 424 | void KOListView::setCategories( bool removeOld ) |
425 | { | 425 | { |
426 | 426 | ||
427 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 427 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
428 | if (! csd->exec()) { | 428 | if (! csd->exec()) { |
429 | delete csd; | 429 | delete csd; |
430 | return; | 430 | return; |
431 | } | 431 | } |
432 | QStringList catList = csd->selectedCategories(); | 432 | QStringList catList = csd->selectedCategories(); |
433 | delete csd; | 433 | delete csd; |
434 | // if ( catList.count() == 0 ) | 434 | // if ( catList.count() == 0 ) |
435 | // return; | 435 | // return; |
436 | catList.sort(); | 436 | catList.sort(); |
437 | QString categoriesStr = catList.join(","); | 437 | QString categoriesStr = catList.join(","); |
438 | int i; | 438 | int i; |
439 | QStringList itemList; | 439 | QStringList itemList; |
440 | QPtrList<KOListViewItem> sel ; | 440 | QPtrList<KOListViewItem> sel ; |
441 | QListViewItem *qitem = mListView->firstChild (); | 441 | QListViewItem *qitem = mListView->firstChild (); |
442 | while ( qitem ) { | 442 | while ( qitem ) { |
443 | if ( qitem->isSelected() ) { | 443 | if ( qitem->isSelected() ) { |
444 | sel.append(((KOListViewItem *)qitem)); | 444 | sel.append(((KOListViewItem *)qitem)); |
445 | } | 445 | } |
446 | qitem = qitem->nextSibling(); | 446 | qitem = qitem->nextSibling(); |
447 | } | 447 | } |
448 | KOListViewItem * item, *temp; | 448 | KOListViewItem * item, *temp; |
449 | item = sel.first(); | 449 | item = sel.first(); |
450 | Incidence* inc; | 450 | Incidence* inc; |
451 | while ( item ) { | 451 | while ( item ) { |
452 | inc = item->data(); | 452 | inc = item->data(); |
453 | if ( removeOld ) { | 453 | if ( removeOld ) { |
454 | inc->setCategories( categoriesStr ); | 454 | inc->setCategories( categoriesStr ); |
455 | } else { | 455 | } else { |
456 | itemList = QStringList::split (",", inc->categoriesStr() ); | 456 | itemList = QStringList::split (",", inc->categoriesStr() ); |
457 | for( i = 0; i< catList.count(); ++i ) { | 457 | for( i = 0; i< catList.count(); ++i ) { |
458 | if ( !itemList.contains (catList[i])) | 458 | if ( !itemList.contains (catList[i])) |
459 | itemList.append( catList[i] ); | 459 | itemList.append( catList[i] ); |
460 | } | 460 | } |
461 | itemList.sort(); | 461 | itemList.sort(); |
462 | inc->setCategories( itemList.join(",") ); | 462 | inc->setCategories( itemList.join(",") ); |
463 | } | 463 | } |
464 | temp = item; | 464 | temp = item; |
465 | item = sel.next(); | 465 | item = sel.next(); |
466 | mUidDict.remove( inc->uid() ); | 466 | mUidDict.remove( inc->uid() ); |
467 | delete temp;; | 467 | delete temp;; |
468 | addIncidence( inc ); | 468 | addIncidence( inc ); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | void KOListView::beamSelected() | 472 | void KOListView::beamSelected() |
473 | { | 473 | { |
474 | int icount = 0; | 474 | int icount = 0; |
475 | QPtrList<Incidence> delSel ; | 475 | QPtrList<Incidence> delSel ; |
476 | QListViewItem *item = mListView->firstChild (); | 476 | QListViewItem *item = mListView->firstChild (); |
477 | while ( item ) { | 477 | while ( item ) { |
478 | if ( item->isSelected() ) { | 478 | if ( item->isSelected() ) { |
479 | delSel.append(((KOListViewItem *)item)->data()); | 479 | delSel.append(((KOListViewItem *)item)->data()); |
480 | ++icount; | 480 | ++icount; |
481 | } | 481 | } |
482 | 482 | ||
483 | item = item->nextSibling(); | 483 | item = item->nextSibling(); |
484 | } | 484 | } |
485 | if ( icount ) { | 485 | if ( icount ) { |
486 | emit beamIncidenceList( delSel ); | 486 | emit beamIncidenceList( delSel ); |
487 | return; | 487 | return; |
488 | QString fn ; | 488 | QString fn ; |
489 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 489 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
490 | QString mes; | 490 | QString mes; |
491 | bool createbup = true; | 491 | bool createbup = true; |
492 | if ( createbup ) { | 492 | if ( createbup ) { |
493 | QString description = "\n"; | 493 | QString description = "\n"; |
494 | CalendarLocal* cal = new CalendarLocal(); | 494 | CalendarLocal* cal = new CalendarLocal(); |
495 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 495 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
496 | Incidence *incidence = delSel.first(); | 496 | Incidence *incidence = delSel.first(); |
497 | while ( incidence ) { | 497 | while ( incidence ) { |
498 | Incidence *in = incidence->clone(); | 498 | Incidence *in = incidence->clone(); |
499 | description += in->summary() + "\n"; | 499 | description += in->summary() + "\n"; |
500 | cal->addIncidence( in ); | 500 | cal->addIncidence( in ); |
501 | incidence = delSel.next(); | 501 | incidence = delSel.next(); |
502 | } | 502 | } |
503 | FileStorage storage( cal, fn, new VCalFormat ); | 503 | FileStorage storage( cal, fn, new VCalFormat ); |
504 | storage.save(); | 504 | storage.save(); |
505 | delete cal; | 505 | delete cal; |
506 | mes = i18n("KO/Pi: Ready for beaming"); | 506 | mes = i18n("KO/Pi: Ready for beaming"); |
507 | topLevelWidget()->setCaption(mes); | 507 | topLevelWidget()->setCaption(mes); |
508 | 508 | ||
509 | #ifndef DESKTOP_VERSION | 509 | #ifndef DESKTOP_VERSION |
510 | Ir *ir = new Ir( this ); | 510 | Ir *ir = new Ir( this ); |
511 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 511 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
512 | ir->send( fn, description, "text/x-vCalendar" ); | 512 | ir->send( fn, description, "text/x-vCalendar" ); |
513 | #endif | 513 | #endif |
514 | } | 514 | } |
515 | } | 515 | } |
516 | } | 516 | } |
517 | void KOListView::beamDone( Ir *ir ) | 517 | void KOListView::beamDone( Ir *ir ) |
518 | { | 518 | { |
519 | #ifndef DESKTOP_VERSION | 519 | #ifndef DESKTOP_VERSION |
520 | delete ir; | 520 | delete ir; |
521 | #endif | 521 | #endif |
522 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 522 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
523 | } | 523 | } |
524 | 524 | ||
525 | void KOListView::saveDescriptionToFile() | 525 | void KOListView::saveDescriptionToFile() |
526 | { | 526 | { |
527 | 527 | ||
528 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 528 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
529 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 529 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
530 | i18n("Continue"), i18n("Cancel"), 0, | 530 | i18n("Continue"), i18n("Cancel"), 0, |
531 | 0, 1 ); | 531 | 0, 1 ); |
532 | if ( result != 0 ) { | 532 | if ( result != 0 ) { |
533 | return; | 533 | return; |
534 | } | 534 | } |
535 | int icount = 0; | 535 | int icount = 0; |
536 | QPtrList<Incidence> delSel ; | 536 | QPtrList<Incidence> delSel ; |
537 | QListViewItem *item = mListView->firstChild (); | 537 | QListViewItem *item = mListView->firstChild (); |
538 | while ( item ) { | 538 | while ( item ) { |
539 | if ( item->isSelected() ) { | 539 | if ( item->isSelected() ) { |
540 | delSel.append(((KOListViewItem *)item)->data()); | 540 | delSel.append(((KOListViewItem *)item)->data()); |
541 | ++icount; | 541 | ++icount; |
542 | } | 542 | } |
543 | 543 | ||
544 | item = item->nextSibling(); | 544 | item = item->nextSibling(); |
545 | } | 545 | } |
546 | if ( icount ) { | 546 | if ( icount ) { |
547 | QString fn = KOPrefs::instance()->mLastSaveFile; | 547 | QString fn = KOPrefs::instance()->mLastSaveFile; |
548 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 548 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
549 | 549 | ||
550 | if ( fn == "" ) | 550 | if ( fn == "" ) |
551 | return; | 551 | return; |
552 | QFileInfo info; | 552 | QFileInfo info; |
553 | info.setFile( fn ); | 553 | info.setFile( fn ); |
554 | QString mes; | 554 | QString mes; |
555 | bool createbup = true; | 555 | bool createbup = true; |
556 | if ( info. exists() ) { | 556 | if ( info. exists() ) { |
557 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 557 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
558 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 558 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
559 | i18n("Overwrite!"), i18n("Cancel"), 0, | 559 | i18n("Overwrite!"), i18n("Cancel"), 0, |
560 | 0, 1 ); | 560 | 0, 1 ); |
561 | if ( result != 0 ) { | 561 | if ( result != 0 ) { |
562 | createbup = false; | 562 | createbup = false; |
563 | } | 563 | } |
564 | } | 564 | } |
565 | if ( createbup ) { | 565 | if ( createbup ) { |
566 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 566 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
567 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 567 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
568 | Incidence *incidence = delSel.first(); | 568 | Incidence *incidence = delSel.first(); |
569 | icount = 0; | 569 | icount = 0; |
570 | while ( incidence ) { | 570 | while ( incidence ) { |
571 | if ( incidence->type() == "Journal" ) { | 571 | if ( incidence->type() == "Journal" ) { |
572 | text += "\n************************************\n"; | 572 | text += "\n************************************\n"; |
573 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 573 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
574 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 574 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
575 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 575 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
576 | ++icount; | 576 | ++icount; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( !incidence->description().isEmpty() ) { | 579 | if ( !incidence->description().isEmpty() ) { |
580 | text += "\n************************************\n"; | 580 | text += "\n************************************\n"; |
581 | if ( incidence->type() == "Todo" ) | 581 | if ( incidence->type() == "Todo" ) |
582 | text += i18n("To-Do: "); | 582 | text += i18n("To-Do: "); |
583 | text += incidence->summary(); | 583 | text += incidence->summary(); |
584 | if ( incidence->hasStartDate() ) | 584 | if ( incidence->hasStartDate() ) |
585 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 585 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
586 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 586 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
587 | if ( !incidence->location().isEmpty() ) | 587 | if ( !incidence->location().isEmpty() ) |
588 | text += "\n" +i18n("Location: ") + incidence->location(); | 588 | text += "\n" +i18n("Location: ") + incidence->location(); |
589 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 589 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
590 | ++icount; | 590 | ++icount; |
591 | 591 | ||
592 | } | 592 | } |
593 | } | 593 | } |
594 | incidence = delSel.next(); | 594 | incidence = delSel.next(); |
595 | } | 595 | } |
596 | QFile file( fn ); | 596 | QFile file( fn ); |
597 | if (!file.open( IO_WriteOnly ) ) { | 597 | if (!file.open( IO_WriteOnly ) ) { |
598 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 598 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
599 | return; | 599 | return; |
600 | } | 600 | } |
601 | QTextStream ts( &file ); | 601 | QTextStream ts( &file ); |
602 | ts << text; | 602 | ts << text; |
603 | file.close(); | 603 | file.close(); |
604 | //qDebug("%s ", text.latin1()); | 604 | //qDebug("%s ", text.latin1()); |
605 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 605 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
606 | KOPrefs::instance()->mLastSaveFile = fn; | 606 | KOPrefs::instance()->mLastSaveFile = fn; |
607 | topLevelWidget()->setCaption(mes); | 607 | topLevelWidget()->setCaption(mes); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | } | 610 | } |
611 | void KOListView::saveToFileVCS() | 611 | void KOListView::saveToFileVCS() |
612 | { | 612 | { |
613 | writeToFile( false ); | 613 | writeToFile( false ); |
614 | } | 614 | } |
615 | void KOListView::saveToFile() | 615 | void KOListView::saveToFile() |
616 | { | 616 | { |
617 | writeToFile( true ); | 617 | writeToFile( true ); |
618 | } | 618 | } |
619 | void KOListView::writeToFile( bool iCal ) | 619 | void KOListView::writeToFile( bool iCal ) |
620 | { | 620 | { |
621 | 621 | ||
622 | int icount = 0; | 622 | int icount = 0; |
623 | QPtrList<Incidence> delSel ; | 623 | QPtrList<Incidence> delSel ; |
624 | QListViewItem *item = mListView->firstChild (); | 624 | QListViewItem *item = mListView->firstChild (); |
625 | bool journal = iCal; // warn only for vCal | 625 | bool journal = iCal; // warn only for vCal |
626 | while ( item ) { | 626 | while ( item ) { |
627 | if ( item->isSelected() ) { | 627 | if ( item->isSelected() ) { |
628 | if ( !journal ) | 628 | if ( !journal ) |
629 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") | 629 | if ( ((KOListViewItem *)item)->data()->type() == "Journal") |
630 | journal = true; | 630 | journal = true; |
631 | delSel.append(((KOListViewItem *)item)->data()); | 631 | delSel.append(((KOListViewItem *)item)->data()); |
632 | ++icount; | 632 | ++icount; |
633 | } | 633 | } |
634 | 634 | ||
635 | item = item->nextSibling(); | 635 | item = item->nextSibling(); |
636 | } | 636 | } |
637 | if ( !iCal && journal ) { | 637 | if ( !iCal && journal ) { |
638 | int result = KMessageBox::warningContinueCancel(this, | 638 | int result = KMessageBox::warningContinueCancel(this, |
639 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 639 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
640 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 640 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
641 | true); | 641 | true); |
642 | if (result != KMessageBox::Continue) return; | 642 | if (result != KMessageBox::Continue) return; |
643 | } | 643 | } |
644 | if ( icount ) { | 644 | if ( icount ) { |
645 | QString fn = KOPrefs::instance()->mLastSaveFile; | 645 | QString fn = KOPrefs::instance()->mLastSaveFile; |
646 | QString extension; | 646 | QString extension; |
647 | if ( iCal ) { | 647 | if ( iCal ) { |
648 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 648 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
649 | fn = fn.left( fn.length() -3) + "ics"; | 649 | fn = fn.left( fn.length() -3) + "ics"; |
650 | } | 650 | } |
651 | } else { | 651 | } else { |
652 | if ( fn.right( 4 ).lower() == ".ics" ) { | 652 | if ( fn.right( 4 ).lower() == ".ics" ) { |
653 | fn = fn.left( fn.length() -3) + "vcs"; | 653 | fn = fn.left( fn.length() -3) + "vcs"; |
654 | } | 654 | } |
655 | } | 655 | } |
656 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 656 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
657 | 657 | ||
658 | if ( fn == "" ) | 658 | if ( fn == "" ) |
659 | return; | 659 | return; |
660 | QFileInfo info; | 660 | QFileInfo info; |
661 | info.setFile( fn ); | 661 | info.setFile( fn ); |
662 | QString mes; | 662 | QString mes; |
663 | bool createbup = true; | 663 | bool createbup = true; |
664 | if ( info. exists() ) { | 664 | if ( info. exists() ) { |
665 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 665 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
666 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 666 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
667 | i18n("Overwrite!"), i18n("Cancel"), 0, | 667 | i18n("Overwrite!"), i18n("Cancel"), 0, |
668 | 0, 1 ); | 668 | 0, 1 ); |
669 | if ( result != 0 ) { | 669 | if ( result != 0 ) { |
670 | createbup = false; | 670 | createbup = false; |
671 | } | 671 | } |
672 | } | 672 | } |
673 | if ( createbup ) { | 673 | if ( createbup ) { |
674 | CalendarLocal cal; | 674 | CalendarLocal cal; |
675 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 675 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
676 | Incidence *incidence = delSel.first(); | 676 | Incidence *incidence = delSel.first(); |
677 | while ( incidence ) { | 677 | while ( incidence ) { |
678 | cal.addIncidence( incidence->clone() ); | 678 | cal.addIncidence( incidence->clone() ); |
679 | incidence = delSel.next(); | 679 | incidence = delSel.next(); |
680 | } | 680 | } |
681 | if ( iCal ) { | 681 | if ( iCal ) { |
682 | ICalFormat format; | 682 | ICalFormat format; |
683 | format.save( &cal, fn ); | 683 | format.save( &cal, fn ); |
684 | } else { | 684 | } else { |
685 | 685 | ||
686 | VCalFormat format; | 686 | VCalFormat format; |
687 | format.save( &cal, fn ); | 687 | format.save( &cal, fn ); |
688 | } | 688 | } |
689 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 689 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
690 | KOPrefs::instance()->mLastSaveFile = fn; | 690 | KOPrefs::instance()->mLastSaveFile = fn; |
691 | topLevelWidget()->setCaption(mes); | 691 | topLevelWidget()->setCaption(mes); |
692 | } | 692 | } |
693 | } | 693 | } |
694 | } | 694 | } |
695 | void KOListView::deleteAll() | 695 | void KOListView::deleteAll() |
696 | { | 696 | { |
697 | int icount = 0; | 697 | int icount = 0; |
698 | QPtrList<Incidence> delSel ; | 698 | QPtrList<Incidence> delSel ; |
699 | QListViewItem *item = mListView->firstChild (); | 699 | QListViewItem *item = mListView->firstChild (); |
700 | while ( item ) { | 700 | while ( item ) { |
701 | if ( item->isSelected() ) { | 701 | if ( item->isSelected() ) { |
702 | delSel.append(((KOListViewItem *)item)->data()); | 702 | delSel.append(((KOListViewItem *)item)->data()); |
703 | ++icount; | 703 | ++icount; |
704 | } | 704 | } |
705 | 705 | ||
706 | item = item->nextSibling(); | 706 | item = item->nextSibling(); |
707 | } | 707 | } |
708 | if ( icount ) { | 708 | if ( icount ) { |
709 | Incidence *incidence = delSel.first(); | 709 | Incidence *incidence = delSel.first(); |
710 | Incidence *toDelete; | 710 | Incidence *toDelete; |
711 | KOPrefs *p = KOPrefs::instance(); | 711 | KOPrefs *p = KOPrefs::instance(); |
712 | bool confirm = p->mConfirm; | 712 | bool confirm = p->mConfirm; |
713 | QString mess; | 713 | QString mess; |
714 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 714 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
715 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 715 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
716 | p->mConfirm = false; | 716 | p->mConfirm = false; |
717 | int delCounter = 0; | 717 | int delCounter = 0; |
718 | QDialog dia ( this, "p-dialog", true ); | 718 | QDialog dia ( this, "p-dialog", true ); |
719 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 719 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
720 | QVBoxLayout lay( &dia ); | 720 | QVBoxLayout lay( &dia ); |
721 | lay.setMargin(7); | 721 | lay.setMargin(7); |
722 | lay.setSpacing(7); | 722 | lay.setSpacing(7); |
723 | lay.addWidget( &lab); | 723 | lay.addWidget( &lab); |
724 | QProgressBar bar( icount, &dia ); | 724 | QProgressBar bar( icount, &dia ); |
725 | lay.addWidget( &bar); | 725 | lay.addWidget( &bar); |
726 | int w = 220; | 726 | int w = 220; |
727 | int h = 50; | 727 | int h = 50; |
728 | int dw = QApplication::desktop()->width(); | 728 | int dw = QApplication::desktop()->width(); |
729 | int dh = QApplication::desktop()->height(); | 729 | int dh = QApplication::desktop()->height(); |
730 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 730 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
731 | //dia.resize( 240,50 ); | 731 | //dia.resize( 240,50 ); |
732 | dia.show(); | 732 | dia.show(); |
733 | 733 | ||
734 | while ( incidence ) { | 734 | while ( incidence ) { |
735 | bar.setProgress( delCounter ); | 735 | bar.setProgress( delCounter ); |
736 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 736 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
737 | dia.setCaption( mess ); | 737 | dia.setCaption( mess ); |
738 | qApp->processEvents(); | 738 | qApp->processEvents(); |
739 | toDelete = (incidence); | 739 | toDelete = (incidence); |
740 | incidence = delSel.next(); | 740 | incidence = delSel.next(); |
741 | emit deleteIncidenceSignal(toDelete ); | 741 | emit deleteIncidenceSignal(toDelete ); |
742 | if ( dia.result() != 0 ) | 742 | if ( dia.result() != 0 ) |
743 | break; | 743 | break; |
744 | 744 | ||
745 | } | 745 | } |
746 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 746 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
747 | topLevelWidget ()->setCaption( mess ); | 747 | topLevelWidget ()->setCaption( mess ); |
748 | p->mConfirm = confirm; | 748 | p->mConfirm = confirm; |
749 | } | 749 | } |
750 | } | 750 | } |
751 | 751 | ||
752 | 752 | ||
753 | } | 753 | } |
754 | int KOListView::maxDatesHint() | 754 | int KOListView::maxDatesHint() |
755 | { | 755 | { |
756 | return 0; | 756 | return 0; |
757 | } | 757 | } |
758 | 758 | ||
759 | int KOListView::currentDateCount() | 759 | int KOListView::currentDateCount() |
760 | { | 760 | { |
761 | return 0; | 761 | return 0; |
762 | } | 762 | } |
763 | 763 | ||
764 | QPtrList<Incidence> KOListView::selectedIncidences() | 764 | QPtrList<Incidence> KOListView::selectedIncidences() |
765 | { | 765 | { |
766 | QPtrList<Incidence> eventList; | 766 | QPtrList<Incidence> eventList; |
767 | QListViewItem *item = mListView->firstChild (); | 767 | QListViewItem *item = mListView->firstChild (); |
768 | while ( item ) { | 768 | while ( item ) { |
769 | if ( item->isSelected() ) { | 769 | if ( item->isSelected() ) { |
770 | eventList.append(((KOListViewItem *)item)->data()); | 770 | eventList.append(((KOListViewItem *)item)->data()); |
771 | } | 771 | } |
772 | 772 | ||
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 | ||
782 | DateList KOListView::selectedDates() | 782 | DateList KOListView::selectedDates() |
783 | { | 783 | { |
784 | DateList eventList; | 784 | DateList eventList; |
785 | return eventList; | 785 | return eventList; |
786 | } | 786 | } |
787 | 787 | ||
788 | void KOListView::showDates(bool show) | 788 | void 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 | ||
807 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 807 | void 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 | ||
815 | void KOListView::showDates() | 815 | void KOListView::showDates() |
816 | { | 816 | { |
817 | showDates(true); | 817 | showDates(true); |
818 | } | 818 | } |
819 | 819 | ||
820 | void KOListView::hideDates() | 820 | void KOListView::hideDates() |
821 | { | 821 | { |
822 | showDates(false); | 822 | showDates(false); |
823 | } | 823 | } |
824 | void KOListView::resetFocus() | 824 | void KOListView::resetFocus() |
825 | { | 825 | { |
826 | mListView->setFocus(); | 826 | mListView->setFocus(); |
827 | } | 827 | } |
828 | void KOListView::updateView() | 828 | void 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 | } |
834 | void KOListView::updateConfig() | 834 | void 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 | } |
841 | void KOListView::setStartDate(const QDate &start) | 841 | void KOListView::setStartDate(const QDate &start) |
842 | { | 842 | { |
843 | mStartDate = start; | 843 | mStartDate = start; |
844 | } | 844 | } |
845 | 845 | ||
846 | void KOListView::showDates(const QDate &start, const QDate &end) | 846 | void 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 | ||
866 | void KOListView::addEvents(QPtrList<Event> eventList) | 866 | void 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 | ||
877 | void KOListView::addTodos(QPtrList<Todo> eventList) | 877 | void 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 | } |
887 | void KOListView::addJournals(QPtrList<Journal> eventList) | 887 | void 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 | ||
898 | void KOListView::addIncidence(Incidence *incidence) | 898 | void 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 | ||
912 | void KOListView::showEvents(QPtrList<Event> eventList) | 912 | void 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 | } |
921 | int KOListView::count() | 921 | int KOListView::count() |
922 | { | 922 | { |
923 | return mListView->childCount(); | 923 | return mListView->childCount(); |
924 | } | 924 | } |
925 | 925 | ||
926 | void KOListView::changeEventDisplay(Event *event, int action) | 926 | void 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 | ||
954 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 954 | KOListViewItem *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 | ||
964 | void KOListView::defaultItemAction(QListViewItem *i) | 964 | void 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 | ||
971 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 971 | void 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 | ||
987 | void KOListView::readSettings(KConfig *config, QString setting) | 987 | void 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 | ||
993 | void KOListView::writeSettings(KConfig *config, QString setting) | 993 | void 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 | ||
999 | void KOListView::processSelectionChange(QListViewItem *) | 999 | void 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 | ||
1012 | void KOListView::clearSelection() | 1012 | void KOListView::clearSelection() |
1013 | { | 1013 | { |
1014 | mListView->selectAll( false ); | 1014 | mListView->selectAll( false ); |
1015 | } | 1015 | } |
1016 | void KOListView::allSelection() | 1016 | void KOListView::allSelection() |
1017 | { | 1017 | { |
1018 | mListView->selectAll( true ); | 1018 | mListView->selectAll( true ); |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | void KOListView::clear() | 1021 | void KOListView::clear() |
1022 | { | 1022 | { |
1023 | mListView->clear(); | 1023 | mListView->clear(); |
1024 | mUidDict.clear(); | 1024 | mUidDict.clear(); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | Incidence* KOListView::currentItem() | 1027 | Incidence* 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 | } |
1033 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1033 | void 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 | } |
1043 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1043 | void 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 | } |
1156 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1156 | KOListViewListView::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 | } |
1165 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1167 | void 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 | |
1177 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1179 | void 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 | } |
1188 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1190 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1189 | { | 1191 | { |
1190 | KListView::contentsMouseReleaseEvent(e); | 1192 | KListView::contentsMouseReleaseEvent(e); |
1191 | } | 1193 | } |
1192 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1194 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1193 | { | 1195 | { |
1194 | KListView::contentsMouseMoveEvent(e); | 1196 | KListView::contentsMouseMoveEvent(e); |
1195 | } | 1197 | } |
1198 | #endif | ||
1199 | void 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 | } | ||
1206 | void 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 | } | ||
1223 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | ||
1224 | { | ||
1225 | mPopupTimer->stop(); | ||
1226 | KListView::contentsMouseReleaseEvent(e); | ||
1227 | } | ||
1228 | void 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 | ||
43 | using namespace KCal; | 43 | using 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" |
59 | class KOAlarmPrefs : public QDialog | 60 | class 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; |
116 | private slots: | 117 | private slots: |
117 | 118 | ||
118 | void pickAlarmSound() | 119 | void 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 | ||
146 | void pickAlarmProgram() | 147 | void 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 | ||
179 | typedef CustomListViewItem<Incidence *> KOListViewItem; | 180 | typedef 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 | */ |
185 | class ListItemVisitor : public Incidence::Visitor | 186 | class 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 | */ |
210 | class KOListView; | 211 | class KOListView; |
211 | 212 | ||
212 | class KOListViewListView : public KListView | 213 | class 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 | ||
229 | class KOListView : public KOEventView | 236 | class 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 | |||
@@ -1,2229 +1,2230 @@ | |||
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 | 4 | Copyright (C) 2000 Peter Putzer |
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 | 20 | ||
21 | #include <qdragobject.h> | 21 | #include <qdragobject.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qheader.h> | 23 | #include <qheader.h> |
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 |
51 | class KListView::Tooltip : public QToolTip | 51 | class KListView::Tooltip : public QToolTip |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); | 54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); |
55 | virtual ~Tooltip () {} | 55 | virtual ~Tooltip () {} |
56 | 56 | ||
57 | protected: | 57 | protected: |
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 | ||
65 | private: | 65 | private: |
66 | KListView* mParent; | 66 | KListView* mParent; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) | 69 | KListView::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 | ||
75 | void KListView::Tooltip::maybeTip (const QPoint&) | 75 | void KListView::Tooltip::maybeTip (const QPoint&) |
76 | { | 76 | { |
77 | // FIXME | 77 | // FIXME |
78 | } | 78 | } |
79 | // */ | 79 | // */ |
80 | 80 | ||
81 | class KListView::KListViewPrivate | 81 | class KListView::KListViewPrivate |
82 | { | 82 | { |
83 | public: | 83 | public: |
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 |
180 | KListViewLineEdit::KListViewLineEdit(KListView *parent) | 180 | KListViewLineEdit::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 | ||
188 | KListViewLineEdit::~KListViewLineEdit() | 188 | KListViewLineEdit::~KListViewLineEdit() |
189 | { | 189 | { |
190 | } | 190 | } |
191 | 191 | ||
192 | void KListViewLineEdit::load(QListViewItem *i, int c) | 192 | void 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 | ||
229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) | 229 | static 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 | ||
242 | static QListViewItem *prevItem (QListViewItem *pi) | 242 | static 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 | ||
255 | static QListViewItem *lastQChild (QListViewItem *pi) | 255 | static 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 |
270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) | 270 | void 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 | ||
323 | bool KListViewLineEdit::event (QEvent *pe) | 323 | bool 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 | ||
342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) | 342 | void 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 | ||
357 | void KListViewLineEdit::terminate() | 357 | void KListViewLineEdit::terminate() |
358 | { | 358 | { |
359 | terminate(true); | 359 | terminate(true); |
360 | } | 360 | } |
361 | 361 | ||
362 | void KListViewLineEdit::terminate(bool commit) | 362 | void 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 | ||
378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) | 378 | void 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 | ||
386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) | 386 | void 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". |
400 | void KListViewLineEdit::slotSelectionChanged() | 400 | void 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 | ||
408 | KListView::KListView( QWidget *parent, const char *name ) | 408 | KListView::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 | ||
467 | KListView::~KListView() | 468 | KListView::~KListView() |
468 | { | 469 | { |
469 | delete d; | 470 | delete d; |
470 | } | 471 | } |
471 | 472 | ||
472 | bool KListView::isExecuteArea( const QPoint& point ) | 473 | bool 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 | ||
480 | bool KListView::isExecuteArea( int x ) | 481 | bool 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 | ||
497 | void KListView::slotOnItem( QListViewItem *item ) | 498 | void 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 | ||
506 | void KListView::slotOnViewport() | 507 | void 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 | ||
515 | void KListView::slotSettingsChanged(int category) | 516 | void 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 | ||
589 | void KListView::slotAutoSelect() | 590 | void 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 | ||
668 | void KListView::slotHeaderChanged() | 669 | void 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 | ||
678 | void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) | 679 | void 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 | ||
705 | void KListView::focusInEvent( QFocusEvent *fe ) | 706 | void 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 | ||
721 | void KListView::focusOutEvent( QFocusEvent *fe ) | 722 | void 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 | ||
744 | void KListView::leaveEvent( QEvent *e ) | 745 | void 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 | ||
751 | bool KListView::event( QEvent *e ) | 752 | bool 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 | ||
762 | void KListView::contentsMousePressEvent( QMouseEvent *e ) | 763 | void 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 |
798 | d->startDragPos = e->pos(); | 799 | d->startDragPos = e->pos(); |
799 | 800 | ||
800 | if (at) | 801 | if (at) |
801 | { | 802 | { |
802 | d->validDrag = true; | 803 | d->validDrag = true; |
803 | d->pressedOnSelected = at->isSelected(); | 804 | d->pressedOnSelected = at->isSelected(); |
804 | } | 805 | } |
805 | } | 806 | } |
806 | 807 | ||
807 | QListView::contentsMousePressEvent( e ); | 808 | QListView::contentsMousePressEvent( e ); |
808 | } | 809 | } |
809 | 810 | ||
810 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) | 811 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) |
811 | { | 812 | { |
812 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { | 813 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { |
813 | QListView::contentsMouseMoveEvent (e); | 814 | QListView::contentsMouseMoveEvent (e); |
814 | return; | 815 | return; |
815 | } | 816 | } |
816 | 817 | ||
817 | QPoint vp = contentsToViewport(e->pos()); | 818 | QPoint vp = contentsToViewport(e->pos()); |
818 | QListViewItem *item = itemAt( vp ); | 819 | QListViewItem *item = itemAt( vp ); |
819 | 820 | ||
820 | //do we process cursor changes at all? | 821 | //do we process cursor changes at all? |
821 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) | 822 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) |
822 | { | 823 | { |
823 | //Cursor moved on a new item or in/out the execute area | 824 | //Cursor moved on a new item or in/out the execute area |
824 | if( (item != d->pCurrentItem) || | 825 | if( (item != d->pCurrentItem) || |
825 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) | 826 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) |
826 | { | 827 | { |
827 | d->cursorInExecuteArea = isExecuteArea(vp); | 828 | d->cursorInExecuteArea = isExecuteArea(vp); |
828 | //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); | 829 | //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); |
829 | /*US | 830 | /*US |
830 | if( d->cursorInExecuteArea ) //cursor moved in execute area | 831 | if( d->cursorInExecuteArea ) //cursor moved in execute area |
831 | viewport()->setCursor( KCursor::handCursor() ); | 832 | viewport()->setCursor( KCursor::handCursor() ); |
832 | else //cursor moved out of execute area | 833 | else //cursor moved out of execute area |
833 | viewport()->unsetCursor(); | 834 | viewport()->unsetCursor(); |
834 | */ | 835 | */ |
835 | } | 836 | } |
836 | } | 837 | } |
837 | 838 | ||
838 | bool dragOn = dragEnabled(); | 839 | bool dragOn = dragEnabled(); |
839 | QPoint newPos = e->pos(); | 840 | QPoint newPos = e->pos(); |
840 | if (dragOn && d->validDrag && | 841 | if (dragOn && d->validDrag && |
841 | (newPos.x() > d->startDragPos.x()+d->dragDelay || | 842 | (newPos.x() > d->startDragPos.x()+d->dragDelay || |
842 | newPos.x() < d->startDragPos.x()-d->dragDelay || | 843 | newPos.x() < d->startDragPos.x()-d->dragDelay || |
843 | newPos.y() > d->startDragPos.y()+d->dragDelay || | 844 | newPos.y() > d->startDragPos.y()+d->dragDelay || |
844 | newPos.y() < d->startDragPos.y()-d->dragDelay)) | 845 | newPos.y() < d->startDragPos.y()-d->dragDelay)) |
845 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) | 846 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) |
846 | { | 847 | { |
847 | QListView::contentsMouseReleaseEvent( 0 ); | 848 | QListView::contentsMouseReleaseEvent( 0 ); |
848 | startDrag(); | 849 | startDrag(); |
849 | d->startDragPos = QPoint(); | 850 | d->startDragPos = QPoint(); |
850 | d->validDrag = false; | 851 | d->validDrag = false; |
851 | } | 852 | } |
852 | } | 853 | } |
853 | 854 | ||
854 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) | 855 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) |
855 | { | 856 | { |
856 | if (e->button() == LeftButton) | 857 | if (e->button() == LeftButton) |
857 | { | 858 | { |
858 | // If the row was already selected, maybe we want to start an in-place editing | 859 | // If the row was already selected, maybe we want to start an in-place editing |
859 | if ( d->pressedOnSelected && itemsRenameable() ) | 860 | if ( d->pressedOnSelected && itemsRenameable() ) |
860 | { | 861 | { |
861 | QPoint p( contentsToViewport( e->pos() ) ); | 862 | QPoint p( contentsToViewport( e->pos() ) ); |
862 | QListViewItem *at = itemAt (p); | 863 | QListViewItem *at = itemAt (p); |
863 | if ( at ) | 864 | if ( at ) |
864 | { | 865 | { |
865 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 866 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
866 | bool rootDecoClicked = | 867 | bool rootDecoClicked = |
867 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 868 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
868 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 869 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
869 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 870 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
870 | 871 | ||
871 | if (!rootDecoClicked) | 872 | if (!rootDecoClicked) |
872 | { | 873 | { |
873 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); | 874 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); |
874 | if ( d->renameable.contains(col) ) | 875 | if ( d->renameable.contains(col) ) |
875 | rename(at, col); | 876 | rename(at, col); |
876 | } | 877 | } |
877 | } | 878 | } |
878 | } | 879 | } |
879 | 880 | ||
880 | d->pressedOnSelected = false; | 881 | d->pressedOnSelected = false; |
881 | d->validDrag = false; | 882 | d->validDrag = false; |
882 | d->startDragPos = QPoint(); | 883 | d->startDragPos = QPoint(); |
883 | } | 884 | } |
884 | QListView::contentsMouseReleaseEvent( e ); | 885 | QListView::contentsMouseReleaseEvent( e ); |
885 | } | 886 | } |
886 | 887 | ||
887 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) | 888 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) |
888 | { | 889 | { |
889 | //qDebug("KListView::contentsMouseDoubleClickEvent"); | 890 | //qDebug("KListView::contentsMouseDoubleClickEvent"); |
890 | // We don't want to call the parent method because it does setOpen, | 891 | // We don't want to call the parent method because it does setOpen, |
891 | // whereas we don't do it in single click mode... (David) | 892 | // whereas we don't do it in single click mode... (David) |
892 | //QListView::contentsMouseDoubleClickEvent( e ); | 893 | //QListView::contentsMouseDoubleClickEvent( e ); |
893 | 894 | ||
894 | QPoint vp = contentsToViewport(e->pos()); | 895 | QPoint vp = contentsToViewport(e->pos()); |
895 | QListViewItem *item = itemAt( vp ); | 896 | QListViewItem *item = itemAt( vp ); |
896 | emit QListView::doubleClicked( item ); // we do it now | 897 | emit QListView::doubleClicked( item ); // we do it now |
897 | 898 | ||
898 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; | 899 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; |
899 | 900 | ||
900 | if( item ) { | 901 | if( item ) { |
901 | //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); | 902 | //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); |
902 | 903 | ||
903 | emit doubleClicked( item, e->globalPos(), col ); | 904 | emit doubleClicked( item, e->globalPos(), col ); |
904 | 905 | ||
905 | if( (e->button() == LeftButton) && !d->bUseSingle ) { | 906 | if( (e->button() == LeftButton) && !d->bUseSingle ) { |
906 | //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); | 907 | //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); |
907 | 908 | ||
908 | emitExecute( e->button(), item, e->globalPos(), col); | 909 | emitExecute( e->button(), item, e->globalPos(), col); |
909 | } | 910 | } |
910 | } | 911 | } |
911 | } | 912 | } |
912 | 913 | ||
913 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) | 914 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) |
914 | { | 915 | { |
915 | //qDebug("KListView::slotMouseButtonClicked"); | 916 | //qDebug("KListView::slotMouseButtonClicked"); |
916 | 917 | ||
917 | if( (btn == LeftButton) && item ) { | 918 | if( (btn == LeftButton) && item ) { |
918 | //qDebug("KListView::slotMouseButtonClicked: emitExecute"); | 919 | //qDebug("KListView::slotMouseButtonClicked: emitExecute"); |
919 | 920 | ||
920 | emitExecute(btn, item, pos, c); | 921 | emitExecute(btn, item, pos, c); |
921 | } | 922 | } |
922 | } | 923 | } |
923 | 924 | ||
924 | void KListView::contentsDropEvent(QDropEvent* e) | 925 | void KListView::contentsDropEvent(QDropEvent* e) |
925 | { | 926 | { |
926 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 927 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
927 | /*US | 928 | /*US |
928 | cleanDropVisualizer(); | 929 | cleanDropVisualizer(); |
929 | cleanItemHighlighter(); | 930 | cleanItemHighlighter(); |
930 | d->dragExpand.stop(); | 931 | d->dragExpand.stop(); |
931 | 932 | ||
932 | if (acceptDrag (e)) | 933 | if (acceptDrag (e)) |
933 | { | 934 | { |
934 | e->acceptAction(); | 935 | e->acceptAction(); |
935 | QListViewItem *afterme; | 936 | QListViewItem *afterme; |
936 | QListViewItem *parent; | 937 | QListViewItem *parent; |
937 | findDrop(e->pos(), parent, afterme); | 938 | findDrop(e->pos(), parent, afterme); |
938 | 939 | ||
939 | if (e->source() == viewport() && itemsMovable()) | 940 | if (e->source() == viewport() && itemsMovable()) |
940 | movableDropEvent(parent, afterme); | 941 | movableDropEvent(parent, afterme); |
941 | else | 942 | else |
942 | { | 943 | { |
943 | 944 | ||
944 | emit dropped(e, afterme); | 945 | emit dropped(e, afterme); |
945 | emit dropped(this, e, afterme); | 946 | emit dropped(this, e, afterme); |
946 | emit dropped(e, parent, afterme); | 947 | emit dropped(e, parent, afterme); |
947 | emit dropped(this, e, parent, afterme); | 948 | emit dropped(this, e, parent, afterme); |
948 | 949 | ||
949 | } | 950 | } |
950 | } | 951 | } |
951 | */ | 952 | */ |
952 | 953 | ||
953 | } | 954 | } |
954 | 955 | ||
955 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) | 956 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) |
956 | { | 957 | { |
957 | QPtrList<QListViewItem> items, afterFirsts, afterNows; | 958 | QPtrList<QListViewItem> items, afterFirsts, afterNows; |
958 | QListViewItem *current=currentItem(); | 959 | QListViewItem *current=currentItem(); |
959 | bool hasMoved=false; | 960 | bool hasMoved=false; |
960 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) | 961 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) |
961 | { | 962 | { |
962 | iNext=i->itemBelow(); | 963 | iNext=i->itemBelow(); |
963 | if (!i->isSelected()) | 964 | if (!i->isSelected()) |
964 | continue; | 965 | continue; |
965 | 966 | ||
966 | // don't drop an item after itself, or else | 967 | // don't drop an item after itself, or else |
967 | // it moves to the top of the list | 968 | // it moves to the top of the list |
968 | if (i==afterme) | 969 | if (i==afterme) |
969 | continue; | 970 | continue; |
970 | 971 | ||
971 | i->setSelected(false); | 972 | i->setSelected(false); |
972 | 973 | ||
973 | QListViewItem *afterFirst = i->itemAbove(); | 974 | QListViewItem *afterFirst = i->itemAbove(); |
974 | 975 | ||
975 | if (!hasMoved) | 976 | if (!hasMoved) |
976 | { | 977 | { |
977 | emit aboutToMove(); | 978 | emit aboutToMove(); |
978 | hasMoved=true; | 979 | hasMoved=true; |
979 | } | 980 | } |
980 | 981 | ||
981 | moveItem(i, parent, afterme); | 982 | moveItem(i, parent, afterme); |
982 | 983 | ||
983 | // ###### This should include the new parent !!! -> KDE 3.0 | 984 | // ###### This should include the new parent !!! -> KDE 3.0 |
984 | // If you need this right now, have a look at keditbookmarks. | 985 | // If you need this right now, have a look at keditbookmarks. |
985 | emit moved(i, afterFirst, afterme); | 986 | emit moved(i, afterFirst, afterme); |
986 | 987 | ||
987 | items.append (i); | 988 | items.append (i); |
988 | afterFirsts.append (afterFirst); | 989 | afterFirsts.append (afterFirst); |
989 | afterNows.append (afterme); | 990 | afterNows.append (afterme); |
990 | 991 | ||
991 | afterme = i; | 992 | afterme = i; |
992 | } | 993 | } |
993 | clearSelection(); | 994 | clearSelection(); |
994 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) | 995 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) |
995 | i->setSelected(true); | 996 | i->setSelected(true); |
996 | if (current) | 997 | if (current) |
997 | setCurrentItem(current); | 998 | setCurrentItem(current); |
998 | 999 | ||
999 | emit moved(items,afterFirsts,afterNows); | 1000 | emit moved(items,afterFirsts,afterNows); |
1000 | 1001 | ||
1001 | if (firstChild()) | 1002 | if (firstChild()) |
1002 | emit moved(); | 1003 | emit moved(); |
1003 | } | 1004 | } |
1004 | 1005 | ||
1005 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) | 1006 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) |
1006 | { | 1007 | { |
1007 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 1008 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
1008 | /*US | 1009 | /*US |
1009 | if (acceptDrag(event)) | 1010 | if (acceptDrag(event)) |
1010 | { | 1011 | { |
1011 | event->acceptAction(); | 1012 | event->acceptAction(); |
1012 | //Clean up the view | 1013 | //Clean up the view |
1013 | 1014 | ||
1014 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); | 1015 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); |
1015 | QPoint vp = contentsToViewport( event->pos() ); | 1016 | QPoint vp = contentsToViewport( event->pos() ); |
1016 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; | 1017 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; |
1017 | 1018 | ||
1018 | if ( item != d->dragOverItem ) | 1019 | if ( item != d->dragOverItem ) |
1019 | { | 1020 | { |
1020 | d->dragExpand.stop(); | 1021 | d->dragExpand.stop(); |
1021 | d->dragOverItem = item; | 1022 | d->dragOverItem = item; |
1022 | d->dragOverPoint = vp; | 1023 | d->dragOverPoint = vp; |
1023 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) | 1024 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) |
1024 | d->dragExpand.start( QApplication::startDragTime(), true ); | 1025 | d->dragExpand.start( QApplication::startDragTime(), true ); |
1025 | } | 1026 | } |
1026 | if (dropVisualizer()) | 1027 | if (dropVisualizer()) |
1027 | { | 1028 | { |
1028 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); | 1029 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); |
1029 | if (tmpRect != d->mOldDropVisualizer) | 1030 | if (tmpRect != d->mOldDropVisualizer) |
1030 | { | 1031 | { |
1031 | cleanDropVisualizer(); | 1032 | cleanDropVisualizer(); |
1032 | d->mOldDropVisualizer=tmpRect; | 1033 | d->mOldDropVisualizer=tmpRect; |
1033 | viewport()->repaint(tmpRect); | 1034 | viewport()->repaint(tmpRect); |
1034 | } | 1035 | } |
1035 | } | 1036 | } |
1036 | if (dropHighlighter()) | 1037 | if (dropHighlighter()) |
1037 | { | 1038 | { |
1038 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); | 1039 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); |
1039 | if (tmpRect != d->mOldDropHighlighter) | 1040 | if (tmpRect != d->mOldDropHighlighter) |
1040 | { | 1041 | { |
1041 | cleanItemHighlighter(); | 1042 | cleanItemHighlighter(); |
1042 | d->mOldDropHighlighter=tmpRect; | 1043 | d->mOldDropHighlighter=tmpRect; |
1043 | viewport()->repaint(tmpRect); | 1044 | viewport()->repaint(tmpRect); |
1044 | } | 1045 | } |
1045 | } | 1046 | } |
1046 | } | 1047 | } |
1047 | else | 1048 | else |
1048 | event->ignore(); | 1049 | event->ignore(); |
1049 | */ | 1050 | */ |
1050 | } | 1051 | } |
1051 | 1052 | ||
1052 | void KListView::slotDragExpand() | 1053 | void KListView::slotDragExpand() |
1053 | { | 1054 | { |
1054 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) | 1055 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) |
1055 | d->dragOverItem->setOpen( true ); | 1056 | d->dragOverItem->setOpen( true ); |
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) | 1059 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) |
1059 | { | 1060 | { |
1060 | d->dragExpand.stop(); | 1061 | d->dragExpand.stop(); |
1061 | cleanDropVisualizer(); | 1062 | cleanDropVisualizer(); |
1062 | cleanItemHighlighter(); | 1063 | cleanItemHighlighter(); |
1063 | } | 1064 | } |
1064 | 1065 | ||
1065 | void KListView::cleanDropVisualizer() | 1066 | void KListView::cleanDropVisualizer() |
1066 | { | 1067 | { |
1067 | if (d->mOldDropVisualizer.isValid()) | 1068 | if (d->mOldDropVisualizer.isValid()) |
1068 | { | 1069 | { |
1069 | QRect rect=d->mOldDropVisualizer; | 1070 | QRect rect=d->mOldDropVisualizer; |
1070 | d->mOldDropVisualizer = QRect(); | 1071 | d->mOldDropVisualizer = QRect(); |
1071 | viewport()->repaint(rect, true); | 1072 | viewport()->repaint(rect, true); |
1072 | } | 1073 | } |
1073 | } | 1074 | } |
1074 | 1075 | ||
1075 | int KListView::depthToPixels( int depth ) | 1076 | int KListView::depthToPixels( int depth ) |
1076 | { | 1077 | { |
1077 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); | 1078 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); |
1078 | } | 1079 | } |
1079 | 1080 | ||
1080 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) | 1081 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) |
1081 | { | 1082 | { |
1082 | QPoint p (contentsToViewport(pos)); | 1083 | QPoint p (contentsToViewport(pos)); |
1083 | 1084 | ||
1084 | // Get the position to put it in | 1085 | // Get the position to put it in |
1085 | QListViewItem *atpos = itemAt(p); | 1086 | QListViewItem *atpos = itemAt(p); |
1086 | 1087 | ||
1087 | QListViewItem *above; | 1088 | QListViewItem *above; |
1088 | if (!atpos) // put it at the end | 1089 | if (!atpos) // put it at the end |
1089 | above = lastItem(); | 1090 | above = lastItem(); |
1090 | else | 1091 | else |
1091 | { | 1092 | { |
1092 | // Get the closest item before us ('atpos' or the one above, if any) | 1093 | // Get the closest item before us ('atpos' or the one above, if any) |
1093 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) | 1094 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) |
1094 | above = atpos->itemAbove(); | 1095 | above = atpos->itemAbove(); |
1095 | else | 1096 | else |
1096 | above = atpos; | 1097 | above = atpos; |
1097 | } | 1098 | } |
1098 | 1099 | ||
1099 | if (above) | 1100 | if (above) |
1100 | { | 1101 | { |
1101 | // Now, we know we want to go after "above". But as a child or as a sibling ? | 1102 | // Now, we know we want to go after "above". But as a child or as a sibling ? |
1102 | // We have to ask the "above" item if it accepts children. | 1103 | // We have to ask the "above" item if it accepts children. |
1103 | if (above->isExpandable()) | 1104 | if (above->isExpandable()) |
1104 | { | 1105 | { |
1105 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children | 1106 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children |
1106 | if (p.x() >= depthToPixels( above->depth() + 1 ) || | 1107 | if (p.x() >= depthToPixels( above->depth() + 1 ) || |
1107 | (above->isOpen() && above->childCount() > 0) ) | 1108 | (above->isOpen() && above->childCount() > 0) ) |
1108 | { | 1109 | { |
1109 | parent = above; | 1110 | parent = above; |
1110 | after = 0L; | 1111 | after = 0L; |
1111 | return; | 1112 | return; |
1112 | } | 1113 | } |
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | // Ok, there's one more level of complexity. We may want to become a new | 1116 | // Ok, there's one more level of complexity. We may want to become a new |
1116 | // sibling, but of an upper-level group, rather than the "above" item | 1117 | // sibling, but of an upper-level group, rather than the "above" item |
1117 | QListViewItem * betterAbove = above->parent(); | 1118 | QListViewItem * betterAbove = above->parent(); |
1118 | QListViewItem * last = above; | 1119 | QListViewItem * last = above; |
1119 | while ( betterAbove ) | 1120 | while ( betterAbove ) |
1120 | { | 1121 | { |
1121 | // We are allowed to become a sibling of "betterAbove" only if we are | 1122 | // We are allowed to become a sibling of "betterAbove" only if we are |
1122 | // after its last child | 1123 | // after its last child |
1123 | if ( last->nextSibling() == 0 ) | 1124 | if ( last->nextSibling() == 0 ) |
1124 | { | 1125 | { |
1125 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) | 1126 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) |
1126 | above = betterAbove; // store this one, but don't stop yet, there may be a better one | 1127 | above = betterAbove; // store this one, but don't stop yet, there may be a better one |
1127 | else | 1128 | else |
1128 | break; // not enough on the left, so stop | 1129 | break; // not enough on the left, so stop |
1129 | last = betterAbove; | 1130 | last = betterAbove; |
1130 | betterAbove = betterAbove->parent(); // up one level | 1131 | betterAbove = betterAbove->parent(); // up one level |
1131 | } else | 1132 | } else |
1132 | break; // we're among the child of betterAbove, not after the last one | 1133 | break; // we're among the child of betterAbove, not after the last one |
1133 | } | 1134 | } |
1134 | } | 1135 | } |
1135 | // set as sibling | 1136 | // set as sibling |
1136 | after = above; | 1137 | after = above; |
1137 | parent = after ? after->parent() : 0L ; | 1138 | parent = after ? after->parent() : 0L ; |
1138 | } | 1139 | } |
1139 | 1140 | ||
1140 | QListViewItem* KListView::lastChild () const | 1141 | QListViewItem* KListView::lastChild () const |
1141 | { | 1142 | { |
1142 | QListViewItem* lastchild = firstChild(); | 1143 | QListViewItem* lastchild = firstChild(); |
1143 | 1144 | ||
1144 | if (lastchild) | 1145 | if (lastchild) |
1145 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); | 1146 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); |
1146 | 1147 | ||
1147 | return lastchild; | 1148 | return lastchild; |
1148 | } | 1149 | } |
1149 | 1150 | ||
1150 | QListViewItem *KListView::lastItem() const | 1151 | QListViewItem *KListView::lastItem() const |
1151 | { | 1152 | { |
1152 | QListViewItem* last = lastChild(); | 1153 | QListViewItem* last = lastChild(); |
1153 | 1154 | ||
1154 | for (QListViewItemIterator it (last); it.current(); ++it) | 1155 | for (QListViewItemIterator it (last); it.current(); ++it) |
1155 | last = it.current(); | 1156 | last = it.current(); |
1156 | 1157 | ||
1157 | return last; | 1158 | return last; |
1158 | } | 1159 | } |
1159 | 1160 | ||
1160 | KLineEdit *KListView::renameLineEdit() const | 1161 | KLineEdit *KListView::renameLineEdit() const |
1161 | { | 1162 | { |
1162 | //US return d->editor; | 1163 | //US return d->editor; |
1163 | qDebug("KListView::renameLineEdit returns 0. Might crash"); | 1164 | qDebug("KListView::renameLineEdit returns 0. Might crash"); |
1164 | return 0; | 1165 | return 0; |
1165 | } | 1166 | } |
1166 | 1167 | ||
1167 | void KListView::startDrag() | 1168 | void KListView::startDrag() |
1168 | { | 1169 | { |
1169 | qDebug("KListView::startDrag drag&drop not supported yet."); | 1170 | qDebug("KListView::startDrag drag&drop not supported yet."); |
1170 | /*US | 1171 | /*US |
1171 | QDragObject *drag = dragObject(); | 1172 | QDragObject *drag = dragObject(); |
1172 | 1173 | ||
1173 | if (!drag) | 1174 | if (!drag) |
1174 | return; | 1175 | return; |
1175 | 1176 | ||
1176 | if (drag->drag() && drag->target() != viewport()) | 1177 | if (drag->drag() && drag->target() != viewport()) |
1177 | emit moved(); | 1178 | emit moved(); |
1178 | */ | 1179 | */ |
1179 | } | 1180 | } |
1180 | 1181 | ||
1181 | QDragObject *KListView::dragObject() | 1182 | QDragObject *KListView::dragObject() |
1182 | { | 1183 | { |
1183 | if (!currentItem()) | 1184 | if (!currentItem()) |
1184 | return 0; | 1185 | return 0; |
1185 | 1186 | ||
1186 | return new QStoredDrag("application/x-qlistviewitem", viewport()); | 1187 | return new QStoredDrag("application/x-qlistviewitem", viewport()); |
1187 | } | 1188 | } |
1188 | 1189 | ||
1189 | void KListView::setItemsMovable(bool b) | 1190 | void KListView::setItemsMovable(bool b) |
1190 | { | 1191 | { |
1191 | d->itemsMovable=b; | 1192 | d->itemsMovable=b; |
1192 | } | 1193 | } |
1193 | 1194 | ||
1194 | bool KListView::itemsMovable() const | 1195 | bool KListView::itemsMovable() const |
1195 | { | 1196 | { |
1196 | return d->itemsMovable; | 1197 | return d->itemsMovable; |
1197 | } | 1198 | } |
1198 | 1199 | ||
1199 | void KListView::setItemsRenameable(bool b) | 1200 | void KListView::setItemsRenameable(bool b) |
1200 | { | 1201 | { |
1201 | d->itemsRenameable=b; | 1202 | d->itemsRenameable=b; |
1202 | } | 1203 | } |
1203 | 1204 | ||
1204 | bool KListView::itemsRenameable() const | 1205 | bool KListView::itemsRenameable() const |
1205 | { | 1206 | { |
1206 | return d->itemsRenameable; | 1207 | return d->itemsRenameable; |
1207 | } | 1208 | } |
1208 | 1209 | ||
1209 | 1210 | ||
1210 | void KListView::setDragEnabled(bool b) | 1211 | void KListView::setDragEnabled(bool b) |
1211 | { | 1212 | { |
1212 | d->dragEnabled=b; | 1213 | d->dragEnabled=b; |
1213 | } | 1214 | } |
1214 | 1215 | ||
1215 | bool KListView::dragEnabled() const | 1216 | bool KListView::dragEnabled() const |
1216 | { | 1217 | { |
1217 | return d->dragEnabled; | 1218 | return d->dragEnabled; |
1218 | } | 1219 | } |
1219 | 1220 | ||
1220 | void KListView::setAutoOpen(bool b) | 1221 | void KListView::setAutoOpen(bool b) |
1221 | { | 1222 | { |
1222 | d->autoOpen=b; | 1223 | d->autoOpen=b; |
1223 | } | 1224 | } |
1224 | 1225 | ||
1225 | bool KListView::autoOpen() const | 1226 | bool KListView::autoOpen() const |
1226 | { | 1227 | { |
1227 | return d->autoOpen; | 1228 | return d->autoOpen; |
1228 | } | 1229 | } |
1229 | 1230 | ||
1230 | bool KListView::dropVisualizer() const | 1231 | bool KListView::dropVisualizer() const |
1231 | { | 1232 | { |
1232 | return d->dropVisualizer; | 1233 | return d->dropVisualizer; |
1233 | } | 1234 | } |
1234 | 1235 | ||
1235 | void KListView::setDropVisualizer(bool b) | 1236 | void KListView::setDropVisualizer(bool b) |
1236 | { | 1237 | { |
1237 | d->dropVisualizer=b; | 1238 | d->dropVisualizer=b; |
1238 | } | 1239 | } |
1239 | 1240 | ||
1240 | QPtrList<QListViewItem> KListView::selectedItems() const | 1241 | QPtrList<QListViewItem> KListView::selectedItems() const |
1241 | { | 1242 | { |
1242 | QPtrList<QListViewItem> list; | 1243 | QPtrList<QListViewItem> list; |
1243 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) | 1244 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) |
1244 | if (i->isSelected()) list.append(i); | 1245 | if (i->isSelected()) list.append(i); |
1245 | return list; | 1246 | return list; |
1246 | } | 1247 | } |
1247 | 1248 | ||
1248 | 1249 | ||
1249 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) | 1250 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) |
1250 | { | 1251 | { |
1251 | // sanity check - don't move a item into it's own child structure | 1252 | // sanity check - don't move a item into it's own child structure |
1252 | QListViewItem *i = parent; | 1253 | QListViewItem *i = parent; |
1253 | while(i) | 1254 | while(i) |
1254 | { | 1255 | { |
1255 | if(i == item) | 1256 | if(i == item) |
1256 | return; | 1257 | return; |
1257 | i = i->parent(); | 1258 | i = i->parent(); |
1258 | } | 1259 | } |
1259 | 1260 | ||
1260 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor | 1261 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor |
1261 | // in here, without ever deleting the item. | 1262 | // in here, without ever deleting the item. |
1262 | if (item->parent()) | 1263 | if (item->parent()) |
1263 | item->parent()->takeItem(item); | 1264 | item->parent()->takeItem(item); |
1264 | else | 1265 | else |
1265 | takeItem(item); | 1266 | takeItem(item); |
1266 | 1267 | ||
1267 | if (parent) | 1268 | if (parent) |
1268 | parent->insertItem(item); | 1269 | parent->insertItem(item); |
1269 | else | 1270 | else |
1270 | insertItem(item); | 1271 | insertItem(item); |
1271 | 1272 | ||
1272 | if (after) | 1273 | if (after) |
1273 | ;//item->moveToJustAfter(after); | 1274 | ;//item->moveToJustAfter(after); |
1274 | } | 1275 | } |
1275 | 1276 | ||
1276 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) | 1277 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) |
1277 | { | 1278 | { |
1278 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); | 1279 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); |
1279 | /*US | 1280 | /*US |
1280 | if (acceptDrag (event)) | 1281 | if (acceptDrag (event)) |
1281 | event->accept(); | 1282 | event->accept(); |
1282 | */ | 1283 | */ |
1283 | } | 1284 | } |
1284 | 1285 | ||
1285 | void KListView::setDropVisualizerWidth (int w) | 1286 | void KListView::setDropVisualizerWidth (int w) |
1286 | { | 1287 | { |
1287 | d->mDropVisualizerWidth = w > 0 ? w : 1; | 1288 | d->mDropVisualizerWidth = w > 0 ? w : 1; |
1288 | } | 1289 | } |
1289 | 1290 | ||
1290 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, | 1291 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, |
1291 | QListViewItem *after) | 1292 | QListViewItem *after) |
1292 | { | 1293 | { |
1293 | QRect insertmarker; | 1294 | QRect insertmarker; |
1294 | 1295 | ||
1295 | if (!after && !parent) | 1296 | if (!after && !parent) |
1296 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); | 1297 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); |
1297 | else | 1298 | else |
1298 | { | 1299 | { |
1299 | int level = 0; | 1300 | int level = 0; |
1300 | if (after) | 1301 | if (after) |
1301 | { | 1302 | { |
1302 | QListViewItem* it = 0L; | 1303 | QListViewItem* it = 0L; |
1303 | if (after->isOpen()) | 1304 | if (after->isOpen()) |
1304 | { | 1305 | { |
1305 | // Look for the last child (recursively) | 1306 | // Look for the last child (recursively) |
1306 | it = after->firstChild(); | 1307 | it = after->firstChild(); |
1307 | if (it) | 1308 | if (it) |
1308 | while (it->nextSibling() || it->firstChild()) | 1309 | while (it->nextSibling() || it->firstChild()) |
1309 | if ( it->nextSibling() ) | 1310 | if ( it->nextSibling() ) |
1310 | it = it->nextSibling(); | 1311 | it = it->nextSibling(); |
1311 | else | 1312 | else |
1312 | it = it->firstChild(); | 1313 | it = it->firstChild(); |
1313 | } | 1314 | } |
1314 | 1315 | ||
1315 | insertmarker = itemRect (it ? it : after); | 1316 | insertmarker = itemRect (it ? it : after); |
1316 | level = after->depth(); | 1317 | level = after->depth(); |
1317 | } | 1318 | } |
1318 | else if (parent) | 1319 | else if (parent) |
1319 | { | 1320 | { |
1320 | insertmarker = itemRect (parent); | 1321 | insertmarker = itemRect (parent); |
1321 | level = parent->depth() + 1; | 1322 | level = parent->depth() + 1; |
1322 | } | 1323 | } |
1323 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); | 1324 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); |
1324 | insertmarker.setRight (viewport()->width()); | 1325 | insertmarker.setRight (viewport()->width()); |
1325 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); | 1326 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); |
1326 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); | 1327 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); |
1327 | } | 1328 | } |
1328 | 1329 | ||
1329 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) | 1330 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) |
1330 | // Remove for KDE 3.0. | 1331 | // Remove for KDE 3.0. |
1331 | if (p) | 1332 | if (p) |
1332 | p->fillRect(insertmarker, Dense4Pattern); | 1333 | p->fillRect(insertmarker, Dense4Pattern); |
1333 | 1334 | ||
1334 | return insertmarker; | 1335 | return insertmarker; |
1335 | } | 1336 | } |
1336 | 1337 | ||
1337 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) | 1338 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) |
1338 | { | 1339 | { |
1339 | QRect r; | 1340 | QRect r; |
1340 | 1341 | ||
1341 | if (item) | 1342 | if (item) |
1342 | { | 1343 | { |
1343 | r = itemRect(item); | 1344 | r = itemRect(item); |
1344 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); | 1345 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); |
1345 | if (painter) { | 1346 | if (painter) { |
1346 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), | 1347 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), |
1347 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); | 1348 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); |
1348 | const QColor* pHighl = &(colorGroup().highlight()); | 1349 | const QColor* pHighl = &(colorGroup().highlight()); |
1349 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); | 1350 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); |
1350 | 1351 | ||
1351 | qDebug("KListView::drawItemHighlighter has to be verified"); | 1352 | qDebug("KListView::drawItemHighlighter has to be verified"); |
1352 | 1353 | ||
1353 | } | 1354 | } |
1354 | 1355 | ||
1355 | } | 1356 | } |
1356 | 1357 | ||
1357 | return r; | 1358 | return r; |
1358 | } | 1359 | } |
1359 | 1360 | ||
1360 | void KListView::cleanItemHighlighter () | 1361 | void KListView::cleanItemHighlighter () |
1361 | { | 1362 | { |
1362 | if (d->mOldDropHighlighter.isValid()) | 1363 | if (d->mOldDropHighlighter.isValid()) |
1363 | { | 1364 | { |
1364 | QRect rect=d->mOldDropHighlighter; | 1365 | QRect rect=d->mOldDropHighlighter; |
1365 | d->mOldDropHighlighter = QRect(); | 1366 | d->mOldDropHighlighter = QRect(); |
1366 | viewport()->repaint(rect, true); | 1367 | viewport()->repaint(rect, true); |
1367 | } | 1368 | } |
1368 | } | 1369 | } |
1369 | 1370 | ||
1370 | void KListView::rename(QListViewItem *item, int c) | 1371 | void KListView::rename(QListViewItem *item, int c) |
1371 | { | 1372 | { |
1372 | if (d->renameable.contains(c)) | 1373 | if (d->renameable.contains(c)) |
1373 | { | 1374 | { |
1374 | ensureItemVisible(item); | 1375 | ensureItemVisible(item); |
1375 | //US d->editor->load(item,c); | 1376 | //US d->editor->load(item,c); |
1376 | qDebug("KListView::rename has to be verified"); | 1377 | qDebug("KListView::rename has to be verified"); |
1377 | 1378 | ||
1378 | } | 1379 | } |
1379 | } | 1380 | } |
1380 | 1381 | ||
1381 | bool KListView::isRenameable (int col) const | 1382 | bool KListView::isRenameable (int col) const |
1382 | { | 1383 | { |
1383 | return d->renameable.contains(col); | 1384 | return d->renameable.contains(col); |
1384 | } | 1385 | } |
1385 | 1386 | ||
1386 | void KListView::setRenameable (int col, bool yesno) | 1387 | void KListView::setRenameable (int col, bool yesno) |
1387 | { | 1388 | { |
1388 | if (col>=header()->count()) return; | 1389 | if (col>=header()->count()) return; |
1389 | 1390 | ||
1390 | d->renameable.remove(col); | 1391 | d->renameable.remove(col); |
1391 | if (yesno && d->renameable.find(col)==d->renameable.end()) | 1392 | if (yesno && d->renameable.find(col)==d->renameable.end()) |
1392 | d->renameable+=col; | 1393 | d->renameable+=col; |
1393 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) | 1394 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) |
1394 | d->renameable.remove(col); | 1395 | d->renameable.remove(col); |
1395 | } | 1396 | } |
1396 | 1397 | ||
1397 | void KListView::doneEditing(QListViewItem *item, int row) | 1398 | void KListView::doneEditing(QListViewItem *item, int row) |
1398 | { | 1399 | { |
1399 | emit itemRenamed(item, item->text(row), row); | 1400 | emit itemRenamed(item, item->text(row), row); |
1400 | emit itemRenamed(item); | 1401 | emit itemRenamed(item); |
1401 | } | 1402 | } |
1402 | 1403 | ||
1403 | bool KListView::acceptDrag(QDropEvent* e) const | 1404 | bool KListView::acceptDrag(QDropEvent* e) const |
1404 | { | 1405 | { |
1405 | qDebug("KListView::acceptDrag drag&drop not supported yet"); | 1406 | qDebug("KListView::acceptDrag drag&drop not supported yet"); |
1406 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); | 1407 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); |
1407 | return false; | 1408 | return false; |
1408 | } | 1409 | } |
1409 | 1410 | ||
1410 | void KListView::setCreateChildren(bool b) | 1411 | void KListView::setCreateChildren(bool b) |
1411 | { | 1412 | { |
1412 | d->createChildren=b; | 1413 | d->createChildren=b; |
1413 | } | 1414 | } |
1414 | 1415 | ||
1415 | bool KListView::createChildren() const | 1416 | bool KListView::createChildren() const |
1416 | { | 1417 | { |
1417 | return d->createChildren; | 1418 | return d->createChildren; |
1418 | } | 1419 | } |
1419 | 1420 | ||
1420 | 1421 | ||
1421 | int KListView::tooltipColumn() const | 1422 | int KListView::tooltipColumn() const |
1422 | { | 1423 | { |
1423 | return d->tooltipColumn; | 1424 | return d->tooltipColumn; |
1424 | } | 1425 | } |
1425 | 1426 | ||
1426 | void KListView::setTooltipColumn(int column) | 1427 | void KListView::setTooltipColumn(int column) |
1427 | { | 1428 | { |
1428 | d->tooltipColumn=column; | 1429 | d->tooltipColumn=column; |
1429 | } | 1430 | } |
1430 | 1431 | ||
1431 | void KListView::setDropHighlighter(bool b) | 1432 | void KListView::setDropHighlighter(bool b) |
1432 | { | 1433 | { |
1433 | d->dropHighlighter=b; | 1434 | d->dropHighlighter=b; |
1434 | } | 1435 | } |
1435 | 1436 | ||
1436 | bool KListView::dropHighlighter() const | 1437 | bool KListView::dropHighlighter() const |
1437 | { | 1438 | { |
1438 | return d->dropHighlighter; | 1439 | return d->dropHighlighter; |
1439 | } | 1440 | } |
1440 | 1441 | ||
1441 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const | 1442 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const |
1442 | { | 1443 | { |
1443 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); | 1444 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); |
1444 | } | 1445 | } |
1445 | 1446 | ||
1446 | QString KListView::tooltip(QListViewItem *item, int column) const | 1447 | QString KListView::tooltip(QListViewItem *item, int column) const |
1447 | { | 1448 | { |
1448 | return item->text(column); | 1449 | return item->text(column); |
1449 | } | 1450 | } |
1450 | 1451 | ||
1451 | void KListView::setTabOrderedRenaming(bool b) | 1452 | void KListView::setTabOrderedRenaming(bool b) |
1452 | { | 1453 | { |
1453 | d->tabRename = b; | 1454 | d->tabRename = b; |
1454 | } | 1455 | } |
1455 | 1456 | ||
1456 | bool KListView::tabOrderedRenaming() const | 1457 | bool KListView::tabOrderedRenaming() const |
1457 | { | 1458 | { |
1458 | return d->tabRename; | 1459 | return d->tabRename; |
1459 | } | 1460 | } |
1460 | 1461 | ||
1461 | void KListView::keyPressEvent (QKeyEvent* e) | 1462 | void KListView::keyPressEvent (QKeyEvent* e) |
1462 | { | 1463 | { |
1463 | //don't we need a contextMenuModifier too ? (aleXXX) | 1464 | //don't we need a contextMenuModifier too ? (aleXXX) |
1464 | if (e->key() == d->contextMenuKey) | 1465 | if (e->key() == d->contextMenuKey) |
1465 | { | 1466 | { |
1466 | emit menuShortCutPressed (this, currentItem()); | 1467 | emit menuShortCutPressed (this, currentItem()); |
1467 | return; | 1468 | return; |
1468 | } | 1469 | } |
1469 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) | 1470 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) |
1470 | { | 1471 | { |
1471 | emit signalDelete ( ); | 1472 | emit signalDelete ( ); |
1472 | return; | 1473 | return; |
1473 | } | 1474 | } |
1474 | 1475 | ||
1475 | if (d->selectionMode != FileManager) | 1476 | if (d->selectionMode != FileManager) |
1476 | QListView::keyPressEvent (e); | 1477 | QListView::keyPressEvent (e); |
1477 | else | 1478 | else |
1478 | fileManagerKeyPressEvent (e); | 1479 | fileManagerKeyPressEvent (e); |
1479 | } | 1480 | } |
1480 | 1481 | ||
1481 | void KListView::activateAutomaticSelection() | 1482 | void KListView::activateAutomaticSelection() |
1482 | { | 1483 | { |
1483 | d->selectedBySimpleMove=true; | 1484 | d->selectedBySimpleMove=true; |
1484 | d->selectedUsingMouse=false; | 1485 | d->selectedUsingMouse=false; |
1485 | if (currentItem()!=0) | 1486 | if (currentItem()!=0) |
1486 | { | 1487 | { |
1487 | selectAll(false); | 1488 | selectAll(false); |
1488 | currentItem()->setSelected(true); | 1489 | currentItem()->setSelected(true); |
1489 | currentItem()->repaint(); | 1490 | currentItem()->repaint(); |
1490 | emit selectionChanged(); | 1491 | emit selectionChanged(); |
1491 | }; | 1492 | }; |
1492 | } | 1493 | } |
1493 | 1494 | ||
1494 | void KListView::deactivateAutomaticSelection() | 1495 | void KListView::deactivateAutomaticSelection() |
1495 | { | 1496 | { |
1496 | d->selectedBySimpleMove=false; | 1497 | d->selectedBySimpleMove=false; |
1497 | } | 1498 | } |
1498 | 1499 | ||
1499 | bool KListView::automaticSelection() const | 1500 | bool KListView::automaticSelection() const |
1500 | { | 1501 | { |
1501 | return d->selectedBySimpleMove; | 1502 | return d->selectedBySimpleMove; |
1502 | } | 1503 | } |
1503 | 1504 | ||
1504 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) | 1505 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) |
1505 | { | 1506 | { |
1506 | //don't care whether it's on the keypad or not | 1507 | //don't care whether it's on the keypad or not |
1507 | int e_state=(e->state() & ~Keypad); | 1508 | int e_state=(e->state() & ~Keypad); |
1508 | 1509 | ||
1509 | int oldSelectionDirection(d->selectionDirection); | 1510 | int oldSelectionDirection(d->selectionDirection); |
1510 | 1511 | ||
1511 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1512 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1512 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) | 1513 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) |
1513 | { | 1514 | { |
1514 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) | 1515 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) |
1515 | selectAll(FALSE); | 1516 | selectAll(FALSE); |
1516 | d->selectionDirection=0; | 1517 | d->selectionDirection=0; |
1517 | d->wasShiftEvent = (e_state == ShiftButton); | 1518 | d->wasShiftEvent = (e_state == ShiftButton); |
1518 | }; | 1519 | }; |
1519 | 1520 | ||
1520 | //d->wasShiftEvent = (e_state == ShiftButton); | 1521 | //d->wasShiftEvent = (e_state == ShiftButton); |
1521 | 1522 | ||
1522 | 1523 | ||
1523 | QListViewItem* item = currentItem(); | 1524 | QListViewItem* item = currentItem(); |
1524 | if (item==0) return; | 1525 | if (item==0) return; |
1525 | 1526 | ||
1526 | QListViewItem* repaintItem1 = item; | 1527 | QListViewItem* repaintItem1 = item; |
1527 | QListViewItem* repaintItem2 = 0L; | 1528 | QListViewItem* repaintItem2 = 0L; |
1528 | QListViewItem* visItem = 0L; | 1529 | QListViewItem* visItem = 0L; |
1529 | 1530 | ||
1530 | QListViewItem* nextItem = 0L; | 1531 | QListViewItem* nextItem = 0L; |
1531 | int items = 0; | 1532 | int items = 0; |
1532 | 1533 | ||
1533 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); | 1534 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); |
1534 | int selectedItems(0); | 1535 | int selectedItems(0); |
1535 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) | 1536 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) |
1536 | if (tmpItem->isSelected()) selectedItems++; | 1537 | if (tmpItem->isSelected()) selectedItems++; |
1537 | 1538 | ||
1538 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) | 1539 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) |
1539 | && (e_state==NoButton) | 1540 | && (e_state==NoButton) |
1540 | && ((e->key()==Key_Down) | 1541 | && ((e->key()==Key_Down) |
1541 | || (e->key()==Key_Up) | 1542 | || (e->key()==Key_Up) |
1542 | || (e->key()==Key_Next) | 1543 | || (e->key()==Key_Next) |
1543 | || (e->key()==Key_Prior) | 1544 | || (e->key()==Key_Prior) |
1544 | || (e->key()==Key_Home) | 1545 | || (e->key()==Key_Home) |
1545 | || (e->key()==Key_End))) | 1546 | || (e->key()==Key_End))) |
1546 | { | 1547 | { |
1547 | d->selectedBySimpleMove=true; | 1548 | d->selectedBySimpleMove=true; |
1548 | d->selectedUsingMouse=false; | 1549 | d->selectedUsingMouse=false; |
1549 | } | 1550 | } |
1550 | else if (selectedItems>1) | 1551 | else if (selectedItems>1) |
1551 | d->selectedBySimpleMove=false; | 1552 | d->selectedBySimpleMove=false; |
1552 | 1553 | ||
1553 | bool emitSelectionChanged(false); | 1554 | bool emitSelectionChanged(false); |
1554 | 1555 | ||
1555 | switch (e->key()) | 1556 | switch (e->key()) |
1556 | { | 1557 | { |
1557 | case Key_Escape: | 1558 | case Key_Escape: |
1558 | selectAll(FALSE); | 1559 | selectAll(FALSE); |
1559 | emitSelectionChanged=TRUE; | 1560 | emitSelectionChanged=TRUE; |
1560 | break; | 1561 | break; |
1561 | 1562 | ||
1562 | case Key_Space: | 1563 | case Key_Space: |
1563 | //toggle selection of current item | 1564 | //toggle selection of current item |
1564 | if (d->selectedBySimpleMove) | 1565 | if (d->selectedBySimpleMove) |
1565 | d->selectedBySimpleMove=false; | 1566 | d->selectedBySimpleMove=false; |
1566 | item->setSelected(!item->isSelected()); | 1567 | item->setSelected(!item->isSelected()); |
1567 | emitSelectionChanged=TRUE; | 1568 | emitSelectionChanged=TRUE; |
1568 | break; | 1569 | break; |
1569 | 1570 | ||
1570 | case Key_Insert: | 1571 | case Key_Insert: |
1571 | //toggle selection of current item and move to the next item | 1572 | //toggle selection of current item and move to the next item |
1572 | if (d->selectedBySimpleMove) | 1573 | if (d->selectedBySimpleMove) |
1573 | { | 1574 | { |
1574 | d->selectedBySimpleMove=false; | 1575 | d->selectedBySimpleMove=false; |
1575 | if (!item->isSelected()) item->setSelected(TRUE); | 1576 | if (!item->isSelected()) item->setSelected(TRUE); |
1576 | } | 1577 | } |
1577 | else | 1578 | else |
1578 | { | 1579 | { |
1579 | item->setSelected(!item->isSelected()); | 1580 | item->setSelected(!item->isSelected()); |
1580 | }; | 1581 | }; |
1581 | 1582 | ||
1582 | nextItem=item->itemBelow(); | 1583 | nextItem=item->itemBelow(); |
1583 | 1584 | ||
1584 | if (nextItem!=0) | 1585 | if (nextItem!=0) |
1585 | { | 1586 | { |
1586 | repaintItem2=nextItem; | 1587 | repaintItem2=nextItem; |
1587 | visItem=nextItem; | 1588 | visItem=nextItem; |
1588 | setCurrentItem(nextItem); | 1589 | setCurrentItem(nextItem); |
1589 | }; | 1590 | }; |
1590 | d->selectionDirection=1; | 1591 | d->selectionDirection=1; |
1591 | emitSelectionChanged=TRUE; | 1592 | emitSelectionChanged=TRUE; |
1592 | break; | 1593 | break; |
1593 | 1594 | ||
1594 | case Key_Down: | 1595 | case Key_Down: |
1595 | nextItem=item->itemBelow(); | 1596 | nextItem=item->itemBelow(); |
1596 | //toggle selection of current item and move to the next item | 1597 | //toggle selection of current item and move to the next item |
1597 | if (shiftOrCtrl) | 1598 | if (shiftOrCtrl) |
1598 | { | 1599 | { |
1599 | d->selectionDirection=1; | 1600 | d->selectionDirection=1; |
1600 | if (d->selectedBySimpleMove) | 1601 | if (d->selectedBySimpleMove) |
1601 | d->selectedBySimpleMove=false; | 1602 | d->selectedBySimpleMove=false; |
1602 | else | 1603 | else |
1603 | { | 1604 | { |
1604 | if (oldSelectionDirection!=-1) | 1605 | if (oldSelectionDirection!=-1) |
1605 | { | 1606 | { |
1606 | item->setSelected(!item->isSelected()); | 1607 | item->setSelected(!item->isSelected()); |
1607 | emitSelectionChanged=TRUE; | 1608 | emitSelectionChanged=TRUE; |
1608 | }; | 1609 | }; |
1609 | }; | 1610 | }; |
1610 | } | 1611 | } |
1611 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1612 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1612 | { | 1613 | { |
1613 | item->setSelected(false); | 1614 | item->setSelected(false); |
1614 | emitSelectionChanged=TRUE; | 1615 | emitSelectionChanged=TRUE; |
1615 | }; | 1616 | }; |
1616 | 1617 | ||
1617 | if (nextItem!=0) | 1618 | if (nextItem!=0) |
1618 | { | 1619 | { |
1619 | if (d->selectedBySimpleMove) | 1620 | if (d->selectedBySimpleMove) |
1620 | nextItem->setSelected(true); | 1621 | nextItem->setSelected(true); |
1621 | repaintItem2=nextItem; | 1622 | repaintItem2=nextItem; |
1622 | visItem=nextItem; | 1623 | visItem=nextItem; |
1623 | setCurrentItem(nextItem); | 1624 | setCurrentItem(nextItem); |
1624 | }; | 1625 | }; |
1625 | break; | 1626 | break; |
1626 | 1627 | ||
1627 | case Key_Up: | 1628 | case Key_Up: |
1628 | nextItem=item->itemAbove(); | 1629 | nextItem=item->itemAbove(); |
1629 | d->selectionDirection=-1; | 1630 | d->selectionDirection=-1; |
1630 | //move to the prev. item and toggle selection of this one | 1631 | //move to the prev. item and toggle selection of this one |
1631 | // => No, can't select the last item, with this. For symmetry, let's | 1632 | // => No, can't select the last item, with this. For symmetry, let's |
1632 | // toggle selection and THEN move up, just like we do in down (David) | 1633 | // toggle selection and THEN move up, just like we do in down (David) |
1633 | if (shiftOrCtrl) | 1634 | if (shiftOrCtrl) |
1634 | { | 1635 | { |
1635 | if (d->selectedBySimpleMove) | 1636 | if (d->selectedBySimpleMove) |
1636 | d->selectedBySimpleMove=false; | 1637 | d->selectedBySimpleMove=false; |
1637 | else | 1638 | else |
1638 | { | 1639 | { |
1639 | if (oldSelectionDirection!=1) | 1640 | if (oldSelectionDirection!=1) |
1640 | { | 1641 | { |
1641 | item->setSelected(!item->isSelected()); | 1642 | item->setSelected(!item->isSelected()); |
1642 | emitSelectionChanged=TRUE; | 1643 | emitSelectionChanged=TRUE; |
1643 | }; | 1644 | }; |
1644 | } | 1645 | } |
1645 | } | 1646 | } |
1646 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1647 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1647 | { | 1648 | { |
1648 | item->setSelected(false); | 1649 | item->setSelected(false); |
1649 | emitSelectionChanged=TRUE; | 1650 | emitSelectionChanged=TRUE; |
1650 | }; | 1651 | }; |
1651 | 1652 | ||
1652 | if (nextItem!=0) | 1653 | if (nextItem!=0) |
1653 | { | 1654 | { |
1654 | if (d->selectedBySimpleMove) | 1655 | if (d->selectedBySimpleMove) |
1655 | nextItem->setSelected(true); | 1656 | nextItem->setSelected(true); |
1656 | repaintItem2=nextItem; | 1657 | repaintItem2=nextItem; |
1657 | visItem=nextItem; | 1658 | visItem=nextItem; |
1658 | setCurrentItem(nextItem); | 1659 | setCurrentItem(nextItem); |
1659 | }; | 1660 | }; |
1660 | break; | 1661 | break; |
1661 | 1662 | ||
1662 | case Key_End: | 1663 | case Key_End: |
1663 | //move to the last item and toggle selection of all items inbetween | 1664 | //move to the last item and toggle selection of all items inbetween |
1664 | nextItem=item; | 1665 | nextItem=item; |
1665 | if (d->selectedBySimpleMove) | 1666 | if (d->selectedBySimpleMove) |
1666 | item->setSelected(false); | 1667 | item->setSelected(false); |
1667 | if (shiftOrCtrl) | 1668 | if (shiftOrCtrl) |
1668 | d->selectedBySimpleMove=false; | 1669 | d->selectedBySimpleMove=false; |
1669 | 1670 | ||
1670 | while(nextItem!=0) | 1671 | while(nextItem!=0) |
1671 | { | 1672 | { |
1672 | if (shiftOrCtrl) | 1673 | if (shiftOrCtrl) |
1673 | nextItem->setSelected(!nextItem->isSelected()); | 1674 | nextItem->setSelected(!nextItem->isSelected()); |
1674 | if (nextItem->itemBelow()==0) | 1675 | if (nextItem->itemBelow()==0) |
1675 | { | 1676 | { |
1676 | if (d->selectedBySimpleMove) | 1677 | if (d->selectedBySimpleMove) |
1677 | nextItem->setSelected(true); | 1678 | nextItem->setSelected(true); |
1678 | repaintItem2=nextItem; | 1679 | repaintItem2=nextItem; |
1679 | visItem=nextItem; | 1680 | visItem=nextItem; |
1680 | setCurrentItem(nextItem); | 1681 | setCurrentItem(nextItem); |
1681 | } | 1682 | } |
1682 | nextItem=nextItem->itemBelow(); | 1683 | nextItem=nextItem->itemBelow(); |
1683 | } | 1684 | } |
1684 | emitSelectionChanged=TRUE; | 1685 | emitSelectionChanged=TRUE; |
1685 | break; | 1686 | break; |
1686 | 1687 | ||
1687 | case Key_Home: | 1688 | case Key_Home: |
1688 | // move to the first item and toggle selection of all items inbetween | 1689 | // move to the first item and toggle selection of all items inbetween |
1689 | nextItem = firstChild(); | 1690 | nextItem = firstChild(); |
1690 | visItem = nextItem; | 1691 | visItem = nextItem; |
1691 | repaintItem2 = visItem; | 1692 | repaintItem2 = visItem; |
1692 | if (d->selectedBySimpleMove) | 1693 | if (d->selectedBySimpleMove) |
1693 | item->setSelected(false); | 1694 | item->setSelected(false); |
1694 | if (shiftOrCtrl) | 1695 | if (shiftOrCtrl) |
1695 | { | 1696 | { |
1696 | d->selectedBySimpleMove=false; | 1697 | d->selectedBySimpleMove=false; |
1697 | 1698 | ||
1698 | while ( nextItem != item ) | 1699 | while ( nextItem != item ) |
1699 | { | 1700 | { |
1700 | nextItem->setSelected( !nextItem->isSelected() ); | 1701 | nextItem->setSelected( !nextItem->isSelected() ); |
1701 | nextItem = nextItem->itemBelow(); | 1702 | nextItem = nextItem->itemBelow(); |
1702 | } | 1703 | } |
1703 | item->setSelected( !item->isSelected() ); | 1704 | item->setSelected( !item->isSelected() ); |
1704 | } | 1705 | } |
1705 | setCurrentItem( firstChild() ); | 1706 | setCurrentItem( firstChild() ); |
1706 | emitSelectionChanged=TRUE; | 1707 | emitSelectionChanged=TRUE; |
1707 | break; | 1708 | break; |
1708 | 1709 | ||
1709 | case Key_Next: | 1710 | case Key_Next: |
1710 | items=visibleHeight()/item->height(); | 1711 | items=visibleHeight()/item->height(); |
1711 | nextItem=item; | 1712 | nextItem=item; |
1712 | if (d->selectedBySimpleMove) | 1713 | if (d->selectedBySimpleMove) |
1713 | item->setSelected(false); | 1714 | item->setSelected(false); |
1714 | if (shiftOrCtrl) | 1715 | if (shiftOrCtrl) |
1715 | { | 1716 | { |
1716 | d->selectedBySimpleMove=false; | 1717 | d->selectedBySimpleMove=false; |
1717 | d->selectionDirection=1; | 1718 | d->selectionDirection=1; |
1718 | }; | 1719 | }; |
1719 | 1720 | ||
1720 | for (int i=0; i<items; i++) | 1721 | for (int i=0; i<items; i++) |
1721 | { | 1722 | { |
1722 | if (shiftOrCtrl) | 1723 | if (shiftOrCtrl) |
1723 | nextItem->setSelected(!nextItem->isSelected()); | 1724 | nextItem->setSelected(!nextItem->isSelected()); |
1724 | //the end | 1725 | //the end |
1725 | if ((i==items-1) || (nextItem->itemBelow()==0)) | 1726 | if ((i==items-1) || (nextItem->itemBelow()==0)) |
1726 | 1727 | ||
1727 | { | 1728 | { |
1728 | if (shiftOrCtrl) | 1729 | if (shiftOrCtrl) |
1729 | nextItem->setSelected(!nextItem->isSelected()); | 1730 | nextItem->setSelected(!nextItem->isSelected()); |
1730 | if (d->selectedBySimpleMove) | 1731 | if (d->selectedBySimpleMove) |
1731 | nextItem->setSelected(true); | 1732 | nextItem->setSelected(true); |
1732 | ensureItemVisible(nextItem); | 1733 | ensureItemVisible(nextItem); |
1733 | setCurrentItem(nextItem); | 1734 | setCurrentItem(nextItem); |
1734 | update(); | 1735 | update(); |
1735 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1736 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1736 | { | 1737 | { |
1737 | emit selectionChanged(); | 1738 | emit selectionChanged(); |
1738 | } | 1739 | } |
1739 | return; | 1740 | return; |
1740 | } | 1741 | } |
1741 | nextItem=nextItem->itemBelow(); | 1742 | nextItem=nextItem->itemBelow(); |
1742 | } | 1743 | } |
1743 | break; | 1744 | break; |
1744 | 1745 | ||
1745 | case Key_Prior: | 1746 | case Key_Prior: |
1746 | items=visibleHeight()/item->height(); | 1747 | items=visibleHeight()/item->height(); |
1747 | nextItem=item; | 1748 | nextItem=item; |
1748 | if (d->selectedBySimpleMove) | 1749 | if (d->selectedBySimpleMove) |
1749 | item->setSelected(false); | 1750 | item->setSelected(false); |
1750 | if (shiftOrCtrl) | 1751 | if (shiftOrCtrl) |
1751 | { | 1752 | { |
1752 | d->selectionDirection=-1; | 1753 | d->selectionDirection=-1; |
1753 | d->selectedBySimpleMove=false; | 1754 | d->selectedBySimpleMove=false; |
1754 | }; | 1755 | }; |
1755 | 1756 | ||
1756 | for (int i=0; i<items; i++) | 1757 | for (int i=0; i<items; i++) |
1757 | { | 1758 | { |
1758 | if ((nextItem!=item) &&(shiftOrCtrl)) | 1759 | if ((nextItem!=item) &&(shiftOrCtrl)) |
1759 | nextItem->setSelected(!nextItem->isSelected()); | 1760 | nextItem->setSelected(!nextItem->isSelected()); |
1760 | //the end | 1761 | //the end |
1761 | if ((i==items-1) || (nextItem->itemAbove()==0)) | 1762 | if ((i==items-1) || (nextItem->itemAbove()==0)) |
1762 | 1763 | ||
1763 | { | 1764 | { |
1764 | if (d->selectedBySimpleMove) | 1765 | if (d->selectedBySimpleMove) |
1765 | nextItem->setSelected(true); | 1766 | nextItem->setSelected(true); |
1766 | ensureItemVisible(nextItem); | 1767 | ensureItemVisible(nextItem); |
1767 | setCurrentItem(nextItem); | 1768 | setCurrentItem(nextItem); |
1768 | update(); | 1769 | update(); |
1769 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1770 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1770 | { | 1771 | { |
1771 | emit selectionChanged(); | 1772 | emit selectionChanged(); |
1772 | } | 1773 | } |
1773 | return; | 1774 | return; |
1774 | } | 1775 | } |
1775 | nextItem=nextItem->itemAbove(); | 1776 | nextItem=nextItem->itemAbove(); |
1776 | } | 1777 | } |
1777 | break; | 1778 | break; |
1778 | 1779 | ||
1779 | case Key_Minus: | 1780 | case Key_Minus: |
1780 | if ( item->isOpen() ) | 1781 | if ( item->isOpen() ) |
1781 | setOpen( item, FALSE ); | 1782 | setOpen( item, FALSE ); |
1782 | break; | 1783 | break; |
1783 | case Key_Plus: | 1784 | case Key_Plus: |
1784 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) | 1785 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) |
1785 | setOpen( item, TRUE ); | 1786 | setOpen( item, TRUE ); |
1786 | break; | 1787 | break; |
1787 | default: | 1788 | default: |
1788 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1789 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1789 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); | 1790 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); |
1790 | 1791 | ||
1791 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); | 1792 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); |
1792 | if (realKey && selectCurrentItem) | 1793 | if (realKey && selectCurrentItem) |
1793 | item->setSelected(false); | 1794 | item->setSelected(false); |
1794 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) | 1795 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) |
1795 | QListView::SelectionMode oldSelectionMode = selectionMode(); | 1796 | QListView::SelectionMode oldSelectionMode = selectionMode(); |
1796 | setSelectionMode (QListView::Multi); | 1797 | setSelectionMode (QListView::Multi); |
1797 | QListView::keyPressEvent (e); | 1798 | QListView::keyPressEvent (e); |
1798 | setSelectionMode (oldSelectionMode); | 1799 | setSelectionMode (oldSelectionMode); |
1799 | if (realKey && selectCurrentItem) | 1800 | if (realKey && selectCurrentItem) |
1800 | { | 1801 | { |
1801 | currentItem()->setSelected(true); | 1802 | currentItem()->setSelected(true); |
1802 | emitSelectionChanged=TRUE; | 1803 | emitSelectionChanged=TRUE; |
1803 | } | 1804 | } |
1804 | repaintItem2=currentItem(); | 1805 | repaintItem2=currentItem(); |
1805 | if (realKey) | 1806 | if (realKey) |
1806 | visItem=currentItem(); | 1807 | visItem=currentItem(); |
1807 | break; | 1808 | break; |
1808 | } | 1809 | } |
1809 | 1810 | ||
1810 | if (visItem) | 1811 | if (visItem) |
1811 | ensureItemVisible(visItem); | 1812 | ensureItemVisible(visItem); |
1812 | 1813 | ||
1813 | QRect ir; | 1814 | QRect ir; |
1814 | if (repaintItem1) | 1815 | if (repaintItem1) |
1815 | ir = ir.unite( itemRect(repaintItem1) ); | 1816 | ir = ir.unite( itemRect(repaintItem1) ); |
1816 | if (repaintItem2) | 1817 | if (repaintItem2) |
1817 | ir = ir.unite( itemRect(repaintItem2) ); | 1818 | ir = ir.unite( itemRect(repaintItem2) ); |
1818 | 1819 | ||
1819 | if ( !ir.isEmpty() ) | 1820 | if ( !ir.isEmpty() ) |
1820 | { // rectangle to be repainted | 1821 | { // rectangle to be repainted |
1821 | if ( ir.x() < 0 ) | 1822 | if ( ir.x() < 0 ) |
1822 | ir.moveBy( -ir.x(), 0 ); | 1823 | ir.moveBy( -ir.x(), 0 ); |
1823 | viewport()->repaint( ir, FALSE ); | 1824 | viewport()->repaint( ir, FALSE ); |
1824 | } | 1825 | } |
1825 | /*if (repaintItem1) | 1826 | /*if (repaintItem1) |
1826 | repaintItem1->repaint(); | 1827 | repaintItem1->repaint(); |
1827 | if (repaintItem2) | 1828 | if (repaintItem2) |
1828 | repaintItem2->repaint();*/ | 1829 | repaintItem2->repaint();*/ |
1829 | update(); | 1830 | update(); |
1830 | if (emitSelectionChanged) | 1831 | if (emitSelectionChanged) |
1831 | emit selectionChanged(); | 1832 | emit selectionChanged(); |
1832 | } | 1833 | } |
1833 | 1834 | ||
1834 | void KListView::setSelectionModeExt (SelectionModeExt mode) | 1835 | void KListView::setSelectionModeExt (SelectionModeExt mode) |
1835 | { | 1836 | { |
1836 | d->selectionMode = mode; | 1837 | d->selectionMode = mode; |
1837 | 1838 | ||
1838 | switch (mode) | 1839 | switch (mode) |
1839 | { | 1840 | { |
1840 | case Single: | 1841 | case Single: |
1841 | case Multi: | 1842 | case Multi: |
1842 | case Extended: | 1843 | case Extended: |
1843 | case NoSelection: | 1844 | case NoSelection: |
1844 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); | 1845 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); |
1845 | break; | 1846 | break; |
1846 | 1847 | ||
1847 | case FileManager: | 1848 | case FileManager: |
1848 | setSelectionMode (QListView::Extended); | 1849 | setSelectionMode (QListView::Extended); |
1849 | break; | 1850 | break; |
1850 | 1851 | ||
1851 | default: | 1852 | default: |
1852 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; | 1853 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; |
1853 | break; | 1854 | break; |
1854 | } | 1855 | } |
1855 | } | 1856 | } |
1856 | 1857 | ||
1857 | KListView::SelectionModeExt KListView::selectionModeExt () const | 1858 | KListView::SelectionModeExt KListView::selectionModeExt () const |
1858 | { | 1859 | { |
1859 | return d->selectionMode; | 1860 | return d->selectionMode; |
1860 | } | 1861 | } |
1861 | 1862 | ||
1862 | int KListView::itemIndex( const QListViewItem *item ) const | 1863 | int KListView::itemIndex( const QListViewItem *item ) const |
1863 | { | 1864 | { |
1864 | if ( !item ) | 1865 | if ( !item ) |
1865 | return -1; | 1866 | return -1; |
1866 | 1867 | ||
1867 | if ( item == firstChild() ) | 1868 | if ( item == firstChild() ) |
1868 | return 0; | 1869 | return 0; |
1869 | else { | 1870 | else { |
1870 | QListViewItemIterator it(firstChild()); | 1871 | QListViewItemIterator it(firstChild()); |
1871 | uint j = 0; | 1872 | uint j = 0; |
1872 | for (; it.current() && it.current() != item; ++it, ++j ); | 1873 | for (; it.current() && it.current() != item; ++it, ++j ); |
1873 | 1874 | ||
1874 | if( !it.current() ) | 1875 | if( !it.current() ) |
1875 | return -1; | 1876 | return -1; |
1876 | 1877 | ||
1877 | return j; | 1878 | return j; |
1878 | } | 1879 | } |
1879 | } | 1880 | } |
1880 | 1881 | ||
1881 | QListViewItem* KListView::itemAtIndex(int index) | 1882 | QListViewItem* KListView::itemAtIndex(int index) |
1882 | { | 1883 | { |
1883 | if (index<0) | 1884 | if (index<0) |
1884 | return 0; | 1885 | return 0; |
1885 | 1886 | ||
1886 | int j(0); | 1887 | int j(0); |
1887 | for (QListViewItemIterator it=firstChild(); it.current(); it++) | 1888 | for (QListViewItemIterator it=firstChild(); it.current(); it++) |
1888 | { | 1889 | { |
1889 | if (j==index) | 1890 | if (j==index) |
1890 | return it.current(); | 1891 | return it.current(); |
1891 | j++; | 1892 | j++; |
1892 | }; | 1893 | }; |
1893 | return 0; | 1894 | return 0; |
1894 | } | 1895 | } |
1895 | 1896 | ||
1896 | 1897 | ||
1897 | void KListView::emitContextMenu (KListView*, QListViewItem* i) | 1898 | void KListView::emitContextMenu (KListView*, QListViewItem* i) |
1898 | { | 1899 | { |
1899 | QPoint p; | 1900 | QPoint p; |
1900 | // qDebug("KListView::emitContextMenu "); | 1901 | // qDebug("KListView::emitContextMenu "); |
1901 | 1902 | ||
1902 | if (i) | 1903 | if (i) |
1903 | p = viewport()->mapToGlobal(itemRect(i).center()); | 1904 | p = viewport()->mapToGlobal(itemRect(i).center()); |
1904 | else | 1905 | else |
1905 | p = mapToGlobal(rect().center()); | 1906 | p = mapToGlobal(rect().center()); |
1906 | 1907 | ||
1907 | emit contextMenu (this, i, p); | 1908 | emit contextMenu (this, i, p); |
1908 | } | 1909 | } |
1909 | 1910 | ||
1910 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) | 1911 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) |
1911 | { | 1912 | { |
1912 | QListViewItem* item = i; | 1913 | QListViewItem* item = i; |
1913 | int c = col; | 1914 | int c = col; |
1914 | // do not trust the values for QListViewItem* i and int col; | 1915 | // do not trust the values for QListViewItem* i and int col; |
1915 | // qDebug("KListView::emitContextMenu col"); | 1916 | // qDebug("KListView::emitContextMenu col"); |
1916 | if ( col == -1 ) { | 1917 | if ( col == -1 ) { |
1917 | QPoint pp = viewport()->mapFromGlobal(p); | 1918 | QPoint pp = viewport()->mapFromGlobal(p); |
1918 | item = itemAt( pp); | 1919 | item = itemAt( pp); |
1919 | c = header()->sectionAt(pp.x() ); | 1920 | c = header()->sectionAt(pp.x() ); |
1920 | } | 1921 | } |
1921 | emit contextRequest( item, p, c ); | 1922 | emit contextRequest( item, p, c ); |
1922 | emit contextMenu (this, item, p); | 1923 | emit contextMenu (this, item, p); |
1923 | } | 1924 | } |
1924 | 1925 | ||
1925 | void KListView::setAcceptDrops (bool val) | 1926 | void KListView::setAcceptDrops (bool val) |
1926 | { | 1927 | { |
1927 | QListView::setAcceptDrops (val); | 1928 | QListView::setAcceptDrops (val); |
1928 | viewport()->setAcceptDrops (val); | 1929 | viewport()->setAcceptDrops (val); |
1929 | } | 1930 | } |
1930 | 1931 | ||
1931 | int KListView::dropVisualizerWidth () const | 1932 | int KListView::dropVisualizerWidth () const |
1932 | { | 1933 | { |
1933 | return d->mDropVisualizerWidth; | 1934 | return d->mDropVisualizerWidth; |
1934 | } | 1935 | } |
1935 | 1936 | ||
1936 | 1937 | ||
1937 | void KListView::viewportPaintEvent(QPaintEvent *e) | 1938 | void KListView::viewportPaintEvent(QPaintEvent *e) |
1938 | { | 1939 | { |
1939 | QListView::viewportPaintEvent(e); | 1940 | QListView::viewportPaintEvent(e); |
1940 | 1941 | ||
1941 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) | 1942 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) |
1942 | { | 1943 | { |
1943 | QPainter painter(viewport()); | 1944 | QPainter painter(viewport()); |
1944 | 1945 | ||
1945 | // This is where we actually draw the drop-visualizer | 1946 | // This is where we actually draw the drop-visualizer |
1946 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); | 1947 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); |
1947 | } | 1948 | } |
1948 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) | 1949 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) |
1949 | { | 1950 | { |
1950 | QPainter painter(viewport()); | 1951 | QPainter painter(viewport()); |
1951 | 1952 | ||
1952 | qDebug("KListView::viewportPaintEvent has to be verified"); | 1953 | qDebug("KListView::viewportPaintEvent has to be verified"); |
1953 | 1954 | ||
1954 | // This is where we actually draw the drop-highlighter | 1955 | // This is where we actually draw the drop-highlighter |
1955 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), | 1956 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), |
1956 | //US QStyle::Style_FocusAtBorder); | 1957 | //US QStyle::Style_FocusAtBorder); |
1957 | 1958 | ||
1958 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); | 1959 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); |
1959 | 1960 | ||
1960 | 1961 | ||
1961 | } | 1962 | } |
1962 | } | 1963 | } |
1963 | 1964 | ||
1964 | void KListView::setFullWidth() | 1965 | void KListView::setFullWidth() |
1965 | { | 1966 | { |
1966 | setFullWidth(true); | 1967 | setFullWidth(true); |
1967 | } | 1968 | } |
1968 | 1969 | ||
1969 | void KListView::setFullWidth(bool fullWidth) | 1970 | void KListView::setFullWidth(bool fullWidth) |
1970 | { | 1971 | { |
1971 | d->fullWidth = fullWidth; | 1972 | d->fullWidth = fullWidth; |
1972 | //US header()->setStretchEnabled(fullWidth, columns()-1); | 1973 | //US header()->setStretchEnabled(fullWidth, columns()-1); |
1973 | } | 1974 | } |
1974 | 1975 | ||
1975 | bool KListView::fullWidth() const | 1976 | bool KListView::fullWidth() const |
1976 | { | 1977 | { |
1977 | return d->fullWidth; | 1978 | return d->fullWidth; |
1978 | } | 1979 | } |
1979 | 1980 | ||
1980 | int KListView::addColumn(const QString& label, int width) | 1981 | int KListView::addColumn(const QString& label, int width) |
1981 | { | 1982 | { |
1982 | int result = QListView::addColumn(label, width); | 1983 | int result = QListView::addColumn(label, width); |
1983 | if (d->fullWidth) { | 1984 | if (d->fullWidth) { |
1984 | //US header()->setStretchEnabled(false, columns()-2); | 1985 | //US header()->setStretchEnabled(false, columns()-2); |
1985 | //US header()->setStretchEnabled(true, columns()-1); | 1986 | //US header()->setStretchEnabled(true, columns()-1); |
1986 | } | 1987 | } |
1987 | return result; | 1988 | return result; |
1988 | } | 1989 | } |
1989 | 1990 | ||
1990 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) | 1991 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) |
1991 | { | 1992 | { |
1992 | int result = QListView::addColumn(iconset, label, width); | 1993 | int result = QListView::addColumn(iconset, label, width); |
1993 | if (d->fullWidth) { | 1994 | if (d->fullWidth) { |
1994 | //US header()->setStretchEnabled(false, columns()-2); | 1995 | //US header()->setStretchEnabled(false, columns()-2); |
1995 | //US header()->setStretchEnabled(true, columns()-1); | 1996 | //US header()->setStretchEnabled(true, columns()-1); |
1996 | } | 1997 | } |
1997 | return result; | 1998 | return result; |
1998 | } | 1999 | } |
1999 | 2000 | ||
2000 | void KListView::removeColumn(int index) | 2001 | void KListView::removeColumn(int index) |
2001 | { | 2002 | { |
2002 | QListView::removeColumn(index); | 2003 | QListView::removeColumn(index); |
2003 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); | 2004 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); |
2004 | } | 2005 | } |
2005 | 2006 | ||
2006 | void KListView::viewportResizeEvent(QResizeEvent* e) | 2007 | void KListView::viewportResizeEvent(QResizeEvent* e) |
2007 | { | 2008 | { |
2008 | QListView::viewportResizeEvent(e); | 2009 | QListView::viewportResizeEvent(e); |
2009 | } | 2010 | } |
2010 | 2011 | ||
2011 | const QColor &KListView::alternateBackground() const | 2012 | const QColor &KListView::alternateBackground() const |
2012 | { | 2013 | { |
2013 | return d->alternateBackground; | 2014 | return d->alternateBackground; |
2014 | } | 2015 | } |
2015 | 2016 | ||
2016 | void KListView::setAlternateBackground(const QColor &c) | 2017 | void KListView::setAlternateBackground(const QColor &c) |
2017 | { | 2018 | { |
2018 | d->alternateBackground = c; | 2019 | d->alternateBackground = c; |
2019 | repaint(); | 2020 | repaint(); |
2020 | } | 2021 | } |
2021 | 2022 | ||
2022 | void KListView::saveLayout(KConfig *config, const QString &group) const | 2023 | void KListView::saveLayout(KConfig *config, const QString &group) const |
2023 | { | 2024 | { |
2024 | KConfigGroupSaver saver(config, group); | 2025 | KConfigGroupSaver saver(config, group); |
2025 | QStringList widths, order; | 2026 | QStringList widths, order; |
2026 | for (int i = 0; i < columns(); ++i) | 2027 | for (int i = 0; i < columns(); ++i) |
2027 | { | 2028 | { |
2028 | widths << QString::number(columnWidth(i)); | 2029 | widths << QString::number(columnWidth(i)); |
2029 | order << QString::number(header()->mapToIndex(i)); | 2030 | order << QString::number(header()->mapToIndex(i)); |
2030 | } | 2031 | } |
2031 | config->writeEntry("ColumnWidths", widths); | 2032 | config->writeEntry("ColumnWidths", widths); |
2032 | config->writeEntry("ColumnOrder", order); | 2033 | config->writeEntry("ColumnOrder", order); |
2033 | config->writeEntry("SortColumn", d->sortColumn); | 2034 | config->writeEntry("SortColumn", d->sortColumn); |
2034 | config->writeEntry("SortAscending", d->sortAscending); | 2035 | config->writeEntry("SortAscending", d->sortAscending); |
2035 | } | 2036 | } |
2036 | 2037 | ||
2037 | void KListView::restoreLayout(KConfig *config, const QString &group) | 2038 | void KListView::restoreLayout(KConfig *config, const QString &group) |
2038 | { | 2039 | { |
2039 | KConfigGroupSaver saver(config, group); | 2040 | KConfigGroupSaver saver(config, group); |
2040 | QStringList cols = config->readListEntry("ColumnWidths"); | 2041 | QStringList cols = config->readListEntry("ColumnWidths"); |
2041 | int i = 0; | 2042 | int i = 0; |
2042 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) | 2043 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) |
2043 | setColumnWidth(i++, (*it).toInt()); | 2044 | setColumnWidth(i++, (*it).toInt()); |
2044 | 2045 | ||
2045 | cols = config->readListEntry("ColumnOrder"); | 2046 | cols = config->readListEntry("ColumnOrder"); |
2046 | i = 0; | 2047 | i = 0; |
2047 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) | 2048 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) |
2048 | header()->moveSection(i++, (*it).toInt()); | 2049 | header()->moveSection(i++, (*it).toInt()); |
2049 | 2050 | ||
2050 | /*US I changed the following code, because hasKey is not available. | 2051 | /*US I changed the following code, because hasKey is not available. |
2051 | !!! check if my version is correct | 2052 | !!! check if my version is correct |
2052 | if (config->hasKey("SortColumn")) | 2053 | if (config->hasKey("SortColumn")) |
2053 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); | 2054 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); |
2054 | */ | 2055 | */ |
2055 | QStringList langLst = config->readListEntry( "SortColumn" ); | 2056 | QStringList langLst = config->readListEntry( "SortColumn" ); |
2056 | if (!langLst.isEmpty()) | 2057 | if (!langLst.isEmpty()) |
2057 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); | 2058 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); |
2058 | } | 2059 | } |
2059 | 2060 | ||
2060 | void KListView::setSorting(int column, bool ascending) | 2061 | void KListView::setSorting(int column, bool ascending) |
2061 | { | 2062 | { |
2062 | d->sortColumn = column; | 2063 | d->sortColumn = column; |
2063 | d->sortAscending = ascending; | 2064 | d->sortAscending = ascending; |
2064 | QListView::setSorting(column, ascending); | 2065 | QListView::setSorting(column, ascending); |
2065 | } | 2066 | } |
2066 | 2067 | ||
2067 | int KListView::columnSorted(void) const | 2068 | int KListView::columnSorted(void) const |
2068 | { | 2069 | { |
2069 | return d->sortColumn; | 2070 | return d->sortColumn; |
2070 | } | 2071 | } |
2071 | 2072 | ||
2072 | bool KListView::ascendingSort(void) const | 2073 | bool KListView::ascendingSort(void) const |
2073 | { | 2074 | { |
2074 | return d->sortAscending; | 2075 | return d->sortAscending; |
2075 | } | 2076 | } |
2076 | 2077 | ||
2077 | KListViewItem::KListViewItem(QListView *parent) | 2078 | KListViewItem::KListViewItem(QListView *parent) |
2078 | : QListViewItem(parent) | 2079 | : QListViewItem(parent) |
2079 | { | 2080 | { |
2080 | init(); | 2081 | init(); |
2081 | } | 2082 | } |
2082 | 2083 | ||
2083 | KListViewItem::KListViewItem(QListViewItem *parent) | 2084 | KListViewItem::KListViewItem(QListViewItem *parent) |
2084 | : QListViewItem(parent) | 2085 | : QListViewItem(parent) |
2085 | { | 2086 | { |
2086 | init(); | 2087 | init(); |
2087 | } | 2088 | } |
2088 | 2089 | ||
2089 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) | 2090 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) |
2090 | : QListViewItem(parent, after) | 2091 | : QListViewItem(parent, after) |
2091 | { | 2092 | { |
2092 | init(); | 2093 | init(); |
2093 | } | 2094 | } |
2094 | 2095 | ||
2095 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) | 2096 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) |
2096 | : QListViewItem(parent, after) | 2097 | : QListViewItem(parent, after) |
2097 | { | 2098 | { |
2098 | init(); | 2099 | init(); |
2099 | } | 2100 | } |
2100 | 2101 | ||
2101 | KListViewItem::KListViewItem(QListView *parent, | 2102 | KListViewItem::KListViewItem(QListView *parent, |
2102 | QString label1, QString label2, QString label3, QString label4, | 2103 | QString label1, QString label2, QString label3, QString label4, |
2103 | QString label5, QString label6, QString label7, QString label8) | 2104 | QString label5, QString label6, QString label7, QString label8) |
2104 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 2105 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
2105 | { | 2106 | { |
2106 | init(); | 2107 | init(); |
2107 | } | 2108 | } |
2108 | 2109 | ||
2109 | KListViewItem::KListViewItem(QListViewItem *parent, | 2110 | KListViewItem::KListViewItem(QListViewItem *parent, |
2110 | QString label1, QString label2, QString label3, QString label4, | 2111 | QString label1, QString label2, QString label3, QString label4, |
2111 | QString label5, QString label6, QString label7, QString label8) | 2112 | QString label5, QString label6, QString label7, QString label8) |
2112 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 2113 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
2113 | { | 2114 | { |
2114 | init(); | 2115 | init(); |
2115 | } | 2116 | } |
2116 | 2117 | ||
2117 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, | 2118 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, |
2118 | QString label1, QString label2, QString label3, QString label4, | 2119 | QString label1, QString label2, QString label3, QString label4, |
2119 | QString label5, QString label6, QString label7, QString label8) | 2120 | QString label5, QString label6, QString label7, QString label8) |
2120 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2121 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2121 | { | 2122 | { |
2122 | init(); | 2123 | init(); |
2123 | } | 2124 | } |
2124 | 2125 | ||
2125 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, | 2126 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, |
2126 | QString label1, QString label2, QString label3, QString label4, | 2127 | QString label1, QString label2, QString label3, QString label4, |
2127 | QString label5, QString label6, QString label7, QString label8) | 2128 | QString label5, QString label6, QString label7, QString label8) |
2128 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2129 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2129 | { | 2130 | { |
2130 | init(); | 2131 | init(); |
2131 | } | 2132 | } |
2132 | 2133 | ||
2133 | KListViewItem::~KListViewItem() | 2134 | KListViewItem::~KListViewItem() |
2134 | { | 2135 | { |
2135 | } | 2136 | } |
2136 | 2137 | ||
2137 | void KListViewItem::init() | 2138 | void KListViewItem::init() |
2138 | { | 2139 | { |
2139 | m_known = false; | 2140 | m_known = false; |
2140 | } | 2141 | } |
2141 | 2142 | ||
2142 | const QColor &KListViewItem::backgroundColor() | 2143 | const QColor &KListViewItem::backgroundColor() |
2143 | { | 2144 | { |
2144 | if (isAlternate()) | 2145 | if (isAlternate()) |
2145 | return static_cast< KListView* >(listView())->alternateBackground(); | 2146 | return static_cast< KListView* >(listView())->alternateBackground(); |
2146 | return listView()->viewport()->colorGroup().base(); | 2147 | return listView()->viewport()->colorGroup().base(); |
2147 | } | 2148 | } |
2148 | 2149 | ||
2149 | bool KListViewItem::isAlternate() | 2150 | bool KListViewItem::isAlternate() |
2150 | { | 2151 | { |
2151 | KListView *lv = static_cast<KListView *>(listView()); | 2152 | KListView *lv = static_cast<KListView *>(listView()); |
2152 | if (lv && lv->alternateBackground().isValid()) | 2153 | if (lv && lv->alternateBackground().isValid()) |
2153 | { | 2154 | { |
2154 | KListViewItem *above = 0; | 2155 | KListViewItem *above = 0; |
2155 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); | 2156 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); |
2156 | above = (KListViewItem *)(itemAbove()); | 2157 | above = (KListViewItem *)(itemAbove()); |
2157 | m_known = above ? above->m_known : true; | 2158 | m_known = above ? above->m_known : true; |
2158 | if (m_known) | 2159 | if (m_known) |
2159 | { | 2160 | { |
2160 | m_odd = above ? !above->m_odd : false; | 2161 | m_odd = above ? !above->m_odd : false; |
2161 | } | 2162 | } |
2162 | else | 2163 | else |
2163 | { | 2164 | { |
2164 | KListViewItem *item; | 2165 | KListViewItem *item; |
2165 | bool previous = true; | 2166 | bool previous = true; |
2166 | if (parent()) | 2167 | if (parent()) |
2167 | { | 2168 | { |
2168 | //US item = dynamic_cast<KListViewItem *>(parent()); | 2169 | //US item = dynamic_cast<KListViewItem *>(parent()); |
2169 | item = (KListViewItem *)(parent()); | 2170 | item = (KListViewItem *)(parent()); |
2170 | if (item) | 2171 | if (item) |
2171 | previous = item->m_odd; | 2172 | previous = item->m_odd; |
2172 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); | 2173 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); |
2173 | item = (KListViewItem *)(parent()->firstChild()); | 2174 | item = (KListViewItem *)(parent()->firstChild()); |
2174 | } | 2175 | } |
2175 | else | 2176 | else |
2176 | { | 2177 | { |
2177 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); | 2178 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); |
2178 | item = (KListViewItem *)(lv->firstChild()); | 2179 | item = (KListViewItem *)(lv->firstChild()); |
2179 | } | 2180 | } |
2180 | 2181 | ||
2181 | while(item) | 2182 | while(item) |
2182 | { | 2183 | { |
2183 | item->m_odd = previous = !previous; | 2184 | item->m_odd = previous = !previous; |
2184 | item->m_known = true; | 2185 | item->m_known = true; |
2185 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); | 2186 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); |
2186 | item = (KListViewItem *)(item->nextSibling()); | 2187 | item = (KListViewItem *)(item->nextSibling()); |
2187 | } | 2188 | } |
2188 | } | 2189 | } |
2189 | return m_odd; | 2190 | return m_odd; |
2190 | } | 2191 | } |
2191 | return false; | 2192 | return false; |
2192 | } | 2193 | } |
2193 | 2194 | ||
2194 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 2195 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
2195 | { | 2196 | { |
2196 | QColorGroup _cg = cg; | 2197 | QColorGroup _cg = cg; |
2197 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 2198 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
2198 | if (pm && !pm->isNull()) | 2199 | if (pm && !pm->isNull()) |
2199 | { | 2200 | { |
2200 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); | 2201 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); |
2201 | QPoint o = p->brushOrigin(); | 2202 | QPoint o = p->brushOrigin(); |
2202 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); | 2203 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); |
2203 | } | 2204 | } |
2204 | else if (isAlternate()) { | 2205 | else if (isAlternate()) { |
2205 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) | 2206 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) |
2206 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) | 2207 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) |
2207 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); | 2208 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); |
2208 | else | 2209 | else |
2209 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); | 2210 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); |
2210 | } | 2211 | } |
2211 | QListViewItem::paintCell(p, _cg, column, width, alignment); | 2212 | QListViewItem::paintCell(p, _cg, column, width, alignment); |
2212 | } | 2213 | } |
2213 | 2214 | ||
2214 | //US we do not have a "global KDE" variable to setup singleClick functionality | 2215 | //US we do not have a "global KDE" variable to setup singleClick functionality |
2215 | void KListView::setSingleClick(bool s) | 2216 | void KListView::setSingleClick(bool s) |
2216 | { | 2217 | { |
2217 | d->bUseSingle = s; | 2218 | d->bUseSingle = s; |
2218 | slotSettingsChanged(1); | 2219 | slotSettingsChanged(1); |
2219 | // qDebug("KListView::setSingleClick: single %i", d->bUseSingle); | 2220 | // qDebug("KListView::setSingleClick: single %i", d->bUseSingle); |
2220 | } | 2221 | } |
2221 | 2222 | ||
2222 | 2223 | ||
2223 | void KListView::virtual_hook( int, void* ) | 2224 | void KListView::virtual_hook( int, void* ) |
2224 | { /*BASE::virtual_hook( id, data );*/ } | 2225 | { /*BASE::virtual_hook( id, data );*/ } |
2225 | 2226 | ||
2226 | //US #include "klistview.moc" | 2227 | //US #include "klistview.moc" |
2227 | //US #include "klistviewlineedit.moc" | 2228 | //US #include "klistviewlineedit.moc" |
2228 | 2229 | ||
2229 | // vim: ts=2 sw=2 et | 2230 | // vim: ts=2 sw=2 et |
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,1039 +1,1039 @@ | |||
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 |
28 | class QDropEvent; | 28 | class QDropEvent; |
29 | class QDragLeaveEvent; | 29 | class QDragLeaveEvent; |
30 | class QDragMoveEvent; | 30 | class QDragMoveEvent; |
31 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
32 | 32 | ||
33 | class QDragObject; | 33 | class QDragObject; |
34 | class KConfig; | 34 | class KConfig; |
35 | class KLineEdit; | 35 | class 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 | */ |
60 | class KListView : public QListView | 60 | class 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 | ||
76 | public: | 76 | public: |
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 | ||
379 | signals: | 379 | signals: |
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. |
511 | */ | 511 | */ |
512 | void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); | 512 | void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); |
513 | 513 | ||
514 | /** | 514 | /** |
515 | * This signal gets emitted when an item is renamed via in-place renaming. | 515 | * This signal gets emitted when an item is renamed via in-place renaming. |
516 | * | 516 | * |
517 | * @param item is the renamed item. | 517 | * @param item is the renamed item. |
518 | * @param str is the new value of column @p col. | 518 | * @param str is the new value of column @p col. |
519 | * @param col is the renamed column. | 519 | * @param col is the renamed column. |
520 | */ | 520 | */ |
521 | void itemRenamed(QListViewItem* item, const QString &str, int col); | 521 | void itemRenamed(QListViewItem* item, const QString &str, int col); |
522 | 522 | ||
523 | /** | 523 | /** |
524 | * Same as above, but without the extra information. | 524 | * Same as above, but without the extra information. |
525 | */ | 525 | */ |
526 | void itemRenamed(QListViewItem* item); | 526 | void itemRenamed(QListViewItem* item); |
527 | void signalDelete(); | 527 | void signalDelete(); |
528 | 528 | ||
529 | /** | 529 | /** |
530 | * This signal is emitted when the shortcut key for popup-menus is pressed. | 530 | * This signal is emitted when the shortcut key for popup-menus is pressed. |
531 | * | 531 | * |
532 | * Normally you should not use this, just connect a slot to signal | 532 | * Normally you should not use this, just connect a slot to signal |
533 | * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly | 533 | * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly |
534 | * handle showing context menus regardless of settings. | 534 | * handle showing context menus regardless of settings. |
535 | * | 535 | * |
536 | * @param list is this listview. | 536 | * @param list is this listview. |
537 | * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. | 537 | * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. |
538 | */ | 538 | */ |
539 | void menuShortCutPressed (KListView* list, QListViewItem* item); | 539 | void menuShortCutPressed (KListView* list, QListViewItem* item); |
540 | 540 | ||
541 | /** | 541 | /** |
542 | * This signal is emitted whenever a context-menu should be shown for item @p i. | 542 | * This signal is emitted whenever a context-menu should be shown for item @p i. |
543 | * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). | 543 | * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). |
544 | * | 544 | * |
545 | * @param l is this listview. | 545 | * @param l is this listview. |
546 | * @param i is the item for which the menu should be shown. May be 0L. | 546 | * @param i is the item for which the menu should be shown. May be 0L. |
547 | * @param p is the point at which the menu should be shown. | 547 | * @param p is the point at which the menu should be shown. |
548 | */ | 548 | */ |
549 | void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); | 549 | void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); |
550 | 550 | ||
551 | public slots: | 551 | public slots: |
552 | /** | 552 | /** |
553 | * Rename column @p c of @p item. | 553 | * Rename column @p c of @p item. |
554 | */ | 554 | */ |
555 | virtual void rename(QListViewItem *item, int c); | 555 | virtual void rename(QListViewItem *item, int c); |
556 | 556 | ||
557 | /** | 557 | /** |
558 | * By default, if you called setItemsRenameable(true), | 558 | * By default, if you called setItemsRenameable(true), |
559 | * only the first column is renameable. | 559 | * only the first column is renameable. |
560 | * Use this function to enable the feature on other columns. | 560 | * Use this function to enable the feature on other columns. |
561 | * | 561 | * |
562 | * If you want more intelligent (dynamic) selection, | 562 | * If you want more intelligent (dynamic) selection, |
563 | * you'll have to derive from KListView, | 563 | * you'll have to derive from KListView, |
564 | * and override @ref rename() and call only call it | 564 | * and override @ref rename() and call only call it |
565 | * if you want the item to be renamed. | 565 | * if you want the item to be renamed. |
566 | */ | 566 | */ |
567 | void setRenameable (int column, bool yesno=true); | 567 | void setRenameable (int column, bool yesno=true); |
568 | 568 | ||
569 | /** | 569 | /** |
570 | * Set whether items in the list view can be moved. | 570 | * Set whether items in the list view can be moved. |
571 | * It is enabled by default. | 571 | * It is enabled by default. |
572 | * | 572 | * |
573 | * @see itemsMovable() | 573 | * @see itemsMovable() |
574 | */ | 574 | */ |
575 | virtual void setItemsMovable(bool b); | 575 | virtual void setItemsMovable(bool b); |
576 | 576 | ||
577 | /** | 577 | /** |
578 | * Enables inplace-renaming of items. | 578 | * Enables inplace-renaming of items. |
579 | * It is disabled by default. | 579 | * It is disabled by default. |
580 | * | 580 | * |
581 | * @see itemsRenameable() | 581 | * @see itemsRenameable() |
582 | * @see setRenameable() | 582 | * @see setRenameable() |
583 | */ | 583 | */ |
584 | virtual void setItemsRenameable(bool b); | 584 | virtual void setItemsRenameable(bool b); |
585 | 585 | ||
586 | /** | 586 | /** |
587 | * Enable/Disable the dragging of items. | 587 | * Enable/Disable the dragging of items. |
588 | * It is disabled by default. | 588 | * It is disabled by default. |
589 | */ | 589 | */ |
590 | virtual void setDragEnabled(bool b); | 590 | virtual void setDragEnabled(bool b); |
591 | 591 | ||
592 | /** | 592 | /** |
593 | * Enable/Disable AutoOpen (not implemented currently). | 593 | * Enable/Disable AutoOpen (not implemented currently). |
594 | */ | 594 | */ |
595 | virtual void setAutoOpen(bool b); | 595 | virtual void setAutoOpen(bool b); |
596 | 596 | ||
597 | /** | 597 | /** |
598 | * Enable/Disable the drawing of a drop-visualizer | 598 | * Enable/Disable the drawing of a drop-visualizer |
599 | * (a bar that shows where a dropped item would be inserted). | 599 | * (a bar that shows where a dropped item would be inserted). |
600 | * It is enabled by default, if dragging is enabled | 600 | * It is enabled by default, if dragging is enabled |
601 | */ | 601 | */ |
602 | virtual void setDropVisualizer(bool b); | 602 | virtual void setDropVisualizer(bool b); |
603 | 603 | ||
604 | /** | 604 | /** |
605 | * Set the width of the (default) drop-visualizer. | 605 | * Set the width of the (default) drop-visualizer. |
606 | * If you don't call this method, the width is set to 4. | 606 | * If you don't call this method, the width is set to 4. |
607 | */ | 607 | */ |
608 | void setDropVisualizerWidth (int w); | 608 | void setDropVisualizerWidth (int w); |
609 | 609 | ||
610 | /** | 610 | /** |
611 | * Set which column should be used for automatic tooltips. | 611 | * Set which column should be used for automatic tooltips. |
612 | * | 612 | * |
613 | * @param column is the column for which tooltips will be shown. | 613 | * @param column is the column for which tooltips will be shown. |
614 | * Set -1 to disable this feature. | 614 | * Set -1 to disable this feature. |
615 | */ | 615 | */ |
616 | virtual void setTooltipColumn(int column); | 616 | virtual void setTooltipColumn(int column); |
617 | 617 | ||
618 | /** | 618 | /** |
619 | * Enable/Disable the drawing of a drop-highlighter | 619 | * Enable/Disable the drawing of a drop-highlighter |
620 | * (a rectangle around the item under the mouse cursor). | 620 | * (a rectangle around the item under the mouse cursor). |
621 | * It is disabled by default. | 621 | * It is disabled by default. |
622 | */ | 622 | */ |
623 | virtual void setDropHighlighter(bool b); | 623 | virtual void setDropHighlighter(bool b); |
624 | 624 | ||
625 | /** | 625 | /** |
626 | * For future expansions. | 626 | * For future expansions. |
627 | * | 627 | * |
628 | * Do not use. | 628 | * Do not use. |
629 | * @deprecated | 629 | * @deprecated |
630 | */ | 630 | */ |
631 | virtual void setCreateChildren(bool b); | 631 | virtual void setCreateChildren(bool b); |
632 | 632 | ||
633 | /** | 633 | /** |
634 | * Set the selection mode. | 634 | * Set the selection mode. |
635 | * | 635 | * |
636 | * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). | 636 | * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). |
637 | */ | 637 | */ |
638 | void setSelectionModeExt (SelectionModeExt mode); | 638 | void setSelectionModeExt (SelectionModeExt mode); |
639 | 639 | ||
640 | /** | 640 | /** |
641 | * Enable/disable tabbing between editable cells | 641 | * Enable/disable tabbing between editable cells |
642 | * @since 3.1 | 642 | * @since 3.1 |
643 | */ | 643 | */ |
644 | void setTabOrderedRenaming(bool b); | 644 | void setTabOrderedRenaming(bool b); |
645 | 645 | ||
646 | /** | 646 | /** |
647 | * Returns whether tab ordered renaming is enabled | 647 | * Returns whether tab ordered renaming is enabled |
648 | * @since 3.1 | 648 | * @since 3.1 |
649 | */ | 649 | */ |
650 | bool tabOrderedRenaming() const; | 650 | bool tabOrderedRenaming() const; |
651 | 651 | ||
652 | protected: | 652 | protected: |
653 | /** | 653 | /** |
654 | * Determine whether a drop on position @p p would count as | 654 | * Determine whether a drop on position @p p would count as |
655 | * being above or below the QRect @p rect. | 655 | * being above or below the QRect @p rect. |
656 | * | 656 | * |
657 | * @param rect is the rectangle we examine. | 657 | * @param rect is the rectangle we examine. |
658 | * @param p is the point located in the rectangle, p is assumed to be in | 658 | * @param p is the point located in the rectangle, p is assumed to be in |
659 | * viewport coordinates. | 659 | * viewport coordinates. |
660 | */ | 660 | */ |
661 | inline bool below (const QRect& rect, const QPoint& p) | 661 | inline bool below (const QRect& rect, const QPoint& p) |
662 | { | 662 | { |
663 | return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); | 663 | return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); |
664 | } | 664 | } |
665 | 665 | ||
666 | /** | 666 | /** |
667 | * An overloaded version of below(const QRect&, const QPoint&). | 667 | * An overloaded version of below(const QRect&, const QPoint&). |
668 | * | 668 | * |
669 | * It differs from the above only in what arguments it takes. | 669 | * It differs from the above only in what arguments it takes. |
670 | * | 670 | * |
671 | * @param i the item whose rect() is passed to the above function. | 671 | * @param i the item whose rect() is passed to the above function. |
672 | * @param p is translated from contents coordinates to viewport coordinates | 672 | * @param p is translated from contents coordinates to viewport coordinates |
673 | * before being passed to the above function. | 673 | * before being passed to the above function. |
674 | */ | 674 | */ |
675 | inline bool below (QListViewItem* i, const QPoint& p) | 675 | inline bool below (QListViewItem* i, const QPoint& p) |
676 | { | 676 | { |
677 | return below (itemRect(i), contentsToViewport(p)); | 677 | return below (itemRect(i), contentsToViewport(p)); |
678 | } | 678 | } |
679 | 679 | ||
680 | /** | 680 | /** |
681 | * Reimplemented to reload the alternate background in palette changes. | 681 | * Reimplemented to reload the alternate background in palette changes. |
682 | * @internal | 682 | * @internal |
683 | */ | 683 | */ |
684 | virtual bool event( QEvent * ); | 684 | virtual bool event( QEvent * ); |
685 | 685 | ||
686 | /** | 686 | /** |
687 | * Emit signal @ref #executed. | 687 | * Emit signal @ref #executed. |
688 | * @internal | 688 | * @internal |
689 | */ | 689 | */ |
690 | //US I added buttonstate to pass the current keyboard status | 690 | //US I added buttonstate to pass the current keyboard status |
691 | void emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c); | 691 | void emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c); |
692 | 692 | ||
693 | /** | 693 | /** |
694 | * Reimplemented for internal reasons. | 694 | * Reimplemented for internal reasons. |
695 | * Further reimplementations should call this function or else | 695 | * Further reimplementations should call this function or else |
696 | * some features may not work correctly. | 696 | * some features may not work correctly. |
697 | * | 697 | * |
698 | * The API is unaffected. | 698 | * The API is unaffected. |
699 | */ | 699 | */ |
700 | virtual void focusInEvent(QFocusEvent* fe); | 700 | virtual void focusInEvent(QFocusEvent* fe); |
701 | 701 | ||
702 | /** | 702 | /** |
703 | * Reimplemented for internal reasons. | 703 | * Reimplemented for internal reasons. |
704 | * Further reimplementations should call this function or else | 704 | * Further reimplementations should call this function or else |
705 | * some features may not work correctly. | 705 | * some features may not work correctly. |
706 | * | 706 | * |
707 | * The API is unaffected. | 707 | * The API is unaffected. |
708 | */ | 708 | */ |
709 | virtual void focusOutEvent( QFocusEvent *fe ); | 709 | virtual void focusOutEvent( QFocusEvent *fe ); |
710 | 710 | ||
711 | /** | 711 | /** |
712 | * Reimplemented for internal reasons. | 712 | * Reimplemented for internal reasons. |
713 | * Further reimplementations should call this function or else | 713 | * Further reimplementations should call this function or else |
714 | * some features may not work correctly. | 714 | * some features may not work correctly. |
715 | * | 715 | * |
716 | * The API is unaffected. | 716 | * The API is unaffected. |
717 | */ | 717 | */ |
718 | virtual void leaveEvent( QEvent *e ); | 718 | virtual void leaveEvent( QEvent *e ); |
719 | 719 | ||
720 | /** | 720 | /** |
721 | * @return the tooltip for @p column of @p item. | 721 | * @return the tooltip for @p column of @p item. |
722 | */ | 722 | */ |
723 | virtual QString tooltip(QListViewItem* item, int column) const; | 723 | virtual QString tooltip(QListViewItem* item, int column) const; |
724 | 724 | ||
725 | /** | 725 | /** |
726 | * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. | 726 | * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. |
727 | */ | 727 | */ |
728 | virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; | 728 | virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; |
729 | 729 | ||
730 | /** | 730 | /** |
731 | * Reimplemented for internal reasons. | 731 | * Reimplemented for internal reasons. |
732 | * Further reimplementations should call this function or else | 732 | * Further reimplementations should call this function or else |
733 | * some features may not work correctly. | 733 | * some features may not work correctly. |
734 | * | 734 | * |
735 | * The API is unaffected. | 735 | * The API is unaffected. |
736 | */ | 736 | */ |
737 | virtual void contentsDragMoveEvent (QDragMoveEvent *event); | 737 | virtual void contentsDragMoveEvent (QDragMoveEvent *event); |
738 | 738 | ||
739 | /** | 739 | /** |
740 | * Reimplemented for internal reasons. | 740 | * Reimplemented for internal reasons. |
741 | * Further reimplementations should call this function or else | 741 | * Further reimplementations should call this function or else |
742 | * some features may not work correctly. | 742 | * some features may not work correctly. |
743 | * | 743 | * |
744 | * The API is unaffected. | 744 | * The API is unaffected. |
745 | */ | 745 | */ |
746 | virtual void contentsMousePressEvent( QMouseEvent *e ); | 746 | virtual void contentsMousePressEvent( QMouseEvent *e ); |
747 | 747 | ||
748 | /** | 748 | /** |
749 | * Reimplemented for internal reasons. | 749 | * Reimplemented for internal reasons. |
750 | * Further reimplementations should call this function or else | 750 | * Further reimplementations should call this function or else |
751 | * some features may not work correctly. | 751 | * some features may not work correctly. |
752 | * | 752 | * |
753 | * The API is unaffected. | 753 | * The API is unaffected. |
754 | */ | 754 | */ |
755 | virtual void contentsMouseMoveEvent( QMouseEvent *e ); | 755 | virtual void contentsMouseMoveEvent( QMouseEvent *e ); |
756 | 756 | ||
757 | /** | 757 | /** |
758 | * Reimplemented for internal reasons. | 758 | * Reimplemented for internal reasons. |
759 | * Further reimplementations should call this function or else | 759 | * Further reimplementations should call this function or else |
760 | * some features may not work correctly. | 760 | * some features may not work correctly. |
761 | * | 761 | * |
762 | * The API is unaffected. | 762 | * The API is unaffected. |
763 | */ | 763 | */ |
764 | virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); | 764 | virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); |
765 | 765 | ||
766 | /** | 766 | /** |
767 | * Reimplemented for internal reasons. | 767 | * Reimplemented for internal reasons. |
768 | * Further reimplementations should call this function or else | 768 | * Further reimplementations should call this function or else |
769 | * some features may not work correctly. | 769 | * some features may not work correctly. |
770 | * | 770 | * |
771 | * The API is unaffected. | 771 | * The API is unaffected. |
772 | */ | 772 | */ |
773 | virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); | 773 | virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); |
774 | 774 | ||
775 | /** | 775 | /** |
776 | * Reimplemented for internal reasons. | 776 | * Reimplemented for internal reasons. |
777 | * Further reimplementations should call this function or else | 777 | * Further reimplementations should call this function or else |
778 | * some features may not work correctly. | 778 | * some features may not work correctly. |
779 | * | 779 | * |
780 | * The API is unaffected. | 780 | * The API is unaffected. |
781 | */ | 781 | */ |
782 | virtual void contentsMouseReleaseEvent (QMouseEvent*); | 782 | virtual void contentsMouseReleaseEvent (QMouseEvent*); |
783 | 783 | ||
784 | /** | 784 | /** |
785 | * Reimplemented for internal reasons. | 785 | * Reimplemented for internal reasons. |
786 | * Further reimplementations should call this function or else | 786 | * Further reimplementations should call this function or else |
787 | * some features may not work correctly. | 787 | * some features may not work correctly. |
788 | * | 788 | * |
789 | * The API is unaffected. | 789 | * The API is unaffected. |
790 | */ | 790 | */ |
791 | virtual void contentsDropEvent (QDropEvent*); | 791 | virtual void contentsDropEvent (QDropEvent*); |
792 | 792 | ||
793 | /** | 793 | /** |
794 | * Reimplemented for internal reasons. | 794 | * Reimplemented for internal reasons. |
795 | * Further reimplementations should call this function or else | 795 | * Further reimplementations should call this function or else |
796 | * some features may not work correctly. | 796 | * some features may not work correctly. |
797 | * | 797 | * |
798 | * The API is unaffected. | 798 | * The API is unaffected. |
799 | */ | 799 | */ |
800 | virtual void contentsDragEnterEvent (QDragEnterEvent *); | 800 | virtual void contentsDragEnterEvent (QDragEnterEvent *); |
801 | 801 | ||
802 | /** | 802 | /** |
803 | * @return a dragobject encoding the current selection. | 803 | * @return a dragobject encoding the current selection. |
804 | * | 804 | * |
805 | * @see setDragEnabled() | 805 | * @see setDragEnabled() |
806 | */ | 806 | */ |
807 | virtual QDragObject *dragObject(); | 807 | virtual QDragObject *dragObject(); |
808 | 808 | ||
809 | /** | 809 | /** |
810 | * @return true if the @p event provides some acceptable | 810 | * @return true if the @p event provides some acceptable |
811 | * format. | 811 | * format. |
812 | * A common mistake is to forget the "const" in your reimplementation | 812 | * A common mistake is to forget the "const" in your reimplementation |
813 | */ | 813 | */ |
814 | virtual bool acceptDrag (QDropEvent* event) const; | 814 | virtual bool acceptDrag (QDropEvent* event) const; |
815 | 815 | ||
816 | /** | 816 | /** |
817 | * Paint the drag line. If painter is null, don't try to :) | 817 | * Paint the drag line. If painter is null, don't try to :) |
818 | * | 818 | * |
819 | * If after == 0 then the marker should be drawn at the top. | 819 | * If after == 0 then the marker should be drawn at the top. |
820 | * | 820 | * |
821 | * @return the rectangle that you painted to. | 821 | * @return the rectangle that you painted to. |
822 | */ | 822 | */ |
823 | virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); | 823 | virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); |
824 | 824 | ||
825 | /** | 825 | /** |
826 | * Paint the drag rectangle. If painter is null, don't try to :) | 826 | * Paint the drag rectangle. If painter is null, don't try to :) |
827 | * | 827 | * |
828 | * | 828 | * |
829 | * @return the rectangle that you painted to. | 829 | * @return the rectangle that you painted to. |
830 | */ | 830 | */ |
831 | virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); | 831 | virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); |
832 | 832 | ||
833 | /** | 833 | /** |
834 | * This method calls @ref dragObject() and starts the drag. | 834 | * This method calls @ref dragObject() and starts the drag. |
835 | * | 835 | * |
836 | * Reimplement it to do fancy stuff like setting a pixmap or | 836 | * Reimplement it to do fancy stuff like setting a pixmap or |
837 | * using a non-default DragMode | 837 | * using a non-default DragMode |
838 | */ | 838 | */ |
839 | virtual void startDrag(); | 839 | virtual void startDrag(); |
840 | 840 | ||
841 | /** | 841 | /** |
842 | * Reimplemented for internal reasons. | 842 | * Reimplemented for internal reasons. |
843 | * Further reimplementations should call this function or else | 843 | * Further reimplementations should call this function or else |
844 | * some features may not work correctly. | 844 | * some features may not work correctly. |
845 | * | 845 | * |
846 | * The API is unaffected. | 846 | * The API is unaffected. |
847 | */ | 847 | */ |
848 | virtual void keyPressEvent (QKeyEvent*); | 848 | virtual void keyPressEvent (QKeyEvent*); |
849 | 849 | ||
850 | /** | 850 | /** |
851 | * Reimplemented for internal reasons. | 851 | * Reimplemented for internal reasons. |
852 | * Further reimplementations should call this function or else | 852 | * Further reimplementations should call this function or else |
853 | * some features may not work correctly. | 853 | * some features may not work correctly. |
854 | * | 854 | * |
855 | * The API is unaffected. | 855 | * The API is unaffected. |
856 | */ | 856 | */ |
857 | virtual void viewportPaintEvent(QPaintEvent*); | 857 | virtual void viewportPaintEvent(QPaintEvent*); |
858 | 858 | ||
859 | /** | 859 | /** |
860 | * In FileManager selection mode: explicitely activate the mode | 860 | * In FileManager selection mode: explicitely activate the mode |
861 | * in which the current item is automatically selected. | 861 | * in which the current item is automatically selected. |
862 | */ | 862 | */ |
863 | void activateAutomaticSelection(); | 863 | void activateAutomaticSelection(); |
864 | /** | 864 | /** |
865 | * In FileManager selection mode: explicitely deactivate the mode | 865 | * In FileManager selection mode: explicitely deactivate the mode |
866 | * in which the current item is automatically selected. | 866 | * in which the current item is automatically selected. |
867 | */ | 867 | */ |
868 | void deactivateAutomaticSelection(); | 868 | void deactivateAutomaticSelection(); |
869 | /** | 869 | /** |
870 | * In FileManager selection mode: return whether it is currently in the mode | 870 | * In FileManager selection mode: return whether it is currently in the mode |
871 | * where the current item is selected automatically. | 871 | * where the current item is selected automatically. |
872 | * Returns false if items were selected explicitely, e.g. using the mouse. | 872 | * Returns false if items were selected explicitely, e.g. using the mouse. |
873 | */ | 873 | */ |
874 | bool automaticSelection() const; | 874 | bool automaticSelection() const; |
875 | 875 | ||
876 | /** | 876 | /** |
877 | * Reimplemented for setFullWidth() | 877 | * Reimplemented for setFullWidth() |
878 | */ | 878 | */ |
879 | virtual void viewportResizeEvent(QResizeEvent* e); | 879 | virtual void viewportResizeEvent(QResizeEvent* e); |
880 | 880 | ||
881 | protected slots: | 881 | protected slots: |
882 | /** | 882 | /** |
883 | * Update internal settings whenever the global ones change. | 883 | * Update internal settings whenever the global ones change. |
884 | * @internal | 884 | * @internal |
885 | */ | 885 | */ |
886 | void slotSettingsChanged(int); | 886 | void slotSettingsChanged(int); |
887 | 887 | ||
888 | void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); | 888 | void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); |
889 | void doneEditing(QListViewItem *item, int row); | 889 | void doneEditing(QListViewItem *item, int row); |
890 | 890 | ||
891 | /** | 891 | /** |
892 | * Repaint the rect where I was drawing the drop line. | 892 | * Repaint the rect where I was drawing the drop line. |
893 | */ | 893 | */ |
894 | void cleanDropVisualizer(); | 894 | void cleanDropVisualizer(); |
895 | 895 | ||
896 | /** | 896 | /** |
897 | * Repaint the rect where I was drawing the drop rectangle. | 897 | * Repaint the rect where I was drawing the drop rectangle. |
898 | */ | 898 | */ |
899 | void cleanItemHighlighter(); | 899 | void cleanItemHighlighter(); |
900 | 900 | ||
901 | /** | 901 | /** |
902 | * Emit the @ref contextMenu signal. This slot is for mouse actions. | 902 | * Emit the @ref contextMenu signal. This slot is for mouse actions. |
903 | */ | 903 | */ |
904 | void emitContextMenu (QListViewItem*, const QPoint&, int); | 904 | void emitContextMenu (QListViewItem*, const QPoint&, int); |
905 | 905 | ||
906 | /** | 906 | /** |
907 | * Emit the @ref #contextMenu signal. This slot is for key presses. | 907 | * Emit the @ref #contextMenu signal. This slot is for key presses. |
908 | */ | 908 | */ |
909 | void emitContextMenu (KListView*, QListViewItem*); | 909 | void emitContextMenu (KListView*, QListViewItem*); |
910 | 910 | ||
911 | /** | 911 | /** |
912 | * Accessory slot for AutoSelect | 912 | * Accessory slot for AutoSelect |
913 | * @internal | 913 | * @internal |
914 | */ | 914 | */ |
915 | void slotOnItem( QListViewItem *item ); | 915 | void slotOnItem( QListViewItem *item ); |
916 | 916 | ||
917 | /** | 917 | /** |
918 | * Accessory slot for AutoSelect/ChangeCursorOverItem | 918 | * Accessory slot for AutoSelect/ChangeCursorOverItem |
919 | * @internal | 919 | * @internal |
920 | */ | 920 | */ |
921 | void slotOnViewport(); | 921 | void slotOnViewport(); |
922 | 922 | ||
923 | /** | 923 | /** |
924 | * Process AutoSelection. | 924 | * Process AutoSelection. |
925 | * @internal | 925 | * @internal |
926 | */ | 926 | */ |
927 | void slotAutoSelect(); | 927 | void slotAutoSelect(); |
928 | 928 | ||
929 | void slotDragExpand(); | 929 | void slotDragExpand(); |
930 | 930 | ||
931 | /** | 931 | /** |
932 | * Reacts to header changes in full width mode | 932 | * Reacts to header changes in full width mode |
933 | * @internal | 933 | * @internal |
934 | */ | 934 | */ |
935 | void slotHeaderChanged(); | 935 | void slotHeaderChanged(); |
936 | 936 | ||
937 | protected: | 937 | protected: |
938 | /** | 938 | /** |
939 | * Handle dropEvent when itemsMovable() is set to true. | 939 | * Handle dropEvent when itemsMovable() is set to true. |
940 | */ | 940 | */ |
941 | virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); | 941 | virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); |
942 | 942 | ||
943 | /** | 943 | /** |
944 | * Where is the nearest QListViewItem that I'm going to drop? | 944 | * Where is the nearest QListViewItem that I'm going to drop? |
945 | * | 945 | * |
946 | * FIXME KDE 4.0: Make this method const so it can be called from an | 946 | * FIXME KDE 4.0: Make this method const so it can be called from an |
947 | * acceptDrag method without ugly casts | 947 | * acceptDrag method without ugly casts |
948 | */ | 948 | */ |
949 | virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); | 949 | virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); |
950 | 950 | ||
951 | /** | 951 | /** |
952 | * A special keyPressEvent (for FileManager selection mode). | 952 | * A special keyPressEvent (for FileManager selection mode). |
953 | */ | 953 | */ |
954 | void fileManagerKeyPressEvent (QKeyEvent*); | 954 | void fileManagerKeyPressEvent (QKeyEvent*); |
955 | 955 | ||
956 | /** | 956 | /** |
957 | * Convert the depth of an item into its indentation in pixels | 957 | * Convert the depth of an item into its indentation in pixels |
958 | */ | 958 | */ |
959 | int depthToPixels( int depth ); | 959 | int depthToPixels( int depth ); |
960 | 960 | ||
961 | private: | 961 | private: |
962 | class Tooltip; | 962 | class Tooltip; |
963 | protected: | 963 | protected: |
964 | virtual void virtual_hook( int id, void* data ); | 964 | virtual void virtual_hook( int id, void* data ); |
965 | private: | 965 | private: |
966 | class KListViewPrivate; | 966 | class KListViewPrivate; |
967 | KListViewPrivate *d; | 967 | KListViewPrivate *d; |
968 | }; | 968 | }; |
969 | 969 | ||
970 | /** | 970 | /** |
971 | * A listview item with support for alternate background colours. It is | 971 | * A listview item with support for alternate background colours. It is |
972 | * a drop-in replacement for @ref QListViewItem | 972 | * a drop-in replacement for @ref QListViewItem |
973 | * | 973 | * |
974 | * @short listview item with alternate background colour support | 974 | * @short listview item with alternate background colour support |
975 | */ | 975 | */ |
976 | class KListViewItem : public QListViewItem | 976 | class KListViewItem : public QListViewItem |
977 | { | 977 | { |
978 | public: | 978 | public: |
979 | /** | 979 | /** |
980 | * constructors. The semantics remain as in @ref QListViewItem. | 980 | * constructors. The semantics remain as in @ref QListViewItem. |
981 | * Although they accept a @ref QListViewItem as parent, please | 981 | * Although they accept a @ref QListViewItem as parent, please |
982 | * don't mix KListViewItem (or subclasses) with QListViewItem | 982 | * don't mix KListViewItem (or subclasses) with QListViewItem |
983 | * (or subclasses). | 983 | * (or subclasses). |
984 | */ | 984 | */ |
985 | KListViewItem(QListView *parent); | 985 | KListViewItem(QListView *parent); |
986 | KListViewItem(QListViewItem *parent); | 986 | KListViewItem(QListViewItem *parent); |
987 | KListViewItem(QListView *parent, QListViewItem *after); | 987 | KListViewItem(QListView *parent, QListViewItem *after); |
988 | KListViewItem(QListViewItem *parent, QListViewItem *after); | 988 | KListViewItem(QListViewItem *parent, QListViewItem *after); |
989 | 989 | ||
990 | KListViewItem(QListView *parent, | 990 | KListViewItem(QListView *parent, |
991 | QString, QString = QString::null, | 991 | QString, QString = QString::null, |
992 | QString = QString::null, QString = QString::null, | 992 | QString = QString::null, QString = QString::null, |
993 | QString = QString::null, QString = QString::null, | 993 | QString = QString::null, QString = QString::null, |
994 | QString = QString::null, QString = QString::null); | 994 | QString = QString::null, QString = QString::null); |
995 | 995 | ||
996 | KListViewItem(QListViewItem *parent, | 996 | KListViewItem(QListViewItem *parent, |
997 | QString, QString = QString::null, | 997 | QString, QString = QString::null, |
998 | QString = QString::null, QString = QString::null, | 998 | QString = QString::null, QString = QString::null, |
999 | QString = QString::null, QString = QString::null, | 999 | QString = QString::null, QString = QString::null, |
1000 | QString = QString::null, QString = QString::null); | 1000 | QString = QString::null, QString = QString::null); |
1001 | 1001 | ||
1002 | KListViewItem(QListView *parent, QListViewItem *after, | 1002 | KListViewItem(QListView *parent, QListViewItem *after, |
1003 | QString, QString = QString::null, | 1003 | QString, QString = QString::null, |
1004 | QString = QString::null, QString = QString::null, | 1004 | QString = QString::null, QString = QString::null, |
1005 | QString = QString::null, QString = QString::null, | 1005 | QString = QString::null, QString = QString::null, |
1006 | QString = QString::null, QString = QString::null); | 1006 | QString = QString::null, QString = QString::null); |
1007 | 1007 | ||
1008 | KListViewItem(QListViewItem *parent, QListViewItem *after, | 1008 | KListViewItem(QListViewItem *parent, QListViewItem *after, |
1009 | QString, QString = QString::null, | 1009 | QString, QString = QString::null, |
1010 | QString = QString::null, QString = QString::null, | 1010 | QString = QString::null, QString = QString::null, |
1011 | QString = QString::null, QString = QString::null, | 1011 | QString = QString::null, QString = QString::null, |
1012 | QString = QString::null, QString = QString::null); | 1012 | QString = QString::null, QString = QString::null); |
1013 | 1013 | ||
1014 | virtual ~KListViewItem(); | 1014 | virtual ~KListViewItem(); |
1015 | 1015 | ||
1016 | /** | 1016 | /** |
1017 | * retuns true if this item is to be drawn with the alternate background | 1017 | * retuns true if this item is to be drawn with the alternate background |
1018 | */ | 1018 | */ |
1019 | bool isAlternate(); | 1019 | bool isAlternate(); |
1020 | /** | 1020 | /** |
1021 | * returns the background colour for this item | 1021 | * returns the background colour for this item |
1022 | */ | 1022 | */ |
1023 | const QColor &backgroundColor(); | 1023 | const QColor &backgroundColor(); |
1024 | 1024 | ||
1025 | virtual void paintCell(QPainter *p, const QColorGroup &cg, | 1025 | virtual void paintCell(QPainter *p, const QColorGroup &cg, |
1026 | int column, int width, int alignment); | 1026 | int column, int width, int alignment); |
1027 | 1027 | ||
1028 | private: | 1028 | private: |
1029 | void init(); | 1029 | void init(); |
1030 | 1030 | ||
1031 | private: | 1031 | private: |
1032 | uint m_odd : 1; | 1032 | uint m_odd : 1; |
1033 | uint m_known : 1; | 1033 | uint m_known : 1; |
1034 | uint m_unused : 30; | 1034 | uint m_unused : 30; |
1035 | }; | 1035 | }; |
1036 | 1036 | ||
1037 | #endif | 1037 | #endif |
1038 | 1038 | ||
1039 | // vim: ts=2 sw=2 et | 1039 | // vim: ts=2 sw=2 et |