summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp4
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp4
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp4
-rw-r--r--korganizer/kotodoviewitem.cpp2
-rw-r--r--korganizer/kotodoviewitem.h2
-rw-r--r--korganizer/koviewmanager.cpp2
-rw-r--r--korganizer/searchdialog.cpp22
-rw-r--r--korganizer/timespanview.cpp2
-rw-r--r--libkcal/icalformatimpl.cpp6
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp10
-rw-r--r--microkde/kcalendarsystemgregorian.cpp8
11 files changed, 31 insertions, 35 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 6fcd73f..9d8c5ce 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -1,507 +1,507 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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 <qdragobject.h> 24#include <qdragobject.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qiconview.h> 26#include <qiconview.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qregexp.h> 29#include <qregexp.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33#include <kabc/addressee.h> 33#include <kabc/addressee.h>
34#include <kconfig.h> 34#include <kconfig.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabprefs.h" 38#include "kabprefs.h"
39#include "viewmanager.h" 39#include "viewmanager.h"
40 40
41 41
42#include "kaddressbookcardview.h" 42#include "kaddressbookcardview.h"
43 43
44#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
45extern "C" { 45extern "C" {
46 void *init_libkaddrbk_cardview() 46 void *init_libkaddrbk_cardview()
47 { 47 {
48 return ( new CardViewFactory ); 48 return ( new CardViewFactory );
49 } 49 }
50} 50}
51#endif //KAB_EMBEDDED 51#endif //KAB_EMBEDDED
52 52
53//////////////////////////////// 53////////////////////////////////
54// AddresseeCardViewItem (internal class) 54// AddresseeCardViewItem (internal class)
55class AddresseeCardViewItem : public CardViewItem 55class AddresseeCardViewItem : public CardViewItem
56{ 56{
57 public: 57 public:
58 AddresseeCardViewItem(const KABC::Field::List &fields, 58 AddresseeCardViewItem(const KABC::Field::List &fields,
59 bool showEmptyFields, 59 bool showEmptyFields,
60 KABC::AddressBook *doc, const KABC::Addressee &a, 60 KABC::AddressBook *doc, const KABC::Addressee &a,
61 CardView *parent) 61 CardView *parent)
62 : CardViewItem(parent, a.formattedName()), 62 : CardViewItem(parent, a.formattedName()),
63 mFields( fields ), mShowEmptyFields(showEmptyFields), 63 mFields( fields ), mShowEmptyFields(showEmptyFields),
64 mDocument(doc), mAddressee(a) 64 mDocument(doc), mAddressee(a)
65 { 65 {
66 if ( mFields.isEmpty() ) { 66 if ( mFields.isEmpty() ) {
67 mFields = KABC::Field::defaultFields(); 67 mFields = KABC::Field::defaultFields();
68 } 68 }
69 refresh(); 69 refresh();
70 } 70 }
71 71
72 const KABC::Addressee &addressee() const { return mAddressee; } 72 const KABC::Addressee &addressee() const { return mAddressee; }
73 73
74 void refresh() 74 void refresh()
75 { 75 {
76 // Update our addressee, since it may have changed elsewhere 76 // Update our addressee, since it may have changed elsewhere
77 mAddressee = mDocument->findByUid(mAddressee.uid()); 77 mAddressee = mDocument->findByUid(mAddressee.uid());
78 78
79 if (!mAddressee.isEmpty()) 79 if (!mAddressee.isEmpty())
80 { 80 {
81 clearFields(); 81 clearFields();
82 82
83 // Try all the selected fields until we find one with text. 83 // Try all the selected fields until we find one with text.
84 // This will limit the number of unlabeled icons in the view 84 // This will limit the number of unlabeled icons in the view
85 KABC::Field::List::Iterator iter; 85 KABC::Field::List::Iterator iter;
86 for (iter = mFields.begin(); iter != mFields.end(); ++iter) 86 for (iter = mFields.begin(); iter != mFields.end(); ++iter)
87 { 87 {
88 // insert empty fields or not? not doing so saves a bit of memory and CPU 88 // insert empty fields or not? not doing so saves a bit of memory and CPU
89 // (during geometry calculations), but prevents having equally 89 // (during geometry calculations), but prevents having equally
90 // wide label columns in all cards, unless CardViewItem/CardView search 90 // wide label columns in all cards, unless CardViewItem/CardView search
91 // globally for the widest label. (anders) 91 // globally for the widest label. (anders)
92 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) 92 //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty())
93 insertField((*iter)->label(), (*iter)->value( mAddressee )); 93 insertField((*iter)->label(), (*iter)->value( mAddressee ));
94 } 94 }
95 95
96 // We might want to make this the first field. hmm... -mpilone 96 // We might want to make this the first field. hmm... -mpilone
97 setCaption( mAddressee.realName() ); 97 setCaption( mAddressee.realName() );
98 } 98 }
99 } 99 }
100 100
101 private: 101 private:
102 KABC::Field::List mFields; 102 KABC::Field::List mFields;
103 bool mShowEmptyFields; 103 bool mShowEmptyFields;
104 KABC::AddressBook *mDocument; 104 KABC::AddressBook *mDocument;
105 KABC::Addressee mAddressee; 105 KABC::Addressee mAddressee;
106}; 106};
107 107
108/////////////////////////////// 108///////////////////////////////
109// AddresseeCardView 109// AddresseeCardView
110 110
111AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) 111AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
112 : CardView(parent, name) 112 : CardView(parent, name)
113{ 113{
114 setAcceptDrops(true); 114 setAcceptDrops(true);
115} 115}
116 116
117AddresseeCardView::~AddresseeCardView() 117AddresseeCardView::~AddresseeCardView()
118{ 118{
119} 119}
120void AddresseeCardView::printMe() 120void AddresseeCardView::printMe()
121{ 121{
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 QPrinter printer; 123 QPrinter printer;
124 if (!printer.setup() ) 124 if (!printer.setup() )
125 return; 125 return;
126 QPainter p; 126 QPainter p;
127 p.begin ( &printer ); 127 p.begin ( &printer );
128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 128 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
129 float dx, dy; 129 float dx, dy;
130 int wid = (m.width() * 9)/10; 130 int wid = (m.width() * 9)/10;
131 dx = (float) wid/(float)contentsWidth (); 131 dx = (float) wid/(float)contentsWidth ();
132 dy = (float)(m.height()) / (float)contentsHeight (); 132 dy = (float)(m.height()) / (float)contentsHeight ();
133 float scale; 133 float scale;
134 // scale to fit the width or height of the paper 134 // scale to fit the width or height of the paper
135 if ( dx < dy ) 135 if ( dx < dy )
136 scale = dx; 136 scale = dx;
137 else 137 else
138 scale = dy; 138 scale = dy;
139 p.translate( m.width()/10,0 ); 139 p.translate( m.width()/10,0 );
140 p.scale( scale, scale ); 140 p.scale( scale, scale );
141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 141 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
142 p.end(); 142 p.end();
143 repaint(); 143 repaint();
144#endif 144#endif
145} 145}
146 146
147 147
148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) 148void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
149{ 149{
150#ifndef KAB_EMBEDDED 150#ifndef KAB_EMBEDDED
151 if (QTextDrag::canDecode(e)) 151 if (QTextDrag::canDecode(e))
152 e->accept(); 152 e->accept();
153#else //KAB_EMBEDDED 153#else //KAB_EMBEDDED
154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); 154qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
155#endif //KAB_EMBEDDED 155#endif //KAB_EMBEDDED
156} 156}
157 157
158void AddresseeCardView::dropEvent(QDropEvent *e) 158void AddresseeCardView::dropEvent(QDropEvent *e)
159{ 159{
160 emit addresseeDropped(e); 160 emit addresseeDropped(e);
161} 161}
162 162
163void AddresseeCardView::startDrag() 163void AddresseeCardView::startDrag()
164{ 164{
165 emit startAddresseeDrag(); 165 emit startAddresseeDrag();
166} 166}
167 167
168 168
169/////////////////////////////// 169///////////////////////////////
170// KAddressBookCardView 170// KAddressBookCardView
171 171
172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 172KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
173 QWidget *parent, const char *name ) 173 QWidget *parent, const char *name )
174 : KAddressBookView( ab, parent, name ) 174 : KAddressBookView( ab, parent, name )
175{ 175{
176 mShowEmptyFields = false; 176 mShowEmptyFields = false;
177 177
178 // Init the GUI 178 // Init the GUI
179 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 179 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
180 180
181 mCardView = new AddresseeCardView(viewWidget(), "mCardView"); 181 mCardView = new AddresseeCardView(viewWidget(), "mCardView");
182 mCardView->setSelectionMode(CardView::Extended); 182 mCardView->setSelectionMode(CardView::Extended);
183 layout->addWidget(mCardView); 183 layout->addWidget(mCardView);
184 184
185 // Connect up the signals 185 // Connect up the signals
186 connect(mCardView, SIGNAL(executed(CardViewItem *)), 186 connect(mCardView, SIGNAL(executed(CardViewItem *)),
187 this, SLOT(addresseeExecuted(CardViewItem *))); 187 this, SLOT(addresseeExecuted(CardViewItem *)));
188 connect(mCardView, SIGNAL(selectionChanged()), 188 connect(mCardView, SIGNAL(selectionChanged()),
189 this, SLOT(addresseeSelected())); 189 this, SLOT(addresseeSelected()));
190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), 190 connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
191 this, SIGNAL(dropped(QDropEvent*))); 191 this, SIGNAL(dropped(QDropEvent*)));
192 connect(mCardView, SIGNAL(startAddresseeDrag()), 192 connect(mCardView, SIGNAL(startAddresseeDrag()),
193 this, SIGNAL(startDrag())); 193 this, SIGNAL(startDrag()));
194 connect(this, SIGNAL(printView()), 194 connect(this, SIGNAL(printView()),
195 mCardView , SLOT(printMe())); 195 mCardView , SLOT(printMe()));
196} 196}
197 197
198KAddressBookCardView::~KAddressBookCardView() 198KAddressBookCardView::~KAddressBookCardView()
199{ 199{
200} 200}
201void KAddressBookCardView::setFocusAV() 201void KAddressBookCardView::setFocusAV()
202{ 202{
203 if ( mCardView ) 203 if ( mCardView )
204 mCardView->setFocus(); 204 mCardView->setFocus();
205 205
206} 206}
207void KAddressBookCardView::scrollUP() 207void KAddressBookCardView::scrollUP()
208{ 208{
209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 209 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
210 QApplication::postEvent( mCardView, ev ); 210 QApplication::postEvent( mCardView, ev );
211 211
212} 212}
213void KAddressBookCardView::scrollDOWN() 213void KAddressBookCardView::scrollDOWN()
214{ 214{
215 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 215 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
216 QApplication::postEvent( mCardView, ev ); 216 QApplication::postEvent( mCardView, ev );
217} 217}
218void KAddressBookCardView::readConfig(KConfig *config) 218void KAddressBookCardView::readConfig(KConfig *config)
219{ 219{
220 KAddressBookView::readConfig(config); 220 KAddressBookView::readConfig(config);
221 221
222 // costum colors? 222 // costum colors?
223 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 223 if ( config->readBoolEntry( "EnableCustomColors", false ) )
224 { 224 {
225 QPalette p( mCardView->palette() ); 225 QPalette p( mCardView->palette() );
226 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 226 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
227 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 227 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
228 c = p.color(QPalette::Normal, QColorGroup::Text ); 228 c = p.color(QPalette::Normal, QColorGroup::Text );
229 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 229 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
230 c = p.color(QPalette::Normal, QColorGroup::Button ); 230 c = p.color(QPalette::Normal, QColorGroup::Button );
231 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 231 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
232 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 232 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
233 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 233 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 234 c = p.color(QPalette::Normal, QColorGroup::Highlight );
235 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 235 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 236 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
237 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
238 mCardView->viewport()->setPalette( p ); 238 mCardView->viewport()->setPalette( p );
239 } 239 }
240 else 240 else
241 { 241 {
242 // needed if turned off during a session. 242 // needed if turned off during a session.
243 mCardView->viewport()->setPalette( mCardView->palette() ); 243 mCardView->viewport()->setPalette( mCardView->palette() );
244 } 244 }
245 245
246 //custom fonts? 246 //custom fonts?
247 QFont f( font() ); 247 QFont f( font() );
248 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 248 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
249 { 249 {
250 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 250 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
251 f.setBold( true ); 251 f.setBold( true );
252 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 252 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
253 } 253 }
254 else 254 else
255 { 255 {
256 mCardView->setFont( f ); 256 mCardView->setFont( f );
257 f.setBold( true ); 257 f.setBold( true );
258 mCardView->setHeaderFont( f ); 258 mCardView->setHeaderFont( f );
259 } 259 }
260 260
261 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 261 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
262 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 262 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
263 true)); 263 true));
264 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 264 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
265 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 265 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
266 266
267 mCardView->setShowEmptyFields( mShowEmptyFields ); 267 mCardView->setShowEmptyFields( mShowEmptyFields );
268 268
269 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 269 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
270 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 270 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
271 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 271 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
272 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 272 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
273 273
274#if 0 274#if 0
275 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 275 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
276 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 276 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
277 this, SLOT(addresseeExecuted(CardViewItem *))); 277 this, SLOT(addresseeExecuted(CardViewItem *)));
278 278
279 if (KABPrefs::instance()->mHonorSingleClick) 279 if (KABPrefs::instance()->mHonorSingleClick)
280 connect(mCardView, SIGNAL(executed(CardViewItem *)), 280 connect(mCardView, SIGNAL(executed(CardViewItem *)),
281 this, SLOT(addresseeExecuted(CardViewItem *))); 281 this, SLOT(addresseeExecuted(CardViewItem *)));
282 else 282 else
283 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 283 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
284 this, SLOT(addresseeExecuted(CardViewItem *))); 284 this, SLOT(addresseeExecuted(CardViewItem *)));
285#endif 285#endif
286 286
287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), 287 connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
288 this, SLOT(addresseeExecuted(CardViewItem *))); 288 this, SLOT(addresseeExecuted(CardViewItem *)));
289} 289}
290 290
291void KAddressBookCardView::writeConfig( KConfig *config ) 291void KAddressBookCardView::writeConfig( KConfig *config )
292{ 292{
293 config->writeEntry( "ItemWidth", mCardView->itemWidth() ); 293 config->writeEntry( "ItemWidth", mCardView->itemWidth() );
294 KAddressBookView::writeConfig( config ); 294 KAddressBookView::writeConfig( config );
295} 295}
296void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) 296void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
297{ 297{
298 mCardView->clear(); 298 mCardView->clear();
299 if ( s.isEmpty() || s == "*" ) { 299 if ( s.isEmpty() || s == "*" ) {
300 refresh(); 300 refresh();
301 return; 301 return;
302 } 302 }
303 QString pattern = s.lower()+"*"; 303 QString pattern = s.lower()+"*";
304 QRegExp re; 304 QRegExp re;
305 re.setWildcard(true); // most people understand these better. 305 re.setWildcard(true); // most people understand these better.
306 re.setCaseSensitive(false); 306 re.setCaseSensitive(false);
307 re.setPattern( pattern ); 307 re.setPattern( pattern );
308 if (!re.isValid()) 308 if (!re.isValid())
309 return; 309 return;
310 mCardView->viewport()->setUpdatesEnabled( false ); 310 mCardView->viewport()->setUpdatesEnabled( false );
311 KABC::Addressee::List addresseeList = addressees(); 311 KABC::Addressee::List addresseeList = addressees();
312 KABC::Addressee::List::Iterator it; 312 KABC::Addressee::List::Iterator it;
313 if ( field ) { 313 if ( field ) {
314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 314 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 315 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
316 continue; 316 continue;
317#if QT_VERSION >= 300 317#if QT_VERSION >= 0x030000
318 if (re.search(field->value( *it ).lower()) != -1) 318 if (re.search(field->value( *it ).lower()) != -1)
319#else 319#else
320 if (re.match(field->value( *it ).lower()) != -1) 320 if (re.match(field->value( *it ).lower()) != -1)
321#endif 321#endif
322 new AddresseeCardViewItem(fields(), mShowEmptyFields, 322 new AddresseeCardViewItem(fields(), mShowEmptyFields,
323 addressBook(), *it, mCardView); 323 addressBook(), *it, mCardView);
324 324
325 } 325 }
326 } else { 326 } else {
327 KABC::Field::List fieldList = allFields(); 327 KABC::Field::List fieldList = allFields();
328 KABC::Field::List::ConstIterator fieldIt; 328 KABC::Field::List::ConstIterator fieldIt;
329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 329 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 330 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
331 continue; 331 continue;
332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 332 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
333#if QT_VERSION >= 300 333#if QT_VERSION >= 0x030000
334 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 334 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
335#else 335#else
336 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 336 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
337#endif 337#endif
338 { 338 {
339 new AddresseeCardViewItem(fields(), mShowEmptyFields, 339 new AddresseeCardViewItem(fields(), mShowEmptyFields,
340 addressBook(), *it, mCardView); 340 addressBook(), *it, mCardView);
341 break; 341 break;
342 } 342 }
343 } 343 }
344 } 344 }
345 } 345 }
346 mCardView->viewport()->setUpdatesEnabled( true ); 346 mCardView->viewport()->setUpdatesEnabled( true );
347 mCardView->viewport()->update(); 347 mCardView->viewport()->update();
348 if ( mCardView->firstItem() ) { 348 if ( mCardView->firstItem() ) {
349 mCardView->setCurrentItem ( mCardView->firstItem() ); 349 mCardView->setCurrentItem ( mCardView->firstItem() );
350 mCardView->setSelected ( mCardView->firstItem() , true ); 350 mCardView->setSelected ( mCardView->firstItem() , true );
351 } 351 }
352 else 352 else
353 emit selected(QString::null); 353 emit selected(QString::null);
354} 354}
355QStringList KAddressBookCardView::selectedUids() 355QStringList KAddressBookCardView::selectedUids()
356{ 356{
357 QStringList uidList; 357 QStringList uidList;
358 CardViewItem *item; 358 CardViewItem *item;
359 AddresseeCardViewItem *aItem; 359 AddresseeCardViewItem *aItem;
360 360
361 for (item = mCardView->firstItem(); item; item = item->nextItem()) 361 for (item = mCardView->firstItem(); item; item = item->nextItem())
362 { 362 {
363 if (item->isSelected()) 363 if (item->isSelected())
364 { 364 {
365#ifndef KAB_EMBEDDED 365#ifndef KAB_EMBEDDED
366 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 366 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
367#else //KAB_EMBEDDED 367#else //KAB_EMBEDDED
368 aItem = (AddresseeCardViewItem*)(item); 368 aItem = (AddresseeCardViewItem*)(item);
369#endif //KAB_EMBEDDED 369#endif //KAB_EMBEDDED
370 if (aItem) 370 if (aItem)
371 uidList << aItem->addressee().uid(); 371 uidList << aItem->addressee().uid();
372 } 372 }
373 } 373 }
374 374
375 return uidList; 375 return uidList;
376} 376}
377 377
378void KAddressBookCardView::refresh(QString uid) 378void KAddressBookCardView::refresh(QString uid)
379{ 379{
380 CardViewItem *item; 380 CardViewItem *item;
381 AddresseeCardViewItem *aItem; 381 AddresseeCardViewItem *aItem;
382 382
383 if (uid.isNull()) 383 if (uid.isNull())
384 { 384 {
385 // Rebuild the view 385 // Rebuild the view
386 mCardView->viewport()->setUpdatesEnabled( false ); 386 mCardView->viewport()->setUpdatesEnabled( false );
387 mCardView->clear(); 387 mCardView->clear();
388 388
389 KABC::Addressee::List addresseeList = addressees(); 389 KABC::Addressee::List addresseeList = addressees();
390 KABC::Addressee::List::Iterator iter; 390 KABC::Addressee::List::Iterator iter;
391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 391 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
392 { 392 {
393 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 393 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
394 continue; 394 continue;
395 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 395 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
396 addressBook(), *iter, mCardView); 396 addressBook(), *iter, mCardView);
397 } 397 }
398 mCardView->viewport()->setUpdatesEnabled( true ); 398 mCardView->viewport()->setUpdatesEnabled( true );
399 mCardView->viewport()->update(); 399 mCardView->viewport()->update();
400 400
401 // by default nothing is selected 401 // by default nothing is selected
402 emit selected(QString::null); 402 emit selected(QString::null);
403 } 403 }
404 else 404 else
405 { 405 {
406 // Try to find the one to refresh 406 // Try to find the one to refresh
407 bool found = false; 407 bool found = false;
408 for (item = mCardView->firstItem(); item && !found; 408 for (item = mCardView->firstItem(); item && !found;
409 item = item->nextItem()) 409 item = item->nextItem())
410 { 410 {
411#ifndef KAB_EMBEDDED 411#ifndef KAB_EMBEDDED
412 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 412 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
413#else //KAB_EMBEDDED 413#else //KAB_EMBEDDED
414 aItem = (AddresseeCardViewItem*)(item); 414 aItem = (AddresseeCardViewItem*)(item);
415#endif //KAB_EMBEDDED 415#endif //KAB_EMBEDDED
416 416
417 if ((aItem) && (aItem->addressee().uid() == uid)) 417 if ((aItem) && (aItem->addressee().uid() == uid))
418 { 418 {
419 aItem->refresh(); 419 aItem->refresh();
420 found = true; 420 found = true;
421 } 421 }
422 } 422 }
423 } 423 }
424} 424}
425 425
426void KAddressBookCardView::setSelected(QString uid, bool selected) 426void KAddressBookCardView::setSelected(QString uid, bool selected)
427{ 427{
428 CardViewItem *item; 428 CardViewItem *item;
429 AddresseeCardViewItem *aItem; 429 AddresseeCardViewItem *aItem;
430 430
431 if (uid.isNull()) 431 if (uid.isNull())
432 { 432 {
433 mCardView->selectAll(selected); 433 mCardView->selectAll(selected);
434 } 434 }
435 else 435 else
436 { 436 {
437 bool found = false; 437 bool found = false;
438 for (item = mCardView->firstItem(); item && !found; 438 for (item = mCardView->firstItem(); item && !found;
439 item = item->nextItem()) 439 item = item->nextItem())
440 { 440 {
441#ifndef KAB_EMBEDDED 441#ifndef KAB_EMBEDDED
442 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 442 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
443#else //KAB_EMBEDDED 443#else //KAB_EMBEDDED
444 aItem = (AddresseeCardViewItem*)(item); 444 aItem = (AddresseeCardViewItem*)(item);
445#endif //KAB_EMBEDDED 445#endif //KAB_EMBEDDED
446 446
447 if ((aItem) && (aItem->addressee().uid() == uid)) 447 if ((aItem) && (aItem->addressee().uid() == uid))
448 { 448 {
449 mCardView->setSelected(aItem, selected); 449 mCardView->setSelected(aItem, selected);
450 mCardView->ensureItemVisible(item); 450 mCardView->ensureItemVisible(item);
451 found = true; 451 found = true;
452 } 452 }
453 } 453 }
454 } 454 }
455} 455}
456 456
457//US added an additional method without parameter 457//US added an additional method without parameter
458void KAddressBookCardView::setSelected() 458void KAddressBookCardView::setSelected()
459{ 459{
460 setSelected(QString::null, true); 460 setSelected(QString::null, true);
461} 461}
462 462
463void KAddressBookCardView::addresseeExecuted(CardViewItem *item) 463void KAddressBookCardView::addresseeExecuted(CardViewItem *item)
464{ 464{
465#ifndef KAB_EMBEDDED 465#ifndef KAB_EMBEDDED
466 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); 466 AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item);
467#else //KAB_EMBEDDED 467#else //KAB_EMBEDDED
468 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); 468 AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item);
469#endif //KAB_EMBEDDED 469#endif //KAB_EMBEDDED
470 if (aItem) 470 if (aItem)
471 { 471 {
472 //kdDebug()<<"... even has a valid item:)"<<endl; 472 //kdDebug()<<"... even has a valid item:)"<<endl;
473 emit executed(aItem->addressee().uid()); 473 emit executed(aItem->addressee().uid());
474 } 474 }
475} 475}
476 476
477void KAddressBookCardView::addresseeSelected() 477void KAddressBookCardView::addresseeSelected()
478{ 478{
479 CardViewItem *item; 479 CardViewItem *item;
480 AddresseeCardViewItem *aItem; 480 AddresseeCardViewItem *aItem;
481 481
482 bool found = false; 482 bool found = false;
483 for (item = mCardView->firstItem(); item && !found; 483 for (item = mCardView->firstItem(); item && !found;
484 item = item->nextItem()) 484 item = item->nextItem())
485 { 485 {
486 if (item->isSelected()) 486 if (item->isSelected())
487 { 487 {
488#ifndef KAB_EMBEDDED 488#ifndef KAB_EMBEDDED
489 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 489 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
490#else //KAB_EMBEDDED 490#else //KAB_EMBEDDED
491 aItem = (AddresseeCardViewItem*)(item); 491 aItem = (AddresseeCardViewItem*)(item);
492#endif //KAB_EMBEDDED 492#endif //KAB_EMBEDDED
493 if ( aItem ) 493 if ( aItem )
494 { 494 {
495 emit selected(aItem->addressee().uid()); 495 emit selected(aItem->addressee().uid());
496 found = true; 496 found = true;
497 } 497 }
498 } 498 }
499 } 499 }
500 500
501 if (!found) 501 if (!found)
502 emit selected(QString::null); 502 emit selected(QString::null);
503 503
504} 504}
505#ifndef KAB_EMBEDDED 505#ifndef KAB_EMBEDDED
506#include "kaddressbookcardview.moc" 506#include "kaddressbookcardview.moc"
507#endif //KAB_EMBEDDED 507#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index ef0a23a..fb53215 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -1,456 +1,456 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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#ifndef KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <qiconview.h> 25#include <qiconview.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27 27
28#include <kabc/addressee.h> 28#include <kabc/addressee.h>
29#include <kconfig.h> 29#include <kconfig.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#else //KAB_EMBEDDED 35#else //KAB_EMBEDDED
36#endif //KAB_EMBEDDED 36#endif //KAB_EMBEDDED
37 37
38#include <kabc/addressbook.h> 38#include <kabc/addressbook.h>
39#include "kabprefs.h" 39#include "kabprefs.h"
40#include "viewmanager.h" 40#include "viewmanager.h"
41#include "kaddressbookiconview.h" 41#include "kaddressbookiconview.h"
42#include <qlayout.h> 42#include <qlayout.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qapplication.h> 44#include <qapplication.h>
45#include <kglobal.h> 45#include <kglobal.h>
46/*US transfered to the headerfile 46/*US transfered to the headerfile
47class IconViewFactory : public ViewFactory 47class IconViewFactory : public ViewFactory
48{ 48{
49 public: 49 public:
50 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) 50 KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
51 { 51 {
52 return new KAddressBookIconView( ab, parent, name ); 52 return new KAddressBookIconView( ab, parent, name );
53 } 53 }
54 54
55 QString type() const { return "Icon"; } 55 QString type() const { return "Icon"; }
56 56
57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } 57 QString description() const { return i18n( "Icons represent contacts. Very simple view." ); }
58}; 58};
59 59
60*/ 60*/
61 61
62extern "C" { 62extern "C" {
63 void *init_libkaddrbk_iconview() 63 void *init_libkaddrbk_iconview()
64 { 64 {
65 return ( new IconViewFactory ); 65 return ( new IconViewFactory );
66 } 66 }
67} 67}
68 68
69//////////////////////////////// 69////////////////////////////////
70// AddresseeIconView (internal class) 70// AddresseeIconView (internal class)
71#ifndef KAB_EMBEDDED 71#ifndef KAB_EMBEDDED
72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 72AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
73 : KIconView(parent, name) 73 : KIconView(parent, name)
74#else //KAB_EMBEDDED 74#else //KAB_EMBEDDED
75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) 75AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name)
76 : QIconView(parent, name) 76 : QIconView(parent, name)
77#endif //KAB_EMBEDDED 77#endif //KAB_EMBEDDED
78 78
79{ 79{
80 setSelectionMode( QIconView::Extended ); 80 setSelectionMode( QIconView::Extended );
81 setResizeMode( QIconView::Adjust ); 81 setResizeMode( QIconView::Adjust );
82 setWordWrapIconText( true ); 82 setWordWrapIconText( true );
83 setGridX( 100 ); 83 setGridX( 100 );
84 setItemsMovable(false); 84 setItemsMovable(false);
85 setSorting(true, true); 85 setSorting(true, true);
86 86
87 87
88//US ??? setMode( KIconView::Select ); 88//US ??? setMode( KIconView::Select );
89 89
90#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
91 91
92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), 92 connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)),
93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); 93 this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&)));
94#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
95} 95}
96 96
97AddresseeIconView::~AddresseeIconView() 97AddresseeIconView::~AddresseeIconView()
98{ 98{
99} 99}
100 100
101 101
102void AddresseeIconView::itemDropped(QDropEvent *e, 102void AddresseeIconView::itemDropped(QDropEvent *e,
103 const QValueList<QIconDragItem> &) 103 const QValueList<QIconDragItem> &)
104{ 104{
105 emit addresseeDropped(e); 105 emit addresseeDropped(e);
106} 106}
107 107
108QDragObject *AddresseeIconView::dragObject() 108QDragObject *AddresseeIconView::dragObject()
109{ 109{
110 emit startAddresseeDrag(); 110 emit startAddresseeDrag();
111 111
112 // We never want IconView to start the drag 112 // We never want IconView to start the drag
113 return 0; 113 return 0;
114} 114}
115//////////////////////////////// 115////////////////////////////////
116// AddresseeIconViewItem (internal class) 116// AddresseeIconViewItem (internal class)
117#ifndef KAB_EMBEDDED 117#ifndef KAB_EMBEDDED
118class AddresseeIconViewItem : public KIconViewItem 118class AddresseeIconViewItem : public KIconViewItem
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120class AddresseeIconViewItem : public QIconViewItem 120class AddresseeIconViewItem : public QIconViewItem
121#endif //KAB_EMBEDDED 121#endif //KAB_EMBEDDED
122{ 122{
123 public: 123 public:
124#ifndef KAB_EMBEDDED 124#ifndef KAB_EMBEDDED
125 AddresseeIconViewItem(const KABC::Field::List &fields, 125 AddresseeIconViewItem(const KABC::Field::List &fields,
126 KABC::AddressBook *doc, const KABC::Addressee &a, 126 KABC::AddressBook *doc, const KABC::Addressee &a,
127 QIconView *parent) 127 QIconView *parent)
128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 128 : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
129#else //KAB_EMBEDDED 129#else //KAB_EMBEDDED
130 AddresseeIconViewItem(const KABC::Field::List &fields, 130 AddresseeIconViewItem(const KABC::Field::List &fields,
131 KABC::AddressBook *doc, const KABC::Addressee &a, 131 KABC::AddressBook *doc, const KABC::Addressee &a,
132 QIconView *parent) 132 QIconView *parent)
133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) 133 : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a)
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 { 135 {
136 if ( mFields.isEmpty() ) { 136 if ( mFields.isEmpty() ) {
137 mFields = KABC::Field::defaultFields(); 137 mFields = KABC::Field::defaultFields();
138 } 138 }
139 refresh(); 139 refresh();
140 } 140 }
141 141
142 const KABC::Addressee &addressee() const { return mAddressee; } 142 const KABC::Addressee &addressee() const { return mAddressee; }
143 143
144 void refresh() 144 void refresh()
145 { 145 {
146 // Update our addressee, since it may have changed elsewhere 146 // Update our addressee, since it may have changed elsewhere
147 mAddressee = mDocument->findByUid(mAddressee.uid()); 147 mAddressee = mDocument->findByUid(mAddressee.uid());
148 148
149 if (!mAddressee.isEmpty()) 149 if (!mAddressee.isEmpty())
150 setText( mAddressee.givenName() + " " + mAddressee.familyName() ); 150 setText( mAddressee.givenName() + " " + mAddressee.familyName() );
151 151
152 QPixmap icon; 152 QPixmap icon;
153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); 153 QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) );
154 KABC::Picture pic = mAddressee.photo(); 154 KABC::Picture pic = mAddressee.photo();
155 if ( pic.data().isNull() ) 155 if ( pic.data().isNull() )
156 pic = mAddressee.logo(); 156 pic = mAddressee.logo();
157 157
158 if ( pic.isIntern() && !pic.data().isNull() ) { 158 if ( pic.isIntern() && !pic.data().isNull() ) {
159 QImage img = pic.data(); 159 QImage img = pic.data();
160#ifndef KAB_EMBEDDED 160#ifndef KAB_EMBEDDED
161 if ( img.width() > img.height() ) 161 if ( img.width() > img.height() )
162 icon = img.scaleWidth( 32 ); 162 icon = img.scaleWidth( 32 );
163 else 163 else
164 icon = img.scaleHeight( 32 ); 164 icon = img.scaleHeight( 32 );
165#else //KAB_EMBEDDED 165#else //KAB_EMBEDDED
166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); 166 qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor");
167 icon.convertFromImage(img.smoothScale(32, 32)); 167 icon.convertFromImage(img.smoothScale(32, 32));
168#endif //KAB_EMBEDDED 168#endif //KAB_EMBEDDED
169 169
170 } else 170 } else
171 icon = defaultIcon; 171 icon = defaultIcon;
172 172
173 setPixmap( icon ); 173 setPixmap( icon );
174 } 174 }
175 175
176 private: 176 private:
177 KABC::Field::List mFields; 177 KABC::Field::List mFields;
178 KABC::AddressBook *mDocument; 178 KABC::AddressBook *mDocument;
179 KABC::Addressee mAddressee; 179 KABC::Addressee mAddressee;
180}; 180};
181 181
182/////////////////////////////// 182///////////////////////////////
183// KAddressBookView 183// KAddressBookView
184 184
185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 185KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab,
186 QWidget *parent, const char *name) 186 QWidget *parent, const char *name)
187 : KAddressBookView( ab, parent, name ) 187 : KAddressBookView( ab, parent, name )
188{ 188{
189 // Init the GUI 189 // Init the GUI
190 QVBoxLayout *layout = new QVBoxLayout(viewWidget()); 190 QVBoxLayout *layout = new QVBoxLayout(viewWidget());
191 191
192 mIconView = new AddresseeIconView(viewWidget(), "mIconView"); 192 mIconView = new AddresseeIconView(viewWidget(), "mIconView");
193 layout->addWidget(mIconView); 193 layout->addWidget(mIconView);
194 194
195 // Connect up the signals 195 // Connect up the signals
196 196
197//US method executed is part of KIconView 197//US method executed is part of KIconView
198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)), 198//US connect(mIconView, SIGNAL(executed(QIconViewItem *)),
199//US this, SLOT(addresseeExecuted(QIconViewItem *))); 199//US this, SLOT(addresseeExecuted(QIconViewItem *)));
200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 200 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
201 this, SLOT(addresseeExecuted(QIconViewItem *))); 201 this, SLOT(addresseeExecuted(QIconViewItem *)));
202 202
203 connect(mIconView, SIGNAL(selectionChanged()), 203 connect(mIconView, SIGNAL(selectionChanged()),
204 this, SLOT(addresseeSelected())); 204 this, SLOT(addresseeSelected()));
205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), 205 connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)),
206 this, SIGNAL(dropped(QDropEvent*))); 206 this, SIGNAL(dropped(QDropEvent*)));
207 connect(mIconView, SIGNAL(startAddresseeDrag()), 207 connect(mIconView, SIGNAL(startAddresseeDrag()),
208 this, SIGNAL(startDrag())); 208 this, SIGNAL(startDrag()));
209} 209}
210 210
211KAddressBookIconView::~KAddressBookIconView() 211KAddressBookIconView::~KAddressBookIconView()
212{ 212{
213} 213}
214void KAddressBookIconView::setFocusAV() 214void KAddressBookIconView::setFocusAV()
215{ 215{
216 if ( mIconView ) 216 if ( mIconView )
217 mIconView->setFocus(); 217 mIconView->setFocus();
218} 218}
219 219
220 220
221void KAddressBookIconView::scrollUP() 221void KAddressBookIconView::scrollUP()
222{ 222{
223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 223 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
224 QApplication::postEvent( mIconView, ev ); 224 QApplication::postEvent( mIconView, ev );
225} 225}
226void KAddressBookIconView::scrollDOWN() 226void KAddressBookIconView::scrollDOWN()
227{ 227{
228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 228 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
229 QApplication::postEvent( mIconView, ev ); 229 QApplication::postEvent( mIconView, ev );
230} 230}
231void KAddressBookIconView::readConfig(KConfig *config) 231void KAddressBookIconView::readConfig(KConfig *config)
232{ 232{
233 KAddressBookView::readConfig(config); 233 KAddressBookView::readConfig(config);
234 234
235//US method executed is part of KIconView 235//US method executed is part of KIconView
236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), 236//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
237//US this, SLOT(addresseeExecuted(QIconViewItem *))); 237//US this, SLOT(addresseeExecuted(QIconViewItem *)));
238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 238 disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
239 this, SLOT(addresseeExecuted(QIconViewItem *))); 239 this, SLOT(addresseeExecuted(QIconViewItem *)));
240 240
241//US method executed is part of KIconView. Use selectionChanged instead 241//US method executed is part of KIconView. Use selectionChanged instead
242/*US 242/*US
243 if (KABPrefs::instance()->mHonorSingleClick) 243 if (KABPrefs::instance()->mHonorSingleClick)
244 connect(mIconView, SIGNAL(executed(QIconViewItem *)), 244 connect(mIconView, SIGNAL(executed(QIconViewItem *)),
245 this, SLOT(addresseeExecuted(QIconViewItem *))); 245 this, SLOT(addresseeExecuted(QIconViewItem *)));
246 else 246 else
247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), 247 connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
248 this, SLOT(addresseeExecuted(QIconViewItem *))); 248 this, SLOT(addresseeExecuted(QIconViewItem *)));
249*/ 249*/
250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), 250 connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
251 this, SLOT(addresseeExecuted(QIconViewItem *))); 251 this, SLOT(addresseeExecuted(QIconViewItem *)));
252 252
253} 253}
254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) 254void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
255{ 255{
256 mIconView->clear(); 256 mIconView->clear();
257 mIconList.clear(); 257 mIconList.clear();
258 if ( s.isEmpty() || s == "*" ) { 258 if ( s.isEmpty() || s == "*" ) {
259 refresh(); 259 refresh();
260 return; 260 return;
261 } 261 }
262 QString pattern = s.lower()+"*"; 262 QString pattern = s.lower()+"*";
263 QRegExp re; 263 QRegExp re;
264 re.setWildcard(true); // most people understand these better. 264 re.setWildcard(true); // most people understand these better.
265 re.setCaseSensitive(false); 265 re.setCaseSensitive(false);
266 re.setPattern( pattern ); 266 re.setPattern( pattern );
267 if (!re.isValid()) 267 if (!re.isValid())
268 return; 268 return;
269 KABC::Addressee::List addresseeList = addressees(); 269 KABC::Addressee::List addresseeList = addressees();
270 KABC::Addressee::List::Iterator it; 270 KABC::Addressee::List::Iterator it;
271 if ( field ) { 271 if ( field ) {
272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 272 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
273 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 273 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
274 continue; 274 continue;
275#if QT_VERSION >= 300 275#if QT_VERSION >= 0x030000
276 if (re.search(field->value( *it ).lower()) != -1) 276 if (re.search(field->value( *it ).lower()) != -1)
277#else 277#else
278 if (re.match(field->value( *it ).lower()) != -1) 278 if (re.match(field->value( *it ).lower()) != -1)
279#endif 279#endif
280 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 280 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
281 281
282 282
283 } 283 }
284 } else { 284 } else {
285 KABC::Field::List fieldList = allFields(); 285 KABC::Field::List fieldList = allFields();
286 KABC::Field::List::ConstIterator fieldIt; 286 KABC::Field::List::ConstIterator fieldIt;
287 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 287 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
288 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 288 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
289 continue; 289 continue;
290 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 290 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
291#if QT_VERSION >= 300 291#if QT_VERSION >= 0x030000
292 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 292 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
293#else 293#else
294 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 294 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
295#endif 295#endif
296 { 296 {
297 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 297 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
298 break; 298 break;
299 } 299 }
300 } 300 }
301 } 301 }
302 } 302 }
303 mIconView->arrangeItemsInGrid( true ); 303 mIconView->arrangeItemsInGrid( true );
304 if ( mIconView->firstItem() ) { 304 if ( mIconView->firstItem() ) {
305 mIconView->setCurrentItem ( mIconView->firstItem() ); 305 mIconView->setCurrentItem ( mIconView->firstItem() );
306 mIconView->setSelected ( mIconView->firstItem() , true ); 306 mIconView->setSelected ( mIconView->firstItem() , true );
307 } 307 }
308 else 308 else
309 emit selected(QString::null); 309 emit selected(QString::null);
310} 310}
311QStringList KAddressBookIconView::selectedUids() 311QStringList KAddressBookIconView::selectedUids()
312{ 312{
313 QStringList uidList; 313 QStringList uidList;
314 QIconViewItem *item; 314 QIconViewItem *item;
315 AddresseeIconViewItem *aItem; 315 AddresseeIconViewItem *aItem;
316 316
317 for (item = mIconView->firstItem(); item; item = item->nextItem()) 317 for (item = mIconView->firstItem(); item; item = item->nextItem())
318 { 318 {
319 if (item->isSelected()) 319 if (item->isSelected())
320 { 320 {
321#ifndef KAB_EMBEDDED 321#ifndef KAB_EMBEDDED
322 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 322 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
323#else //KAB_EMBEDDED 323#else //KAB_EMBEDDED
324 aItem = (AddresseeIconViewItem*)(item); 324 aItem = (AddresseeIconViewItem*)(item);
325#endif //KAB_EMBEDDED 325#endif //KAB_EMBEDDED
326 if (aItem) 326 if (aItem)
327 uidList << aItem->addressee().uid(); 327 uidList << aItem->addressee().uid();
328 } 328 }
329 } 329 }
330 330
331 return uidList; 331 return uidList;
332} 332}
333 333
334void KAddressBookIconView::refresh(QString uid) 334void KAddressBookIconView::refresh(QString uid)
335{ 335{
336 QIconViewItem *item; 336 QIconViewItem *item;
337 AddresseeIconViewItem *aItem; 337 AddresseeIconViewItem *aItem;
338 338
339 if ( uid.isNull() ) { 339 if ( uid.isNull() ) {
340 // Rebuild the view 340 // Rebuild the view
341 mIconView->clear(); 341 mIconView->clear();
342 mIconList.clear(); 342 mIconList.clear();
343 343
344 KABC::Addressee::List addresseeList = addressees(); 344 KABC::Addressee::List addresseeList = addressees();
345 KABC::Addressee::List::Iterator iter; 345 KABC::Addressee::List::Iterator iter;
346 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { 346 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
347 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) 347 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
348 continue; 348 continue;
349 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 349 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
350 } 350 }
351 351
352 mIconView->arrangeItemsInGrid( true ); 352 mIconView->arrangeItemsInGrid( true );
353 353
354 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) 354 for ( item = mIconView->firstItem(); item; item = item->nextItem() )
355 { 355 {
356#ifndef KAB_EMBEDDED 356#ifndef KAB_EMBEDDED
357 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); 357 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item );
358#else //KAB_EMBEDDED 358#else //KAB_EMBEDDED
359 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); 359 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item );
360#endif //KAB_EMBEDDED 360#endif //KAB_EMBEDDED
361 mIconList.append( aivi ); 361 mIconList.append( aivi );
362 } 362 }
363 363
364 } else { 364 } else {
365 // Try to find the one to refresh 365 // Try to find the one to refresh
366 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { 366 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) {
367#ifndef KAB_EMBEDDED 367#ifndef KAB_EMBEDDED
368 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 368 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
369#else //KAB_EMBEDDED 369#else //KAB_EMBEDDED
370 aItem = (AddresseeIconViewItem*)(item); 370 aItem = (AddresseeIconViewItem*)(item);
371#endif //KAB_EMBEDDED 371#endif //KAB_EMBEDDED
372 if ((aItem) && (aItem->addressee().uid() == uid)) { 372 if ((aItem) && (aItem->addressee().uid() == uid)) {
373 aItem->refresh(); 373 aItem->refresh();
374 mIconView->arrangeItemsInGrid( true ); 374 mIconView->arrangeItemsInGrid( true );
375 return; 375 return;
376 } 376 }
377 } 377 }
378 refresh( QString::null ); 378 refresh( QString::null );
379 } 379 }
380} 380}
381 381
382void KAddressBookIconView::setSelected(QString uid, bool selected) 382void KAddressBookIconView::setSelected(QString uid, bool selected)
383{ 383{
384 QIconViewItem *item; 384 QIconViewItem *item;
385 AddresseeIconViewItem *aItem; 385 AddresseeIconViewItem *aItem;
386 386
387 if (uid.isNull()) 387 if (uid.isNull())
388 { 388 {
389 mIconView->selectAll(selected); 389 mIconView->selectAll(selected);
390 } 390 }
391 else 391 else
392 { 392 {
393 bool found = false; 393 bool found = false;
394 for (item = mIconView->firstItem(); item && !found; 394 for (item = mIconView->firstItem(); item && !found;
395 item = item->nextItem()) 395 item = item->nextItem())
396 { 396 {
397#ifndef KAB_EMBEDDED 397#ifndef KAB_EMBEDDED
398 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 398 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
399#else //KAB_EMBEDDED 399#else //KAB_EMBEDDED
400 aItem = (AddresseeIconViewItem*)(item); 400 aItem = (AddresseeIconViewItem*)(item);
401#endif //KAB_EMBEDDED 401#endif //KAB_EMBEDDED
402 402
403 if ((aItem) && (aItem->addressee().uid() == uid)) 403 if ((aItem) && (aItem->addressee().uid() == uid))
404 { 404 {
405 mIconView->setSelected(aItem, selected); 405 mIconView->setSelected(aItem, selected);
406 mIconView->ensureItemVisible( aItem ); 406 mIconView->ensureItemVisible( aItem );
407 found = true; 407 found = true;
408 } 408 }
409 } 409 }
410 } 410 }
411} 411}
412 412
413void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) 413void KAddressBookIconView::addresseeExecuted(QIconViewItem *item)
414{ 414{
415#ifndef KAB_EMBEDDED 415#ifndef KAB_EMBEDDED
416 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); 416 AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item);
417#else //KAB_EMBEDDED 417#else //KAB_EMBEDDED
418 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); 418 AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item);
419#endif //KAB_EMBEDDED 419#endif //KAB_EMBEDDED
420 420
421 if (aItem) { 421 if (aItem) {
422 emit executed(aItem->addressee().uid()); 422 emit executed(aItem->addressee().uid());
423 } 423 }
424} 424}
425 425
426void KAddressBookIconView::addresseeSelected() 426void KAddressBookIconView::addresseeSelected()
427{ 427{
428 QIconViewItem *item; 428 QIconViewItem *item;
429 AddresseeIconViewItem *aItem; 429 AddresseeIconViewItem *aItem;
430 430
431 bool found = false; 431 bool found = false;
432 for (item = mIconView->firstItem(); item && !found; 432 for (item = mIconView->firstItem(); item && !found;
433 item = item->nextItem()) 433 item = item->nextItem())
434 { 434 {
435 if (item->isSelected()) 435 if (item->isSelected())
436 { 436 {
437#ifndef KAB_EMBEDDED 437#ifndef KAB_EMBEDDED
438 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 438 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
439#else //KAB_EMBEDDED 439#else //KAB_EMBEDDED
440 aItem = (AddresseeIconViewItem*)(item); 440 aItem = (AddresseeIconViewItem*)(item);
441#endif //KAB_EMBEDDED 441#endif //KAB_EMBEDDED
442 if (aItem) 442 if (aItem)
443 { 443 {
444 emit selected(aItem->addressee().uid()); 444 emit selected(aItem->addressee().uid());
445 found = true; 445 found = true;
446 } 446 }
447 } 447 }
448 } 448 }
449 449
450 if (!found) 450 if (!found)
451 emit selected(QString::null); 451 emit selected(QString::null);
452} 452}
453 453
454#ifndef KAB_EMBEDDED 454#ifndef KAB_EMBEDDED
455#include "kaddressbookiconview.moc" 455#include "kaddressbookiconview.moc"
456#endif //KAB_EMBEDDED 456#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 7022dcb..69802a4 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,473 +1,473 @@
1// $Id$ 1// $Id$
2 2
3#include <qvbox.h> 3#include <qvbox.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qwidget.h> 5#include <qwidget.h>
6#include <qfile.h> 6#include <qfile.h>
7#include <qimage.h> 7#include <qimage.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qdragobject.h> 10#include <qdragobject.h>
11#include <qevent.h> 11#include <qevent.h>
12#include <qurl.h> 12#include <qurl.h>
13#include <qpixmap.h> 13#include <qpixmap.h>
14 14
15#include <kabc/addressbook.h> 15#include <kabc/addressbook.h>
16#include <kapplication.h> 16#include <kapplication.h>
17#include <kconfig.h> 17#include <kconfig.h>
18#include <kcolorbutton.h> 18#include <kcolorbutton.h>
19#include <kdebug.h> 19#include <kdebug.h>
20#include <kglobal.h> 20#include <kglobal.h>
21#include <kiconloader.h> 21#include <kiconloader.h>
22#include <klineedit.h> 22#include <klineedit.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kmessagebox.h> 24#include <kmessagebox.h>
25#include <kurl.h> 25#include <kurl.h>
26#include <kurlrequester.h> 26#include <kurlrequester.h>
27 27
28//US#include "configuretableviewdialog.h" 28//US#include "configuretableviewdialog.h"
29#include "contactlistview.h" 29#include "contactlistview.h"
30#include "kabprefs.h" 30#include "kabprefs.h"
31#include "undocmds.h" 31#include "undocmds.h"
32#include "viewmanager.h" 32#include "viewmanager.h"
33 33
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qheader.h> 35#include <qheader.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include "kaddressbooktableview.h" 38#include "kaddressbooktableview.h"
39 39
40 40
41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 41KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
42 QWidget *parent, const char *name ) 42 QWidget *parent, const char *name )
43 : KAddressBookView( ab, parent, name ) 43 : KAddressBookView( ab, parent, name )
44{ 44{
45 mainLayout = new QVBoxLayout( viewWidget(), 2 ); 45 mainLayout = new QVBoxLayout( viewWidget(), 2 );
46 46
47 // The list view will be created when the config is read. 47 // The list view will be created when the config is read.
48 mListView = 0; 48 mListView = 0;
49} 49}
50 50
51KAddressBookTableView::~KAddressBookTableView() 51KAddressBookTableView::~KAddressBookTableView()
52{ 52{
53} 53}
54void KAddressBookTableView::setFocusAV() 54void KAddressBookTableView::setFocusAV()
55{ 55{
56 if ( mListView ) 56 if ( mListView )
57 mListView->setFocus(); 57 mListView->setFocus();
58 58
59} 59}
60void KAddressBookTableView::scrollUP() 60void KAddressBookTableView::scrollUP()
61{ 61{
62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); 62 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
63 QApplication::postEvent( mListView, ev ); 63 QApplication::postEvent( mListView, ev );
64} 64}
65void KAddressBookTableView::scrollDOWN() 65void KAddressBookTableView::scrollDOWN()
66{ 66{
67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
68 QApplication::postEvent( mListView, ev ); 68 QApplication::postEvent( mListView, ev );
69} 69}
70void KAddressBookTableView::reconstructListView() 70void KAddressBookTableView::reconstructListView()
71{ 71{
72 if (mListView) 72 if (mListView)
73 { 73 {
74 disconnect(mListView, SIGNAL(selectionChanged()), 74 disconnect(mListView, SIGNAL(selectionChanged()),
75 this, SLOT(addresseeSelected())); 75 this, SLOT(addresseeSelected()));
76 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 76 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
77 this, SLOT(addresseeExecuted(QListViewItem*))); 77 this, SLOT(addresseeExecuted(QListViewItem*)));
78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
79 this, SLOT(addresseeExecuted(QListViewItem*))); 79 this, SLOT(addresseeExecuted(QListViewItem*)));
80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
81 SIGNAL(startDrag())); 81 SIGNAL(startDrag()));
82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
84 84
85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
86 SIGNAL(dropped(QDropEvent*))); 86 SIGNAL(dropped(QDropEvent*)));
87 delete mListView; 87 delete mListView;
88 } 88 }
89 89
90 mListView = new ContactListView( this, addressBook(), viewWidget() ); 90 mListView = new ContactListView( this, addressBook(), viewWidget() );
91 91
92 connect(this, SIGNAL(printView()), 92 connect(this, SIGNAL(printView()),
93 mListView , SLOT(printMe())); 93 mListView , SLOT(printMe()));
94 //US set singleClick manually, because it is no global configparameter in embedded space 94 //US set singleClick manually, because it is no global configparameter in embedded space
95 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 95 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
96 96
97 // Add the columns 97 // Add the columns
98 KABC::Field::List fieldList = fields(); 98 KABC::Field::List fieldList = fields();
99 KABC::Field::List::ConstIterator it; 99 KABC::Field::List::ConstIterator it;
100 100
101 int c = 0; 101 int c = 0;
102 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 102 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
103 mListView->addColumn( (*it)->label() ); 103 mListView->addColumn( (*it)->label() );
104 mListView->setColumnWidthMode(c++, QListView::Manual); 104 mListView->setColumnWidthMode(c++, QListView::Manual);
105//US 105//US
106 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 106 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
107 } 107 }
108 108
109 connect(mListView, SIGNAL(selectionChanged()), 109 connect(mListView, SIGNAL(selectionChanged()),
110 this, SLOT(addresseeSelected())); 110 this, SLOT(addresseeSelected()));
111 connect(mListView, SIGNAL(startAddresseeDrag()), this, 111 connect(mListView, SIGNAL(startAddresseeDrag()), this,
112 SIGNAL(startDrag())); 112 SIGNAL(startDrag()));
113 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 113 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
114 SIGNAL(dropped(QDropEvent*))); 114 SIGNAL(dropped(QDropEvent*)));
115 115
116 if (KABPrefs::instance()->mHonorSingleClick) { 116 if (KABPrefs::instance()->mHonorSingleClick) {
117 // qDebug("KAddressBookTableView::reconstructListView single"); 117 // qDebug("KAddressBookTableView::reconstructListView single");
118 connect(mListView, SIGNAL(executed(QListViewItem*)), 118 connect(mListView, SIGNAL(executed(QListViewItem*)),
119 this, SLOT(addresseeExecuted(QListViewItem*))); 119 this, SLOT(addresseeExecuted(QListViewItem*)));
120 } else { 120 } else {
121 // qDebug("KAddressBookTableView::reconstructListView double"); 121 // qDebug("KAddressBookTableView::reconstructListView double");
122 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 122 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 123 this, SLOT(addresseeExecuted(QListViewItem*)));
124 } 124 }
125 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 125 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
126 this, SLOT(addresseeExecuted(QListViewItem*))); 126 this, SLOT(addresseeExecuted(QListViewItem*)));
127 connect(mListView, SIGNAL(signalDelete()), 127 connect(mListView, SIGNAL(signalDelete()),
128 this, SLOT(addresseeDeleted())); 128 this, SLOT(addresseeDeleted()));
129 129
130//US performceimprovement. Refresh is done from the outside 130//US performceimprovement. Refresh is done from the outside
131//US refresh(); 131//US refresh();
132 132
133 mListView->setSorting( 0, true ); 133 mListView->setSorting( 0, true );
134 mainLayout->addWidget( mListView ); 134 mainLayout->addWidget( mListView );
135 mainLayout->activate(); 135 mainLayout->activate();
136 mListView->show(); 136 mListView->show();
137} 137}
138 138
139void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 139void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
140{ 140{
141 mListView->clear(); 141 mListView->clear();
142 if ( s.isEmpty() || s == "*" ) { 142 if ( s.isEmpty() || s == "*" ) {
143 refresh(); 143 refresh();
144 return; 144 return;
145 } 145 }
146 QString pattern = s.lower()+"*"; 146 QString pattern = s.lower()+"*";
147 QRegExp re; 147 QRegExp re;
148 re.setWildcard(true); // most people understand these better. 148 re.setWildcard(true); // most people understand these better.
149 re.setCaseSensitive(false); 149 re.setCaseSensitive(false);
150 re.setPattern( pattern ); 150 re.setPattern( pattern );
151 if (!re.isValid()) 151 if (!re.isValid())
152 return; 152 return;
153 KABC::Addressee::List addresseeList = addressees(); 153 KABC::Addressee::List addresseeList = addressees();
154 KABC::Addressee::List::Iterator it; 154 KABC::Addressee::List::Iterator it;
155 if ( field ) { 155 if ( field ) {
156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 156 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 157 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
158 continue; 158 continue;
159#if QT_VERSION >= 300 159#if QT_VERSION >= 0x030000
160 if (re.search(field->value( *it ).lower()) == 0) 160 if (re.search(field->value( *it ).lower()) == 0)
161#else 161#else
162 if (re.match(field->value( *it ).lower()) != -1) 162 if (re.match(field->value( *it ).lower()) != -1)
163#endif 163#endif
164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 164 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
165 165
166 } 166 }
167 } else { 167 } else {
168 KABC::Field::List fieldList = allFields(); 168 KABC::Field::List fieldList = allFields();
169 KABC::Field::List::ConstIterator fieldIt; 169 KABC::Field::List::ConstIterator fieldIt;
170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 170 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 171 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
172 continue; 172 continue;
173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 173 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
174#if QT_VERSION >= 300 174#if QT_VERSION >= 0x030000
175 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 175 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
176#else 176#else
177 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 177 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
178#endif 178#endif
179 { 179 {
180 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 180 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
181 break; 181 break;
182 } 182 }
183 } 183 }
184 } 184 }
185 } 185 }
186 // Sometimes the background pixmap gets messed up when we add lots 186 // Sometimes the background pixmap gets messed up when we add lots
187 // of items. 187 // of items.
188 mListView->repaint(); 188 mListView->repaint();
189 if ( mListView->firstChild() ) { 189 if ( mListView->firstChild() ) {
190 mListView->setCurrentItem ( mListView->firstChild() ); 190 mListView->setCurrentItem ( mListView->firstChild() );
191 mListView->setSelected ( mListView->firstChild(), true ); 191 mListView->setSelected ( mListView->firstChild(), true );
192 } 192 }
193 else 193 else
194 emit selected(QString::null); 194 emit selected(QString::null);
195 195
196} 196}
197void KAddressBookTableView::writeConfig(KConfig *config) 197void KAddressBookTableView::writeConfig(KConfig *config)
198{ 198{
199 KAddressBookView::writeConfig(config); 199 KAddressBookView::writeConfig(config);
200 200
201 mListView->saveLayout(config, config->group()); 201 mListView->saveLayout(config, config->group());
202} 202}
203 203
204void KAddressBookTableView::readConfig(KConfig *config) 204void KAddressBookTableView::readConfig(KConfig *config)
205{ 205{
206 KAddressBookView::readConfig( config ); 206 KAddressBookView::readConfig( config );
207 // The config could have changed the fields, so we need to reconstruct 207 // The config could have changed the fields, so we need to reconstruct
208 // the listview. 208 // the listview.
209 reconstructListView(); 209 reconstructListView();
210 210
211 // costum colors? 211 // costum colors?
212 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 212 if ( config->readBoolEntry( "EnableCustomColors", false ) )
213 { 213 {
214 QPalette p( mListView->palette() ); 214 QPalette p( mListView->palette() );
215 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 215 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
216 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 216 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
217 c = p.color(QPalette::Normal, QColorGroup::Text ); 217 c = p.color(QPalette::Normal, QColorGroup::Text );
218 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 218 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
219 c = p.color(QPalette::Normal, QColorGroup::Button ); 219 c = p.color(QPalette::Normal, QColorGroup::Button );
220 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 220 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
221 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 221 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
222 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 222 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
223 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 223 c = p.color(QPalette::Normal, QColorGroup::Highlight );
224 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 224 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
225 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 225 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
226 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 226 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
227#ifndef KAB_EMBEDDED 227#ifndef KAB_EMBEDDED
228 c = KGlobalSettings::alternateBackgroundColor(); 228 c = KGlobalSettings::alternateBackgroundColor();
229#else //KAB_EMBEDDED 229#else //KAB_EMBEDDED
230 c = QColor(240, 240, 240); 230 c = QColor(240, 240, 240);
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 232 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
233 mListView->setAlternateColor(c); 233 mListView->setAlternateColor(c);
234 234
235 235
236 //US mListView->viewport()->setPalette( p ); 236 //US mListView->viewport()->setPalette( p );
237 mListView->setPalette( p ); 237 mListView->setPalette( p );
238 } 238 }
239 else 239 else
240 { 240 {
241 // needed if turned off during a session. 241 // needed if turned off during a session.
242 //US mListView->viewport()->setPalette( mListView->palette() ); 242 //US mListView->viewport()->setPalette( mListView->palette() );
243 mListView->setPalette( mListView->palette() ); 243 mListView->setPalette( mListView->palette() );
244 } 244 }
245 245
246 //custom fonts? 246 //custom fonts?
247 QFont f( font() ); 247 QFont f( font() );
248 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 248 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
249 { 249 {
250 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 250 mListView->setFont( config->readFontEntry( "TextFont", &f) );
251 f.setBold( true ); 251 f.setBold( true );
252 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 252 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
253 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 253 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
254 } 254 }
255 else 255 else
256 { 256 {
257 mListView->setFont( f ); 257 mListView->setFont( f );
258 f.setBold( true ); 258 f.setBold( true );
259 //US mListView->setHeaderFont( f ); 259 //US mListView->setHeaderFont( f );
260 mListView->header()->setFont( f ); 260 mListView->header()->setFont( f );
261 } 261 }
262 262
263 // Set the list view options 263 // Set the list view options
264 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 264 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
265 true)); 265 true));
266 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 266 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
267 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 267 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
268 268
269 if (config->readBoolEntry("Background", false)) 269 if (config->readBoolEntry("Background", false))
270 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 270 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
271 271
272 // Restore the layout of the listview 272 // Restore the layout of the listview
273 mListView->restoreLayout(config, config->group()); 273 mListView->restoreLayout(config, config->group());
274} 274}
275 275
276void KAddressBookTableView::refresh(QString uid) 276void KAddressBookTableView::refresh(QString uid)
277{ 277{
278 // For now just repopulate. In reality this method should 278 // For now just repopulate. In reality this method should
279 // check the value of uid, and if valid iterate through 279 // check the value of uid, and if valid iterate through
280 // the listview to find the entry, then tell it to refresh. 280 // the listview to find the entry, then tell it to refresh.
281 281
282 if (uid.isNull()) { 282 if (uid.isNull()) {
283 // Clear the list view 283 // Clear the list view
284 QString currentUID, nextUID; 284 QString currentUID, nextUID;
285#ifndef KAB_EMBEDDED 285#ifndef KAB_EMBEDDED
286 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 286 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
287#else //KAB_EMBEDDED 287#else //KAB_EMBEDDED
288 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 288 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
289#endif //KAB_EMBEDDED 289#endif //KAB_EMBEDDED
290 290
291 if ( currentItem ) { 291 if ( currentItem ) {
292#ifndef KAB_EMBEDDED 292#ifndef KAB_EMBEDDED
293 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 293 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
294#else //KAB_EMBEDDED 294#else //KAB_EMBEDDED
295 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 295 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
296#endif //KAB_EMBEDDED 296#endif //KAB_EMBEDDED
297 if ( nextItem ) 297 if ( nextItem )
298 nextUID = nextItem->addressee().uid(); 298 nextUID = nextItem->addressee().uid();
299 currentUID = currentItem->addressee().uid(); 299 currentUID = currentItem->addressee().uid();
300 } 300 }
301 301
302 mListView->clear(); 302 mListView->clear();
303 303
304 currentItem = 0; 304 currentItem = 0;
305 KABC::Addressee::List addresseeList = addressees(); 305 KABC::Addressee::List addresseeList = addressees();
306 KABC::Addressee::List::Iterator it; 306 KABC::Addressee::List::Iterator it;
307 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 307 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
308 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) 308 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
309 continue; 309 continue;
310 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 310 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
311 if ( (*it).uid() == currentUID ) 311 if ( (*it).uid() == currentUID )
312 currentItem = item; 312 currentItem = item;
313 else if ( (*it).uid() == nextUID && !currentItem ) 313 else if ( (*it).uid() == nextUID && !currentItem )
314 currentItem = item; 314 currentItem = item;
315 } 315 }
316 316
317 // Sometimes the background pixmap gets messed up when we add lots 317 // Sometimes the background pixmap gets messed up when we add lots
318 // of items. 318 // of items.
319 mListView->repaint(); 319 mListView->repaint();
320 320
321 if ( currentItem ) { 321 if ( currentItem ) {
322 mListView->setCurrentItem( currentItem ); 322 mListView->setCurrentItem( currentItem );
323 mListView->ensureItemVisible( currentItem ); 323 mListView->ensureItemVisible( currentItem );
324 } 324 }
325 } else { 325 } else {
326 // Only need to update on entry. Iterate through and try to find it 326 // Only need to update on entry. Iterate through and try to find it
327 ContactListViewItem *ceItem; 327 ContactListViewItem *ceItem;
328 QListViewItemIterator it( mListView ); 328 QListViewItemIterator it( mListView );
329 while ( it.current() ) { 329 while ( it.current() ) {
330#ifndef KAB_EMBEDDED 330#ifndef KAB_EMBEDDED
331 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 331 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
332#else //KAB_EMBEDDED 332#else //KAB_EMBEDDED
333 ceItem = (ContactListViewItem*)( it.current() ); 333 ceItem = (ContactListViewItem*)( it.current() );
334#endif //KAB_EMBEDDED 334#endif //KAB_EMBEDDED
335 335
336 if ( ceItem && ceItem->addressee().uid() == uid ) { 336 if ( ceItem && ceItem->addressee().uid() == uid ) {
337 ceItem->refresh(); 337 ceItem->refresh();
338 return; 338 return;
339 } 339 }
340 ++it; 340 ++it;
341 } 341 }
342 342
343 refresh( QString::null ); 343 refresh( QString::null );
344 } 344 }
345} 345}
346 346
347QStringList KAddressBookTableView::selectedUids() 347QStringList KAddressBookTableView::selectedUids()
348{ 348{
349 QStringList uidList; 349 QStringList uidList;
350 QListViewItem *item; 350 QListViewItem *item;
351 ContactListViewItem *ceItem; 351 ContactListViewItem *ceItem;
352 352
353 for(item = mListView->firstChild(); item; item = item->itemBelow()) 353 for(item = mListView->firstChild(); item; item = item->itemBelow())
354 { 354 {
355 if (mListView->isSelected( item )) 355 if (mListView->isSelected( item ))
356 { 356 {
357#ifndef KAB_EMBEDDED 357#ifndef KAB_EMBEDDED
358 ceItem = dynamic_cast<ContactListViewItem*>(item); 358 ceItem = dynamic_cast<ContactListViewItem*>(item);
359#else //KAB_EMBEDDED 359#else //KAB_EMBEDDED
360 ceItem = (ContactListViewItem*)(item); 360 ceItem = (ContactListViewItem*)(item);
361#endif //KAB_EMBEDDED 361#endif //KAB_EMBEDDED
362 362
363 if (ceItem != 0L) 363 if (ceItem != 0L)
364 uidList << ceItem->addressee().uid(); 364 uidList << ceItem->addressee().uid();
365 } 365 }
366 } 366 }
367 if ( uidList.count() == 0 ) 367 if ( uidList.count() == 0 )
368 if ( mListView->currentItem() ) { 368 if ( mListView->currentItem() ) {
369 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 369 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
370 uidList << ceItem->addressee().uid(); 370 uidList << ceItem->addressee().uid();
371 } 371 }
372 372
373 return uidList; 373 return uidList;
374} 374}
375 375
376void KAddressBookTableView::setSelected(QString uid, bool selected) 376void KAddressBookTableView::setSelected(QString uid, bool selected)
377{ 377{
378 QListViewItem *item; 378 QListViewItem *item;
379 ContactListViewItem *ceItem; 379 ContactListViewItem *ceItem;
380 380
381 if (uid.isNull()) 381 if (uid.isNull())
382 { 382 {
383 mListView->selectAll(selected); 383 mListView->selectAll(selected);
384 } 384 }
385 else 385 else
386 { 386 {
387 for(item = mListView->firstChild(); item; item = item->itemBelow()) 387 for(item = mListView->firstChild(); item; item = item->itemBelow())
388 { 388 {
389#ifndef KAB_EMBEDDED 389#ifndef KAB_EMBEDDED
390 ceItem = dynamic_cast<ContactListViewItem*>(item); 390 ceItem = dynamic_cast<ContactListViewItem*>(item);
391#else //KAB_EMBEDDED 391#else //KAB_EMBEDDED
392 ceItem = (ContactListViewItem*)(item); 392 ceItem = (ContactListViewItem*)(item);
393#endif //KAB_EMBEDDED 393#endif //KAB_EMBEDDED
394 394
395 395
396 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) 396 if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
397 { 397 {
398 mListView->setSelected(item, selected); 398 mListView->setSelected(item, selected);
399 399
400 if (selected) 400 if (selected)
401 mListView->ensureItemVisible(item); 401 mListView->ensureItemVisible(item);
402 } 402 }
403 } 403 }
404 } 404 }
405} 405}
406 406
407void KAddressBookTableView::addresseeSelected() 407void KAddressBookTableView::addresseeSelected()
408{ 408{
409 // We need to try to find the first selected item. This might not be the 409 // We need to try to find the first selected item. This might not be the
410 // last selected item, but when QListView is in multiselection mode, 410 // last selected item, but when QListView is in multiselection mode,
411 // there is no way to figure out which one was 411 // there is no way to figure out which one was
412 // selected last. 412 // selected last.
413 QListViewItem *item; 413 QListViewItem *item;
414 bool found =false; 414 bool found =false;
415 for (item = mListView->firstChild(); item && !found; 415 for (item = mListView->firstChild(); item && !found;
416 item = item->nextSibling()) 416 item = item->nextSibling())
417 { 417 {
418 if (item->isSelected()) 418 if (item->isSelected())
419 { 419 {
420 found = true; 420 found = true;
421#ifndef KAB_EMBEDDED 421#ifndef KAB_EMBEDDED
422 ContactListViewItem *ceItem 422 ContactListViewItem *ceItem
423 = dynamic_cast<ContactListViewItem*>(item); 423 = dynamic_cast<ContactListViewItem*>(item);
424#else //KAB_EMBEDDED 424#else //KAB_EMBEDDED
425 ContactListViewItem *ceItem 425 ContactListViewItem *ceItem
426 = (ContactListViewItem*)(item); 426 = (ContactListViewItem*)(item);
427#endif //KAB_EMBEDDED 427#endif //KAB_EMBEDDED
428 428
429 if ( ceItem ) emit selected(ceItem->addressee().uid()); 429 if ( ceItem ) emit selected(ceItem->addressee().uid());
430 } 430 }
431 } 431 }
432 432
433 if (!found) 433 if (!found)
434 emit selected(QString::null); 434 emit selected(QString::null);
435} 435}
436 436
437void KAddressBookTableView::addresseeExecuted(QListViewItem *item) 437void KAddressBookTableView::addresseeExecuted(QListViewItem *item)
438{ 438{
439 if (item) 439 if (item)
440 { 440 {
441#ifndef KAB_EMBEDDED 441#ifndef KAB_EMBEDDED
442 ContactListViewItem *ceItem 442 ContactListViewItem *ceItem
443 = dynamic_cast<ContactListViewItem*>(item); 443 = dynamic_cast<ContactListViewItem*>(item);
444#else //KAB_EMBEDDED 444#else //KAB_EMBEDDED
445 ContactListViewItem *ceItem 445 ContactListViewItem *ceItem
446 = (ContactListViewItem*)(item); 446 = (ContactListViewItem*)(item);
447#endif //KAB_EMBEDDED 447#endif //KAB_EMBEDDED
448 448
449 if (ceItem) 449 if (ceItem)
450 { 450 {
451 emit executed(ceItem->addressee().uid()); 451 emit executed(ceItem->addressee().uid());
452 } 452 }
453 } 453 }
454 else 454 else
455 { 455 {
456 emit executed(QString::null); 456 emit executed(QString::null);
457 } 457 }
458} 458}
459 459
460void KAddressBookTableView::addresseeDeleted() 460void KAddressBookTableView::addresseeDeleted()
461{ 461{
462 462
463 emit deleteRequest(); 463 emit deleteRequest();
464 464
465} 465}
466 466
467 467
468 468
469 469
470 470
471#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
472#include "kaddressbooktableview.moc" 472#include "kaddressbooktableview.moc"
473#endif //KAB_EMBEDDED 473#endif //KAB_EMBEDDED
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index ead8628..21ecb73 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,457 +1,457 @@
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 <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23 23
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include "kotodoviewitem.h" 25#include "kotodoviewitem.h"
26#include "kotodoview.h" 26#include "kotodoview.h"
27#include "koprefs.h" 27#include "koprefs.h"
28 28
29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
31{ 31{
32 construct(); 32 construct();
33} 33}
34 34
35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
37{ 37{
38 construct(); 38 construct();
39} 39}
40 40
41QString KOTodoViewItem::key(int column,bool) const 41QString KOTodoViewItem::key(int column,bool) const
42{ 42{
43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
44 if (it == mKeyMap.end()) { 44 if (it == mKeyMap.end()) {
45 return text(column).lower(); 45 return text(column).lower();
46 } else { 46 } else {
47 return *it; 47 return *it;
48 } 48 }
49} 49}
50 50
51void KOTodoViewItem:: setup() 51void KOTodoViewItem:: setup()
52{ 52{
53 53
54 int h = 20; 54 int h = 20;
55 if ( listView () ) { 55 if ( listView () ) {
56 QFontMetrics fm ( listView ()->font () ); 56 QFontMetrics fm ( listView ()->font () );
57 h = fm.height(); 57 h = fm.height();
58 } 58 }
59 setHeight( h ); 59 setHeight( h );
60 60
61} 61}
62void KOTodoViewItem::setSortKey(int column,const QString &key) 62void KOTodoViewItem::setSortKey(int column,const QString &key)
63{ 63{
64 mKeyMap.insert(column,key); 64 mKeyMap.insert(column,key);
65} 65}
66 66
67#if QT_VERSION >= 300 67#if QT_VERSION >= 0x030000
68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
69 int y,int h) 69 int y,int h)
70{ 70{
71 QListViewItem::paintBranches(p,cg,w,y,h); 71 QListViewItem::paintBranches(p,cg,w,y,h);
72} 72}
73#else 73#else
74#endif 74#endif
75 75
76void KOTodoViewItem::construct() 76void KOTodoViewItem::construct()
77{ 77{
78 // qDebug("KOTodoViewItem::construct() "); 78 // qDebug("KOTodoViewItem::construct() ");
79 m_init = true; 79 m_init = true;
80 QString keyd = "=="; 80 QString keyd = "==";
81 QString keyt = "=="; 81 QString keyt = "==";
82 QString skeyd = "=="; 82 QString skeyd = "==";
83 QString skeyt = "=="; 83 QString skeyt = "==";
84 84
85 setOn(mTodo->isCompleted()); 85 setOn(mTodo->isCompleted());
86 setText(0,mTodo->summary()); 86 setText(0,mTodo->summary());
87 setText(1,QString::number(mTodo->priority())); 87 setText(1,QString::number(mTodo->priority()));
88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
89 if (mTodo->percentComplete()<100) { 89 if (mTodo->percentComplete()<100) {
90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
91 else setSortKey(2,QString::number(mTodo->percentComplete())); 91 else setSortKey(2,QString::number(mTodo->percentComplete()));
92 } 92 }
93 else { 93 else {
94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
95 else setSortKey(2,QString::number(99)); 95 else setSortKey(2,QString::number(99));
96 } 96 }
97 if (mTodo->hasDueDate()) { 97 if (mTodo->hasDueDate()) {
98 setText(3, mTodo->dtDueDateStr()); 98 setText(3, mTodo->dtDueDateStr());
99 QDate d = mTodo->dtDue().date(); 99 QDate d = mTodo->dtDue().date();
100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
101 // setSortKey(3,keyd); 101 // setSortKey(3,keyd);
102 if (mTodo->doesFloat()) { 102 if (mTodo->doesFloat()) {
103 setText(4,""); 103 setText(4,"");
104 } 104 }
105 else { 105 else {
106 setText(4,mTodo->dtDueTimeStr()); 106 setText(4,mTodo->dtDueTimeStr());
107 QTime t = mTodo->dtDue().time(); 107 QTime t = mTodo->dtDue().time();
108 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 108 keyt.sprintf("%02d%02d",t.hour(),t.minute());
109 //setSortKey(4,keyt); 109 //setSortKey(4,keyt);
110 } 110 }
111 } else { 111 } else {
112 setText(3,""); 112 setText(3,"");
113 setText(4,""); 113 setText(4,"");
114 } 114 }
115 setSortKey(3,keyd); 115 setSortKey(3,keyd);
116 setSortKey(4,keyt); 116 setSortKey(4,keyt);
117 117
118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
120 120
121 121
122 122
123 if (mTodo->hasStartDate()) { 123 if (mTodo->hasStartDate()) {
124 setText(5, mTodo->dtStartDateStr()); 124 setText(5, mTodo->dtStartDateStr());
125 QDate d = mTodo->dtStart().date(); 125 QDate d = mTodo->dtStart().date();
126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
127 127
128 if (mTodo->doesFloat()) { 128 if (mTodo->doesFloat()) {
129 setText(6,""); 129 setText(6,"");
130 } 130 }
131 else { 131 else {
132 setText(6,mTodo->dtStartTimeStr()); 132 setText(6,mTodo->dtStartTimeStr());
133 QTime t = mTodo->dtStart().time(); 133 QTime t = mTodo->dtStart().time();
134 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 134 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
135 135
136 } 136 }
137 } else { 137 } else {
138 setText(5,""); 138 setText(5,"");
139 setText(6,""); 139 setText(6,"");
140 } 140 }
141 setSortKey(5,skeyd); 141 setSortKey(5,skeyd);
142 setSortKey(6,skeyt); 142 setSortKey(6,skeyt);
143 143
144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
145 setText(8,mTodo->categoriesStr()); 145 setText(8,mTodo->categoriesStr());
146 146
147#if 0 147#if 0
148 // Find sort id in description. It's the text behind the last '#' character 148 // Find sort id in description. It's the text behind the last '#' character
149 // found in the description. White spaces are removed from beginning and end 149 // found in the description. White spaces are removed from beginning and end
150 // of sort id. 150 // of sort id.
151 int pos = mTodo->description().findRev('#'); 151 int pos = mTodo->description().findRev('#');
152 if (pos < 0) { 152 if (pos < 0) {
153 setText(6,""); 153 setText(6,"");
154 } else { 154 } else {
155 QString str = mTodo->description().mid(pos+1); 155 QString str = mTodo->description().mid(pos+1);
156 str.stripWhiteSpace(); 156 str.stripWhiteSpace();
157 setText(6,str); 157 setText(6,str);
158 } 158 }
159#endif 159#endif
160 160
161 m_known = false; 161 m_known = false;
162 m_init = false; 162 m_init = false;
163 163
164 setMyPixmap(); 164 setMyPixmap();
165 165
166} 166}
167void KOTodoViewItem::setMyPixmap() 167void KOTodoViewItem::setMyPixmap()
168{ 168{
169 int size = 5; 169 int size = 5;
170 QPixmap pixi = QPixmap( 1, 1 ); 170 QPixmap pixi = QPixmap( 1, 1 );
171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
172// pixi = SmallIcon("redcross16"); 172// pixi = SmallIcon("redcross16");
173// } else { 173// } else {
174 QPainter p; 174 QPainter p;
175 175
176 int pixSize = 0; 176 int pixSize = 0;
177 QPixmap pPix = QPixmap( size, size ); 177 QPixmap pPix = QPixmap( size, size );
178 if ( mTodo->description().length() > 0 ) { 178 if ( mTodo->description().length() > 0 ) {
179 pixi.resize(size, pixSize+size); 179 pixi.resize(size, pixSize+size);
180 pPix.fill( Qt::darkGreen ); 180 pPix.fill( Qt::darkGreen );
181 p.begin( &pixi ); 181 p.begin( &pixi );
182 p. drawPixmap ( 0, pixSize, pPix); 182 p. drawPixmap ( 0, pixSize, pPix);
183 p.end(); 183 p.end();
184 pixSize += size; 184 pixSize += size;
185 } 185 }
186 if ( mTodo->isAlarmEnabled() ) { 186 if ( mTodo->isAlarmEnabled() ) {
187 pixi.resize(size, pixSize+size); 187 pixi.resize(size, pixSize+size);
188 pPix.fill( Qt::red ); 188 pPix.fill( Qt::red );
189 p.begin( &pixi ); 189 p.begin( &pixi );
190 p. drawPixmap ( 0, pixSize, pPix); 190 p. drawPixmap ( 0, pixSize, pPix);
191 p.end(); 191 p.end();
192 pixSize += size; 192 pixSize += size;
193 } 193 }
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 199 }
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 206
207 kdDebug() << "State changed, modified " << state << endl; 207 kdDebug() << "State changed, modified " << state << endl;
208 QString keyd = "=="; 208 QString keyd = "==";
209 QString keyt = "=="; 209 QString keyt = "==";
210 210
211 if (state) mTodo->setCompleted(state); 211 if (state) mTodo->setCompleted(state);
212 else mTodo->setPercentComplete(0); 212 else mTodo->setPercentComplete(0);
213 if (isOn()!=state) { 213 if (isOn()!=state) {
214 setOn(state); 214 setOn(state);
215 } 215 }
216 216
217 if (mTodo->hasDueDate()) { 217 if (mTodo->hasDueDate()) {
218 setText(3, mTodo->dtDueDateStr()); 218 setText(3, mTodo->dtDueDateStr());
219 QDate d = mTodo->dtDue().date(); 219 QDate d = mTodo->dtDue().date();
220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
221 setSortKey(3,keyd); 221 setSortKey(3,keyd);
222 if (mTodo->doesFloat()) { 222 if (mTodo->doesFloat()) {
223 setText(4,""); 223 setText(4,"");
224 } 224 }
225 else { 225 else {
226 setText(4,mTodo->dtDueTimeStr()); 226 setText(4,mTodo->dtDueTimeStr());
227 QTime t = mTodo->dtDue().time(); 227 QTime t = mTodo->dtDue().time();
228 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 228 keyt.sprintf("%02d%02d",t.hour(),t.minute());
229 setSortKey(4,keyt); 229 setSortKey(4,keyt);
230 } 230 }
231 } 231 }
232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
234 234
235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
236 if (mTodo->percentComplete()<100) { 236 if (mTodo->percentComplete()<100) {
237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
238 else setSortKey(2,QString::number(mTodo->percentComplete())); 238 else setSortKey(2,QString::number(mTodo->percentComplete()));
239 } 239 }
240 else { 240 else {
241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
242 else setSortKey(2,QString::number(99)); 242 else setSortKey(2,QString::number(99));
243 } 243 }
244 QListViewItem * myChild = firstChild(); 244 QListViewItem * myChild = firstChild();
245 KOTodoViewItem *item; 245 KOTodoViewItem *item;
246 while( myChild ) { 246 while( myChild ) {
247 item = static_cast<KOTodoViewItem*>(myChild); 247 item = static_cast<KOTodoViewItem*>(myChild);
248 item->stateChange(state); 248 item->stateChange(state);
249 myChild = myChild->nextSibling(); 249 myChild = myChild->nextSibling();
250 } 250 }
251 mTodoView->modified(true); 251 mTodoView->modified(true);
252 setMyPixmap(); 252 setMyPixmap();
253 mTodoView->setTodoModified( mTodo ); 253 mTodoView->setTodoModified( mTodo );
254} 254}
255 255
256bool KOTodoViewItem::isAlternate() 256bool KOTodoViewItem::isAlternate()
257{ 257{
258#ifndef KORG_NOLVALTERNATION 258#ifndef KORG_NOLVALTERNATION
259 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 259 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
260 if (lv && lv->alternateBackground().isValid()) 260 if (lv && lv->alternateBackground().isValid())
261 { 261 {
262 KOTodoViewItem *above = 0; 262 KOTodoViewItem *above = 0;
263 above = dynamic_cast<KOTodoViewItem *>(itemAbove()); 263 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
264 m_known = above ? above->m_known : true; 264 m_known = above ? above->m_known : true;
265 if (m_known) 265 if (m_known)
266 { 266 {
267 m_odd = above ? !above->m_odd : false; 267 m_odd = above ? !above->m_odd : false;
268 } 268 }
269 else 269 else
270 { 270 {
271 KOTodoViewItem *item; 271 KOTodoViewItem *item;
272 bool previous = true; 272 bool previous = true;
273 if (QListViewItem::parent()) 273 if (QListViewItem::parent())
274 { 274 {
275 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); 275 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
276 if (item) 276 if (item)
277 previous = item->m_odd; 277 previous = item->m_odd;
278 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 278 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
279 } 279 }
280 else 280 else
281 { 281 {
282 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); 282 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
283 } 283 }
284 284
285 while(item) 285 while(item)
286 { 286 {
287 item->m_odd = previous = !previous; 287 item->m_odd = previous = !previous;
288 item->m_known = true; 288 item->m_known = true;
289 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); 289 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
290 } 290 }
291 } 291 }
292 return m_odd; 292 return m_odd;
293 } 293 }
294 return false; 294 return false;
295#else 295#else
296 return false; 296 return false;
297#endif 297#endif
298} 298}
299 299
300void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 300void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
301{ 301{
302 QColorGroup _cg = cg; 302 QColorGroup _cg = cg;
303 QColorGroup::ColorRole role; 303 QColorGroup::ColorRole role;
304 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 304 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
305 role = QColorGroup::Text; 305 role = QColorGroup::Text;
306 else 306 else
307 role = QColorGroup::Base; 307 role = QColorGroup::Base;
308 //#ifndef KORG_NOLVALTERNATION 308 //#ifndef KORG_NOLVALTERNATION
309 // if (isAlternate()) 309 // if (isAlternate())
310 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 310 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
311 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 311 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
312 QColor colorToSet; 312 QColor colorToSet;
313 if ( setColor ) { 313 if ( setColor ) {
314 QStringList categories = mTodo->categories(); 314 QStringList categories = mTodo->categories();
315 QString cat = categories.first(); 315 QString cat = categories.first();
316 if ( !cat.isEmpty()) { 316 if ( !cat.isEmpty()) {
317 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 317 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
318 } else 318 } else
319 setColor = false; 319 setColor = false;
320 } 320 }
321 if (mTodo->hasDueDate()) { 321 if (mTodo->hasDueDate()) {
322 if (mTodo->dtDue().date()==QDate::currentDate() && 322 if (mTodo->dtDue().date()==QDate::currentDate() &&
323 !mTodo->isCompleted()) { 323 !mTodo->isCompleted()) {
324 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); 324 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor);
325 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 325 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
326 setColor = true; 326 setColor = true;
327 } 327 }
328 if (mTodo->dtDue().date() < QDate::currentDate() && 328 if (mTodo->dtDue().date() < QDate::currentDate() &&
329 !mTodo->isCompleted()) { 329 !mTodo->isCompleted()) {
330 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); 330 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor);
331 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 331 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
332 setColor = true; 332 setColor = true;
333 } 333 }
334 } 334 }
335 335
336 if ( setColor ) { 336 if ( setColor ) {
337 _cg.setColor(role,colorToSet ); 337 _cg.setColor(role,colorToSet );
338 if ( role == QColorGroup::Base) { 338 if ( role == QColorGroup::Base) {
339 int rgb = colorToSet.red(); 339 int rgb = colorToSet.red();
340 rgb += colorToSet.blue()/2; 340 rgb += colorToSet.blue()/2;
341 rgb += colorToSet.green(); 341 rgb += colorToSet.green();
342 if ( rgb < 200 ) 342 if ( rgb < 200 )
343 _cg.setColor(QColorGroup::Text,Qt::white ); 343 _cg.setColor(QColorGroup::Text,Qt::white );
344 } 344 }
345 } 345 }
346 //#endif 346 //#endif
347 if ( column > 0 ){ 347 if ( column > 0 ){
348 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 348 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
349 p->save(); 349 p->save();
350 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 350 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
351 351
352 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 352 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
353 // p->setPen(Qt::black ); //border 353 // p->setPen(Qt::black ); //border
354 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 354 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
355 QColor fc = KOPrefs::instance()->mHighlightColor; 355 QColor fc = KOPrefs::instance()->mHighlightColor;
356 if ( mTodo->percentComplete() == 100 ) 356 if ( mTodo->percentComplete() == 100 )
357 fc = darkGreen; 357 fc = darkGreen;
358 p->drawRect( 2, 2, width-4, height()-4); 358 p->drawRect( 2, 2, width-4, height()-4);
359 p->fillRect( 3, 3, progress, height()-6, 359 p->fillRect( 3, 3, progress, height()-6,
360 fc ); 360 fc );
361 p->restore(); 361 p->restore();
362 } else { 362 } else {
363 QCheckListItem::paintCell(p, _cg, column, width, alignment); 363 QCheckListItem::paintCell(p, _cg, column, width, alignment);
364 } 364 }
365 return; 365 return;
366 } 366 }
367 367
368 int align = alignment; 368 int align = alignment;
369 369
370 if ( !p ) 370 if ( !p )
371 return; 371 return;
372 372
373 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 373 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
374 374
375 QListView *lv = listView(); 375 QListView *lv = listView();
376 if ( !lv ) 376 if ( !lv )
377 return; 377 return;
378 int marg = 2;//lv->itemMargin(); 378 int marg = 2;//lv->itemMargin();
379 int r = 0; 379 int r = 0;
380 QCheckListItem::Type myType = QCheckListItem::CheckBox; 380 QCheckListItem::Type myType = QCheckListItem::CheckBox;
381 int BoxSize = 20; 381 int BoxSize = 20;
382 int boxOffset = 2; 382 int boxOffset = 2;
383 int xOffset = 2; 383 int xOffset = 2;
384 if (qApp->desktop()->width() < 300 ) { 384 if (qApp->desktop()->width() < 300 ) {
385 BoxSize = 14; 385 BoxSize = 14;
386 boxOffset = -1; 386 boxOffset = -1;
387 xOffset = 1; 387 xOffset = 1;
388 // marg = 0; 388 // marg = 0;
389 } 389 }
390 if ( height() < BoxSize ) { 390 if ( height() < BoxSize ) {
391 boxOffset = boxOffset - ((BoxSize - height())/2) ; 391 boxOffset = boxOffset - ((BoxSize - height())/2) ;
392 // qDebug("boxOffset %d height %d", boxOffset, height() ); 392 // qDebug("boxOffset %d height %d", boxOffset, height() );
393 BoxSize = height(); 393 BoxSize = height();
394 394
395 } 395 }
396 //bool winStyle = lv->style() == WindowsStyle; 396 //bool winStyle = lv->style() == WindowsStyle;
397 397
398 int lineStart = 5; 398 int lineStart = 5;
399 if ( myType == Controller ) { 399 if ( myType == Controller ) {
400 if ( !pixmap( 0 ) ) 400 if ( !pixmap( 0 ) )
401 r += BoxSize + 4; 401 r += BoxSize + 4;
402 } else { 402 } else {
403 ASSERT( lv ); //### 403 ASSERT( lv ); //###
404 //QFontMetrics fm( lv->font() ); 404 //QFontMetrics fm( lv->font() );
405 //int d = fm.height(); 405 //int d = fm.height();
406 int x = 0; 406 int x = 0;
407 int y = (height() - BoxSize) / 2; 407 int y = (height() - BoxSize) / 2;
408 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 408 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
409 if ( myType == CheckBox ) { 409 if ( myType == CheckBox ) {
410 if ( isEnabled() ) 410 if ( isEnabled() )
411 p->setPen( QPen( _cg.text(), 1 ) ); 411 p->setPen( QPen( _cg.text(), 1 ) );
412 else 412 else
413 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 413 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
414 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 414 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
415 lineStart = x+marg; 415 lineStart = x+marg;
416 ///////////////////// 416 /////////////////////
417 x++; 417 x++;
418 y++; 418 y++;
419 if ( isOn() ) { 419 if ( isOn() ) {
420 QPointArray a( 7*2 ); 420 QPointArray a( 7*2 );
421 int i, xx, yy; 421 int i, xx, yy;
422 xx = x+xOffset+marg+(boxOffset/2); 422 xx = x+xOffset+marg+(boxOffset/2);
423 yy = y+5+boxOffset; 423 yy = y+5+boxOffset;
424 for ( i=0; i<3; i++ ) { 424 for ( i=0; i<3; i++ ) {
425 a.setPoint( 2*i, xx, yy ); 425 a.setPoint( 2*i, xx, yy );
426 a.setPoint( 2*i+1, xx, yy+2 ); 426 a.setPoint( 2*i+1, xx, yy+2 );
427 // qDebug(" "); 427 // qDebug(" ");
428 xx++; yy++; 428 xx++; yy++;
429 } 429 }
430 yy -= 2; 430 yy -= 2;
431 for ( i=3; i<7; i++ ) { 431 for ( i=3; i<7; i++ ) {
432 a.setPoint( 2*i, xx, yy ); 432 a.setPoint( 2*i, xx, yy );
433 a.setPoint( 2*i+1, xx, yy+2 ); 433 a.setPoint( 2*i+1, xx, yy+2 );
434 xx++; yy--; 434 xx++; yy--;
435 } 435 }
436 p->setPen( darkGreen ); 436 p->setPen( darkGreen );
437 p->drawLineSegments( a ); 437 p->drawLineSegments( a );
438 } 438 }
439 //////////////////////// 439 ////////////////////////
440 } 440 }
441 r += BoxSize + 4; 441 r += BoxSize + 4;
442 } 442 }
443 443
444 p->translate( r, 0 ); 444 p->translate( r, 0 );
445 p->setPen( QPen( _cg.text() ) ); 445 p->setPen( QPen( _cg.text() ) );
446 QListViewItem::paintCell( p, _cg, column, width - r, align ); 446 QListViewItem::paintCell( p, _cg, column, width - r, align );
447 if ( mTodo->cancelled () ) { 447 if ( mTodo->cancelled () ) {
448 p->setPen( black ); 448 p->setPen( black );
449 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 449 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
450 int wid = br.width() +lineStart; 450 int wid = br.width() +lineStart;
451 if ( wid > width-3 ) 451 if ( wid > width-3 )
452 wid = width-3; 452 wid = width-3;
453 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 453 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
454 454
455 } 455 }
456 456
457} 457}
diff --git a/korganizer/kotodoviewitem.h b/korganizer/kotodoviewitem.h
index 74dbe98..bd024c8 100644
--- a/korganizer/kotodoviewitem.h
+++ b/korganizer/kotodoviewitem.h
@@ -1,93 +1,93 @@
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#ifndef KOTODOVIEWITEM_H 19#ifndef KOTODOVIEWITEM_H
20#define KOTODOVIEWITEM_H 20#define KOTODOVIEWITEM_H
21 21
22#include <qfont.h> 22#include <qfont.h>
23#include <qfontmetrics.h> 23#include <qfontmetrics.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qstrlist.h> 26#include <qstrlist.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qmap.h> 30#include <qmap.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qpainter.h> 32#include <qpainter.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35#include <libkcal/todo.h> 35#include <libkcal/todo.h>
36 36
37using namespace KCal; 37using namespace KCal;
38 38
39class KOTodoView; 39class KOTodoView;
40 40
41/** 41/**
42 This class provides a way of displaying a single Event of Todo-Type in a 42 This class provides a way of displaying a single Event of Todo-Type in a
43 KTodoView. 43 KTodoView.
44 44
45 @author Cornelius Schumacher <schumacher@kde.org> 45 @author Cornelius Schumacher <schumacher@kde.org>
46 @see KOTodoView 46 @see KOTodoView
47*/ 47*/
48class KOTodoViewItem : public QCheckListItem 48class KOTodoViewItem : public QCheckListItem
49{ 49{
50 public: 50 public:
51 /** 51 /**
52 Constructor. 52 Constructor.
53 53
54 @param parent is the list view to which this item belongs. 54 @param parent is the list view to which this item belongs.
55 @param ev is the event to have the item display information for. 55 @param ev is the event to have the item display information for.
56 */ 56 */
57 KOTodoViewItem(QListView *parent, Todo *todo, KOTodoView *kotodo); 57 KOTodoViewItem(QListView *parent, Todo *todo, KOTodoView *kotodo);
58 KOTodoViewItem(KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo); 58 KOTodoViewItem(KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo);
59 //~KOTodoViewItem() { qDebug("~KOTodoViewItem() %s ", text(0).latin1() );} 59 //~KOTodoViewItem() { qDebug("~KOTodoViewItem() %s ", text(0).latin1() );}
60 60
61 void construct(); 61 void construct();
62 62
63 Todo *todo() { return mTodo; } 63 Todo *todo() { return mTodo; }
64 64
65 QString key(int, bool) const; 65 QString key(int, bool) const;
66 66
67 void setSortKey(int column,const QString &key); 67 void setSortKey(int column,const QString &key);
68 68
69 bool isAlternate(); 69 bool isAlternate();
70 70
71 virtual void paintCell(QPainter *p, const QColorGroup &cg, 71 virtual void paintCell(QPainter *p, const QColorGroup &cg,
72 int column, int width, int alignment); 72 int column, int width, int alignment);
73 virtual void setup(); 73 virtual void setup();
74 protected: 74 protected:
75#if QT_VERSION >= 300 75#if QT_VERSION >= 0x030000
76 void paintBranches(QPainter *p,const QColorGroup & cg,int w,int y,int h); 76 void paintBranches(QPainter *p,const QColorGroup & cg,int w,int y,int h);
77#else 77#else
78#endif 78#endif
79 virtual void stateChange(bool); 79 virtual void stateChange(bool);
80 void setMyPixmap(); 80 void setMyPixmap();
81 81
82 private: 82 private:
83 Todo *mTodo; 83 Todo *mTodo;
84 KOTodoView *mTodoView; 84 KOTodoView *mTodoView;
85 85
86 QMap<int,QString> mKeyMap; 86 QMap<int,QString> mKeyMap;
87 uint m_odd : 1; 87 uint m_odd : 1;
88 uint m_known : 1; 88 uint m_known : 1;
89 uint m_unused : 30; 89 uint m_unused : 30;
90 bool m_init; 90 bool m_init;
91}; 91};
92 92
93#endif 93#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index f6b7718..e255b83 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,588 +1,588 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
92 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
96 else { 96 else {
97 showAgendaView(); 97 showAgendaView();
98 } 98 }
99} 99}
100 100
101void KOViewManager::writeSettings(KConfig *config) 101void KOViewManager::writeSettings(KConfig *config)
102{ 102{
103 config->setGroup("General"); 103 config->setGroup("General");
104 104
105 QString view; 105 QString view;
106 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 106 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
107 else if (mCurrentView == mMonthView) view = "Month"; 107 else if (mCurrentView == mMonthView) view = "Month";
108 else if (mCurrentView == mListView) view = "List"; 108 else if (mCurrentView == mListView) view = "List";
109 else if (mCurrentView == mJournalView) view = "Journal"; 109 else if (mCurrentView == mJournalView) view = "Journal";
110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
111 else if (mCurrentView == mTodoView) view = "Todo"; 111 else if (mCurrentView == mTodoView) view = "Todo";
112 else view = "Agenda"; 112 else view = "Agenda";
113 113
114 config->writeEntry("Current View",view); 114 config->writeEntry("Current View",view);
115 115
116 if (mAgendaView) { 116 if (mAgendaView) {
117 mAgendaView->writeSettings(config); 117 mAgendaView->writeSettings(config);
118 } 118 }
119 if (mTimeSpanView) { 119 if (mTimeSpanView) {
120 mTimeSpanView->writeSettings(config); 120 mTimeSpanView->writeSettings(config);
121 } 121 }
122 if (mListView) { 122 if (mListView) {
123 mListView->writeSettings(config); 123 mListView->writeSettings(config);
124 } 124 }
125 if (mTodoView) { 125 if (mTodoView) {
126 mTodoView->saveLayout(config,"Todo View"); 126 mTodoView->saveLayout(config,"Todo View");
127 } 127 }
128} 128}
129 129
130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
131{ 131{
132 132
133 //mFlagShowNextxDays = false; 133 //mFlagShowNextxDays = false;
134 //if(view == mCurrentView) return; 134 //if(view == mCurrentView) return;
135 if ( view == 0 ) { 135 if ( view == 0 ) {
136 view = mCurrentView; 136 view = mCurrentView;
137 if ( view == 0 ) 137 if ( view == 0 )
138 return; 138 return;
139 } 139 }
140 bool full = fullScreen; 140 bool full = fullScreen;
141 if(view == mCurrentView && view != mWhatsNextView ) { 141 if(view == mCurrentView && view != mWhatsNextView ) {
142 if ( mCurrentAgendaView < 0 ) 142 if ( mCurrentAgendaView < 0 )
143 return; 143 return;
144 full = mMainView->leftFrame()->isVisible(); 144 full = mMainView->leftFrame()->isVisible();
145 } else { 145 } else {
146 mCurrentView = view; 146 mCurrentView = view;
147 147
148 // bool full = fullScreen; 148 // bool full = fullScreen;
149 bool isFull = !mMainView->leftFrame()->isVisible(); 149 bool isFull = !mMainView->leftFrame()->isVisible();
150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
151 full = true; 151 full = true;
152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
153 full = false; 153 full = false;
154 } 154 }
155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
156 //raiseCurrentView( full ); 156 //raiseCurrentView( full );
157 mMainView->processIncidenceSelection( 0 ); 157 mMainView->processIncidenceSelection( 0 );
158 mMainView->updateView(); 158 mMainView->updateView();
159 raiseCurrentView( full ); 159 raiseCurrentView( full );
160 mMainView->adaptNavigationUnits(); 160 mMainView->adaptNavigationUnits();
161} 161}
162 162
163void KOViewManager::raiseCurrentView( bool fullScreen ) 163void KOViewManager::raiseCurrentView( bool fullScreen )
164{ 164{
165 //qDebug("raiseCurrentView "); 165 //qDebug("raiseCurrentView ");
166 mCurrentAgendaView = 0; 166 mCurrentAgendaView = 0;
167 int wid = mMainView->width() ; 167 int wid = mMainView->width() ;
168 int hei = mMainView->height(); 168 int hei = mMainView->height();
169 if ( mCurrentView == mMonthView ) { 169 if ( mCurrentView == mMonthView ) {
170 mMainView->navigatorBar()->show(); 170 mMainView->navigatorBar()->show();
171 hei -= mMainView->navigatorBar()->sizeHint().height(); 171 hei -= mMainView->navigatorBar()->sizeHint().height();
172 //mMainView->navigatorBar()->hide(); 172 //mMainView->navigatorBar()->hide();
173 } else { 173 } else {
174 mMainView->navigatorBar()->hide(); 174 mMainView->navigatorBar()->hide();
175 } 175 }
176 if ( fullScreen ) { 176 if ( fullScreen ) {
177 mMainView->leftFrame()->hide(); 177 mMainView->leftFrame()->hide();
178 } else { 178 } else {
179 mMainView->leftFrame()->show(); 179 mMainView->leftFrame()->show();
180 if ( KOPrefs::instance()->mVerticalScreen ) 180 if ( KOPrefs::instance()->mVerticalScreen )
181 hei -= mMainView->leftFrame()->height(); 181 hei -= mMainView->leftFrame()->height();
182 else 182 else
183 wid -= mMainView->leftFrame()->width(); 183 wid -= mMainView->leftFrame()->width();
184 } 184 }
185 185
186 if ( globalFlagBlockAgenda == 5 ) { 186 if ( globalFlagBlockAgenda == 5 ) {
187 globalFlagBlockAgenda = 4; 187 globalFlagBlockAgenda = 4;
188 globalFlagBlockAgendaItemPaint = 1; 188 globalFlagBlockAgendaItemPaint = 1;
189 } 189 }
190 mMainView->viewStack()->raiseWidget(mCurrentView); 190 mMainView->viewStack()->raiseWidget(mCurrentView);
191 if ( globalFlagBlockAgenda == 4 ) { 191 if ( globalFlagBlockAgenda == 4 ) {
192 if ( mCurrentView == mAgendaView ) { 192 if ( mCurrentView == mAgendaView ) {
193 //globalFlagBlockAgenda =1 ; 193 //globalFlagBlockAgenda =1 ;
194 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 194 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
195 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 195 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
196 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 196 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
197 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 197 mAgendaView->setStartHour( QTime::currentTime ().hour() );
198 qApp->processEvents(); 198 qApp->processEvents();
199 //qDebug("qApp->processEvents() "); 199 //qDebug("qApp->processEvents() ");
200 globalFlagBlockAgenda = 0; 200 globalFlagBlockAgenda = 0;
201 mAgendaView->repaintAgenda(); 201 mAgendaView->repaintAgenda();
202 202
203 } 203 }
204 globalFlagBlockAgenda = 0; 204 globalFlagBlockAgenda = 0;
205 } 205 }
206 //qDebug("raiseCurrentView ende "); 206 //qDebug("raiseCurrentView ende ");
207} 207}
208 208
209void KOViewManager::updateView() 209void KOViewManager::updateView()
210{ 210{
211 // qDebug("KOViewManager::updateView() "); 211 // qDebug("KOViewManager::updateView() ");
212 // if we are updating mTodoView, we get endless recursion 212 // if we are updating mTodoView, we get endless recursion
213 if ( mTodoView == mCurrentView ) 213 if ( mTodoView == mCurrentView )
214 return; 214 return;
215 if ( mCurrentView ) mCurrentView->updateView(); 215 if ( mCurrentView ) mCurrentView->updateView();
216 216
217} 217}
218 218
219void KOViewManager::updateView(const QDate &start, const QDate &end) 219void KOViewManager::updateView(const QDate &start, const QDate &end)
220{ 220{
221 // kdDebug() << "KOViewManager::updateView()" << endl; 221 // kdDebug() << "KOViewManager::updateView()" << endl;
222 222
223 if (mCurrentView) mCurrentView->showDates(start, end); 223 if (mCurrentView) mCurrentView->showDates(start, end);
224 224
225 if (mTodoView) mTodoView->updateView(); 225 if (mTodoView) mTodoView->updateView();
226} 226}
227 227
228 228
229void KOViewManager::updateWNview() 229void KOViewManager::updateWNview()
230{ 230{
231 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 231 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
232 mWhatsNextView->updateView(); 232 mWhatsNextView->updateView();
233 233
234} 234}
235void KOViewManager::showWhatsNextView() 235void KOViewManager::showWhatsNextView()
236{ 236{
237 if (!mWhatsNextView) { 237 if (!mWhatsNextView) {
238 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 238 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
239 "KOViewManager::WhatsNextView"); 239 "KOViewManager::WhatsNextView");
240 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 240 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
241 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 241 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
242 addView(mWhatsNextView); 242 addView(mWhatsNextView);
243 connect(this, SIGNAL( printWNV() ), 243 connect(this, SIGNAL( printWNV() ),
244 mWhatsNextView, SLOT( printMe() ) ); 244 mWhatsNextView, SLOT( printMe() ) );
245 } 245 }
246 globalFlagBlockAgenda = 1; 246 globalFlagBlockAgenda = 1;
247 showView(mWhatsNextView, true ); 247 showView(mWhatsNextView, true );
248 //mWhatsNextView->updateView(); 248 //mWhatsNextView->updateView();
249 249
250} 250}
251 251
252void KOViewManager::showListView() 252void KOViewManager::showListView()
253{ 253{
254 if (!mListView) { 254 if (!mListView) {
255 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 255 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
256 addView(mListView); 256 addView(mListView);
257 257
258 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 258 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
259 mMainView, SLOT(showIncidence(Incidence *))); 259 mMainView, SLOT(showIncidence(Incidence *)));
260 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 260 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
261 mMainView, SLOT(editIncidence(Incidence *))); 261 mMainView, SLOT(editIncidence(Incidence *)));
262 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 262 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
263 mMainView, SLOT(deleteIncidence(Incidence *))); 263 mMainView, SLOT(deleteIncidence(Incidence *)));
264 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 264 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
265 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 265 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
266 connect( mListView, SIGNAL( signalNewEvent() ), 266 connect( mListView, SIGNAL( signalNewEvent() ),
267 mMainView, SLOT( newEvent() ) ); 267 mMainView, SLOT( newEvent() ) );
268 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 268 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
269 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 269 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
270 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 270 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
271 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 271 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
272 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 272 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
273 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 273 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
274 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 274 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
275 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 275 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
276 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 276 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
277 } 277 }
278 // bool temp = mFlagShowNextxDays; 278 // bool temp = mFlagShowNextxDays;
279 //globalFlagBlockPainting = true; 279 //globalFlagBlockPainting = true;
280 globalFlagBlockAgenda = 1; 280 globalFlagBlockAgenda = 1;
281 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 281 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
282 mMainView->setBlockShowDates( true ); 282 mMainView->setBlockShowDates( true );
283 mMainView->dateNavigator()->selectMonth(); 283 mMainView->dateNavigator()->selectMonth();
284 mMainView->setBlockShowDates( false ); 284 mMainView->setBlockShowDates( false );
285 } 285 }
286 showView(mListView, KOPrefs::instance()->mFullViewTodo); 286 showView(mListView, KOPrefs::instance()->mFullViewTodo);
287 //mFlagShowNextxDays = temp; 287 //mFlagShowNextxDays = temp;
288} 288}
289 289
290void KOViewManager::showAgendaView( bool fullScreen ) 290void KOViewManager::showAgendaView( bool fullScreen )
291{ 291{
292 292
293 mMainView->dialogManager()->hideSearchDialog(); 293 mMainView->dialogManager()->hideSearchDialog();
294 // qDebug("KOViewManager::showAgendaView "); 294 // qDebug("KOViewManager::showAgendaView ");
295 bool full; 295 bool full;
296 full = fullScreen; 296 full = fullScreen;
297 if (!mAgendaView) { 297 if (!mAgendaView) {
298 full = false; 298 full = false;
299 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 299 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
300 addView(mAgendaView); 300 addView(mAgendaView);
301#ifndef DESKTOP_VERSION 301#ifndef DESKTOP_VERSION
302 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 302 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
303#endif 303#endif
304 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 304 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
305 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 305 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
306 306
307 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 307 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
308 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 308 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
309 mMainView, SLOT(newEvent(QDateTime))); 309 mMainView, SLOT(newEvent(QDateTime)));
310 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 310 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
311 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 311 // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
312 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 312 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
313 mMainView, SLOT(newEvent(QDate))); 313 mMainView, SLOT(newEvent(QDate)));
314 314
315 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 315 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
316 mMainView, SLOT(editIncidence(Incidence *))); 316 mMainView, SLOT(editIncidence(Incidence *)));
317 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 317 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
318 mMainView, SLOT(showIncidence(Incidence *))); 318 mMainView, SLOT(showIncidence(Incidence *)));
319 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 319 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
320 mMainView, SLOT(deleteIncidence(Incidence *))); 320 mMainView, SLOT(deleteIncidence(Incidence *)));
321 321
322 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 322 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
323 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 323 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
324 324
325 connect(mAgendaView, SIGNAL( toggleExpand() ), 325 connect(mAgendaView, SIGNAL( toggleExpand() ),
326 mMainView, SLOT( toggleExpand() ) ); 326 mMainView, SLOT( toggleExpand() ) );
327 327
328 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 328 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
329 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 329 mAgendaView, SLOT( setExpandedButton( bool ) ) );
330 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 330 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
331 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 331 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
332 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 332 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
333 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 333 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
334 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 334 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
335 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 335 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
336 SLOT( updateTodo( Todo *, int ) ) ); 336 SLOT( updateTodo( Todo *, int ) ) );
337 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 337 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
338 mMainView, SIGNAL( todoModified( Todo *, int ))); 338 mMainView, SIGNAL( todoModified( Todo *, int )));
339 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 339 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
340 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 340 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
341 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 341 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
342 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 342 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
343 mAgendaView->readSettings(); 343 mAgendaView->readSettings();
344 mAgendaView->updateConfig(); 344 mAgendaView->updateConfig();
345 } 345 }
346 346
347 showView( mAgendaView, full); 347 showView( mAgendaView, full);
348 348
349} 349}
350 350
351void KOViewManager::showDayView() 351void KOViewManager::showDayView()
352{ 352{
353 mFlagShowNextxDays = false; 353 mFlagShowNextxDays = false;
354 globalFlagBlockLabel = 1; 354 globalFlagBlockLabel = 1;
355 globalFlagBlockAgenda = 1; 355 globalFlagBlockAgenda = 1;
356 if ( mCurrentAgendaView != 1 ) 356 if ( mCurrentAgendaView != 1 )
357 mCurrentAgendaView = -1; 357 mCurrentAgendaView = -1;
358 showAgendaView(); 358 showAgendaView();
359 qApp->processEvents(); 359 qApp->processEvents();
360 globalFlagBlockAgenda = 2; 360 globalFlagBlockAgenda = 2;
361 globalFlagBlockLabel = 0; 361 globalFlagBlockLabel = 0;
362 mMainView->dateNavigator()->selectDates( 1 ); 362 mMainView->dateNavigator()->selectDates( 1 );
363 mCurrentAgendaView = 1 ; 363 mCurrentAgendaView = 1 ;
364 364
365} 365}
366 366
367void KOViewManager::showWorkWeekView() 367void KOViewManager::showWorkWeekView()
368{ 368{
369 mFlagShowNextxDays = false; 369 mFlagShowNextxDays = false;
370 globalFlagBlockAgenda = 1; 370 globalFlagBlockAgenda = 1;
371 globalFlagBlockLabel = 1; 371 globalFlagBlockLabel = 1;
372 if ( mCurrentAgendaView != 5 ) 372 if ( mCurrentAgendaView != 5 )
373 mCurrentAgendaView = -1; 373 mCurrentAgendaView = -1;
374 showAgendaView(); 374 showAgendaView();
375 qApp->processEvents(); 375 qApp->processEvents();
376 globalFlagBlockAgenda = 2; 376 globalFlagBlockAgenda = 2;
377 globalFlagBlockLabel = 0; 377 globalFlagBlockLabel = 0;
378 mMainView->dateNavigator()->selectWorkWeek(); 378 mMainView->dateNavigator()->selectWorkWeek();
379 mCurrentAgendaView = 5 ; 379 mCurrentAgendaView = 5 ;
380 380
381} 381}
382 382
383void KOViewManager::showWeekView() 383void KOViewManager::showWeekView()
384{ 384{
385 /* 385 /*
386 globalFlagBlockAgenda = 2; 386 globalFlagBlockAgenda = 2;
387 qDebug("4globalFlagBlockAgenda = 2; "); 387 qDebug("4globalFlagBlockAgenda = 2; ");
388 //globalFlagBlockPainting = true; 388 //globalFlagBlockPainting = true;
389 mMainView->dateNavigator()->selectWeek(); 389 mMainView->dateNavigator()->selectWeek();
390 showAgendaView(); 390 showAgendaView();
391 */ 391 */
392 392
393 393
394 mFlagShowNextxDays = false; 394 mFlagShowNextxDays = false;
395 globalFlagBlockAgenda = 1; 395 globalFlagBlockAgenda = 1;
396 globalFlagBlockLabel = 1; 396 globalFlagBlockLabel = 1;
397 if ( mCurrentAgendaView != 7 ) 397 if ( mCurrentAgendaView != 7 )
398 mCurrentAgendaView = -1; 398 mCurrentAgendaView = -1;
399 showAgendaView(); 399 showAgendaView();
400 qApp->processEvents(); 400 qApp->processEvents();
401 globalFlagBlockAgenda = 2; 401 globalFlagBlockAgenda = 2;
402 globalFlagBlockLabel = 0; 402 globalFlagBlockLabel = 0;
403 mMainView->dateNavigator()->selectWeek(); 403 mMainView->dateNavigator()->selectWeek();
404 mCurrentAgendaView = 7 ; 404 mCurrentAgendaView = 7 ;
405} 405}
406 406
407void KOViewManager::showNextXView() 407void KOViewManager::showNextXView()
408{ 408{
409 409
410 globalFlagBlockAgenda = 1; 410 globalFlagBlockAgenda = 1;
411 if ( mCurrentAgendaView != 3 ) 411 if ( mCurrentAgendaView != 3 )
412 mCurrentAgendaView = -1; 412 mCurrentAgendaView = -1;
413 showAgendaView(KOPrefs::instance()->mFullViewMonth); 413 showAgendaView(KOPrefs::instance()->mFullViewMonth);
414 globalFlagBlockAgenda = 2; 414 globalFlagBlockAgenda = 2;
415 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 415 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
416 KOPrefs::instance()->mNextXDays ); 416 KOPrefs::instance()->mNextXDays );
417 mFlagShowNextxDays = true; 417 mFlagShowNextxDays = true;
418 mCurrentAgendaView = 3 ; 418 mCurrentAgendaView = 3 ;
419} 419}
420bool KOViewManager::showsNextDays() 420bool KOViewManager::showsNextDays()
421{ 421{
422 return mFlagShowNextxDays; 422 return mFlagShowNextxDays;
423} 423}
424void KOViewManager::showMonthView() 424void KOViewManager::showMonthView()
425{ 425{
426 if (!mMonthView) { 426 if (!mMonthView) {
427 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 427 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
428 428
429 addView(mMonthView); 429 addView(mMonthView);
430 // mMonthView->show(); 430 // mMonthView->show();
431 // SIGNALS/SLOTS FOR MONTH VIEW 431 // SIGNALS/SLOTS FOR MONTH VIEW
432 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 432 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
433 mMainView, SLOT(newEvent(QDateTime))); 433 mMainView, SLOT(newEvent(QDateTime)));
434 434
435 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 435 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
436 mMainView, SLOT(showIncidence(Incidence *))); 436 mMainView, SLOT(showIncidence(Incidence *)));
437 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 437 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
438 mMainView, SLOT(editIncidence(Incidence *))); 438 mMainView, SLOT(editIncidence(Incidence *)));
439 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 439 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
440 mMainView, SLOT(deleteIncidence(Incidence *))); 440 mMainView, SLOT(deleteIncidence(Incidence *)));
441 441
442 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 442 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
443 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 443 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
444 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 444 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
445 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 445 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
446 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 446 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
447 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 447 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
448 448
449 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 449 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
450 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 450 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
451 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 451 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
452 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 452 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
453 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 453 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
454 mMainView, SLOT ( selectWeekNum( int ) ) ); 454 mMainView, SLOT ( selectWeekNum( int ) ) );
455 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 455 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
456 mMainView, SLOT ( showDay( QDate ) ) ); 456 mMainView, SLOT ( showDay( QDate ) ) );
457 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 457 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
458 mMonthView->updateConfig(); 458 mMonthView->updateConfig();
459 } 459 }
460 460
461 globalFlagBlockAgenda = 1; 461 globalFlagBlockAgenda = 1;
462 //mFlagShowNextxDays = false; 462 //mFlagShowNextxDays = false;
463 // if(mMonthView == mCurrentView) return; 463 // if(mMonthView == mCurrentView) return;
464 mMainView->dateNavigator()->selectMonth(); 464 mMainView->dateNavigator()->selectMonth();
465 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 465 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
466 //mMonthView->showDates(tmpList.first(), tmpList.last()); 466 //mMonthView->showDates(tmpList.first(), tmpList.last());
467 467
468 showView(mMonthView, true ); 468 showView(mMonthView, true );
469 469
470} 470}
471 471
472void KOViewManager::showTodoView() 472void KOViewManager::showTodoView()
473{ 473{
474 //mFlagShowNextxDays = false; 474 //mFlagShowNextxDays = false;
475 if ( !mTodoView ) { 475 if ( !mTodoView ) {
476 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 476 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
477 "KOViewManager::TodoView" ); 477 "KOViewManager::TodoView" );
478 478
479 addView( mTodoView ); 479 addView( mTodoView );
480 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 480 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
481 481
482 // SIGNALS/SLOTS FOR TODO VIEW 482 // SIGNALS/SLOTS FOR TODO VIEW
483 connect( mTodoView, SIGNAL( newTodoSignal() ), 483 connect( mTodoView, SIGNAL( newTodoSignal() ),
484 mMainView, SLOT( newTodo() ) ); 484 mMainView, SLOT( newTodo() ) );
485 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 485 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
486 mMainView, SLOT( newSubTodo( Todo *) ) ); 486 mMainView, SLOT( newSubTodo( Todo *) ) );
487 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 487 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
488 mMainView, SLOT( showTodo( Todo * ) ) ); 488 mMainView, SLOT( showTodo( Todo * ) ) );
489 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 489 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
490 mMainView, SLOT( editTodo( Todo * ) ) ); 490 mMainView, SLOT( editTodo( Todo * ) ) );
491 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 491 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
492 mMainView, SLOT( deleteTodo( Todo * ) ) ); 492 mMainView, SLOT( deleteTodo( Todo * ) ) );
493 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 493 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
494 mMainView, SLOT( purgeCompleted() ) ); 494 mMainView, SLOT( purgeCompleted() ) );
495 495
496 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 496 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
497 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 497 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
498 498
499 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 499 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
500 SLOT( updateConfig() ) ); 500 SLOT( updateConfig() ) );
501 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 501 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
502 SLOT( updateTodo( Todo *, int ) ) ); 502 SLOT( updateTodo( Todo *, int ) ) );
503 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 503 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
504 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 504 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
505 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 505 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
506 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 506 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
507 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 507 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
508 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 508 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
509 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 509 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
510 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 510 mMainView, SLOT ( todo_unsub( Todo * ) ) );
511 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 511 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
512 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 512 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
513 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 513 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
514 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 514 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
515 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 515 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
516 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 516 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
517 KConfig *config = KOGlobals::config(); 517 KConfig *config = KOGlobals::config();
518 mTodoView->restoreLayout(config,"Todo View"); 518 mTodoView->restoreLayout(config,"Todo View");
519 mTodoView->setNavigator( mMainView->dateNavigator() ); 519 mTodoView->setNavigator( mMainView->dateNavigator() );
520 } 520 }
521 521
522 globalFlagBlockAgenda = 1; 522 globalFlagBlockAgenda = 1;
523 showView( mTodoView, true ); 523 showView( mTodoView, true );
524 524
525} 525}
526 526
527void KOViewManager::showJournalView() 527void KOViewManager::showJournalView()
528{ 528{
529 //mFlagShowNextxDays = false; 529 //mFlagShowNextxDays = false;
530 if (!mJournalView) { 530 if (!mJournalView) {
531 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 531 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
532 "KOViewManager::JournalView"); 532 "KOViewManager::JournalView");
533 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 533 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
534 SLOT( updateConfig() ) ); 534 SLOT( updateConfig() ) );
535 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 535 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
536 addView(mJournalView); 536 addView(mJournalView);
537 } 537 }
538 538
539 showView(mJournalView); 539 showView(mJournalView);
540} 540}
541 541
542void KOViewManager::showTimeSpanView() 542void KOViewManager::showTimeSpanView()
543{ 543{
544 //mFlagShowNextxDays = false; 544 //mFlagShowNextxDays = false;
545 if (!mTimeSpanView) { 545 if (!mTimeSpanView) {
546 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 546 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
547 "KOViewManager::TimeSpanView"); 547 "KOViewManager::TimeSpanView");
548 addView(mTimeSpanView); 548 addView(mTimeSpanView);
549 549
550 mTimeSpanView->readSettings(); 550 mTimeSpanView->readSettings();
551 } 551 }
552 552
553 showView(mTimeSpanView); 553 showView(mTimeSpanView);
554} 554}
555 555
556Incidence *KOViewManager::currentSelection() 556Incidence *KOViewManager::currentSelection()
557{ 557{
558 if (!mCurrentView) return 0; 558 if (!mCurrentView) return 0;
559 if ( mCurrentView == mListView ) { 559 if ( mCurrentView == mListView ) {
560 if ( mListView->currentItem() ) 560 if ( mListView->currentItem() )
561 return mListView->currentItem(); 561 return mListView->currentItem();
562 } 562 }
563 return mCurrentView->selectedIncidences().first(); 563 return mCurrentView->selectedIncidences().first();
564} 564}
565 565
566QDate KOViewManager::currentSelectionDate() 566QDate KOViewManager::currentSelectionDate()
567{ 567{
568 QDate qd; 568 QDate qd;
569 if (mCurrentView) { 569 if (mCurrentView) {
570 DateList qvl = mCurrentView->selectedDates(); 570 DateList qvl = mCurrentView->selectedDates();
571 if (!qvl.isEmpty()) qd = qvl.first(); 571 if (!qvl.isEmpty()) qd = qvl.first();
572 } 572 }
573 return qd; 573 return qd;
574} 574}
575 575
576void KOViewManager::addView(KOrg::BaseView *view) 576void KOViewManager::addView(KOrg::BaseView *view)
577{ 577{
578#if QT_VERSION >= 300 578#if QT_VERSION >= 0x030000
579 mMainView->viewStack()->addWidget( view ); 579 mMainView->viewStack()->addWidget( view );
580#else 580#else
581 mMainView->viewStack()->addWidget( view, 1 ); 581 mMainView->viewStack()->addWidget( view, 1 );
582#endif 582#endif
583} 583}
584 584
585void KOViewManager::setDocumentId( const QString &id ) 585void KOViewManager::setDocumentId( const QString &id )
586{ 586{
587 if (mTodoView) mTodoView->setDocumentId( id ); 587 if (mTodoView) mTodoView->setDocumentId( id );
588} 588}
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 72ee1d2..39966b5 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,397 +1,397 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 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 <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <klocale.h> 32#include <klocale.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34 34
35#include <libkdepim/kdateedit.h> 35#include <libkdepim/kdateedit.h>
36 36
37#include "koglobals.h" 37#include "koglobals.h"
38#include "koprefs.h" 38#include "koprefs.h"
39 39
40#include "calendarview.h" 40#include "calendarview.h"
41#include "koviewmanager.h" 41#include "koviewmanager.h"
42#include "searchdialog.h" 42#include "searchdialog.h"
43 43
44SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 44SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
45 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false, 45 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false,
46 i18n("&Find")) 46 i18n("&Find"))
47{ 47{
48 mCalendar = calendar; 48 mCalendar = calendar;
49 QFrame *topFrame = plainPage(); 49 QFrame *topFrame = plainPage();
50 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint()); 50 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint());
51 51
52 // Search expression 52 // Search expression
53 QHBoxLayout *subLayout = new QHBoxLayout(); 53 QHBoxLayout *subLayout = new QHBoxLayout();
54 layout->addLayout(subLayout); 54 layout->addLayout(subLayout);
55 55
56 searchLabel = new QLabel(topFrame); 56 searchLabel = new QLabel(topFrame);
57 searchLabel->setText(i18n("Search for:")); 57 searchLabel->setText(i18n("Search for:"));
58 subLayout->addWidget(searchLabel); 58 subLayout->addWidget(searchLabel);
59 59
60 searchEdit = new QLineEdit(topFrame); 60 searchEdit = new QLineEdit(topFrame);
61 subLayout->addWidget(searchEdit); 61 subLayout->addWidget(searchEdit);
62 searchEdit->setText("*"); // Find all events by default 62 searchEdit->setText("*"); // Find all events by default
63 searchEdit->setFocus(); 63 searchEdit->setFocus();
64 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 64 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
65 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 65 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
66 // Subjects to search 66 // Subjects to search
67 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 67 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
68 // topFrame); 68 // topFrame);
69 69
70 70
71 71
72 QHBox *incidenceGroup = new QHBox( topFrame ); 72 QHBox *incidenceGroup = new QHBox( topFrame );
73 layout->addWidget(incidenceGroup); 73 layout->addWidget(incidenceGroup);
74 74
75 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 75 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
76 mSearchEvent->setChecked(true); 76 mSearchEvent->setChecked(true);
77 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 77 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
78 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 78 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
79 79
80 QHBox *subjectGroup = new QHBox( topFrame ); 80 QHBox *subjectGroup = new QHBox( topFrame );
81 layout->addWidget(subjectGroup); 81 layout->addWidget(subjectGroup);
82 82
83 mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup); 83 mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup);
84 mSummaryCheck->setChecked(true); 84 mSummaryCheck->setChecked(true);
85 mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup); 85 mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup);
86 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 86 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
87 87
88 QHBox *attendeeGroup = new QHBox( topFrame ); 88 QHBox *attendeeGroup = new QHBox( topFrame );
89 layout->addWidget(attendeeGroup ); 89 layout->addWidget(attendeeGroup );
90 new QLabel( i18n("Attendee:"),attendeeGroup ); 90 new QLabel( i18n("Attendee:"),attendeeGroup );
91 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 91 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
92 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 92 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
93 // Date range 93 // Date range
94 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 94 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
95 // topFrame); 95 // topFrame);
96 // layout->addWidget(rangeGroup); 96 // layout->addWidget(rangeGroup);
97 97
98 QWidget *rangeWidget = new QWidget(topFrame); 98 QWidget *rangeWidget = new QWidget(topFrame);
99 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint()); 99 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint());
100 100
101 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 101 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
102 mStartDate = new KDateEdit(rangeWidget); 102 mStartDate = new KDateEdit(rangeWidget);
103 rangeLayout->addWidget(mStartDate); 103 rangeLayout->addWidget(mStartDate);
104 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
105 mEndDate = new KDateEdit(rangeWidget); 105 mEndDate = new KDateEdit(rangeWidget);
106 mEndDate->setDate(QDate::currentDate().addDays(365)); 106 mEndDate->setDate(QDate::currentDate().addDays(365));
107 rangeLayout->addWidget(mEndDate); 107 rangeLayout->addWidget(mEndDate);
108 108
109 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame); 109 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame);
110 //mInclusiveCheck->setChecked(false); 110 //mInclusiveCheck->setChecked(false);
111 layout->addWidget(rangeWidget); 111 layout->addWidget(rangeWidget);
112 //layout->addWidget(mInclusiveCheck); 112 //layout->addWidget(mInclusiveCheck);
113 // Subjects to search 113 // Subjects to search
114 114
115 115
116 // Results list view 116 // Results list view
117 listView = new KOListView(mCalendar,topFrame); 117 listView = new KOListView(mCalendar,topFrame);
118 //listView->showDates(); 118 //listView->showDates();
119 119
120 120
121 layout->addWidget(listView); 121 layout->addWidget(listView);
122 122
123 // if ( KOPrefs::instance()->mCompactDialogs ) { 123 // if ( KOPrefs::instance()->mCompactDialogs ) {
124 // KOGlobals::fitDialogToScreen( this, true ); 124 // KOGlobals::fitDialogToScreen( this, true );
125 // } 125 // }
126 126
127 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 127 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
128 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch())); 128 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch()));
129 QPushButton *CloseButton = findButton( Close ); 129 QPushButton *CloseButton = findButton( Close );
130 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear())); 130 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear()));
131 131
132#ifndef DESKTOP_VERSION 132#ifndef DESKTOP_VERSION
133 setCaption(i18n("Click OK to search ->")); 133 setCaption(i18n("Click OK to search ->"));
134 hideButtons(); 134 hideButtons();
135#endif 135#endif
136} 136}
137 137
138SearchDialog::~SearchDialog() 138SearchDialog::~SearchDialog()
139{ 139{
140 140
141} 141}
142void SearchDialog::accept() 142void SearchDialog::accept()
143{ 143{
144 doSearch(); 144 doSearch();
145} 145}
146void SearchDialog::updateList() 146void SearchDialog::updateList()
147{ 147{
148 //listView->updateList(); 148 //listView->updateList();
149 if ( isVisible() ) { 149 if ( isVisible() ) {
150 updateView(); 150 updateView();
151 //qDebug("SearchDialog::updated "); 151 //qDebug("SearchDialog::updated ");
152 } 152 }
153 else { 153 else {
154 listView->clear(); 154 listView->clear();
155 //qDebug("SearchDialog::cleared "); 155 //qDebug("SearchDialog::cleared ");
156 156
157 } 157 }
158} 158}
159void SearchDialog::searchTextChanged( const QString &_text ) 159void SearchDialog::searchTextChanged( const QString &_text )
160{ 160{
161 enableButton( KDialogBase::User1, !_text.isEmpty() ); 161 enableButton( KDialogBase::User1, !_text.isEmpty() );
162} 162}
163 163
164void SearchDialog::doSearch() 164void SearchDialog::doSearch()
165{ 165{
166 QRegExp re; 166 QRegExp re;
167 167
168 re.setWildcard(true); // most people understand these better. 168 re.setWildcard(true); // most people understand these better.
169 re.setCaseSensitive(false); 169 re.setCaseSensitive(false);
170 re.setPattern(searchEdit->text()); 170 re.setPattern(searchEdit->text());
171 if (!re.isValid() ) { 171 if (!re.isValid() ) {
172 KMessageBox::sorry(this, 172 KMessageBox::sorry(this,
173 i18n("Invalid search expression,\ncannot perform " 173 i18n("Invalid search expression,\ncannot perform "
174 "the search.\nPlease enter a search expression\n" 174 "the search.\nPlease enter a search expression\n"
175 "using the wildcard characters\n '*' and '?'" 175 "using the wildcard characters\n '*' and '?'"
176 "where needed.")); 176 "where needed."));
177 return; 177 return;
178 } 178 }
179 179
180 search(re); 180 search(re);
181 181
182 listView->setStartDate( mStartDate->date() ); 182 listView->setStartDate( mStartDate->date() );
183 listView->showEvents(mMatchedEvents); 183 listView->showEvents(mMatchedEvents);
184 listView->addTodos(mMatchedTodos); 184 listView->addTodos(mMatchedTodos);
185 listView->addJournals(mMatchedJournals); 185 listView->addJournals(mMatchedJournals);
186 186
187 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 187 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
188 KMessageBox::information(this, 188 KMessageBox::information(this,
189 i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed.")); 189 i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed."));
190#ifndef DESKTOP_VERSION 190#ifndef DESKTOP_VERSION
191 setCaption(i18n("Click OK to search ->")); 191 setCaption(i18n("Click OK to search ->"));
192#else 192#else
193 setCaption(i18n("KO/Pi Find ")); 193 setCaption(i18n("KO/Pi Find "));
194#endif 194#endif
195 } else { 195 } else {
196 QString mess; 196 QString mess;
197 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 197 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
198 setCaption( i18n("KO/Pi Find: ") + mess); 198 setCaption( i18n("KO/Pi Find: ") + mess);
199 199
200 } 200 }
201} 201}
202void SearchDialog::updateConfig() 202void SearchDialog::updateConfig()
203{ 203{
204 listView->updateConfig(); 204 listView->updateConfig();
205} 205}
206void SearchDialog::updateView() 206void SearchDialog::updateView()
207{ 207{
208 208
209 QRegExp re; 209 QRegExp re;
210 re.setWildcard(true); // most people understand these better. 210 re.setWildcard(true); // most people understand these better.
211 re.setCaseSensitive(false); 211 re.setCaseSensitive(false);
212 re.setPattern(searchEdit->text()); 212 re.setPattern(searchEdit->text());
213 if (re.isValid()) { 213 if (re.isValid()) {
214 search(re); 214 search(re);
215 } else { 215 } else {
216 mMatchedEvents.clear(); 216 mMatchedEvents.clear();
217 mMatchedTodos.clear(); 217 mMatchedTodos.clear();
218 mMatchedJournals.clear(); 218 mMatchedJournals.clear();
219 } 219 }
220 listView->setStartDate( mStartDate->date() ); 220 listView->setStartDate( mStartDate->date() );
221 listView->showEvents(mMatchedEvents); 221 listView->showEvents(mMatchedEvents);
222 listView->addTodos(mMatchedTodos); 222 listView->addTodos(mMatchedTodos);
223 listView->addJournals(mMatchedJournals); 223 listView->addJournals(mMatchedJournals);
224} 224}
225 225
226void SearchDialog::search(const QRegExp &re) 226void SearchDialog::search(const QRegExp &re)
227{ 227{
228 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 228 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
229 mEndDate->date(), 229 mEndDate->date(),
230 false /*mInclusiveCheck->isChecked()*/ ); 230 false /*mInclusiveCheck->isChecked()*/ );
231 231
232 mMatchedEvents.clear(); 232 mMatchedEvents.clear();
233 if ( mSearchEvent->isChecked() ) { 233 if ( mSearchEvent->isChecked() ) {
234 Event *ev; 234 Event *ev;
235 for(ev=events.first();ev;ev=events.next()) { 235 for(ev=events.first();ev;ev=events.next()) {
236 if (mSummaryCheck->isChecked()) { 236 if (mSummaryCheck->isChecked()) {
237#if QT_VERSION >= 300 237#if QT_VERSION >= 0x030000
238 if (re.search(ev->summary()) != -1) 238 if (re.search(ev->summary()) != -1)
239#else 239#else
240 if (re.match(ev->summary()) != -1) 240 if (re.match(ev->summary()) != -1)
241#endif 241#endif
242 { 242 {
243 mMatchedEvents.append(ev); 243 mMatchedEvents.append(ev);
244 continue; 244 continue;
245 } 245 }
246 } 246 }
247 if (mDescriptionCheck->isChecked()) { 247 if (mDescriptionCheck->isChecked()) {
248#if QT_VERSION >= 300 248#if QT_VERSION >= 0x030000
249 if (re.search(ev->description()) != -1) 249 if (re.search(ev->description()) != -1)
250#else 250#else
251 if (re.match(ev->description()) != -1) 251 if (re.match(ev->description()) != -1)
252#endif 252#endif
253 { 253 {
254 mMatchedEvents.append(ev); 254 mMatchedEvents.append(ev);
255 continue; 255 continue;
256 } 256 }
257 } 257 }
258 if (mCategoryCheck->isChecked()) { 258 if (mCategoryCheck->isChecked()) {
259#if QT_VERSION >= 300 259#if QT_VERSION >= 0x030000
260 if (re.search(ev->categoriesStr()) != -1) 260 if (re.search(ev->categoriesStr()) != -1)
261#else 261#else
262 if (re.match(ev->categoriesStr()) != -1) 262 if (re.match(ev->categoriesStr()) != -1)
263#endif 263#endif
264 { 264 {
265 mMatchedEvents.append(ev); 265 mMatchedEvents.append(ev);
266 continue; 266 continue;
267 } 267 }
268 } 268 }
269 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 269 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
270 QPtrList<Attendee> tmpAList = ev->attendees(); 270 QPtrList<Attendee> tmpAList = ev->attendees();
271 Attendee *a; 271 Attendee *a;
272 for (a = tmpAList.first(); a; a = tmpAList.next()) { 272 for (a = tmpAList.first(); a; a = tmpAList.next()) {
273 if (mSearchAName->isChecked()) { 273 if (mSearchAName->isChecked()) {
274#if QT_VERSION >= 300 274#if QT_VERSION >= 0x030000
275 if (re.search(a->name()) != -1) 275 if (re.search(a->name()) != -1)
276#else 276#else
277 if (re.match(a->name()) != -1) 277 if (re.match(a->name()) != -1)
278#endif 278#endif
279 { 279 {
280 mMatchedEvents.append(ev); 280 mMatchedEvents.append(ev);
281 break; 281 break;
282 } 282 }
283 } 283 }
284 if (mSearchAEmail->isChecked()) { 284 if (mSearchAEmail->isChecked()) {
285#if QT_VERSION >= 300 285#if QT_VERSION >= 0x030000
286 if (re.search(a->email()) != -1) 286 if (re.search(a->email()) != -1)
287#else 287#else
288 if (re.match(a->email()) != -1) 288 if (re.match(a->email()) != -1)
289#endif 289#endif
290 { 290 {
291 mMatchedEvents.append(ev); 291 mMatchedEvents.append(ev);
292 break; 292 break;
293 } 293 }
294 } 294 }
295 } 295 }
296 } 296 }
297 } 297 }
298 } 298 }
299 QPtrList<Todo> todos = mCalendar->todos( ); 299 QPtrList<Todo> todos = mCalendar->todos( );
300 mMatchedTodos.clear(); 300 mMatchedTodos.clear();
301 if ( mSearchTodo->isChecked() ) { 301 if ( mSearchTodo->isChecked() ) {
302 Todo *tod; 302 Todo *tod;
303 for(tod=todos.first();tod;tod=todos.next()) { 303 for(tod=todos.first();tod;tod=todos.next()) {
304 if (mSummaryCheck->isChecked()) { 304 if (mSummaryCheck->isChecked()) {
305#if QT_VERSION >= 300 305#if QT_VERSION >= 0x030000
306 if (re.search(tod->summary()) != -1) 306 if (re.search(tod->summary()) != -1)
307#else 307#else
308 if (re.match(tod->summary()) != -1) 308 if (re.match(tod->summary()) != -1)
309#endif 309#endif
310 { 310 {
311 mMatchedTodos.append(tod); 311 mMatchedTodos.append(tod);
312 continue; 312 continue;
313 } 313 }
314 } 314 }
315 if (mDescriptionCheck->isChecked()) { 315 if (mDescriptionCheck->isChecked()) {
316#if QT_VERSION >= 300 316#if QT_VERSION >= 0x030000
317 if (re.search(tod->description()) != -1) 317 if (re.search(tod->description()) != -1)
318#else 318#else
319 if (re.match(tod->description()) != -1) 319 if (re.match(tod->description()) != -1)
320#endif 320#endif
321 { 321 {
322 mMatchedTodos.append(tod); 322 mMatchedTodos.append(tod);
323 continue; 323 continue;
324 } 324 }
325 } 325 }
326 if (mCategoryCheck->isChecked()) { 326 if (mCategoryCheck->isChecked()) {
327#if QT_VERSION >= 300 327#if QT_VERSION >= 0x030000
328 if (re.search(tod->categoriesStr()) != -1) 328 if (re.search(tod->categoriesStr()) != -1)
329#else 329#else
330 if (re.match(tod->categoriesStr()) != -1) 330 if (re.match(tod->categoriesStr()) != -1)
331#endif 331#endif
332 { 332 {
333 mMatchedTodos.append(tod); 333 mMatchedTodos.append(tod);
334 continue; 334 continue;
335 } 335 }
336 } 336 }
337 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 337 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
338 QPtrList<Attendee> tmpAList = tod->attendees(); 338 QPtrList<Attendee> tmpAList = tod->attendees();
339 Attendee *a; 339 Attendee *a;
340 for (a = tmpAList.first(); a; a = tmpAList.next()) { 340 for (a = tmpAList.first(); a; a = tmpAList.next()) {
341 if (mSearchAName->isChecked()) { 341 if (mSearchAName->isChecked()) {
342#if QT_VERSION >= 300 342#if QT_VERSION >= 0x030000
343 if (re.search(a->name()) != -1) 343 if (re.search(a->name()) != -1)
344#else 344#else
345 if (re.match(a->name()) != -1) 345 if (re.match(a->name()) != -1)
346#endif 346#endif
347 { 347 {
348 mMatchedTodos.append(tod); 348 mMatchedTodos.append(tod);
349 break; 349 break;
350 } 350 }
351 } 351 }
352 if (mSearchAEmail->isChecked()) { 352 if (mSearchAEmail->isChecked()) {
353#if QT_VERSION >= 300 353#if QT_VERSION >= 0x030000
354 if (re.search(a->email()) != -1) 354 if (re.search(a->email()) != -1)
355#else 355#else
356 if (re.match(a->email()) != -1) 356 if (re.match(a->email()) != -1)
357#endif 357#endif
358 { 358 {
359 mMatchedTodos.append(tod); 359 mMatchedTodos.append(tod);
360 break; 360 break;
361 } 361 }
362 } 362 }
363 } 363 }
364 } 364 }
365 } 365 }
366 } 366 }
367 mMatchedJournals.clear(); 367 mMatchedJournals.clear();
368 if (mSearchJournal->isChecked() ) { 368 if (mSearchJournal->isChecked() ) {
369 QPtrList<Journal> journals = mCalendar->journals( ); 369 QPtrList<Journal> journals = mCalendar->journals( );
370 Journal* journ; 370 Journal* journ;
371 371
372 for(journ=journals.first();journ;journ=journals.next()) { 372 for(journ=journals.first();journ;journ=journals.next()) {
373 if ( journ->dtStart().date() <= mEndDate->date() 373 if ( journ->dtStart().date() <= mEndDate->date()
374 &&journ->dtStart().date() >= mStartDate->date()) { 374 &&journ->dtStart().date() >= mStartDate->date()) {
375#if QT_VERSION >= 300 375#if QT_VERSION >= 0x030000
376 if (re.search(journ->description()) != -1) 376 if (re.search(journ->description()) != -1)
377#else 377#else
378 if (re.match(journ->description()) != -1) 378 if (re.match(journ->description()) != -1)
379#endif 379#endif
380 { 380 {
381 mMatchedJournals.append(journ); 381 mMatchedJournals.append(journ);
382 continue; 382 continue;
383 } 383 }
384 } 384 }
385 } 385 }
386 } 386 }
387 387
388} 388}
389/* 389/*
390void SearchDialog::keyPressEvent ( QKeyEvent *e) 390void SearchDialog::keyPressEvent ( QKeyEvent *e)
391{ 391{
392 392
393 e->ignore(); 393 e->ignore();
394 394
395} 395}
396*/ 396*/
397//mMatchedJournals; 397//mMatchedJournals;
diff --git a/korganizer/timespanview.cpp b/korganizer/timespanview.cpp
index 67a3811..df8ff88 100644
--- a/korganizer/timespanview.cpp
+++ b/korganizer/timespanview.cpp
@@ -1,157 +1,157 @@
1 1
2#ifndef DESKTOP_VERSION 2#ifndef DESKTOP_VERSION
3#include <qksplitter.h> 3#include <qksplitter.h>
4#else 4#else
5#include <qsplitter.h> 5#include <qsplitter.h>
6#endif 6#endif
7#include <qlistview.h> 7#include <qlistview.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qheader.h> 9#include <qheader.h>
10#include <qpushbutton.h> 10#include <qpushbutton.h>
11 11
12#include <klocale.h> 12#include <klocale.h>
13#include <kdebug.h> 13#include <kdebug.h>
14 14
15#include "lineview.h" 15#include "lineview.h"
16#include "timeline.h" 16#include "timeline.h"
17 17
18#include "timespanview.h" 18#include "timespanview.h"
19 19
20 20
21TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) : 21TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) :
22 QWidget( parent, name ) 22 QWidget( parent, name )
23{ 23{
24 QBoxLayout *topLayout = new QVBoxLayout( this ); 24 QBoxLayout *topLayout = new QVBoxLayout( this );
25#ifndef DESKTOP_VERSION 25#ifndef DESKTOP_VERSION
26 mSplitter = new QKSplitter( this ); 26 mSplitter = new QKSplitter( this );
27#else 27#else
28 mSplitter = new QSplitter( this ); 28 mSplitter = new QSplitter( this );
29#endif 29#endif
30 topLayout->addWidget( mSplitter ); 30 topLayout->addWidget( mSplitter );
31 31
32 mList = new QListView( mSplitter ); 32 mList = new QListView( mSplitter );
33 mList->addColumn( i18n("Summary") ); 33 mList->addColumn( i18n("Summary") );
34 34
35 QWidget *rightPane = new QWidget( mSplitter ); 35 QWidget *rightPane = new QWidget( mSplitter );
36 QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane ); 36 QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane );
37 37
38 mTimeLine = new TimeLine( rightPane ); 38 mTimeLine = new TimeLine( rightPane );
39 mTimeLine->setFixedHeight( mList->header()->height() ); 39 mTimeLine->setFixedHeight( mList->header()->height() );
40 rightPaneLayout->addWidget( mTimeLine ); 40 rightPaneLayout->addWidget( mTimeLine );
41 41
42 mLineView = new LineView( rightPane ); 42 mLineView = new LineView( rightPane );
43 rightPaneLayout->addWidget( mLineView ); 43 rightPaneLayout->addWidget( mLineView );
44 44
45 QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout ); 45 QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout );
46 46
47 QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane ); 47 QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane );
48 connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) ); 48 connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) );
49 buttonLayout->addWidget( zoomInButton ); 49 buttonLayout->addWidget( zoomInButton );
50 50
51 QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane ); 51 QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane );
52 connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) ); 52 connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) );
53 buttonLayout->addWidget( zoomOutButton ); 53 buttonLayout->addWidget( zoomOutButton );
54 54
55 QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane ); 55 QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane );
56 connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) ); 56 connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) );
57 buttonLayout->addWidget( centerButton ); 57 buttonLayout->addWidget( centerButton );
58 58
59 connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)), 59 connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)),
60 mTimeLine,SLOT(setContentsPos(int))); 60 mTimeLine,SLOT(setContentsPos(int)));
61} 61}
62 62
63TimeSpanView::~TimeSpanView() 63TimeSpanView::~TimeSpanView()
64{ 64{
65} 65}
66 66
67QValueList<int> TimeSpanView::splitterSizes() 67QValueList<int> TimeSpanView::splitterSizes()
68{ 68{
69 return mSplitter->sizes(); 69 return mSplitter->sizes();
70} 70}
71 71
72void TimeSpanView::setSplitterSizes( QValueList<int> sizes ) 72void TimeSpanView::setSplitterSizes( QValueList<int> sizes )
73{ 73{
74 mSplitter->setSizes( sizes ); 74 mSplitter->setSizes( sizes );
75} 75}
76 76
77void TimeSpanView::addItem( KCal::Event *event ) 77void TimeSpanView::addItem( KCal::Event *event )
78{ 78{
79 new QListViewItem( mList, event->summary() ); 79 new QListViewItem( mList, event->summary() );
80 80
81 QDateTime startDt = event->dtStart(); 81 QDateTime startDt = event->dtStart();
82 QDateTime endDt = event->dtEnd(); 82 QDateTime endDt = event->dtEnd();
83 83
84// kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString() 84// kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString()
85// << " end: " << endDt.toString() << endl; 85// << " end: " << endDt.toString() << endl;
86 86
87 int startSecs = mStartDate.secsTo( startDt ); 87 int startSecs = mStartDate.secsTo( startDt );
88 int durationSecs = startDt.secsTo( endDt ); 88 int durationSecs = startDt.secsTo( endDt );
89 89
90// kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl; 90// kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl;
91 91
92 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel; 92 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel;
93 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel; 93 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel;
94 94
95// kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl; 95// kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl;
96 96
97 mLineView->addLine( startX, endX ); 97 mLineView->addLine( startX, endX );
98} 98}
99 99
100void TimeSpanView::clear() 100void TimeSpanView::clear()
101{ 101{
102 mList->clear(); 102 mList->clear();
103 mLineView->clear(); 103 mLineView->clear();
104} 104}
105 105
106void TimeSpanView::updateView() 106void TimeSpanView::updateView()
107{ 107{
108#if QT_VERSION >= 300 108#if QT_VERSION >= 0x030000
109 mLineView->updateContents(); 109 mLineView->updateContents();
110 mTimeLine->updateContents(); 110 mTimeLine->updateContents();
111#else 111#else
112#endif 112#endif
113} 113}
114 114
115void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end ) 115void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end )
116{ 116{
117 mStartDate = start; 117 mStartDate = start;
118 mEndDate = end; 118 mEndDate = end;
119 119
120 mTimeLine->setDateRange( start, end ); 120 mTimeLine->setDateRange( start, end );
121 121
122 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth(); 122 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth();
123} 123}
124 124
125QDateTime TimeSpanView::startDateTime() 125QDateTime TimeSpanView::startDateTime()
126{ 126{
127 return mStartDate; 127 return mStartDate;
128} 128}
129 129
130QDateTime TimeSpanView::endDateTime() 130QDateTime TimeSpanView::endDateTime()
131{ 131{
132 return mEndDate; 132 return mEndDate;
133} 133}
134 134
135void TimeSpanView::zoomIn() 135void TimeSpanView::zoomIn()
136{ 136{
137 int span = mStartDate.daysTo( mEndDate ); 137 int span = mStartDate.daysTo( mEndDate );
138 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) ); 138 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) );
139 139
140 emit dateRangeChanged(); 140 emit dateRangeChanged();
141} 141}
142 142
143void TimeSpanView::zoomOut() 143void TimeSpanView::zoomOut()
144{ 144{
145 int span = mStartDate.daysTo( mEndDate ); 145 int span = mStartDate.daysTo( mEndDate );
146 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) ); 146 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) );
147 147
148 emit dateRangeChanged(); 148 emit dateRangeChanged();
149} 149}
150 150
151void TimeSpanView::centerView() 151void TimeSpanView::centerView()
152{ 152{
153 QScrollBar *scrollBar = mLineView->horizontalScrollBar(); 153 QScrollBar *scrollBar = mLineView->horizontalScrollBar();
154 int min = scrollBar->minValue(); 154 int min = scrollBar->minValue();
155 int max = scrollBar->maxValue(); 155 int max = scrollBar->maxValue();
156 scrollBar->setValue( min + (max-min) / 2 ); 156 scrollBar->setValue( min + (max-min) / 2 );
157} 157}
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index c23978d..bd13132 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -1,978 +1,974 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
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 <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qfile.h> 24#include <qfile.h>
25 25
26#include <kdebug.h> 26#include <kdebug.h>
27#include <klocale.h> 27#include <klocale.h>
28#include <kglobal.h> 28#include <kglobal.h>
29 29
30extern "C" { 30extern "C" {
31 #include <ical.h> 31 #include <ical.h>
32 #include <icalss.h> 32 #include <icalss.h>
33 #include <icalparser.h> 33 #include <icalparser.h>
34 #include <icalrestriction.h> 34 #include <icalrestriction.h>
35} 35}
36 36
37#include "calendar.h" 37#include "calendar.h"
38#include "journal.h" 38#include "journal.h"
39#include "icalformat.h" 39#include "icalformat.h"
40#include "icalformatimpl.h" 40#include "icalformatimpl.h"
41#include "compat.h" 41#include "compat.h"
42 42
43#define _ICAL_VERSION "2.0" 43#define _ICAL_VERSION "2.0"
44 44
45using namespace KCal; 45using namespace KCal;
46 46
47const int gSecondsPerMinute = 60; 47const int gSecondsPerMinute = 60;
48const int gSecondsPerHour = gSecondsPerMinute * 60; 48const int gSecondsPerHour = gSecondsPerMinute * 60;
49const int gSecondsPerDay = gSecondsPerHour * 24; 49const int gSecondsPerDay = gSecondsPerHour * 24;
50const int gSecondsPerWeek = gSecondsPerDay * 7; 50const int gSecondsPerWeek = gSecondsPerDay * 7;
51 51
52ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : 52ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) :
53 mParent( parent ), mCalendarVersion( 0 ) 53 mParent( parent ), mCalendarVersion( 0 )
54{ 54{
55 mCompat = new Compat; 55 mCompat = new Compat;
56} 56}
57 57
58ICalFormatImpl::~ICalFormatImpl() 58ICalFormatImpl::~ICalFormatImpl()
59{ 59{
60 delete mCompat; 60 delete mCompat;
61} 61}
62 62
63class ToStringVisitor : public Incidence::Visitor 63class ToStringVisitor : public Incidence::Visitor
64{ 64{
65 public: 65 public:
66 ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} 66 ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {}
67 67
68 bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } 68 bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; }
69 bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } 69 bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; }
70 bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } 70 bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; }
71 71
72 icalcomponent *component() { return mComponent; } 72 icalcomponent *component() { return mComponent; }
73 73
74 private: 74 private:
75 ICalFormatImpl *mImpl; 75 ICalFormatImpl *mImpl;
76 icalcomponent *mComponent; 76 icalcomponent *mComponent;
77}; 77};
78 78
79icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) 79icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence)
80{ 80{
81 ToStringVisitor v( this ); 81 ToStringVisitor v( this );
82 incidence->accept(v); 82 incidence->accept(v);
83 return v.component(); 83 return v.component();
84} 84}
85 85
86icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) 86icalcomponent *ICalFormatImpl::writeTodo(Todo *todo)
87{ 87{
88 QString tmpStr; 88 QString tmpStr;
89 QStringList tmpStrList; 89 QStringList tmpStrList;
90 90
91 icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); 91 icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
92 92
93 writeIncidence(vtodo,todo); 93 writeIncidence(vtodo,todo);
94 94
95 // due date 95 // due date
96 if (todo->hasDueDate()) { 96 if (todo->hasDueDate()) {
97 icaltimetype due; 97 icaltimetype due;
98 if (todo->doesFloat()) { 98 if (todo->doesFloat()) {
99 due = writeICalDate(todo->dtDue().date()); 99 due = writeICalDate(todo->dtDue().date());
100 } else { 100 } else {
101 due = writeICalDateTime(todo->dtDue()); 101 due = writeICalDateTime(todo->dtDue());
102 } 102 }
103 icalcomponent_add_property(vtodo,icalproperty_new_due(due)); 103 icalcomponent_add_property(vtodo,icalproperty_new_due(due));
104 } 104 }
105 105
106 // start time 106 // start time
107 if (todo->hasStartDate()) { 107 if (todo->hasStartDate()) {
108 icaltimetype start; 108 icaltimetype start;
109 if (todo->doesFloat()) { 109 if (todo->doesFloat()) {
110// kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; 110// kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl;
111 start = writeICalDate(todo->dtStart().date()); 111 start = writeICalDate(todo->dtStart().date());
112 } else { 112 } else {
113// kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; 113// kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl;
114 start = writeICalDateTime(todo->dtStart()); 114 start = writeICalDateTime(todo->dtStart());
115 } 115 }
116 icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); 116 icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start));
117 } 117 }
118 118
119 // completion date 119 // completion date
120 if (todo->isCompleted()) { 120 if (todo->isCompleted()) {
121 if (!todo->hasCompletedDate()) { 121 if (!todo->hasCompletedDate()) {
122 // If todo was created by KOrganizer <2.2 it has no correct completion 122 // If todo was created by KOrganizer <2.2 it has no correct completion
123 // date. Set it to now. 123 // date. Set it to now.
124 todo->setCompleted(QDateTime::currentDateTime()); 124 todo->setCompleted(QDateTime::currentDateTime());
125 } 125 }
126 icaltimetype completed = writeICalDateTime(todo->completed()); 126 icaltimetype completed = writeICalDateTime(todo->completed());
127 icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); 127 icalcomponent_add_property(vtodo,icalproperty_new_completed(completed));
128 } 128 }
129 129
130 icalcomponent_add_property(vtodo, 130 icalcomponent_add_property(vtodo,
131 icalproperty_new_percentcomplete(todo->percentComplete())); 131 icalproperty_new_percentcomplete(todo->percentComplete()));
132 132
133 return vtodo; 133 return vtodo;
134} 134}
135 135
136icalcomponent *ICalFormatImpl::writeEvent(Event *event) 136icalcomponent *ICalFormatImpl::writeEvent(Event *event)
137{ 137{
138 kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() 138 kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid()
139 << ")" << endl; 139 << ")" << endl;
140 140
141 QString tmpStr; 141 QString tmpStr;
142 QStringList tmpStrList; 142 QStringList tmpStrList;
143 143
144 icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); 144 icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
145 145
146 writeIncidence(vevent,event); 146 writeIncidence(vevent,event);
147 147
148 // start time 148 // start time
149 icaltimetype start; 149 icaltimetype start;
150 if (event->doesFloat()) { 150 if (event->doesFloat()) {
151// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 151// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
152 start = writeICalDate(event->dtStart().date()); 152 start = writeICalDate(event->dtStart().date());
153 } else { 153 } else {
154// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 154// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
155 start = writeICalDateTime(event->dtStart()); 155 start = writeICalDateTime(event->dtStart());
156 } 156 }
157 icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); 157 icalcomponent_add_property(vevent,icalproperty_new_dtstart(start));
158 158
159 if (event->hasEndDate()) { 159 if (event->hasEndDate()) {
160 // end time 160 // end time
161 icaltimetype end; 161 icaltimetype end;
162 if (event->doesFloat()) { 162 if (event->doesFloat()) {
163// kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; 163// kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl;
164 // +1 day because end date is non-inclusive. 164 // +1 day because end date is non-inclusive.
165 end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); 165 end = writeICalDate( event->dtEnd().date().addDays( 1 ) );
166 } else { 166 } else {
167// kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; 167// kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl;
168 end = writeICalDateTime(event->dtEnd()); 168 end = writeICalDateTime(event->dtEnd());
169 } 169 }
170 icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); 170 icalcomponent_add_property(vevent,icalproperty_new_dtend(end));
171 } 171 }
172 172
173// TODO: attachments, resources 173// TODO: attachments, resources
174#if 0 174#if 0
175 // attachments 175 // attachments
176 tmpStrList = anEvent->attachments(); 176 tmpStrList = anEvent->attachments();
177 for ( QStringList::Iterator it = tmpStrList.begin(); 177 for ( QStringList::Iterator it = tmpStrList.begin();
178 it != tmpStrList.end(); 178 it != tmpStrList.end();
179 ++it ) 179 ++it )
180 addPropValue(vevent, VCAttachProp, (*it).utf8()); 180 addPropValue(vevent, VCAttachProp, (*it).utf8());
181 181
182 // resources 182 // resources
183 tmpStrList = anEvent->resources(); 183 tmpStrList = anEvent->resources();
184 tmpStr = tmpStrList.join(";"); 184 tmpStr = tmpStrList.join(";");
185 if (!tmpStr.isEmpty()) 185 if (!tmpStr.isEmpty())
186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); 186 addPropValue(vevent, VCResourcesProp, tmpStr.utf8());
187 187
188#endif 188#endif
189 189
190 // Transparency 190 // Transparency
191 switch( event->transparency() ) { 191 switch( event->transparency() ) {
192 case Event::Transparent: 192 case Event::Transparent:
193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); 193 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT));
194 break; 194 break;
195 case Event::Opaque: 195 case Event::Opaque:
196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); 196 icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE));
197 break; 197 break;
198 } 198 }
199 199
200 return vevent; 200 return vevent;
201} 201}
202 202
203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, 203icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
204 Scheduler::Method method) 204 Scheduler::Method method)
205{ 205{
206#if QT_VERSION >= 300 206
207 kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: "
208 << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: "
209 << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl;
210#endif
211 207
212 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); 208 icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT);
213 209
214 writeIncidenceBase(vfreebusy,freebusy); 210 writeIncidenceBase(vfreebusy,freebusy);
215 211
216 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( 212 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart(
217 writeICalDateTime(freebusy->dtStart()))); 213 writeICalDateTime(freebusy->dtStart())));
218 214
219 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( 215 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend(
220 writeICalDateTime(freebusy->dtEnd()))); 216 writeICalDateTime(freebusy->dtEnd())));
221 217
222 if (method == Scheduler::Request) { 218 if (method == Scheduler::Request) {
223 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 219 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
224 freebusy->uid().utf8())); 220 freebusy->uid().utf8()));
225 } 221 }
226 222
227 //Loops through all the periods in the freebusy object 223 //Loops through all the periods in the freebusy object
228 QValueList<Period> list = freebusy->busyPeriods(); 224 QValueList<Period> list = freebusy->busyPeriods();
229 QValueList<Period>::Iterator it; 225 QValueList<Period>::Iterator it;
230 icalperiodtype period; 226 icalperiodtype period;
231 for (it = list.begin(); it!= list.end(); ++it) { 227 for (it = list.begin(); it!= list.end(); ++it) {
232 period.start = writeICalDateTime((*it).start()); 228 period.start = writeICalDateTime((*it).start());
233 period.end = writeICalDateTime((*it).end()); 229 period.end = writeICalDateTime((*it).end());
234 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 230 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
235 } 231 }
236 232
237 return vfreebusy; 233 return vfreebusy;
238} 234}
239 235
240icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) 236icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
241{ 237{
242 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); 238 icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT);
243 239
244 writeIncidence(vjournal,journal); 240 writeIncidence(vjournal,journal);
245 241
246 // start time 242 // start time
247 if (journal->dtStart().isValid()) { 243 if (journal->dtStart().isValid()) {
248 icaltimetype start; 244 icaltimetype start;
249 if (journal->doesFloat()) { 245 if (journal->doesFloat()) {
250// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; 246// kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl;
251 start = writeICalDate(journal->dtStart().date()); 247 start = writeICalDate(journal->dtStart().date());
252 } else { 248 } else {
253// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; 249// kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl;
254 start = writeICalDateTime(journal->dtStart()); 250 start = writeICalDateTime(journal->dtStart());
255 } 251 }
256 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); 252 icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start));
257 } 253 }
258 254
259 return vjournal; 255 return vjournal;
260} 256}
261 257
262void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) 258void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
263{ 259{
264 // pilot sync stuff 260 // pilot sync stuff
265// TODO: move this application-specific code to kpilot 261// TODO: move this application-specific code to kpilot
266 if (incidence->pilotId()) { 262 if (incidence->pilotId()) {
267 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); 263 incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId()));
268 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); 264 incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus()));
269 } 265 }
270 if ( !incidence->IDStr().isEmpty()) { 266 if ( !incidence->IDStr().isEmpty()) {
271 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); 267 incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() );
272 } 268 }
273 269
274 270
275 writeIncidenceBase(parent,incidence); 271 writeIncidenceBase(parent,incidence);
276 if (incidence->cancelled()) { 272 if (incidence->cancelled()) {
277 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); 273 icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED));
278 } 274 }
279 275
280 // creation date 276 // creation date
281 icalcomponent_add_property(parent,icalproperty_new_created( 277 icalcomponent_add_property(parent,icalproperty_new_created(
282 writeICalDateTime(incidence->created()))); 278 writeICalDateTime(incidence->created())));
283 279
284 // unique id 280 // unique id
285 icalcomponent_add_property(parent,icalproperty_new_uid( 281 icalcomponent_add_property(parent,icalproperty_new_uid(
286 incidence->uid().utf8())); 282 incidence->uid().utf8()));
287 283
288 // revision 284 // revision
289 icalcomponent_add_property(parent,icalproperty_new_sequence( 285 icalcomponent_add_property(parent,icalproperty_new_sequence(
290 incidence->revision())); 286 incidence->revision()));
291 287
292 // last modification date 288 // last modification date
293 icalcomponent_add_property(parent,icalproperty_new_lastmodified( 289 icalcomponent_add_property(parent,icalproperty_new_lastmodified(
294 writeICalDateTime(incidence->lastModified()))); 290 writeICalDateTime(incidence->lastModified())));
295 291
296 // description 292 // description
297 if (!incidence->description().isEmpty()) { 293 if (!incidence->description().isEmpty()) {
298 icalcomponent_add_property(parent,icalproperty_new_description( 294 icalcomponent_add_property(parent,icalproperty_new_description(
299 incidence->description().utf8())); 295 incidence->description().utf8()));
300 } 296 }
301 297
302 // summary 298 // summary
303 if (!incidence->summary().isEmpty()) { 299 if (!incidence->summary().isEmpty()) {
304 icalcomponent_add_property(parent,icalproperty_new_summary( 300 icalcomponent_add_property(parent,icalproperty_new_summary(
305 incidence->summary().utf8())); 301 incidence->summary().utf8()));
306 } 302 }
307 303
308 // location 304 // location
309 if (!incidence->location().isEmpty()) { 305 if (!incidence->location().isEmpty()) {
310 icalcomponent_add_property(parent,icalproperty_new_location( 306 icalcomponent_add_property(parent,icalproperty_new_location(
311 incidence->location().utf8())); 307 incidence->location().utf8()));
312 } 308 }
313 309
314// TODO: 310// TODO:
315 // status 311 // status
316// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); 312// addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8());
317 313
318 // secrecy 314 // secrecy
319 enum icalproperty_class classInt; 315 enum icalproperty_class classInt;
320 switch (incidence->secrecy()) { 316 switch (incidence->secrecy()) {
321 case Incidence::SecrecyPublic: 317 case Incidence::SecrecyPublic:
322 classInt = ICAL_CLASS_PUBLIC; 318 classInt = ICAL_CLASS_PUBLIC;
323 break; 319 break;
324 case Incidence::SecrecyConfidential: 320 case Incidence::SecrecyConfidential:
325 classInt = ICAL_CLASS_CONFIDENTIAL; 321 classInt = ICAL_CLASS_CONFIDENTIAL;
326 break; 322 break;
327 case Incidence::SecrecyPrivate: 323 case Incidence::SecrecyPrivate:
328 classInt =ICAL_CLASS_PRIVATE ; 324 classInt =ICAL_CLASS_PRIVATE ;
329 default: 325 default:
330 classInt =ICAL_CLASS_PRIVATE ; 326 classInt =ICAL_CLASS_PRIVATE ;
331 break; 327 break;
332 } 328 }
333 icalcomponent_add_property(parent,icalproperty_new_class(classInt)); 329 icalcomponent_add_property(parent,icalproperty_new_class(classInt));
334 330
335 // priority 331 // priority
336 icalcomponent_add_property(parent,icalproperty_new_priority( 332 icalcomponent_add_property(parent,icalproperty_new_priority(
337 incidence->priority())); 333 incidence->priority()));
338 334
339 // categories 335 // categories
340 QStringList categories = incidence->categories(); 336 QStringList categories = incidence->categories();
341 QStringList::Iterator it; 337 QStringList::Iterator it;
342 for(it = categories.begin(); it != categories.end(); ++it ) { 338 for(it = categories.begin(); it != categories.end(); ++it ) {
343 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
344 } 340 }
345// TODO: Ensure correct concatenation of categories properties. 341// TODO: Ensure correct concatenation of categories properties.
346 342
347/* 343/*
348 // categories 344 // categories
349 tmpStrList = incidence->getCategories(); 345 tmpStrList = incidence->getCategories();
350 tmpStr = ""; 346 tmpStr = "";
351 QString catStr; 347 QString catStr;
352 for ( QStringList::Iterator it = tmpStrList.begin(); 348 for ( QStringList::Iterator it = tmpStrList.begin();
353 it != tmpStrList.end(); 349 it != tmpStrList.end();
354 ++it ) { 350 ++it ) {
355 catStr = *it; 351 catStr = *it;
356 if (catStr[0] == ' ') 352 if (catStr[0] == ' ')
357 tmpStr += catStr.mid(1); 353 tmpStr += catStr.mid(1);
358 else 354 else
359 tmpStr += catStr; 355 tmpStr += catStr;
360 // this must be a ';' character as the vCalendar specification requires! 356 // this must be a ';' character as the vCalendar specification requires!
361 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
362 // read in. 358 // read in.
363 tmpStr += ";"; 359 tmpStr += ";";
364 } 360 }
365 if (!tmpStr.isEmpty()) { 361 if (!tmpStr.isEmpty()) {
366 tmpStr.truncate(tmpStr.length()-1); 362 tmpStr.truncate(tmpStr.length()-1);
367 icalcomponent_add_property(parent,icalproperty_new_categories( 363 icalcomponent_add_property(parent,icalproperty_new_categories(
368 writeText(incidence->getCategories().join(";")))); 364 writeText(incidence->getCategories().join(";"))));
369 } 365 }
370*/ 366*/
371 367
372 // related event 368 // related event
373 if (incidence->relatedTo()) { 369 if (incidence->relatedTo()) {
374 icalcomponent_add_property(parent,icalproperty_new_relatedto( 370 icalcomponent_add_property(parent,icalproperty_new_relatedto(
375 incidence->relatedTo()->uid().utf8())); 371 incidence->relatedTo()->uid().utf8()));
376 } 372 }
377 373
378 // recurrence rule stuff 374 // recurrence rule stuff
379 Recurrence *recur = incidence->recurrence(); 375 Recurrence *recur = incidence->recurrence();
380 if (recur->doesRecur()) { 376 if (recur->doesRecur()) {
381 377
382 icalcomponent_add_property(parent,writeRecurrenceRule(recur)); 378 icalcomponent_add_property(parent,writeRecurrenceRule(recur));
383 } 379 }
384 380
385 // recurrence excpetion dates 381 // recurrence excpetion dates
386 DateList dateList = incidence->exDates(); 382 DateList dateList = incidence->exDates();
387 DateList::ConstIterator exIt; 383 DateList::ConstIterator exIt;
388 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
389 icalcomponent_add_property(parent,icalproperty_new_exdate( 385 icalcomponent_add_property(parent,icalproperty_new_exdate(
390 writeICalDate(*exIt))); 386 writeICalDate(*exIt)));
391 } 387 }
392 388
393 // attachments 389 // attachments
394 QPtrList<Attachment> attachments = incidence->attachments(); 390 QPtrList<Attachment> attachments = incidence->attachments();
395 for (Attachment *at = attachments.first(); at; at = attachments.next()) 391 for (Attachment *at = attachments.first(); at; at = attachments.next())
396 icalcomponent_add_property(parent,writeAttachment(at)); 392 icalcomponent_add_property(parent,writeAttachment(at));
397 393
398 // alarms 394 // alarms
399 QPtrList<Alarm> alarms = incidence->alarms(); 395 QPtrList<Alarm> alarms = incidence->alarms();
400 Alarm* alarm; 396 Alarm* alarm;
401 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
402 if (alarm->enabled()) { 398 if (alarm->enabled()) {
403 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
404 icalcomponent_add_component(parent,writeAlarm(alarm)); 400 icalcomponent_add_component(parent,writeAlarm(alarm));
405 } 401 }
406 } 402 }
407 403
408 // duration 404 // duration
409 405
410// turned off as it always is set to PTS0 (and must not occur together with DTEND 406// turned off as it always is set to PTS0 (and must not occur together with DTEND
411 407
412// if (incidence->hasDuration()) { 408// if (incidence->hasDuration()) {
413// icaldurationtype duration; 409// icaldurationtype duration;
414// duration = writeICalDuration(incidence->duration()); 410// duration = writeICalDuration(incidence->duration());
415// icalcomponent_add_property(parent,icalproperty_new_duration(duration)); 411// icalcomponent_add_property(parent,icalproperty_new_duration(duration));
416// } 412// }
417} 413}
418 414
419void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 415void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
420{ 416{
421 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 417 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
422 writeICalDateTime(QDateTime::currentDateTime()))); 418 writeICalDateTime(QDateTime::currentDateTime())));
423 419
424 // organizer stuff 420 // organizer stuff
425 icalcomponent_add_property(parent,icalproperty_new_organizer( 421 icalcomponent_add_property(parent,icalproperty_new_organizer(
426 ("MAILTO:" + incidenceBase->organizer()).utf8())); 422 ("MAILTO:" + incidenceBase->organizer()).utf8()));
427 423
428 // attendees 424 // attendees
429 if (incidenceBase->attendeeCount() != 0) { 425 if (incidenceBase->attendeeCount() != 0) {
430 QPtrList<Attendee> al = incidenceBase->attendees(); 426 QPtrList<Attendee> al = incidenceBase->attendees();
431 QPtrListIterator<Attendee> ai(al); 427 QPtrListIterator<Attendee> ai(al);
432 for (; ai.current(); ++ai) { 428 for (; ai.current(); ++ai) {
433 icalcomponent_add_property(parent,writeAttendee(ai.current())); 429 icalcomponent_add_property(parent,writeAttendee(ai.current()));
434 } 430 }
435 } 431 }
436 432
437 // custom properties 433 // custom properties
438 writeCustomProperties(parent, incidenceBase); 434 writeCustomProperties(parent, incidenceBase);
439} 435}
440 436
441void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) 437void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties)
442{ 438{
443 QMap<QCString, QString> custom = properties->customProperties(); 439 QMap<QCString, QString> custom = properties->customProperties();
444 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 440 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
445 icalproperty *p = icalproperty_new_x(c.data().utf8()); 441 icalproperty *p = icalproperty_new_x(c.data().utf8());
446 icalproperty_set_x_name(p,c.key()); 442 icalproperty_set_x_name(p,c.key());
447 icalcomponent_add_property(parent,p); 443 icalcomponent_add_property(parent,p);
448 } 444 }
449} 445}
450 446
451icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) 447icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
452{ 448{
453 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); 449 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8());
454 450
455 if (!attendee->name().isEmpty()) { 451 if (!attendee->name().isEmpty()) {
456 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); 452 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8()));
457 } 453 }
458 454
459 455
460 icalproperty_add_parameter(p,icalparameter_new_rsvp( 456 icalproperty_add_parameter(p,icalparameter_new_rsvp(
461 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); 457 attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE ));
462 458
463 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; 459 icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION;
464 switch (attendee->status()) { 460 switch (attendee->status()) {
465 default: 461 default:
466 case Attendee::NeedsAction: 462 case Attendee::NeedsAction:
467 status = ICAL_PARTSTAT_NEEDSACTION; 463 status = ICAL_PARTSTAT_NEEDSACTION;
468 break; 464 break;
469 case Attendee::Accepted: 465 case Attendee::Accepted:
470 status = ICAL_PARTSTAT_ACCEPTED; 466 status = ICAL_PARTSTAT_ACCEPTED;
471 break; 467 break;
472 case Attendee::Declined: 468 case Attendee::Declined:
473 status = ICAL_PARTSTAT_DECLINED; 469 status = ICAL_PARTSTAT_DECLINED;
474 break; 470 break;
475 case Attendee::Tentative: 471 case Attendee::Tentative:
476 status = ICAL_PARTSTAT_TENTATIVE; 472 status = ICAL_PARTSTAT_TENTATIVE;
477 break; 473 break;
478 case Attendee::Delegated: 474 case Attendee::Delegated:
479 status = ICAL_PARTSTAT_DELEGATED; 475 status = ICAL_PARTSTAT_DELEGATED;
480 break; 476 break;
481 case Attendee::Completed: 477 case Attendee::Completed:
482 status = ICAL_PARTSTAT_COMPLETED; 478 status = ICAL_PARTSTAT_COMPLETED;
483 break; 479 break;
484 case Attendee::InProcess: 480 case Attendee::InProcess:
485 status = ICAL_PARTSTAT_INPROCESS; 481 status = ICAL_PARTSTAT_INPROCESS;
486 break; 482 break;
487 } 483 }
488 icalproperty_add_parameter(p,icalparameter_new_partstat(status)); 484 icalproperty_add_parameter(p,icalparameter_new_partstat(status));
489 485
490 icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; 486 icalparameter_role role = ICAL_ROLE_REQPARTICIPANT;
491 switch (attendee->role()) { 487 switch (attendee->role()) {
492 case Attendee::Chair: 488 case Attendee::Chair:
493 role = ICAL_ROLE_CHAIR; 489 role = ICAL_ROLE_CHAIR;
494 break; 490 break;
495 default: 491 default:
496 case Attendee::ReqParticipant: 492 case Attendee::ReqParticipant:
497 role = ICAL_ROLE_REQPARTICIPANT; 493 role = ICAL_ROLE_REQPARTICIPANT;
498 break; 494 break;
499 case Attendee::OptParticipant: 495 case Attendee::OptParticipant:
500 role = ICAL_ROLE_OPTPARTICIPANT; 496 role = ICAL_ROLE_OPTPARTICIPANT;
501 break; 497 break;
502 case Attendee::NonParticipant: 498 case Attendee::NonParticipant:
503 role = ICAL_ROLE_NONPARTICIPANT; 499 role = ICAL_ROLE_NONPARTICIPANT;
504 break; 500 break;
505 } 501 }
506 icalproperty_add_parameter(p,icalparameter_new_role(role)); 502 icalproperty_add_parameter(p,icalparameter_new_role(role));
507 503
508 if (!attendee->uid().isEmpty()) { 504 if (!attendee->uid().isEmpty()) {
509 icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); 505 icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8());
510 icalparameter_set_xname(icalparameter_uid,"X-UID"); 506 icalparameter_set_xname(icalparameter_uid,"X-UID");
511 icalproperty_add_parameter(p,icalparameter_uid); 507 icalproperty_add_parameter(p,icalparameter_uid);
512 } 508 }
513 509
514 return p; 510 return p;
515} 511}
516 512
517icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) 513icalproperty *ICalFormatImpl::writeAttachment(Attachment *att)
518{ 514{
519#if 0 515#if 0
520 icalattachtype* attach = icalattachtype_new(); 516 icalattachtype* attach = icalattachtype_new();
521 if (att->isURI()) 517 if (att->isURI())
522 icalattachtype_set_url(attach, att->uri().utf8().data()); 518 icalattachtype_set_url(attach, att->uri().utf8().data());
523 else 519 else
524 icalattachtype_set_base64(attach, att->data(), 0); 520 icalattachtype_set_base64(attach, att->data(), 0);
525#endif 521#endif
526 icalattach *attach; 522 icalattach *attach;
527 if (att->isURI()) 523 if (att->isURI())
528 attach = icalattach_new_from_url( att->uri().utf8().data()); 524 attach = icalattach_new_from_url( att->uri().utf8().data());
529 else 525 else
530 attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); 526 attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0);
531 icalproperty *p = icalproperty_new_attach(attach); 527 icalproperty *p = icalproperty_new_attach(attach);
532 if (!att->mimeType().isEmpty()) 528 if (!att->mimeType().isEmpty())
533 icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); 529 icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data()));
534 530
535 if (att->isBinary()) { 531 if (att->isBinary()) {
536 icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); 532 icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
537 icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); 533 icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64));
538 } 534 }
539 return p; 535 return p;
540} 536}
541 537
542icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) 538icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur)
543{ 539{
544// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; 540// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl;
545 541
546 icalrecurrencetype r; 542 icalrecurrencetype r;
547 543
548 icalrecurrencetype_clear(&r); 544 icalrecurrencetype_clear(&r);
549 545
550 int index = 0; 546 int index = 0;
551 int index2 = 0; 547 int index2 = 0;
552 548
553 QPtrList<Recurrence::rMonthPos> tmpPositions; 549 QPtrList<Recurrence::rMonthPos> tmpPositions;
554 QPtrList<int> tmpDays; 550 QPtrList<int> tmpDays;
555 int *tmpDay; 551 int *tmpDay;
556 Recurrence::rMonthPos *tmpPos; 552 Recurrence::rMonthPos *tmpPos;
557 bool datetime = false; 553 bool datetime = false;
558 int day; 554 int day;
559 int i; 555 int i;
560 556
561 switch(recur->doesRecur()) { 557 switch(recur->doesRecur()) {
562 case Recurrence::rMinutely: 558 case Recurrence::rMinutely:
563 r.freq = ICAL_MINUTELY_RECURRENCE; 559 r.freq = ICAL_MINUTELY_RECURRENCE;
564 datetime = true; 560 datetime = true;
565 break; 561 break;
566 case Recurrence::rHourly: 562 case Recurrence::rHourly:
567 r.freq = ICAL_HOURLY_RECURRENCE; 563 r.freq = ICAL_HOURLY_RECURRENCE;
568 datetime = true; 564 datetime = true;
569 break; 565 break;
570 case Recurrence::rDaily: 566 case Recurrence::rDaily:
571 r.freq = ICAL_DAILY_RECURRENCE; 567 r.freq = ICAL_DAILY_RECURRENCE;
572 break; 568 break;
573 case Recurrence::rWeekly: 569 case Recurrence::rWeekly:
574 r.freq = ICAL_WEEKLY_RECURRENCE; 570 r.freq = ICAL_WEEKLY_RECURRENCE;
575 r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); 571 r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1);
576 for (i = 0; i < 7; i++) { 572 for (i = 0; i < 7; i++) {
577 if (recur->days().testBit(i)) { 573 if (recur->days().testBit(i)) {
578 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 574 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1
579 r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); 575 r.by_day[index++] = icalrecurrencetype_day_day_of_week(day);
580 } 576 }
581 } 577 }
582// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 578// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
583 break; 579 break;
584 case Recurrence::rMonthlyPos: 580 case Recurrence::rMonthlyPos:
585 r.freq = ICAL_MONTHLY_RECURRENCE; 581 r.freq = ICAL_MONTHLY_RECURRENCE;
586 582
587 tmpPositions = recur->monthPositions(); 583 tmpPositions = recur->monthPositions();
588 for (tmpPos = tmpPositions.first(); 584 for (tmpPos = tmpPositions.first();
589 tmpPos; 585 tmpPos;
590 tmpPos = tmpPositions.next()) { 586 tmpPos = tmpPositions.next()) {
591 for (i = 0; i < 7; i++) { 587 for (i = 0; i < 7; i++) {
592 if (tmpPos->rDays.testBit(i)) { 588 if (tmpPos->rDays.testBit(i)) {
593 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 589 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1
594 day += tmpPos->rPos*8; 590 day += tmpPos->rPos*8;
595 if (tmpPos->negative) day = -day; 591 if (tmpPos->negative) day = -day;
596 r.by_day[index++] = day; 592 r.by_day[index++] = day;
597 } 593 }
598 } 594 }
599 } 595 }
600// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 596// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
601 break; 597 break;
602 case Recurrence::rMonthlyDay: 598 case Recurrence::rMonthlyDay:
603 r.freq = ICAL_MONTHLY_RECURRENCE; 599 r.freq = ICAL_MONTHLY_RECURRENCE;
604 600
605 tmpDays = recur->monthDays(); 601 tmpDays = recur->monthDays();
606 for (tmpDay = tmpDays.first(); 602 for (tmpDay = tmpDays.first();
607 tmpDay; 603 tmpDay;
608 tmpDay = tmpDays.next()) { 604 tmpDay = tmpDays.next()) {
609 r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); 605 r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay);
610 } 606 }
611// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 607// r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
612 break; 608 break;
613 case Recurrence::rYearlyMonth: 609 case Recurrence::rYearlyMonth:
614 case Recurrence::rYearlyPos: 610 case Recurrence::rYearlyPos:
615 r.freq = ICAL_YEARLY_RECURRENCE; 611 r.freq = ICAL_YEARLY_RECURRENCE;
616 612
617 tmpDays = recur->yearNums(); 613 tmpDays = recur->yearNums();
618 for (tmpDay = tmpDays.first(); 614 for (tmpDay = tmpDays.first();
619 tmpDay; 615 tmpDay;
620 tmpDay = tmpDays.next()) { 616 tmpDay = tmpDays.next()) {
621 r.by_month[index++] = *tmpDay; 617 r.by_month[index++] = *tmpDay;
622 } 618 }
623// r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; 619// r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX;
624 if (recur->doesRecur() == Recurrence::rYearlyPos) { 620 if (recur->doesRecur() == Recurrence::rYearlyPos) {
625 tmpPositions = recur->monthPositions(); 621 tmpPositions = recur->monthPositions();
626 for (tmpPos = tmpPositions.first(); 622 for (tmpPos = tmpPositions.first();
627 tmpPos; 623 tmpPos;
628 tmpPos = tmpPositions.next()) { 624 tmpPos = tmpPositions.next()) {
629 for (i = 0; i < 7; i++) { 625 for (i = 0; i < 7; i++) {
630 if (tmpPos->rDays.testBit(i)) { 626 if (tmpPos->rDays.testBit(i)) {
631 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 627 day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1
632 day += tmpPos->rPos*8; 628 day += tmpPos->rPos*8;
633 if (tmpPos->negative) day = -day; 629 if (tmpPos->negative) day = -day;
634 r.by_day[index2++] = day; 630 r.by_day[index2++] = day;
635 } 631 }
636 } 632 }
637 } 633 }
638// r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX; 634// r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX;
639 } 635 }
640 break; 636 break;
641 case Recurrence::rYearlyDay: 637 case Recurrence::rYearlyDay:
642 r.freq = ICAL_YEARLY_RECURRENCE; 638 r.freq = ICAL_YEARLY_RECURRENCE;
643 639
644 tmpDays = recur->yearNums(); 640 tmpDays = recur->yearNums();
645 for (tmpDay = tmpDays.first(); 641 for (tmpDay = tmpDays.first();
646 tmpDay; 642 tmpDay;
647 tmpDay = tmpDays.next()) { 643 tmpDay = tmpDays.next()) {
648 r.by_year_day[index++] = *tmpDay; 644 r.by_year_day[index++] = *tmpDay;
649 } 645 }
650// r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX; 646// r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX;
651 break; 647 break;
652 default: 648 default:
653 r.freq = ICAL_NO_RECURRENCE; 649 r.freq = ICAL_NO_RECURRENCE;
654 kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl; 650 kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl;
655 break; 651 break;
656 } 652 }
657 653
658 r.interval = recur->frequency(); 654 r.interval = recur->frequency();
659 655
660 if (recur->duration() > 0) { 656 if (recur->duration() > 0) {
661 r.count = recur->duration(); 657 r.count = recur->duration();
662 } else if (recur->duration() == -1) { 658 } else if (recur->duration() == -1) {
663 r.count = 0; 659 r.count = 0;
664 } else { 660 } else {
665 if (datetime) 661 if (datetime)
666 r.until = writeICalDateTime(recur->endDateTime()); 662 r.until = writeICalDateTime(recur->endDateTime());
667 else 663 else
668 r.until = writeICalDate(recur->endDate()); 664 r.until = writeICalDate(recur->endDate());
669 } 665 }
670 666
671// Debug output 667// Debug output
672#if 0 668#if 0
673 const char *str = icalrecurrencetype_as_string(&r); 669 const char *str = icalrecurrencetype_as_string(&r);
674 if (str) { 670 if (str) {
675 kdDebug(5800) << " String: " << str << endl; 671 kdDebug(5800) << " String: " << str << endl;
676 } else { 672 } else {
677 kdDebug(5800) << " No String" << endl; 673 kdDebug(5800) << " No String" << endl;
678 } 674 }
679#endif 675#endif
680 676
681 return icalproperty_new_rrule(r); 677 return icalproperty_new_rrule(r);
682} 678}
683 679
684icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) 680icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
685{ 681{
686 icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); 682 icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT);
687 683
688 icalproperty_action action; 684 icalproperty_action action;
689 icalattach *attach = 0; 685 icalattach *attach = 0;
690 686
691 switch (alarm->type()) { 687 switch (alarm->type()) {
692 case Alarm::Procedure: 688 case Alarm::Procedure:
693 action = ICAL_ACTION_PROCEDURE; 689 action = ICAL_ACTION_PROCEDURE;
694 attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); 690 attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() );
695 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 691 icalcomponent_add_property(a,icalproperty_new_attach(attach));
696 if (!alarm->programArguments().isEmpty()) { 692 if (!alarm->programArguments().isEmpty()) {
697 icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); 693 icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8()));
698 } 694 }
699 break; 695 break;
700 case Alarm::Audio: 696 case Alarm::Audio:
701 action = ICAL_ACTION_AUDIO; 697 action = ICAL_ACTION_AUDIO;
702 if (!alarm->audioFile().isEmpty()) { 698 if (!alarm->audioFile().isEmpty()) {
703 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); 699 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data());
704 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 700 icalcomponent_add_property(a,icalproperty_new_attach(attach));
705 } 701 }
706 break; 702 break;
707 case Alarm::Email: { 703 case Alarm::Email: {
708 action = ICAL_ACTION_EMAIL; 704 action = ICAL_ACTION_EMAIL;
709 QValueList<Person> addresses = alarm->mailAddresses(); 705 QValueList<Person> addresses = alarm->mailAddresses();
710 for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { 706 for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) {
711 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); 707 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8());
712 if (!(*ad).name().isEmpty()) { 708 if (!(*ad).name().isEmpty()) {
713 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); 709 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8()));
714 } 710 }
715 icalcomponent_add_property(a,p); 711 icalcomponent_add_property(a,p);
716 } 712 }
717 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); 713 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8()));
718 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); 714 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8()));
719 QStringList attachments = alarm->mailAttachments(); 715 QStringList attachments = alarm->mailAttachments();
720 if (attachments.count() > 0) { 716 if (attachments.count() > 0) {
721 for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { 717 for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) {
722 attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); 718 attach = icalattach_new_from_url(QFile::encodeName( *at ).data());
723 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 719 icalcomponent_add_property(a,icalproperty_new_attach(attach));
724 } 720 }
725 } 721 }
726 break; 722 break;
727 } 723 }
728 case Alarm::Display: 724 case Alarm::Display:
729 action = ICAL_ACTION_DISPLAY; 725 action = ICAL_ACTION_DISPLAY;
730 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); 726 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8()));
731 break; 727 break;
732 case Alarm::Invalid: 728 case Alarm::Invalid:
733 default: 729 default:
734 kdDebug(5800) << "Unknown type of alarm" << endl; 730 kdDebug(5800) << "Unknown type of alarm" << endl;
735 action = ICAL_ACTION_NONE; 731 action = ICAL_ACTION_NONE;
736 break; 732 break;
737 } 733 }
738 icalcomponent_add_property(a,icalproperty_new_action(action)); 734 icalcomponent_add_property(a,icalproperty_new_action(action));
739 735
740 // Trigger time 736 // Trigger time
741 icaltriggertype trigger; 737 icaltriggertype trigger;
742 if ( alarm->hasTime() ) { 738 if ( alarm->hasTime() ) {
743 trigger.time = writeICalDateTime(alarm->time()); 739 trigger.time = writeICalDateTime(alarm->time());
744 trigger.duration = icaldurationtype_null_duration(); 740 trigger.duration = icaldurationtype_null_duration();
745 } else { 741 } else {
746 trigger.time = icaltime_null_time(); 742 trigger.time = icaltime_null_time();
747 Duration offset; 743 Duration offset;
748 if ( alarm->hasStartOffset() ) 744 if ( alarm->hasStartOffset() )
749 offset = alarm->startOffset(); 745 offset = alarm->startOffset();
750 else 746 else
751 offset = alarm->endOffset(); 747 offset = alarm->endOffset();
752 trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); 748 trigger.duration = icaldurationtype_from_int( offset.asSeconds() );
753 } 749 }
754 icalproperty *p = icalproperty_new_trigger(trigger); 750 icalproperty *p = icalproperty_new_trigger(trigger);
755 if ( alarm->hasEndOffset() ) 751 if ( alarm->hasEndOffset() )
756 icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); 752 icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END));
757 icalcomponent_add_property(a,p); 753 icalcomponent_add_property(a,p);
758 754
759 // Repeat count and duration 755 // Repeat count and duration
760 if (alarm->repeatCount()) { 756 if (alarm->repeatCount()) {
761 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); 757 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount()));
762 icalcomponent_add_property(a,icalproperty_new_duration( 758 icalcomponent_add_property(a,icalproperty_new_duration(
763 icaldurationtype_from_int(alarm->snoozeTime()*60))); 759 icaldurationtype_from_int(alarm->snoozeTime()*60)));
764 } 760 }
765 761
766 // Custom properties 762 // Custom properties
767 QMap<QCString, QString> custom = alarm->customProperties(); 763 QMap<QCString, QString> custom = alarm->customProperties();
768 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 764 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
769 icalproperty *p = icalproperty_new_x(c.data().utf8()); 765 icalproperty *p = icalproperty_new_x(c.data().utf8());
770 icalproperty_set_x_name(p,c.key()); 766 icalproperty_set_x_name(p,c.key());
771 icalcomponent_add_property(a,p); 767 icalcomponent_add_property(a,p);
772 } 768 }
773 769
774 return a; 770 return a;
775} 771}
776 772
777Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) 773Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo)
778{ 774{
779 Todo *todo = new Todo; 775 Todo *todo = new Todo;
780 776
781 readIncidence(vtodo,todo); 777 readIncidence(vtodo,todo);
782 778
783 icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY); 779 icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY);
784 780
785// int intvalue; 781// int intvalue;
786 icaltimetype icaltime; 782 icaltimetype icaltime;
787 783
788 QStringList categories; 784 QStringList categories;
789 785
790 while (p) { 786 while (p) {
791 icalproperty_kind kind = icalproperty_isa(p); 787 icalproperty_kind kind = icalproperty_isa(p);
792 switch (kind) { 788 switch (kind) {
793 789
794 case ICAL_DUE_PROPERTY: // due date 790 case ICAL_DUE_PROPERTY: // due date
795 icaltime = icalproperty_get_due(p); 791 icaltime = icalproperty_get_due(p);
796 if (icaltime.is_date) { 792 if (icaltime.is_date) {
797 todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0))); 793 todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0)));
798 todo->setFloats(true); 794 todo->setFloats(true);
799 795
800 } else { 796 } else {
801 todo->setDtDue(readICalDateTime(icaltime)); 797 todo->setDtDue(readICalDateTime(icaltime));
802 todo->setFloats(false); 798 todo->setFloats(false);
803 } 799 }
804 todo->setHasDueDate(true); 800 todo->setHasDueDate(true);
805 break; 801 break;
806 802
807 case ICAL_COMPLETED_PROPERTY: // completion date 803 case ICAL_COMPLETED_PROPERTY: // completion date
808 icaltime = icalproperty_get_completed(p); 804 icaltime = icalproperty_get_completed(p);
809 todo->setCompleted(readICalDateTime(icaltime)); 805 todo->setCompleted(readICalDateTime(icaltime));
810 break; 806 break;
811 807
812 case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed 808 case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed
813 todo->setPercentComplete(icalproperty_get_percentcomplete(p)); 809 todo->setPercentComplete(icalproperty_get_percentcomplete(p));
814 break; 810 break;
815 811
816 case ICAL_RELATEDTO_PROPERTY: // related todo (parent) 812 case ICAL_RELATEDTO_PROPERTY: // related todo (parent)
817 todo->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); 813 todo->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p)));
818 mTodosRelate.append(todo); 814 mTodosRelate.append(todo);
819 break; 815 break;
820 816
821 case ICAL_DTSTART_PROPERTY: 817 case ICAL_DTSTART_PROPERTY:
822 // Flag that todo has start date. Value is read in by readIncidence(). 818 // Flag that todo has start date. Value is read in by readIncidence().
823 todo->setHasStartDate(true); 819 todo->setHasStartDate(true);
824 break; 820 break;
825 821
826 default: 822 default:
827// kdDebug(5800) << "ICALFormat::readTodo(): Unknown property: " << kind 823// kdDebug(5800) << "ICALFormat::readTodo(): Unknown property: " << kind
828// << endl; 824// << endl;
829 break; 825 break;
830 } 826 }
831 827
832 p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY); 828 p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY);
833 } 829 }
834 830
835 return todo; 831 return todo;
836} 832}
837 833
838Event *ICalFormatImpl::readEvent(icalcomponent *vevent) 834Event *ICalFormatImpl::readEvent(icalcomponent *vevent)
839{ 835{
840 Event *event = new Event; 836 Event *event = new Event;
841 event->setFloats(false); 837 event->setFloats(false);
842 838
843 readIncidence(vevent,event); 839 readIncidence(vevent,event);
844 840
845 icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY); 841 icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY);
846 842
847// int intvalue; 843// int intvalue;
848 icaltimetype icaltime; 844 icaltimetype icaltime;
849 845
850 QStringList categories; 846 QStringList categories;
851 QString transparency; 847 QString transparency;
852 848
853 while (p) { 849 while (p) {
854 icalproperty_kind kind = icalproperty_isa(p); 850 icalproperty_kind kind = icalproperty_isa(p);
855 switch (kind) { 851 switch (kind) {
856 852
857 case ICAL_DTEND_PROPERTY: // start date and time 853 case ICAL_DTEND_PROPERTY: // start date and time
858 icaltime = icalproperty_get_dtend(p); 854 icaltime = icalproperty_get_dtend(p);
859 if (icaltime.is_date) { 855 if (icaltime.is_date) {
860 event->setFloats( true ); 856 event->setFloats( true );
861 // End date is non-inclusive 857 // End date is non-inclusive
862 QDate endDate = readICalDate( icaltime ).addDays( -1 ); 858 QDate endDate = readICalDate( icaltime ).addDays( -1 );
863 mCompat->fixFloatingEnd( endDate ); 859 mCompat->fixFloatingEnd( endDate );
864 if ( endDate < event->dtStart().date() ) { 860 if ( endDate < event->dtStart().date() ) {
865 endDate = event->dtStart().date(); 861 endDate = event->dtStart().date();
866 } 862 }
867 event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) ); 863 event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) );
868 } else { 864 } else {
869 event->setDtEnd(readICalDateTime(icaltime)); 865 event->setDtEnd(readICalDateTime(icaltime));
870 } 866 }
871 break; 867 break;
872 868
873// TODO: 869// TODO:
874 // at this point, there should be at least a start or end time. 870 // at this point, there should be at least a start or end time.
875 // fix up for events that take up no time but have a time associated 871 // fix up for events that take up no time but have a time associated
876#if 0 872#if 0
877 if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) 873 if (!(vo = isAPropertyOf(vevent, VCDTstartProp)))
878 anEvent->setDtStart(anEvent->dtEnd()); 874 anEvent->setDtStart(anEvent->dtEnd());
879 if (!(vo = isAPropertyOf(vevent, VCDTendProp))) 875 if (!(vo = isAPropertyOf(vevent, VCDTendProp)))
880 anEvent->setDtEnd(anEvent->dtStart()); 876 anEvent->setDtEnd(anEvent->dtStart());
881#endif 877#endif
882 878
883// TODO: exdates 879// TODO: exdates
884#if 0 880#if 0
885 // recurrence exceptions 881 // recurrence exceptions
886 if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { 882 if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) {
887 anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo))); 883 anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo)));
888 deleteStr(s); 884 deleteStr(s);
889 } 885 }
890#endif 886#endif
891 887
892#if 0 888#if 0
893 // secrecy 889 // secrecy
894 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { 890 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) {
895 anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo))); 891 anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo)));
896 deleteStr(s); 892 deleteStr(s);
897 } 893 }
898 else 894 else
899 anEvent->setSecrecy("PUBLIC"); 895 anEvent->setSecrecy("PUBLIC");
900 896
901 // attachments 897 // attachments
902 tmpStrList.clear(); 898 tmpStrList.clear();
903 initPropIterator(&voi, vevent); 899 initPropIterator(&voi, vevent);
904 while (moreIteration(&voi)) { 900 while (moreIteration(&voi)) {
905 vo = nextVObject(&voi); 901 vo = nextVObject(&voi);
906 if (strcmp(vObjectName(vo), VCAttachProp) == 0) { 902 if (strcmp(vObjectName(vo), VCAttachProp) == 0) {
907 tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo))); 903 tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo)));
908 deleteStr(s); 904 deleteStr(s);
909 } 905 }
910 } 906 }
911 anEvent->setAttachments(tmpStrList); 907 anEvent->setAttachments(tmpStrList);
912 908
913 // resources 909 // resources
914 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { 910 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) {
915 QString resources = (s = fakeCString(vObjectUStringZValue(vo))); 911 QString resources = (s = fakeCString(vObjectUStringZValue(vo)));
916 deleteStr(s); 912 deleteStr(s);
917 tmpStrList.clear(); 913 tmpStrList.clear();
918 index1 = 0; 914 index1 = 0;
919 index2 = 0; 915 index2 = 0;
920 QString resource; 916 QString resource;
921 while ((index2 = resources.find(';', index1)) != -1) { 917 while ((index2 = resources.find(';', index1)) != -1) {
922 resource = resources.mid(index1, (index2 - index1)); 918 resource = resources.mid(index1, (index2 - index1));
923 tmpStrList.append(resource); 919 tmpStrList.append(resource);
924 index1 = index2; 920 index1 = index2;
925 } 921 }
926 anEvent->setResources(tmpStrList); 922 anEvent->setResources(tmpStrList);
927 } 923 }
928#endif 924#endif
929 925
930 case ICAL_RELATEDTO_PROPERTY: // releated event (parent) 926 case ICAL_RELATEDTO_PROPERTY: // releated event (parent)
931 event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); 927 event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p)));
932 mEventsRelate.append(event); 928 mEventsRelate.append(event);
933 break; 929 break;
934 930
935 case ICAL_TRANSP_PROPERTY: // Transparency 931 case ICAL_TRANSP_PROPERTY: // Transparency
936 if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) 932 if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT )
937 event->setTransparency( Event::Transparent ); 933 event->setTransparency( Event::Transparent );
938 else 934 else
939 event->setTransparency( Event::Opaque ); 935 event->setTransparency( Event::Opaque );
940 break; 936 break;
941 937
942 default: 938 default:
943// kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind 939// kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind
944// << endl; 940// << endl;
945 break; 941 break;
946 } 942 }
947 943
948 p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); 944 p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY);
949 } 945 }
950 946
951 QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); 947 QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT");
952 if (!msade.isNull()) { 948 if (!msade.isNull()) {
953 bool floats = (msade == QString::fromLatin1("TRUE")); 949 bool floats = (msade == QString::fromLatin1("TRUE"));
954 kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; 950 kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl;
955 event->setFloats(floats); 951 event->setFloats(floats);
956 if (floats) { 952 if (floats) {
957 QDateTime endDate = event->dtEnd(); 953 QDateTime endDate = event->dtEnd();
958 event->setDtEnd(endDate.addDays(-1)); 954 event->setDtEnd(endDate.addDays(-1));
959 } 955 }
960 } 956 }
961 957
962 // some stupid vCal exporters ignore the standard and use Description 958 // some stupid vCal exporters ignore the standard and use Description
963 // instead of Summary for the default field. Correct for this. 959 // instead of Summary for the default field. Correct for this.
964 if (event->summary().isEmpty() && 960 if (event->summary().isEmpty() &&
965 !(event->description().isEmpty())) { 961 !(event->description().isEmpty())) {
966 QString tmpStr = event->description().simplifyWhiteSpace(); 962 QString tmpStr = event->description().simplifyWhiteSpace();
967 event->setDescription(""); 963 event->setDescription("");
968 event->setSummary(tmpStr); 964 event->setSummary(tmpStr);
969 } 965 }
970 966
971 return event; 967 return event;
972} 968}
973 969
974FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) 970FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy)
975{ 971{
976 FreeBusy *freebusy = new FreeBusy; 972 FreeBusy *freebusy = new FreeBusy;
977 973
978 readIncidenceBase(vfreebusy,freebusy); 974 readIncidenceBase(vfreebusy,freebusy);
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 60b8bc7..567ae54 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -1,1636 +1,1636 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 300 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "qptrlist.h"
42#include "qmemarray.h" 42#include "qmemarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define QPtrList QList
47#define QMemArray QArray 47#define QMemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobjectlist.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#ifndef KDGANTT_MASTER_CVS 55#ifndef KDGANTT_MASTER_CVS
56//#include "KDGanttMinimizeSplitter.moc" 56//#include "KDGanttMinimizeSplitter.moc"
57#endif 57#endif
58 58
59 59
60 60
61#ifndef DOXYGEN_SKIP_INTERNAL 61#ifndef DOXYGEN_SKIP_INTERNAL
62 62
63#if QT_VERSION >= 232 63#if QT_VERSION >= 232
64static int mouseOffset; 64static int mouseOffset;
65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
66 66
67 67
68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
69 KDGanttMinimizeSplitter *parent, const char * name ) 69 KDGanttMinimizeSplitter *parent, const char * name )
70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) 70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
71{ 71{
72 72
73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { 73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
74 mSizeHint = QSize(7,7); 74 mSizeHint = QSize(7,7);
75 mUseOffset = true; 75 mUseOffset = true;
76 } else { 76 } else {
77 mSizeHint = QSize(6,6); 77 mSizeHint = QSize(6,6);
78 mUseOffset = false; 78 mUseOffset = false;
79 } 79 }
80 s = parent; 80 s = parent;
81 setOrientation(o); 81 setOrientation(o);
82 setMouseTracking( true ); 82 setMouseTracking( true );
83 //setMaximumHeight( 5 ); // test only 83 //setMaximumHeight( 5 ); // test only
84} 84}
85 85
86QSize KDGanttSplitterHandle::sizeHint() const 86QSize KDGanttSplitterHandle::sizeHint() const
87{ 87{
88 return mSizeHint; 88 return mSizeHint;
89} 89}
90 90
91void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 91void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
92{ 92{
93 orient = o; 93 orient = o;
94#ifndef QT_NO_CURSOR 94#ifndef QT_NO_CURSOR
95 if ( o == KDGanttMinimizeSplitter::Horizontal ) 95 if ( o == KDGanttMinimizeSplitter::Horizontal )
96 setCursor( splitHCursor ); 96 setCursor( splitHCursor );
97 else 97 else
98 setCursor( splitVCursor ); 98 setCursor( splitVCursor );
99#endif 99#endif
100} 100}
101 101
102 102
103void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 103void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
104{ 104{
105 updateCursor( e->pos() ); 105 updateCursor( e->pos() );
106 if ( !(e->state()&LeftButton) ) 106 if ( !(e->state()&LeftButton) )
107 return; 107 return;
108 108
109 if ( _activeButton != 0) 109 if ( _activeButton != 0)
110 return; 110 return;
111 111
112 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 112 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
113 - mouseOffset; 113 - mouseOffset;
114 if ( true /*opaque()*/ ) { 114 if ( true /*opaque()*/ ) {
115 s->moveSplitter( pos, id() ); 115 s->moveSplitter( pos, id() );
116 } else { 116 } else {
117 int min = pos; int max = pos; 117 int min = pos; int max = pos;
118 s->getRange( id(), &min, &max ); 118 s->getRange( id(), &min, &max );
119 s->setRubberband( QMAX( min, QMIN(max, pos ))); 119 s->setRubberband( QMAX( min, QMIN(max, pos )));
120 } 120 }
121 _collapsed = false; 121 _collapsed = false;
122} 122}
123 123
124void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 124void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
125{ 125{
126 if ( e->button() == LeftButton ) { 126 if ( e->button() == LeftButton ) {
127 _activeButton = onButton( e->pos() ); 127 _activeButton = onButton( e->pos() );
128 mouseOffset = s->pick(e->pos()); 128 mouseOffset = s->pick(e->pos());
129 if ( _activeButton != 0) 129 if ( _activeButton != 0)
130 repaint(); 130 repaint();
131 updateCursor( e->pos() ); 131 updateCursor( e->pos() );
132 } 132 }
133} 133}
134 134
135void KDGanttSplitterHandle::updateCursor( const QPoint& p) 135void KDGanttSplitterHandle::updateCursor( const QPoint& p)
136{ 136{
137 if ( onButton( p ) != 0 ) { 137 if ( onButton( p ) != 0 ) {
138 setCursor( arrowCursor ); 138 setCursor( arrowCursor );
139 } 139 }
140 else { 140 else {
141 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 141 if ( orient == KDGanttMinimizeSplitter::Horizontal )
142 setCursor( splitHCursor ); 142 setCursor( splitHCursor );
143 else 143 else
144 setCursor( splitVCursor ); 144 setCursor( splitVCursor );
145 } 145 }
146} 146}
147void KDGanttSplitterHandle::toggle() 147void KDGanttSplitterHandle::toggle()
148{ 148{
149 int pos; 149 int pos;
150 int min, max; 150 int min, max;
151 if ( !_collapsed ) { 151 if ( !_collapsed ) {
152 s->expandPos( id(), &min, &max ); 152 s->expandPos( id(), &min, &max );
153 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 153 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
154 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 154 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
155 pos = min; 155 pos = min;
156 } 156 }
157 else { 157 else {
158 pos = max; 158 pos = max;
159 } 159 }
160 160
161 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 161 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
162 s->moveSplitter( pos, id() ); 162 s->moveSplitter( pos, id() );
163 _collapsed = true; 163 _collapsed = true;
164 } 164 }
165 else { 165 else {
166 s->moveSplitter( _origPos, id() ); 166 s->moveSplitter( _origPos, id() );
167 _collapsed = false; 167 _collapsed = false;
168 } 168 }
169} 169}
170 170
171void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 171void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
172{ 172{
173 if ( _activeButton != 0 ) { 173 if ( _activeButton != 0 ) {
174 if ( onButton( e->pos() ) == _activeButton ) 174 if ( onButton( e->pos() ) == _activeButton )
175 { 175 {
176 toggle(); 176 toggle();
177 } 177 }
178 _activeButton = 0; 178 _activeButton = 0;
179 updateCursor( e->pos() ); 179 updateCursor( e->pos() );
180 } 180 }
181 else { 181 else {
182 if ( !opaque() && e->button() == LeftButton ) { 182 if ( !opaque() && e->button() == LeftButton ) {
183 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 183 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
184 - mouseOffset; 184 - mouseOffset;
185 s->setRubberband( -1 ); 185 s->setRubberband( -1 );
186 s->moveSplitter( pos, id() ); 186 s->moveSplitter( pos, id() );
187 } 187 }
188 } 188 }
189 repaint(); 189 repaint();
190} 190}
191 191
192int KDGanttSplitterHandle::onButton( const QPoint& p ) 192int KDGanttSplitterHandle::onButton( const QPoint& p )
193{ 193{
194 QValueList<QPointArray> list = buttonRegions(); 194 QValueList<QPointArray> list = buttonRegions();
195 int index = 1; 195 int index = 1;
196 int add = 12; 196 int add = 12;
197 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 197 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
198 QRect rect = (*it).boundingRect(); 198 QRect rect = (*it).boundingRect();
199 rect.setLeft( rect.left()- add ); 199 rect.setLeft( rect.left()- add );
200 rect.setRight( rect.right() + add); 200 rect.setRight( rect.right() + add);
201 rect.setTop( rect.top()- add ); 201 rect.setTop( rect.top()- add );
202 rect.setBottom( rect.bottom() + add); 202 rect.setBottom( rect.bottom() + add);
203 if ( rect.contains( p ) ) { 203 if ( rect.contains( p ) ) {
204 return index; 204 return index;
205 } 205 }
206 index++; 206 index++;
207 } 207 }
208 return 0; 208 return 0;
209} 209}
210 210
211 211
212QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 212QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
213{ 213{
214 QValueList<QPointArray> list; 214 QValueList<QPointArray> list;
215 215
216 int sw = 8; 216 int sw = 8;
217 int yyy = 1; 217 int yyy = 1;
218 int xxx = 1; 218 int xxx = 1;
219 int voffset[] = { (int) -sw*3, (int) sw*3 }; 219 int voffset[] = { (int) -sw*3, (int) sw*3 };
220 for ( int i = 0; i < 2; i++ ) { 220 for ( int i = 0; i < 2; i++ ) {
221 QPointArray arr; 221 QPointArray arr;
222 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 222 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
223 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 223 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
224 int mid = height()/2 + voffset[i]; 224 int mid = height()/2 + voffset[i];
225 arr.setPoints( 3, 225 arr.setPoints( 3,
226 1-xxx, mid - sw + 4, 226 1-xxx, mid - sw + 4,
227 sw-3-xxx, mid, 227 sw-3-xxx, mid,
228 1-xxx, mid + sw -4); 228 1-xxx, mid + sw -4);
229 } 229 }
230 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 230 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
231 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 231 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
232 int mid = height()/2 + voffset[i]; 232 int mid = height()/2 + voffset[i];
233 arr.setPoints( 3, 233 arr.setPoints( 3,
234 sw-4, mid - sw + 4, 234 sw-4, mid - sw + 4,
235 0, mid, 235 0, mid,
236 sw-4, mid + sw - 4); 236 sw-4, mid + sw - 4);
237 } 237 }
238 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 238 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
239 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { 239 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
240 int mid = width()/2 + voffset[i]; 240 int mid = width()/2 + voffset[i];
241 arr.setPoints( 3, 241 arr.setPoints( 3,
242 mid - sw + 4, sw-4, 242 mid - sw + 4, sw-4,
243 mid, 0, 243 mid, 0,
244 mid + sw - 4, sw-4 ); 244 mid + sw - 4, sw-4 );
245 } 245 }
246 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || 246 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
247 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 247 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
248 int mid = width()/2 + voffset[i]; 248 int mid = width()/2 + voffset[i];
249 arr.setPoints( 3, 249 arr.setPoints( 3,
250 mid - sw + 4, 1-yyy, 250 mid - sw + 4, 1-yyy,
251 mid, sw-3-yyy, 251 mid, sw-3-yyy,
252 mid + sw -4, 1-yyy); 252 mid + sw -4, 1-yyy);
253 } 253 }
254 list.append( arr ); 254 list.append( arr );
255 } 255 }
256 return list; 256 return list;
257} 257}
258 258
259void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) 259void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
260{ 260{
261 QPixmap buffer( size() ); 261 QPixmap buffer( size() );
262 QPainter p( &buffer ); 262 QPainter p( &buffer );
263 263
264 //LR 264 //LR
265 // Draw the splitter rectangle 265 // Draw the splitter rectangle
266 p.setBrush( colorGroup().background() ); 266 p.setBrush( colorGroup().background() );
267 p.setPen( colorGroup().foreground() ); 267 p.setPen( colorGroup().foreground() );
268 //p.drawRect( rect() ); 268 //p.drawRect( rect() );
269 buffer.fill( colorGroup().background() ); 269 buffer.fill( colorGroup().background() );
270 //buffer.fill( backgroundColor() ); 270 //buffer.fill( backgroundColor() );
271 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); 271 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
272 272
273 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size 273 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
274 274
275 // arrow color 275 // arrow color
276 QColor col; 276 QColor col;
277 if ( _activeButton ) 277 if ( _activeButton )
278 col = colorGroup().background().dark( 250 ); 278 col = colorGroup().background().dark( 250 );
279 else 279 else
280 col = colorGroup().background().dark( 150 ); 280 col = colorGroup().background().dark( 150 );
281 //QColor col = backgroundColor().dark( 130 ); 281 //QColor col = backgroundColor().dark( 130 );
282 p.setBrush( col ); 282 p.setBrush( col );
283 p.setPen( col ); 283 p.setPen( col );
284 284
285 QValueList<QPointArray> list = buttonRegions(); 285 QValueList<QPointArray> list = buttonRegions();
286 int index = 1; 286 int index = 1;
287 if ( mUseOffset ) 287 if ( mUseOffset )
288 p.translate( 0, 1 ); 288 p.translate( 0, 1 );
289 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 289 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
290 if ( index == _activeButton ) { 290 if ( index == _activeButton ) {
291 291
292 /* 292 /*
293 if ( ! _collapsed ) { 293 if ( ! _collapsed ) {
294 p.save(); 294 p.save();
295 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), 295 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
296 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); 296 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
297 p.translate( -1, 0 ); 297 p.translate( -1, 0 );
298 p.drawPolygon( *it, true ); 298 p.drawPolygon( *it, true );
299 p.restore(); } else 299 p.restore(); } else
300 */ 300 */
301 p.drawPolygon( *it, true ); 301 p.drawPolygon( *it, true );
302 302
303 } 303 }
304 else { 304 else {
305 /* 305 /*
306 if ( ! _collapsed ) { 306 if ( ! _collapsed ) {
307 p.save(); 307 p.save();
308 p.translate( -1, 0 ); 308 p.translate( -1, 0 );
309 p.drawPolygon( *it, true ); 309 p.drawPolygon( *it, true );
310 p.restore(); 310 p.restore();
311 } else 311 } else
312 */ 312 */
313 p.drawPolygon( *it, true ); 313 p.drawPolygon( *it, true );
314 314
315 } 315 }
316 index++; 316 index++;
317 } 317 }
318 318
319 // Draw the lines between the arrows 319 // Draw the lines between the arrows
320 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 320 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
321 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 321 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
322 int mid = height()/2; 322 int mid = height()/2;
323 p.drawLine ( 1, mid - sw, 1, mid + sw ); 323 p.drawLine ( 1, mid - sw, 1, mid + sw );
324 p.drawLine ( 3, mid - sw, 3, mid + sw ); 324 p.drawLine ( 3, mid - sw, 3, mid + sw );
325 } 325 }
326 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 326 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
327 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { 327 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
328 int mid = width()/2; 328 int mid = width()/2;
329 p.drawLine( mid -sw, 1, mid +sw, 1 ); 329 p.drawLine( mid -sw, 1, mid +sw, 1 );
330 p.drawLine( mid -sw, 3, mid +sw, 3 ); 330 p.drawLine( mid -sw, 3, mid +sw, 3 );
331 } 331 }
332 bitBlt( this, 0, 0, &buffer ); 332 bitBlt( this, 0, 0, &buffer );
333 333
334} 334}
335#endif 335#endif
336 336
337class QSplitterLayoutStruct 337class QSplitterLayoutStruct
338{ 338{
339public: 339public:
340 KDGanttMinimizeSplitter::ResizeMode mode; 340 KDGanttMinimizeSplitter::ResizeMode mode;
341 QCOORD sizer; 341 QCOORD sizer;
342 bool isSplitter; 342 bool isSplitter;
343 QWidget *wid; 343 QWidget *wid;
344}; 344};
345 345
346class QSplitterData 346class QSplitterData
347{ 347{
348public: 348public:
349 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 349 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
350 350
351 QPtrList<QSplitterLayoutStruct> list; 351 QPtrList<QSplitterLayoutStruct> list;
352 bool opaque; 352 bool opaque;
353 bool firstShow; 353 bool firstShow;
354}; 354};
355 355
356void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 356void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
357 int space, int spacer ); 357 int space, int spacer );
358#endif // DOXYGEN_SKIP_INTERNAL 358#endif // DOXYGEN_SKIP_INTERNAL
359 359
360 360
361/*! 361/*!
362 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 362 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
363 \brief The KDGanttMinimizeSplitter class implements a splitter 363 \brief The KDGanttMinimizeSplitter class implements a splitter
364 widget with minimize buttons. 364 widget with minimize buttons.
365 365
366 This class (and its documentation) is largely a copy of Qt's 366 This class (and its documentation) is largely a copy of Qt's
367 QSplitter; the copying was necessary because QSplitter is not 367 QSplitter; the copying was necessary because QSplitter is not
368 extensible at all. QSplitter and its documentation are licensed 368 extensible at all. QSplitter and its documentation are licensed
369 according to the GPL and the Qt Professional License (if you hold 369 according to the GPL and the Qt Professional License (if you hold
370 such a license) and are (C) Trolltech AS. 370 such a license) and are (C) Trolltech AS.
371 371
372 A splitter lets the user control the size of child widgets by 372 A splitter lets the user control the size of child widgets by
373 dragging the boundary between the children. Any number of widgets 373 dragging the boundary between the children. Any number of widgets
374 may be controlled. 374 may be controlled.
375 375
376 To show a QListBox, a QListView and a QTextEdit side by side: 376 To show a QListBox, a QListView and a QTextEdit side by side:
377 377
378 \code 378 \code
379 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 379 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
380 QListBox *lb = new QListBox( split ); 380 QListBox *lb = new QListBox( split );
381 QListView *lv = new QListView( split ); 381 QListView *lv = new QListView( split );
382 QTextEdit *ed = new QTextEdit( split ); 382 QTextEdit *ed = new QTextEdit( split );
383 \endcode 383 \endcode
384 384
385 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 385 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
386 vertical. The default is horizontal (the children are side by side) 386 vertical. The default is horizontal (the children are side by side)
387 but you can use setOrientation( QSplitter::Vertical ) to set it to 387 but you can use setOrientation( QSplitter::Vertical ) to set it to
388 vertical. 388 vertical.
389 389
390 Use setResizeMode() to specify 390 Use setResizeMode() to specify
391 that a widget should keep its size when the splitter is resized. 391 that a widget should keep its size when the splitter is resized.
392 392
393 Although KDGanttMinimizeSplitter normally resizes the children only 393 Although KDGanttMinimizeSplitter normally resizes the children only
394 at the end of a resize operation, if you call setOpaqueResize( TRUE 394 at the end of a resize operation, if you call setOpaqueResize( TRUE
395 ) the widgets are resized as often as possible. 395 ) the widgets are resized as often as possible.
396 396
397 The initial distribution of size between the widgets is determined 397 The initial distribution of size between the widgets is determined
398 by the initial size of each widget. You can also use setSizes() to 398 by the initial size of each widget. You can also use setSizes() to
399 set the sizes of all the widgets. The function sizes() returns the 399 set the sizes of all the widgets. The function sizes() returns the
400 sizes set by the user. 400 sizes set by the user.
401 401
402 If you hide() a child, its space will be distributed among the other 402 If you hide() a child, its space will be distributed among the other
403 children. It will be reinstated when you show() it again. It is also 403 children. It will be reinstated when you show() it again. It is also
404 possible to reorder the widgets within the splitter using 404 possible to reorder the widgets within the splitter using
405 moveToFirst() and moveToLast(). 405 moveToFirst() and moveToLast().
406*/ 406*/
407 407
408 408
409 409
410static QSize minSize( const QWidget* /*w*/ ) 410static QSize minSize( const QWidget* /*w*/ )
411{ 411{
412 return QSize(0,0); 412 return QSize(0,0);
413} 413}
414 414
415// This is the original version of minSize 415// This is the original version of minSize
416static QSize minSizeHint( const QWidget* w ) 416static QSize minSizeHint( const QWidget* w )
417{ 417{
418 QSize min = w->minimumSize(); 418 QSize min = w->minimumSize();
419 QSize s; 419 QSize s;
420 if ( min.height() <= 0 || min.width() <= 0 ) 420 if ( min.height() <= 0 || min.width() <= 0 )
421 s = w->minimumSizeHint(); 421 s = w->minimumSizeHint();
422 if ( min.height() > 0 ) 422 if ( min.height() > 0 )
423 s.setHeight( min.height() ); 423 s.setHeight( min.height() );
424 if ( min.width() > 0 ) 424 if ( min.width() > 0 )
425 s.setWidth( min.width() ); 425 s.setWidth( min.width() );
426 return s.expandedTo(QSize(0,0)); 426 return s.expandedTo(QSize(0,0));
427} 427}
428 428
429 429
430 430
431/*! 431/*!
432 Constructs a horizontal splitter with the \a parent and \a 432 Constructs a horizontal splitter with the \a parent and \a
433 name arguments being passed on to the QFrame constructor. 433 name arguments being passed on to the QFrame constructor.
434*/ 434*/
435KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 435KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
436 :QFrame(parent,name,WPaintUnclipped) 436 :QFrame(parent,name,WPaintUnclipped)
437{ 437{
438 mFirstHandle = 0; 438 mFirstHandle = 0;
439#if QT_VERSION >= 232 439#if QT_VERSION >= 232
440 orient = Horizontal; 440 orient = Horizontal;
441 init(); 441 init();
442#endif 442#endif
443} 443}
444 444
445/*! 445/*!
446 Constructs a splitter with orientation \a o with the \a parent 446 Constructs a splitter with orientation \a o with the \a parent
447 and \a name arguments being passed on to the QFrame constructor. 447 and \a name arguments being passed on to the QFrame constructor.
448*/ 448*/
449KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 449KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
450 :QFrame(parent,name,WPaintUnclipped) 450 :QFrame(parent,name,WPaintUnclipped)
451{ 451{
452 mFirstHandle = 0; 452 mFirstHandle = 0;
453#if QT_VERSION >= 232 453#if QT_VERSION >= 232
454 orient = o; 454 orient = o;
455 init(); 455 init();
456#endif 456#endif
457} 457}
458 458
459/*! 459/*!
460 Destroys the splitter and any children. 460 Destroys the splitter and any children.
461*/ 461*/
462KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 462KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
463{ 463{
464#if QT_VERSION >= 232 464#if QT_VERSION >= 232
465 data->list.setAutoDelete( TRUE ); 465 data->list.setAutoDelete( TRUE );
466 delete data; 466 delete data;
467#endif 467#endif
468} 468}
469 469
470 470
471#if QT_VERSION >= 232 471#if QT_VERSION >= 232
472void KDGanttMinimizeSplitter::init() 472void KDGanttMinimizeSplitter::init()
473{ 473{
474 data = new QSplitterData; 474 data = new QSplitterData;
475 if ( orient == Horizontal ) 475 if ( orient == Horizontal )
476 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 476 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
477 else 477 else
478 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 478 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
479} 479}
480#endif 480#endif
481 481
482 482
483 483
484/*! 484/*!
485 \brief the orientation of the splitter 485 \brief the orientation of the splitter
486 486
487 By default the orientation is horizontal (the widgets are side by side). 487 By default the orientation is horizontal (the widgets are side by side).
488 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 488 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
489*/ 489*/
490void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 490void KDGanttMinimizeSplitter::setOrientation( Orientation o )
491{ 491{
492#if QT_VERSION >= 232 492#if QT_VERSION >= 232
493 if ( orient == o ) 493 if ( orient == o )
494 return; 494 return;
495 orient = o; 495 orient = o;
496 496
497 if ( orient == Horizontal ) 497 if ( orient == Horizontal )
498 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 498 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
499 else 499 else
500 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 500 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
501 501
502 QSplitterLayoutStruct *s = data->list.first(); 502 QSplitterLayoutStruct *s = data->list.first();
503 while ( s ) { 503 while ( s ) {
504 if ( s->isSplitter ) 504 if ( s->isSplitter )
505 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 505 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
506 s = data->list.next(); // ### next at end of loop, no iterator 506 s = data->list.next(); // ### next at end of loop, no iterator
507 } 507 }
508 recalc( isVisible() ); 508 recalc( isVisible() );
509#endif 509#endif
510} 510}
511 511
512 512
513#if QT_VERSION >= 232 513#if QT_VERSION >= 232
514/*! 514/*!
515 \reimp 515 \reimp
516*/ 516*/
517void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 517void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
518{ 518{
519 doResize(); 519 doResize();
520} 520}
521 521
522 522
523/* 523/*
524 Inserts the widget \a w at the end (or at the beginning if \a first 524 Inserts the widget \a w at the end (or at the beginning if \a first
525 is TRUE) of the splitter's list of widgets. 525 is TRUE) of the splitter's list of widgets.
526 526
527 It is the responsibility of the caller of this function to make sure 527 It is the responsibility of the caller of this function to make sure
528 that \a w is not already in the splitter and to call recalcId if 528 that \a w is not already in the splitter and to call recalcId if
529 needed. (If \a first is TRUE, then recalcId is very probably 529 needed. (If \a first is TRUE, then recalcId is very probably
530 needed.) 530 needed.)
531*/ 531*/
532QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 532QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
533{ 533{
534 QSplitterLayoutStruct *s; 534 QSplitterLayoutStruct *s;
535 KDGanttSplitterHandle *newHandle = 0; 535 KDGanttSplitterHandle *newHandle = 0;
536 if ( data->list.count() > 0 ) { 536 if ( data->list.count() > 0 ) {
537 s = new QSplitterLayoutStruct; 537 s = new QSplitterLayoutStruct;
538 s->mode = KeepSize; 538 s->mode = KeepSize;
539 QString tmp = "qt_splithandle_"; 539 QString tmp = "qt_splithandle_";
540 tmp += w->name(); 540 tmp += w->name();
541 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 541 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
542 if ( ! mFirstHandle ) 542 if ( ! mFirstHandle )
543 mFirstHandle = newHandle; 543 mFirstHandle = newHandle;
544 s->wid = newHandle; 544 s->wid = newHandle;
545 newHandle->setId(data->list.count()); 545 newHandle->setId(data->list.count());
546 s->isSplitter = TRUE; 546 s->isSplitter = TRUE;
547 s->sizer = pick( newHandle->sizeHint() ); 547 s->sizer = pick( newHandle->sizeHint() );
548 if ( first ) 548 if ( first )
549 data->list.insert( 0, s ); 549 data->list.insert( 0, s );
550 else 550 else
551 data->list.append( s ); 551 data->list.append( s );
552 } 552 }
553 s = new QSplitterLayoutStruct; 553 s = new QSplitterLayoutStruct;
554 s->mode = Stretch; 554 s->mode = Stretch;
555 s->wid = w; 555 s->wid = w;
556 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 556 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
557 s->sizer = pick( w->sizeHint() ); 557 s->sizer = pick( w->sizeHint() );
558 else 558 else
559 s->sizer = pick( w->size() ); 559 s->sizer = pick( w->size() );
560 s->isSplitter = FALSE; 560 s->isSplitter = FALSE;
561 if ( first ) 561 if ( first )
562 data->list.insert( 0, s ); 562 data->list.insert( 0, s );
563 else 563 else
564 data->list.append( s ); 564 data->list.append( s );
565 if ( newHandle && isVisible() ) 565 if ( newHandle && isVisible() )
566 newHandle->show(); //will trigger sending of post events 566 newHandle->show(); //will trigger sending of post events
567 return s; 567 return s;
568} 568}
569 569
570 570
571/*! 571/*!
572 Tells the splitter that a child widget has been inserted or removed. 572 Tells the splitter that a child widget has been inserted or removed.
573 The event is passed in \a c. 573 The event is passed in \a c.
574*/ 574*/
575void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 575void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
576{ 576{
577 if ( c->type() == QEvent::ChildInserted ) { 577 if ( c->type() == QEvent::ChildInserted ) {
578 if ( !c->child()->isWidgetType() ) 578 if ( !c->child()->isWidgetType() )
579 return; 579 return;
580 580
581 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 581 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
582 return; 582 return;
583 583
584 QSplitterLayoutStruct *s = data->list.first(); 584 QSplitterLayoutStruct *s = data->list.first();
585 while ( s ) { 585 while ( s ) {
586 if ( s->wid == c->child() ) 586 if ( s->wid == c->child() )
587 return; 587 return;
588 s = data->list.next(); 588 s = data->list.next();
589 } 589 }
590 addWidget( (QWidget*)c->child() ); 590 addWidget( (QWidget*)c->child() );
591 recalc( isVisible() ); 591 recalc( isVisible() );
592 592
593 } else if ( c->type() == QEvent::ChildRemoved ) { 593 } else if ( c->type() == QEvent::ChildRemoved ) {
594 QSplitterLayoutStruct *p = 0; 594 QSplitterLayoutStruct *p = 0;
595 if ( data->list.count() > 1 ) 595 if ( data->list.count() > 1 )
596 p = data->list.at(1); //remove handle _after_ first widget. 596 p = data->list.at(1); //remove handle _after_ first widget.
597 QSplitterLayoutStruct *s = data->list.first(); 597 QSplitterLayoutStruct *s = data->list.first();
598 while ( s ) { 598 while ( s ) {
599 if ( s->wid == c->child() ) { 599 if ( s->wid == c->child() ) {
600 data->list.removeRef( s ); 600 data->list.removeRef( s );
601 delete s; 601 delete s;
602 if ( p && p->isSplitter ) { 602 if ( p && p->isSplitter ) {
603 data->list.removeRef( p ); 603 data->list.removeRef( p );
604 delete p->wid; //will call childEvent 604 delete p->wid; //will call childEvent
605 delete p; 605 delete p;
606 } 606 }
607 recalcId(); 607 recalcId();
608 doResize(); 608 doResize();
609 return; 609 return;
610 } 610 }
611 p = s; 611 p = s;
612 s = data->list.next(); 612 s = data->list.next();
613 } 613 }
614 } 614 }
615} 615}
616 616
617 617
618/*! 618/*!
619 Shows a rubber band at position \a p. If \a p is negative, the 619 Shows a rubber band at position \a p. If \a p is negative, the
620 rubber band is removed. 620 rubber band is removed.
621*/ 621*/
622void KDGanttMinimizeSplitter::setRubberband( int p ) 622void KDGanttMinimizeSplitter::setRubberband( int p )
623{ 623{
624 QPainter paint( this ); 624 QPainter paint( this );
625 paint.setPen( gray ); 625 paint.setPen( gray );
626 paint.setBrush( gray ); 626 paint.setBrush( gray );
627 paint.setRasterOp( XorROP ); 627 paint.setRasterOp( XorROP );
628 QRect r = contentsRect(); 628 QRect r = contentsRect();
629 const int rBord = 3; //Themable???? 629 const int rBord = 3; //Themable????
630#if QT_VERSION >= 300 630#if QT_VERSION >= 0x030000
631 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 631 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
632#else 632#else
633 int sw = style().splitterWidth(); 633 int sw = style().splitterWidth();
634#endif 634#endif
635 if ( orient == Horizontal ) { 635 if ( orient == Horizontal ) {
636 if ( opaqueOldPos >= 0 ) 636 if ( opaqueOldPos >= 0 )
637 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 637 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
638 2*rBord, r.height() ); 638 2*rBord, r.height() );
639 if ( p >= 0 ) 639 if ( p >= 0 )
640 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 640 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
641 } else { 641 } else {
642 if ( opaqueOldPos >= 0 ) 642 if ( opaqueOldPos >= 0 )
643 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 643 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
644 r.width(), 2*rBord ); 644 r.width(), 2*rBord );
645 if ( p >= 0 ) 645 if ( p >= 0 )
646 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 646 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
647 } 647 }
648 opaqueOldPos = p; 648 opaqueOldPos = p;
649} 649}
650 650
651 651
652/*! \reimp */ 652/*! \reimp */
653bool KDGanttMinimizeSplitter::event( QEvent *e ) 653bool KDGanttMinimizeSplitter::event( QEvent *e )
654{ 654{
655 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 655 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
656 recalc( isVisible() ); 656 recalc( isVisible() );
657 if ( e->type() == QEvent::Show ) 657 if ( e->type() == QEvent::Show )
658 data->firstShow = FALSE; 658 data->firstShow = FALSE;
659 } 659 }
660 return QWidget::event( e ); 660 return QWidget::event( e );
661} 661}
662 662
663 663
664/*! 664/*!
665 \obsolete 665 \obsolete
666 666
667 Draws the splitter handle in the rectangle described by \a x, \a y, 667 Draws the splitter handle in the rectangle described by \a x, \a y,
668 \a w, \a h using painter \a p. 668 \a w, \a h using painter \a p.
669 \sa QStyle::drawPrimitive() 669 \sa QStyle::drawPrimitive()
670*/ 670*/
671void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 671void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
672 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 672 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
673{ 673{
674#if 0 674#if 0
675 // LR 675 // LR
676 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 676 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
677 (orientation() == Qt::Horizontal ? 677 (orientation() == Qt::Horizontal ?
678 QStyle::Style_Horizontal : 0)); 678 QStyle::Style_Horizontal : 0));
679#endif 679#endif
680} 680}
681 681
682 682
683/*! 683/*!
684 Returns the id of the splitter to the right of or below the widget \a w, 684 Returns the id of the splitter to the right of or below the widget \a w,
685 or 0 if there is no such splitter 685 or 0 if there is no such splitter
686 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 686 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
687*/ 687*/
688int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 688int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
689{ 689{
690 QSplitterLayoutStruct *s = data->list.first(); 690 QSplitterLayoutStruct *s = data->list.first();
691 bool seen_w = FALSE; 691 bool seen_w = FALSE;
692 while ( s ) { 692 while ( s ) {
693 if ( s->isSplitter && seen_w ) 693 if ( s->isSplitter && seen_w )
694 return data->list.at(); 694 return data->list.at();
695 if ( !s->isSplitter && s->wid == w ) 695 if ( !s->isSplitter && s->wid == w )
696 seen_w = TRUE; 696 seen_w = TRUE;
697 s = data->list.next(); 697 s = data->list.next();
698 } 698 }
699 return 0; 699 return 0;
700} 700}
701 701
702 702
703/*! 703/*!
704 Moves the left/top edge of the splitter handle with id \a id as 704 Moves the left/top edge of the splitter handle with id \a id as
705 close as possible to position \a p, which is the distance from the 705 close as possible to position \a p, which is the distance from the
706 left (or top) edge of the widget. 706 left (or top) edge of the widget.
707 707
708 For Arabic and Hebrew the layout is reversed, and using this 708 For Arabic and Hebrew the layout is reversed, and using this
709 function to set the position of the splitter might lead to 709 function to set the position of the splitter might lead to
710 unexpected results, since in Arabic and Hebrew the position of 710 unexpected results, since in Arabic and Hebrew the position of
711 splitter one is to the left of the position of splitter zero. 711 splitter one is to the left of the position of splitter zero.
712 712
713 \sa idAfter() 713 \sa idAfter()
714*/ 714*/
715void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 715void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
716{ 716{
717 p = adjustPos( p, id ); 717 p = adjustPos( p, id );
718 QSplitterLayoutStruct *s = data->list.at(id); 718 QSplitterLayoutStruct *s = data->list.at(id);
719 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 719 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y();
720 bool upLeft; 720 bool upLeft;
721 if ( false && orient == Horizontal ) { 721 if ( false && orient == Horizontal ) {
722 p += s->wid->width(); 722 p += s->wid->width();
723 upLeft = p > oldP; 723 upLeft = p > oldP;
724 } else 724 } else
725 upLeft = p < oldP; 725 upLeft = p < oldP;
726 726
727 moveAfter( p, id, upLeft ); 727 moveAfter( p, id, upLeft );
728 moveBefore( p-1, id-1, upLeft ); 728 moveBefore( p-1, id-1, upLeft );
729 729
730 storeSizes(); 730 storeSizes();
731} 731}
732 732
733 733
734void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 734void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
735{ 735{
736 if ( orient == Horizontal ) { 736 if ( orient == Horizontal ) {
737 if ( false && orient == Horizontal && !isSplitter ) 737 if ( false && orient == Horizontal && !isSplitter )
738 p = contentsRect().width() - p - s; 738 p = contentsRect().width() - p - s;
739 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 739 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
740 } else 740 } else
741 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 741 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
742} 742}
743 743
744 744
745/* 745/*
746 Places the right/bottom edge of the widget at \a id at position \a pos. 746 Places the right/bottom edge of the widget at \a id at position \a pos.
747 747
748 \sa idAfter() 748 \sa idAfter()
749*/ 749*/
750void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) 750void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft )
751{ 751{
752 if( id < 0 ) 752 if( id < 0 )
753 return; 753 return;
754 QSplitterLayoutStruct *s = data->list.at(id); 754 QSplitterLayoutStruct *s = data->list.at(id);
755 if ( !s ) 755 if ( !s )
756 return; 756 return;
757 QWidget *w = s->wid; 757 QWidget *w = s->wid;
758 if ( w->isHidden() ) { 758 if ( w->isHidden() ) {
759 moveBefore( pos, id-1, upLeft ); 759 moveBefore( pos, id-1, upLeft );
760 } else if ( s->isSplitter ) { 760 } else if ( s->isSplitter ) {
761 int pos1, pos2; 761 int pos1, pos2;
762 int dd = s->sizer; 762 int dd = s->sizer;
763 if( false && orient == Horizontal ) { 763 if( false && orient == Horizontal ) {
764 pos1 = pos; 764 pos1 = pos;
765 pos2 = pos + dd; 765 pos2 = pos + dd;
766 } else { 766 } else {
767 pos2 = pos - dd; 767 pos2 = pos - dd;
768 pos1 = pos2 + 1; 768 pos1 = pos2 + 1;
769 } 769 }
770 if ( upLeft ) { 770 if ( upLeft ) {
771 setG( w, pos1, dd, TRUE ); 771 setG( w, pos1, dd, TRUE );
772 moveBefore( pos2, id-1, upLeft ); 772 moveBefore( pos2, id-1, upLeft );
773 } else { 773 } else {
774 moveBefore( pos2, id-1, upLeft ); 774 moveBefore( pos2, id-1, upLeft );
775 setG( w, pos1, dd, TRUE ); 775 setG( w, pos1, dd, TRUE );
776 } 776 }
777 } else { 777 } else {
778 int dd, newLeft, nextPos; 778 int dd, newLeft, nextPos;
779 if( false && orient == Horizontal ) { 779 if( false && orient == Horizontal ) {
780 dd = w->geometry().right() - pos; 780 dd = w->geometry().right() - pos;
781 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 781 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
782 newLeft = pos+1; 782 newLeft = pos+1;
783 nextPos = newLeft + dd; 783 nextPos = newLeft + dd;
784 } else { 784 } else {
785 dd = pos - pick( w->pos() ) + 1; 785 dd = pos - pick( w->pos() ) + 1;
786 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 786 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
787 newLeft = pos-dd+1; 787 newLeft = pos-dd+1;
788 nextPos = newLeft - 1; 788 nextPos = newLeft - 1;
789 } 789 }
790 setG( w, newLeft, dd, TRUE ); 790 setG( w, newLeft, dd, TRUE );
791 moveBefore( nextPos, id-1, upLeft ); 791 moveBefore( nextPos, id-1, upLeft );
792 } 792 }
793} 793}
794 794
795 795
796/* 796/*
797 Places the left/top edge of the widget at \a id at position \a pos. 797 Places the left/top edge of the widget at \a id at position \a pos.
798 798
799 \sa idAfter() 799 \sa idAfter()
800*/ 800*/
801void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) 801void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft )
802{ 802{
803 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 803 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
804 data->list.at(id) : 0; 804 data->list.at(id) : 0;
805 if ( !s ) 805 if ( !s )
806 return; 806 return;
807 QWidget *w = s->wid; 807 QWidget *w = s->wid;
808 if ( w->isHidden() ) { 808 if ( w->isHidden() ) {
809 moveAfter( pos, id+1, upLeft ); 809 moveAfter( pos, id+1, upLeft );
810 } else if ( pick( w->pos() ) == pos ) { 810 } else if ( pick( w->pos() ) == pos ) {
811 //No need to do anything if it's already there. 811 //No need to do anything if it's already there.
812 return; 812 return;
813 } else if ( s->isSplitter ) { 813 } else if ( s->isSplitter ) {
814 int dd = s->sizer; 814 int dd = s->sizer;
815 int pos1, pos2; 815 int pos1, pos2;
816 if( false && orient == Horizontal ) { 816 if( false && orient == Horizontal ) {
817 pos2 = pos - dd; 817 pos2 = pos - dd;
818 pos1 = pos2 + 1; 818 pos1 = pos2 + 1;
819 } else { 819 } else {
820 pos1 = pos; 820 pos1 = pos;
821 pos2 = pos + dd; 821 pos2 = pos + dd;
822 } 822 }
823 if ( upLeft ) { 823 if ( upLeft ) {
824 setG( w, pos1, dd, TRUE ); 824 setG( w, pos1, dd, TRUE );
825 moveAfter( pos2, id+1, upLeft ); 825 moveAfter( pos2, id+1, upLeft );
826 } else { 826 } else {
827 moveAfter( pos2, id+1, upLeft ); 827 moveAfter( pos2, id+1, upLeft );
828 setG( w, pos1, dd, TRUE ); 828 setG( w, pos1, dd, TRUE );
829 } 829 }
830 } else { 830 } else {
831 int left = pick( w->pos() ); 831 int left = pick( w->pos() );
832 int right, dd,/* newRight,*/ newLeft, nextPos; 832 int right, dd,/* newRight,*/ newLeft, nextPos;
833 if ( false && orient == Horizontal ) { 833 if ( false && orient == Horizontal ) {
834 dd = pos - left + 1; 834 dd = pos - left + 1;
835 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 835 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
836 newLeft = pos-dd+1; 836 newLeft = pos-dd+1;
837 nextPos = newLeft - 1; 837 nextPos = newLeft - 1;
838 } else { 838 } else {
839 right = pick( w->geometry().bottomRight() ); 839 right = pick( w->geometry().bottomRight() );
840 dd = right - pos + 1; 840 dd = right - pos + 1;
841 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 841 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
842 /*newRight = pos+dd-1;*/ 842 /*newRight = pos+dd-1;*/
843 newLeft = pos; 843 newLeft = pos;
844 nextPos = newLeft + dd; 844 nextPos = newLeft + dd;
845 } 845 }
846 setG( w, newLeft, dd, TRUE ); 846 setG( w, newLeft, dd, TRUE );
847 /*if( right != newRight )*/ 847 /*if( right != newRight )*/
848 moveAfter( nextPos, id+1, upLeft ); 848 moveAfter( nextPos, id+1, upLeft );
849 } 849 }
850} 850}
851 851
852 852
853void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) 853void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max )
854{ 854{
855 QSplitterLayoutStruct *s = data->list.at(id-1); 855 QSplitterLayoutStruct *s = data->list.at(id-1);
856 QWidget* w = s->wid; 856 QWidget* w = s->wid;
857 *min = pick( w->mapToParent( QPoint(0,0) ) ); 857 *min = pick( w->mapToParent( QPoint(0,0) ) );
858 858
859 if ( (uint) id == data->list.count() ) { 859 if ( (uint) id == data->list.count() ) {
860 pick( size() ); 860 pick( size() );
861 } 861 }
862 else { 862 else {
863 QSplitterLayoutStruct *s = data->list.at(id+1); 863 QSplitterLayoutStruct *s = data->list.at(id+1);
864 QWidget* w = s->wid; 864 QWidget* w = s->wid;
865 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; 865 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8;
866 } 866 }
867} 867}
868 868
869 869
870/*! 870/*!
871 Returns the valid range of the splitter with id \a id in \a *min and \a *max. 871 Returns the valid range of the splitter with id \a id in \a *min and \a *max.
872 872
873 \sa idAfter() 873 \sa idAfter()
874*/ 874*/
875 875
876void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) 876void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
877{ 877{
878 int minB = 0;//before 878 int minB = 0;//before
879 int maxB = 0; 879 int maxB = 0;
880 int minA = 0; 880 int minA = 0;
881 int maxA = 0;//after 881 int maxA = 0;//after
882 int n = data->list.count(); 882 int n = data->list.count();
883 if ( id < 0 || id >= n ) 883 if ( id < 0 || id >= n )
884 return; 884 return;
885 int i; 885 int i;
886 for ( i = 0; i < id; i++ ) { 886 for ( i = 0; i < id; i++ ) {
887 QSplitterLayoutStruct *s = data->list.at(i); 887 QSplitterLayoutStruct *s = data->list.at(i);
888 if ( s->wid->isHidden() ) { 888 if ( s->wid->isHidden() ) {
889 //ignore 889 //ignore
890 } else if ( s->isSplitter ) { 890 } else if ( s->isSplitter ) {
891 minB += s->sizer; 891 minB += s->sizer;
892 maxB += s->sizer; 892 maxB += s->sizer;
893 } else { 893 } else {
894 minB += pick( minSize(s->wid) ); 894 minB += pick( minSize(s->wid) );
895 maxB += pick( s->wid->maximumSize() ); 895 maxB += pick( s->wid->maximumSize() );
896 } 896 }
897 } 897 }
898 for ( i = id; i < n; i++ ) { 898 for ( i = id; i < n; i++ ) {
899 QSplitterLayoutStruct *s = data->list.at(i); 899 QSplitterLayoutStruct *s = data->list.at(i);
900 if ( s->wid->isHidden() ) { 900 if ( s->wid->isHidden() ) {
901 //ignore 901 //ignore
902 } else if ( s->isSplitter ) { 902 } else if ( s->isSplitter ) {
903 minA += s->sizer; 903 minA += s->sizer;
904 maxA += s->sizer; 904 maxA += s->sizer;
905 } else { 905 } else {
906 minA += pick( minSize(s->wid) ); 906 minA += pick( minSize(s->wid) );
907 maxA += pick( s->wid->maximumSize() ); 907 maxA += pick( s->wid->maximumSize() );
908 } 908 }
909 } 909 }
910 QRect r = contentsRect(); 910 QRect r = contentsRect();
911 if ( orient == Horizontal && false ) { 911 if ( orient == Horizontal && false ) {
912#if QT_VERSION >= 300 912#if QT_VERSION >= 0x030000
913 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 913 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this);
914#else 914#else
915 int splitterWidth = style().splitterWidth(); 915 int splitterWidth = style().splitterWidth();
916#endif 916#endif
917 917
918 if ( min ) 918 if ( min )
919 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 919 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
920 if ( max ) 920 if ( max )
921 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 921 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
922 } else { 922 } else {
923 if ( min ) 923 if ( min )
924 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 924 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
925 if ( max ) 925 if ( max )
926 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 926 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
927 } 927 }
928} 928}
929 929
930 930
931/*! 931/*!
932 Returns the closest legal position to \a p of the splitter with id \a id. 932 Returns the closest legal position to \a p of the splitter with id \a id.
933 933
934 \sa idAfter() 934 \sa idAfter()
935*/ 935*/
936 936
937int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 937int KDGanttMinimizeSplitter::adjustPos( int p, int id )
938{ 938{
939 int min = 0; 939 int min = 0;
940 int max = 0; 940 int max = 0;
941 getRange( id, &min, &max ); 941 getRange( id, &min, &max );
942 p = QMAX( min, QMIN( p, max ) ); 942 p = QMAX( min, QMIN( p, max ) );
943 943
944 return p; 944 return p;
945} 945}
946 946
947 947
948void KDGanttMinimizeSplitter::doResize() 948void KDGanttMinimizeSplitter::doResize()
949{ 949{
950 QRect r = contentsRect(); 950 QRect r = contentsRect();
951 int i; 951 int i;
952 int n = data->list.count(); 952 int n = data->list.count();
953 QMemArray<QLayoutStruct> a( n ); 953 QMemArray<QLayoutStruct> a( n );
954 for ( i = 0; i< n; i++ ) { 954 for ( i = 0; i< n; i++ ) {
955 a[i].init(); 955 a[i].init();
956 QSplitterLayoutStruct *s = data->list.at(i); 956 QSplitterLayoutStruct *s = data->list.at(i);
957 if ( s->wid->isHidden() ) { 957 if ( s->wid->isHidden() ) {
958 a[i].stretch = 0; 958 a[i].stretch = 0;
959 a[i].sizeHint = a[i].minimumSize = 0; 959 a[i].sizeHint = a[i].minimumSize = 0;
960 a[i].maximumSize = 0; 960 a[i].maximumSize = 0;
961 } else if ( s->isSplitter ) { 961 } else if ( s->isSplitter ) {
962 a[i].stretch = 0; 962 a[i].stretch = 0;
963 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 963 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
964 a[i].empty = FALSE; 964 a[i].empty = FALSE;
965 } else if ( s->mode == KeepSize ) { 965 } else if ( s->mode == KeepSize ) {
966 a[i].stretch = 0; 966 a[i].stretch = 0;
967 a[i].minimumSize = pick( minSize(s->wid) ); 967 a[i].minimumSize = pick( minSize(s->wid) );
968 a[i].sizeHint = s->sizer; 968 a[i].sizeHint = s->sizer;
969 a[i].maximumSize = pick( s->wid->maximumSize() ); 969 a[i].maximumSize = pick( s->wid->maximumSize() );
970 a[i].empty = FALSE; 970 a[i].empty = FALSE;
971 } else if ( s->mode == FollowSizeHint ) { 971 } else if ( s->mode == FollowSizeHint ) {
972 a[i].stretch = 0; 972 a[i].stretch = 0;
973 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 973 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
974 a[i].maximumSize = pick( s->wid->maximumSize() ); 974 a[i].maximumSize = pick( s->wid->maximumSize() );
975 a[i].empty = FALSE; 975 a[i].empty = FALSE;
976 } else { //proportional 976 } else { //proportional
977 a[i].stretch = s->sizer; 977 a[i].stretch = s->sizer;
978 a[i].maximumSize = pick( s->wid->maximumSize() ); 978 a[i].maximumSize = pick( s->wid->maximumSize() );
979 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 979 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
980 a[i].empty = FALSE; 980 a[i].empty = FALSE;
981 } 981 }
982 } 982 }
983 983
984 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 984 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
985 985
986 for ( i = 0; i< n; i++ ) { 986 for ( i = 0; i< n; i++ ) {
987 QSplitterLayoutStruct *s = data->list.at(i); 987 QSplitterLayoutStruct *s = data->list.at(i);
988 setG( s->wid, a[i].pos, a[i].size ); 988 setG( s->wid, a[i].pos, a[i].size );
989 } 989 }
990 990
991} 991}
992 992
993 993
994void KDGanttMinimizeSplitter::recalc( bool update ) 994void KDGanttMinimizeSplitter::recalc( bool update )
995{ 995{
996 int fi = 2*frameWidth(); 996 int fi = 2*frameWidth();
997 int maxl = fi; 997 int maxl = fi;
998 int minl = fi; 998 int minl = fi;
999 int maxt = QWIDGETSIZE_MAX; 999 int maxt = QWIDGETSIZE_MAX;
1000 int mint = fi; 1000 int mint = fi;
1001 int n = data->list.count(); 1001 int n = data->list.count();
1002 bool first = TRUE; 1002 bool first = TRUE;
1003 /* 1003 /*
1004 The splitter before a hidden widget is always hidden. 1004 The splitter before a hidden widget is always hidden.
1005 The splitter before the first visible widget is hidden. 1005 The splitter before the first visible widget is hidden.
1006 The splitter before any other visible widget is visible. 1006 The splitter before any other visible widget is visible.
1007 */ 1007 */
1008 for ( int i = 0; i< n; i++ ) { 1008 for ( int i = 0; i< n; i++ ) {
1009 QSplitterLayoutStruct *s = data->list.at(i); 1009 QSplitterLayoutStruct *s = data->list.at(i);
1010 if ( !s->isSplitter ) { 1010 if ( !s->isSplitter ) {
1011 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 1011 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
1012 if ( p && p->isSplitter ) 1012 if ( p && p->isSplitter )
1013 if ( first || s->wid->isHidden() ) 1013 if ( first || s->wid->isHidden() )
1014 p->wid->hide(); //may trigger new recalc 1014 p->wid->hide(); //may trigger new recalc
1015 else 1015 else
1016 p->wid->show(); //may trigger new recalc 1016 p->wid->show(); //may trigger new recalc
1017 if ( !s->wid->isHidden() ) 1017 if ( !s->wid->isHidden() )
1018 first = FALSE; 1018 first = FALSE;
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 bool empty=TRUE; 1022 bool empty=TRUE;
1023 for ( int j = 0; j< n; j++ ) { 1023 for ( int j = 0; j< n; j++ ) {
1024 QSplitterLayoutStruct *s = data->list.at(j); 1024 QSplitterLayoutStruct *s = data->list.at(j);
1025 if ( !s->wid->isHidden() ) { 1025 if ( !s->wid->isHidden() ) {
1026 empty = FALSE; 1026 empty = FALSE;
1027 if ( s->isSplitter ) { 1027 if ( s->isSplitter ) {
1028 minl += s->sizer; 1028 minl += s->sizer;
1029 maxl += s->sizer; 1029 maxl += s->sizer;
1030 } else { 1030 } else {
1031 QSize minS = minSize(s->wid); 1031 QSize minS = minSize(s->wid);
1032 minl += pick( minS ); 1032 minl += pick( minS );
1033 maxl += pick( s->wid->maximumSize() ); 1033 maxl += pick( s->wid->maximumSize() );
1034 mint = QMAX( mint, trans( minS )); 1034 mint = QMAX( mint, trans( minS ));
1035 int tm = trans( s->wid->maximumSize() ); 1035 int tm = trans( s->wid->maximumSize() );
1036 if ( tm > 0 ) 1036 if ( tm > 0 )
1037 maxt = QMIN( maxt, tm ); 1037 maxt = QMIN( maxt, tm );
1038 } 1038 }
1039 } 1039 }
1040 } 1040 }
1041 if ( empty ) { 1041 if ( empty ) {
1042 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { 1042 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) {
1043 // nested splitters; be nice 1043 // nested splitters; be nice
1044 maxl = maxt = 0; 1044 maxl = maxt = 0;
1045 } else { 1045 } else {
1046 // KDGanttMinimizeSplitter with no children yet 1046 // KDGanttMinimizeSplitter with no children yet
1047 maxl = QWIDGETSIZE_MAX; 1047 maxl = QWIDGETSIZE_MAX;
1048 } 1048 }
1049 } else { 1049 } else {
1050 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 1050 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
1051 } 1051 }
1052 if ( maxt < mint ) 1052 if ( maxt < mint )
1053 maxt = mint; 1053 maxt = mint;
1054 1054
1055 if ( orient == Horizontal ) { 1055 if ( orient == Horizontal ) {
1056 setMaximumSize( maxl, maxt ); 1056 setMaximumSize( maxl, maxt );
1057 setMinimumSize( minl, mint ); 1057 setMinimumSize( minl, mint );
1058 } else { 1058 } else {
1059 setMaximumSize( maxt, maxl ); 1059 setMaximumSize( maxt, maxl );
1060 setMinimumSize( mint, minl ); 1060 setMinimumSize( mint, minl );
1061 } 1061 }
1062 if ( update ) 1062 if ( update )
1063 doResize(); 1063 doResize();
1064} 1064}
1065 1065
1066/*! 1066/*!
1067 Sets resize mode of \a w to \a mode. 1067 Sets resize mode of \a w to \a mode.
1068 1068
1069 \sa ResizeMode 1069 \sa ResizeMode
1070*/ 1070*/
1071 1071
1072void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 1072void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode )
1073{ 1073{
1074 processChildEvents(); 1074 processChildEvents();
1075 QSplitterLayoutStruct *s = data->list.first(); 1075 QSplitterLayoutStruct *s = data->list.first();
1076 while ( s ) { 1076 while ( s ) {
1077 if ( s->wid == w ) { 1077 if ( s->wid == w ) {
1078 s->mode = mode; 1078 s->mode = mode;
1079 return; 1079 return;
1080 } 1080 }
1081 s = data->list.next(); 1081 s = data->list.next();
1082 } 1082 }
1083 s = addWidget( w, TRUE ); 1083 s = addWidget( w, TRUE );
1084 s->mode = mode; 1084 s->mode = mode;
1085} 1085}
1086 1086
1087 1087
1088/*! 1088/*!
1089 Returns TRUE if opaque resize is on; otherwise returns FALSE. 1089 Returns TRUE if opaque resize is on; otherwise returns FALSE.
1090 1090
1091 \sa setOpaqueResize() 1091 \sa setOpaqueResize()
1092*/ 1092*/
1093 1093
1094bool KDGanttMinimizeSplitter::opaqueResize() const 1094bool KDGanttMinimizeSplitter::opaqueResize() const
1095{ 1095{
1096 return data->opaque; 1096 return data->opaque;
1097} 1097}
1098 1098
1099 1099
1100/*! 1100/*!
1101 If \a on is TRUE then opaque resizing is turned on; otherwise 1101 If \a on is TRUE then opaque resizing is turned on; otherwise
1102 opaque resizing is turned off. 1102 opaque resizing is turned off.
1103 Opaque resizing is initially turned off. 1103 Opaque resizing is initially turned off.
1104 1104
1105 \sa opaqueResize() 1105 \sa opaqueResize()
1106*/ 1106*/
1107 1107
1108void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) 1108void KDGanttMinimizeSplitter::setOpaqueResize( bool on )
1109{ 1109{
1110 data->opaque = on; 1110 data->opaque = on;
1111} 1111}
1112 1112
1113 1113
1114/*! 1114/*!
1115 Moves widget \a w to the leftmost/top position. 1115 Moves widget \a w to the leftmost/top position.
1116*/ 1116*/
1117 1117
1118void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) 1118void KDGanttMinimizeSplitter::moveToFirst( QWidget *w )
1119{ 1119{
1120 processChildEvents(); 1120 processChildEvents();
1121 bool found = FALSE; 1121 bool found = FALSE;
1122 QSplitterLayoutStruct *s = data->list.first(); 1122 QSplitterLayoutStruct *s = data->list.first();
1123 while ( s ) { 1123 while ( s ) {
1124 if ( s->wid == w ) { 1124 if ( s->wid == w ) {
1125 found = TRUE; 1125 found = TRUE;
1126 QSplitterLayoutStruct *p = data->list.prev(); 1126 QSplitterLayoutStruct *p = data->list.prev();
1127 if ( p ) { // not already at first place 1127 if ( p ) { // not already at first place
1128 data->list.take(); //take p 1128 data->list.take(); //take p
1129 data->list.take(); // take s 1129 data->list.take(); // take s
1130 data->list.insert( 0, p ); 1130 data->list.insert( 0, p );
1131 data->list.insert( 0, s ); 1131 data->list.insert( 0, s );
1132 } 1132 }
1133 break; 1133 break;
1134 } 1134 }
1135 s = data->list.next(); 1135 s = data->list.next();
1136 } 1136 }
1137 if ( !found ) 1137 if ( !found )
1138 addWidget( w, TRUE ); 1138 addWidget( w, TRUE );
1139 recalcId(); 1139 recalcId();
1140} 1140}
1141 1141
1142 1142
1143/*! 1143/*!
1144 Moves widget \a w to the rightmost/bottom position. 1144 Moves widget \a w to the rightmost/bottom position.
1145*/ 1145*/
1146 1146
1147void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) 1147void KDGanttMinimizeSplitter::moveToLast( QWidget *w )
1148{ 1148{
1149 processChildEvents(); 1149 processChildEvents();
1150 bool found = FALSE; 1150 bool found = FALSE;
1151 QSplitterLayoutStruct *s = data->list.first(); 1151 QSplitterLayoutStruct *s = data->list.first();
1152 while ( s ) { 1152 while ( s ) {
1153 if ( s->wid == w ) { 1153 if ( s->wid == w ) {
1154 found = TRUE; 1154 found = TRUE;
1155 data->list.take(); // take s 1155 data->list.take(); // take s
1156 QSplitterLayoutStruct *p = data->list.current(); 1156 QSplitterLayoutStruct *p = data->list.current();
1157 if ( p ) { // the splitter handle after s 1157 if ( p ) { // the splitter handle after s
1158 data->list.take(); //take p 1158 data->list.take(); //take p
1159 data->list.append( p ); 1159 data->list.append( p );
1160 } 1160 }
1161 data->list.append( s ); 1161 data->list.append( s );
1162 break; 1162 break;
1163 } 1163 }
1164 s = data->list.next(); 1164 s = data->list.next();
1165 } 1165 }
1166 if ( !found ) 1166 if ( !found )
1167 addWidget( w); 1167 addWidget( w);
1168 recalcId(); 1168 recalcId();
1169} 1169}
1170 1170
1171 1171
1172void KDGanttMinimizeSplitter::recalcId() 1172void KDGanttMinimizeSplitter::recalcId()
1173{ 1173{
1174 int n = data->list.count(); 1174 int n = data->list.count();
1175 for ( int i = 0; i < n; i++ ) { 1175 for ( int i = 0; i < n; i++ ) {
1176 QSplitterLayoutStruct *s = data->list.at(i); 1176 QSplitterLayoutStruct *s = data->list.at(i);
1177 if ( s->isSplitter ) 1177 if ( s->isSplitter )
1178 ((KDGanttSplitterHandle*)s->wid)->setId(i); 1178 ((KDGanttSplitterHandle*)s->wid)->setId(i);
1179 } 1179 }
1180} 1180}
1181 1181
1182 1182
1183/*!\reimp 1183/*!\reimp
1184*/ 1184*/
1185QSize KDGanttMinimizeSplitter::sizeHint() const 1185QSize KDGanttMinimizeSplitter::sizeHint() const
1186{ 1186{
1187 constPolish(); 1187 constPolish();
1188 int l = 0; 1188 int l = 0;
1189 int t = 0; 1189 int t = 0;
1190 if ( children() ) { 1190 if ( children() ) {
1191 const QObjectList * c = children(); 1191 const QObjectList * c = children();
1192 QObjectListIt it( *c ); 1192 QObjectListIt it( *c );
1193 QObject * o; 1193 QObject * o;
1194 1194
1195 while( (o=it.current()) != 0 ) { 1195 while( (o=it.current()) != 0 ) {
1196 ++it; 1196 ++it;
1197 if ( o->isWidgetType() && 1197 if ( o->isWidgetType() &&
1198 !((QWidget*)o)->isHidden() ) { 1198 !((QWidget*)o)->isHidden() ) {
1199 QSize s = ((QWidget*)o)->sizeHint(); 1199 QSize s = ((QWidget*)o)->sizeHint();
1200 if ( s.isValid() ) { 1200 if ( s.isValid() ) {
1201 l += pick( s ); 1201 l += pick( s );
1202 t = QMAX( t, trans( s ) ); 1202 t = QMAX( t, trans( s ) );
1203 } 1203 }
1204 } 1204 }
1205 } 1205 }
1206 } 1206 }
1207 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1207 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1208} 1208}
1209 1209
1210 1210
1211/*! 1211/*!
1212\reimp 1212\reimp
1213*/ 1213*/
1214 1214
1215QSize KDGanttMinimizeSplitter::minimumSizeHint() const 1215QSize KDGanttMinimizeSplitter::minimumSizeHint() const
1216{ 1216{
1217 constPolish(); 1217 constPolish();
1218 int l = 0; 1218 int l = 0;
1219 int t = 0; 1219 int t = 0;
1220 if ( children() ) { 1220 if ( children() ) {
1221 const QObjectList * c = children(); 1221 const QObjectList * c = children();
1222 QObjectListIt it( *c ); 1222 QObjectListIt it( *c );
1223 QObject * o; 1223 QObject * o;
1224 1224
1225 while( (o=it.current()) != 0 ) { 1225 while( (o=it.current()) != 0 ) {
1226 ++it; 1226 ++it;
1227 if ( o->isWidgetType() && 1227 if ( o->isWidgetType() &&
1228 !((QWidget*)o)->isHidden() ) { 1228 !((QWidget*)o)->isHidden() ) {
1229 QSize s = minSizeHint((QWidget*)o); 1229 QSize s = minSizeHint((QWidget*)o);
1230 if ( s.isValid() ) { 1230 if ( s.isValid() ) {
1231 l += pick( s ); 1231 l += pick( s );
1232 t = QMAX( t, trans( s ) ); 1232 t = QMAX( t, trans( s ) );
1233 } 1233 }
1234 } 1234 }
1235 } 1235 }
1236 } 1236 }
1237 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1237 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1238} 1238}
1239 1239
1240 1240
1241/* 1241/*
1242 Calculates stretch parameters from current sizes 1242 Calculates stretch parameters from current sizes
1243*/ 1243*/
1244 1244
1245void KDGanttMinimizeSplitter::storeSizes() 1245void KDGanttMinimizeSplitter::storeSizes()
1246{ 1246{
1247 QSplitterLayoutStruct *s = data->list.first(); 1247 QSplitterLayoutStruct *s = data->list.first();
1248 while ( s ) { 1248 while ( s ) {
1249 if ( !s->isSplitter ) 1249 if ( !s->isSplitter )
1250 s->sizer = pick( s->wid->size() ); 1250 s->sizer = pick( s->wid->size() );
1251 s = data->list.next(); 1251 s = data->list.next();
1252 } 1252 }
1253} 1253}
1254 1254
1255 1255
1256#if 0 // ### remove this code ASAP 1256#if 0 // ### remove this code ASAP
1257 1257
1258/*! 1258/*!
1259 Hides \a w if \a hide is TRUE and updates the splitter. 1259 Hides \a w if \a hide is TRUE and updates the splitter.
1260 1260
1261 \warning Due to a limitation in the current implementation, 1261 \warning Due to a limitation in the current implementation,
1262 calling QWidget::hide() will not work. 1262 calling QWidget::hide() will not work.
1263*/ 1263*/
1264 1264
1265void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) 1265void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide )
1266{ 1266{
1267 if ( w == w1 ) { 1267 if ( w == w1 ) {
1268 w1show = !hide; 1268 w1show = !hide;
1269 } else if ( w == w2 ) { 1269 } else if ( w == w2 ) {
1270 w2show = !hide; 1270 w2show = !hide;
1271 } else { 1271 } else {
1272#ifdef QT_CHECK_RANGE 1272#ifdef QT_CHECK_RANGE
1273 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); 1273 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" );
1274#endif 1274#endif
1275 return; 1275 return;
1276 } 1276 }
1277 if ( hide ) 1277 if ( hide )
1278 w->hide(); 1278 w->hide();
1279 else 1279 else
1280 w->show(); 1280 w->show();
1281 recalc( TRUE ); 1281 recalc( TRUE );
1282} 1282}
1283 1283
1284 1284
1285/*! 1285/*!
1286 Returns the hidden status of \a w 1286 Returns the hidden status of \a w
1287*/ 1287*/
1288 1288
1289bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const 1289bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const
1290{ 1290{
1291 if ( w == w1 ) 1291 if ( w == w1 )
1292 return !w1show; 1292 return !w1show;
1293 else if ( w == w2 ) 1293 else if ( w == w2 )
1294 return !w2show; 1294 return !w2show;
1295#ifdef QT_CHECK_RANGE 1295#ifdef QT_CHECK_RANGE
1296 else 1296 else
1297 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); 1297 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" );
1298#endif 1298#endif
1299 return FALSE; 1299 return FALSE;
1300} 1300}
1301#endif 1301#endif
1302 1302
1303 1303
1304/*! 1304/*!
1305 Returns a list of the size parameters of all the widgets in this 1305 Returns a list of the size parameters of all the widgets in this
1306 splitter. 1306 splitter.
1307 1307
1308 Giving the values to another splitter's setSizes() function will 1308 Giving the values to another splitter's setSizes() function will
1309 produce a splitter with the same layout as this one. 1309 produce a splitter with the same layout as this one.
1310 1310
1311 Note that if you want to iterate over the list, you should 1311 Note that if you want to iterate over the list, you should
1312 iterate over a copy, e.g. 1312 iterate over a copy, e.g.
1313 \code 1313 \code
1314 QValueList<int> list = mySplitter.sizes(); 1314 QValueList<int> list = mySplitter.sizes();
1315 QValueList<int>::Iterator it = list.begin(); 1315 QValueList<int>::Iterator it = list.begin();
1316 while( it != list.end() ) { 1316 while( it != list.end() ) {
1317 myProcessing( *it ); 1317 myProcessing( *it );
1318 ++it; 1318 ++it;
1319 } 1319 }
1320 \endcode 1320 \endcode
1321 1321
1322 \sa setSizes() 1322 \sa setSizes()
1323*/ 1323*/
1324 1324
1325QValueList<int> KDGanttMinimizeSplitter::sizes() const 1325QValueList<int> KDGanttMinimizeSplitter::sizes() const
1326{ 1326{
1327 if ( !testWState(WState_Polished) ) { 1327 if ( !testWState(WState_Polished) ) {
1328 QWidget* that = (QWidget*) this; 1328 QWidget* that = (QWidget*) this;
1329 that->polish(); 1329 that->polish();
1330 } 1330 }
1331 QValueList<int> list; 1331 QValueList<int> list;
1332 QSplitterLayoutStruct *s = data->list.first(); 1332 QSplitterLayoutStruct *s = data->list.first();
1333 while ( s ) { 1333 while ( s ) {
1334 if ( !s->isSplitter ) 1334 if ( !s->isSplitter )
1335 list.append( s->sizer ); 1335 list.append( s->sizer );
1336 s = data->list.next(); 1336 s = data->list.next();
1337 } 1337 }
1338 return list; 1338 return list;
1339} 1339}
1340 1340
1341 1341
1342 1342
1343/*! 1343/*!
1344 Sets the size parameters to the values given in \a list. 1344 Sets the size parameters to the values given in \a list.
1345 If the splitter is horizontal, the values set the sizes from 1345 If the splitter is horizontal, the values set the sizes from
1346 left to right. If it is vertical, the sizes are applied from 1346 left to right. If it is vertical, the sizes are applied from
1347 top to bottom. 1347 top to bottom.
1348 Extra values in \a list are ignored. 1348 Extra values in \a list are ignored.
1349 1349
1350 If \a list contains too few values, the result is undefined 1350 If \a list contains too few values, the result is undefined
1351 but the program will still be well-behaved. 1351 but the program will still be well-behaved.
1352 1352
1353 \sa sizes() 1353 \sa sizes()
1354*/ 1354*/
1355 1355
1356void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) 1356void KDGanttMinimizeSplitter::setSizes( QValueList<int> list )
1357{ 1357{
1358 processChildEvents(); 1358 processChildEvents();
1359 QValueList<int>::Iterator it = list.begin(); 1359 QValueList<int>::Iterator it = list.begin();
1360 QSplitterLayoutStruct *s = data->list.first(); 1360 QSplitterLayoutStruct *s = data->list.first();
1361 while ( s && it != list.end() ) { 1361 while ( s && it != list.end() ) {
1362 if ( !s->isSplitter ) { 1362 if ( !s->isSplitter ) {
1363 s->sizer = *it; 1363 s->sizer = *it;
1364 ++it; 1364 ++it;
1365 } 1365 }
1366 s = data->list.next(); 1366 s = data->list.next();
1367 } 1367 }
1368 doResize(); 1368 doResize();
1369} 1369}
1370 1370
1371 1371
1372/*! 1372/*!
1373 Gets all posted child events, ensuring that the internal state of 1373 Gets all posted child events, ensuring that the internal state of
1374 the splitter is consistent. 1374 the splitter is consistent.
1375*/ 1375*/
1376 1376
1377void KDGanttMinimizeSplitter::processChildEvents() 1377void KDGanttMinimizeSplitter::processChildEvents()
1378{ 1378{
1379 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1379 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1380} 1380}
1381 1381
1382 1382
1383/*! 1383/*!
1384 \reimp 1384 \reimp
1385*/ 1385*/
1386 1386
1387void KDGanttMinimizeSplitter::styleChange( QStyle& old ) 1387void KDGanttMinimizeSplitter::styleChange( QStyle& old )
1388{ 1388{
1389 1389
1390#if QT_VERSION >= 300 1390#if QT_VERSION >= 0x030000
1391 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1391 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
1392#else 1392#else
1393 int sw = style().splitterWidth(); 1393 int sw = style().splitterWidth();
1394#endif 1394#endif
1395 QSplitterLayoutStruct *s = data->list.first(); 1395 QSplitterLayoutStruct *s = data->list.first();
1396 while ( s ) { 1396 while ( s ) {
1397 if ( s->isSplitter ) 1397 if ( s->isSplitter )
1398 s->sizer = sw; 1398 s->sizer = sw;
1399 s = data->list.next(); 1399 s = data->list.next();
1400 } 1400 }
1401 doResize(); 1401 doResize();
1402 QFrame::styleChange( old ); 1402 QFrame::styleChange( old );
1403} 1403}
1404 1404
1405#endif 1405#endif
1406 1406
1407/*! 1407/*!
1408 Specifies the direction of the minimize buttons. 1408 Specifies the direction of the minimize buttons.
1409 If the orientation of the splitter is horizontal then with 1409 If the orientation of the splitter is horizontal then with
1410 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, 1410 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used,
1411 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down 1411 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down
1412 should be used. 1412 should be used.
1413*/ 1413*/
1414void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) 1414void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction )
1415{ 1415{
1416 _direction = direction; 1416 _direction = direction;
1417} 1417}
1418 1418
1419/*! 1419/*!
1420 Returns the direction of the minimize buttons. 1420 Returns the direction of the minimize buttons.
1421*/ 1421*/
1422KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const 1422KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const
1423{ 1423{
1424 return _direction; 1424 return _direction;
1425} 1425}
1426 1426
1427/* 1427/*
1428 This is a copy of qGeomCalc() in qlayoutengine.cpp which 1428 This is a copy of qGeomCalc() in qlayoutengine.cpp which
1429 unfortunately isn't exported. 1429 unfortunately isn't exported.
1430*/ 1430*/
1431static inline int toFixed( int i ) { return i * 256; } 1431static inline int toFixed( int i ) { return i * 256; }
1432static inline int fRound( int i ) { 1432static inline int fRound( int i ) {
1433 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; 1433 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256;
1434} 1434}
1435void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 1435void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
1436 int space, int spacer ) 1436 int space, int spacer )
1437{ 1437{
1438 typedef int fixed; 1438 typedef int fixed;
1439 int cHint = 0; 1439 int cHint = 0;
1440 int cMin = 0; 1440 int cMin = 0;
1441 int cMax = 0; 1441 int cMax = 0;
1442 int sumStretch = 0; 1442 int sumStretch = 0;
1443 int spacerCount = 0; 1443 int spacerCount = 0;
1444 1444
1445 bool wannaGrow = FALSE; // anyone who really wants to grow? 1445 bool wannaGrow = FALSE; // anyone who really wants to grow?
1446 // bool canShrink = FALSE; // anyone who could be persuaded to shrink? 1446 // bool canShrink = FALSE; // anyone who could be persuaded to shrink?
1447 1447
1448 int i; 1448 int i;
1449 for ( i = start; i < start + count; i++ ) { 1449 for ( i = start; i < start + count; i++ ) {
1450 chain[i].done = FALSE; 1450 chain[i].done = FALSE;
1451 cHint += chain[i].sizeHint; 1451 cHint += chain[i].sizeHint;
1452 cMin += chain[i].minimumSize; 1452 cMin += chain[i].minimumSize;
1453 cMax += chain[i].maximumSize; 1453 cMax += chain[i].maximumSize;
1454 sumStretch += chain[i].stretch; 1454 sumStretch += chain[i].stretch;
1455 if ( !chain[i].empty ) 1455 if ( !chain[i].empty )
1456 spacerCount++; 1456 spacerCount++;
1457 wannaGrow = wannaGrow || chain[i].expansive; 1457 wannaGrow = wannaGrow || chain[i].expansive;
1458 } 1458 }
1459 1459
1460 int extraspace = 0; 1460 int extraspace = 0;
1461 if ( spacerCount ) 1461 if ( spacerCount )
1462 spacerCount--; // only spacers between things 1462 spacerCount--; // only spacers between things
1463 if ( space < cMin + spacerCount * spacer ) { 1463 if ( space < cMin + spacerCount * spacer ) {
1464 //qDebug("not enough space"); 1464 //qDebug("not enough space");
1465 for ( i = start; i < start+count; i++ ) { 1465 for ( i = start; i < start+count; i++ ) {
1466 chain[i].size = chain[i].minimumSize; 1466 chain[i].size = chain[i].minimumSize;
1467 chain[i].done = TRUE; 1467 chain[i].done = TRUE;
1468 } 1468 }
1469 } else if ( space < cHint + spacerCount*spacer ) { 1469 } else if ( space < cHint + spacerCount*spacer ) {
1470 // Less space than sizeHint, but more than minimum. 1470 // Less space than sizeHint, but more than minimum.
1471 // Currently take space equally from each, like in Qt 2.x. 1471 // Currently take space equally from each, like in Qt 2.x.
1472 // Commented-out lines will give more space to stretchier items. 1472 // Commented-out lines will give more space to stretchier items.
1473 int n = count; 1473 int n = count;
1474 int space_left = space - spacerCount*spacer; 1474 int space_left = space - spacerCount*spacer;
1475 int overdraft = cHint - space_left; 1475 int overdraft = cHint - space_left;
1476 //first give to the fixed ones: 1476 //first give to the fixed ones:
1477 for ( i = start; i < start+count; i++ ) { 1477 for ( i = start; i < start+count; i++ ) {
1478 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { 1478 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) {
1479 chain[i].size = chain[i].sizeHint; 1479 chain[i].size = chain[i].sizeHint;
1480 chain[i].done = TRUE; 1480 chain[i].done = TRUE;
1481 space_left -= chain[i].sizeHint; 1481 space_left -= chain[i].sizeHint;
1482 // sumStretch -= chain[i].stretch; 1482 // sumStretch -= chain[i].stretch;
1483 n--; 1483 n--;
1484 } 1484 }
1485 } 1485 }
1486 bool finished = n == 0; 1486 bool finished = n == 0;
1487 while ( !finished ) { 1487 while ( !finished ) {
1488 finished = TRUE; 1488 finished = TRUE;
1489 fixed fp_over = toFixed( overdraft ); 1489 fixed fp_over = toFixed( overdraft );
1490 fixed fp_w = 0; 1490 fixed fp_w = 0;
1491 1491
1492 for ( i = start; i < start+count; i++ ) { 1492 for ( i = start; i < start+count; i++ ) {
1493 if ( chain[i].done ) 1493 if ( chain[i].done )
1494 continue; 1494 continue;
1495 // if ( sumStretch <= 0 ) 1495 // if ( sumStretch <= 0 )
1496 fp_w += fp_over / n; 1496 fp_w += fp_over / n;
1497 // else 1497 // else
1498 // fp_w += (fp_over * chain[i].stretch) / sumStretch; 1498 // fp_w += (fp_over * chain[i].stretch) / sumStretch;
1499 int w = fRound( fp_w ); 1499 int w = fRound( fp_w );
1500 chain[i].size = chain[i].sizeHint - w; 1500 chain[i].size = chain[i].sizeHint - w;
1501 fp_w -= toFixed( w ); //give the difference to the next 1501 fp_w -= toFixed( w ); //give the difference to the next
1502 if ( chain[i].size < chain[i].minimumSize ) { 1502 if ( chain[i].size < chain[i].minimumSize ) {
1503 chain[i].done = TRUE; 1503 chain[i].done = TRUE;
1504 chain[i].size = chain[i].minimumSize; 1504 chain[i].size = chain[i].minimumSize;
1505 finished = FALSE; 1505 finished = FALSE;
1506 overdraft -= chain[i].sizeHint - chain[i].minimumSize; 1506 overdraft -= chain[i].sizeHint - chain[i].minimumSize;
1507 // sumStretch -= chain[i].stretch; 1507 // sumStretch -= chain[i].stretch;
1508 n--; 1508 n--;
1509 break; 1509 break;
1510 } 1510 }
1511 } 1511 }
1512 } 1512 }
1513 } else { //extra space 1513 } else { //extra space
1514 int n = count; 1514 int n = count;
1515 int space_left = space - spacerCount*spacer; 1515 int space_left = space - spacerCount*spacer;
1516 // first give to the fixed ones, and handle non-expansiveness 1516 // first give to the fixed ones, and handle non-expansiveness
1517 for ( i = start; i < start + count; i++ ) { 1517 for ( i = start; i < start + count; i++ ) {
1518 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint 1518 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint
1519 || wannaGrow && !chain[i].expansive) ) { 1519 || wannaGrow && !chain[i].expansive) ) {
1520 chain[i].size = chain[i].sizeHint; 1520 chain[i].size = chain[i].sizeHint;
1521 chain[i].done = TRUE; 1521 chain[i].done = TRUE;
1522 space_left -= chain[i].sizeHint; 1522 space_left -= chain[i].sizeHint;
1523 sumStretch -= chain[i].stretch; 1523 sumStretch -= chain[i].stretch;
1524 n--; 1524 n--;
1525 } 1525 }
1526 } 1526 }
1527 extraspace = space_left; 1527 extraspace = space_left;
1528 /* 1528 /*
1529 Do a trial distribution and calculate how much it is off. 1529 Do a trial distribution and calculate how much it is off.
1530 If there are more deficit pixels than surplus pixels, give 1530 If there are more deficit pixels than surplus pixels, give
1531 the minimum size items what they need, and repeat. 1531 the minimum size items what they need, and repeat.
1532 Otherwise give to the maximum size items, and repeat. 1532 Otherwise give to the maximum size items, and repeat.
1533 1533
1534 I have a wonderful mathematical proof for the correctness 1534 I have a wonderful mathematical proof for the correctness
1535 of this principle, but unfortunately this comment is too 1535 of this principle, but unfortunately this comment is too
1536 small to contain it. 1536 small to contain it.
1537 */ 1537 */
1538 int surplus, deficit; 1538 int surplus, deficit;
1539 do { 1539 do {
1540 surplus = deficit = 0; 1540 surplus = deficit = 0;
1541 fixed fp_space = toFixed( space_left ); 1541 fixed fp_space = toFixed( space_left );
1542 fixed fp_w = 0; 1542 fixed fp_w = 0;
1543 for ( i = start; i < start+count; i++ ) { 1543 for ( i = start; i < start+count; i++ ) {
1544 if ( chain[i].done ) 1544 if ( chain[i].done )
1545 continue; 1545 continue;
1546 extraspace = 0; 1546 extraspace = 0;
1547 if ( sumStretch <= 0 ) 1547 if ( sumStretch <= 0 )
1548 fp_w += fp_space / n; 1548 fp_w += fp_space / n;
1549 else 1549 else
1550 fp_w += (fp_space * chain[i].stretch) / sumStretch; 1550 fp_w += (fp_space * chain[i].stretch) / sumStretch;
1551 int w = fRound( fp_w ); 1551 int w = fRound( fp_w );
1552 chain[i].size = w; 1552 chain[i].size = w;
1553 fp_w -= toFixed( w ); // give the difference to the next 1553 fp_w -= toFixed( w ); // give the difference to the next
1554 if ( w < chain[i].sizeHint ) { 1554 if ( w < chain[i].sizeHint ) {
1555 deficit += chain[i].sizeHint - w; 1555 deficit += chain[i].sizeHint - w;
1556 } else if ( w > chain[i].maximumSize ) { 1556 } else if ( w > chain[i].maximumSize ) {
1557 surplus += w - chain[i].maximumSize; 1557 surplus += w - chain[i].maximumSize;
1558 } 1558 }
1559 } 1559 }
1560 if ( deficit > 0 && surplus <= deficit ) { 1560 if ( deficit > 0 && surplus <= deficit ) {
1561 // give to the ones that have too little 1561 // give to the ones that have too little
1562 for ( i = start; i < start+count; i++ ) { 1562 for ( i = start; i < start+count; i++ ) {
1563 if ( !chain[i].done && 1563 if ( !chain[i].done &&
1564 chain[i].size < chain[i].sizeHint ) { 1564 chain[i].size < chain[i].sizeHint ) {
1565 chain[i].size = chain[i].sizeHint; 1565 chain[i].size = chain[i].sizeHint;
1566 chain[i].done = TRUE; 1566 chain[i].done = TRUE;
1567 space_left -= chain[i].sizeHint; 1567 space_left -= chain[i].sizeHint;
1568 sumStretch -= chain[i].stretch; 1568 sumStretch -= chain[i].stretch;
1569 n--; 1569 n--;
1570 } 1570 }
1571 } 1571 }
1572 } 1572 }
1573 if ( surplus > 0 && surplus >= deficit ) { 1573 if ( surplus > 0 && surplus >= deficit ) {
1574 // take from the ones that have too much 1574 // take from the ones that have too much
1575 for ( i = start; i < start+count; i++ ) { 1575 for ( i = start; i < start+count; i++ ) {
1576 if ( !chain[i].done && 1576 if ( !chain[i].done &&
1577 chain[i].size > chain[i].maximumSize ) { 1577 chain[i].size > chain[i].maximumSize ) {
1578 chain[i].size = chain[i].maximumSize; 1578 chain[i].size = chain[i].maximumSize;
1579 chain[i].done = TRUE; 1579 chain[i].done = TRUE;
1580 space_left -= chain[i].maximumSize; 1580 space_left -= chain[i].maximumSize;
1581 sumStretch -= chain[i].stretch; 1581 sumStretch -= chain[i].stretch;
1582 n--; 1582 n--;
1583 } 1583 }
1584 } 1584 }
1585 } 1585 }
1586 } while ( n > 0 && surplus != deficit ); 1586 } while ( n > 0 && surplus != deficit );
1587 if ( n == 0 ) 1587 if ( n == 0 )
1588 extraspace = space_left; 1588 extraspace = space_left;
1589 } 1589 }
1590 1590
1591 // as a last resort, we distribute the unwanted space equally 1591 // as a last resort, we distribute the unwanted space equally
1592 // among the spacers (counting the start and end of the chain). 1592 // among the spacers (counting the start and end of the chain).
1593 1593
1594 //### should do a sub-pixel allocation of extra space 1594 //### should do a sub-pixel allocation of extra space
1595 int extra = extraspace / ( spacerCount + 2 ); 1595 int extra = extraspace / ( spacerCount + 2 );
1596 int p = pos + extra; 1596 int p = pos + extra;
1597 for ( i = start; i < start+count; i++ ) { 1597 for ( i = start; i < start+count; i++ ) {
1598 chain[i].pos = p; 1598 chain[i].pos = p;
1599 p = p + chain[i].size; 1599 p = p + chain[i].size;
1600 if ( !chain[i].empty ) 1600 if ( !chain[i].empty )
1601 p += spacer+extra; 1601 p += spacer+extra;
1602 } 1602 }
1603} 1603}
1604 1604
1605#endif 1605#endif
1606 1606
1607/*! 1607/*!
1608 \enum KDGanttMinimizeSplitter::Direction 1608 \enum KDGanttMinimizeSplitter::Direction
1609 1609
1610 The values of this enumeration describe into which direction the 1610 The values of this enumeration describe into which direction the
1611 splitter will collapse its child widgets. By extension, it also 1611 splitter will collapse its child widgets. By extension, it also
1612 specifies the orientation of the splitter; collapsing to the left or 1612 specifies the orientation of the splitter; collapsing to the left or
1613 to the right results in a horizontal splitter, collapsing to the top 1613 to the right results in a horizontal splitter, collapsing to the top
1614 or bottom in a vertical splitter. 1614 or bottom in a vertical splitter.
1615*/ 1615*/
1616 1616
1617/*! 1617/*!
1618 \fn Orientation KDGanttMinimizeSplitter::orientation() const 1618 \fn Orientation KDGanttMinimizeSplitter::orientation() const
1619 1619
1620 Returns the orientation of the splitter. 1620 Returns the orientation of the splitter.
1621*/ 1621*/
1622 1622
1623/*! \enum KDGanttMinimizeSplitter::ResizeMode 1623/*! \enum KDGanttMinimizeSplitter::ResizeMode
1624 1624
1625 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are: 1625 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are:
1626 1626
1627 Stretch: the widget will be resized when the splitter 1627 Stretch: the widget will be resized when the splitter
1628 itself is resized. 1628 itself is resized.
1629 1629
1630 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size 1630 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size
1631 unchanged. 1631 unchanged.
1632 1632
1633 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the 1633 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the
1634 widget's size hint changes. 1634 widget's size hint changes.
1635*/ 1635*/
1636 1636
diff --git a/microkde/kcalendarsystemgregorian.cpp b/microkde/kcalendarsystemgregorian.cpp
index 7c5b62a..cc12b9f 100644
--- a/microkde/kcalendarsystemgregorian.cpp
+++ b/microkde/kcalendarsystemgregorian.cpp
@@ -1,359 +1,359 @@
1/* 1/*
2 Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es> 2 Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es>
3 Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org> 3 Copyright (c) 2002 Hans Petter Bieker <bieker@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
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// Derived gregorian kde calendar class 21// Derived gregorian kde calendar class
22// Just a schema. 22// Just a schema.
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include "kcalendarsystemgregorian.h" 30#include "kcalendarsystemgregorian.h"
31 31
32KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) 32KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale)
33 : KCalendarSystem(locale) 33 : KCalendarSystem(locale)
34{ 34{
35 kdDebug(5400) << "Created gregorian calendar" << endl; 35 kdDebug(5400) << "Created gregorian calendar" << endl;
36} 36}
37 37
38KCalendarSystemGregorian::~KCalendarSystemGregorian() 38KCalendarSystemGregorian::~KCalendarSystemGregorian()
39{ 39{
40} 40}
41 41
42int KCalendarSystemGregorian::year(const QDate& date) const 42int KCalendarSystemGregorian::year(const QDate& date) const
43{ 43{
44// kdDebug(5400) << "Gregorian year..." << endl; 44// kdDebug(5400) << "Gregorian year..." << endl;
45 return date.year(); 45 return date.year();
46} 46}
47 47
48int KCalendarSystemGregorian::monthsInYear( const QDate & ) const 48int KCalendarSystemGregorian::monthsInYear( const QDate & ) const
49{ 49{
50// kdDebug(5400) << "Gregorian monthsInYear" << endl; 50// kdDebug(5400) << "Gregorian monthsInYear" << endl;
51 51
52 return 12; 52 return 12;
53} 53}
54 54
55int KCalendarSystemGregorian::weeksInYear(int year) const 55int KCalendarSystemGregorian::weeksInYear(int year) const
56{ 56{
57#if QT_VERSION >= 300 57#if QT_VERSION >= 0x030000
58 QDate temp; 58 QDate temp;
59 temp.setYMD(year, 12, 31); 59 temp.setYMD(year, 12, 31);
60 60
61 // If the last day of the year is in the first week, we have to check the 61 // If the last day of the year is in the first week, we have to check the
62 // week before 62 // week before
63 if ( temp.weekNumber() == 1 ) 63 if ( temp.weekNumber() == 1 )
64 temp.addDays(-7); 64 temp.addDays(-7);
65 65
66 return temp.weekNumber(); 66 return temp.weekNumber();
67#else 67#else
68 return 52; 68 return 52;
69#endif 69#endif
70} 70}
71 71
72int KCalendarSystemGregorian::weekNumber(const QDate& date, 72int KCalendarSystemGregorian::weekNumber(const QDate& date,
73 int * yearNum) const 73 int * yearNum) const
74{ 74{
75#if QT_VERSION >= 300 75#if QT_VERSION >= 0x030000
76 return date.weekNumber(yearNum); 76 return date.weekNumber(yearNum);
77#else 77#else
78 return 1; 78 return 1;
79#endif 79#endif
80} 80}
81 81
82QString KCalendarSystemGregorian::monthName(const QDate& date, 82QString KCalendarSystemGregorian::monthName(const QDate& date,
83 bool shortName) const 83 bool shortName) const
84{ 84{
85 return monthName(month(date), shortName); 85 return monthName(month(date), shortName);
86} 86}
87 87
88QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const 88QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const
89{ 89{
90 return monthNamePossessive(month(date), shortName); 90 return monthNamePossessive(month(date), shortName);
91} 91}
92 92
93QString KCalendarSystemGregorian::monthName(int month, bool shortName) const 93QString KCalendarSystemGregorian::monthName(int month, bool shortName) const
94{ 94{
95// kdDebug(5400) << "Gregorian getMonthName" << endl; 95// kdDebug(5400) << "Gregorian getMonthName" << endl;
96 96
97 if ( shortName ) 97 if ( shortName )
98 switch ( month ) 98 switch ( month )
99 { 99 {
100 case 1: 100 case 1:
101 return locale()->translate("January", "Jan"); 101 return locale()->translate("January", "Jan");
102 case 2: 102 case 2:
103 return locale()->translate("February", "Feb"); 103 return locale()->translate("February", "Feb");
104 case 3: 104 case 3:
105 return locale()->translate("March", "Mar"); 105 return locale()->translate("March", "Mar");
106 case 4: 106 case 4:
107 return locale()->translate("April", "Apr"); 107 return locale()->translate("April", "Apr");
108 case 5: 108 case 5:
109 return locale()->translate("May short", "May"); 109 return locale()->translate("May short", "May");
110 case 6: 110 case 6:
111 return locale()->translate("June", "Jun"); 111 return locale()->translate("June", "Jun");
112 case 7: 112 case 7:
113 return locale()->translate("July", "Jul"); 113 return locale()->translate("July", "Jul");
114 case 8: 114 case 8:
115 return locale()->translate("August", "Aug"); 115 return locale()->translate("August", "Aug");
116 case 9: 116 case 9:
117 return locale()->translate("September", "Sep"); 117 return locale()->translate("September", "Sep");
118 case 10: 118 case 10:
119 return locale()->translate("October", "Oct"); 119 return locale()->translate("October", "Oct");
120 case 11: 120 case 11:
121 return locale()->translate("November", "Nov"); 121 return locale()->translate("November", "Nov");
122 case 12: 122 case 12:
123 return locale()->translate("December", "Dec"); 123 return locale()->translate("December", "Dec");
124 } 124 }
125 else 125 else
126 switch ( month ) 126 switch ( month )
127 { 127 {
128 case 1: 128 case 1:
129 return locale()->translate("January"); 129 return locale()->translate("January");
130 case 2: 130 case 2:
131 return locale()->translate("February"); 131 return locale()->translate("February");
132 case 3: 132 case 3:
133 return locale()->translate("March"); 133 return locale()->translate("March");
134 case 4: 134 case 4:
135 return locale()->translate("April"); 135 return locale()->translate("April");
136 case 5: 136 case 5:
137 return locale()->translate("May long", "May"); 137 return locale()->translate("May long", "May");
138 case 6: 138 case 6:
139 return locale()->translate("June"); 139 return locale()->translate("June");
140 case 7: 140 case 7:
141 return locale()->translate("July"); 141 return locale()->translate("July");
142 case 8: 142 case 8:
143 return locale()->translate("August"); 143 return locale()->translate("August");
144 case 9: 144 case 9:
145 return locale()->translate("September"); 145 return locale()->translate("September");
146 case 10: 146 case 10:
147 return locale()->translate("October"); 147 return locale()->translate("October");
148 case 11: 148 case 11:
149 return locale()->translate("November"); 149 return locale()->translate("November");
150 case 12: 150 case 12:
151 return locale()->translate("December"); 151 return locale()->translate("December");
152 } 152 }
153 153
154 return QString::null; 154 return QString::null;
155} 155}
156 156
157QString KCalendarSystemGregorian::monthNamePossessive(int month, 157QString KCalendarSystemGregorian::monthNamePossessive(int month,
158 bool shortName) const 158 bool shortName) const
159{ 159{
160// kdDebug(5400) << "Gregorian getMonthName" << endl; 160// kdDebug(5400) << "Gregorian getMonthName" << endl;
161 161
162 if ( shortName ) 162 if ( shortName )
163 switch ( month ) 163 switch ( month )
164 { 164 {
165 case 1: 165 case 1:
166 return locale()->translate("of January", "of Jan"); 166 return locale()->translate("of January", "of Jan");
167 case 2: 167 case 2:
168 return locale()->translate("of February", "of Feb"); 168 return locale()->translate("of February", "of Feb");
169 case 3: 169 case 3:
170 return locale()->translate("of March", "of Mar"); 170 return locale()->translate("of March", "of Mar");
171 case 4: 171 case 4:
172 return locale()->translate("of April", "of Apr"); 172 return locale()->translate("of April", "of Apr");
173 case 5: 173 case 5:
174 return locale()->translate("of May short", "of May"); 174 return locale()->translate("of May short", "of May");
175 case 6: 175 case 6:
176 return locale()->translate("of June", "of Jun"); 176 return locale()->translate("of June", "of Jun");
177 case 7: 177 case 7:
178 return locale()->translate("of July", "of Jul"); 178 return locale()->translate("of July", "of Jul");
179 case 8: 179 case 8:
180 return locale()->translate("of August", "of Aug"); 180 return locale()->translate("of August", "of Aug");
181 case 9: 181 case 9:
182 return locale()->translate("of September", "of Sep"); 182 return locale()->translate("of September", "of Sep");
183 case 10: 183 case 10:
184 return locale()->translate("of October", "of Oct"); 184 return locale()->translate("of October", "of Oct");
185 case 11: 185 case 11:
186 return locale()->translate("of November", "of Nov"); 186 return locale()->translate("of November", "of Nov");
187 case 12: 187 case 12:
188 return locale()->translate("of December", "of Dec"); 188 return locale()->translate("of December", "of Dec");
189 } 189 }
190 else 190 else
191 switch ( month ) 191 switch ( month )
192 { 192 {
193 case 1: 193 case 1:
194 return locale()->translate("of January"); 194 return locale()->translate("of January");
195 case 2: 195 case 2:
196 return locale()->translate("of February"); 196 return locale()->translate("of February");
197 case 3: 197 case 3:
198 return locale()->translate("of March"); 198 return locale()->translate("of March");
199 case 4: 199 case 4:
200 return locale()->translate("of April"); 200 return locale()->translate("of April");
201 case 5: 201 case 5:
202 return locale()->translate("of May long", "of May"); 202 return locale()->translate("of May long", "of May");
203 case 6: 203 case 6:
204 return locale()->translate("of June"); 204 return locale()->translate("of June");
205 case 7: 205 case 7:
206 return locale()->translate("of July"); 206 return locale()->translate("of July");
207 case 8: 207 case 8:
208 return locale()->translate("of August"); 208 return locale()->translate("of August");
209 case 9: 209 case 9:
210 return locale()->translate("of September"); 210 return locale()->translate("of September");
211 case 10: 211 case 10:
212 return locale()->translate("of October"); 212 return locale()->translate("of October");
213 case 11: 213 case 11:
214 return locale()->translate("of November"); 214 return locale()->translate("of November");
215 case 12: 215 case 12:
216 return locale()->translate("of December"); 216 return locale()->translate("of December");
217 } 217 }
218 218
219 return QString::null; 219 return QString::null;
220} 220}
221 221
222bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const 222bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const
223{ 223{
224 // We don't want Qt to add 1900 to them 224 // We don't want Qt to add 1900 to them
225 if ( y >= 0 && y <= 99 ) 225 if ( y >= 0 && y <= 99 )
226 return false; 226 return false;
227 227
228 // QDate supports gregorian internally 228 // QDate supports gregorian internally
229 return date.setYMD(y, m, d); 229 return date.setYMD(y, m, d);
230} 230}
231 231
232QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const 232QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const
233{ 233{
234#if QT_VERSION >= 300 234#if QT_VERSION >= 0x030000
235 return date.addYears(nyears); 235 return date.addYears(nyears);
236#else 236#else
237 int year = date.year() + nyears; 237 int year = date.year() + nyears;
238 int month = date.month(); 238 int month = date.month();
239 int day = date.day(); 239 int day = date.day();
240 QDate newDate( year, month, 1 ); 240 QDate newDate( year, month, 1 );
241 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); 241 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth();
242 return QDate( year, month, day ); 242 return QDate( year, month, day );
243#endif 243#endif
244} 244}
245 245
246QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const 246QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const
247{ 247{
248#if QT_VERSION >= 300 248#if QT_VERSION >= 0x030000
249 return date.addMonths(nmonths); 249 return date.addMonths(nmonths);
250#else 250#else
251 int month = date.month(); 251 int month = date.month();
252 int nyears; 252 int nyears;
253 if ( nmonths >= 0 ) { 253 if ( nmonths >= 0 ) {
254 month += nmonths; 254 month += nmonths;
255 nyears = ( month - 1 ) / 12; 255 nyears = ( month - 1 ) / 12;
256 month = ( ( month - 1 ) % 12 ) + 1; 256 month = ( ( month - 1 ) % 12 ) + 1;
257 } else { 257 } else {
258 nyears = nmonths / 12; 258 nyears = nmonths / 12;
259 // nmonths += nyears * 12; 259 // nmonths += nyears * 12;
260 nmonths = nmonths % 12; 260 nmonths = nmonths % 12;
261 month += nmonths; 261 month += nmonths;
262 if ( month <= 0 ) { 262 if ( month <= 0 ) {
263 month += 12; 263 month += 12;
264 --nyears; 264 --nyears;
265 } 265 }
266 } 266 }
267 int year = date.year() + nyears; 267 int year = date.year() + nyears;
268 int day = date.day(); 268 int day = date.day();
269 QDate newDate( year, month, 1 ); 269 QDate newDate( year, month, 1 );
270 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); 270 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth();
271 return QDate( year, month, day ); 271 return QDate( year, month, day );
272#endif 272#endif
273} 273}
274 274
275QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const 275QDate KCalendarSystemGregorian::addDays(const QDate & date, int ndays) const
276{ 276{
277 return date.addDays(ndays); 277 return date.addDays(ndays);
278} 278}
279 279
280QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const 280QString KCalendarSystemGregorian::weekDayName(int col, bool shortName) const
281{ 281{
282 // ### Should this really be different to each calendar system? Or are we 282 // ### Should this really be different to each calendar system? Or are we
283 // only going to support weeks with 7 days? 283 // only going to support weeks with 7 days?
284 284
285 //kdDebug(5400) << "Gregorian wDayName" << endl; 285 //kdDebug(5400) << "Gregorian wDayName" << endl;
286 return locale()->weekDayName(col, shortName); 286 return locale()->weekDayName(col, shortName);
287} 287}
288 288
289QString KCalendarSystemGregorian::weekDayName(const QDate& date, bool shortName) const 289QString KCalendarSystemGregorian::weekDayName(const QDate& date, bool shortName) const
290{ 290{
291 return weekDayName(dayOfWeek(date), shortName); 291 return weekDayName(dayOfWeek(date), shortName);
292} 292}
293 293
294 294
295int KCalendarSystemGregorian::dayOfWeek(const QDate& date) const 295int KCalendarSystemGregorian::dayOfWeek(const QDate& date) const
296{ 296{
297 return date.dayOfWeek(); 297 return date.dayOfWeek();
298} 298}
299 299
300int KCalendarSystemGregorian::dayOfYear(const QDate & date) const 300int KCalendarSystemGregorian::dayOfYear(const QDate & date) const
301{ 301{
302 return date.dayOfYear(); 302 return date.dayOfYear();
303} 303}
304 304
305int KCalendarSystemGregorian::daysInMonth(const QDate& date) const 305int KCalendarSystemGregorian::daysInMonth(const QDate& date) const
306{ 306{
307// kdDebug(5400) << "Gregorian daysInMonth" << endl; 307// kdDebug(5400) << "Gregorian daysInMonth" << endl;
308 return date.daysInMonth(); 308 return date.daysInMonth();
309} 309}
310 310
311int KCalendarSystemGregorian::minValidYear() const 311int KCalendarSystemGregorian::minValidYear() const
312{ 312{
313 return 1753; // QDate limit 313 return 1753; // QDate limit
314} 314}
315 315
316int KCalendarSystemGregorian::maxValidYear() const 316int KCalendarSystemGregorian::maxValidYear() const
317{ 317{
318 return 8000; // QDate limit 318 return 8000; // QDate limit
319} 319}
320 320
321int KCalendarSystemGregorian::day(const QDate& date) const 321int KCalendarSystemGregorian::day(const QDate& date) const
322{ 322{
323 return date.day(); 323 return date.day();
324} 324}
325 325
326int KCalendarSystemGregorian::month(const QDate& date) const 326int KCalendarSystemGregorian::month(const QDate& date) const
327{ 327{
328 return date.month(); 328 return date.month();
329} 329}
330 330
331int KCalendarSystemGregorian::daysInYear(const QDate& date) const 331int KCalendarSystemGregorian::daysInYear(const QDate& date) const
332{ 332{
333 return date.daysInYear(); 333 return date.daysInYear();
334} 334}
335 335
336int KCalendarSystemGregorian::weekDayOfPray() const 336int KCalendarSystemGregorian::weekDayOfPray() const
337{ 337{
338 return 7; // sunday 338 return 7; // sunday
339} 339}
340 340
341QString KCalendarSystemGregorian::calendarName() const 341QString KCalendarSystemGregorian::calendarName() const
342{ 342{
343 return QString::fromLatin1("gregorian"); 343 return QString::fromLatin1("gregorian");
344} 344}
345 345
346bool KCalendarSystemGregorian::isLunar() const 346bool KCalendarSystemGregorian::isLunar() const
347{ 347{
348 return false; 348 return false;
349} 349}
350 350
351bool KCalendarSystemGregorian::isLunisolar() const 351bool KCalendarSystemGregorian::isLunisolar() const
352{ 352{
353 return false; 353 return false;
354} 354}
355 355
356bool KCalendarSystemGregorian::isSolar() const 356bool KCalendarSystemGregorian::isSolar() const
357{ 357{
358 return true; 358 return true;
359} 359}