summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaddressbookview.cpp4
-rw-r--r--kaddressbook/kaddressbookview.h6
-rw-r--r--kaddressbook/views/cardview.cpp31
-rw-r--r--kaddressbook/views/cardview.h7
-rw-r--r--kaddressbook/views/contactlistview.cpp29
-rw-r--r--kaddressbook/views/contactlistview.h4
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp4
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp4
-rw-r--r--korganizer/komonthview.cpp19
-rw-r--r--korganizer/komonthview.h3
-rw-r--r--korganizer/mainwindow.cpp26
-rw-r--r--korganizer/mainwindow.h1
12 files changed, 129 insertions, 9 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp
index 09859c2..86898e2 100644
--- a/kaddressbook/kaddressbookview.cpp
+++ b/kaddressbook/kaddressbookview.cpp
@@ -1,110 +1,110 @@
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 <qapplication.h> 25#include <qapplication.h>
26 26
27#include <kabc/distributionlistdialog.h> 27#include <kabc/distributionlistdialog.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "viewmanager.h" 31#include "viewmanager.h"
32 32
33#endif //KAB_EMBEDDED 33#endif //KAB_EMBEDDED
34#include <qlayout.h> 34#include <qlayout.h>
35 35
36#include <kabc/distributionlistdialog.h> 36#include <kabc/distributionlistdialog.h>
37#include <kabc/addressbook.h> 37#include <kabc/addressbook.h>
38#include <kdebug.h> 38#include <kdebug.h>
39 39
40#include "kaddressbookview.h" 40#include "kaddressbookview.h"
41 41
42KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, 42KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent,
43 const char *name ) 43 const char *name )
44 : QWidget( parent, name ), mAddressBook( ab ), mFieldList() 44 : QWidget( parent, name ), mAddressBook( ab ), mFieldList()
45{ 45{
46 46
47 initGUI(); 47 initGUI();
48} 48}
49 49
50KAddressBookView::~KAddressBookView() 50KAddressBookView::~KAddressBookView()
51{ 51{
52 52
53} 53}
54 54
55QRegExp KAddressBookView::getRegExp( const QString s ) 55QRegExp KAddressBookView::getRegExp( const QString s )
56{ 56{
57 QRegExp re; 57 QRegExp re;
58 58
59 if ( s.length() == 3 && s.mid(1,1) == "-" ) { 59 if ( s.length() == 3 && s.mid(1,1) == "-" ) {
60 QString pattern = "^[" + s.lower() +"]"; 60 QString pattern = "^[" + s.lower() +"]";
61 re.setCaseSensitive(false); 61 re.setCaseSensitive(false);
62 re.setPattern( pattern ); 62 re.setPattern( pattern );
63 } else { 63 } else {
64 QString pattern = s.lower()+"*"; 64 QString pattern = s.lower()+"*";
65 re.setWildcard(true); // most people understand these better. 65 re.setWildcard(true); // most people understand these better.
66 re.setCaseSensitive(false); 66 re.setCaseSensitive(false);
67 re.setPattern( pattern ); 67 re.setPattern( pattern );
68 } 68 }
69 return re; 69 return re;
70} 70}
71 71
72void KAddressBookView::readConfig( KConfig *config ) 72void KAddressBookView::readConfig( KConfig *config )
73{ 73{
74 mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); 74 mFieldList = KABC::Field::restoreFields( config, "KABCFields" );
75 75
76 if ( mFieldList.isEmpty() ) 76 if ( mFieldList.isEmpty() )
77 mFieldList = KABC::Field::defaultFields(); 77 mFieldList = KABC::Field::defaultFields();
78 78
79 mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); 79 mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 );
80 mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); 80 mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null );
81} 81}
82 82
83void KAddressBookView::writeConfig( KConfig* ) 83void KAddressBookView::writeConfig( KConfig* )
84{ 84{
85 // Most of writing the config is handled by the ConfigureViewDialog 85 // Most of writing the config is handled by the ConfigureViewDialog
86} 86}
87 87
88QString KAddressBookView::selectedEmails() 88QString KAddressBookView::selectedEmails()
89{ 89{
90 bool first = true; 90 bool first = true;
91 QString emailAddrs; 91 QString emailAddrs;
92 QStringList uidList = selectedUids(); 92 QStringList uidList = selectedUids();
93 KABC::Addressee addr; 93 KABC::Addressee addr;
94 QString email; 94 QString email;
95 95
96 QStringList::Iterator it; 96 QStringList::Iterator it;
97 for ( it = uidList.begin(); it != uidList.end(); ++it ) { 97 for ( it = uidList.begin(); it != uidList.end(); ++it ) {
98 addr = mAddressBook->findByUid( *it ); 98 addr = mAddressBook->findByUid( *it );
99 99
100 if ( !addr.isEmpty() ) { 100 if ( !addr.isEmpty() ) {
101 QString m = QString::null; 101 QString m = QString::null;
102 102
103 if ( addr.emails().count() > 1 ) 103 if ( addr.emails().count() > 1 )
104 m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); 104 m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this );
105 105
106 email = addr.fullEmail( m ); 106 email = addr.fullEmail( m );
107 107
108 if ( !first ) 108 if ( !first )
109 emailAddrs += ", "; 109 emailAddrs += ", ";
110 else 110 else
@@ -120,67 +120,69 @@ QString KAddressBookView::selectedEmails()
120KABC::Addressee::List KAddressBookView::addressees() 120KABC::Addressee::List KAddressBookView::addressees()
121{ 121{
122 KABC::Addressee::List addresseeList; 122 KABC::Addressee::List addresseeList;
123 123
124 KABC::AddressBook::Iterator it; 124 KABC::AddressBook::Iterator it;
125 for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 125 for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
126 if ( mFilter.filterAddressee( *it ) ) 126 if ( mFilter.filterAddressee( *it ) )
127 addresseeList.append( *it ); 127 addresseeList.append( *it );
128 } 128 }
129 129
130 return addresseeList; 130 return addresseeList;
131} 131}
132 132
133void KAddressBookView::initGUI() 133void KAddressBookView::initGUI()
134{ 134{
135 // Create the layout 135 // Create the layout
136 QVBoxLayout *layout = new QVBoxLayout( this ); 136 QVBoxLayout *layout = new QVBoxLayout( this );
137 137
138 // Add the view widget 138 // Add the view widget
139 mViewWidget = new QWidget( this ); 139 mViewWidget = new QWidget( this );
140 layout->addWidget( mViewWidget ); 140 layout->addWidget( mViewWidget );
141} 141}
142 142
143KABC::Field::List KAddressBookView::fields() const 143KABC::Field::List KAddressBookView::fields() const
144{ 144{
145 return mFieldList; 145 return mFieldList;
146} 146}
147KABC::Field::List KAddressBookView::allFields() const 147KABC::Field::List KAddressBookView::allFields() const
148{ 148{
149 return KABC::Field::allFields(); 149 return KABC::Field::allFields();
150} 150}
151 151
152void KAddressBookView::setFilter( const Filter &filter ) 152void KAddressBookView::setFilter( const Filter &filter )
153{ 153{
154 mFilter = filter; 154 mFilter = filter;
155} 155}
156 156
157KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const 157KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const
158{ 158{
159 return mDefaultFilterType; 159 return mDefaultFilterType;
160} 160}
161 161
162const QString &KAddressBookView::defaultFilterName() const 162const QString &KAddressBookView::defaultFilterName() const
163{ 163{
164 return mDefaultFilterName; 164 return mDefaultFilterName;
165} 165}
166 166
167KABC::AddressBook *KAddressBookView::addressBook() const 167KABC::AddressBook *KAddressBookView::addressBook() const
168{ 168{
169 return mAddressBook; 169 return mAddressBook;
170} 170}
171 171
172QWidget *KAddressBookView::viewWidget() 172QWidget *KAddressBookView::viewWidget()
173{ 173{
174 return mViewWidget; 174 return mViewWidget;
175} 175}
176 176
177ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, 177ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab,
178 QWidget *parent, 178 QWidget *parent,
179 const char *name ) 179 const char *name )
180{ 180{
181 return new ViewConfigureWidget( ab, parent, name ); 181 return new ViewConfigureWidget( ab, parent, name );
182} 182}
183 183
184
185
184#ifndef KAB_EMBEDDED 186#ifndef KAB_EMBEDDED
185#include "kaddressbookview.moc" 187#include "kaddressbookview.moc"
186#endif //KAB_EMBEDDED 188#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index 6bbb9c2..3a3f71a 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -169,144 +169,146 @@ class KAddressBookView : public QWidget
169 */ 169 */
170 virtual void refresh( QString uid = QString::null ) = 0; 170 virtual void refresh( QString uid = QString::null ) = 0;
171 171
172 /** 172 /**
173 This method must be overloaded in subclasses. Select (highlight) 173 This method must be overloaded in subclasses. Select (highlight)
174 the addressee matching <i>uid</i>. If uid 174 the addressee matching <i>uid</i>. If uid
175 is equal to QString::null, then all addressees should be selected. 175 is equal to QString::null, then all addressees should be selected.
176 */ 176 */
177#ifndef KAB_EMBEDDED 177#ifndef KAB_EMBEDDED
178//MOC_SKIP_BEGIN 178//MOC_SKIP_BEGIN
179 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; 179 virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0;
180//MOC_SKIP_END 180//MOC_SKIP_END
181#else //KAB_EMBEDDED 181#else //KAB_EMBEDDED
182 //US my moc can not handle the default parameters. Is this a problem ??? 182 //US my moc can not handle the default parameters. Is this a problem ???
183 virtual void setSelected( QString uid, bool selected) = 0; 183 virtual void setSelected( QString uid, bool selected) = 0;
184#endif //KAB_EMBEDDED 184#endif //KAB_EMBEDDED
185 185
186 signals: 186 signals:
187 187
188 void printView(); 188 void printView();
189 /** 189 /**
190 This signal should be emitted by a subclass whenever an addressee 190 This signal should be emitted by a subclass whenever an addressee
191 is modified. 191 is modified.
192 */ 192 */
193 void modified(); 193 void modified();
194 194
195 /** 195 /**
196 This signal should be emitted by a subclass whenever an addressee 196 This signal should be emitted by a subclass whenever an addressee
197 is selected. Selected means that the addressee was given the focus. 197 is selected. Selected means that the addressee was given the focus.
198 Some widgets may call this 'highlighted'. The view is responsible for 198 Some widgets may call this 'highlighted'. The view is responsible for
199 emitting this signal multiple times if multiple items are selected, 199 emitting this signal multiple times if multiple items are selected,
200 with the last item selected being the last emit. 200 with the last item selected being the last emit.
201 201
202 @param uid The uid of the selected addressee. 202 @param uid The uid of the selected addressee.
203 203
204 @see KListView 204 @see KListView
205 */ 205 */
206 void selected( const QString &uid ); 206 void selected( const QString &uid );
207 void deleteRequest(); 207 void deleteRequest();
208 /** 208 /**
209 This signal should be emitted by a subclass whenever an addressee 209 This signal should be emitted by a subclass whenever an addressee
210 is executed. This is defined by the KDE system wide config, but it 210 is executed. This is defined by the KDE system wide config, but it
211 either means single or doubleclicked. 211 either means single or doubleclicked.
212 212
213 @param ui The uid of the selected addressee 213 @param ui The uid of the selected addressee
214 214
215 @see KListView 215 @see KListView
216 */ 216 */
217 void executed( const QString &uid ); 217 void executed( const QString &uid );
218 218
219 /** 219 /**
220 This signal is emitted whenever a user attempts to start a drag 220 This signal is emitted whenever a user attempts to start a drag
221 in the view. The slot connected to this signal would usually want 221 in the view. The slot connected to this signal would usually want
222 to create a QDragObject. 222 to create a QDragObject.
223 */ 223 */
224 void startDrag(); 224 void startDrag();
225 225
226 /** 226 /**
227 This signal is emitted whenever the user drops something on the 227 This signal is emitted whenever the user drops something on the
228 view. The individual view should handle checking if the item is 228 view. The individual view should handle checking if the item is
229 droppable (ie: if it is a vcard). 229 droppable (ie: if it is a vcard).
230 */ 230 */
231 void dropped( QDropEvent* ); 231 void dropped( QDropEvent* );
232 232
233 protected: 233 protected:
234
234 /** 235 /**
235 Returns a list of the addressees that should be displayed. This method 236 Returns a list of the addressees that should be displayed. This method
236 should always be used by the subclass to get a list of addressees. This 237 should always be used by the subclass to get a list of addressees. This
237 method internally takes many factors into account, including the current 238 method internally takes many factors into account, including the current
238 filter. 239 filter.
239 */ 240 */
240 KABC::Addressee::List addressees(); 241 KABC::Addressee::List addressees();
241 242
242 /** 243 /**
243 This method returns the widget that should be used as the parent for 244 This method returns the widget that should be used as the parent for
244 all view components. By using this widget as the parent and not 245 all view components. By using this widget as the parent and not
245 'this', the view subclass has the option of placing other widgets 246 'this', the view subclass has the option of placing other widgets
246 around the view (ie: search fields, etc). Do not delete this widget! 247 around the view (ie: search fields, etc). Do not delete this widget!
247 */ 248 */
248 QWidget *viewWidget(); 249 QWidget *viewWidget();
249 QRegExp getRegExp( const QString ); 250 QRegExp getRegExp( const QString );
250 251
251 private: 252 private:
252 void initGUI(); 253 void initGUI();
253 254
254 DefaultFilterType mDefaultFilterType; 255 DefaultFilterType mDefaultFilterType;
255 Filter mFilter; 256 Filter mFilter;
256 QString mDefaultFilterName; 257 QString mDefaultFilterName;
257 KABC::AddressBook *mAddressBook; 258 KABC::AddressBook *mAddressBook;
258 KABC::Field::List mFieldList; 259 KABC::Field::List mFieldList;
259 260
260 QWidget *mViewWidget; 261 QWidget *mViewWidget;
261}; 262};
262 263
263#ifndef KAB_EMBEDDED 264#ifndef KAB_EMBEDDED
264//MOC_SKIP_BEGIN 265//MOC_SKIP_BEGIN
265class ViewFactory : public KLibFactory 266class ViewFactory : public KLibFactory
266//MOC_SKIP_END 267//MOC_SKIP_END
267#else //KAB_EMBEDDED 268#else //KAB_EMBEDDED
268class ViewFactory 269class ViewFactory
269#endif //KAB_EMBEDDED 270#endif //KAB_EMBEDDED
270{ 271{
271 272
272 public: 273 public:
273 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, 274 virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent,
274 const char *name = 0 ) = 0; 275 const char *name = 0 ) = 0;
275 276
276 /** 277 /**
277 @return The type of the view. This is normally a small one word 278 @return The type of the view. This is normally a small one word
278 string (ie: Table, Icon, Tree, etc). 279 string (ie: Table, Icon, Tree, etc).
279 */ 280 */
280 virtual QString type() const = 0; 281 virtual QString type() const = 0;
281 282
282 /** 283 /**
283 @return The description of the view. This should be a 3 to 284 @return The description of the view. This should be a 3 to
284 4 line string (don't actually use return characters in the string) 285 4 line string (don't actually use return characters in the string)
285 describing the features offered by the view. 286 describing the features offered by the view.
286 */ 287 */
287 virtual QString description() const = 0; 288 virtual QString description() const = 0;
288 289
289 /** 290 /**
290 Creates a config dialog for the view type. The default 291 Creates a config dialog for the view type. The default
291 implementation will return a ViewConfigDialog. This default 292 implementation will return a ViewConfigDialog. This default
292 dialog will allow the user to set the visible fields only. If 293 dialog will allow the user to set the visible fields only. If
293 you need more config options (as most views will), this method 294 you need more config options (as most views will), this method
294 can be overloaded to return your sublcass of ViewConfigDialog. 295 can be overloaded to return your sublcass of ViewConfigDialog.
295 If this method is over loaded the base classes method should 296 If this method is over loaded the base classes method should
296 <B>not</B> be called. 297 <B>not</B> be called.
297 */ 298 */
298 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, 299 virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab,
299 QWidget *parent, 300 QWidget *parent,
300 const char *name = 0 ); 301 const char *name = 0 );
301 302
302 protected: 303 protected:
303 virtual QObject* createObject( QObject*, const char*, const char*, 304 virtual QObject* createObject( QObject*, const char*, const char*,
304 const QStringList & ) 305 const QStringList & )
305 { 306 {
306 return 0; 307 return 0;
307 } 308 }
309
308 310
309}; 311};
310 312
311 313
312#endif 314#endif
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index 03df444..84d3116 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -1,99 +1,100 @@
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//BEGIN Includes 24//BEGIN Includes
25#include "cardview.h" 25#include "cardview.h"
26 26
27#include <limits.h> 27#include <limits.h>
28 28
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qstyle.h> 33#include <qstyle.h>
34#include <qcursor.h> 34#include <qcursor.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qapplication.h>
36 37
37#include "kabprefs.h" 38#include "kabprefs.h"
38#include <kdebug.h> 39#include <kdebug.h>
39#include <kglobalsettings.h> 40#include <kglobalsettings.h>
40//END includes 41//END includes
41 42
42#define MIN_ITEM_WIDTH 80 43#define MIN_ITEM_WIDTH 80
43 44
44//BEGIN Helpers 45//BEGIN Helpers
45////////////////////////////////////// 46//////////////////////////////////////
46// CardViewTip 47// CardViewTip
47class CardViewTip : public QLabel { 48class CardViewTip : public QLabel {
48 public: 49 public:
49 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) 50 CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name )
50 { 51 {
51 setPalette( QToolTip::palette() ); 52 setPalette( QToolTip::palette() );
52 setFrameStyle( Panel|Plain ); 53 setFrameStyle( Panel|Plain );
53 setMidLineWidth(0); 54 setMidLineWidth(0);
54 setIndent(1); 55 setIndent(1);
55 } 56 }
56 57
57 ~CardViewTip() {}; 58 ~CardViewTip() {};
58 protected: 59 protected:
59 void leaveEvent( QEvent * ) 60 void leaveEvent( QEvent * )
60 { 61 {
61 hide(); 62 hide();
62 } 63 }
63}; 64};
64 65
65////////////////////////////////////// 66//////////////////////////////////////
66// CardViewItemList 67// CardViewItemList
67 68
68 69
69// 70//
70// Warning: make sure you use findRef() instead of find() to find an 71// Warning: make sure you use findRef() instead of find() to find an
71// item! Only the pointer value is unique in the list. 72// item! Only the pointer value is unique in the list.
72// 73//
73class CardViewItemList : public QPtrList<CardViewItem> 74class CardViewItemList : public QPtrList<CardViewItem>
74{ 75{
75 protected: 76 protected:
76 virtual int compareItems(QPtrCollection::Item item1, 77 virtual int compareItems(QPtrCollection::Item item1,
77 QPtrCollection::Item item2) 78 QPtrCollection::Item item2)
78 { 79 {
79 CardViewItem *cItem1 = (CardViewItem*)item1; 80 CardViewItem *cItem1 = (CardViewItem*)item1;
80 CardViewItem *cItem2 = (CardViewItem*)item2; 81 CardViewItem *cItem2 = (CardViewItem*)item2;
81 82
82 if ( cItem1 == cItem2 ) 83 if ( cItem1 == cItem2 )
83 return 0; 84 return 0;
84 85
85 if ((cItem1 == 0) || (cItem2 == 0)) 86 if ((cItem1 == 0) || (cItem2 == 0))
86 return cItem1 ? -1 : 1; 87 return cItem1 ? -1 : 1;
87 88
88 if (cItem1->caption() < cItem2->caption()) 89 if (cItem1->caption() < cItem2->caption())
89 return -1; 90 return -1;
90 91
91 else if (cItem1->caption() > cItem2->caption()) 92 else if (cItem1->caption() > cItem2->caption())
92 return 1; 93 return 1;
93 94
94 return 0; 95 return 0;
95 } 96 }
96 97
97 private: 98 private:
98 /*int find( const CardViewItem * ) 99 /*int find( const CardViewItem * )
99 { 100 {
@@ -578,128 +579,130 @@ void CardViewItem::showFullString( const QPoint &itempos, CardViewTip *tip )
578 int colonWidth = mView->d->mFm->width(":"); 579 int colonWidth = mView->d->mFm->width(":");
579 lw = drawLabels ? // label width 580 lw = drawLabels ? // label width
580 QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) : 581 QMIN( w/2 - 4 - mrg, d->maxLabelWidth + colonWidth + 4 ) :
581 0; 582 0;
582 int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string 583 int mw = isLabel ? lw - colonWidth : w - lw - (mrg*2); // max width for string
583 if ( isLabel ) 584 if ( isLabel )
584 { 585 {
585 trimmed = mView->d->mFm->width( s ) > mw - colonWidth; 586 trimmed = mView->d->mFm->width( s ) > mw - colonWidth;
586 } else { 587 } else {
587 QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) ); 588 QRect r( mView->d->mFm->boundingRect( 0, 0, INT_MAX, INT_MAX, Qt::AlignTop|Qt::AlignLeft, s ) );
588 trimmed = r.width() > mw || r.height()/fh > QMIN(s.contains('\n') + 1, maxLines); 589 trimmed = r.width() > mw || r.height()/fh > QMIN(s.contains('\n') + 1, maxLines);
589 } 590 }
590 } 591 }
591 if ( trimmed ) 592 if ( trimmed )
592 { 593 {
593 tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header 594 tip->setFont( (isLabel && !lw) ? mView->headerFont() : mView->font() ); // if condition is true, a header
594 tip->setText( s ); 595 tip->setText( s );
595 tip->adjustSize(); 596 tip->adjustSize();
596 // find a proper position 597 // find a proper position
597 int lx; 598 int lx;
598 lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/; 599 lx = isLabel || !drawLabels ? mrg : lw + mrg + 2 /*-1*/;
599 QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) )); 600 QPoint pnt(mView->contentsToViewport( QPoint(d->x, d->y) ));
600 pnt += QPoint(lx, y); 601 pnt += QPoint(lx, y);
601 if ( pnt.x() < 0 ) 602 if ( pnt.x() < 0 )
602 pnt.setX( 0 ); 603 pnt.setX( 0 );
603 if ( pnt.x() + tip->width() > mView->visibleWidth() ) 604 if ( pnt.x() + tip->width() > mView->visibleWidth() )
604 pnt.setX( mView->visibleWidth() - tip->width() ); 605 pnt.setX( mView->visibleWidth() - tip->width() );
605 if ( pnt.y() + tip->height() > mView->visibleHeight() ) 606 if ( pnt.y() + tip->height() > mView->visibleHeight() )
606 pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) ); 607 pnt.setY( QMAX( 0, mView->visibleHeight() - tip->height() ) );
607 // show 608 // show
608 tip->move( pnt ); 609 tip->move( pnt );
609 tip->show(); 610 tip->show();
610 } 611 }
611} 612}
612 613
613CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const 614CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const
614{ 615{
615 int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin; 616 int ypos = mView->d->mBFm->height() + 7 + mView->d->mItemMargin;
616 int iy = itempos.y(); 617 int iy = itempos.y();
617 // skip below caption 618 // skip below caption
618 if ( iy <= ypos ) 619 if ( iy <= ypos )
619 return 0; 620 return 0;
620 // try find a field 621 // try find a field
621 bool showEmpty = mView->showEmptyFields(); 622 bool showEmpty = mView->showEmptyFields();
622 int fh = mView->d->mFm->height(); 623 int fh = mView->d->mFm->height();
623 int maxLines = mView->maxFieldLines(); 624 int maxLines = mView->maxFieldLines();
624 Field *f; 625 Field *f;
625 for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() ) 626 for ( f = d->mFieldList.first(); f; f = d->mFieldList.next() )
626 { 627 {
627 if ( showEmpty || !f->second.isEmpty() ) 628 if ( showEmpty || !f->second.isEmpty() )
628 ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2; 629 ypos += ( QMIN( f->second.contains('\n')+1, maxLines ) *fh)+2;
629 if ( iy <= ypos ) 630 if ( iy <= ypos )
630 break; 631 break;
631 } 632 }
632 return f ? f : 0; 633 return f ? f : 0;
633} 634}
634//END CardViewItem 635//END CardViewItem
635 636
636//BEGIN CardView 637//BEGIN CardView
637 638
638CardView::CardView(QWidget *parent, const char *name) 639CardView::CardView(QWidget *parent, const char *name)
639 : QScrollView(parent, name), 640 : QScrollView(parent, name),
640 d(new CardViewPrivate()) 641 d(new CardViewPrivate())
641{ 642{
643 mFlagKeyPressed = false;
644 mFlagBlockKeyPressed = false;
642 d->mItemList.setAutoDelete(true); 645 d->mItemList.setAutoDelete(true);
643 d->mSeparatorList.setAutoDelete(true); 646 d->mSeparatorList.setAutoDelete(true);
644 647
645 QFont f = font(); 648 QFont f = font();
646 d->mFm = new QFontMetrics(f); 649 d->mFm = new QFontMetrics(f);
647 f.setBold(true); 650 f.setBold(true);
648 d->mHeaderFont = f; 651 d->mHeaderFont = f;
649 d->mBFm = new QFontMetrics(f); 652 d->mBFm = new QFontMetrics(f);
650 d->mTip = ( new CardViewTip( viewport() ) ), 653 d->mTip = ( new CardViewTip( viewport() ) ),
651 d->mTip->hide(); 654 d->mTip->hide();
652 d->mTimer = ( new QTimer(this, "mouseTimer") ), 655 d->mTimer = ( new QTimer(this, "mouseTimer") ),
653 656
654 viewport()->setMouseTracking( true ); 657 viewport()->setMouseTracking( true );
655 viewport()->setFocusProxy(this); 658 viewport()->setFocusProxy(this);
656 viewport()->setFocusPolicy(WheelFocus); 659 viewport()->setFocusPolicy(WheelFocus);
657 viewport()->setBackgroundMode(PaletteBase); 660 viewport()->setBackgroundMode(PaletteBase);
658 661
659 connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); 662 connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) );
660 663
661//US setBackgroundMode(PaletteBackground, PaletteBase); 664//US setBackgroundMode(PaletteBackground, PaletteBase);
662 setBackgroundMode(PaletteBackground); 665 setBackgroundMode(PaletteBackground);
663 666
664 // no reason for a vertical scrollbar 667 // no reason for a vertical scrollbar
665 setVScrollBarMode(AlwaysOff); 668 setVScrollBarMode(AlwaysOff);
666} 669}
667 670
668CardView::~CardView() 671CardView::~CardView()
669{ 672{
670 delete d->mFm; 673 delete d->mFm;
671 delete d->mBFm; 674 delete d->mBFm;
672 delete d; 675 delete d;
673 d = 0; 676 d = 0;
674} 677}
675 678
676void CardView::insertItem(CardViewItem *item) 679void CardView::insertItem(CardViewItem *item)
677{ 680{
678 d->mItemList.inSort(item); 681 d->mItemList.inSort(item);
679 setLayoutDirty(true); 682 setLayoutDirty(true);
680} 683}
681 684
682void CardView::takeItem(CardViewItem *item) 685void CardView::takeItem(CardViewItem *item)
683{ 686{
684 if ( d->mCurrentItem == item ) 687 if ( d->mCurrentItem == item )
685 d->mCurrentItem = item->nextItem(); 688 d->mCurrentItem = item->nextItem();
686 d->mItemList.take(d->mItemList.findRef(item)); 689 d->mItemList.take(d->mItemList.findRef(item));
687 690
688 setLayoutDirty(true); 691 setLayoutDirty(true);
689} 692}
690 693
691void CardView::clear() 694void CardView::clear()
692{ 695{
693 d->mItemList.clear(); 696 d->mItemList.clear();
694 697
695 setLayoutDirty(true); 698 setLayoutDirty(true);
696} 699}
697 700
698CardViewItem *CardView::currentItem() 701CardViewItem *CardView::currentItem()
699{ 702{
700 if ( ! d->mCurrentItem && d->mItemList.count() ) 703 if ( ! d->mCurrentItem && d->mItemList.count() )
701 d->mCurrentItem = d->mItemList.first(); 704 d->mCurrentItem = d->mItemList.first();
702 return d->mCurrentItem; 705 return d->mCurrentItem;
703} 706}
704 707
705void CardView::setCurrentItem( CardViewItem *item ) 708void CardView::setCurrentItem( CardViewItem *item )
@@ -1290,129 +1293,137 @@ void CardView::contentsMouseMoveEvent( QMouseEvent *e )
1290 } 1293 }
1291 1294
1292 d->mTimer->start( 500 ); 1295 d->mTimer->start( 500 );
1293 1296
1294 // see if we are over a separator 1297 // see if we are over a separator
1295 // only if we actually have them painted? 1298 // only if we actually have them painted?
1296 if ( d->mDrawSeparators ) 1299 if ( d->mDrawSeparators )
1297 { 1300 {
1298 int colcontentw = d->mItemWidth + (2*d->mItemSpacing); 1301 int colcontentw = d->mItemWidth + (2*d->mItemSpacing);
1299 int colw = colcontentw + d->mSepWidth; 1302 int colw = colcontentw + d->mSepWidth;
1300 int m = e->x()%colw; 1303 int m = e->x()%colw;
1301 if ( m >= colcontentw && m > 0 ) 1304 if ( m >= colcontentw && m > 0 )
1302 { 1305 {
1303 setCursor( SplitVCursor ); // Why does this fail sometimes? 1306 setCursor( SplitVCursor ); // Why does this fail sometimes?
1304 d->mOnSeparator = true; 1307 d->mOnSeparator = true;
1305 } 1308 }
1306 else 1309 else
1307 { 1310 {
1308 setCursor( ArrowCursor ); 1311 setCursor( ArrowCursor );
1309 d->mOnSeparator = false; 1312 d->mOnSeparator = false;
1310 } 1313 }
1311 } 1314 }
1312} 1315}
1313 1316
1314void CardView::enterEvent( QEvent * ) 1317void CardView::enterEvent( QEvent * )
1315{ 1318{
1316 d->mTimer->start( 500 ); 1319 d->mTimer->start( 500 );
1317} 1320}
1318 1321
1319void CardView::leaveEvent( QEvent * ) 1322void CardView::leaveEvent( QEvent * )
1320{ 1323{
1321 d->mTimer->stop(); 1324 d->mTimer->stop();
1322 if (d->mOnSeparator) 1325 if (d->mOnSeparator)
1323 { 1326 {
1324 d->mOnSeparator = false; 1327 d->mOnSeparator = false;
1325 setCursor( ArrowCursor ); 1328 setCursor( ArrowCursor );
1326 } 1329 }
1327} 1330}
1328 1331
1329void CardView::focusInEvent( QFocusEvent * ) 1332void CardView::focusInEvent( QFocusEvent * )
1330{ 1333{
1331 if (!d->mCurrentItem && d->mItemList.count() ) 1334 if (!d->mCurrentItem && d->mItemList.count() )
1332 { 1335 {
1333 setCurrentItem( d->mItemList.first() ); 1336 setCurrentItem( d->mItemList.first() );
1334 } 1337 }
1335 else if ( d->mCurrentItem ) 1338 else if ( d->mCurrentItem )
1336 { 1339 {
1337 d->mCurrentItem->repaintCard(); 1340 d->mCurrentItem->repaintCard();
1338 } 1341 }
1339} 1342}
1340 1343
1341void CardView::focusOutEvent( QFocusEvent * ) 1344void CardView::focusOutEvent( QFocusEvent * )
1342{ 1345{
1343 if (d->mCurrentItem) 1346 if (d->mCurrentItem)
1344 d->mCurrentItem->repaintCard(); 1347 d->mCurrentItem->repaintCard();
1345} 1348}
1346 1349
1347void CardView::keyPressEvent( QKeyEvent *e ) 1350void CardView::keyPressEvent( QKeyEvent *e )
1348{ 1351{
1349 if ( ! ( childCount() && d->mCurrentItem ) ) 1352 if ( ! ( childCount() && d->mCurrentItem ) )
1350 { 1353 {
1351 e->ignore(); 1354 e->ignore();
1352 return; 1355 return;
1353 } 1356 }
1354 1357 if ( mFlagBlockKeyPressed )
1358 return;
1359 qApp->processEvents();
1360 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1361 e->accept();
1362 return;
1363 }
1364 if (! e->isAutoRepeat() )
1365 mFlagKeyPressed = true;
1355 uint pos = d->mItemList.findRef( d->mCurrentItem ); 1366 uint pos = d->mItemList.findRef( d->mCurrentItem );
1356 CardViewItem *aItem = 0L; // item that gets the focus 1367 CardViewItem *aItem = 0L; // item that gets the focus
1357 CardViewItem *old = d->mCurrentItem; 1368 CardViewItem *old = d->mCurrentItem;
1358 1369
1359 switch ( e->key() ) 1370 switch ( e->key() )
1360 { 1371 {
1361 case Key_Up: 1372 case Key_Up:
1362 if ( pos > 0 ) 1373 if ( pos > 0 )
1363 { 1374 {
1364 aItem = d->mItemList.at( pos - 1 ); 1375 aItem = d->mItemList.at( pos - 1 );
1365 setCurrentItem( aItem ); 1376 setCurrentItem( aItem );
1366 } 1377 }
1367 break; 1378 break;
1368 case Key_Down: 1379 case Key_Down:
1369 if ( pos < d->mItemList.count() - 1 ) 1380 if ( pos < d->mItemList.count() - 1 )
1370 { 1381 {
1371 aItem = d->mItemList.at( pos + 1 ); 1382 aItem = d->mItemList.at( pos + 1 );
1372 setCurrentItem( aItem ); 1383 setCurrentItem( aItem );
1373 } 1384 }
1374 break; 1385 break;
1375 case Key_Left: 1386 case Key_Left:
1376 { 1387 {
1377 // look for an item in the previous/next column, starting from 1388 // look for an item in the previous/next column, starting from
1378 // the vertical middle of the current item. 1389 // the vertical middle of the current item.
1379 // FIXME use nice calculatd measures!!! 1390 // FIXME use nice calculatd measures!!!
1380 QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y ); 1391 QPoint aPoint( d->mCurrentItem->d->x, d->mCurrentItem->d->y );
1381 aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) ); 1392 aPoint -= QPoint( 30,-(d->mCurrentItem->height()/2) );
1382 aItem = itemAt( aPoint ); 1393 aItem = itemAt( aPoint );
1383 // maybe we hit some space below an item 1394 // maybe we hit some space below an item
1384 while ( !aItem && aPoint.y() > 27 ) 1395 while ( !aItem && aPoint.y() > 27 )
1385 { 1396 {
1386 aPoint -= QPoint( 0, 16 ); 1397 aPoint -= QPoint( 0, 16 );
1387 aItem = itemAt( aPoint ); 1398 aItem = itemAt( aPoint );
1388 } 1399 }
1389 if ( aItem ) 1400 if ( aItem )
1390 setCurrentItem( aItem ); 1401 setCurrentItem( aItem );
1391 } 1402 }
1392 break; 1403 break;
1393 case Key_Right: 1404 case Key_Right:
1394 { 1405 {
1395 // FIXME use nice calculated measures!!! 1406 // FIXME use nice calculated measures!!!
1396 QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y ); 1407 QPoint aPoint( d->mCurrentItem->d->x + d->mItemWidth, d->mCurrentItem->d->y );
1397 aPoint += QPoint( 30,(d->mCurrentItem->height()/2) ); 1408 aPoint += QPoint( 30,(d->mCurrentItem->height()/2) );
1398 aItem = itemAt( aPoint ); 1409 aItem = itemAt( aPoint );
1399 while ( !aItem && aPoint.y() > 27 ) 1410 while ( !aItem && aPoint.y() > 27 )
1400 { 1411 {
1401 aPoint -= QPoint( 0, 16 ); 1412 aPoint -= QPoint( 0, 16 );
1402 aItem = itemAt( aPoint ); 1413 aItem = itemAt( aPoint );
1403 } 1414 }
1404 if ( aItem ) 1415 if ( aItem )
1405 setCurrentItem( aItem ); 1416 setCurrentItem( aItem );
1406 } 1417 }
1407 break; 1418 break;
1408 case Key_Home: 1419 case Key_Home:
1409 aItem = d->mItemList.first(); 1420 aItem = d->mItemList.first();
1410 setCurrentItem( aItem ); 1421 setCurrentItem( aItem );
1411 break; 1422 break;
1412 case Key_End: 1423 case Key_End:
1413 aItem = d->mItemList.last(); 1424 aItem = d->mItemList.last();
1414 setCurrentItem( aItem ); 1425 setCurrentItem( aItem );
1415 break; 1426 break;
1416 case Key_Prior: // PageUp 1427 case Key_Prior: // PageUp
1417 { 1428 {
1418 // QListView: "Make the item above the top visible and current" 1429 // QListView: "Make the item above the top visible and current"
@@ -1654,69 +1665,87 @@ void CardView::drawRubberBands( int pos )
1654 1665
1655 1666
1656int CardView::itemWidth() const 1667int CardView::itemWidth() const
1657{ 1668{
1658 return d->mItemWidth; 1669 return d->mItemWidth;
1659} 1670}
1660 1671
1661void CardView::setItemWidth( int w ) 1672void CardView::setItemWidth( int w )
1662{ 1673{
1663 if ( w == d->mItemWidth ) 1674 if ( w == d->mItemWidth )
1664 return; 1675 return;
1665 if ( w < MIN_ITEM_WIDTH ) 1676 if ( w < MIN_ITEM_WIDTH )
1666 w = MIN_ITEM_WIDTH; 1677 w = MIN_ITEM_WIDTH;
1667 d->mItemWidth = w; 1678 d->mItemWidth = w;
1668 setLayoutDirty( true ); 1679 setLayoutDirty( true );
1669#ifndef KAB_EMBEDDED 1680#ifndef KAB_EMBEDDED
1670 updateContents(); 1681 updateContents();
1671#else //KAB_EMBEDDED 1682#else //KAB_EMBEDDED
1672//US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() ); 1683//US updateContents( d->contentsX(), d->contentsY(), visibleWidth(), visibleHeight() );
1673qDebug("CardView::setItemWidth has to be verified"); 1684qDebug("CardView::setItemWidth has to be verified");
1674 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); 1685 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() );
1675#endif //KAB_EMBEDDED 1686#endif //KAB_EMBEDDED
1676} 1687}
1677 1688
1678void CardView::setHeaderFont( const QFont &fnt ) 1689void CardView::setHeaderFont( const QFont &fnt )
1679{ 1690{
1680 d->mHeaderFont = fnt; 1691 d->mHeaderFont = fnt;
1681 delete d->mBFm; 1692 delete d->mBFm;
1682 d->mBFm = new QFontMetrics( fnt ); 1693 d->mBFm = new QFontMetrics( fnt );
1683} 1694}
1684 1695
1685QFont CardView::headerFont() const 1696QFont CardView::headerFont() const
1686{ 1697{
1687 return d->mHeaderFont; 1698 return d->mHeaderFont;
1688} 1699}
1689 1700
1690void CardView::setFont( const QFont &fnt ) 1701void CardView::setFont( const QFont &fnt )
1691{ 1702{
1692 QScrollView::setFont( fnt ); 1703 QScrollView::setFont( fnt );
1693 delete d->mFm; 1704 delete d->mFm;
1694 d->mFm = new QFontMetrics( fnt ); 1705 d->mFm = new QFontMetrics( fnt );
1695} 1706}
1696 1707
1697int CardView::separatorWidth() 1708int CardView::separatorWidth()
1698{ 1709{
1699 return d->mSepWidth; 1710 return d->mSepWidth;
1700} 1711}
1701 1712
1702void CardView::setSeparatorWidth( int width ) 1713void CardView::setSeparatorWidth( int width )
1703{ 1714{
1704 d->mSepWidth = width; 1715 d->mSepWidth = width;
1705 setLayoutDirty( true ); // hmm, actually I could just adjust the x'es... 1716 setLayoutDirty( true ); // hmm, actually I could just adjust the x'es...
1706} 1717}
1707 1718
1708int CardView::maxFieldLines() const 1719int CardView::maxFieldLines() const
1709{ 1720{
1710 return d->mMaxFieldLines; 1721 return d->mMaxFieldLines;
1711} 1722}
1712 1723
1713void CardView::setMaxFieldLines( int howmany ) 1724void CardView::setMaxFieldLines( int howmany )
1714{ 1725{
1715 d->mMaxFieldLines = howmany ? howmany : INT_MAX; 1726 d->mMaxFieldLines = howmany ? howmany : INT_MAX;
1716 // FIXME update, forcing the items to recalc height!! 1727 // FIXME update, forcing the items to recalc height!!
1717} 1728}
1729
1730void CardView::keyReleaseEvent ( QKeyEvent * e )
1731{
1732 if ( mFlagBlockKeyPressed )
1733 return;
1734 if ( !e->isAutoRepeat() ) {
1735 mFlagBlockKeyPressed = true;
1736 qApp->processEvents();
1737 mFlagBlockKeyPressed = false;
1738 mFlagKeyPressed = false;
1739 }
1740 QScrollView::keyReleaseEvent ( e );
1741}
1742
1743
1744
1745
1746
1718//END Cardview 1747//END Cardview
1719 1748
1720#ifndef KAB_EMBEDDED 1749#ifndef KAB_EMBEDDED
1721#include "cardview.moc" 1750#include "cardview.moc"
1722#endif //KAB_EMBEDDED 1751#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/cardview.h b/kaddressbook/views/cardview.h
index 37dddb6..2ea3771 100644
--- a/kaddressbook/views/cardview.h
+++ b/kaddressbook/views/cardview.h
@@ -344,130 +344,133 @@ class CardView : public QScrollView
344 344
345 /** @return the width made available to the card items. */ 345 /** @return the width made available to the card items. */
346 int itemWidth() const; 346 int itemWidth() const;
347 347
348 /** Sets the width made available to card items. */ 348 /** Sets the width made available to card items. */
349 void setItemWidth( int width ); 349 void setItemWidth( int width );
350 350
351 /** Sets the header font */ 351 /** Sets the header font */
352 void setHeaderFont( const QFont &fnt ); 352 void setHeaderFont( const QFont &fnt );
353 353
354 /** @return the header font */ 354 /** @return the header font */
355 QFont headerFont() const; 355 QFont headerFont() const;
356 356
357 /** @reimp */ 357 /** @reimp */
358 void setFont( const QFont &fnt ); 358 void setFont( const QFont &fnt );
359 359
360 /** Sets the column separator width */ 360 /** Sets the column separator width */
361 void setSeparatorWidth( int width ); 361 void setSeparatorWidth( int width );
362 362
363 /** @return the column separator width */ 363 /** @return the column separator width */
364 int separatorWidth(); 364 int separatorWidth();
365 365
366 /** Sets the maximum number of lines to display pr field. 366 /** Sets the maximum number of lines to display pr field.
367 If set to 0 (the default) all lines will be displayed. 367 If set to 0 (the default) all lines will be displayed.
368 */ 368 */
369 void setMaxFieldLines( int howmany ); 369 void setMaxFieldLines( int howmany );
370 370
371 /** @return the maximum number of lines pr field */ 371 /** @return the maximum number of lines pr field */
372 int maxFieldLines() const; 372 int maxFieldLines() const;
373 373
374 signals: 374 signals:
375 /** Emitted whenever the selection changes. This means a user highlighted 375 /** Emitted whenever the selection changes. This means a user highlighted
376 * a new item or unhighlighted a currently selected item. 376 * a new item or unhighlighted a currently selected item.
377 */ 377 */
378 void selectionChanged(); 378 void selectionChanged();
379 379
380 /** Same as above method, only it carries the item that was selected. This 380 /** Same as above method, only it carries the item that was selected. This
381 * method will only be emitted in single select mode, since it defineds 381 * method will only be emitted in single select mode, since it defineds
382 * which item was selected. 382 * which item was selected.
383 */ 383 */
384 void selectionChanged(CardViewItem *); 384 void selectionChanged(CardViewItem *);
385 385
386 /** This method is emitted whenever an item is clicked. 386 /** This method is emitted whenever an item is clicked.
387 */ 387 */
388 void clicked(CardViewItem *); 388 void clicked(CardViewItem *);
389 389
390 /** Emitted whenever the user 'executes' an item. This is dependant on 390 /** Emitted whenever the user 'executes' an item. This is dependant on
391 * the KDE global config. This could be a single click or a doubleclick. 391 * the KDE global config. This could be a single click or a doubleclick.
392 * Also emitted when the return key is pressed on an item. 392 * Also emitted when the return key is pressed on an item.
393 */ 393 */
394 void executed(CardViewItem *); 394 void executed(CardViewItem *);
395 395
396 /** Emitted whenever the user double clicks on an item. 396 /** Emitted whenever the user double clicks on an item.
397 */ 397 */
398 void doubleClicked(CardViewItem *); 398 void doubleClicked(CardViewItem *);
399 399
400 /** Emitted when the current item changes 400 /** Emitted when the current item changes
401 */ 401 */
402 void currentChanged( CardViewItem * ); 402 void currentChanged( CardViewItem * );
403 403
404 /** Emitted when the return key is pressed in an item. 404 /** Emitted when the return key is pressed in an item.
405 */ 405 */
406 void returnPressed( CardViewItem * ); 406 void returnPressed( CardViewItem * );
407 407
408 protected: 408 protected:
409 bool mFlagKeyPressed;
410 bool mFlagBlockKeyPressed;
411 virtual void keyPressEvent ( QKeyEvent * );
412 virtual void keyReleaseEvent ( QKeyEvent * );
409 /** Determines which cards intersect that region and tells them to paint 413 /** Determines which cards intersect that region and tells them to paint
410 * themselves. 414 * themselves.
411 */ 415 */
412 void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph); 416 void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
413 417
414 /** Sets the layout to dirty and repaints. 418 /** Sets the layout to dirty and repaints.
415 */ 419 */
416 void resizeEvent(QResizeEvent *e); 420 void resizeEvent(QResizeEvent *e);
417 421
418 /** Changes the direction the canvas scolls. 422 /** Changes the direction the canvas scolls.
419 */ 423 */
420 void contentsWheelEvent(QWheelEvent *e); 424 void contentsWheelEvent(QWheelEvent *e);
421 425
422 /** Sets the layout to dirty and calls for a repaint. 426 /** Sets the layout to dirty and calls for a repaint.
423 */ 427 */
424 void setLayoutDirty(bool dirty); 428 void setLayoutDirty(bool dirty);
425 429
426 /** Does the math based on the bounding rect of the cards to properly 430 /** Does the math based on the bounding rect of the cards to properly
427 * lay the cards out on the screen. This is only done if the layout is 431 * lay the cards out on the screen. This is only done if the layout is
428 * marked as dirty. 432 * marked as dirty.
429 */ 433 */
430 void calcLayout(); 434 void calcLayout();
431 435
432// virtual void mousePressEvent(QMouseEvent *e); 436// virtual void mousePressEvent(QMouseEvent *e);
433// virtual void mouseReleaseEvent(QMouseEvent *e); 437// virtual void mouseReleaseEvent(QMouseEvent *e);
434// virtual void mouseMoveEvent(QMouseEvent *e); 438// virtual void mouseMoveEvent(QMouseEvent *e);
435 439
436 virtual void contentsMousePressEvent(QMouseEvent *e); 440 virtual void contentsMousePressEvent(QMouseEvent *e);
437 virtual void contentsMouseMoveEvent(QMouseEvent *e); 441 virtual void contentsMouseMoveEvent(QMouseEvent *e);
438 virtual void contentsMouseReleaseEvent(QMouseEvent *e); 442 virtual void contentsMouseReleaseEvent(QMouseEvent *e);
439 virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); 443 virtual void contentsMouseDoubleClickEvent(QMouseEvent *e);
440 444
441 virtual void enterEvent( QEvent * ); 445 virtual void enterEvent( QEvent * );
442 virtual void leaveEvent( QEvent * ); 446 virtual void leaveEvent( QEvent * );
443 447
444 virtual void focusInEvent( QFocusEvent * ); 448 virtual void focusInEvent( QFocusEvent * );
445 virtual void focusOutEvent( QFocusEvent * ); 449 virtual void focusOutEvent( QFocusEvent * );
446 450
447 virtual void keyPressEvent( QKeyEvent * );
448 451
449 /** Overload this method to be told when a drag should be started. 452 /** Overload this method to be told when a drag should be started.
450 * In most cases you will want to start a drag event with the currently 453 * In most cases you will want to start a drag event with the currently
451 * selected item. 454 * selected item.
452 */ 455 */
453 virtual void startDrag(); 456 virtual void startDrag();
454 457
455 private slots: 458 private slots:
456 /** Called by a timer to display a label with truncated text. 459 /** Called by a timer to display a label with truncated text.
457 * Pop up a label, if there is a field with obscured text or 460 * Pop up a label, if there is a field with obscured text or
458 * label at the cursor position. 461 * label at the cursor position.
459 */ 462 */
460 void tryShowFullText(); 463 void tryShowFullText();
461 464
462 private: 465 private:
463 /** draws and erases the rubber bands while columns are resized. 466 /** draws and erases the rubber bands while columns are resized.
464 * @p pos is the horizontal position inside the viewport to use as 467 * @p pos is the horizontal position inside the viewport to use as
465 * the anchor. 468 * the anchor.
466 * If pos is 0, only erase is done. 469 * If pos is 0, only erase is done.
467 */ 470 */
468 void drawRubberBands( int pos ); 471 void drawRubberBands( int pos );
469 472
470 CardViewPrivate *d; 473 CardViewPrivate *d;
471}; 474};
472 475
473#endif 476#endif
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index e75810e..09d9c03 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -1,95 +1,96 @@
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 <qheader.h> 24#include <qheader.h>
25#include <qiconset.h> 25#include <qiconset.h>
26#include <qimage.h> 26#include <qimage.h>
27#include <qdragobject.h> 27#include <qdragobject.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qbrush.h> 30#include <qbrush.h>
31#include <qevent.h> 31#include <qevent.h>
32#include <qapplication.h>
32 33
33#include <klocale.h> 34#include <klocale.h>
34#include <kglobalsettings.h> 35#include <kglobalsettings.h>
35#include <kiconloader.h> 36#include <kiconloader.h>
36#include <kdebug.h> 37#include <kdebug.h>
37#include <kconfig.h> 38#include <kconfig.h>
38#include <kapplication.h> 39#include <kapplication.h>
39#include <kurl.h> 40#include <kurl.h>
40 41
41#include "kaddressbooktableview.h" 42#include "kaddressbooktableview.h"
42 43
43#include "contactlistview.h" 44#include "contactlistview.h"
44 45
45///////////////////////////////// 46/////////////////////////////////
46// DynamicTip Methods 47// DynamicTip Methods
47 48
48DynamicTip::DynamicTip( ContactListView *parent) 49DynamicTip::DynamicTip( ContactListView *parent)
49 : QToolTip( parent ) 50 : QToolTip( parent )
50{ 51{
51} 52}
52 53
53void DynamicTip::maybeTip( const QPoint &pos ) 54void DynamicTip::maybeTip( const QPoint &pos )
54{ 55{
55 static bool ishidden = true; 56 static bool ishidden = true;
56 if (!parentWidget()->inherits( "ContactListView" )) 57 if (!parentWidget()->inherits( "ContactListView" ))
57 return; 58 return;
58 59
59 ContactListView *plv = (ContactListView*)parentWidget(); 60 ContactListView *plv = (ContactListView*)parentWidget();
60 if (!plv->tooltips()) 61 if (!plv->tooltips())
61 return; 62 return;
62 63
63 QPoint posVp = plv->viewport()->pos(); 64 QPoint posVp = plv->viewport()->pos();
64 65
65 QListViewItem *lvi = plv->itemAt( pos - posVp ); 66 QListViewItem *lvi = plv->itemAt( pos - posVp );
66 if (!lvi) 67 if (!lvi)
67 return; 68 return;
68 69
69#ifndef KAB_EMBEDDED 70#ifndef KAB_EMBEDDED
70 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); 71 ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi);
71#else //KAB_EMBEDDED 72#else //KAB_EMBEDDED
72 ContactListViewItem *plvi = (ContactListViewItem*)(lvi); 73 ContactListViewItem *plvi = (ContactListViewItem*)(lvi);
73#endif //KAB_EMBEDDED 74#endif //KAB_EMBEDDED
74 75
75 if (!plvi) 76 if (!plvi)
76 return; 77 return;
77 78
78 if (ishidden) { 79 if (ishidden) {
79 QString s; 80 QString s;
80 QRect r = plv->itemRect( lvi ); 81 QRect r = plv->itemRect( lvi );
81 r.moveBy( posVp.x(), posVp.y() ); 82 r.moveBy( posVp.x(), posVp.y() );
82 83
83 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() 84 //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width()
84 // << "," << r.height() << endl; 85 // << "," << r.height() << endl;
85 86
86 KABC::Addressee a = plvi->addressee(); 87 KABC::Addressee a = plvi->addressee();
87 if (a.isEmpty()) 88 if (a.isEmpty())
88 return; 89 return;
89 90
90 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) 91 s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel())
91 .arg(a.formattedName()); 92 .arg(a.formattedName());
92 93
93 s += '\n'; 94 s += '\n';
94 s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) 95 s += i18n("label: value", "%1: %2").arg(a.organizationLabel())
95 .arg(a.organization()); 96 .arg(a.organization());
@@ -187,128 +188,130 @@ QString ContactListViewItem::key(int column, bool ascending) const
187 } 188 }
188 start = -1; 189 start = -1;
189 while ( (start = ret.find( 'ß', start+1)) > 0 ) { 190 while ( (start = ret.find( 'ß', start+1)) > 0 ) {
190 ret.at(start-1) = 's'; 191 ret.at(start-1) = 's';
191 } 192 }
192 //qDebug("conv string %s ", ret.latin1()); 193 //qDebug("conv string %s ", ret.latin1());
193 194
194 return ret; 195 return ret;
195 196
196 } 197 }
197 else 198 else
198#endif 199#endif
199 return QListViewItem::key(column, ascending).lower(); 200 return QListViewItem::key(column, ascending).lower();
200} 201}
201 202
202void ContactListViewItem::paintCell(QPainter * p, 203void ContactListViewItem::paintCell(QPainter * p,
203 const QColorGroup & cg, 204 const QColorGroup & cg,
204 int column, 205 int column,
205 int width, 206 int width,
206 int align) 207 int align)
207{ 208{
208 KListViewItem::paintCell(p, cg, column, width, align); 209 KListViewItem::paintCell(p, cg, column, width, align);
209 210
210 if ( !p ) 211 if ( !p )
211 return; 212 return;
212 213
213 if (parentListView->singleLine()) { 214 if (parentListView->singleLine()) {
214 p->setPen( parentListView->alternateColor() ); 215 p->setPen( parentListView->alternateColor() );
215 p->drawLine( 0, height() - 1, width, height() - 1 ); 216 p->drawLine( 0, height() - 1, width, height() - 1 );
216 } 217 }
217} 218}
218 219
219 220
220ContactListView *ContactListViewItem::parent() 221ContactListView *ContactListViewItem::parent()
221{ 222{
222 return parentListView; 223 return parentListView;
223} 224}
224 225
225 226
226void ContactListViewItem::refresh() 227void ContactListViewItem::refresh()
227{ 228{
228 // Update our addressee, since it may have changed else were 229 // Update our addressee, since it may have changed else were
229 mAddressee = mDocument->findByUid(mAddressee.uid()); 230 mAddressee = mDocument->findByUid(mAddressee.uid());
230 if (mAddressee.isEmpty()) 231 if (mAddressee.isEmpty())
231 return; 232 return;
232 233
233 int i = 0; 234 int i = 0;
234 KABC::Field::List::ConstIterator it; 235 KABC::Field::List::ConstIterator it;
235 for( it = mFields.begin(); it != mFields.end(); ++it ) { 236 for( it = mFields.begin(); it != mFields.end(); ++it ) {
236 setText( i++, (*it)->value( mAddressee ) ); 237 setText( i++, (*it)->value( mAddressee ) );
237 } 238 }
238} 239}
239 240
240/////////////////////////////// 241///////////////////////////////
241// ContactListView 242// ContactListView
242 243
243ContactListView::ContactListView(KAddressBookTableView *view, 244ContactListView::ContactListView(KAddressBookTableView *view,
244 KABC::AddressBook* /* doc */, 245 KABC::AddressBook* /* doc */,
245 QWidget *parent, 246 QWidget *parent,
246 const char *name ) 247 const char *name )
247 : KListView( parent, name ), 248 : KListView( parent, name ),
248 pabWidget( view ), 249 pabWidget( view ),
249 oldColumn( 0 ) 250 oldColumn( 0 )
250{ 251{
252 mFlagBlockKeyPressed = false;
253 mFlagKeyPressed = false;
251 mABackground = true; 254 mABackground = true;
252 mSingleLine = false; 255 mSingleLine = false;
253 mToolTips = true; 256 mToolTips = true;
254#ifndef KAB_EMBEDDED 257#ifndef KAB_EMBEDDED
255 mAlternateColor = KGlobalSettings::alternateBackgroundColor(); 258 mAlternateColor = KGlobalSettings::alternateBackgroundColor();
256#else //KAB_EMBEDDED 259#else //KAB_EMBEDDED
257 mAlternateColor = QColor(240, 240, 240); 260 mAlternateColor = QColor(240, 240, 240);
258#endif //KAB_EMBEDDED 261#endif //KAB_EMBEDDED
259 262
260 setAlternateBackgroundEnabled(mABackground); 263 setAlternateBackgroundEnabled(mABackground);
261 setAcceptDrops( true ); 264 setAcceptDrops( true );
262 viewport()->setAcceptDrops( true ); 265 viewport()->setAcceptDrops( true );
263 setAllColumnsShowFocus( true ); 266 setAllColumnsShowFocus( true );
264 setShowSortIndicator(true); 267 setShowSortIndicator(true);
265 268
266 setSelectionModeExt( KListView::Extended ); 269 setSelectionModeExt( KListView::Extended );
267 setDropVisualizer(false); 270 setDropVisualizer(false);
268 // setFrameStyle(QFrame::NoFrame); 271 // setFrameStyle(QFrame::NoFrame);
269 //setLineWidth ( 0 ); 272 //setLineWidth ( 0 );
270 //setMidLineWidth ( 0 ); 273 //setMidLineWidth ( 0 );
271 //setMargin ( 0 ); 274 //setMargin ( 0 );
272#ifndef KAB_EMBEDDED 275#ifndef KAB_EMBEDDED
273 connect(this, SIGNAL(dropped(QDropEvent*)), 276 connect(this, SIGNAL(dropped(QDropEvent*)),
274 this, SLOT(itemDropped(QDropEvent*))); 277 this, SLOT(itemDropped(QDropEvent*)));
275#endif //KAB_EMBEDDED 278#endif //KAB_EMBEDDED
276 279
277 280
278 new DynamicTip( this ); 281 new DynamicTip( this );
279} 282}
280void ContactListView::printMe() 283void ContactListView::printMe()
281{ 284{
282#ifdef DESKTOP_VERSION 285#ifdef DESKTOP_VERSION
283 QPrinter printer; 286 QPrinter printer;
284 if (!printer.setup() ) 287 if (!printer.setup() )
285 return; 288 return;
286 QPainter p; 289 QPainter p;
287 p.begin ( &printer ); 290 p.begin ( &printer );
288 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 291 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
289 float dx, dy; 292 float dx, dy;
290 int wid = (m.width() * 9)/10; 293 int wid = (m.width() * 9)/10;
291 dx = (float) wid/(float)contentsWidth (); 294 dx = (float) wid/(float)contentsWidth ();
292 dy = (float)(m.height()) / (float)contentsHeight (); 295 dy = (float)(m.height()) / (float)contentsHeight ();
293 float scale; 296 float scale;
294 // scale to fit the width or height of the paper 297 // scale to fit the width or height of the paper
295 if ( dx < dy ) 298 if ( dx < dy )
296 scale = dx; 299 scale = dx;
297 else 300 else
298 scale = dy; 301 scale = dy;
299 p.translate( m.width()/10,0 ); 302 p.translate( m.width()/10,0 );
300 p.scale( scale, scale ); 303 p.scale( scale, scale );
301 qDebug("scale %f ", scale); 304 qDebug("scale %f ", scale);
302 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 305 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
303 p.end(); 306 p.end();
304 qDebug("Why does it not print??? "); 307 qDebug("Why does it not print??? ");
305#endif 308#endif
306} 309}
307 310
308void ContactListView::setAlternateColor(const QColor &m_AlternateColor) 311void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
309{ 312{
310 mAlternateColor = m_AlternateColor; 313 mAlternateColor = m_AlternateColor;
311} 314}
312 315
313void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) 316void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
314{ 317{
@@ -334,67 +337,93 @@ void ContactListView::contentsMousePressEvent(QMouseEvent* e)
334{ 337{
335 presspos = e->pos(); 338 presspos = e->pos();
336 KListView::contentsMousePressEvent(e); 339 KListView::contentsMousePressEvent(e);
337} 340}
338 341
339 342
340// To initiate a drag operation 343// To initiate a drag operation
341void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) 344void ContactListView::contentsMouseMoveEvent( QMouseEvent *e )
342{ 345{
343 if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { 346 if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) {
344 emit startAddresseeDrag(); 347 emit startAddresseeDrag();
345 } 348 }
346 else 349 else
347 KListView::contentsMouseMoveEvent( e ); 350 KListView::contentsMouseMoveEvent( e );
348} 351}
349 352
350bool ContactListView::acceptDrag(QDropEvent *e) const 353bool ContactListView::acceptDrag(QDropEvent *e) const
351{ 354{
352#ifndef KAB_EMBEDDED 355#ifndef KAB_EMBEDDED
353 return QTextDrag::canDecode(e); 356 return QTextDrag::canDecode(e);
354#else //KAB_EMBEDDED 357#else //KAB_EMBEDDED
355qDebug("ContactListView::acceptDrag has to be fixed"); 358qDebug("ContactListView::acceptDrag has to be fixed");
356 return false; 359 return false;
357#endif //KAB_EMBEDDED 360#endif //KAB_EMBEDDED
358} 361}
359 362
360void ContactListView::itemDropped(QDropEvent *e) 363void ContactListView::itemDropped(QDropEvent *e)
361{ 364{
362 contentsDropEvent(e); 365 contentsDropEvent(e);
363} 366}
364 367
365void ContactListView::contentsDropEvent( QDropEvent *e ) 368void ContactListView::contentsDropEvent( QDropEvent *e )
366{ 369{
367 emit addresseeDropped(e); 370 emit addresseeDropped(e);
368} 371}
369 372
370void ContactListView::setAlternateBackgroundEnabled(bool enabled) 373void ContactListView::setAlternateBackgroundEnabled(bool enabled)
371{ 374{
372 mABackground = enabled; 375 mABackground = enabled;
373 376
374 if (mABackground) 377 if (mABackground)
375 { 378 {
376 setAlternateBackground(mAlternateColor); 379 setAlternateBackground(mAlternateColor);
377 } 380 }
378 else 381 else
379 { 382 {
380 setAlternateBackground(QColor()); 383 setAlternateBackground(QColor());
381 } 384 }
382} 385}
383 386
384void ContactListView::setBackgroundPixmap(const QString &filename) 387void ContactListView::setBackgroundPixmap(const QString &filename)
385{ 388{
386 if (filename.isEmpty()) 389 if (filename.isEmpty())
387 { 390 {
388 unsetPalette(); 391 unsetPalette();
389 } 392 }
390 else 393 else
391 { 394 {
392 qDebug("ContactListView::setBackgroundPixmap has to be verified"); 395 qDebug("ContactListView::setBackgroundPixmap has to be verified");
393//US setPaletteBackgroundPixmap(QPixmap(filename)); 396//US setPaletteBackgroundPixmap(QPixmap(filename));
394 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); 397 KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename));
395 } 398 }
396 399
397} 400}
401
402void ContactListView::keyPressEvent ( QKeyEvent * e )
403{
404 if ( mFlagBlockKeyPressed )
405 return;
406 qApp->processEvents();
407 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
408 e->accept();
409 return;
410 }
411 if (! e->isAutoRepeat() )
412 mFlagKeyPressed = true;
413 KListView::keyPressEvent ( e );
414}
415void ContactListView::keyReleaseEvent ( QKeyEvent * e )
416{
417 if ( mFlagBlockKeyPressed )
418 return;
419 if ( !e->isAutoRepeat() ) {
420 mFlagBlockKeyPressed = true;
421 qApp->processEvents();
422 mFlagBlockKeyPressed = false;
423 mFlagKeyPressed = false;
424 }
425 KListView::keyReleaseEvent ( e );
426}
398#ifndef KAB_EMBEDDED 427#ifndef KAB_EMBEDDED
399#include "contactlistview.moc" 428#include "contactlistview.moc"
400#endif //KAB_EMBEDDED 429#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h
index 9d1a672..46477e1 100644
--- a/kaddressbook/views/contactlistview.h
+++ b/kaddressbook/views/contactlistview.h
@@ -31,100 +31,104 @@ class DynamicTip : public QToolTip
31 private: 31 private:
32}; 32};
33 33
34class ContactListViewItem : public KListViewItem 34class ContactListViewItem : public KListViewItem
35{ 35{
36 36
37public: 37public:
38 ContactListViewItem(const KABC::Addressee &a, ContactListView* parent, 38 ContactListViewItem(const KABC::Addressee &a, ContactListView* parent,
39 KABC::AddressBook *doc, const KABC::Field::List &fields ); 39 KABC::AddressBook *doc, const KABC::Field::List &fields );
40 const KABC::Addressee &addressee() const { return mAddressee; } 40 const KABC::Addressee &addressee() const { return mAddressee; }
41 virtual void refresh(); 41 virtual void refresh();
42 virtual ContactListView* parent(); 42 virtual ContactListView* parent();
43 virtual QString key ( int, bool ) const; 43 virtual QString key ( int, bool ) const;
44 44
45 /** Adds the border around the cell if the user wants it. 45 /** Adds the border around the cell if the user wants it.
46 * This is how the single line config option is implemented. 46 * This is how the single line config option is implemented.
47 */ 47 */
48 virtual void paintCell(QPainter * p, const QColorGroup & cg, 48 virtual void paintCell(QPainter * p, const QColorGroup & cg,
49 int column, int width, int align ); 49 int column, int width, int align );
50 50
51private: 51private:
52 KABC::Addressee mAddressee; 52 KABC::Addressee mAddressee;
53 KABC::Field::List mFields; 53 KABC::Field::List mFields;
54 ContactListView *parentListView; 54 ContactListView *parentListView;
55 KABC::AddressBook *mDocument; 55 KABC::AddressBook *mDocument;
56}; 56};
57 57
58 58
59///////////////////////////////////////////// 59/////////////////////////////////////////////
60// ContactListView 60// ContactListView
61 61
62class ContactListView : public KListView 62class ContactListView : public KListView
63{ 63{
64 Q_OBJECT 64 Q_OBJECT
65 65
66public: 66public:
67 ContactListView(KAddressBookTableView *view, 67 ContactListView(KAddressBookTableView *view,
68 KABC::AddressBook *doc, 68 KABC::AddressBook *doc,
69 QWidget *parent, 69 QWidget *parent,
70 const char *name = 0L ); 70 const char *name = 0L );
71 virtual ~ContactListView() {} 71 virtual ~ContactListView() {}
72 //void resort(); 72 //void resort();
73 73
74 /** Returns true if tooltips should be displayed, false otherwise 74 /** Returns true if tooltips should be displayed, false otherwise
75 */ 75 */
76 bool tooltips() const { return mToolTips; } 76 bool tooltips() const { return mToolTips; }
77 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; } 77 void setToolTipsEnabled(bool enabled) { mToolTips = enabled; }
78 78
79 bool alternateBackground() const { return mABackground; } 79 bool alternateBackground() const { return mABackground; }
80 void setAlternateBackgroundEnabled(bool enabled); 80 void setAlternateBackgroundEnabled(bool enabled);
81 81
82 bool singleLine() const { return mSingleLine; } 82 bool singleLine() const { return mSingleLine; }
83 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; } 83 void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; }
84 84
85 const QColor &alternateColor() const { return mAlternateColor; } 85 const QColor &alternateColor() const { return mAlternateColor; }
86 void setAlternateColor(const QColor &mAlternateColor); 86 void setAlternateColor(const QColor &mAlternateColor);
87 87
88 /** Sets the background pixmap to <i>filename</i>. If the 88 /** Sets the background pixmap to <i>filename</i>. If the
89 * QString is empty (QString::isEmpty()), then the background 89 * QString is empty (QString::isEmpty()), then the background
90 * pixmap will be disabled. 90 * pixmap will be disabled.
91 */ 91 */
92 void setBackgroundPixmap(const QString &filename); 92 void setBackgroundPixmap(const QString &filename);
93 93
94protected: 94protected:
95 bool mFlagKeyPressed;
96 bool mFlagBlockKeyPressed;
97 virtual void keyPressEvent ( QKeyEvent * );
98 virtual void keyReleaseEvent ( QKeyEvent * );
95 /** Paints the background pixmap in the empty area. This method is needed 99 /** Paints the background pixmap in the empty area. This method is needed
96 * since Qt::FixedPixmap will not scroll with the list view. 100 * since Qt::FixedPixmap will not scroll with the list view.
97 */ 101 */
98 virtual void paintEmptyArea( QPainter * p, const QRect & rect ); 102 virtual void paintEmptyArea( QPainter * p, const QRect & rect );
99 virtual void contentsMousePressEvent(QMouseEvent*); 103 virtual void contentsMousePressEvent(QMouseEvent*);
100 void contentsMouseMoveEvent( QMouseEvent *e ); 104 void contentsMouseMoveEvent( QMouseEvent *e );
101 void contentsDropEvent( QDropEvent *e ); 105 void contentsDropEvent( QDropEvent *e );
102 virtual bool acceptDrag(QDropEvent *e) const; 106 virtual bool acceptDrag(QDropEvent *e) const;
103 107
104protected slots: 108protected slots:
105 void itemDropped(QDropEvent *e); 109 void itemDropped(QDropEvent *e);
106 110
107public slots: 111public slots:
108 void printMe(); 112 void printMe();
109 113
110signals: 114signals:
111 void startAddresseeDrag(); 115 void startAddresseeDrag();
112 void addresseeDropped(QDropEvent *); 116 void addresseeDropped(QDropEvent *);
113 117
114private: 118private:
115 KAddressBookTableView *pabWidget; 119 KAddressBookTableView *pabWidget;
116 int oldColumn; 120 int oldColumn;
117 int column; 121 int column;
118 bool ascending; 122 bool ascending;
119 123
120 bool mABackground; 124 bool mABackground;
121 bool mSingleLine; 125 bool mSingleLine;
122 bool mToolTips; 126 bool mToolTips;
123 127
124 QColor mAlternateColor; 128 QColor mAlternateColor;
125 129
126 QPoint presspos; 130 QPoint presspos;
127}; 131};
128 132
129 133
130#endif 134#endif
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index cce68b9..9c35fd6 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -147,134 +147,138 @@ void AddresseeCardView::printMe()
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 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 );
212 QApplication::postEvent( mCardView, ev );
211 213
212} 214}
213void KAddressBookCardView::scrollDOWN() 215void KAddressBookCardView::scrollDOWN()
214{ 216{
215 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 217 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
216 QApplication::postEvent( mCardView, ev ); 218 QApplication::postEvent( mCardView, ev );
219 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
220 QApplication::postEvent( mCardView, ev );
217} 221}
218void KAddressBookCardView::readConfig(KConfig *config) 222void KAddressBookCardView::readConfig(KConfig *config)
219{ 223{
220 KAddressBookView::readConfig(config); 224 KAddressBookView::readConfig(config);
221 225
222 // costum colors? 226 // costum colors?
223 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 227 if ( config->readBoolEntry( "EnableCustomColors", false ) )
224 { 228 {
225 QPalette p( mCardView->palette() ); 229 QPalette p( mCardView->palette() );
226 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 230 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
227 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 231 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
228 c = p.color(QPalette::Normal, QColorGroup::Text ); 232 c = p.color(QPalette::Normal, QColorGroup::Text );
229 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 233 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
230 c = p.color(QPalette::Normal, QColorGroup::Button ); 234 c = p.color(QPalette::Normal, QColorGroup::Button );
231 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 235 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
232 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 236 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
233 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 237 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
234 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 238 c = p.color(QPalette::Normal, QColorGroup::Highlight );
235 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 239 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
236 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 240 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
237 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 241 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
238 mCardView->viewport()->setPalette( p ); 242 mCardView->viewport()->setPalette( p );
239 } 243 }
240 else 244 else
241 { 245 {
242 // needed if turned off during a session. 246 // needed if turned off during a session.
243 mCardView->viewport()->setPalette( mCardView->palette() ); 247 mCardView->viewport()->setPalette( mCardView->palette() );
244 } 248 }
245 249
246 //custom fonts? 250 //custom fonts?
247 QFont f( font() ); 251 QFont f( font() );
248 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 252 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
249 { 253 {
250 mCardView->setFont( config->readFontEntry( "TextFont", &f) ); 254 mCardView->setFont( config->readFontEntry( "TextFont", &f) );
251 f.setBold( true ); 255 f.setBold( true );
252 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 256 mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
253 } 257 }
254 else 258 else
255 { 259 {
256 mCardView->setFont( f ); 260 mCardView->setFont( f );
257 f.setBold( true ); 261 f.setBold( true );
258 mCardView->setHeaderFont( f ); 262 mCardView->setHeaderFont( f );
259 } 263 }
260 264
261 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); 265 mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true));
262 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", 266 mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators",
263 true)); 267 true));
264 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); 268 mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false));
265 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); 269 mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false);
266 270
267 mCardView->setShowEmptyFields( mShowEmptyFields ); 271 mCardView->setShowEmptyFields( mShowEmptyFields );
268 272
269 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); 273 mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) );
270 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); 274 mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) );
271 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); 275 mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
272 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); 276 mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
273 277
274#if 0 278#if 0
275 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven 279 // LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
276 disconnect(mCardView, SIGNAL(executed(CardViewItem *)), 280 disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
277 this, SLOT(addresseeExecuted(CardViewItem *))); 281 this, SLOT(addresseeExecuted(CardViewItem *)));
278 282
279 if (KABPrefs::instance()->mHonorSingleClick) 283 if (KABPrefs::instance()->mHonorSingleClick)
280 connect(mCardView, SIGNAL(executed(CardViewItem *)), 284 connect(mCardView, SIGNAL(executed(CardViewItem *)),
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index f4b008c..e322473 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -1,132 +1,136 @@
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 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 );
65 QApplication::postEvent( mListView, ev );
64} 66}
65void KAddressBookTableView::scrollDOWN() 67void KAddressBookTableView::scrollDOWN()
66{ 68{
67 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); 69 QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
68 QApplication::postEvent( mListView, ev ); 70 QApplication::postEvent( mListView, ev );
71 ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
72 QApplication::postEvent( mListView, ev );
69} 73}
70void KAddressBookTableView::reconstructListView() 74void KAddressBookTableView::reconstructListView()
71{ 75{
72 if (mListView) 76 if (mListView)
73 { 77 {
74 disconnect(mListView, SIGNAL(selectionChanged()), 78 disconnect(mListView, SIGNAL(selectionChanged()),
75 this, SLOT(addresseeSelected())); 79 this, SLOT(addresseeSelected()));
76 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 80 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
77 this, SLOT(addresseeExecuted(QListViewItem*))); 81 this, SLOT(addresseeExecuted(QListViewItem*)));
78 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 82 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
79 this, SLOT(addresseeExecuted(QListViewItem*))); 83 this, SLOT(addresseeExecuted(QListViewItem*)));
80 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 84 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
81 SIGNAL(startDrag())); 85 SIGNAL(startDrag()));
82 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 86 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
83 this, SLOT(addresseeExecuted(QListViewItem*))); 87 this, SLOT(addresseeExecuted(QListViewItem*)));
84 88
85 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 89 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
86 SIGNAL(dropped(QDropEvent*))); 90 SIGNAL(dropped(QDropEvent*)));
87 delete mListView; 91 delete mListView;
88 } 92 }
89 93
90 mListView = new ContactListView( this, addressBook(), viewWidget() ); 94 mListView = new ContactListView( this, addressBook(), viewWidget() );
91 95
92 connect(this, SIGNAL(printView()), 96 connect(this, SIGNAL(printView()),
93 mListView , SLOT(printMe())); 97 mListView , SLOT(printMe()));
94 //US set singleClick manually, because it is no global configparameter in embedded space 98 //US set singleClick manually, because it is no global configparameter in embedded space
95 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); 99 mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
96 100
97 // Add the columns 101 // Add the columns
98 KABC::Field::List fieldList = fields(); 102 KABC::Field::List fieldList = fields();
99 KABC::Field::List::ConstIterator it; 103 KABC::Field::List::ConstIterator it;
100 104
101 int c = 0; 105 int c = 0;
102 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 106 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
103 mListView->addColumn( (*it)->label() ); 107 mListView->addColumn( (*it)->label() );
104 mListView->setColumnWidthMode(c++, QListView::Manual); 108 mListView->setColumnWidthMode(c++, QListView::Manual);
105//US 109//US
106 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 110 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
107 } 111 }
108 112
109 connect(mListView, SIGNAL(selectionChanged()), 113 connect(mListView, SIGNAL(selectionChanged()),
110 this, SLOT(addresseeSelected())); 114 this, SLOT(addresseeSelected()));
111 connect(mListView, SIGNAL(startAddresseeDrag()), this, 115 connect(mListView, SIGNAL(startAddresseeDrag()), this,
112 SIGNAL(startDrag())); 116 SIGNAL(startDrag()));
113 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 117 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
114 SIGNAL(dropped(QDropEvent*))); 118 SIGNAL(dropped(QDropEvent*)));
115 119
116 if (KABPrefs::instance()->mHonorSingleClick) { 120 if (KABPrefs::instance()->mHonorSingleClick) {
117 // qDebug("KAddressBookTableView::reconstructListView single"); 121 // qDebug("KAddressBookTableView::reconstructListView single");
118 connect(mListView, SIGNAL(executed(QListViewItem*)), 122 connect(mListView, SIGNAL(executed(QListViewItem*)),
119 this, SLOT(addresseeExecuted(QListViewItem*))); 123 this, SLOT(addresseeExecuted(QListViewItem*)));
120 } else { 124 } else {
121 // qDebug("KAddressBookTableView::reconstructListView double"); 125 // qDebug("KAddressBookTableView::reconstructListView double");
122 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 126 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
123 this, SLOT(addresseeExecuted(QListViewItem*))); 127 this, SLOT(addresseeExecuted(QListViewItem*)));
124 } 128 }
125 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 129 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
126 this, SLOT(addresseeExecuted(QListViewItem*))); 130 this, SLOT(addresseeExecuted(QListViewItem*)));
127 connect(mListView, SIGNAL(signalDelete()), 131 connect(mListView, SIGNAL(signalDelete()),
128 this, SLOT(addresseeDeleted())); 132 this, SLOT(addresseeDeleted()));
129 133
130//US performceimprovement. Refresh is done from the outside 134//US performceimprovement. Refresh is done from the outside
131//US refresh(); 135//US refresh();
132 136
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index ca35a86..b9ce4f4 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -939,128 +939,129 @@ void MonthViewCell::defaultAction( QListBoxItem *item )
939{ 939{
940 if ( !item ) return; 940 if ( !item ) return;
941 941
942 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 942 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
943 Incidence *incidence = eventItem->incidence(); 943 Incidence *incidence = eventItem->incidence();
944 if ( incidence ) mMonthView->defaultAction( incidence ); 944 if ( incidence ) mMonthView->defaultAction( incidence );
945} 945}
946void MonthViewCell::showDay() 946void MonthViewCell::showDay()
947{ 947{
948 emit showDaySignal( date() ); 948 emit showDaySignal( date() );
949} 949}
950void MonthViewCell::newEvent() 950void MonthViewCell::newEvent()
951{ 951{
952 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 952 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
953 emit newEventSignal( dt ); 953 emit newEventSignal( dt );
954} 954}
955void MonthViewCell::cellClicked( QListBoxItem *item ) 955void MonthViewCell::cellClicked( QListBoxItem *item )
956{ 956{
957 static QListBoxItem * lastClicked = 0; 957 static QListBoxItem * lastClicked = 0;
958 if ( item == 0 ) { 958 if ( item == 0 ) {
959 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 959 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
960 emit newEventSignal( dt ); 960 emit newEventSignal( dt );
961 return; 961 return;
962 } 962 }
963 /* 963 /*
964 if ( lastClicked ) 964 if ( lastClicked )
965 if ( ! item ) { 965 if ( ! item ) {
966 if ( lastClicked->listBox() != item->listBox() ) 966 if ( lastClicked->listBox() != item->listBox() )
967 lastClicked->listBox()->clearSelection(); 967 lastClicked->listBox()->clearSelection();
968 } 968 }
969 */ 969 */
970 970
971 mMonthView->setSelectedCell( this ); 971 mMonthView->setSelectedCell( this );
972 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 972 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
973 select(); 973 select();
974} 974}
975 975
976void MonthViewCell::contextMenu( QListBoxItem *item ) 976void MonthViewCell::contextMenu( QListBoxItem *item )
977{ 977{
978 if ( !item ) return; 978 if ( !item ) return;
979 979
980 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 980 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
981 Incidence *incidence = eventItem->incidence(); 981 Incidence *incidence = eventItem->incidence();
982 if ( incidence ) mMonthView->showContextMenu( incidence ); 982 if ( incidence ) mMonthView->showContextMenu( incidence );
983} 983}
984 984
985void MonthViewCell::selection( QListBoxItem *item ) 985void MonthViewCell::selection( QListBoxItem *item )
986{ 986{
987 if ( !item ) return; 987 if ( !item ) return;
988 988
989 mMonthView->setSelectedCell( this ); 989 mMonthView->setSelectedCell( this );
990} 990}
991 991
992 992
993// ******************************************************************************* 993// *******************************************************************************
994// ******************************************************************************* 994// *******************************************************************************
995// ******************************************************************************* 995// *******************************************************************************
996 996
997 997
998KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 998KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
999 : KOEventView( calendar, parent, name ), 999 : KOEventView( calendar, parent, name ),
1000 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1000 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1001 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1001 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1002{ 1002{
1003 mFlagKeyPressed = false;
1003 mShortDayLabelsM = false; 1004 mShortDayLabelsM = false;
1004 mShortDayLabelsW = false; 1005 mShortDayLabelsW = false;
1005 skipResize = false; 1006 skipResize = false;
1006 clPending = true; 1007 clPending = true;
1007 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1008 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1008 mWidStack = new QWidgetStack( this ); 1009 mWidStack = new QWidgetStack( this );
1009 QVBoxLayout* hb = new QVBoxLayout( this ); 1010 QVBoxLayout* hb = new QVBoxLayout( this );
1010 mMonthView = new QWidget( mWidStack ); 1011 mMonthView = new QWidget( mWidStack );
1011 mWeekView = new QWidget( mWidStack ); 1012 mWeekView = new QWidget( mWidStack );
1012#if QT_VERSION >= 0x030000 1013#if QT_VERSION >= 0x030000
1013 mWidStack->addWidget(mMonthView ); 1014 mWidStack->addWidget(mMonthView );
1014 mWidStack->addWidget(mWeekView ); 1015 mWidStack->addWidget(mWeekView );
1015#else 1016#else
1016 mWidStack->addWidget( mMonthView, 1 ); 1017 mWidStack->addWidget( mMonthView, 1 );
1017 mWidStack->addWidget( mWeekView , 1 ); 1018 mWidStack->addWidget( mWeekView , 1 );
1018#endif 1019#endif
1019 hb->addWidget( mNavigatorBar ); 1020 hb->addWidget( mNavigatorBar );
1020 hb->addWidget( mWidStack ); 1021 hb->addWidget( mWidStack );
1021 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1022 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1022 updatePossible = false; 1023 updatePossible = false;
1023 //updatePossible = true; 1024 //updatePossible = true;
1024 mCells.setAutoDelete( true ); 1025 mCells.setAutoDelete( true );
1025 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1026 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1026 mDayLabels.resize( mDaysPerWeek ); 1027 mDayLabels.resize( mDaysPerWeek );
1027 mDayLabelsW.resize( mDaysPerWeek ); 1028 mDayLabelsW.resize( mDaysPerWeek );
1028 QFont bfont = font(); 1029 QFont bfont = font();
1029 if ( QApplication::desktop()->width() < 650 ) { 1030 if ( QApplication::desktop()->width() < 650 ) {
1030 bfont.setPointSize( bfont.pointSize() - 2 ); 1031 bfont.setPointSize( bfont.pointSize() - 2 );
1031 } 1032 }
1032 bfont.setBold( true ); 1033 bfont.setBold( true );
1033 int i; 1034 int i;
1034 1035
1035 for( i = 0; i < mDaysPerWeek; i++ ) { 1036 for( i = 0; i < mDaysPerWeek; i++ ) {
1036 QLabel *label = new QLabel( mMonthView ); 1037 QLabel *label = new QLabel( mMonthView );
1037 label->setFont(bfont); 1038 label->setFont(bfont);
1038 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1039 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1039 label->setLineWidth(1); 1040 label->setLineWidth(1);
1040 label->setAlignment(AlignCenter); 1041 label->setAlignment(AlignCenter);
1041 mDayLabels.insert( i, label ); 1042 mDayLabels.insert( i, label );
1042 label = new QLabel( mWeekView ); 1043 label = new QLabel( mWeekView );
1043 label->setFont(bfont); 1044 label->setFont(bfont);
1044 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1045 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1045 label->setLineWidth(1); 1046 label->setLineWidth(1);
1046 label->setAlignment(AlignCenter); 1047 label->setAlignment(AlignCenter);
1047 mDayLabelsW.insert( i, label ); 1048 mDayLabelsW.insert( i, label );
1048 } 1049 }
1049 1050
1050 bfont.setBold( false ); 1051 bfont.setBold( false );
1051 mWeekLabels.resize( mNumWeeks+1 ); 1052 mWeekLabels.resize( mNumWeeks+1 );
1052 mWeekLabelsW.resize( 2 ); 1053 mWeekLabelsW.resize( 2 );
1053 for( i = 0; i < mNumWeeks+1; i++ ) { 1054 for( i = 0; i < mNumWeeks+1; i++ ) {
1054 KOWeekButton *label = new KOWeekButton( mMonthView ); 1055 KOWeekButton *label = new KOWeekButton( mMonthView );
1055 label->setFocusPolicy(NoFocus); 1056 label->setFocusPolicy(NoFocus);
1056 label->setFont(bfont); 1057 label->setFont(bfont);
1057 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1058 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1058 label->setFlat(true); 1059 label->setFlat(true);
1059 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1060 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1060 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1061 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1061 //label->setLineWidth(1); 1062 //label->setLineWidth(1);
1062 //label->setAlignment(AlignCenter); 1063 //label->setAlignment(AlignCenter);
1063 mWeekLabels.insert( i, label ); 1064 mWeekLabels.insert( i, label );
1064 } 1065 }
1065 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1066 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1066 mWeekLabels[0]->setFocusPolicy(WheelFocus); 1067 mWeekLabels[0]->setFocusPolicy(WheelFocus);
@@ -1776,111 +1777,127 @@ void KOMonthView::computeLayout()
1776 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1777 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1777 y += h; 1778 y += h;
1778 } 1779 }
1779 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1780 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1780 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1781 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1781 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1782 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1782 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1783 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1783 updateDayLabels(); 1784 updateDayLabels();
1784 //bool forceUpdate = !updatePossible; 1785 //bool forceUpdate = !updatePossible;
1785 updatePossible = true; 1786 updatePossible = true;
1786 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1787 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1787} 1788}
1788 1789
1789void KOMonthView::showContextMenu( Incidence *incidence ) 1790void KOMonthView::showContextMenu( Incidence *incidence )
1790{ 1791{
1791 mContextMenu->showIncidencePopup(incidence); 1792 mContextMenu->showIncidencePopup(incidence);
1792 /* 1793 /*
1793 if( incidence && incidence->type() == "Event" ) { 1794 if( incidence && incidence->type() == "Event" ) {
1794 Event *event = static_cast<Event *>(incidence); 1795 Event *event = static_cast<Event *>(incidence);
1795 mContextMenu->showEventPopup(event); 1796 mContextMenu->showEventPopup(event);
1796 } else { 1797 } else {
1797 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1798 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1798 } 1799 }
1799 */ 1800 */
1800} 1801}
1801MonthViewCell * KOMonthView::selectedCell( ) 1802MonthViewCell * KOMonthView::selectedCell( )
1802{ 1803{
1803 return mSelectedCell; 1804 return mSelectedCell;
1804} 1805}
1805void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1806void KOMonthView::setSelectedCell( MonthViewCell *cell )
1806{ 1807{
1807 //qDebug("KOMonthView::setSelectedCell "); 1808 //qDebug("KOMonthView::setSelectedCell ");
1808 if ( mSelectedCell && mSelectedCell != cell ) { 1809 if ( mSelectedCell && mSelectedCell != cell ) {
1809 MonthViewCell * mvc = mSelectedCell; 1810 MonthViewCell * mvc = mSelectedCell;
1810 mSelectedCell = cell; 1811 mSelectedCell = cell;
1811 mvc->deselect(); 1812 mvc->deselect();
1812 } else 1813 } else
1813 mSelectedCell = cell; 1814 mSelectedCell = cell;
1814 // if ( mSelectedCell ) 1815 // if ( mSelectedCell )
1815 // mSelectedCell->select(); 1816 // mSelectedCell->select();
1816 if ( !mSelectedCell ) 1817 if ( !mSelectedCell )
1817 emit incidenceSelected( 0 ); 1818 emit incidenceSelected( 0 );
1818 else 1819 else
1819 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1820 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1820} 1821}
1821 1822
1822void KOMonthView::processSelectionChange() 1823void KOMonthView::processSelectionChange()
1823{ 1824{
1824 QPtrList<Incidence> incidences = selectedIncidences(); 1825 QPtrList<Incidence> incidences = selectedIncidences();
1825 if (incidences.count() > 0) { 1826 if (incidences.count() > 0) {
1826 emit incidenceSelected( incidences.first() ); 1827 emit incidenceSelected( incidences.first() );
1827 } else { 1828 } else {
1828 emit incidenceSelected( 0 ); 1829 emit incidenceSelected( 0 );
1829 clearSelection(); 1830 clearSelection();
1830 } 1831 }
1831} 1832}
1832 1833
1833void KOMonthView::clearSelection() 1834void KOMonthView::clearSelection()
1834{ 1835{
1835 if ( mSelectedCell ) { 1836 if ( mSelectedCell ) {
1836 mSelectedCell->deselect(); 1837 mSelectedCell->deselect();
1837 mSelectedCell = 0; 1838 mSelectedCell = 0;
1838 } 1839 }
1839} 1840}
1841
1842void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1843{
1844 if ( !e->isAutoRepeat() ) {
1845 mFlagKeyPressed = false;
1846 }
1847}
1848
1840void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1849void KOMonthView::keyPressEvent ( QKeyEvent * e )
1841{ 1850{
1842 //qDebug("KOMonthView::keyPressEvent "); 1851
1852 qApp->processEvents();
1853 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1854 //e->ignore();
1855 e->accept();
1856 return;
1857 }
1858 if (! e->isAutoRepeat() )
1859 mFlagKeyPressed = true;
1843 switch(e->key()) { 1860 switch(e->key()) {
1844 case Key_Up: 1861 case Key_Up:
1845 { 1862 {
1846 if ( mShowWeekView ) { 1863 if ( mShowWeekView ) {
1847 emit selectWeekNum ( currentWeek() - 1 ); 1864 emit selectWeekNum ( currentWeek() - 1 );
1848 } 1865 }
1849 else { 1866 else {
1850 emit prevMonth(); 1867 emit prevMonth();
1851 } 1868 }
1852 } 1869 }
1853 e->accept(); 1870 e->accept();
1854 break; 1871 break;
1855 case Key_Down: 1872 case Key_Down:
1856 { 1873 {
1857 if ( mShowWeekView ) { 1874 if ( mShowWeekView ) {
1858 emit selectWeekNum ( currentWeek() +1); 1875 emit selectWeekNum ( currentWeek() +1);
1859 } 1876 }
1860 else { 1877 else {
1861 emit nextMonth(); 1878 emit nextMonth();
1862 } 1879 }
1863 1880
1864 } 1881 }
1865 e->accept(); 1882 e->accept();
1866 break; 1883 break;
1867 case Key_Return: 1884 case Key_Return:
1868 case Key_Enter: 1885 case Key_Enter:
1869 { 1886 {
1870 selectInternalWeekNum ( currentWeek() ); 1887 selectInternalWeekNum ( currentWeek() );
1871 } 1888 }
1872 e->accept(); 1889 e->accept();
1873 break; 1890 break;
1874 case Key_D: 1891 case Key_D:
1875 if ( mSelectedCell ) { 1892 if ( mSelectedCell ) {
1876 mSelectedCell->showDay(); 1893 mSelectedCell->showDay();
1877 e->accept(); 1894 e->accept();
1878 } else { 1895 } else {
1879 e->ignore(); 1896 e->ignore();
1880 } 1897 }
1881 break; 1898 break;
1882 default: 1899 default:
1883 e->ignore(); 1900 e->ignore();
1884 break; 1901 break;
1885 } 1902 }
1886} 1903}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index c1ca3d4..88050fe 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -250,71 +250,72 @@ class KOMonthView: public KOEventView
250 public slots: 250 public slots:
251 virtual void updateView(); 251 virtual void updateView();
252 virtual void updateConfig(); 252 virtual void updateConfig();
253 virtual void showDates(const QDate &start, const QDate &end); 253 virtual void showDates(const QDate &start, const QDate &end);
254 virtual void showEvents(QPtrList<Event> eventList); 254 virtual void showEvents(QPtrList<Event> eventList);
255 255
256 void changeEventDisplay(Event *, int); 256 void changeEventDisplay(Event *, int);
257 257
258 void clearSelection(); 258 void clearSelection();
259 259
260 void showContextMenu( Incidence * ); 260 void showContextMenu( Incidence * );
261 261
262 void setSelectedCell( MonthViewCell * ); 262 void setSelectedCell( MonthViewCell * );
263 void switchView(); 263 void switchView();
264 void setKeyBoardFocus(); 264 void setKeyBoardFocus();
265 void setKeyBFocus(); 265 void setKeyBFocus();
266 266
267 protected slots: 267 protected slots:
268 void slotComputeLayout(); 268 void slotComputeLayout();
269 void selectInternalWeekNum ( int ); 269 void selectInternalWeekNum ( int );
270 void processSelectionChange(); 270 void processSelectionChange();
271 signals: 271 signals:
272 void nextMonth(); 272 void nextMonth();
273 void prevMonth(); 273 void prevMonth();
274 void selectWeekNum ( int ); 274 void selectWeekNum ( int );
275 void selectMonth (); 275 void selectMonth ();
276 void showDaySignal( QDate ); 276 void showDaySignal( QDate );
277 protected: 277 protected:
278 void resizeEvent(QResizeEvent *); 278 void resizeEvent(QResizeEvent *);
279 void viewChanged(); 279 void viewChanged();
280 void updateDayLabels(); 280 void updateDayLabels();
281 281
282 private: 282 private:
283 QTimer* mComputeLayoutTimer; 283 QTimer* mComputeLayoutTimer;
284 NavigatorBar* mNavigatorBar; 284 NavigatorBar* mNavigatorBar;
285 int currentWeek(); 285 int currentWeek();
286 bool clPending; 286 bool clPending;
287 QWidgetStack * mWidStack; 287 QWidgetStack * mWidStack;
288 QWidget* mMonthView; 288 QWidget* mMonthView;
289 QWidget* mWeekView; 289 QWidget* mWeekView;
290 bool mShowWeekView; 290 bool mShowWeekView;
291 bool updatePossible; 291 bool updatePossible;
292 int mDaysPerWeek; 292 int mDaysPerWeek;
293 int mNumWeeks; 293 int mNumWeeks;
294 int mNumCells; 294 int mNumCells;
295 //bool mWeekStartsMonday; 295 //bool mWeekStartsMonday;
296 bool mShowSatSunComp; 296 bool mShowSatSunComp;
297 void computeLayout(); 297 void computeLayout();
298 void computeLayoutWeek(); 298 void computeLayoutWeek();
299 299
300 QPtrVector<MonthViewCell> mCells; 300 QPtrVector<MonthViewCell> mCells;
301 QPtrVector<QLabel> mDayLabels; 301 QPtrVector<QLabel> mDayLabels;
302 QPtrVector<KOWeekButton> mWeekLabels; 302 QPtrVector<KOWeekButton> mWeekLabels;
303 QPtrVector<MonthViewCell> mCellsW; 303 QPtrVector<MonthViewCell> mCellsW;
304 QPtrVector<QLabel> mDayLabelsW; 304 QPtrVector<QLabel> mDayLabelsW;
305 QPtrVector<KOWeekButton> mWeekLabelsW; 305 QPtrVector<KOWeekButton> mWeekLabelsW;
306 306
307 bool mShortDayLabelsM; 307 bool mShortDayLabelsM;
308 bool mShortDayLabelsW; 308 bool mShortDayLabelsW;
309 int mWidthLongDayLabel; 309 int mWidthLongDayLabel;
310 310
311 QDate mStartDate; 311 QDate mStartDate;
312 312
313 MonthViewCell *mSelectedCell; 313 MonthViewCell *mSelectedCell;
314 314 bool mFlagKeyPressed;
315 KOEventPopupMenu *mContextMenu; 315 KOEventPopupMenu *mContextMenu;
316 void keyPressEvent ( QKeyEvent * ) ; 316 void keyPressEvent ( QKeyEvent * ) ;
317 void keyReleaseEvent ( QKeyEvent * ) ;
317 318
318}; 319};
319 320
320#endif 321#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index ae03a09..09a0880 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -105,164 +105,175 @@ class KOex2phonePrefs : public QDialog
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 if ( p->mHourSize > 22 ) 148 if ( p->mHourSize > 22 )
149 p->mHourSize = 22; 149 p->mHourSize = 22;
150 QMainWindow::ToolBarDock tbd; 150 QMainWindow::ToolBarDock tbd;
151 if ( p->mToolBarHor ) { 151 if ( p->mToolBarHor ) {
152 if ( p->mToolBarUp ) 152 if ( p->mToolBarUp )
153 tbd = Bottom; 153 tbd = Bottom;
154 else 154 else
155 tbd = Top; 155 tbd = Top;
156 } 156 }
157 else { 157 else {
158 if ( p->mToolBarUp ) 158 if ( p->mToolBarUp )
159 tbd = Right; 159 tbd = Right;
160 else 160 else
161 tbd = Left; 161 tbd = Left;
162 } 162 }
163 if ( KOPrefs::instance()->mUseAppColors ) 163 if ( KOPrefs::instance()->mUseAppColors )
164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
165 globalFlagBlockStartup = 1; 165 globalFlagBlockStartup = 1;
166 iconToolBar = new QPEToolBar( this ); 166 iconToolBar = new QPEToolBar( this );
167 addToolBar (iconToolBar , tbd ); 167 addToolBar (iconToolBar , tbd );
168 168
169 if ( KOPrefs::instance()->mShowIconFilter ) { 169#ifdef DESKTOP_VERSION
170 if ( KOPrefs::instance()->mShowIconFilter )
171#else
172 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
173#endif
174
175{
170 if ( p->mToolBarHorF ) { 176 if ( p->mToolBarHorF ) {
171 if ( p->mToolBarUpF ) 177 if ( p->mToolBarUpF )
172 tbd = Bottom; 178 tbd = Bottom;
173 else 179 else
174 tbd = Top; 180 tbd = Top;
175 } 181 }
176 else { 182 else {
177 if ( p->mToolBarUpF ) 183 if ( p->mToolBarUpF )
178 tbd = Right; 184 tbd = Right;
179 else 185 else
180 tbd = Left; 186 tbd = Left;
181 } 187 }
182 filterToolBar = new QPEToolBar ( this ); 188 filterToolBar = new QPEToolBar ( this );
183 filterMenubar = new QPEMenuBar( filterToolBar ); 189 filterMenubar = new QPEMenuBar( filterToolBar );
184 QFontMetrics fm ( filterMenubar->font() ); 190 QFontMetrics fm ( filterMenubar->font() );
185 191
186 filterPopupMenu = new QPopupMenu( this ); 192 filterPopupMenu = new QPopupMenu( this );
187 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 193 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
188 QString addTest = "Ax"; 194 QString addTest = "Ax";
189#ifdef DESKTOP_VERSION 195#ifdef DESKTOP_VERSION
190 addTest = "AAAx"; 196 addTest = "AAAx";
191#endif 197#endif
192 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); 198 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) );
193 addToolBar (filterToolBar , tbd ); 199 addToolBar (filterToolBar , tbd );
194 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 200 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
195 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 201 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
202 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
203 filterToolBar->hide();
196 } else { 204 } else {
197 filterToolBar = 0; 205 filterToolBar = 0;
198 filterMenubar = 0; 206 filterMenubar = 0;
199 filterPopupMenu = 0; 207 filterPopupMenu = 0;
200 } 208 }
201 if ( p->mShowIconOnetoolbar ) { 209 if ( p->mShowIconOnetoolbar ) {
202 viewToolBar = iconToolBar ; 210 viewToolBar = iconToolBar ;
203 navigatorToolBar = iconToolBar ; 211 navigatorToolBar = iconToolBar ;
204 } else { 212 } else {
213#ifndef DESKTOP_VERSION
214 setToolBarsMovable( false );
215#endif
205 if ( p->mToolBarHorV ) { 216 if ( p->mToolBarHorV ) {
206 if ( p->mToolBarUpV ) 217 if ( p->mToolBarUpV )
207 tbd = Bottom; 218 tbd = Bottom;
208 else 219 else
209 tbd = Top; 220 tbd = Top;
210 } 221 }
211 else { 222 else {
212 if ( p->mToolBarUpV ) 223 if ( p->mToolBarUpV )
213 tbd = Right; 224 tbd = Right;
214 else 225 else
215 tbd = Left; 226 tbd = Left;
216 } 227 }
217 viewToolBar = new QPEToolBar( this ); 228 viewToolBar = new QPEToolBar( this );
218 addToolBar (viewToolBar , tbd ); 229 addToolBar (viewToolBar , tbd );
219 if ( p->mToolBarHorN ) { 230 if ( p->mToolBarHorN ) {
220 if ( p->mToolBarUpN ) 231 if ( p->mToolBarUpN )
221 tbd = Bottom; 232 tbd = Bottom;
222 else 233 else
223 tbd = Top; 234 tbd = Top;
224 } 235 }
225 else { 236 else {
226 if ( p->mToolBarUpN ) 237 if ( p->mToolBarUpN )
227 tbd = Right; 238 tbd = Right;
228 else 239 else
229 tbd = Left; 240 tbd = Left;
230 } 241 }
231 navigatorToolBar = new QPEToolBar( this ); 242 navigatorToolBar = new QPEToolBar( this );
232 addToolBar (navigatorToolBar , tbd ); 243 addToolBar (navigatorToolBar , tbd );
233 } 244 }
234 245
235 246
236 247
237 mCalendarModifiedFlag = false; 248 mCalendarModifiedFlag = false;
238 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 249 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
239 splash->setAlignment ( AlignCenter ); 250 splash->setAlignment ( AlignCenter );
240 setCentralWidget( splash ); 251 setCentralWidget( splash );
241#ifndef DESKTOP_VERSION 252#ifndef DESKTOP_VERSION
242 showMaximized(); 253 showMaximized();
243#endif 254#endif
244 255
245 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 256 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
246 setDefaultPreferences(); 257 setDefaultPreferences();
247 mCalendar = new CalendarLocal(); 258 mCalendar = new CalendarLocal();
248 mView = new CalendarView( mCalendar, this,"mCalendar " ); 259 mView = new CalendarView( mCalendar, this,"mCalendar " );
249 mView->hide(); 260 mView->hide();
250 //mView->resize(splash->size() ); 261 //mView->resize(splash->size() );
251 initActions(); 262 initActions();
252 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 263 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
253 mSyncManager->setBlockSave(false); 264 mSyncManager->setBlockSave(false);
254 mView->setSyncManager(mSyncManager); 265 mView->setSyncManager(mSyncManager);
255#ifndef DESKTOP_VERSION 266#ifndef DESKTOP_VERSION
256 iconToolBar->show(); 267 iconToolBar->show();
257 qApp->processEvents(); 268 qApp->processEvents();
258#endif 269#endif
259 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 270 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
260 int vh = height() ; 271 int vh = height() ;
261 int vw = width(); 272 int vw = width();
262 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 273 //qDebug("Toolbar hei %d ",iconToolBar->height() );
263 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 274 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
264 vh -= iconToolBar->height(); 275 vh -= iconToolBar->height();
265 } else { 276 } else {
266 vw -= iconToolBar->height(); 277 vw -= iconToolBar->height();
267 } 278 }
268 //mView->setMaximumSize( splash->size() ); 279 //mView->setMaximumSize( splash->size() );
@@ -2349,64 +2360,77 @@ void MainWindow::getFile( bool success )
2349void MainWindow::printSel( ) 2360void MainWindow::printSel( )
2350{ 2361{
2351 mView->viewManager()->agendaView()->agenda()->printSelection(); 2362 mView->viewManager()->agendaView()->agenda()->printSelection();
2352} 2363}
2353 2364
2354void MainWindow::printCal() 2365void MainWindow::printCal()
2355{ 2366{
2356 mView->print();//mCp->showDialog(); 2367 mView->print();//mCp->showDialog();
2357} 2368}
2358 2369
2359 2370
2360#include "libkdepim/kdatepicker.h" 2371#include "libkdepim/kdatepicker.h"
2361#include <kdatetbl.h> 2372#include <kdatetbl.h>
2362 2373
2363void MainWindow::weekAction() 2374void MainWindow::weekAction()
2364{ 2375{
2365 int month; 2376 int month;
2366 KPopupFrame* popup = new KPopupFrame(this); 2377 KPopupFrame* popup = new KPopupFrame(this);
2367 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2378 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2368 // ----- 2379 // -----
2369 picker->resize(picker->sizeHint()); 2380 picker->resize(picker->sizeHint());
2370 popup->setMainWidget(picker); 2381 popup->setMainWidget(picker);
2371 picker->setFocus(); 2382 picker->setFocus();
2372 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2383 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2373 int x = 0; 2384 int x = 0;
2374 int y = iconToolBar->height(); 2385 int y = iconToolBar->height();
2375 int dX = 0; 2386 int dX = 0;
2376 int dY = 0; 2387 int dY = 0;
2377 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2388 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2378 if ( iconToolBar->y() > height()/2 ) { 2389 if ( iconToolBar->y() > height()/2 ) {
2379 dY = picker->sizeHint().height()+8; 2390 dY = picker->sizeHint().height()+8;
2380 y = 0; 2391 y = 0;
2381 } 2392 }
2382 } else { 2393 } else {
2383 if ( iconToolBar->x() > width()/2 ) { // right side 2394 if ( iconToolBar->x() > width()/2 ) { // right side
2384 x=0; 2395 x=0;
2385 dX= picker->sizeHint().width()+8; 2396 dX= picker->sizeHint().width()+8;
2386 y = 0; 2397 y = 0;
2387 } else { 2398 } else {
2388 x= iconToolBar->width(); 2399 x= iconToolBar->width();
2389 y = 0; 2400 y = 0;
2390 } 2401 }
2391 } 2402 }
2392 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2403 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2393 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2404 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2394 { 2405 {
2395 month = picker->getResult(); 2406 month = picker->getResult();
2396 emit selectWeek ( month ); 2407 emit selectWeek ( month );
2397 //qDebug("weekSelected %d ", month); 2408 //qDebug("weekSelected %d ", month);
2398 } 2409 }
2399 delete popup; 2410 delete popup;
2400} 2411}
2401 2412
2402void MainWindow::hideEvent ( QHideEvent * ) 2413void MainWindow::hideEvent ( QHideEvent * )
2403{ 2414{
2404 QString message; 2415 QString message;
2405 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2416 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2406 if ( nextA.isValid() ) { 2417 if ( nextA.isValid() ) {
2407 QString sum = mCalendar->nextSummary(); 2418 QString sum = mCalendar->nextSummary();
2408 2419
2409 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2420 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2410 setCaption( message ); 2421 setCaption( message );
2411 } 2422 }
2412} 2423}
2424
2425void MainWindow::resizeEvent( QResizeEvent* e)
2426{
2427#ifndef DESKTOP_VERSION
2428 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar ) {
2429 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2430 filterToolBar->hide();
2431 else
2432 filterToolBar->show();
2433 }
2434#endif
2435 QMainWindow::resizeEvent( e);
2436}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7c16aeb..4d1753f 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -72,101 +72,102 @@ class MainWindow : public QMainWindow
72 void whatsNew(); 72 void whatsNew();
73 void keyBindings(); 73 void keyBindings();
74 void aboutAutoSaving();; 74 void aboutAutoSaving();;
75 void aboutKnownBugs(); 75 void aboutKnownBugs();
76 76
77 void processIncidenceSelection( Incidence * ); 77 void processIncidenceSelection( Incidence * );
78 78
79 void importQtopia(); 79 void importQtopia();
80 void importBday(); 80 void importBday();
81 void importOL(); 81 void importOL();
82 void importIcal(); 82 void importIcal();
83 void importFile( QString, bool ); 83 void importFile( QString, bool );
84 void quickImportIcal(); 84 void quickImportIcal();
85 85
86 void slotModifiedChanged( bool ); 86 void slotModifiedChanged( bool );
87 87
88 void save(); 88 void save();
89 void saveStopTimer(); 89 void saveStopTimer();
90 void configureToolBar( int ); 90 void configureToolBar( int );
91 void printSel(); 91 void printSel();
92 void printCal(); 92 void printCal();
93 void saveCalendar(); 93 void saveCalendar();
94 void loadCalendar(); 94 void loadCalendar();
95 void exportVCalendar(); 95 void exportVCalendar();
96 void fillFilterMenu(); 96 void fillFilterMenu();
97 void fillFilterMenuTB(); 97 void fillFilterMenuTB();
98 void selectFilter( int ); 98 void selectFilter( int );
99 void fillFilterMenuPopup(); 99 void fillFilterMenuPopup();
100 void selectFilterPopup( int ); 100 void selectFilterPopup( int );
101 void exportToPhone( int ); 101 void exportToPhone( int );
102 void toggleBeamReceive(); 102 void toggleBeamReceive();
103 void disableBR(bool); 103 void disableBR(bool);
104 signals: 104 signals:
105 void selectWeek ( int ); 105 void selectWeek ( int );
106 private slots: 106 private slots:
107 void showConfigureAgenda(); 107 void showConfigureAgenda();
108 void getFile( bool ); 108 void getFile( bool );
109 void syncFileRequest(); 109 void syncFileRequest();
110 110
111 protected: 111 protected:
112 void hideEvent ( QHideEvent * ); 112 void hideEvent ( QHideEvent * );
113 QString sentSyncFile(); 113 QString sentSyncFile();
114 void displayText( QString, QString); 114 void displayText( QString, QString);
115 void enableIncidenceActions( bool ); 115 void enableIncidenceActions( bool );
116 116
117 private: 117 private:
118 bool mBRdisabled; 118 bool mBRdisabled;
119#ifndef DESKTOP_VERSION 119#ifndef DESKTOP_VERSION
120 QCopChannel* infrared; 120 QCopChannel* infrared;
121#endif 121#endif
122 QAction* brAction; 122 QAction* brAction;
123 KSyncManager* mSyncManager; 123 KSyncManager* mSyncManager;
124 bool mClosed; 124 bool mClosed;
125 void saveOnClose(); 125 void saveOnClose();
126 bool mFlagKeyPressed; 126 bool mFlagKeyPressed;
127 bool mBlockAtStartup; 127 bool mBlockAtStartup;
128 QPEToolBar *iconToolBar; 128 QPEToolBar *iconToolBar;
129 QPEToolBar *viewToolBar; 129 QPEToolBar *viewToolBar;
130 QPEToolBar *navigatorToolBar; 130 QPEToolBar *navigatorToolBar;
131 QPEToolBar *filterToolBar; 131 QPEToolBar *filterToolBar;
132 QPEMenuBar *filterMenubar; 132 QPEMenuBar *filterMenubar;
133 QPopupMenu * filterPopupMenu; 133 QPopupMenu * filterPopupMenu;
134 void initActions(); 134 void initActions();
135 void setDefaultPreferences(); 135 void setDefaultPreferences();
136 void resizeEvent( QResizeEvent* e);
136 void keyPressEvent ( QKeyEvent * ) ; 137 void keyPressEvent ( QKeyEvent * ) ;
137 void keyReleaseEvent ( QKeyEvent * ) ; 138 void keyReleaseEvent ( QKeyEvent * ) ;
138 QPopupMenu *configureToolBarMenu; 139 QPopupMenu *configureToolBarMenu;
139 QPopupMenu *selectFilterMenu; 140 QPopupMenu *selectFilterMenu;
140 QPopupMenu *selectFilterMenuTB; 141 QPopupMenu *selectFilterMenuTB;
141 QPopupMenu *configureAgendaMenu, *syncMenu; 142 QPopupMenu *configureAgendaMenu, *syncMenu;
142 CalendarLocal *mCalendar; 143 CalendarLocal *mCalendar;
143 CalendarView *mView; 144 CalendarView *mView;
144 QAction *mNewSubTodoAction; 145 QAction *mNewSubTodoAction;
145 QAction *mWeekAction; 146 QAction *mWeekAction;
146 QFont mWeekFont; 147 QFont mWeekFont;
147 QPixmap mWeekPixmap; 148 QPixmap mWeekPixmap;
148 QColor mWeekBgColor; 149 QColor mWeekBgColor;
149 150
150 QAction *mShowAction; 151 QAction *mShowAction;
151 QAction *mEditAction; 152 QAction *mEditAction;
152 QAction *mDeleteAction; 153 QAction *mDeleteAction;
153 QAction *mCloneAction; 154 QAction *mCloneAction;
154 QAction *mMoveAction; 155 QAction *mMoveAction;
155 QAction *mBeamAction; 156 QAction *mBeamAction;
156 QAction *mCancelAction; 157 QAction *mCancelAction;
157 158
158 QAction *mToggleNav; 159 QAction *mToggleNav;
159 QAction *mToggleFilter; 160 QAction *mToggleFilter;
160 QAction *mToggleAllday; 161 QAction *mToggleAllday;
161 QAction *actionFilterMenuTB; 162 QAction *actionFilterMenuTB;
162 163
163 void closeEvent( QCloseEvent* ce ); 164 void closeEvent( QCloseEvent* ce );
164 SimpleAlarmClient mAlarmClient; 165 SimpleAlarmClient mAlarmClient;
165 QTimer mSaveTimer; 166 QTimer mSaveTimer;
166 //bool mBlockSaveFlag; 167 //bool mBlockSaveFlag;
167 bool mCalendarModifiedFlag; 168 bool mCalendarModifiedFlag;
168 QPixmap loadPixmap( QString ); 169 QPixmap loadPixmap( QString );
169}; 170};
170 171
171 172
172#endif 173#endif