summaryrefslogtreecommitdiff
path: root/core/pim
authoralwin <alwin>2004-03-02 12:14:15 (UTC)
committer alwin <alwin>2004-03-02 12:14:15 (UTC)
commit0d59c780513da78033f4d9040475dee9db0256d4 (patch) (unidiff)
tree503d320b4aa3daae9982082e7b34e3e2c48bdfb7 /core/pim
parenta0981652d61776d70f25980f035748b21339e946 (diff)
downloadopie-0d59c780513da78033f4d9040475dee9db0256d4.zip
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.gz
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.bz2
run the optimize_connect script
the whole cvs is tagged with "before_optimize_connect" if there are problems you can check the diff (but it had compiled and run here)
Diffstat (limited to 'core/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp2
-rw-r--r--core/pim/addressbook/abview.cpp8
-rw-r--r--core/pim/addressbook/addressbook.cpp20
-rw-r--r--core/pim/addressbook/contacteditor.cpp60
-rw-r--r--core/pim/datebook/datebook.cpp36
-rw-r--r--core/pim/datebook/datebookday.cpp16
-rw-r--r--core/pim/datebook/datebookdayallday.cpp2
-rw-r--r--core/pim/datebook/datebookdayheaderimpl.cpp4
-rw-r--r--core/pim/datebook/datebooksettings.cpp2
-rw-r--r--core/pim/datebook/datebookweek.cpp4
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp2
-rw-r--r--core/pim/datebook/datebookweeklst.cpp28
-rw-r--r--core/pim/datebook/dateentryimpl.cpp20
-rw-r--r--core/pim/datebook/repeatentry.cpp4
-rw-r--r--core/pim/datebook2/mainwindow.cpp12
-rw-r--r--core/pim/osearch/mainwindow.cpp2
-rw-r--r--core/pim/today/plugins/addressbook/addresspluginwidget.cpp4
-rw-r--r--core/pim/today/plugins/datebook/datebookpluginwidget.cpp4
-rw-r--r--core/pim/today/plugins/mail/mailpluginwidget.cpp4
-rw-r--r--core/pim/today/today.cpp4
-rw-r--r--core/pim/today/todayconfig.cpp2
-rw-r--r--core/pim/todo/mainwindow.cpp2
-rw-r--r--core/pim/todo/otaskeditor.cpp2
-rw-r--r--core/pim/todo/tableview.cpp16
-rw-r--r--core/pim/todo/taskeditoralarms.cpp4
-rw-r--r--core/pim/todo/taskeditorstatus.cpp12
26 files changed, 137 insertions, 139 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index f7bff58..29f4383 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -34,193 +34,193 @@
34#include <stdlib.h> 34#include <stdlib.h>
35 35
36#include <ctype.h> //toupper() for key hack 36#include <ctype.h> //toupper() for key hack
37 37
38#if 0 38#if 0
39 39
40/*! 40/*!
41 \class AbTableItem abtable.h 41 \class AbTableItem abtable.h
42 42
43 \brief QTableItem based class for showing a field of an entry 43 \brief QTableItem based class for showing a field of an entry
44*/ 44*/
45 45
46AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 46AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
47 const QString &secondSortKey) 47 const QString &secondSortKey)
48 : QTableItem( t, et, s ) 48 : QTableItem( t, et, s )
49{ 49{
50 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); 50 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
51 sortKey = Qtopia::buildSortKey( s, secondSortKey ); 51 sortKey = Qtopia::buildSortKey( s, secondSortKey );
52} 52}
53 53
54int AbTableItem::alignment() const 54int AbTableItem::alignment() const
55{ 55{
56 return AlignLeft|AlignVCenter; 56 return AlignLeft|AlignVCenter;
57} 57}
58 58
59QString AbTableItem::key() const 59QString AbTableItem::key() const
60{ 60{
61 return sortKey; 61 return sortKey;
62} 62}
63 63
64// A way to reset the item, without out doing a delete or a new... 64// A way to reset the item, without out doing a delete or a new...
65void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 65void AbTableItem::setItem( const QString &txt, const QString &secondKey )
66{ 66{
67 setText( txt ); 67 setText( txt );
68 sortKey = Qtopia::buildSortKey( txt, secondKey ); 68 sortKey = Qtopia::buildSortKey( txt, secondKey );
69 69
70 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); 70 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
71} 71}
72 72
73/*! 73/*!
74 \class AbPickItem abtable.h 74 \class AbPickItem abtable.h
75 75
76 \brief QTableItem based class for showing slection of an entry 76 \brief QTableItem based class for showing slection of an entry
77*/ 77*/
78 78
79AbPickItem::AbPickItem( QTable *t ) : 79AbPickItem::AbPickItem( QTable *t ) :
80 QTableItem(t, WhenCurrent, "?") 80 QTableItem(t, WhenCurrent, "?")
81{ 81{
82} 82}
83 83
84QWidget *AbPickItem::createEditor() const 84QWidget *AbPickItem::createEditor() const
85{ 85{
86 QComboBox* combo = new QComboBox( table()->viewport() ); 86 QComboBox* combo = new QComboBox( table()->viewport() );
87 ( (AbPickItem*)this )->cb = combo; 87 ( (AbPickItem*)this )->cb = combo;
88 AbTable* t = static_cast<AbTable*>(table()); 88 AbTable* t = static_cast<AbTable*>(table());
89 QStringList c = t->choiceNames(); 89 QStringList c = t->choiceNames();
90 int cur = 0; 90 int cur = 0;
91 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { 91 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
92 if ( *it == text() ) 92 if ( *it == text() )
93 cur = combo->count(); 93 cur = combo->count();
94 combo->insertItem(*it); 94 combo->insertItem(*it);
95 } 95 }
96 combo->setCurrentItem(cur); 96 combo->setCurrentItem(cur);
97 return combo; 97 return combo;
98} 98}
99 99
100void AbPickItem::setContentFromEditor( QWidget *w ) 100void AbPickItem::setContentFromEditor( QWidget *w )
101{ 101{
102 if ( w->inherits("QComboBox") ) 102 if ( w->inherits("QComboBox") )
103 setText( ( (QComboBox*)w )->currentText() ); 103 setText( ( (QComboBox*)w )->currentText() );
104 else 104 else
105 QTableItem::setContentFromEditor( w ); 105 QTableItem::setContentFromEditor( w );
106} 106}
107 107
108#endif 108#endif
109 109
110/*! 110/*!
111 \class AbTable abtable.h 111 \class AbTable abtable.h
112 112
113 \brief QTable based class for showing a list of entries 113 \brief QTable based class for showing a list of entries
114*/ 114*/
115 115
116AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) 116AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
117 : QTable( parent, name ), 117 : QTable( parent, name ),
118 lastSortCol( -1 ), 118 lastSortCol( -1 ),
119 asc( TRUE ), 119 asc( TRUE ),
120 intFields( order ), 120 intFields( order ),
121 enablePainting( true ), 121 enablePainting( true ),
122 columnVisible( true ), 122 columnVisible( true ),
123 countNested( 0 ) 123 countNested( 0 )
124{ 124{
125 //qWarning("C'tor start"); 125 //qWarning("C'tor start");
126 126
127 setSelectionMode( NoSelection ); 127 setSelectionMode( NoSelection );
128 init(); 128 init();
129 setSorting( TRUE ); 129 setSorting( TRUE );
130 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 130 connect( this, SIGNAL(clicked(int,int,int,const QPoint&)),
131 this, SLOT(itemClicked(int,int)) ); 131 this, SLOT(itemClicked(int,int)) );
132 132
133 // contactList.clear(); 133 // contactList.clear();
134 //qWarning("C'tor end"); 134 //qWarning("C'tor end");
135} 135}
136 136
137AbTable::~AbTable() 137AbTable::~AbTable()
138{ 138{
139} 139}
140 140
141void AbTable::init() 141void AbTable::init()
142{ 142{
143 // :SX showChar = '\0'; 143 // :SX showChar = '\0';
144 setNumRows( 0 ); 144 setNumRows( 0 );
145 setNumCols( 2 ); 145 setNumCols( 2 );
146 146
147 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 147 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
148 horizontalHeader()->setLabel( 1, tr( "Contact" )); 148 horizontalHeader()->setLabel( 1, tr( "Contact" ));
149 setLeftMargin( 0 ); 149 setLeftMargin( 0 );
150 verticalHeader()->hide(); 150 verticalHeader()->hide();
151 columnVisible = true; 151 columnVisible = true;
152} 152}
153 153
154void AbTable::setContacts( const OContactAccess::List& viewList ) 154void AbTable::setContacts( const OContactAccess::List& viewList )
155{ 155{
156 qWarning("AbTable::setContacts()"); 156 qWarning("AbTable::setContacts()");
157 157
158 clear(); 158 clear();
159 m_viewList = viewList; 159 m_viewList = viewList;
160 160
161 setSorting( false ); 161 setSorting( false );
162 setPaintingEnabled( FALSE ); 162 setPaintingEnabled( FALSE );
163 163
164 OContactAccess::List::Iterator it; 164 OContactAccess::List::Iterator it;
165 setNumRows( m_viewList.count() ); 165 setNumRows( m_viewList.count() );
166 //int row = 0; 166 //int row = 0;
167 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 167 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
168 // insertIntoTable( *it, row++ ); 168 // insertIntoTable( *it, row++ );
169 169
170 // setSorting( true ); 170 // setSorting( true );
171 171
172 // resort(); 172 // resort();
173 173
174 updateVisible(); 174 updateVisible();
175 175
176 setPaintingEnabled( TRUE ); 176 setPaintingEnabled( TRUE );
177 177
178} 178}
179 179
180void AbTable::setOrderedList( const QValueList<int> ordered ) 180void AbTable::setOrderedList( const QValueList<int> ordered )
181{ 181{
182 intFields = ordered; 182 intFields = ordered;
183} 183}
184 184
185 185
186bool AbTable::selectContact( int UID ) 186bool AbTable::selectContact( int UID )
187{ 187{
188 qWarning( "AbTable::selectContact( %d )", UID ); 188 qWarning( "AbTable::selectContact( %d )", UID );
189 int rows = numRows(); 189 int rows = numRows();
190 OContact* foundContact = 0l; 190 OContact* foundContact = 0l;
191 bool found = false; 191 bool found = false;
192 192
193 setPaintingEnabled( FALSE ); 193 setPaintingEnabled( FALSE );
194 qWarning( "search start" ); 194 qWarning( "search start" );
195 for ( int r = 0; r < rows; ++r ) { 195 for ( int r = 0; r < rows; ++r ) {
196 if ( m_viewList.uidAt( r ) == UID ){ 196 if ( m_viewList.uidAt( r ) == UID ){
197 ensureCellVisible( r, 0 ); 197 ensureCellVisible( r, 0 );
198 setCurrentCell( r, 0 ); 198 setCurrentCell( r, 0 );
199 found = true; 199 found = true;
200 break; 200 break;
201 } 201 }
202 } 202 }
203 qWarning( "search end" ); 203 qWarning( "search end" );
204 204
205 if ( !found ){ 205 if ( !found ){
206 ensureCellVisible( 0,0 ); 206 ensureCellVisible( 0,0 );
207 setCurrentCell( 0, 0 ); 207 setCurrentCell( 0, 0 );
208 } 208 }
209 209
210 setPaintingEnabled( TRUE ); 210 setPaintingEnabled( TRUE );
211 211
212 return true; 212 return true;
213} 213}
214 214
215#if 0 215#if 0
216void AbTable::insertIntoTable( const OContact& cnt, int row ) 216void AbTable::insertIntoTable( const OContact& cnt, int row )
217{ 217{
218 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); 218 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
219 QString strName; 219 QString strName;
220 ContactItem contactItem; 220 ContactItem contactItem;
221 221
222 strName = findContactName( cnt ); 222 strName = findContactName( cnt );
223 contactItem = findContactContact( cnt, row ); 223 contactItem = findContactContact( cnt, row );
224 224
225 AbTableItem *ati; 225 AbTableItem *ati;
226 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); 226 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value );
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 670cdb0..8d61582 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,179 +1,179 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** 14**
15**********************************************************************/ 15**********************************************************************/
16 16
17#include "abview.h" 17#include "abview.h"
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20 20
21#include <qpe/global.h> 21#include <qpe/global.h>
22 22
23#include <opie/ocontactaccessbackend_vcard.h> 23#include <opie/ocontactaccessbackend_vcard.h>
24 24
25#include <assert.h> 25#include <assert.h>
26 26
27 27
28// Is defined in LibQPE 28// Is defined in LibQPE
29extern QString categoryFileName(); 29extern QString categoryFileName();
30 30
31QString addressbookPersonalVCardName() 31QString addressbookPersonalVCardName()
32{ 32{
33 QString filename = Global::applicationFileName("addressbook", 33 QString filename = Global::applicationFileName("addressbook",
34 "businesscard.vcf"); 34 "businesscard.vcf");
35 return filename; 35 return filename;
36} 36}
37 37
38 38
39AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): 39AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
40 QWidget(parent), 40 QWidget(parent),
41 mCat(0), 41 mCat(0),
42 m_inSearch( false ), 42 m_inSearch( false ),
43 m_inPersonal( false ), 43 m_inPersonal( false ),
44 m_curr_category( -1 ), 44 m_curr_category( -1 ),
45 m_curr_View( TableView ), 45 m_curr_View( TableView ),
46 m_prev_View( TableView ), 46 m_prev_View( TableView ),
47 m_curr_Contact ( 0 ), 47 m_curr_Contact ( 0 ),
48 m_contactdb ( 0l ), 48 m_contactdb ( 0l ),
49 m_storedDB ( 0l ), 49 m_storedDB ( 0l ),
50 m_viewStack( 0l ), 50 m_viewStack( 0l ),
51 m_abTable( 0l ), 51 m_abTable( 0l ),
52 m_orderedFields( ordered ) 52 m_orderedFields( ordered )
53{ 53{
54 qWarning("AbView::c'tor"); 54 qWarning("AbView::c'tor");
55 // Load default database and handle syncing myself.. ! 55 // Load default database and handle syncing myself.. !
56 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ); 56 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false );
57 m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available 57 m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available
58 mCat.load( categoryFileName() ); 58 mCat.load( categoryFileName() );
59 59
60 // Create Layout and put WidgetStack into it. 60 // Create Layout and put WidgetStack into it.
61 QVBoxLayout *vb = new QVBoxLayout( this ); 61 QVBoxLayout *vb = new QVBoxLayout( this );
62 m_viewStack = new QWidgetStack( this ); 62 m_viewStack = new QWidgetStack( this );
63 vb->addWidget( m_viewStack ); 63 vb->addWidget( m_viewStack );
64 64
65 // Creat TableView 65 // Creat TableView
66 QVBox* tableBox = new QVBox( m_viewStack ); 66 QVBox* tableBox = new QVBox( m_viewStack );
67 m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); 67 m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
68 m_abTable->setCurrentCell( 0, 0 ); 68 m_abTable->setCurrentCell( 0, 0 );
69 m_abTable->setFocus(); 69 m_abTable->setFocus();
70 70
71 // Add TableView to WidgetStack and raise it 71 // Add TableView to WidgetStack and raise it
72 m_viewStack -> addWidget( tableBox , TableView ); 72 m_viewStack -> addWidget( tableBox , TableView );
73 73
74 // Create CardView and add it to WidgetStack 74 // Create CardView and add it to WidgetStack
75 QVBox* cardBox = new QVBox( m_viewStack ); 75 QVBox* cardBox = new QVBox( m_viewStack );
76 m_ablabel = new AbLabel( cardBox, "CardView"); 76 m_ablabel = new AbLabel( cardBox, "CardView");
77 m_viewStack -> addWidget( cardBox , CardView ); 77 m_viewStack -> addWidget( cardBox , CardView );
78 78
79 // Connect views to me 79 // Connect views to me
80 connect ( m_abTable, SIGNAL( signalSwitch( void ) ), 80 connect ( m_abTable, SIGNAL( signalSwitch(void) ),
81 this, SLOT( slotSwitch( void ) ) ); 81 this, SLOT( slotSwitch(void) ) );
82 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), 82 connect ( m_ablabel, SIGNAL( signalOkPressed(void) ),
83 this, SLOT( slotSwitch( void ) ) ); 83 this, SLOT( slotSwitch(void) ) );
84 84
85 load(); 85 load();
86} 86}
87 87
88AbView::~AbView() 88AbView::~AbView()
89{ 89{
90 m_contactdb -> save(); 90 m_contactdb -> save();
91 delete m_contactdb; 91 delete m_contactdb;
92 92
93 if ( m_storedDB ){ 93 if ( m_storedDB ){
94 m_storedDB -> save(); 94 m_storedDB -> save();
95 delete m_storedDB; 95 delete m_storedDB;
96 } 96 }
97} 97}
98 98
99 99
100void AbView::setView( Views view ) 100void AbView::setView( Views view )
101{ 101{
102 qWarning("AbView::setView( Views view )"); 102 qWarning("AbView::setView( Views view )");
103 m_curr_View = view; 103 m_curr_View = view;
104 load(); 104 load();
105} 105}
106 106
107void AbView::addEntry( const OContact &newContact ) 107void AbView::addEntry( const OContact &newContact )
108{ 108{
109 qWarning("abview:AddContact"); 109 qWarning("abview:AddContact");
110 m_contactdb->add ( newContact ); 110 m_contactdb->add ( newContact );
111 load(); 111 load();
112 112
113} 113}
114void AbView::removeEntry( const int UID ) 114void AbView::removeEntry( const int UID )
115{ 115{
116 qWarning("abview:RemoveContact"); 116 qWarning("abview:RemoveContact");
117 m_contactdb->remove( UID ); 117 m_contactdb->remove( UID );
118 load(); 118 load();
119} 119}
120 120
121void AbView::replaceEntry( const OContact &contact ) 121void AbView::replaceEntry( const OContact &contact )
122{ 122{
123 qWarning("abview:ReplaceContact"); 123 qWarning("abview:ReplaceContact");
124 m_contactdb->replace( contact ); 124 m_contactdb->replace( contact );
125 load(); 125 load();
126 126
127} 127}
128 128
129OContact AbView::currentEntry() 129OContact AbView::currentEntry()
130{ 130{
131 OContact currentContact; 131 OContact currentContact;
132 132
133 switch ( (int) m_curr_View ) { 133 switch ( (int) m_curr_View ) {
134 case TableView: 134 case TableView:
135 currentContact = m_abTable -> currentEntry(); 135 currentContact = m_abTable -> currentEntry();
136 break; 136 break;
137 case CardView: 137 case CardView:
138 currentContact = m_ablabel -> currentEntry(); 138 currentContact = m_ablabel -> currentEntry();
139 break; 139 break;
140 } 140 }
141 m_curr_Contact = currentContact.uid(); 141 m_curr_Contact = currentContact.uid();
142 return currentContact; 142 return currentContact;
143} 143}
144 144
145bool AbView::save() 145bool AbView::save()
146{ 146{
147 //qWarning("abView:Save data"); 147 //qWarning("abView:Save data");
148 148
149 return m_contactdb->save(); 149 return m_contactdb->save();
150} 150}
151 151
152void AbView::load() 152void AbView::load()
153{ 153{
154 qWarning("abView:Load data"); 154 qWarning("abView:Load data");
155 155
156 // Letter Search is stopped at this place 156 // Letter Search is stopped at this place
157 emit signalClearLetterPicker(); 157 emit signalClearLetterPicker();
158 158
159 if ( m_inPersonal ) 159 if ( m_inPersonal )
160 // VCard Backend does not sort.. 160 // VCard Backend does not sort..
161 m_list = m_contactdb->allRecords(); 161 m_list = m_contactdb->allRecords();
162 else{ 162 else{
163 m_list = m_contactdb->sorted( true, 0, 0, 0 ); 163 m_list = m_contactdb->sorted( true, 0, 0, 0 );
164 if ( m_curr_category != -1 ) 164 if ( m_curr_category != -1 )
165 clearForCategory(); 165 clearForCategory();
166 } 166 }
167 167
168 qWarning ("Number of contacts: %d", m_list.count()); 168 qWarning ("Number of contacts: %d", m_list.count());
169 169
170 updateView( true ); 170 updateView( true );
171 171
172} 172}
173 173
174void AbView::reload() 174void AbView::reload()
175{ 175{
176 qWarning( "void AbView::reload()" ); 176 qWarning( "void AbView::reload()" );
177 177
178 m_contactdb->reload(); 178 m_contactdb->reload();
179 load(); 179 load();
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 9cf55b3..8a5f9d5 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -42,313 +42,313 @@
42#include <qtoolbutton.h> 42#include <qtoolbutton.h>
43 43
44#include <stdlib.h> 44#include <stdlib.h>
45#include <sys/stat.h> 45#include <sys/stat.h>
46#include <sys/types.h> 46#include <sys/types.h>
47#include <fcntl.h> 47#include <fcntl.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50 50
51#include "picker.h" 51#include "picker.h"
52#include "configdlg.h" 52#include "configdlg.h"
53 53
54extern QString addressbookPersonalVCardName(); 54extern QString addressbookPersonalVCardName();
55 55
56AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 56AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
57 WFlags f ) 57 WFlags f )
58 : QMainWindow( parent, name, f ), 58 : QMainWindow( parent, name, f ),
59 catMenu (0l), 59 catMenu (0l),
60 abEditor(0l), 60 abEditor(0l),
61 syncing(FALSE), 61 syncing(FALSE),
62 m_tableViewButton(0l), 62 m_tableViewButton(0l),
63 m_cardViewButton(0l) 63 m_cardViewButton(0l)
64{ 64{
65 isLoading = true; 65 isLoading = true;
66 66
67 m_config.load(); 67 m_config.load();
68 68
69 setCaption( tr("Contacts") ); 69 setCaption( tr("Contacts") );
70 setIcon( Resource::loadPixmap( "AddressBook" ) ); 70 setIcon( Resource::loadPixmap( "AddressBook" ) );
71 71
72 // Settings for Main Menu 72 // Settings for Main Menu
73 // setToolBarsMovable( false ); 73 // setToolBarsMovable( false );
74 setToolBarsMovable( !m_config.fixedBars() ); 74 setToolBarsMovable( !m_config.fixedBars() );
75 setRightJustification( true ); 75 setRightJustification( true );
76 76
77 QToolBar *bar = new QToolBar( this ); 77 QToolBar *bar = new QToolBar( this );
78 bar->setHorizontalStretchable( TRUE ); 78 bar->setHorizontalStretchable( TRUE );
79 79
80 QMenuBar *mbList = new QMenuBar( bar ); 80 QMenuBar *mbList = new QMenuBar( bar );
81 mbList->setMargin( 0 ); 81 mbList->setMargin( 0 );
82 82
83 QPopupMenu *edit = new QPopupMenu( mbList ); 83 QPopupMenu *edit = new QPopupMenu( mbList );
84 mbList->insertItem( tr( "Contact" ), edit ); 84 mbList->insertItem( tr( "Contact" ), edit );
85 85
86 // Category Menu 86 // Category Menu
87 catMenu = new QPopupMenu( this ); 87 catMenu = new QPopupMenu( this );
88 catMenu->setCheckable( TRUE ); 88 catMenu->setCheckable( TRUE );
89 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 89 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
90 mbList->insertItem( tr("View"), catMenu ); 90 mbList->insertItem( tr("View"), catMenu );
91 91
92 // Create Toolbar 92 // Create Toolbar
93 listTools = new QToolBar( this, "list operations" ); 93 listTools = new QToolBar( this, "list operations" );
94 listTools->setHorizontalStretchable( true ); 94 listTools->setHorizontalStretchable( true );
95 addToolBar( listTools ); 95 addToolBar( listTools );
96 moveToolBar( listTools, m_config.getToolBarPos() ); 96 moveToolBar( listTools, m_config.getToolBarPos() );
97 97
98 // View Icons 98 // View Icons
99 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), 99 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ),
100 QString::null, 0, this, 0 ); 100 QString::null, 0, this, 0 );
101 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); 101 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
102 m_tableViewButton->setToggleAction( true ); 102 m_tableViewButton->setToggleAction( true );
103 m_tableViewButton->addTo( listTools ); 103 m_tableViewButton->addTo( listTools );
104 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); 104 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 );
105 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); 105 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
106 m_cardViewButton->setToggleAction( true ); 106 m_cardViewButton->setToggleAction( true );
107 m_cardViewButton->addTo( listTools ); 107 m_cardViewButton->addTo( listTools );
108 108
109 listTools->addSeparator(); 109 listTools->addSeparator();
110 110
111 // Other Buttons 111 // Other Buttons
112 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 112 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
113 0, this, 0 ); 113 0, this, 0 );
114 actionNew = a; 114 actionNew = a;
115 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 115 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
116 a->addTo( edit ); 116 a->addTo( edit );
117 a->addTo( listTools ); 117 a->addTo( listTools );
118 118
119 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 119 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
120 0, this, 0 ); 120 0, this, 0 );
121 actionEdit = a; 121 actionEdit = a;
122 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
123 a->addTo( edit ); 123 a->addTo( edit );
124 a->addTo( listTools ); 124 a->addTo( listTools );
125 125
126 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 126 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
127 0, this, 0 ); 127 0, this, 0 );
128 actionTrash = a; 128 actionTrash = a;
129 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 129 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
130 a->addTo( edit ); 130 a->addTo( edit );
131 a->addTo( listTools ); 131 a->addTo( listTools );
132 132
133 133
134 // make it possible to go directly to businesscard via qcop call 134 // make it possible to go directly to businesscard via qcop call
135 //#if defined(Q_WS_QWS) // Why this ? (se) 135 //#if defined(Q_WS_QWS) // Why this ? (se)
136#if !defined(QT_NO_COP) 136#if !defined(QT_NO_COP)
137 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); 137 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
138 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 138 connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)),
139 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 139 this, SLOT ( appMessage(const QCString&,const QByteArray&) ) );
140#endif 140#endif
141 // #endif 141 // #endif
142 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 142 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
143 QString::null, 0, this, 0 ); 143 QString::null, 0, this, 0 );
144 actionFind = a; 144 actionFind = a;
145 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); 145 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
146 a->addTo( edit ); 146 a->addTo( edit );
147 a->addTo( listTools ); 147 a->addTo( listTools );
148 148
149 // Much better search widget, taken from QTReader.. (se) 149 // Much better search widget, taken from QTReader.. (se)
150 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); 150 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
151 searchBar->setHorizontalStretchable( TRUE ); 151 searchBar->setHorizontalStretchable( TRUE );
152 searchBar->hide(); 152 searchBar->hide();
153 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 153 searchEdit = new QLineEdit( searchBar, "searchEdit" );
154 154
155 // QFont f("unifont", 16 /*, QFont::Bold*/); 155 // QFont f("unifont", 16 /*, QFont::Bold*/);
156 // searchEdit->setFont( f ); 156 // searchEdit->setFont( f );
157 157
158 searchBar->setStretchableWidget( searchEdit ); 158 searchBar->setStretchableWidget( searchEdit );
159 connect( searchEdit, SIGNAL( returnPressed( ) ), 159 connect( searchEdit, SIGNAL( returnPressed() ),
160 this, SLOT( slotFind( ) ) ); 160 this, SLOT( slotFind() ) );
161 161
162 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 162 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
163 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 163 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
164 a->addTo( searchBar ); 164 a->addTo( searchBar );
165 165
166 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 166 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
167 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 167 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
168 a->addTo( searchBar ); 168 a->addTo( searchBar );
169 169
170 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), 170 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ),
171 QString::null, 0, this, 0 ); 171 QString::null, 0, this, 0 );
172 //a->setEnabled( FALSE ); we got support for it now :) zecke 172 //a->setEnabled( FALSE ); we got support for it now :) zecke
173 actionMail = a; 173 actionMail = a;
174 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 174 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
175 a->addTo( edit ); 175 a->addTo( edit );
176 a->addTo( listTools ); 176 a->addTo( listTools );
177 177
178 if ( Ir::supported() ) { 178 if ( Ir::supported() ) {
179 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 179 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
180 0, this, 0 ); 180 0, this, 0 );
181 actionBeam = a; 181 actionBeam = a;
182 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 182 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
183 a->addTo( edit ); 183 a->addTo( edit );
184 a->addTo( listTools ); 184 a->addTo( listTools );
185 } 185 }
186 186
187 edit->insertSeparator(); 187 edit->insertSeparator();
188 188
189 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, 189 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null,
190 0, this, 0); 190 0, this, 0);
191 actionPersonal = a; 191 actionPersonal = a;
192 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 192 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
193 a->addTo( edit ); 193 a->addTo( edit );
194 194
195 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, 195 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null,
196 0, this, 0); 196 0, this, 0);
197 actionPersonal = a; 197 actionPersonal = a;
198 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) );
199 a->addTo( edit ); 199 a->addTo( edit );
200 200
201 edit->insertSeparator(); 201 edit->insertSeparator();
202 202
203 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), 203 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
204 QString::null, 0, this, 0 , TRUE ); 204 QString::null, 0, this, 0 , TRUE );
205 actionPersonal = a; 205 actionPersonal = a;
206 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
207 a->addTo( edit ); 207 a->addTo( edit );
208 208
209 209
210#ifdef __DEBUG_RELEASE 210#ifdef __DEBUG_RELEASE
211 // Remove this function for public Release ! This is only 211 // Remove this function for public Release ! This is only
212 // for debug purposes .. 212 // for debug purposes ..
213 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 213 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
214 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 214 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
215 a->addTo( edit ); 215 a->addTo( edit );
216#endif 216#endif
217 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 217 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null,
218 0, this, 0 ); 218 0, this, 0 );
219 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 219 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
220 a->addTo( edit ); 220 a->addTo( edit );
221 221
222 // Create Views 222 // Create Views
223 listContainer = new QWidget( this ); 223 listContainer = new QWidget( this );
224 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 224 QVBoxLayout *vb = new QVBoxLayout( listContainer );
225 225
226 m_abView = new AbView( listContainer, m_config.orderList() ); 226 m_abView = new AbView( listContainer, m_config.orderList() );
227 vb->addWidget( m_abView ); 227 vb->addWidget( m_abView );
228 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 228 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
229 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), 229 connect( m_abView, SIGNAL( signalViewSwitched(int) ),
230 this, SLOT( slotViewSwitched( int ) ) ); 230 this, SLOT( slotViewSwitched(int) ) );
231 231
232 232
233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
234 234
235 // m_abView->load(); // Already done by c'tor . 235 // m_abView->load(); // Already done by c'tor .
236 236
237 // Letter Picker 237 // Letter Picker
238 pLabel = new LetterPicker( listContainer ); 238 pLabel = new LetterPicker( listContainer );
239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); 240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
241 241
242 vb->addWidget( pLabel ); 242 vb->addWidget( pLabel );
243 243
244 // All Categories into view-menu.. 244 // All Categories into view-menu..
245 populateCategories(); 245 populateCategories();
246 246
247 // Fontsize 247 // Fontsize
248 defaultFont = new QFont( m_abView->font() ); 248 defaultFont = new QFont( m_abView->font() );
249 slotSetFont(m_config.fontSize()); 249 slotSetFont(m_config.fontSize());
250 m_curFontSize = m_config.fontSize(); 250 m_curFontSize = m_config.fontSize();
251 251
252 setCentralWidget(listContainer); 252 setCentralWidget(listContainer);
253 253
254 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 254 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
255 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 255 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
256 connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); 256 connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) );
257 connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), 257 connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
258 this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); 258 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
259 259
260 260
261 isLoading = false; 261 isLoading = false;
262} 262}
263 263
264 264
265void AddressbookWindow::slotConfig() 265void AddressbookWindow::slotConfig()
266{ 266{
267 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 267 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
268 dlg -> setConfig( m_config ); 268 dlg -> setConfig( m_config );
269 if ( QPEApplication::execDialog( dlg ) ) { 269 if ( QPEApplication::execDialog( dlg ) ) {
270 qWarning ("Config Dialog accepted!"); 270 qWarning ("Config Dialog accepted!");
271 m_config = dlg -> getConfig(); 271 m_config = dlg -> getConfig();
272 if ( m_curFontSize != m_config.fontSize() ){ 272 if ( m_curFontSize != m_config.fontSize() ){
273 qWarning("Font was changed!"); 273 qWarning("Font was changed!");
274 m_curFontSize = m_config.fontSize(); 274 m_curFontSize = m_config.fontSize();
275 emit slotSetFont( m_curFontSize ); 275 emit slotSetFont( m_curFontSize );
276 } 276 }
277 m_abView -> setListOrder( m_config.orderList() ); 277 m_abView -> setListOrder( m_config.orderList() );
278 } 278 }
279 279
280 delete dlg; 280 delete dlg;
281} 281}
282 282
283 283
284void AddressbookWindow::slotSetFont( int size ) 284void AddressbookWindow::slotSetFont( int size )
285{ 285{
286 qWarning("void AddressbookWindow::slotSetFont( %d )", size); 286 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
287 287
288 if (size > 2 || size < 0) 288 if (size > 2 || size < 0)
289 size = 1; 289 size = 1;
290 290
291 m_config.setFontSize( size ); 291 m_config.setFontSize( size );
292 292
293 QFont *currentFont; 293 QFont *currentFont;
294 294
295 switch (size) { 295 switch (size) {
296 case 0: 296 case 0:
297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
298 currentFont = new QFont (m_abView->font()); 298 currentFont = new QFont (m_abView->font());
299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
300 // abList->resizeRows(); 300 // abList->resizeRows();
301 break; 301 break;
302 case 1: 302 case 1:
303 m_abView->setFont( *defaultFont ); 303 m_abView->setFont( *defaultFont );
304 currentFont = new QFont (m_abView->font()); 304 currentFont = new QFont (m_abView->font());
305 // // abList->resizeRows(currentFont->pixelSize() + 7); 305 // // abList->resizeRows(currentFont->pixelSize() + 7);
306 // abList->resizeRows(); 306 // abList->resizeRows();
307 break; 307 break;
308 case 2: 308 case 2:
309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
310 currentFont = new QFont (m_abView->font()); 310 currentFont = new QFont (m_abView->font());
311 // //abList->resizeRows(currentFont->pixelSize() + 7); 311 // //abList->resizeRows(currentFont->pixelSize() + 7);
312 // abList->resizeRows(); 312 // abList->resizeRows();
313 break; 313 break;
314 } 314 }
315} 315}
316 316
317 317
318 318
319void AddressbookWindow::importvCard() { 319void AddressbookWindow::importvCard() {
320 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 320 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
321 if(!str.isEmpty() ){ 321 if(!str.isEmpty() ){
322 setDocument((const QString&) str ); 322 setDocument((const QString&) str );
323 } 323 }
324 324
325} 325}
326void AddressbookWindow::exportvCard() 326void AddressbookWindow::exportvCard()
327{ 327{
328 qWarning(" void AddressbookWindow::exportvCard()"); 328 qWarning(" void AddressbookWindow::exportvCard()");
329 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); 329 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this );
330 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ 330 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){
331 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); 331 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 );
332 OContact curCont = m_abView->currentEntry(); 332 OContact curCont = m_abView->currentEntry();
333 if ( !curCont.isEmpty() ){ 333 if ( !curCont.isEmpty() ){
334 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 334 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
335 filename ); 335 filename );
336 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); 336 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true );
337 if ( access ){ 337 if ( access ){
338 access->add( curCont ); 338 access->add( curCont );
339 access->save(); 339 access->save();
340 } 340 }
341 delete access; 341 delete access;
342 }else 342 }else
343 QMessageBox::critical( 0, "Export VCard", 343 QMessageBox::critical( 0, "Export VCard",
344 QString( tr( "You have to select a contact !") ) ); 344 QString( tr( "You have to select a contact !") ) );
345 345
346 }else 346 }else
347 QMessageBox::critical( 0, "Export VCard", 347 QMessageBox::critical( 0, "Export VCard",
348 QString( tr( "You have to set a filename !") ) ); 348 QString( tr( "You have to set a filename !") ) );
349} 349}
350 350
351void AddressbookWindow::setDocument( const QString &filename ) 351void AddressbookWindow::setDocument( const QString &filename )
352{ 352{
353 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); 353 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
354 354
@@ -502,271 +502,271 @@ void AddressbookWindow::slotFind()
502 502
503} 503}
504 504
505void AddressbookWindow::slotViewBack() 505void AddressbookWindow::slotViewBack()
506{ 506{
507 // :SX showList(); 507 // :SX showList();
508} 508}
509 509
510void AddressbookWindow::slotViewEdit() 510void AddressbookWindow::slotViewEdit()
511{ 511{
512 if(!syncing) { 512 if(!syncing) {
513 if (actionPersonal->isOn()) { 513 if (actionPersonal->isOn()) {
514 editPersonal(); 514 editPersonal();
515 } else { 515 } else {
516 editEntry( EditEntry ); 516 editEntry( EditEntry );
517 } 517 }
518 } else { 518 } else {
519 QMessageBox::warning( this, tr("Contacts"), 519 QMessageBox::warning( this, tr("Contacts"),
520 tr("Can not edit data, currently syncing") ); 520 tr("Can not edit data, currently syncing") );
521 } 521 }
522} 522}
523 523
524 524
525 525
526void AddressbookWindow::writeMail() 526void AddressbookWindow::writeMail()
527{ 527{
528 OContact c = m_abView -> currentEntry(); 528 OContact c = m_abView -> currentEntry();
529 QString name = c.fileAs(); 529 QString name = c.fileAs();
530 QString email = c.defaultEmail(); 530 QString email = c.defaultEmail();
531 531
532 // I prefer the OPIE-Environment variable before the 532 // I prefer the OPIE-Environment variable before the
533 // QPE-one.. 533 // QPE-one..
534 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 534 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
535 if ( basepath.isEmpty() ) 535 if ( basepath.isEmpty() )
536 basepath = QString::fromLatin1( getenv("QPEDIR") ); 536 basepath = QString::fromLatin1( getenv("QPEDIR") );
537 537
538 // Try to access the preferred. If not possible, try to 538 // Try to access the preferred. If not possible, try to
539 // switch to the other one.. 539 // switch to the other one..
540 if ( m_config.useQtMail() ){ 540 if ( m_config.useQtMail() ){
541 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 541 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
542 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 542 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
543 qWarning ("QCop"); 543 qWarning ("QCop");
544 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 544 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
545 e << name << email; 545 e << name << email;
546 return; 546 return;
547 } else 547 } else
548 m_config.setUseOpieMail( true ); 548 m_config.setUseOpieMail( true );
549 } 549 }
550 if ( m_config.useOpieMail() ){ 550 if ( m_config.useOpieMail() ){
551 qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1()); 551 qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1());
552 if ( QFile::exists( basepath + "/bin/opiemail" ) ){ 552 if ( QFile::exists( basepath + "/bin/opiemail" ) ){
553 qWarning ("QCop"); 553 qWarning ("QCop");
554 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); 554 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)");
555 e << name << email; 555 e << name << email;
556 return; 556 return;
557 } else 557 } else
558 m_config.setUseQtMail( true ); 558 m_config.setUseQtMail( true );
559 } 559 }
560 560
561} 561}
562 562
563static const char * beamfile = "/tmp/obex/contact.vcf"; 563static const char * beamfile = "/tmp/obex/contact.vcf";
564 564
565void AddressbookWindow::slotBeam() 565void AddressbookWindow::slotBeam()
566{ 566{
567 QString beamFilename; 567 QString beamFilename;
568 OContact c; 568 OContact c;
569 if ( actionPersonal->isOn() ) { 569 if ( actionPersonal->isOn() ) {
570 beamFilename = addressbookPersonalVCardName(); 570 beamFilename = addressbookPersonalVCardName();
571 if ( !QFile::exists( beamFilename ) ) 571 if ( !QFile::exists( beamFilename ) )
572 return; // can't beam a non-existent file 572 return; // can't beam a non-existent file
573 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 573 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
574 beamFilename ); 574 beamFilename );
575 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 575 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
576 OContactAccess::List allList = access->allRecords(); 576 OContactAccess::List allList = access->allRecords();
577 OContactAccess::List::Iterator it = allList.begin(); // Just take first 577 OContactAccess::List::Iterator it = allList.begin(); // Just take first
578 c = *it; 578 c = *it;
579 579
580 delete access; 580 delete access;
581 } else { 581 } else {
582 unlink( beamfile ); // delete if exists 582 unlink( beamfile ); // delete if exists
583 mkdir("/tmp/obex/", 0755); 583 mkdir("/tmp/obex/", 0755);
584 c = m_abView -> currentEntry(); 584 c = m_abView -> currentEntry();
585 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 585 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
586 beamfile ); 586 beamfile );
587 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 587 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
588 access->add( c ); 588 access->add( c );
589 access->save(); 589 access->save();
590 delete access; 590 delete access;
591 591
592 beamFilename = beamfile; 592 beamFilename = beamfile;
593 } 593 }
594 594
595 qWarning("Beaming: %s", beamFilename.latin1() ); 595 qWarning("Beaming: %s", beamFilename.latin1() );
596 596
597 Ir *ir = new Ir( this ); 597 Ir *ir = new Ir( this );
598 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 598 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
599 QString description = c.fullName(); 599 QString description = c.fullName();
600 ir->send( beamFilename, description, "text/x-vCard" ); 600 ir->send( beamFilename, description, "text/x-vCard" );
601} 601}
602 602
603void AddressbookWindow::beamDone( Ir *ir ) 603void AddressbookWindow::beamDone( Ir *ir )
604{ 604{
605 605
606 delete ir; 606 delete ir;
607 unlink( beamfile ); 607 unlink( beamfile );
608} 608}
609 609
610 610
611static void parseName( const QString& name, QString *first, QString *middle, 611static void parseName( const QString& name, QString *first, QString *middle,
612 QString * last ) 612 QString * last )
613{ 613{
614 614
615 int comma = name.find ( "," ); 615 int comma = name.find ( "," );
616 QString rest; 616 QString rest;
617 if ( comma > 0 ) { 617 if ( comma > 0 ) {
618 *last = name.left( comma ); 618 *last = name.left( comma );
619 comma++; 619 comma++;
620 while ( comma < int(name.length()) && name[comma] == ' ' ) 620 while ( comma < int(name.length()) && name[comma] == ' ' )
621 comma++; 621 comma++;
622 rest = name.mid( comma ); 622 rest = name.mid( comma );
623 } else { 623 } else {
624 int space = name.findRev( ' ' ); 624 int space = name.findRev( ' ' );
625 *last = name.mid( space+1 ); 625 *last = name.mid( space+1 );
626 rest = name.left( space ); 626 rest = name.left( space );
627 } 627 }
628 int space = rest.find( ' ' ); 628 int space = rest.find( ' ' );
629 if ( space <= 0 ) { 629 if ( space <= 0 ) {
630 *first = rest; 630 *first = rest;
631 } else { 631 } else {
632 *first = rest.left( space ); 632 *first = rest.left( space );
633 *middle = rest.mid( space+1 ); 633 *middle = rest.mid( space+1 );
634 } 634 }
635 635
636} 636}
637 637
638 638
639void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 639void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
640{ 640{
641 bool needShow = FALSE; 641 bool needShow = FALSE;
642 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); 642 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() );
643 643
644 644
645 if (msg == "editPersonal()") { 645 if (msg == "editPersonal()") {
646 editPersonal(); 646 editPersonal();
647 } else if (msg == "editPersonalAndClose()") { 647 } else if (msg == "editPersonalAndClose()") {
648 editPersonal(); 648 editPersonal();
649 close(); 649 close();
650 } else if ( msg == "addContact(QString,QString)" ) { 650 } else if ( msg == "addContact(QString,QString)" ) {
651 QDataStream stream(data,IO_ReadOnly); 651 QDataStream stream(data,IO_ReadOnly);
652 QString name, email; 652 QString name, email;
653 stream >> name >> email; 653 stream >> name >> email;
654 654
655 OContact cnt; 655 OContact cnt;
656 QString fn, mn, ln; 656 QString fn, mn, ln;
657 parseName( name, &fn, &mn, &ln ); 657 parseName( name, &fn, &mn, &ln );
658 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 658 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
659 cnt.setFirstName( fn ); 659 cnt.setFirstName( fn );
660 cnt.setMiddleName( mn ); 660 cnt.setMiddleName( mn );
661 cnt.setLastName( ln ); 661 cnt.setLastName( ln );
662 cnt.insertEmails( email ); 662 cnt.insertEmails( email );
663 cnt.setDefaultEmail( email ); 663 cnt.setDefaultEmail( email );
664 cnt.setFileAs(); 664 cnt.setFileAs();
665 665
666 m_abView -> addEntry( cnt ); 666 m_abView -> addEntry( cnt );
667 667
668 // :SXm_abView()->init( cnt ); 668 // :SXm_abView()->init( cnt );
669 editEntry( EditEntry ); 669 editEntry( EditEntry );
670 } else if ( msg == "beamBusinessCard()" ) { 670 } else if ( msg == "beamBusinessCard()" ) {
671 QString beamFilename = addressbookPersonalVCardName(); 671 QString beamFilename = addressbookPersonalVCardName();
672 if ( !QFile::exists( beamFilename ) ) 672 if ( !QFile::exists( beamFilename ) )
673 return; // can't beam a non-existent file 673 return; // can't beam a non-existent file
674 674
675 Ir *ir = new Ir( this ); 675 Ir *ir = new Ir( this );
676 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 676 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
677 QString description = "mycard.vcf"; 677 QString description = "mycard.vcf";
678 ir->send( beamFilename, description, "text/x-vCard" ); 678 ir->send( beamFilename, description, "text/x-vCard" );
679 } else if ( msg == "show(int)" ) { 679 } else if ( msg == "show(int)" ) {
680 raise(); 680 raise();
681 QDataStream stream(data,IO_ReadOnly); 681 QDataStream stream(data,IO_ReadOnly);
682 int uid; 682 int uid;
683 stream >> uid; 683 stream >> uid;
684 684
685 qWarning( "Showing uid: %d" , uid ); 685 qWarning( "Showing uid: %d" , uid );
686 686
687 // Deactivate Personal View.. 687 // Deactivate Personal View..
688 if ( actionPersonal->isOn() ){ 688 if ( actionPersonal->isOn() ){
689 actionPersonal->setOn( false ); 689 actionPersonal->setOn( false );
690 slotPersonalView(); 690 slotPersonalView();
691 } 691 }
692 692
693 // Reset category and show as card.. 693 // Reset category and show as card..
694 m_abView -> setShowByCategory( QString::null ); 694 m_abView -> setShowByCategory( QString::null );
695 m_abView -> setCurrentUid( uid ); 695 m_abView -> setCurrentUid( uid );
696 slotViewSwitched ( AbView::CardView ); 696 slotViewSwitched ( AbView::CardView );
697 697
698 needShow = true; 698 needShow = true;
699 699
700 700
701 } else if ( msg == "edit(int)" ) { 701 } else if ( msg == "edit(int)" ) {
702 QDataStream stream(data,IO_ReadOnly); 702 QDataStream stream(data,IO_ReadOnly);
703 int uid; 703 int uid;
704 stream >> uid; 704 stream >> uid;
705 705
706 // Deactivate Personal View.. 706 // Deactivate Personal View..
707 if ( actionPersonal->isOn() ){ 707 if ( actionPersonal->isOn() ){
708 actionPersonal->setOn( false ); 708 actionPersonal->setOn( false );
709 slotPersonalView(); 709 slotPersonalView();
710 } 710 }
711 711
712 // Reset category and edit.. 712 // Reset category and edit..
713 m_abView -> setShowByCategory( QString::null ); 713 m_abView -> setShowByCategory( QString::null );
714 m_abView -> setCurrentUid( uid ); 714 m_abView -> setCurrentUid( uid );
715 slotViewEdit(); 715 slotViewEdit();
716 } 716 }
717 717
718 if (needShow) 718 if (needShow)
719 QPEApplication::setKeepRunning(); 719 QPEApplication::setKeepRunning();
720 720
721} 721}
722 722
723void AddressbookWindow::editEntry( EntryMode entryMode ) 723void AddressbookWindow::editEntry( EntryMode entryMode )
724{ 724{
725 OContact entry; 725 OContact entry;
726 if ( !abEditor ) { 726 if ( !abEditor ) {
727 abEditor = new ContactEditor( entry, this, "editor" ); 727 abEditor = new ContactEditor( entry, this, "editor" );
728 } 728 }
729 if ( entryMode == EditEntry ) 729 if ( entryMode == EditEntry )
730 abEditor->setEntry( m_abView -> currentEntry() ); 730 abEditor->setEntry( m_abView -> currentEntry() );
731 else if ( entryMode == NewEntry ) 731 else if ( entryMode == NewEntry )
732 abEditor->setEntry( entry ); 732 abEditor->setEntry( entry );
733 // other things may change the caption. 733 // other things may change the caption.
734 abEditor->setCaption( tr("Edit Address") ); 734 abEditor->setCaption( tr("Edit Address") );
735 735
736 // fix the foxus... 736 // fix the foxus...
737 abEditor->setNameFocus(); 737 abEditor->setNameFocus();
738 if ( QPEApplication::execDialog( abEditor ) ) { 738 if ( QPEApplication::execDialog( abEditor ) ) {
739 setFocus(); 739 setFocus();
740 if ( entryMode == NewEntry ) { 740 if ( entryMode == NewEntry ) {
741 OContact insertEntry = abEditor->entry(); 741 OContact insertEntry = abEditor->entry();
742 insertEntry.assignUid(); 742 insertEntry.assignUid();
743 m_abView -> addEntry( insertEntry ); 743 m_abView -> addEntry( insertEntry );
744 m_abView -> setCurrentUid( insertEntry.uid() ); 744 m_abView -> setCurrentUid( insertEntry.uid() );
745 } else { 745 } else {
746 OContact replEntry = abEditor->entry(); 746 OContact replEntry = abEditor->entry();
747 747
748 if ( !replEntry.isValidUid() ) 748 if ( !replEntry.isValidUid() )
749 replEntry.assignUid(); 749 replEntry.assignUid();
750 750
751 m_abView -> replaceEntry( replEntry ); 751 m_abView -> replaceEntry( replEntry );
752 } 752 }
753 } 753 }
754 // populateCategories(); 754 // populateCategories();
755 755
756} 756}
757 757
758void AddressbookWindow::editPersonal() 758void AddressbookWindow::editPersonal()
759{ 759{
760 OContact entry; 760 OContact entry;
761 761
762 // Switch to personal view if not selected 762 // Switch to personal view if not selected
763 // but take care of the menu, too 763 // but take care of the menu, too
764 if ( ! actionPersonal->isOn() ){ 764 if ( ! actionPersonal->isOn() ){
765 qWarning("*** ++++"); 765 qWarning("*** ++++");
766 actionPersonal->setOn( true ); 766 actionPersonal->setOn( true );
767 slotPersonalView(); 767 slotPersonalView();
768 } 768 }
769 769
770 if ( !abEditor ) { 770 if ( !abEditor ) {
771 abEditor = new ContactEditor( entry, this, "editor" ); 771 abEditor = new ContactEditor( entry, this, "editor" );
772 } 772 }
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index b1eb042..8acf570 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -442,327 +442,327 @@ void ContactEditor::init() {
442 cmbCountry->insertItem( tr ( "Solomon Islands" ) ); 442 cmbCountry->insertItem( tr ( "Solomon Islands" ) );
443 cmbCountry->insertItem( tr ( "Somalia" ) ); 443 cmbCountry->insertItem( tr ( "Somalia" ) );
444 cmbCountry->insertItem( tr ( "South Africa" ) ); 444 cmbCountry->insertItem( tr ( "South Africa" ) );
445 cmbCountry->insertItem( tr ( "Spain" ) ); 445 cmbCountry->insertItem( tr ( "Spain" ) );
446 cmbCountry->insertItem( tr ( "Sri Lanka" ) ); 446 cmbCountry->insertItem( tr ( "Sri Lanka" ) );
447 cmbCountry->insertItem( tr ( "St. Helena" ) ); 447 cmbCountry->insertItem( tr ( "St. Helena" ) );
448 cmbCountry->insertItem( tr ( "Sudan" ) ); 448 cmbCountry->insertItem( tr ( "Sudan" ) );
449 cmbCountry->insertItem( tr ( "Suriname" ) ); 449 cmbCountry->insertItem( tr ( "Suriname" ) );
450 cmbCountry->insertItem( tr ( "Swaziland" ) ); 450 cmbCountry->insertItem( tr ( "Swaziland" ) );
451 cmbCountry->insertItem( tr ( "Sweden" ) ); 451 cmbCountry->insertItem( tr ( "Sweden" ) );
452 cmbCountry->insertItem( tr ( "Switzerland" ) ); 452 cmbCountry->insertItem( tr ( "Switzerland" ) );
453 cmbCountry->insertItem( tr ( "Taiwan" ) ); 453 cmbCountry->insertItem( tr ( "Taiwan" ) );
454 cmbCountry->insertItem( tr ( "Tajikistan" ) ); 454 cmbCountry->insertItem( tr ( "Tajikistan" ) );
455 cmbCountry->insertItem( tr ( "Tanzania" ) ); 455 cmbCountry->insertItem( tr ( "Tanzania" ) );
456 cmbCountry->insertItem( tr ( "Thailand" ) ); 456 cmbCountry->insertItem( tr ( "Thailand" ) );
457 cmbCountry->insertItem( tr ( "Togo" ) ); 457 cmbCountry->insertItem( tr ( "Togo" ) );
458 cmbCountry->insertItem( tr ( "Tokelau" ) ); 458 cmbCountry->insertItem( tr ( "Tokelau" ) );
459 cmbCountry->insertItem( tr ( "Tonga" ) ); 459 cmbCountry->insertItem( tr ( "Tonga" ) );
460 cmbCountry->insertItem( tr ( "Tunisia" ) ); 460 cmbCountry->insertItem( tr ( "Tunisia" ) );
461 cmbCountry->insertItem( tr ( "Turkey" ) ); 461 cmbCountry->insertItem( tr ( "Turkey" ) );
462 cmbCountry->insertItem( tr ( "Turkmenistan" ) ); 462 cmbCountry->insertItem( tr ( "Turkmenistan" ) );
463 cmbCountry->insertItem( tr ( "Tuvalu" ) ); 463 cmbCountry->insertItem( tr ( "Tuvalu" ) );
464 cmbCountry->insertItem( tr ( "Uganda" ) ); 464 cmbCountry->insertItem( tr ( "Uganda" ) );
465 cmbCountry->insertItem( tr ( "Ukraine" ) ); 465 cmbCountry->insertItem( tr ( "Ukraine" ) );
466 cmbCountry->insertItem( tr ( "Uruguay" ) ); 466 cmbCountry->insertItem( tr ( "Uruguay" ) );
467 cmbCountry->insertItem( tr ( "Uzbekistan" ) ); 467 cmbCountry->insertItem( tr ( "Uzbekistan" ) );
468 cmbCountry->insertItem( tr ( "Vanuatu" ) ); 468 cmbCountry->insertItem( tr ( "Vanuatu" ) );
469 cmbCountry->insertItem( tr ( "Venezuela" ) ); 469 cmbCountry->insertItem( tr ( "Venezuela" ) );
470 cmbCountry->insertItem( tr ( "Vietnam" ) ); 470 cmbCountry->insertItem( tr ( "Vietnam" ) );
471 cmbCountry->insertItem( tr ( "Virgin Islands" ) ); 471 cmbCountry->insertItem( tr ( "Virgin Islands" ) );
472 cmbCountry->insertItem( tr ( "Western Sahara" ) ); 472 cmbCountry->insertItem( tr ( "Western Sahara" ) );
473 cmbCountry->insertItem( tr ( "Yemen" ) ); 473 cmbCountry->insertItem( tr ( "Yemen" ) );
474 cmbCountry->insertItem( tr ( "Yugoslavia" ) ); 474 cmbCountry->insertItem( tr ( "Yugoslavia" ) );
475 cmbCountry->insertItem( tr ( "Zambia" ) ); 475 cmbCountry->insertItem( tr ( "Zambia" ) );
476 cmbCountry->insertItem( tr ( "Zimbabwe" ) ); 476 cmbCountry->insertItem( tr ( "Zimbabwe" ) );
477 if (cmbCountry->listBox()!=0) 477 if (cmbCountry->listBox()!=0)
478 cmbCountry->listBox()->sort(); 478 cmbCountry->listBox()->sort();
479 479
480 cmbCountry->setMaximumWidth( 135 ); 480 cmbCountry->setMaximumWidth( 135 );
481 481
482 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); 482 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
483 483
484 // Chooser 4 484 // Chooser 4
485 cmbChooserField4 = new QComboBox( FALSE, container ); 485 cmbChooserField4 = new QComboBox( FALSE, container );
486 cmbChooserField4->setMaximumWidth( 90 ); 486 cmbChooserField4->setMaximumWidth( 90 );
487 gl->addWidget( cmbChooserField4, 6, 0 ); 487 gl->addWidget( cmbChooserField4, 6, 0 );
488 // Textfield for chooser 2 488 // Textfield for chooser 2
489 // Now use WidgetStack to contain the textfield and the default-email combo! 489 // Now use WidgetStack to contain the textfield and the default-email combo!
490 m_widgetStack4 = new QWidgetStack( container ); 490 m_widgetStack4 = new QWidgetStack( container );
491 txtChooserField4 = new QLineEdit( m_widgetStack4 ); 491 txtChooserField4 = new QLineEdit( m_widgetStack4 );
492 m_widgetStack4 -> addWidget( txtChooserField4, TextField ); 492 m_widgetStack4 -> addWidget( txtChooserField4, TextField );
493 gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); 493 gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 );
494 m_widgetStack4 -> raiseWidget( TextField ); 494 m_widgetStack4 -> raiseWidget( TextField );
495 495
496 QSpacerItem *space = new QSpacerItem(1,1, 496 QSpacerItem *space = new QSpacerItem(1,1,
497 QSizePolicy::Maximum, 497 QSizePolicy::Maximum,
498 QSizePolicy::MinimumExpanding ); 498 QSizePolicy::MinimumExpanding );
499 gl->addItem( space, 7, 0 ); 499 gl->addItem( space, 7, 0 );
500 500
501 tabMain->insertTab( tabViewport, tr( "Address" ) ); 501 tabMain->insertTab( tabViewport, tr( "Address" ) );
502 502
503 tabViewport = new QWidget ( tabMain ); 503 tabViewport = new QWidget ( tabMain );
504 504
505 vb = new QVBoxLayout( tabViewport ); 505 vb = new QVBoxLayout( tabViewport );
506 506
507 svDetails = new QScrollView( tabViewport ); 507 svDetails = new QScrollView( tabViewport );
508 vb->addWidget( svDetails, 0, 0 ); 508 vb->addWidget( svDetails, 0, 0 );
509 svDetails->setResizePolicy( QScrollView::AutoOneFit ); 509 svDetails->setResizePolicy( QScrollView::AutoOneFit );
510 svDetails->setFrameStyle( QFrame::NoFrame ); 510 svDetails->setFrameStyle( QFrame::NoFrame );
511 511
512 container = new QWidget( svDetails->viewport() ); 512 container = new QWidget( svDetails->viewport() );
513 svDetails->addChild( container ); 513 svDetails->addChild( container );
514 514
515 gl = new QGridLayout( container, 1, 2, 2, 4 ); 515 gl = new QGridLayout( container, 1, 2, 2, 4 );
516 516
517 int counter = 0; 517 int counter = 0;
518 518
519 // Birthday 519 // Birthday
520 QHBox* hBox = new QHBox( container ); 520 QHBox* hBox = new QHBox( container );
521 l = new QLabel( tr("Birthday"), container ); 521 l = new QLabel( tr("Birthday"), container );
522 gl->addWidget( l, counter, 0 ); 522 gl->addWidget( l, counter, 0 );
523 523
524 QPopupMenu* m1 = new QPopupMenu( container ); 524 QPopupMenu* m1 = new QPopupMenu( container );
525 birthdayPicker = new DateBookMonth( m1, 0, TRUE ); 525 birthdayPicker = new DateBookMonth( m1, 0, TRUE );
526 m1->insertItem( birthdayPicker ); 526 m1->insertItem( birthdayPicker );
527 527
528 birthdayButton= new QToolButton( hBox, "buttonStart" ); 528 birthdayButton= new QToolButton( hBox, "buttonStart" );
529 birthdayButton->setPopup( m1 ); 529 birthdayButton->setPopup( m1 );
530 birthdayButton->setPopupDelay(0); 530 birthdayButton->setPopupDelay(0);
531 531
532 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 532 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
533 tr( "Delete" ), 533 tr( "Delete" ),
534 hBox, 0 ); 534 hBox, 0 );
535 535
536 gl->addWidget( hBox, counter , 1 ); 536 gl->addWidget( hBox, counter , 1 );
537 537
538 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), 538 connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ),
539 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); 539 this, SLOT( slotBirthdayDateChanged(int,int,int) ) );
540 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); 540 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
541 541
542 ++counter; 542 ++counter;
543 543
544 // Anniversary 544 // Anniversary
545 hBox = new QHBox( container ); 545 hBox = new QHBox( container );
546 l = new QLabel( tr("Anniversary"), container ); 546 l = new QLabel( tr("Anniversary"), container );
547 gl->addWidget( l, counter, 0 ); 547 gl->addWidget( l, counter, 0 );
548 548
549 m1 = new QPopupMenu( container ); 549 m1 = new QPopupMenu( container );
550 anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); 550 anniversaryPicker = new DateBookMonth( m1, 0, TRUE );
551 m1->insertItem( anniversaryPicker ); 551 m1->insertItem( anniversaryPicker );
552 552
553 anniversaryButton= new QToolButton( hBox, "buttonStart" ); 553 anniversaryButton= new QToolButton( hBox, "buttonStart" );
554 anniversaryButton->setPopup( m1 ); 554 anniversaryButton->setPopup( m1 );
555 anniversaryButton->setPopupDelay(0); 555 anniversaryButton->setPopupDelay(0);
556 556
557 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 557 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
558 tr( "Delete" ), 558 tr( "Delete" ),
559 hBox, 0 ); 559 hBox, 0 );
560 gl->addWidget( hBox, counter , 1 ); 560 gl->addWidget( hBox, counter , 1 );
561 561
562 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), 562 connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ),
563 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); 563 this, SLOT( slotAnniversaryDateChanged(int,int,int) ) );
564 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); 564 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
565 565
566 ++counter; 566 ++counter;
567 567
568 // Gender 568 // Gender
569 l = new QLabel( tr("Gender"), container ); 569 l = new QLabel( tr("Gender"), container );
570 gl->addWidget( l, counter, 0 ); 570 gl->addWidget( l, counter, 0 );
571 cmbGender = new QComboBox( container ); 571 cmbGender = new QComboBox( container );
572 cmbGender->insertItem( "", 0 ); 572 cmbGender->insertItem( "", 0 );
573 cmbGender->insertItem( tr("Male"), 1); 573 cmbGender->insertItem( tr("Male"), 1);
574 cmbGender->insertItem( tr("Female"), 2); 574 cmbGender->insertItem( tr("Female"), 2);
575 gl->addWidget( cmbGender, counter, 1 ); 575 gl->addWidget( cmbGender, counter, 1 );
576 576
577 ++counter; 577 ++counter;
578 578
579 // Create Labels and lineedit fields for every dynamic entry 579 // Create Labels and lineedit fields for every dynamic entry
580 QStringList::ConstIterator it = slDynamicEntries.begin(); 580 QStringList::ConstIterator it = slDynamicEntries.begin();
581 QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); 581 QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId();
582 QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); 582 QMap<int, QString> mapIdToStr = OContactFields::idToTrFields();
583 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { 583 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
584 584
585 if (((*it) == "Anniversary") || 585 if (((*it) == "Anniversary") ||
586 ((*it) == "Birthday")|| ((*it) == "Gender")) continue; 586 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
587 587
588 l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); 588 l = new QLabel( mapIdToStr[mapStrToID[*it]], container );
589 listName.append( l ); 589 listName.append( l );
590 gl->addWidget( l, i, 0 ); 590 gl->addWidget( l, i, 0 );
591 QLineEdit *e = new QLineEdit( container ); 591 QLineEdit *e = new QLineEdit( container );
592 listValue.append( e ); 592 listValue.append( e );
593 gl->addWidget( e, i, 1); 593 gl->addWidget( e, i, 1);
594 } 594 }
595 // Fill labels with names.. 595 // Fill labels with names..
596 //loadFields(); 596 //loadFields();
597 597
598 598
599 tabMain->insertTab( tabViewport, tr( "Details" ) ); 599 tabMain->insertTab( tabViewport, tr( "Details" ) );
600 600
601 dlgNote = new QDialog( this, "Note Dialog", TRUE ); 601 dlgNote = new QDialog( this, "Note Dialog", TRUE );
602 dlgNote->setCaption( tr("Enter Note") ); 602 dlgNote->setCaption( tr("Enter Note") );
603 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); 603 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
604 txtNote = new QMultiLineEdit( dlgNote ); 604 txtNote = new QMultiLineEdit( dlgNote );
605 vbNote->addWidget( txtNote ); 605 vbNote->addWidget( txtNote );
606 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); 606 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
607 607
608 dlgName = new QDialog( this, "Name Dialog", TRUE ); 608 dlgName = new QDialog( this, "Name Dialog", TRUE );
609 dlgName->setCaption( tr("Edit Name") ); 609 dlgName->setCaption( tr("Edit Name") );
610 gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); 610 gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
611 611
612 l = new QLabel( tr("First Name"), dlgName ); 612 l = new QLabel( tr("First Name"), dlgName );
613 gl->addWidget( l, 0, 0 ); 613 gl->addWidget( l, 0, 0 );
614 txtFirstName = new QLineEdit( dlgName ); 614 txtFirstName = new QLineEdit( dlgName );
615 gl->addWidget( txtFirstName, 0, 1 ); 615 gl->addWidget( txtFirstName, 0, 1 );
616 616
617 l = new QLabel( tr("Middle Name"), dlgName ); 617 l = new QLabel( tr("Middle Name"), dlgName );
618 gl->addWidget( l, 1, 0 ); 618 gl->addWidget( l, 1, 0 );
619 txtMiddleName = new QLineEdit( dlgName ); 619 txtMiddleName = new QLineEdit( dlgName );
620 gl->addWidget( txtMiddleName, 1, 1 ); 620 gl->addWidget( txtMiddleName, 1, 1 );
621 621
622 l = new QLabel( tr("Last Name"), dlgName ); 622 l = new QLabel( tr("Last Name"), dlgName );
623 gl->addWidget( l, 2, 0 ); 623 gl->addWidget( l, 2, 0 );
624 txtLastName = new QLineEdit( dlgName ); 624 txtLastName = new QLineEdit( dlgName );
625 gl->addWidget( txtLastName, 2, 1 ); 625 gl->addWidget( txtLastName, 2, 1 );
626 626
627 // l = new QLabel( tr("Suffix"), dlgName ); 627 // l = new QLabel( tr("Suffix"), dlgName );
628 // gl->addWidget( l, 3, 0 ); 628 // gl->addWidget( l, 3, 0 );
629 // txtSuffix = new QLineEdit( dlgName ); 629 // txtSuffix = new QLineEdit( dlgName );
630 // gl->addWidget( txtSuffix, 3, 1 ); 630 // gl->addWidget( txtSuffix, 3, 1 );
631 space = new QSpacerItem(1,1, 631 space = new QSpacerItem(1,1,
632 QSizePolicy::Maximum, 632 QSizePolicy::Maximum,
633 QSizePolicy::MinimumExpanding ); 633 QSizePolicy::MinimumExpanding );
634 gl->addItem( space, 4, 0 ); 634 gl->addItem( space, 4, 0 );
635 635
636 cmbChooserField1->insertStringList( trlChooserNames ); 636 cmbChooserField1->insertStringList( trlChooserNames );
637 cmbChooserField2->insertStringList( trlChooserNames ); 637 cmbChooserField2->insertStringList( trlChooserNames );
638 cmbChooserField3->insertStringList( trlChooserNames ); 638 cmbChooserField3->insertStringList( trlChooserNames );
639 cmbChooserField4->insertStringList( trlChooserNames ); 639 cmbChooserField4->insertStringList( trlChooserNames );
640 640
641 cmbChooserField1->setCurrentItem( 0 ); 641 cmbChooserField1->setCurrentItem( 0 );
642 cmbChooserField2->setCurrentItem( 1 ); 642 cmbChooserField2->setCurrentItem( 1 );
643 cmbChooserField3->setCurrentItem( 2 ); 643 cmbChooserField3->setCurrentItem( 2 );
644 644
645 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 645 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
646 646
647 connect( txtFullName, SIGNAL(textChanged(const QString &)), 647 connect( txtFullName, SIGNAL(textChanged(const QString&)),
648 this, SLOT(slotFullNameChange(const QString &)) ); 648 this, SLOT(slotFullNameChange(const QString&)) );
649 connect( txtSuffix, SIGNAL(textChanged(const QString &)), 649 connect( txtSuffix, SIGNAL(textChanged(const QString&)),
650 this, SLOT(slotSuffixChange(const QString &)) ); 650 this, SLOT(slotSuffixChange(const QString&)) );
651 connect( txtOrganization, SIGNAL(textChanged(const QString &)), 651 connect( txtOrganization, SIGNAL(textChanged(const QString&)),
652 this, SLOT(slotOrganizationChange(const QString &)) ); 652 this, SLOT(slotOrganizationChange(const QString&)) );
653 connect( txtChooserField1, SIGNAL(textChanged(const QString &)), 653 connect( txtChooserField1, SIGNAL(textChanged(const QString&)),
654 this, SLOT(slotChooser1Change(const QString &)) ); 654 this, SLOT(slotChooser1Change(const QString&)) );
655 connect( txtChooserField2, SIGNAL(textChanged(const QString &)), 655 connect( txtChooserField2, SIGNAL(textChanged(const QString&)),
656 this, SLOT(slotChooser2Change(const QString &)) ); 656 this, SLOT(slotChooser2Change(const QString&)) );
657 connect( txtChooserField3, SIGNAL(textChanged(const QString &)), 657 connect( txtChooserField3, SIGNAL(textChanged(const QString&)),
658 this, SLOT(slotChooser3Change(const QString &)) ); 658 this, SLOT(slotChooser3Change(const QString&)) );
659 connect( txtChooserField4, SIGNAL(textChanged(const QString &)), 659 connect( txtChooserField4, SIGNAL(textChanged(const QString&)),
660 this, SLOT(slotChooser4Change(const QString &)) ); 660 this, SLOT(slotChooser4Change(const QString&)) );
661 connect( txtAddress, SIGNAL(textChanged(const QString &)), 661 connect( txtAddress, SIGNAL(textChanged(const QString&)),
662 this, SLOT(slotAddressChange(const QString &)) ); 662 this, SLOT(slotAddressChange(const QString&)) );
663 connect( txtCity, SIGNAL(textChanged(const QString &)), 663 connect( txtCity, SIGNAL(textChanged(const QString&)),
664 this, SLOT(slotCityChange(const QString &)) ); 664 this, SLOT(slotCityChange(const QString&)) );
665 connect( txtState, SIGNAL(textChanged(const QString &)), 665 connect( txtState, SIGNAL(textChanged(const QString&)),
666 this, SLOT(slotStateChange(const QString &)) ); 666 this, SLOT(slotStateChange(const QString&)) );
667 connect( txtZip, SIGNAL(textChanged(const QString &)), 667 connect( txtZip, SIGNAL(textChanged(const QString&)),
668 this, SLOT(slotZipChange(const QString &)) ); 668 this, SLOT(slotZipChange(const QString&)) );
669 connect( cmbCountry, SIGNAL(textChanged(const QString &)), 669 connect( cmbCountry, SIGNAL(textChanged(const QString&)),
670 this, SLOT(slotCountryChange(const QString &)) ); 670 this, SLOT(slotCountryChange(const QString&)) );
671 connect( cmbCountry, SIGNAL(activated(const QString &)), 671 connect( cmbCountry, SIGNAL(activated(const QString&)),
672 this, SLOT(slotCountryChange(const QString &)) ); 672 this, SLOT(slotCountryChange(const QString&)) );
673 connect( cmbChooserField1, SIGNAL(activated(int)), 673 connect( cmbChooserField1, SIGNAL(activated(int)),
674 this, SLOT(slotCmbChooser1Change(int)) ); 674 this, SLOT(slotCmbChooser1Change(int)) );
675 connect( cmbChooserField2, SIGNAL(activated(int)), 675 connect( cmbChooserField2, SIGNAL(activated(int)),
676 this, SLOT(slotCmbChooser2Change(int)) ); 676 this, SLOT(slotCmbChooser2Change(int)) );
677 connect( cmbChooserField3, SIGNAL(activated(int)), 677 connect( cmbChooserField3, SIGNAL(activated(int)),
678 this, SLOT(slotCmbChooser3Change(int)) ); 678 this, SLOT(slotCmbChooser3Change(int)) );
679 connect( cmbChooserField4, SIGNAL(activated(int)), 679 connect( cmbChooserField4, SIGNAL(activated(int)),
680 this, SLOT(slotCmbChooser4Change(int)) ); 680 this, SLOT(slotCmbChooser4Change(int)) );
681 connect( cmbAddress, SIGNAL(activated(int)), 681 connect( cmbAddress, SIGNAL(activated(int)),
682 this, SLOT(slotAddressTypeChange(int)) ); 682 this, SLOT(slotAddressTypeChange(int)) );
683 683
684 new QPEDialogListener(this); 684 new QPEDialogListener(this);
685 685
686 setPersonalView ( m_personalView ); 686 setPersonalView ( m_personalView );
687 687
688 qWarning("init() END"); 688 qWarning("init() END");
689} 689}
690 690
691void ContactEditor::defaultEmailChanged(int i){ 691void ContactEditor::defaultEmailChanged(int i){
692 qDebug("defaultEmailChanged"); 692 qDebug("defaultEmailChanged");
693 693
694 // was sollte das ? (se) 694 // was sollte das ? (se)
695 // int index = cmbChooserField1->currentItem(); 695 // int index = cmbChooserField1->currentItem();
696 // slChooserValues[index] = cmbDefaultEmail->text(i); 696 // slChooserValues[index] = cmbDefaultEmail->text(i);
697 697
698 defaultEmail = cmbDefaultEmail->text(i); 698 defaultEmail = cmbDefaultEmail->text(i);
699 qDebug ("Changed to: %s", defaultEmail.latin1()); 699 qDebug ("Changed to: %s", defaultEmail.latin1());
700 700
701} 701}
702 702
703void ContactEditor::populateDefaultEmailCmb(){ 703void ContactEditor::populateDefaultEmailCmb(){
704 704
705 // if the default-email combo was not selected and therfore not created 705 // if the default-email combo was not selected and therfore not created
706 // we get a lot of trouble.. Therfore create an invisible one.. 706 // we get a lot of trouble.. Therfore create an invisible one..
707 if ( !cmbDefaultEmail ){ 707 if ( !cmbDefaultEmail ){
708 cmbDefaultEmail = new QComboBox(this); 708 cmbDefaultEmail = new QComboBox(this);
709 cmbDefaultEmail -> hide(); 709 cmbDefaultEmail -> hide();
710 } 710 }
711 cmbDefaultEmail->clear(); 711 cmbDefaultEmail->clear();
712 cmbDefaultEmail->insertStringList( emails ); 712 cmbDefaultEmail->insertStringList( emails );
713 // cmbDefaultEmail->show(); 713 // cmbDefaultEmail->show();
714 714
715 // Select default email in combo.. 715 // Select default email in combo..
716 bool found = false; 716 bool found = false;
717 for ( int i = 0; i < cmbDefaultEmail->count(); i++){ 717 for ( int i = 0; i < cmbDefaultEmail->count(); i++){
718 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", 718 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",
719 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); 719 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1());
720 720
721 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ 721 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
722 cmbDefaultEmail->setCurrentItem( i ); 722 cmbDefaultEmail->setCurrentItem( i );
723 qDebug("set"); 723 qDebug("set");
724 found = true; 724 found = true;
725 } 725 }
726 } 726 }
727 727
728 // If the current default email is not found in the list, we choose the 728 // If the current default email is not found in the list, we choose the
729 // first one.. 729 // first one..
730 if ( !found ) 730 if ( !found )
731 defaultEmail = cmbDefaultEmail->text(0); 731 defaultEmail = cmbDefaultEmail->text(0);
732} 732}
733 733
734// Called when any combobox was changed. 734// Called when any combobox was changed.
735// "true" returned if the change was chandled by this function, else it should 735// "true" returned if the change was chandled by this function, else it should
736// be handled by something else.. 736// be handled by something else..
737bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { 737bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) {
738 QString type = slChooserNames[index]; 738 QString type = slChooserNames[index];
739 qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); 739 qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos );
740 740
741 if ( !initializing ) 741 if ( !initializing )
742 contactfields.setFieldOrder( widgetPos-1, index ); 742 contactfields.setFieldOrder( widgetPos-1, index );
743 743
744 // Create and connect combobox for selecting the default email 744 // Create and connect combobox for selecting the default email
745 if ( type == "Default Email"){ 745 if ( type == "Default Email"){
746 qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); 746 qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition);
747 747
748 // More than one default-email chooser is not allowed ! 748 // More than one default-email chooser is not allowed !
749 if ( ( defaultEmailChooserPosition != -1 ) && 749 if ( ( defaultEmailChooserPosition != -1 ) &&
750 defaultEmailChooserPosition != widgetPos && !initializing){ 750 defaultEmailChooserPosition != widgetPos && !initializing){
751 chooserError( widgetPos ); 751 chooserError( widgetPos );
752 return true; 752 return true;
753 } 753 }
754 754
755 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); 755 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
756 if ( cmbo ){ 756 if ( cmbo ){
757 inputStack->raiseWidget( TextField ); 757 inputStack->raiseWidget( TextField );
758 inputStack -> removeWidget( cmbo ); 758 inputStack -> removeWidget( cmbo );
759 delete cmbo; 759 delete cmbo;
760 } 760 }
761 cmbo = new QComboBox( inputStack ); 761 cmbo = new QComboBox( inputStack );
762 cmbo -> insertStringList( emails ); 762 cmbo -> insertStringList( emails );
763 763
764 inputStack -> addWidget( cmbo, Combo ); 764 inputStack -> addWidget( cmbo, Combo );
765 inputStack -> raiseWidget( Combo ); 765 inputStack -> raiseWidget( Combo );
766 766
767 defaultEmailChooserPosition = widgetPos; 767 defaultEmailChooserPosition = widgetPos;
768 cmbDefaultEmail = cmbo; 768 cmbDefaultEmail = cmbo;
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index af26302..3934411 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -68,202 +68,202 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
68{ 68{
69 bool needEvilHack= false; // if we need an Evil Hack 69 bool needEvilHack= false; // if we need an Evil Hack
70 QTime t; 70 QTime t;
71 t.start(); 71 t.start();
72 db = new DateBookDBHack; 72 db = new DateBookDBHack;
73 qDebug("loading db t=%d", t.elapsed() ); 73 qDebug("loading db t=%d", t.elapsed() );
74 loadSettings(); 74 loadSettings();
75 setCaption( tr("Calendar") ); 75 setCaption( tr("Calendar") );
76 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 76 setIcon( Resource::loadPixmap( "datebook_icon" ) );
77 77
78 setToolBarsMovable( FALSE ); 78 setToolBarsMovable( FALSE );
79 79
80 views = new QWidgetStack( this ); 80 views = new QWidgetStack( this );
81 setCentralWidget( views ); 81 setCentralWidget( views );
82 82
83 dayView = 0; 83 dayView = 0;
84 weekView = 0; 84 weekView = 0;
85 weekLstView = 0; 85 weekLstView = 0;
86 monthView = 0; 86 monthView = 0;
87 87
88// QToolBar *bar = new QToolBar( this ); 88// QToolBar *bar = new QToolBar( this );
89// bar->setHorizontalStretchable( TRUE ); 89// bar->setHorizontalStretchable( TRUE );
90 90
91// QMenuBar *mb = new QMenuBar( bar ); 91// QMenuBar *mb = new QMenuBar( bar );
92// mb->setMargin( 0 ); 92// mb->setMargin( 0 );
93 93
94// QPopupMenu *view = new QPopupMenu( this ); 94// QPopupMenu *view = new QPopupMenu( this );
95// mb->insertItem( tr( "View" ), view ); 95// mb->insertItem( tr( "View" ), view );
96 96
97 QToolBar *sub_bar = new QToolBar(this); 97 QToolBar *sub_bar = new QToolBar(this);
98 sub_bar->setHorizontalStretchable(TRUE); 98 sub_bar->setHorizontalStretchable(TRUE);
99 99
100 QActionGroup *g = new QActionGroup( this ); 100 QActionGroup *g = new QActionGroup( this );
101 g->setExclusive( TRUE ); 101 g->setExclusive( TRUE );
102 102
103 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 103 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
104 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 104 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
105 a->addTo( sub_bar ); 105 a->addTo( sub_bar );
106 106
107 sub_bar->addSeparator(); 107 sub_bar->addSeparator();
108 108
109 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 109 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
110 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 110 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
111 a->addTo( sub_bar ); 111 a->addTo( sub_bar );
112 //a->addTo( view ); 112 //a->addTo( view );
113 113
114 sub_bar->addSeparator(); 114 sub_bar->addSeparator();
115 115
116 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 116 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
117 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 117 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
118 a->addTo( sub_bar ); 118 a->addTo( sub_bar );
119// a->addTo( view ); 119// a->addTo( view );
120 a->setToggleAction( TRUE ); 120 a->setToggleAction( TRUE );
121 a->setOn( TRUE ); 121 a->setOn( TRUE );
122 dayAction = a; 122 dayAction = a;
123 123
124 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 124 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
125 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 125 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
126 a->addTo( sub_bar ); 126 a->addTo( sub_bar );
127// a->addTo( view ); 127// a->addTo( view );
128 a->setToggleAction( TRUE ); 128 a->setToggleAction( TRUE );
129 weekAction = a; 129 weekAction = a;
130 130
131 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 131 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
132 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
133 a->addTo( sub_bar ); 133 a->addTo( sub_bar );
134// a->addTo( view ); 134// a->addTo( view );
135 a->setToggleAction( TRUE ); 135 a->setToggleAction( TRUE );
136 weekLstAction = a; 136 weekLstAction = a;
137 137
138 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 138 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
139 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 139 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
140 a->addTo( sub_bar ); 140 a->addTo( sub_bar );
141// a->addTo( view ); 141// a->addTo( view );
142 a->setToggleAction( TRUE ); 142 a->setToggleAction( TRUE );
143 monthAction = a; 143 monthAction = a;
144 144
145 sub_bar->addSeparator(); 145 sub_bar->addSeparator();
146 146
147 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 147 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
148 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 148 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
149 a->addTo( sub_bar ); 149 a->addTo( sub_bar );
150 150
151 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 151 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
152 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 152 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
153 a->addTo( sub_bar ); 153 a->addTo( sub_bar );
154 154
155 if(defaultView==DAY) viewDay(); 155 if(defaultView==DAY) viewDay();
156 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 156 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
157 if(defaultView==WEEKLST) viewWeekLst(); 157 if(defaultView==WEEKLST) viewWeekLst();
158 if(defaultView==MONTH) viewMonth(); 158 if(defaultView==MONTH) viewMonth();
159 159
160 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 160 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
161 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 161 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
162 162
163#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 163#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
164 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); 164 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
165#endif 165#endif
166 166
167 // listen on QPE/System 167 // listen on QPE/System
168#if defined(Q_WS_QWS) 168#if defined(Q_WS_QWS)
169#if !defined(QT_NO_COP) 169#if !defined(QT_NO_COP)
170 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 170 QCopChannel *channel = new QCopChannel( "QPE/System", this );
171 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 171 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
172 channel = new QCopChannel( "QPE/Datebook", this ); 172 channel = new QCopChannel( "QPE/Datebook", this );
173 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); 173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
174#endif 174#endif
175#endif 175#endif
176 176
177 qDebug("done t=%d", t.elapsed() ); 177 qDebug("done t=%d", t.elapsed() );
178 178
179 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 179 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
180 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 180 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
181 /* 181 /*
182 * Here is a problem description: 182 * Here is a problem description:
183 * When Weekview is the default view 183 * When Weekview is the default view
184 * a DateBookWeekView get's created 184 * a DateBookWeekView get's created
185 * redraw() get's called. So what? 185 * redraw() get's called. So what?
186 * Remember that we're still in the c'tor 186 * Remember that we're still in the c'tor
187 * and no final layout has happened? Ok 187 * and no final layout has happened? Ok
188 * now all Events get arranged. Their x 188 * now all Events get arranged. Their x
189 * position get's determined by a QHeader 189 * position get's determined by a QHeader
190 * position. But the QHeader isn't layouted or 190 * position. But the QHeader isn't layouted or
191 * at the right position. redraw() is a slot 191 * at the right position. redraw() is a slot
192 * so we'll call it then via a singleShot 192 * so we'll call it then via a singleShot
193 * from view() 193 * from view()
194 */ 194 */
195 if( needEvilHack ){ 195 if( needEvilHack ){
196 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 196 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
197 } 197 }
198} 198}
199 199
200void DateBook::receive( const QCString &msg, const QByteArray &data ) 200void DateBook::receive( const QCString &msg, const QByteArray &data )
201{ 201{
202 QDataStream stream( data, IO_ReadOnly ); 202 QDataStream stream( data, IO_ReadOnly );
203 if ( msg == "timeChange(QString)" ) { 203 if ( msg == "timeChange(QString)" ) {
204 // update active view! 204 // update active view!
205 if ( dayAction->isOn() ) 205 if ( dayAction->isOn() )
206 viewDay(); 206 viewDay();
207 else if ( weekAction->isOn() ) 207 else if ( weekAction->isOn() )
208 viewWeek(); 208 viewWeek();
209 else if ( monthAction->isOn() ) 209 else if ( monthAction->isOn() )
210 viewMonth(); 210 viewMonth();
211 } 211 }
212 else if (msg == "editEvent(int)") { 212 else if (msg == "editEvent(int)") {
213 int uid; 213 int uid;
214 stream >> uid; 214 stream >> uid;
215 Event e=db->eventByUID(uid); 215 Event e=db->eventByUID(uid);
216 editEvent(e); 216 editEvent(e);
217 }else if (msg == "viewDefault(QDate)"){ 217 }else if (msg == "viewDefault(QDate)"){
218 QDate day; 218 QDate day;
219 stream >> day; 219 stream >> day;
220 viewDefault(day); 220 viewDefault(day);
221 } 221 }
222} 222}
223 223
224DateBook::~DateBook() 224DateBook::~DateBook()
225{ 225{
226} 226}
227 227
228void DateBook::slotSettings() 228void DateBook::slotSettings()
229{ 229{
230 DateBookSettings frmSettings( ampm, this ); 230 DateBookSettings frmSettings( ampm, this );
231 frmSettings.setStartTime( startTime ); 231 frmSettings.setStartTime( startTime );
232 frmSettings.setAlarmPreset( aPreset, presetTime ); 232 frmSettings.setAlarmPreset( aPreset, presetTime );
233 frmSettings.setJumpToCurTime( bJumpToCurTime ); 233 frmSettings.setJumpToCurTime( bJumpToCurTime );
234 frmSettings.setRowStyle( rowStyle ); 234 frmSettings.setRowStyle( rowStyle );
235 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 235 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
236 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 236 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
237 237
238 bool found=false; 238 bool found=false;
239 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 239 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
240 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 240 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
241 frmSettings.comboLocation->setCurrentItem(i); 241 frmSettings.comboLocation->setCurrentItem(i);
242 found=true; 242 found=true;
243 break; 243 break;
244 } 244 }
245 } 245 }
246 if(!found) { 246 if(!found) {
247 frmSettings.comboLocation->insertItem(defaultLocation); 247 frmSettings.comboLocation->insertItem(defaultLocation);
248 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 248 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
249 } 249 }
250 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 250 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
251 251
252 if ( QPEApplication::execDialog( &frmSettings ) ) { 252 if ( QPEApplication::execDialog( &frmSettings ) ) {
253 aPreset = frmSettings.alarmPreset(); 253 aPreset = frmSettings.alarmPreset();
254 presetTime = frmSettings.presetTime(); 254 presetTime = frmSettings.presetTime();
255 startTime = frmSettings.startTime(); 255 startTime = frmSettings.startTime();
256 bJumpToCurTime = frmSettings.jumpToCurTime(); 256 bJumpToCurTime = frmSettings.jumpToCurTime();
257 rowStyle = frmSettings.rowStyle(); 257 rowStyle = frmSettings.rowStyle();
258 defaultView=frmSettings.comboDefaultView->currentItem()+1; 258 defaultView=frmSettings.comboDefaultView->currentItem()+1;
259 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 259 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
260 defaultLocation=frmSettings.comboLocation->currentText(); 260 defaultLocation=frmSettings.comboLocation->currentText();
261 defaultCategories=frmSettings.comboCategory->currentCategories(); 261 defaultCategories=frmSettings.comboCategory->currentCategories();
262 262
263 if ( dayView ) { 263 if ( dayView ) {
264 dayView->setStartViewTime( startTime ); 264 dayView->setStartViewTime( startTime );
265 dayView->setJumpToCurTime( bJumpToCurTime ); 265 dayView->setJumpToCurTime( bJumpToCurTime );
266 dayView->setRowStyle( rowStyle ); 266 dayView->setRowStyle( rowStyle );
267 } 267 }
268 if ( weekView ) { 268 if ( weekView ) {
269 weekView->setStartViewTime( startTime ); 269 weekView->setStartViewTime( startTime );
@@ -424,246 +424,246 @@ void DateBook::duplicateEvent( const Event &e )
424 } 424 }
425 /* 425 /*
426 * The problem: 426 * The problem:
427 * DateBookDB does remove repeating events not by uid but by the time 427 * DateBookDB does remove repeating events not by uid but by the time
428 * the recurrence was created 428 * the recurrence was created
429 * so we need to update that time as well 429 * so we need to update that time as well
430 */ 430 */
431 Event::RepeatPattern rp = newEv.repeatPattern(); 431 Event::RepeatPattern rp = newEv.repeatPattern();
432 rp.createTime = ::time( NULL ); 432 rp.createTime = ::time( NULL );
433 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 433 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
434 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 434 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
435 newEv.assignUid(); 435 newEv.assignUid();
436 436
437 db->addEvent(newEv); 437 db->addEvent(newEv);
438 emit newEvent(); 438 emit newEvent();
439 break; 439 break;
440 } 440 }
441} 441}
442 442
443void DateBook::editEvent( const Event &e ) 443void DateBook::editEvent( const Event &e )
444{ 444{
445 if (syncing) { 445 if (syncing) {
446 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 446 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
447 return; 447 return;
448 } 448 }
449 449
450 // workaround added for text input. 450 // workaround added for text input.
451 QDialog editDlg( this, 0, TRUE ); 451 QDialog editDlg( this, 0, TRUE );
452 DateEntry *entry; 452 DateEntry *entry;
453 editDlg.setCaption( tr("Edit Event") ); 453 editDlg.setCaption( tr("Edit Event") );
454 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 454 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
455 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 455 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
456 sv->setResizePolicy( QScrollView::AutoOneFit ); 456 sv->setResizePolicy( QScrollView::AutoOneFit );
457 // KLUDGE!!! 457 // KLUDGE!!!
458 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 458 sv->setHScrollBarMode( QScrollView::AlwaysOff );
459 vb->addWidget( sv ); 459 vb->addWidget( sv );
460 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 460 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
461 entry->timezone->setEnabled( FALSE ); 461 entry->timezone->setEnabled( FALSE );
462 sv->addChild( entry ); 462 sv->addChild( entry );
463 463
464 while ( QPEApplication::execDialog( &editDlg ) ) { 464 while ( QPEApplication::execDialog( &editDlg ) ) {
465 Event newEv = entry->event(); 465 Event newEv = entry->event();
466 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 466 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
467 break; 467 break;
468 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 468 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
469 QString error = checkEvent(newEv); 469 QString error = checkEvent(newEv);
470 if (!error.isNull()) { 470 if (!error.isNull()) {
471 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; 471 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
472 } 472 }
473 db->editEvent(e, newEv); 473 db->editEvent(e, newEv);
474 emit newEvent(); 474 emit newEvent();
475 break; 475 break;
476 } 476 }
477} 477}
478 478
479void DateBook::removeEvent( const Event &e ) 479void DateBook::removeEvent( const Event &e )
480{ 480{
481 if (syncing) { 481 if (syncing) {
482 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 482 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
483 return; 483 return;
484 } 484 }
485 485
486 QString strName = e.description(); 486 QString strName = e.description();
487 487
488 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 488 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
489 return; 489 return;
490 490
491 db->removeEvent( e ); 491 db->removeEvent( e );
492 if ( views->visibleWidget() == dayView && dayView ) 492 if ( views->visibleWidget() == dayView && dayView )
493 dayView->redraw(); 493 dayView->redraw();
494 494
495} 495}
496 496
497void DateBook::addEvent( const Event &e ) 497void DateBook::addEvent( const Event &e )
498{ 498{
499 QDate d = e.start().date(); 499 QDate d = e.start().date();
500 initDay(); 500 initDay();
501 dayView->setDate( d ); 501 dayView->setDate( d );
502} 502}
503 503
504void DateBook::showDay( int year, int month, int day ) 504void DateBook::showDay( int year, int month, int day )
505{ 505{
506 QDate d(year, month, day); 506 QDate d(year, month, day);
507 view(DAY,d); 507 view(DAY,d);
508} 508}
509 509
510void DateBook::initDay() 510void DateBook::initDay()
511{ 511{
512 if ( !dayView ) { 512 if ( !dayView ) {
513 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 513 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
514 views->addWidget( dayView, DAY ); 514 views->addWidget( dayView, DAY );
515 dayView->setJumpToCurTime( bJumpToCurTime ); 515 dayView->setJumpToCurTime( bJumpToCurTime );
516 dayView->setStartViewTime( startTime ); 516 dayView->setStartViewTime( startTime );
517 dayView->setRowStyle( rowStyle ); 517 dayView->setRowStyle( rowStyle );
518 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 518 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
519 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 519 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
520 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 520 connect( dayView, SIGNAL( removeEvent(const Event&) ), this, SLOT( removeEvent(const Event&) ) );
521 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 521 connect( dayView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
522 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 522 connect( dayView, SIGNAL( duplicateEvent(const Event&) ), this, SLOT( duplicateEvent(const Event&) ) );
523 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); 523 connect( dayView, SIGNAL( beamEvent(const Event&) ), this, SLOT( beamEvent(const Event&) ) );
524 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); 524 connect( dayView, SIGNAL(sigNewEvent(const QString&)), this, SLOT(slotNewEventFromKey(const QString&)) );
525 } 525 }
526} 526}
527 527
528void DateBook::initWeek() 528void DateBook::initWeek()
529{ 529{
530 if ( !weekView ) { 530 if ( !weekView ) {
531 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 531 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
532 weekView->setStartViewTime( startTime ); 532 weekView->setStartViewTime( startTime );
533 views->addWidget( weekView, WEEK ); 533 views->addWidget( weekView, WEEK );
534 connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 534 connect( weekView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
535 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 535 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
536 } 536 }
537 537
538 //But also get it right: the year that we display can be different 538 //But also get it right: the year that we display can be different
539 //from the year of the current date. So, first find the year 539 //from the year of the current date. So, first find the year
540 //number of the current week. 540 //number of the current week.
541 int yearNumber, totWeeks; 541 int yearNumber, totWeeks;
542 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 542 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
543 543
544 QDate d = QDate( yearNumber, 12, 31 ); 544 QDate d = QDate( yearNumber, 12, 31 );
545 calcWeek( d, totWeeks, yearNumber, onMonday ); 545 calcWeek( d, totWeeks, yearNumber, onMonday );
546 546
547 while ( totWeeks == 1 ) { 547 while ( totWeeks == 1 ) {
548 d = d.addDays( -1 ); 548 d = d.addDays( -1 );
549 calcWeek( d, totWeeks, yearNumber, onMonday ); 549 calcWeek( d, totWeeks, yearNumber, onMonday );
550 } 550 }
551} 551}
552 552
553void DateBook::initWeekLst() { 553void DateBook::initWeekLst() {
554 if ( !weekLstView ) { 554 if ( !weekLstView ) {
555 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 555 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
556 views->addWidget( weekLstView, WEEKLST ); 556 views->addWidget( weekLstView, WEEKLST );
557 557
558 //weekLstView->setStartViewTime( startTime ); 558 //weekLstView->setStartViewTime( startTime );
559 connect( weekLstView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 559 connect( weekLstView, SIGNAL( showDate(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
560 connect( weekLstView, SIGNAL( addEvent( const QDateTime &, const QDateTime &, const QString & , const QString &) ), 560 connect( weekLstView, SIGNAL( addEvent(const QDateTime&,const QDateTime&,const QString&, const QString&) ),
561 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); 561 this, SLOT( slotNewEntry(const QDateTime&,const QDateTime&,const QString&, const QString&) ) );
562 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 562 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
563 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 563 connect( weekLstView, SIGNAL( editEvent(const Event&) ), this, SLOT( editEvent(const Event&) ) );
564 } 564 }
565} 565}
566 566
567 567
568void DateBook::initMonth() 568void DateBook::initMonth()
569{ 569{
570 if ( !monthView ) { 570 if ( !monthView ) {
571 monthView = new DateBookMonth( views, "month view", FALSE, db ); 571 monthView = new DateBookMonth( views, "month view", FALSE, db );
572 views->addWidget( monthView, MONTH ); 572 views->addWidget( monthView, MONTH );
573 connect( monthView, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) ); 573 connect( monthView, SIGNAL( dateClicked(int,int,int) ), this, SLOT( showDay(int,int,int) ) );
574 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 574 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
575 qApp->processEvents(); 575 qApp->processEvents();
576 } 576 }
577} 577}
578 578
579void DateBook::loadSettings() 579void DateBook::loadSettings()
580{ 580{
581 Config qpeconfig( "qpe" ); 581 Config qpeconfig( "qpe" );
582 qpeconfig.setGroup("Time"); 582 qpeconfig.setGroup("Time");
583 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 583 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
584 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 584 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
585 585
586 Config config("DateBook"); 586 Config config("DateBook");
587 config.setGroup("Main"); 587 config.setGroup("Main");
588 startTime = config.readNumEntry("startviewtime", 8); 588 startTime = config.readNumEntry("startviewtime", 8);
589 aPreset = config.readBoolEntry("alarmpreset"); 589 aPreset = config.readBoolEntry("alarmpreset");
590 presetTime = config.readNumEntry("presettime"); 590 presetTime = config.readNumEntry("presettime");
591 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 591 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
592 rowStyle = config.readNumEntry("rowstyle"); 592 rowStyle = config.readNumEntry("rowstyle");
593 defaultView = config.readNumEntry("defaultview",DAY); 593 defaultView = config.readNumEntry("defaultview",DAY);
594 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 594 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
595 595
596 defaultLocation=config.readEntry("defaultLocation"); 596 defaultLocation=config.readEntry("defaultLocation");
597 QString tmpString=config.readEntry("defaultCategories"); 597 QString tmpString=config.readEntry("defaultCategories");
598 QStringList tmpStringList=QStringList::split(",",tmpString); 598 QStringList tmpStringList=QStringList::split(",",tmpString);
599 defaultCategories.truncate(0); 599 defaultCategories.truncate(0);
600 600
601 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 601 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
602 defaultCategories.resize(defaultCategories.count()+1); 602 defaultCategories.resize(defaultCategories.count()+1);
603 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 603 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
604 } 604 }
605} 605}
606 606
607void DateBook::saveSettings() 607void DateBook::saveSettings()
608{ 608{
609 Config config( "qpe" ); 609 Config config( "qpe" );
610 Config configDB( "DateBook" ); 610 Config configDB( "DateBook" );
611 configDB.setGroup( "Main" ); 611 configDB.setGroup( "Main" );
612 configDB.writeEntry("startviewtime",startTime); 612 configDB.writeEntry("startviewtime",startTime);
613 configDB.writeEntry("alarmpreset",aPreset); 613 configDB.writeEntry("alarmpreset",aPreset);
614 configDB.writeEntry("presettime",presetTime); 614 configDB.writeEntry("presettime",presetTime);
615 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 615 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
616 configDB.writeEntry("rowstyle", rowStyle); 616 configDB.writeEntry("rowstyle", rowStyle);
617 configDB.writeEntry("defaultview",defaultView); 617 configDB.writeEntry("defaultview",defaultView);
618 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 618 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
619 619
620 configDB.writeEntry("defaultLocation",defaultLocation); 620 configDB.writeEntry("defaultLocation",defaultLocation);
621 QStringList tmpStringList; 621 QStringList tmpStringList;
622 for( uint i=0; i<defaultCategories.count(); i++) { 622 for( uint i=0; i<defaultCategories.count(); i++) {
623 tmpStringList << QString::number(defaultCategories[i]); 623 tmpStringList << QString::number(defaultCategories[i]);
624 } 624 }
625 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 625 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
626} 626}
627 627
628void DateBook::appMessage(const QCString& msg, const QByteArray& data) 628void DateBook::appMessage(const QCString& msg, const QByteArray& data)
629{ 629{
630 bool needShow = FALSE; 630 bool needShow = FALSE;
631 if ( msg == "alarm(QDateTime,int)" ) { 631 if ( msg == "alarm(QDateTime,int)" ) {
632 QDataStream ds(data,IO_ReadOnly); 632 QDataStream ds(data,IO_ReadOnly);
633 QDateTime when; int warn; 633 QDateTime when; int warn;
634 ds >> when >> warn; 634 ds >> when >> warn;
635 635
636 // check to make it's okay to continue, 636 // check to make it's okay to continue,
637 // this is the case that the time was set ahead, and 637 // this is the case that the time was set ahead, and
638 // we are forced given a stale alarm... 638 // we are forced given a stale alarm...
639 QDateTime current = QDateTime::currentDateTime(); 639 QDateTime current = QDateTime::currentDateTime();
640 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() ) 640 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
641 return; 641 return;
642 642
643 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 643 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
644 if ( list.count() > 0 ) { 644 if ( list.count() > 0 ) {
645 QString msg; 645 QString msg;
646 bool bSound = FALSE; 646 bool bSound = FALSE;
647 int stopTimer = 0; 647 int stopTimer = 0;
648 bool found = FALSE; 648 bool found = FALSE;
649 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 649 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
650 if ( (*it).event().hasAlarm() ) { 650 if ( (*it).event().hasAlarm() ) {
651 found = TRUE; 651 found = TRUE;
652 msg += "<CENTER><B>" + (*it).description() + "</B>" 652 msg += "<CENTER><B>" + (*it).description() + "</B>"
653 + "<BR>" + (*it).location() + "<BR>" 653 + "<BR>" + (*it).location() + "<BR>"
654 + TimeString::dateString((*it).event().start(),ampm) 654 + TimeString::dateString((*it).event().start(),ampm)
655 + (warn 655 + (warn
656 ? tr(" (in " + QString::number(warn) 656 ? tr(" (in " + QString::number(warn)
657 + tr(" minutes)")) 657 + tr(" minutes)"))
658 : QString("")) 658 : QString(""))
659 + "<BR>" 659 + "<BR>"
660 + (*it).notes() + "</CENTER>"; 660 + (*it).notes() + "</CENTER>";
661 if ( (*it).event().alarmSound() != Event::Silent ) { 661 if ( (*it).event().alarmSound() != Event::Silent ) {
662 bSound = TRUE; 662 bSound = TRUE;
663 } 663 }
664 } 664 }
665 } 665 }
666 if ( found ) { 666 if ( found ) {
667 if ( bSound ) { 667 if ( bSound ) {
668 Sound::soundAlarm(); 668 Sound::soundAlarm();
669 alarmCounter = 0; 669 alarmCounter = 0;
@@ -812,216 +812,214 @@ void DateBook::slotNewEventFromKey( const QString &str )
812{ 812{
813 if (syncing) { 813 if (syncing) {
814 QMessageBox::warning( this, tr("Calendar"), 814 QMessageBox::warning( this, tr("Calendar"),
815 tr( "Can not edit data, currently syncing") ); 815 tr( "Can not edit data, currently syncing") );
816 return; 816 return;
817 } 817 }
818 818
819 // We get to here from a key pressed in the Day View 819 // We get to here from a key pressed in the Day View
820 // So we can assume some things. We want the string 820 // So we can assume some things. We want the string
821 // passed in to be part of the description. 821 // passed in to be part of the description.
822 QDateTime start, end; 822 QDateTime start, end;
823 if ( views->visibleWidget() == dayView ) { 823 if ( views->visibleWidget() == dayView ) {
824 dayView->selectedDates( start, end ); 824 dayView->selectedDates( start, end );
825 } else if ( views->visibleWidget() == monthView ) { 825 } else if ( views->visibleWidget() == monthView ) {
826 QDate d = monthView->selectedDate(); 826 QDate d = monthView->selectedDate();
827 start = end = d; 827 start = end = d;
828 start.setTime( QTime( 10, 0 ) ); 828 start.setTime( QTime( 10, 0 ) );
829 end.setTime( QTime( 12, 0 ) ); 829 end.setTime( QTime( 12, 0 ) );
830 } else if ( views->visibleWidget() == weekView ) { 830 } else if ( views->visibleWidget() == weekView ) {
831 QDate d = weekView->date(); 831 QDate d = weekView->date();
832 start = end = d; 832 start = end = d;
833 start.setTime( QTime( 10, 0 ) ); 833 start.setTime( QTime( 10, 0 ) );
834 end.setTime( QTime( 12, 0 ) ); 834 end.setTime( QTime( 12, 0 ) );
835 } else if ( views->visibleWidget() == weekLstView ) { 835 } else if ( views->visibleWidget() == weekLstView ) {
836 QDate d = weekLstView->date(); 836 QDate d = weekLstView->date();
837 start = end = d; 837 start = end = d;
838 start.setTime( QTime( 10, 0 ) ); 838 start.setTime( QTime( 10, 0 ) );
839 end.setTime( QTime( 12, 0 ) ); 839 end.setTime( QTime( 12, 0 ) );
840 } 840 }
841 slotNewEntry(start, end, str); 841 slotNewEntry(start, end, str);
842} 842}
843void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) { 843void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str, const QString &location) {
844 // argh! This really needs to be encapsulated in a class 844 // argh! This really needs to be encapsulated in a class
845 // or function. 845 // or function.
846 QDialog newDlg( this, 0, TRUE ); 846 QDialog newDlg( this, 0, TRUE );
847 newDlg.setCaption( DateEntryBase::tr("New Event") ); 847 newDlg.setCaption( DateEntryBase::tr("New Event") );
848 DateEntry *e; 848 DateEntry *e;
849 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 849 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
850 QScrollView *sv = new QScrollView( &newDlg ); 850 QScrollView *sv = new QScrollView( &newDlg );
851 sv->setResizePolicy( QScrollView::AutoOneFit ); 851 sv->setResizePolicy( QScrollView::AutoOneFit );
852 sv->setFrameStyle( QFrame::NoFrame ); 852 sv->setFrameStyle( QFrame::NoFrame );
853 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 853 sv->setHScrollBarMode( QScrollView::AlwaysOff );
854 vb->addWidget( sv ); 854 vb->addWidget( sv );
855 855
856 Event ev; 856 Event ev;
857 ev.setDescription( str ); 857 ev.setDescription( str );
858 // When the new gui comes in, change this... 858 // When the new gui comes in, change this...
859 if(location==0) { 859 if(location==0) {
860 if(defaultLocation.isEmpty()) { 860 if(defaultLocation.isEmpty()) {
861 ev.setLocation(tr("(Unknown)")); 861 ev.setLocation(tr("(Unknown)"));
862 } else { 862 } else {
863 ev.setLocation( defaultLocation ); 863 ev.setLocation( defaultLocation );
864 } 864 }
865 } else { 865 } else {
866 ev.setLocation(location); 866 ev.setLocation(location);
867 } 867 }
868 ev.setCategories(defaultCategories); 868 ev.setCategories(defaultCategories);
869 ev.setStart( start ); 869 ev.setStart( start );
870 ev.setEnd( end ); 870 ev.setEnd( end );
871 871
872 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 872 e = new DateEntry( onMonday, ev, ampm, &newDlg );
873 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 873 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
874 sv->addChild( e ); 874 sv->addChild( e );
875 while ( QPEApplication::execDialog( &newDlg ) ) { 875 while ( QPEApplication::execDialog( &newDlg ) ) {
876 ev = e->event(); 876 ev = e->event();
877 ev.assignUid(); 877 ev.assignUid();
878 QString error = checkEvent( ev ); 878 QString error = checkEvent( ev );
879 if ( !error.isNull() ) { 879 if ( !error.isNull() ) {
880 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 880 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
881 continue; 881 continue;
882 } 882 }
883 db->addEvent( ev ); 883 db->addEvent( ev );
884 emit newEvent(); 884 emit newEvent();
885 break; 885 break;
886 } 886 }
887} 887}
888 888
889void DateBook::setDocument( const QString &filename ) 889void DateBook::setDocument( const QString &filename )
890{ 890{
891 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 891 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
892 892
893 QValueList<Event> tl = Event::readVCalendar( filename ); 893 QValueList<Event> tl = Event::readVCalendar( filename );
894 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 894 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
895 db->addEvent( *it ); 895 db->addEvent( *it );
896 } 896 }
897} 897}
898 898
899static const char * beamfile = "/tmp/obex/event.vcs"; 899static const char * beamfile = "/tmp/obex/event.vcs";
900 900
901void DateBook::beamEvent( const Event &e ) 901void DateBook::beamEvent( const Event &e )
902{ 902{
903 qDebug("trying to beamn"); 903 qDebug("trying to beamn");
904 unlink( beamfile ); // delete if exists 904 unlink( beamfile ); // delete if exists
905 mkdir("/tmp/obex/", 0755); 905 mkdir("/tmp/obex/", 0755);
906 Event::writeVCalendar( beamfile, e ); 906 Event::writeVCalendar( beamfile, e );
907 Ir *ir = new Ir( this ); 907 Ir *ir = new Ir( this );
908 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 908 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
909 QString description = e.description(); 909 QString description = e.description();
910 ir->send( beamfile, description, "text/x-vCalendar" ); 910 ir->send( beamfile, description, "text/x-vCalendar" );
911} 911}
912 912
913void DateBook::beamDone( Ir *ir ) 913void DateBook::beamDone( Ir *ir )
914{ 914{
915 delete ir; 915 delete ir;
916 unlink( beamfile ); 916 unlink( beamfile );
917} 917}
918 918
919void DateBook::slotFind() 919void DateBook::slotFind()
920{ 920{
921 // move it to the day view... 921 // move it to the day view...
922 viewDay(); 922 viewDay();
923 FindDialog frmFind( "Calendar", this ); // no tr needed 923 FindDialog frmFind( "Calendar", this ); // no tr needed
924 frmFind.setUseDate( true ); 924 frmFind.setUseDate( true );
925 frmFind.setDate( currentDate() ); 925 frmFind.setDate( currentDate() );
926 QObject::connect( &frmFind, 926 QObject::connect( &frmFind,
927 SIGNAL(signalFindClicked(const QString&, const QDate&, 927 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
928 bool, bool, int)),
929 this, 928 this,
930 SLOT(slotDoFind(const QString&, const QDate&, 929 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
931 bool, bool, int)) );
932 QObject::connect( this, 930 QObject::connect( this,
933 SIGNAL(signalNotFound()), 931 SIGNAL(signalNotFound()),
934 &frmFind, 932 &frmFind,
935 SLOT(slotNotFound()) ); 933 SLOT(slotNotFound()) );
936 QObject::connect( this, 934 QObject::connect( this,
937 SIGNAL(signalWrapAround()), 935 SIGNAL(signalWrapAround()),
938 &frmFind, 936 &frmFind,
939 SLOT(slotWrapAround()) ); 937 SLOT(slotWrapAround()) );
940 frmFind.move(0,0); 938 frmFind.move(0,0);
941 frmFind.exec(); 939 frmFind.exec();
942 inSearch = false; 940 inSearch = false;
943} 941}
944 942
945bool catComp( QArray<int> cats, int category ) 943bool catComp( QArray<int> cats, int category )
946{ 944{
947 bool returnMe; 945 bool returnMe;
948 int i, 946 int i,
949 count; 947 count;
950 948
951 count = int(cats.count()); 949 count = int(cats.count());
952 returnMe = false; 950 returnMe = false;
953 if ( (category == -1 && count == 0) || category == -2 ) 951 if ( (category == -1 && count == 0) || category == -2 )
954 returnMe = true; 952 returnMe = true;
955 else { 953 else {
956 for ( i = 0; i < count; i++ ) { 954 for ( i = 0; i < count; i++ ) {
957 if ( category == cats[i] ) { 955 if ( category == cats[i] ) {
958 returnMe = true; 956 returnMe = true;
959 break; 957 break;
960 } 958 }
961 } 959 }
962 } 960 }
963 return returnMe; 961 return returnMe;
964} 962}
965 963
966 964
967void DateBook::slotDoFind( const QString& txt, const QDate &dt, 965void DateBook::slotDoFind( const QString& txt, const QDate &dt,
968 bool caseSensitive, bool /*backwards*/, 966 bool caseSensitive, bool /*backwards*/,
969 int category ) 967 int category )
970{ 968{
971 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 969 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
972 next; 970 next;
973 971
974 QRegExp r( txt ); 972 QRegExp r( txt );
975 r.setCaseSensitive( caseSensitive ); 973 r.setCaseSensitive( caseSensitive );
976 974
977 975
978 static Event rev, nonrev; 976 static Event rev, nonrev;
979 if ( !inSearch ) { 977 if ( !inSearch ) {
980 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 978 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
981 nonrev.setStart( rev.start() ); 979 nonrev.setStart( rev.start() );
982 inSearch = true; 980 inSearch = true;
983 } 981 }
984 static QDate searchDate = dt; 982 static QDate searchDate = dt;
985 // if true at the end we will start at the begin again and afterwards 983 // if true at the end we will start at the begin again and afterwards
986 // we will emit string not found 984 // we will emit string not found
987 static bool wrapAround = true; 985 static bool wrapAround = true;
988 bool candidtate; 986 bool candidtate;
989 candidtate = false; 987 candidtate = false;
990 988
991 QValueList<Event> repeats = db->getRawRepeats(); 989 QValueList<Event> repeats = db->getRawRepeats();
992 990
993 // find the candidate for the first repeat that matches... 991 // find the candidate for the first repeat that matches...
994 // first check if there can ever be a match and then compute 992 // first check if there can ever be a match and then compute
995 // the next occurence from start. See if this event is closer 993 // the next occurence from start. See if this event is closer
996 // to the beginning (start. next < dtEnd) and not smaller then the last 994 // to the beginning (start. next < dtEnd) and not smaller then the last
997 // result. If we find a canditate we set the dtEnd to the time 995 // result. If we find a canditate we set the dtEnd to the time
998 // of the ocurrence and rev to this occurence. 996 // of the ocurrence and rev to this occurence.
999 // set wrap around to true because there might be more events coming 997 // set wrap around to true because there might be more events coming
1000 // and we're not at the end. 998 // and we're not at the end.
1001 QValueListConstIterator<Event> it; 999 QValueListConstIterator<Event> it;
1002 QDate start = dt; 1000 QDate start = dt;
1003 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1001 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1004 if ( catComp( (*it).categories(), category ) ) { 1002 if ( catComp( (*it).categories(), category ) ) {
1005 if ( (*it).match( r ) ) { 1003 if ( (*it).match( r ) ) {
1006 if ( nextOccurance( *it, start, next ) ) { 1004 if ( nextOccurance( *it, start, next ) ) {
1007 if ( next < dtEnd && !(next <= rev.start() ) ) { 1005 if ( next < dtEnd && !(next <= rev.start() ) ) {
1008 rev = *it; 1006 rev = *it;
1009 dtEnd = next; 1007 dtEnd = next;
1010 rev.setStart( next ); 1008 rev.setStart( next );
1011 candidtate = true; 1009 candidtate = true;
1012 wrapAround = true; 1010 wrapAround = true;
1013 } 1011 }
1014 } 1012 }
1015 } 1013 }
1016 } 1014 }
1017 } 1015 }
1018 1016
1019 // now the for first non repeat... 1017 // now the for first non repeat...
1020 // dtEnd is set by the previous iteration of repeatingEvents 1018 // dtEnd is set by the previous iteration of repeatingEvents
1021 // check if we find a closer item. Also set dtEnd to find even 1019 // check if we find a closer item. Also set dtEnd to find even
1022 // more close occurrence 1020 // more close occurrence
1023 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1021 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1024 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1022 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1025 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1023 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1026 if ( catComp( (*it).categories(), category ) ) { 1024 if ( catComp( (*it).categories(), category ) ) {
1027 if ( (*it).start() < dtEnd ) { 1025 if ( (*it).start() < dtEnd ) {
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 751a1da..ca63dc5 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -115,361 +115,361 @@ void DateBookDayView::moveUp()
115 scrollBy(0, -20); 115 scrollBy(0, -20);
116} 116}
117 117
118void DateBookDayView::moveDown() 118void DateBookDayView::moveDown()
119{ 119{
120 scrollBy(0, 20); 120 scrollBy(0, 20);
121} 121}
122 122
123void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) 123void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
124{ 124{
125 int w = cr.width(); 125 int w = cr.width();
126 int h = cr.height(); 126 int h = cr.height();
127 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 127 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
128 if ( showGrid() ) { 128 if ( showGrid() ) {
129 // Draw our lines 129 // Draw our lines
130 int x2 = w - 1; 130 int x2 = w - 1;
131 int y2 = h - 1; 131 int y2 = h - 1;
132 QPen pen( p->pen() ); 132 QPen pen( p->pen() );
133 p->setPen( colorGroup().dark() ); 133 p->setPen( colorGroup().dark() );
134 p->drawLine( x2, 0, x2, y2 ); 134 p->drawLine( x2, 0, x2, y2 );
135 p->drawLine( 0, y2, x2, y2 ); 135 p->drawLine( 0, y2, x2, y2 );
136 136
137 p->setPen( colorGroup().midlight() ); 137 p->setPen( colorGroup().midlight() );
138 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 138 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
139 139
140 p->setPen( pen ); 140 p->setPen( pen );
141 } 141 }
142} 142}
143 143
144void DateBookDayView::paintFocus( QPainter *, const QRect & ) 144void DateBookDayView::paintFocus( QPainter *, const QRect & )
145{ 145{
146} 146}
147 147
148void DateBookDayView::resizeEvent( QResizeEvent *e ) 148void DateBookDayView::resizeEvent( QResizeEvent *e )
149{ 149{
150 QTable::resizeEvent( e ); 150 QTable::resizeEvent( e );
151 columnWidthChanged( 0 ); 151 columnWidthChanged( 0 );
152 emit sigColWidthChanged(); 152 emit sigColWidthChanged();
153} 153}
154 154
155void DateBookDayView::keyPressEvent( QKeyEvent *e ) 155void DateBookDayView::keyPressEvent( QKeyEvent *e )
156{ 156{
157 QString txt = e->text(); 157 QString txt = e->text();
158 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 158 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
159 // we this is some sort of thing we know about... 159 // we this is some sort of thing we know about...
160 e->accept(); 160 e->accept();
161 emit sigCapturedKey( txt ); 161 emit sigCapturedKey( txt );
162 } else { 162 } else {
163 // I don't know what this key is, do you? 163 // I don't know what this key is, do you?
164 e->ignore(); 164 e->ignore();
165 } 165 }
166} 166}
167 167
168void DateBookDayView::setRowStyle( int style ) 168void DateBookDayView::setRowStyle( int style )
169{ 169{
170 if (style<0) style = 0; 170 if (style<0) style = 0;
171 171
172 for (int i=0; i<numRows(); i++) 172 for (int i=0; i<numRows(); i++)
173 setRowHeight(i, style*10+20); 173 setRowHeight(i, style*10+20);
174} 174}
175 175
176void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ ) 176void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent* /* e */ )
177{ 177{
178 int sh=99,eh=-1; 178 int sh=99,eh=-1;
179 179
180 for(int i=0;i<this->numSelections();i++) { 180 for(int i=0;i<this->numSelections();i++) {
181 QTableSelection sel = this->selection( i ); 181 QTableSelection sel = this->selection( i );
182 sh = QMIN(sh,sel.topRow()); 182 sh = QMIN(sh,sel.topRow());
183 eh = QMAX(sh,sel.bottomRow()+1); 183 eh = QMAX(sh,sel.bottomRow()+1);
184 } 184 }
185 if (sh > 23 || eh < 1) { 185 if (sh > 23 || eh < 1) {
186 sh=8; 186 sh=8;
187 eh=9; 187 eh=9;
188 } 188 }
189 189
190 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit"); 190 quickLineEdit=new DateBookDayViewQuickLineEdit(QDateTime(currDate,QTime(sh,0,0,0)),QDateTime(currDate,QTime(eh,0,0,0)),this->viewport(),"quickedit");
191 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0)); 191 quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0));
192 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0)); 192 this->moveChild(quickLineEdit,0,sh*this->rowHeight(0));
193 quickLineEdit->setFocus(); 193 quickLineEdit->setFocus();
194 quickLineEdit->show(); 194 quickLineEdit->show();
195} 195}
196 196
197//=========================================================================== 197//===========================================================================
198 198
199DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name) 199DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name)
200{ 200{
201 active=1; 201 active=1;
202 quickEvent.setStart(start); 202 quickEvent.setStart(start);
203 quickEvent.setEnd(end); 203 quickEvent.setEnd(end);
204 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed())); 204 connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed()));
205} 205}
206 206
207void DateBookDayViewQuickLineEdit::slotReturnPressed() 207void DateBookDayViewQuickLineEdit::slotReturnPressed()
208{ 208{
209 if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times. 209 if(active && (!this->text().isEmpty())) {// Fix to avoid having this event beeing added multiple times.
210 quickEvent.setDescription(this->text()); 210 quickEvent.setDescription(this->text());
211 connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &))); 211 connect(this,SIGNAL(insertEvent(const Event&)),this->topLevelWidget(),SLOT(insertEvent(const Event&)));
212 emit(insertEvent(quickEvent)); 212 emit(insertEvent(quickEvent));
213 active=0; 213 active=0;
214 } 214 }
215 /* we need to return to this object.. */ 215 /* we need to return to this object.. */
216 QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget 216 QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget
217} 217}
218void DateBookDayViewQuickLineEdit::finallyCallClose() { 218void DateBookDayViewQuickLineEdit::finallyCallClose() {
219 close(true); // also deletes this widget... 219 close(true); // also deletes this widget...
220} 220}
221 221
222void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */) 222void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent* /* e */)
223{ 223{
224 slotReturnPressed(); // Reuse code to add event and close this widget. 224 slotReturnPressed(); // Reuse code to add event and close this widget.
225} 225}
226 226
227//=========================================================================== 227//===========================================================================
228 228
229DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name ) 229DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name )
230 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 ) 230 : QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
231{ 231{
232 widgetList.setAutoDelete( true ); 232 widgetList.setAutoDelete( true );
233 header = new DateBookDayHeader( startOnMonday, this, "day header" ); 233 header = new DateBookDayHeader( startOnMonday, this, "day header" );
234 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 234 header->setDate( currDate.year(), currDate.month(), currDate.day() );
235 235
236 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); 236 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" );
237 m_allDays->hide(); 237 m_allDays->hide();
238 238
239 view = new DateBookDayView( ampm, this, "day view" ); 239 view = new DateBookDayView( ampm, this, "day view" );
240 240
241 connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) ); 241 connect( header, SIGNAL( dateChanged(int,int,int) ), this, SLOT( dateChanged(int,int,int) ) );
242 connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) ); 242 connect( header, SIGNAL( dateChanged(int,int,int) ), view, SLOT( slotDateChanged(int,int,int) ) );
243 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) ); 243 connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
244 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 244 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
245 connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) ); 245 connect( view, SIGNAL(sigCapturedKey(const QString&)), this, SIGNAL(sigNewEvent(const QString&)) );
246 246
247 QTimer *timer = new QTimer( this ); 247 QTimer *timer = new QTimer( this );
248 248
249 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors 249 connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) );//connect timer for updating timeMarker & daywidgetcolors
250 timer->start( 1000*60*5, FALSE ); //update every 5min 250 timer->start( 1000*60*5, FALSE ); //update every 5min
251 251
252 selectedWidget = 0; 252 selectedWidget = 0;
253 253
254 timeMarker = new DateBookDayTimeMarker( this ); 254 timeMarker = new DateBookDayTimeMarker( this );
255 timeMarker->setTime( QTime::currentTime() ); 255 timeMarker->setTime( QTime::currentTime() );
256 rowStyle = -1; // initialize with bogus values 256 rowStyle = -1; // initialize with bogus values
257 jumpToCurTime = false; 257 jumpToCurTime = false;
258} 258}
259 259
260void DateBookDay::setJumpToCurTime( bool bJump ) 260void DateBookDay::setJumpToCurTime( bool bJump )
261{ 261{
262 jumpToCurTime = bJump; 262 jumpToCurTime = bJump;
263} 263}
264 264
265void DateBookDay::setRowStyle( int style ) 265void DateBookDay::setRowStyle( int style )
266{ 266{
267 if (rowStyle != style) view->setRowStyle( style ); 267 if (rowStyle != style) view->setRowStyle( style );
268 rowStyle = style; 268 rowStyle = style;
269} 269}
270 270
271void DateBookDay::updateView( void ) 271void DateBookDay::updateView( void )
272{ 272{
273 timeMarker->setTime( QTime::currentTime() ); 273 timeMarker->setTime( QTime::currentTime() );
274 //need to find a way to update all DateBookDayWidgets 274 //need to find a way to update all DateBookDayWidgets
275} 275}
276 276
277void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) 277void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
278{ 278{
279 selectedWidget = w; 279 selectedWidget = w;
280} 280}
281 281
282DateBookDayWidget * DateBookDay::getSelectedWidget( void ) 282DateBookDayWidget * DateBookDay::getSelectedWidget( void )
283{ 283{
284 return selectedWidget; 284 return selectedWidget;
285} 285}
286 286
287void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) 287void DateBookDay::selectedDates( QDateTime &start, QDateTime &end )
288{ 288{
289 start.setDate( currDate ); 289 start.setDate( currDate );
290 end.setDate( currDate ); 290 end.setDate( currDate );
291 291
292 int sh=99,eh=-1; 292 int sh=99,eh=-1;
293 293
294 int n = dayView()->numSelections(); 294 int n = dayView()->numSelections();
295 295
296 for (int i=0; i<n; i++) { 296 for (int i=0; i<n; i++) {
297 QTableSelection sel = dayView()->selection( i ); 297 QTableSelection sel = dayView()->selection( i );
298 sh = QMIN(sh,sel.topRow()); 298 sh = QMIN(sh,sel.topRow());
299 eh = QMAX(sh,sel.bottomRow()+1); 299 eh = QMAX(sh,sel.bottomRow()+1);
300 } 300 }
301 301
302 if (sh > 23 || eh < 1) { 302 if (sh > 23 || eh < 1) {
303 sh=8; 303 sh=8;
304 eh=9; 304 eh=9;
305 } 305 }
306 306
307 start.setTime( QTime( sh, 0, 0 ) ); 307 start.setTime( QTime( sh, 0, 0 ) );
308 end.setTime( QTime( eh, 0, 0 ) ); 308 end.setTime( QTime( eh, 0, 0 ) );
309} 309}
310 310
311void DateBookDay::setDate( int y, int m, int d ) 311void DateBookDay::setDate( int y, int m, int d )
312{ 312{
313 header->setDate( y, m, d ); 313 header->setDate( y, m, d );
314 selectedWidget = 0; 314 selectedWidget = 0;
315} 315}
316 316
317void DateBookDay::setDate( QDate d) 317void DateBookDay::setDate( QDate d)
318{ 318{
319 header->setDate( d.year(), d.month(), d.day() ); 319 header->setDate( d.year(), d.month(), d.day() );
320 selectedWidget = 0; 320 selectedWidget = 0;
321} 321}
322 322
323void DateBookDay::dateChanged( int y, int m, int d ) 323void DateBookDay::dateChanged( int y, int m, int d )
324{ 324{
325 QDate date( y, m, d ); 325 QDate date( y, m, d );
326 if ( currDate == date ) 326 if ( currDate == date )
327 return; 327 return;
328 currDate.setYMD( y, m, d ); 328 currDate.setYMD( y, m, d );
329 relayoutPage(); 329 relayoutPage();
330 dayView()->clearSelection(); 330 dayView()->clearSelection();
331 QTableSelection ts; 331 QTableSelection ts;
332 332
333 if (jumpToCurTime && this->date() == QDate::currentDate()) 333 if (jumpToCurTime && this->date() == QDate::currentDate())
334 { 334 {
335 ts.init( QTime::currentTime().hour(), 0); 335 ts.init( QTime::currentTime().hour(), 0);
336 ts.expandTo( QTime::currentTime().hour(), 0); 336 ts.expandTo( QTime::currentTime().hour(), 0);
337 } else { 337 } else {
338 ts.init( startTime, 0 ); 338 ts.init( startTime, 0 );
339 ts.expandTo( startTime, 0 ); 339 ts.expandTo( startTime, 0 );
340 } 340 }
341 341
342 dayView()->addSelection( ts ); 342 dayView()->addSelection( ts );
343 selectedWidget = 0; 343 selectedWidget = 0;
344} 344}
345 345
346void DateBookDay::redraw() 346void DateBookDay::redraw()
347{ 347{
348 if ( isUpdatesEnabled() ) 348 if ( isUpdatesEnabled() )
349 relayoutPage(); 349 relayoutPage();
350} 350}
351 351
352void DateBookDay::getEvents() 352void DateBookDay::getEvents()
353{ 353{
354 widgetList.clear(); 354 widgetList.clear();
355 355
356 /* clear the AllDay List */ 356 /* clear the AllDay List */
357 m_allDays->hide(); // just in case 357 m_allDays->hide(); // just in case
358 m_allDays->removeAllEvents(); 358 m_allDays->removeAllEvents();
359 359
360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
361 QValueListIterator<EffectiveEvent> it; 361 QValueListIterator<EffectiveEvent> it;
362 QObject* object = 0; 362 QObject* object = 0;
363 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 363 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
364 EffectiveEvent ev=*it; 364 EffectiveEvent ev=*it;
365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day.
366 if (ev.event().type() == Event::AllDay ) { 366 if (ev.event().type() == Event::AllDay ) {
367 object = m_allDays->addEvent( ev ); 367 object = m_allDays->addEvent( ev );
368 if (!object) 368 if (!object)
369 continue; 369 continue;
370 }else { 370 }else {
371 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 371 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
372 widgetList.append( w ); 372 widgetList.append( w );
373 object = w; 373 object = w;
374 } 374 }
375 375
376 connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); 376 connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) );
377 connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); 377 connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) );
378 connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); 378 connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) );
379 connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); 379 connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) );
380 380
381 } 381 }
382 } 382 }
383} 383}
384 384
385static int place( const DateBookDayWidget *item, bool *used, int maxn ) 385static int place( const DateBookDayWidget *item, bool *used, int maxn )
386{ 386{
387 int place = 0; 387 int place = 0;
388 int start = item->event().start().hour(); 388 int start = item->event().start().hour();
389 QTime e = item->event().end(); 389 QTime e = item->event().end();
390 int end = e.hour(); 390 int end = e.hour();
391 if ( e.minute() < 5 ) 391 if ( e.minute() < 5 )
392 end--; 392 end--;
393 if ( end < start ) 393 if ( end < start )
394 end = start; 394 end = start;
395 while ( place < maxn ) { 395 while ( place < maxn ) {
396 bool free = TRUE; 396 bool free = TRUE;
397 int s = start; 397 int s = start;
398 while( s <= end ) { 398 while( s <= end ) {
399 if ( used[10*s+place] ) { 399 if ( used[10*s+place] ) {
400 free = FALSE; 400 free = FALSE;
401 break; 401 break;
402 } 402 }
403 s++; 403 s++;
404 } 404 }
405 if ( free ) 405 if ( free )
406 break; 406 break;
407 place++; 407 place++;
408 } 408 }
409 if ( place == maxn ) { 409 if ( place == maxn ) {
410 return -1; 410 return -1;
411 } 411 }
412 while( start <= end ) { 412 while( start <= end ) {
413 used[10*start+place] = TRUE; 413 used[10*start+place] = TRUE;
414 start++; 414 start++;
415 } 415 }
416 return place; 416 return place;
417} 417}
418 418
419 419
420void DateBookDay::relayoutPage( bool fromResize ) 420void DateBookDay::relayoutPage( bool fromResize )
421{ 421{
422 setUpdatesEnabled( FALSE ); 422 setUpdatesEnabled( FALSE );
423 if ( !fromResize ) { 423 if ( !fromResize ) {
424 getEvents(); // no need we already have them! 424 getEvents(); // no need we already have them!
425 425
426 if (m_allDays->items() > 0 ) 426 if (m_allDays->items() > 0 )
427 m_allDays->show(); 427 m_allDays->show();
428 /* 428 /*
429 * else if ( m_allDays->items() == 0 ) already hide in getEvents 429 * else if ( m_allDays->items() == 0 ) already hide in getEvents
430 */ 430 */
431 } 431 }
432 432
433 widgetList.sort(); 433 widgetList.sort();
434 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning 434 //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
435 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view 435 //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
436 436
437 int wCount = widgetList.count(); 437 int wCount = widgetList.count();
438 int wid = view->columnWidth(0)-1; 438 int wid = view->columnWidth(0)-1;
439 int wd; 439 int wd;
440 int n = 1; 440 int n = 1;
441 441
442 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget 442 QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
443 443
444 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); 444 for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
445 445
446 if ( wCount < 20 ) { 446 if ( wCount < 20 ) {
447 447
448 QArray<QRect> geometries(wCount); 448 QArray<QRect> geometries(wCount);
449 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector 449 for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++);//stores geometry for each widget in vector
450 450
451 for ( int i = 0; i < wCount; i++) { 451 for ( int i = 0; i < wCount; i++) {
452 QValueList<int> intersectedWidgets; 452 QValueList<int> intersectedWidgets;
453 453
454 //find all widgets intersecting with widgetList.at(i) 454 //find all widgets intersecting with widgetList.at(i)
455 for ( int j = 0; j < wCount; j++) { 455 for ( int j = 0; j < wCount; j++) {
456 if (i != j) 456 if (i != j)
457 if (geometries[j].intersects(geometries[i])) 457 if (geometries[j].intersects(geometries[i]))
458 intersectedWidgets.append(j); 458 intersectedWidgets.append(j);
459 } 459 }
460 460
461 //for each of these intersecting widgets find out how many widgets are they intersecting with 461 //for each of these intersecting widgets find out how many widgets are they intersecting with
462 for ( uint j = 0; j < intersectedWidgets.count(); j++) 462 for ( uint j = 0; j < intersectedWidgets.count(); j++)
463 { 463 {
464 QArray<int> inter(wCount); 464 QArray<int> inter(wCount);
465 inter[j]=1; 465 inter[j]=1;
466 466
467 if (intersectedWidgets[j] != -1) 467 if (intersectedWidgets[j] != -1)
468 for ( uint k = j; k < intersectedWidgets.count(); k++) { 468 for ( uint k = j; k < intersectedWidgets.count(); k++) {
469 if (j != k && intersectedWidgets[k] != -1) 469 if (j != k && intersectedWidgets[k] != -1)
470 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { 470 if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) {
471 inter[j]++; 471 inter[j]++;
472 intersectedWidgets[k] = -1; 472 intersectedWidgets[k] = -1;
473 } 473 }
474 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; 474 if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1;
475 } 475 }
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index d43d31a..a0aefd3 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -1,159 +1,159 @@
1/**************************************************************************** 1/****************************************************************************
2** GPL by Rajko Albrecht 2** GPL by Rajko Albrecht
3** 3**
4** 4**
5** 5**
6** 6**
7** 7**
8****************************************************************************/ 8****************************************************************************/
9#include "datebookdayallday.h" 9#include "datebookdayallday.h"
10 10
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qpe/ir.h> 12#include <qpe/ir.h>
13#include <qpopupmenu.h> 13#include <qpopupmenu.h>
14#include <qtimer.h> 14#include <qtimer.h>
15 15
16#include "datebookday.h" 16#include "datebookday.h"
17 17
18/* 18/*
19 * Constructs a DatebookdayAllday which is a child of 'parent', with the 19 * Constructs a DatebookdayAllday which is a child of 'parent', with the
20 * name 'name' and widget flags set to 'f' 20 * name 'name' and widget flags set to 'f'
21 */ 21 */
22DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) 22DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags )
23 : QScrollView( parent, name ),item_count(0),dateBook(db) 23 : QScrollView( parent, name ),item_count(0),dateBook(db)
24{ 24{
25 if ( !name ) 25 if ( !name )
26 setName( "DatebookdayAllday" ); 26 setName( "DatebookdayAllday" );
27 setMinimumSize( QSize( 0, 0 ) ); 27 setMinimumSize( QSize( 0, 0 ) );
28 setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); 28 setMaximumHeight(3* (QFontMetrics(font()).height()+4) );
29 29
30 m_MainFrame = new QFrame(viewport()); 30 m_MainFrame = new QFrame(viewport());
31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); 31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
32 setFrameStyle(QFrame::NoFrame|QFrame::Plain); 32 setFrameStyle(QFrame::NoFrame|QFrame::Plain);
33 setResizePolicy( QScrollView::Default ); 33 setResizePolicy( QScrollView::Default );
34 setHScrollBarMode( AlwaysOff ); 34 setHScrollBarMode( AlwaysOff );
35 addChild(m_MainFrame); 35 addChild(m_MainFrame);
36 36
37 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); 37 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame );
38 datebookdayalldayLayout->setSpacing( 0 ); 38 datebookdayalldayLayout->setSpacing( 0 );
39 datebookdayalldayLayout->setMargin( 0 ); 39 datebookdayalldayLayout->setMargin( 0 );
40 40
41 lblDesc = new DatebookEventDesc(parent->parentWidget(),""); 41 lblDesc = new DatebookEventDesc(parent->parentWidget(),"");
42 lblDesc->setBackgroundColor(Qt::yellow); 42 lblDesc->setBackgroundColor(Qt::yellow);
43 lblDesc->hide(); 43 lblDesc->hide();
44 subWidgets.setAutoDelete(true); 44 subWidgets.setAutoDelete(true);
45} 45}
46 46
47/* 47/*
48 * Destroys the object and frees any allocated resources 48 * Destroys the object and frees any allocated resources
49 */ 49 */
50DatebookdayAllday::~DatebookdayAllday() 50DatebookdayAllday::~DatebookdayAllday()
51{ 51{
52 // no need to delete child widgets, Qt does it all for us 52 // no need to delete child widgets, Qt does it all for us
53} 53}
54 54
55DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) 55DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
56{ 56{
57 DatebookAlldayDisp * lb; 57 DatebookAlldayDisp * lb;
58 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); 58 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL);
59 lb->show(); 59 lb->show();
60 datebookdayalldayLayout->addWidget(lb); 60 datebookdayalldayLayout->addWidget(lb);
61 subWidgets.append(lb); 61 subWidgets.append(lb);
62 62
63 connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&))); 63 connect(lb,SIGNAL(displayMe(const Event&)),lblDesc,SLOT(disp_event(const Event&)));
64 ++item_count; 64 ++item_count;
65 65
66 return lb; 66 return lb;
67} 67}
68 68
69void DatebookdayAllday::removeAllEvents() 69void DatebookdayAllday::removeAllEvents()
70{ 70{
71 subWidgets.clear(); 71 subWidgets.clear();
72 item_count = 0; 72 item_count = 0;
73} 73}
74 74
75DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, 75DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
76 QWidget* parent,const char* name,WFlags f) 76 QWidget* parent,const char* name,WFlags f)
77 : QLabel(parent,name,f),m_Ev(ev),dateBook(db) 77 : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
78{ 78{
79 QString strDesc = m_Ev.description(); 79 QString strDesc = m_Ev.description();
80 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 80 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
81 setBackgroundColor(yellow); 81 setBackgroundColor(yellow);
82 setText(strDesc); 82 setText(strDesc);
83 setFrameStyle(QFrame::Raised|QFrame::Panel); 83 setFrameStyle(QFrame::Raised|QFrame::Panel);
84 84
85 int s = QFontMetrics(font()).height()+4; 85 int s = QFontMetrics(font()).height()+4;
86 setMaximumHeight( s ); 86 setMaximumHeight( s );
87 setMinimumSize( QSize( 0, s ) ); 87 setMinimumSize( QSize( 0, s ) );
88} 88}
89 89
90DatebookAlldayDisp::~DatebookAlldayDisp() 90DatebookAlldayDisp::~DatebookAlldayDisp()
91{ 91{
92} 92}
93 93
94void DatebookAlldayDisp::beam_single_event() 94void DatebookAlldayDisp::beam_single_event()
95{ 95{
96 // create an Event and beam it... 96 // create an Event and beam it...
97 /* 97 /*
98 * Start with the easy stuff. If start and end date is the same we can just use 98 * Start with the easy stuff. If start and end date is the same we can just use
99 * the values of effective m_Events 99 * the values of effective m_Events
100 * If it is a multi day m_Event we need to find the real start and end date... 100 * If it is a multi day m_Event we need to find the real start and end date...
101 */ 101 */
102 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 102 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
103 Event m_Event( m_Ev.event() ); 103 Event m_Event( m_Ev.event() );
104 104
105 QDateTime dt( m_Ev.date(), m_Ev.start() ); 105 QDateTime dt( m_Ev.date(), m_Ev.start() );
106 m_Event.setStart( dt ); 106 m_Event.setStart( dt );
107 107
108 dt.setTime( m_Ev.end() ); 108 dt.setTime( m_Ev.end() );
109 m_Event.setEnd( dt ); 109 m_Event.setEnd( dt );
110 emit beamMe( m_Event ); 110 emit beamMe( m_Event );
111 }else { 111 }else {
112 /* 112 /*
113 * at least the the Times are right now 113 * at least the the Times are right now
114 */ 114 */
115 QDateTime start( m_Ev.event().start() ); 115 QDateTime start( m_Ev.event().start() );
116 QDateTime end ( m_Ev.event().end () ); 116 QDateTime end ( m_Ev.event().end () );
117 117
118 /* 118 /*
119 * ok we know the start date or we need to find it 119 * ok we know the start date or we need to find it
120 */ 120 */
121 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { 121 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
122 start.setDate( m_Ev.date() ); 122 start.setDate( m_Ev.date() );
123 }else { 123 }else {
124 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); 124 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook );
125 start.setDate( dt ); 125 start.setDate( dt );
126 } 126 }
127 127
128 /* 128 /*
129 * ok we know now the end date... 129 * ok we know now the end date...
130 * else 130 * else
131 * get to know the offset btw the real start and real end 131 * get to know the offset btw the real start and real end
132 * and then add it to the new start date... 132 * and then add it to the new start date...
133 */ 133 */
134 if ( m_Ev.end() != QTime(23, 59, 59 ) ) { 134 if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
135 end.setDate( m_Ev.date() ); 135 end.setDate( m_Ev.date() );
136 }else{ 136 }else{
137 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); 137 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() );
138 end.setDate( start.date().addDays( days ) ); 138 end.setDate( start.date().addDays( days ) );
139 } 139 }
140 Event m_Event( m_Ev.event() ); 140 Event m_Event( m_Ev.event() );
141 m_Event.setStart( start ); 141 m_Event.setStart( start );
142 m_Event.setEnd ( end ); 142 m_Event.setEnd ( end );
143 emit beamMe( m_Event ); 143 emit beamMe( m_Event );
144 } 144 }
145} 145}
146 146
147void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 147void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
148{ 148{
149 Event ev = m_Ev.event(); 149 Event ev = m_Ev.event();
150 QColor b = backgroundColor(); 150 QColor b = backgroundColor();
151 setBackgroundColor(green); 151 setBackgroundColor(green);
152 update(); 152 update();
153 QPopupMenu m; 153 QPopupMenu m;
154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
155 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 155 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
157 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 157 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
158 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); 158 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
159 m.insertItem( tr( "Info"),6); 159 m.insertItem( tr( "Info"),6);
diff --git a/core/pim/datebook/datebookdayheaderimpl.cpp b/core/pim/datebook/datebookdayheaderimpl.cpp
index 213c843..51b78ca 100644
--- a/core/pim/datebook/datebookdayheaderimpl.cpp
+++ b/core/pim/datebook/datebookdayheaderimpl.cpp
@@ -3,194 +3,194 @@
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "datebookdayheaderimpl.h" 20#include "datebookdayheaderimpl.h"
21 21
22#include <qpe/datebookmonth.h> 22#include <qpe/datebookmonth.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24 24
25#include <qbuttongroup.h> 25#include <qbuttongroup.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27 27
28 28
29/* 29/*
30 * Constructs a DateBookDayHeader which is a child of 'parent', with the 30 * Constructs a DateBookDayHeader which is a child of 'parent', with the
31 * name 'name' and widget flags set to 'f' 31 * name 'name' and widget flags set to 'f'
32 * 32 *
33 * The dialog will by default be modeless, unless you set 'modal' to 33 * The dialog will by default be modeless, unless you set 'modal' to
34 * TRUE to construct a modal dialog. 34 * TRUE to construct a modal dialog.
35 */ 35 */
36DateBookDayHeader::DateBookDayHeader( bool useMonday, 36DateBookDayHeader::DateBookDayHeader( bool useMonday,
37 QWidget* parent, const char* name ) 37 QWidget* parent, const char* name )
38 : DateBookDayHeaderBase( parent, name ), 38 : DateBookDayHeaderBase( parent, name ),
39 bUseMonday( useMonday ) 39 bUseMonday( useMonday )
40{ 40{
41 connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); 41 connect(date,SIGNAL(pressed()),this,SLOT(pickDate()));
42 42
43 setupNames(); 43 setupNames();
44 44
45 forward->setPixmap( Resource::loadPixmap( "forward" ) ); 45 forward->setPixmap( Resource::loadPixmap( "forward" ) );
46 back->setPixmap( Resource::loadPixmap( "back" ) ); 46 back->setPixmap( Resource::loadPixmap( "back" ) );
47 forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); 47 forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) );
48 backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); 48 backweek->setPixmap( Resource::loadPixmap( "fastback" ) );
49 49
50 setBackgroundMode( PaletteButton ); 50 setBackgroundMode( PaletteButton );
51 grpDays->setBackgroundMode( PaletteButton ); 51 grpDays->setBackgroundMode( PaletteButton );
52} 52}
53 53
54/* 54/*
55 * Destroys the object and frees any allocated resources 55 * Destroys the object and frees any allocated resources
56 */ 56 */
57DateBookDayHeader::~DateBookDayHeader() 57DateBookDayHeader::~DateBookDayHeader()
58{ 58{
59 // no need to delete child widgets, Qt does it all for us 59 // no need to delete child widgets, Qt does it all for us
60} 60}
61 61
62void DateBookDayHeader::setStartOfWeek( bool onMonday ) 62void DateBookDayHeader::setStartOfWeek( bool onMonday )
63{ 63{
64 bUseMonday = onMonday; 64 bUseMonday = onMonday;
65 setupNames(); 65 setupNames();
66 setDate( currDate.year(), currDate.month(), currDate.day() ); 66 setDate( currDate.year(), currDate.month(), currDate.day() );
67} 67}
68 68
69void DateBookDayHeader::setupNames() 69void DateBookDayHeader::setupNames()
70{ 70{
71 if ( bUseMonday ) { 71 if ( bUseMonday ) {
72 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 72 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
73 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 73 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
74 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 74 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
75 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 75 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
76 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 76 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
77 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 77 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
78 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 78 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
79 } else { 79 } else {
80 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 80 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
81 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 81 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
82 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 82 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
83 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 83 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
84 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 84 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
85 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 85 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
86 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 86 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
87 } 87 }
88} 88}
89 89
90 90
91void DateBookDayHeader::pickDate() 91void DateBookDayHeader::pickDate()
92{ 92{
93 static QPopupMenu *m1 = 0; 93 static QPopupMenu *m1 = 0;
94 static DateBookMonth *picker = 0; 94 static DateBookMonth *picker = 0;
95 if ( !m1 ) { 95 if ( !m1 ) {
96 m1 = new QPopupMenu( this ); 96 m1 = new QPopupMenu( this );
97 picker = new DateBookMonth( m1, 0, TRUE ); 97 picker = new DateBookMonth( m1, 0, TRUE );
98 m1->insertItem( picker ); 98 m1->insertItem( picker );
99 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 99 connect( picker, SIGNAL( dateClicked(int,int,int) ),
100 this, SLOT( setDate( int, int, int ) ) ); 100 this, SLOT( setDate(int,int,int) ) );
101 connect( m1, SIGNAL( aboutToHide() ), 101 connect( m1, SIGNAL( aboutToHide() ),
102 this, SLOT( gotHide() ) ); 102 this, SLOT( gotHide() ) );
103 } 103 }
104 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 104 picker->setDate( currDate.year(), currDate.month(), currDate.day() );
105 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); 105 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height())));
106 picker->setFocus(); 106 picker->setFocus();
107} 107}
108 108
109void DateBookDayHeader::gotHide() 109void DateBookDayHeader::gotHide()
110{ 110{
111 // we have to redo the button... 111 // we have to redo the button...
112 date->setDown( false ); 112 date->setDown( false );
113} 113}
114 114
115/* 115/*
116 * public slot 116 * public slot
117 */ 117 */
118void DateBookDayHeader::goBack() 118void DateBookDayHeader::goBack()
119{ 119{
120 currDate = currDate.addDays( -1 ); 120 currDate = currDate.addDays( -1 );
121 setDate( currDate.year(), currDate.month(), currDate.day() ); 121 setDate( currDate.year(), currDate.month(), currDate.day() );
122} 122}
123/* 123/*
124 * public slot 124 * public slot
125 */ 125 */
126void DateBookDayHeader::goForward() 126void DateBookDayHeader::goForward()
127{ 127{
128 currDate = currDate.addDays( 1 ); 128 currDate = currDate.addDays( 1 );
129 setDate( currDate.year(), currDate.month(), currDate.day() ); 129 setDate( currDate.year(), currDate.month(), currDate.day() );
130} 130}
131/* 131/*
132 * public slot 132 * public slot
133 */ 133 */
134void DateBookDayHeader::goBackWeek() 134void DateBookDayHeader::goBackWeek()
135{ 135{
136 currDate = currDate.addDays( -7 ); 136 currDate = currDate.addDays( -7 );
137 setDate( currDate.year(), currDate.month(), currDate.day() ); 137 setDate( currDate.year(), currDate.month(), currDate.day() );
138} 138}
139/* 139/*
140 * public slot 140 * public slot
141 */ 141 */
142void DateBookDayHeader::goForwardWeek() 142void DateBookDayHeader::goForwardWeek()
143{ 143{
144 currDate = currDate.addDays( 7 ); 144 currDate = currDate.addDays( 7 );
145 setDate( currDate.year(), currDate.month(), currDate.day() ); 145 setDate( currDate.year(), currDate.month(), currDate.day() );
146} 146}
147 147
148 148
149/* 149/*
150 * public slot 150 * public slot
151 */ 151 */
152void DateBookDayHeader::setDate( int y, int m, int d ) 152void DateBookDayHeader::setDate( int y, int m, int d )
153{ 153{
154 currDate.setYMD( y, m, d ); 154 currDate.setYMD( y, m, d );
155 date->setText( TimeString::shortDate( currDate ) ); 155 date->setText( TimeString::shortDate( currDate ) );
156 156
157 int iDayOfWeek = currDate.dayOfWeek(); 157 int iDayOfWeek = currDate.dayOfWeek();
158 // cleverly adjust the day depending on how we start the week 158 // cleverly adjust the day depending on how we start the week
159 if ( bUseMonday ) 159 if ( bUseMonday )
160 iDayOfWeek--; 160 iDayOfWeek--;
161 else { 161 else {
162 if ( iDayOfWeek == 7 ) // Sunday 162 if ( iDayOfWeek == 7 ) // Sunday
163 iDayOfWeek = 0; 163 iDayOfWeek = 0;
164 } 164 }
165 grpDays->setButton( iDayOfWeek ); 165 grpDays->setButton( iDayOfWeek );
166 emit dateChanged( y, m, d ); 166 emit dateChanged( y, m, d );
167} 167}
168 168
169/* 169/*
170 * public slot 170 * public slot
171 */ 171 */
172void DateBookDayHeader::setDay( int day ) 172void DateBookDayHeader::setDay( int day )
173{ 173{
174 int realDay; 174 int realDay;
175 int dayOfWeek = currDate.dayOfWeek(); 175 int dayOfWeek = currDate.dayOfWeek();
176 176
177 // a little adjustment is needed... 177 // a little adjustment is needed...
178 if ( bUseMonday ) 178 if ( bUseMonday )
179 realDay = day + 1 ; 179 realDay = day + 1 ;
180 else if ( !bUseMonday && day == 0 ) // sunday 180 else if ( !bUseMonday && day == 0 ) // sunday
181 realDay = 7; 181 realDay = 7;
182 else 182 else
183 realDay = day; 183 realDay = day;
184 // special cases first... 184 // special cases first...
185 if ( realDay == 7 && !bUseMonday ) { 185 if ( realDay == 7 && !bUseMonday ) {
186 while ( currDate.dayOfWeek() != realDay ) 186 while ( currDate.dayOfWeek() != realDay )
187 currDate = currDate.addDays( -1 ); 187 currDate = currDate.addDays( -1 );
188 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { 188 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) {
189 while ( currDate.dayOfWeek() != realDay ) 189 while ( currDate.dayOfWeek() != realDay )
190 currDate = currDate.addDays( 1 ); 190 currDate = currDate.addDays( 1 );
191 } else if ( dayOfWeek < realDay ) { 191 } else if ( dayOfWeek < realDay ) {
192 while ( currDate.dayOfWeek() < realDay ) 192 while ( currDate.dayOfWeek() < realDay )
193 currDate = currDate.addDays( 1 ); 193 currDate = currDate.addDays( 1 );
194 } else if ( dayOfWeek > realDay ) { 194 } else if ( dayOfWeek > realDay ) {
195 while ( currDate.dayOfWeek() > realDay ) 195 while ( currDate.dayOfWeek() > realDay )
196 currDate = currDate.addDays( -1 ); 196 currDate = currDate.addDays( -1 );
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index a6d04ba..cb4b73b 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,130 +1,130 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "datebooksettings.h" 21#include "datebooksettings.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qspinbox.h> 25#include <qspinbox.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27 27
28DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 28DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
29 const char *name, bool modal, WFlags fl ) 29 const char *name, bool modal, WFlags fl )
30 : DateBookSettingsBase( parent, name, modal, fl ), 30 : DateBookSettingsBase( parent, name, modal, fl ),
31 ampm( whichClock ) 31 ampm( whichClock )
32{ 32{
33 init(); 33 init();
34 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) ); 34 QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) );
35 QArray<int> categories; 35 QArray<int> categories;
36 comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); 36 comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
37} 37}
38 38
39DateBookSettings::~DateBookSettings() 39DateBookSettings::~DateBookSettings()
40{ 40{
41} 41}
42 42
43void DateBookSettings::setStartTime( int newStartViewTime ) 43void DateBookSettings::setStartTime( int newStartViewTime )
44{ 44{
45 if ( ampm ) { 45 if ( ampm ) {
46 if ( newStartViewTime >= 12 ) { 46 if ( newStartViewTime >= 12 ) {
47 newStartViewTime %= 12; 47 newStartViewTime %= 12;
48 if ( newStartViewTime == 0 ) 48 if ( newStartViewTime == 0 )
49 newStartViewTime = 12; 49 newStartViewTime = 12;
50 spinStart->setSuffix( tr(":00 PM") ); 50 spinStart->setSuffix( tr(":00 PM") );
51 } 51 }
52 else if ( newStartViewTime == 0 ) { 52 else if ( newStartViewTime == 0 ) {
53 newStartViewTime = 12; 53 newStartViewTime = 12;
54 spinStart->setSuffix( tr(":00 AM") ); 54 spinStart->setSuffix( tr(":00 AM") );
55 } 55 }
56 oldtime = newStartViewTime; 56 oldtime = newStartViewTime;
57 } 57 }
58 spinStart->setValue( newStartViewTime ); 58 spinStart->setValue( newStartViewTime );
59} 59}
60 60
61int DateBookSettings::startTime() const 61int DateBookSettings::startTime() const
62{ 62{
63 int returnMe = spinStart->value(); 63 int returnMe = spinStart->value();
64 if ( ampm ) { 64 if ( ampm ) {
65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
66 returnMe += 12; 66 returnMe += 12;
67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
68 returnMe = 0; 68 returnMe = 0;
69 } 69 }
70 return returnMe; 70 return returnMe;
71} 71}
72 72
73 73
74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
75{ 75{
76 chkAlarmPreset->setChecked( bAlarm ); 76 chkAlarmPreset->setChecked( bAlarm );
77 if ( presetTime >=5 ) 77 if ( presetTime >=5 )
78 spinPreset->setValue( presetTime ); 78 spinPreset->setValue( presetTime );
79} 79}
80 80
81bool DateBookSettings::alarmPreset() const 81bool DateBookSettings::alarmPreset() const
82{ 82{
83 return chkAlarmPreset->isChecked(); 83 return chkAlarmPreset->isChecked();
84} 84}
85 85
86int DateBookSettings::presetTime() const 86int DateBookSettings::presetTime() const
87{ 87{
88 return spinPreset->value(); 88 return spinPreset->value();
89} 89}
90 90
91 91
92void DateBookSettings::slot12Hour( int i ) 92void DateBookSettings::slot12Hour( int i )
93{ 93{
94 if ( ampm ) { 94 if ( ampm ) {
95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
97 spinStart->setSuffix( tr(":00 PM") ); 97 spinStart->setSuffix( tr(":00 PM") );
98 } else { 98 } else {
99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
100 spinStart->setSuffix( tr(":00 AM") ); 100 spinStart->setSuffix( tr(":00 AM") );
101 } 101 }
102 oldtime = i; 102 oldtime = i;
103 } 103 }
104} 104}
105 105
106void DateBookSettings::init() 106void DateBookSettings::init()
107{ 107{
108 if ( ampm ) { 108 if ( ampm ) {
109 spinStart->setMinValue( 1 ); 109 spinStart->setMinValue( 1 );
110 spinStart->setMaxValue( 12 ); 110 spinStart->setMaxValue( 12 );
111 spinStart->setValue( 12 ); 111 spinStart->setValue( 12 );
112 spinStart->setSuffix( tr(":00 AM") ); 112 spinStart->setSuffix( tr(":00 AM") );
113 oldtime = 12; 113 oldtime = 12;
114 } else { 114 } else {
115 spinStart->setMinValue( 0 ); 115 spinStart->setMinValue( 0 );
116 spinStart->setMaxValue( 23 ); 116 spinStart->setMaxValue( 23 );
117 spinStart->setSuffix( tr(":00") ); 117 spinStart->setSuffix( tr(":00") );
118 } 118 }
119} 119}
120 120
121void DateBookSettings::slotChangeClock( bool whichClock ) 121void DateBookSettings::slotChangeClock( bool whichClock )
122{ 122{
123 int saveMe; 123 int saveMe;
124 saveMe = spinStart->value(); 124 saveMe = spinStart->value();
125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { 125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
126 if ( saveMe == 12 ) 126 if ( saveMe == 12 )
127 saveMe = 0; 127 saveMe = 0;
128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { 128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
129 if ( saveMe != 12 ) 129 if ( saveMe != 12 )
130 saveMe += 12; 130 saveMe += 12;
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 933e191..7503751 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -269,196 +269,196 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch
269 int y = t*rowHeight; 269 int y = t*rowHeight;
270 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { 270 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
271 QString s; 271 QString s;
272 if ( ampm ) { 272 if ( ampm ) {
273 if ( t == 0 ) 273 if ( t == 0 )
274 s = QString::number( 12 ); 274 s = QString::number( 12 );
275 else if ( t == 12 ) 275 else if ( t == 12 )
276 s = QString::number(12) + tr( "p" ); 276 s = QString::number(12) + tr( "p" );
277 else if ( t > 12 ) { 277 else if ( t > 12 ) {
278 if ( t - 12 < 10 ) 278 if ( t - 12 < 10 )
279 s = " "; 279 s = " ";
280 else 280 else
281 s = ""; 281 s = "";
282 s += QString::number( t - 12 ) + tr("p"); 282 s += QString::number( t - 12 ) + tr("p");
283 } else { 283 } else {
284 if ( 12 - t < 3 ) 284 if ( 12 - t < 3 )
285 s = ""; 285 s = "";
286 else 286 else
287 s = " "; 287 s = " ";
288 s += QString::number( t ); 288 s += QString::number( t );
289 } 289 }
290 } else { 290 } else {
291 s = QString::number( t ); 291 s = QString::number( t );
292 if ( s.length() == 1 ) 292 if ( s.length() == 1 )
293 s.prepend( "0" ); 293 s.prepend( "0" );
294 } 294 }
295 p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); 295 p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
296 } 296 }
297 } 297 }
298 298
299 QListIterator<DateBookWeekItem> it(items); 299 QListIterator<DateBookWeekItem> it(items);
300 for ( ; it.current(); ++it ) { 300 for ( ; it.current(); ++it ) {
301 DateBookWeekItem *i = it.current(); 301 DateBookWeekItem *i = it.current();
302 if ( i->geometry().intersects( ur ) ) { 302 if ( i->geometry().intersects( ur ) ) {
303 p->setBrush( i->color() ); 303 p->setBrush( i->color() );
304 p->drawRect( i->geometry() ); 304 p->drawRect( i->geometry() );
305 } 305 }
306 } 306 }
307} 307}
308 308
309void DateBookWeekView::resizeEvent( QResizeEvent *e ) 309void DateBookWeekView::resizeEvent( QResizeEvent *e )
310{ 310{
311 const int hourWidth = 20; 311 const int hourWidth = 20;
312 QScrollView::resizeEvent( e ); 312 QScrollView::resizeEvent( e );
313 313
314 314
315 //HEAD 315 //HEAD
316 /* 316 /*
317 int avail = visibleWidth(); 317 int avail = visibleWidth();
318 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), 318 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(),
319 visibleWidth(), header->sizeHint().height() ); 319 visibleWidth(), header->sizeHint().height() );
320 setMargins( 0, header->sizeHint().height(), 0, 0 ); 320 setMargins( 0, header->sizeHint().height(), 0, 0 );
321 */ 321 */
322 //BRANCH_1_0 322 //BRANCH_1_0
323 int avail = width()-qApp->style().scrollBarExtent().width()-1; 323 int avail = width()-qApp->style().scrollBarExtent().width()-1;
324 header->setGeometry( 0, 0, avail, header->sizeHint().height() ); 324 header->setGeometry( 0, 0, avail, header->sizeHint().height() );
325 setMargins( 0, header->height(), 0, 0 ); 325 setMargins( 0, header->height(), 0, 0 );
326 326
327 327
328 header->resizeSection( 0, hourWidth ); 328 header->resizeSection( 0, hourWidth );
329 int sw = (avail - hourWidth) / 7; 329 int sw = (avail - hourWidth) / 7;
330 for ( int i = 1; i < 7; i++ ) 330 for ( int i = 1; i < 7; i++ )
331 header->resizeSection( i, sw ); 331 header->resizeSection( i, sw );
332 header->resizeSection( 7, avail - hourWidth - sw*6 ); 332 header->resizeSection( 7, avail - hourWidth - sw*6 );
333} 333}
334 334
335void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) 335void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
336{ 336{
337 bOnMonday = bStartOnMonday; 337 bOnMonday = bStartOnMonday;
338 initNames(); 338 initNames();
339} 339}
340 340
341//------------------------------------------------------------------- 341//-------------------------------------------------------------------
342 342
343DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, 343DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
344 QWidget *parent, const char *name ) 344 QWidget *parent, const char *name )
345 : QWidget( parent, name ), 345 : QWidget( parent, name ),
346 db( newDB ), 346 db( newDB ),
347 startTime( 0 ), 347 startTime( 0 ),
348 ampm( ap ), 348 ampm( ap ),
349 bStartOnMonday( startOnMonday ) 349 bStartOnMonday( startOnMonday )
350{ 350{
351 setFocusPolicy(StrongFocus); 351 setFocusPolicy(StrongFocus);
352 QVBoxLayout *vb = new QVBoxLayout( this ); 352 QVBoxLayout *vb = new QVBoxLayout( this );
353 header = new DateBookWeekHeader( bStartOnMonday, this ); 353 header = new DateBookWeekHeader( bStartOnMonday, this );
354 view = new DateBookWeekView( ampm, startOnMonday, this ); 354 view = new DateBookWeekView( ampm, startOnMonday, this );
355 vb->addWidget( header ); 355 vb->addWidget( header );
356 vb->addWidget( view ); 356 vb->addWidget( view );
357 357
358 lblDesc = new QLabel( this, "event label" ); 358 lblDesc = new QLabel( this, "event label" );
359 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); 359 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
360 lblDesc->setBackgroundColor( yellow ); 360 lblDesc->setBackgroundColor( yellow );
361 lblDesc->hide(); 361 lblDesc->hide();
362 362
363 tHide = new QTimer( this ); 363 tHide = new QTimer( this );
364 364
365 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); 365 connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) );
366 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); 366 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
367 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); 367 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
368 connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); 368 connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) );
369 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); 369 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
370 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 370 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
371 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); 371 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
372 setDate(QDate::currentDate()); 372 setDate(QDate::currentDate());
373} 373}
374 374
375void DateBookWeek::keyPressEvent(QKeyEvent *e) 375void DateBookWeek::keyPressEvent(QKeyEvent *e)
376{ 376{
377 switch(e->key()) { 377 switch(e->key()) {
378 case Key_Up: 378 case Key_Up:
379 view->scrollBy(0, -20); 379 view->scrollBy(0, -20);
380 break; 380 break;
381 case Key_Down: 381 case Key_Down:
382 view->scrollBy(0, 20); 382 view->scrollBy(0, 20);
383 break; 383 break;
384 case Key_Left: 384 case Key_Left:
385 setDate(date().addDays(-7)); 385 setDate(date().addDays(-7));
386 break; 386 break;
387 case Key_Right: 387 case Key_Right:
388 setDate(date().addDays(7)); 388 setDate(date().addDays(7));
389 break; 389 break;
390 default: 390 default:
391 e->ignore(); 391 e->ignore();
392 } 392 }
393} 393}
394 394
395void DateBookWeek::showDay( int day ) 395void DateBookWeek::showDay( int day )
396{ 396{
397 QDate d=bdate; 397 QDate d=bdate;
398 398
399 // Calculate offset to first day of week. 399 // Calculate offset to first day of week.
400 int dayoffset=d.dayOfWeek() % 7; 400 int dayoffset=d.dayOfWeek() % 7;
401 401
402 if(bStartOnMonday) dayoffset--; 402 if(bStartOnMonday) dayoffset--;
403 403
404 day--; 404 day--;
405 d=d.addDays(day-dayoffset); 405 d=d.addDays(day-dayoffset);
406 emit showDate( d.year(), d.month(), d.day() ); 406 emit showDate( d.year(), d.month(), d.day() );
407} 407}
408 408
409void DateBookWeek::setDate( int y, int m, int d ) 409void DateBookWeek::setDate( int y, int m, int d )
410{ 410{
411 setDate(QDate(y, m, d)); 411 setDate(QDate(y, m, d));
412} 412}
413 413
414void DateBookWeek::setDate(QDate newdate) 414void DateBookWeek::setDate(QDate newdate)
415{ 415{
416 bdate=newdate; 416 bdate=newdate;
417 dow = newdate.dayOfWeek(); 417 dow = newdate.dayOfWeek();
418 header->setDate( newdate ); 418 header->setDate( newdate );
419} 419}
420 420
421void DateBookWeek::dateChanged( QDate &newdate ) 421void DateBookWeek::dateChanged( QDate &newdate )
422{ 422{
423 bdate=newdate; 423 bdate=newdate;
424 getEvents(); 424 getEvents();
425} 425}
426 426
427QDate DateBookWeek::date() const 427QDate DateBookWeek::date() const
428{ 428{
429 return bdate; 429 return bdate;
430} 430}
431 431
432void DateBookWeek::getEvents() 432void DateBookWeek::getEvents()
433{ 433{
434 QDate startWeek = weekDate(); 434 QDate startWeek = weekDate();
435 435
436 QDate endWeek = startWeek.addDays( 6 ); 436 QDate endWeek = startWeek.addDays( 6 );
437 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); 437 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
438 view->showEvents( eventList ); 438 view->showEvents( eventList );
439 view->moveToHour( startTime ); 439 view->moveToHour( startTime );
440} 440}
441 441
442void DateBookWeek::generateAllDayTooltext( QString& text ) { 442void DateBookWeek::generateAllDayTooltext( QString& text ) {
443 text += "<b>" + tr("This is an all day event.") + "</b><br>"; 443 text += "<b>" + tr("This is an all day event.") + "</b><br>";
444} 444}
445 445
446void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { 446void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) {
447 str += "<b>" + QObject::tr("Start") + "</b>: "; 447 str += "<b>" + QObject::tr("Start") + "</b>: ";
448 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); 448 str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
449 if( ev.startDate()!=ev.endDate() ) { 449 if( ev.startDate()!=ev.endDate() ) {
450 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; 450 str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
451 } 451 }
452 str += "<br>"; 452 str += "<br>";
453 str += "<b>" + QObject::tr("End") + "</b>: "; 453 str += "<b>" + QObject::tr("End") + "</b>: ";
454 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); 454 str += TimeString::timeString( ev.event().end().time(), ampm, FALSE );
455 if( ev.startDate()!=ev.endDate() ) { 455 if( ev.startDate()!=ev.endDate() ) {
456 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; 456 str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>";
457 } 457 }
458} 458}
459 459
460void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) 460void DateBookWeek::slotShowEvent( const EffectiveEvent &ev )
461{ 461{
462 if ( tHide->isActive() ) 462 if ( tHide->isActive() )
463 tHide->stop(); 463 tHide->stop();
464 464
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index eaa9730..c237b2d 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,120 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "datebookweekheaderimpl.h" 20#include "datebookweekheaderimpl.h"
21#include "datebookweek.h" 21#include "datebookweek.h"
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/datebookmonth.h> 23#include <qpe/datebookmonth.h>
24 24
25#include <qtoolbutton.h> 25#include <qtoolbutton.h>
26 26
27/* 27/*
28 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 28 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
29 * name 'name' and widget flags set to 'f' 29 * name 'name' and widget flags set to 'f'
30 */ 30 */
31DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) 31DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
32 : DateBookWeekHeaderBase( parent, name, fl ), 32 : DateBookWeekHeaderBase( parent, name, fl ),
33 bStartOnMonday( startOnMonday ) 33 bStartOnMonday( startOnMonday )
34{ 34{
35 setBackgroundMode( PaletteButton ); 35 setBackgroundMode( PaletteButton );
36 labelDate->setBackgroundMode( PaletteButton ); 36 labelDate->setBackgroundMode( PaletteButton );
37 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 37 backmonth->setPixmap( Resource::loadPixmap("fastback") );
38 backweek->setPixmap( Resource::loadPixmap("back") ); 38 backweek->setPixmap( Resource::loadPixmap("back") );
39 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 39 forwardweek->setPixmap( Resource::loadPixmap("forward") );
40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
41} 41}
42 42
43/* 43/*
44 * Destroys the object and frees any allocated resources 44 * Destroys the object and frees any allocated resources
45 */ 45 */
46DateBookWeekHeader::~DateBookWeekHeader() 46DateBookWeekHeader::~DateBookWeekHeader()
47{ 47{
48 // no need to delete child widgets, Qt does it all for us 48 // no need to delete child widgets, Qt does it all for us
49} 49}
50 50
51void DateBookWeekHeader::pickDate() 51void DateBookWeekHeader::pickDate()
52{ 52{
53 static QPopupMenu *m1 = 0; 53 static QPopupMenu *m1 = 0;
54 static DateBookMonth *picker = 0; 54 static DateBookMonth *picker = 0;
55 if ( !m1 ) { 55 if ( !m1 ) {
56 m1 = new QPopupMenu( this ); 56 m1 = new QPopupMenu( this );
57 picker = new DateBookMonth( m1, 0, TRUE ); 57 picker = new DateBookMonth( m1, 0, TRUE );
58 m1->insertItem( picker ); 58 m1->insertItem( picker );
59 connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) ); 59 connect( picker, SIGNAL( dateClicked(int,int,int) ), this, SLOT( setDate(int,int,int) ) );
60 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); 60 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
61 } 61 }
62 picker->setDate( date.year(), date.month(), date.day() ); 62 picker->setDate( date.year(), date.month(), date.day() );
63 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 63 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
64 picker->setFocus(); 64 picker->setFocus();
65} 65}
66 66
67void DateBookWeekHeader::nextMonth() 67void DateBookWeekHeader::nextMonth()
68{ 68{
69 qWarning("nextMonth() " ); 69 qWarning("nextMonth() " );
70 setDate(date.addDays(28)); 70 setDate(date.addDays(28));
71} 71}
72void DateBookWeekHeader::prevMonth() 72void DateBookWeekHeader::prevMonth()
73{ 73{
74 qWarning("prevMonth() " ); 74 qWarning("prevMonth() " );
75 setDate(date.addDays(-28)); 75 setDate(date.addDays(-28));
76} 76}
77void DateBookWeekHeader::nextWeek() 77void DateBookWeekHeader::nextWeek()
78{ 78{
79 qWarning("nextWeek() " ); 79 qWarning("nextWeek() " );
80 setDate(date.addDays(7)); 80 setDate(date.addDays(7));
81} 81}
82void DateBookWeekHeader::prevWeek() 82void DateBookWeekHeader::prevWeek()
83{ 83{
84 qWarning("prevWeek() "); 84 qWarning("prevWeek() ");
85 setDate(date.addDays(-7)); 85 setDate(date.addDays(-7));
86} 86}
87 87
88void DateBookWeekHeader::setDate( int y, int m, int d ) 88void DateBookWeekHeader::setDate( int y, int m, int d )
89{ 89{
90 setDate(QDate(y,m,d)); 90 setDate(QDate(y,m,d));
91} 91}
92 92
93void DateBookWeekHeader::setDate(const QDate &d) { 93void DateBookWeekHeader::setDate(const QDate &d) {
94 int year,week,dayofweek; 94 int year,week,dayofweek;
95 date=d; 95 date=d;
96 dayofweek=d.dayOfWeek(); 96 dayofweek=d.dayOfWeek();
97 if(bStartOnMonday) 97 if(bStartOnMonday)
98 dayofweek--; 98 dayofweek--;
99 else if( dayofweek == 7 ) 99 else if( dayofweek == 7 )
100 // we already have the right day -7 would lead to the current week.. 100 // we already have the right day -7 would lead to the current week..
101 dayofweek = 0; 101 dayofweek = 0;
102 102
103 date=date.addDays(-dayofweek); 103 date=date.addDays(-dayofweek);
104 calcWeek(date,week,year,bStartOnMonday); 104 calcWeek(date,week,year,bStartOnMonday);
105 QDate start=date; 105 QDate start=date;
106 QDate stop=start.addDays(6); 106 QDate stop=start.addDays(6);
107 labelDate->setText( QString::number(start.day()) + "." + 107 labelDate->setText( QString::number(start.day()) + "." +
108 Calendar::nameOfMonth( start.month()) + "-" + 108 Calendar::nameOfMonth( start.month()) + "-" +
109 QString::number(stop.day()) + "." + 109 QString::number(stop.day()) + "." +
110 Calendar::nameOfMonth( stop.month()) +" ("+ 110 Calendar::nameOfMonth( stop.month()) +" ("+
111 tr("w")+":"+QString::number( week ) +")"); 111 tr("w")+":"+QString::number( week ) +")");
112 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 112 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
113 emit dateChanged(date); 113 emit dateChanged(date);
114} 114}
115 115
116void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 116void DateBookWeekHeader::setStartOfWeek( bool onMonday )
117{ 117{
118 bStartOnMonday = onMonday; 118 bStartOnMonday = onMonday;
119 setDate( date ); 119 setDate( date );
120} 120}
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 42a1753..af40143 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,394 +1,394 @@
1#include "datebookweeklst.h" 1#include "datebookweeklst.h"
2 2
3 3
4#include "datebook.h" 4#include "datebook.h"
5 5
6#include <qpe/datebookmonth.h> 6#include <qpe/datebookmonth.h>
7#include <qpe/config.h> 7#include <qpe/config.h>
8#include <qpe/resource.h> 8#include <qpe/resource.h>
9 9
10#include <qlayout.h> 10#include <qlayout.h>
11#include <qtoolbutton.h> 11#include <qtoolbutton.h>
12#include <qtl.h> 12#include <qtl.h>
13 13
14bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 14bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
15 15
16DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 16DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
17 : DateBookWeekLstHeaderBase(parent, name, fl) 17 : DateBookWeekLstHeaderBase(parent, name, fl)
18{ 18{
19 setBackgroundMode( PaletteButton ); 19 setBackgroundMode( PaletteButton );
20 labelDate->setBackgroundMode( PaletteButton ); 20 labelDate->setBackgroundMode( PaletteButton );
21 forwardweek->setBackgroundMode( PaletteButton ); 21 forwardweek->setBackgroundMode( PaletteButton );
22 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 22 forwardweek->setPixmap( Resource::loadPixmap("forward") );
23 forwardmonth->setBackgroundMode( PaletteButton ); 23 forwardmonth->setBackgroundMode( PaletteButton );
24 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 24 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
25 backweek->setBackgroundMode( PaletteButton ); 25 backweek->setBackgroundMode( PaletteButton );
26 backweek->setPixmap( Resource::loadPixmap("back") ); 26 backweek->setPixmap( Resource::loadPixmap("back") );
27 backmonth->setBackgroundMode( PaletteButton ); 27 backmonth->setBackgroundMode( PaletteButton );
28 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 28 backmonth->setPixmap( Resource::loadPixmap("fastback") );
29 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 29 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
30 DateBookWeekLstHeaderBaseLayout->setMargin(0); 30 DateBookWeekLstHeaderBaseLayout->setMargin(0);
31 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 31 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
32 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 32 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
33 33
34 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 34 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
35 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 35 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
36 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 36 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
37 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 37 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
38 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 38 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
39 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 39 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
40 bStartOnMonday=onM; 40 bStartOnMonday=onM;
41} 41}
42DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 42DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
43 43
44void DateBookWeekLstHeader::setDate(const QDate &d) { 44void DateBookWeekLstHeader::setDate(const QDate &d) {
45 int year,week,dayofweek; 45 int year,week,dayofweek;
46 date=d; 46 date=d;
47 dayofweek=d.dayOfWeek(); 47 dayofweek=d.dayOfWeek();
48 if(bStartOnMonday) 48 if(bStartOnMonday)
49 dayofweek--; 49 dayofweek--;
50 else if( dayofweek == 7 ) 50 else if( dayofweek == 7 )
51 /* we already have the right day -7 would lead to the same week */ 51 /* we already have the right day -7 would lead to the same week */
52 dayofweek = 0; 52 dayofweek = 0;
53 53
54 date=date.addDays(-dayofweek); 54 date=date.addDays(-dayofweek);
55 55
56 calcWeek(date,week,year,bStartOnMonday); 56 calcWeek(date,week,year,bStartOnMonday);
57 QDate start=date; 57 QDate start=date;
58 QDate stop=start.addDays(6); 58 QDate stop=start.addDays(6);
59 labelDate->setText( QString::number(start.day()) + "." + 59 labelDate->setText( QString::number(start.day()) + "." +
60 Calendar::nameOfMonth( start.month() ) + "-" + 60 Calendar::nameOfMonth( start.month() ) + "-" +
61 QString::number(stop.day()) + "." + 61 QString::number(stop.day()) + "." +
62 Calendar::nameOfMonth( stop.month()) +" ("+ 62 Calendar::nameOfMonth( stop.month()) +" ("+
63 tr("w")+":"+QString::number( week ) +")"); 63 tr("w")+":"+QString::number( week ) +")");
64 date = d; // bugfix: 0001126 - date has to be the selected date, not monday! 64 date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
65 emit dateChanged(date); 65 emit dateChanged(date);
66} 66}
67 67
68void DateBookWeekLstHeader::pickDate() { 68void DateBookWeekLstHeader::pickDate() {
69 static QPopupMenu *m1 = 0; 69 static QPopupMenu *m1 = 0;
70 static DateBookMonth *picker = 0; 70 static DateBookMonth *picker = 0;
71 if ( !m1 ) { 71 if ( !m1 ) {
72 m1 = new QPopupMenu( this ); 72 m1 = new QPopupMenu( this );
73 picker = new DateBookMonth( m1, 0, TRUE ); 73 picker = new DateBookMonth( m1, 0, TRUE );
74 m1->insertItem( picker ); 74 m1->insertItem( picker );
75 connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) ); 75 connect( picker, SIGNAL( dateClicked(int,int,int) ),this, SLOT( setDate(int,int,int) ) );
76 //connect( m1, SIGNAL( aboutToHide() ), 76 //connect( m1, SIGNAL( aboutToHide() ),
77 //this, SLOT( gotHide() ) ); 77 //this, SLOT( gotHide() ) );
78 } 78 }
79 picker->setDate( date.year(), date.month(), date.day() ); 79 picker->setDate( date.year(), date.month(), date.day() );
80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
81 picker->setFocus(); 81 picker->setFocus();
82} 82}
83void DateBookWeekLstHeader::setDate(int y, int m, int d) { 83void DateBookWeekLstHeader::setDate(int y, int m, int d) {
84 setDate(QDate(y,m,d)); 84 setDate(QDate(y,m,d));
85} 85}
86 86
87void DateBookWeekLstHeader::nextWeek() { 87void DateBookWeekLstHeader::nextWeek() {
88 setDate(date.addDays(7)); 88 setDate(date.addDays(7));
89} 89}
90void DateBookWeekLstHeader::prevWeek() { 90void DateBookWeekLstHeader::prevWeek() {
91 setDate(date.addDays(-7)); 91 setDate(date.addDays(-7));
92} 92}
93void DateBookWeekLstHeader::nextMonth() 93void DateBookWeekLstHeader::nextMonth()
94{ 94{
95 setDate(date.addDays(28)); 95 setDate(date.addDays(28));
96} 96}
97void DateBookWeekLstHeader::prevMonth() 97void DateBookWeekLstHeader::prevMonth()
98{ 98{
99 setDate(date.addDays(-28)); 99 setDate(date.addDays(-28));
100} 100}
101 101
102DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, 102DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
103 QWidget* parent, 103 QWidget* parent,
104 const char* name, 104 const char* name,
105 WFlags fl ) 105 WFlags fl )
106 : DateBookWeekLstDayHdrBase(parent, name, fl) { 106 : DateBookWeekLstDayHdrBase(parent, name, fl) {
107 107
108 date=d; 108 date=d;
109 109
110 static const QString wdays=tr("MTWTFSSM", "Week days"); 110 static const QString wdays=tr("MTWTFSSM", "Week days");
111 char day=wdays[d.dayOfWeek()-1]; 111 char day=wdays[d.dayOfWeek()-1];
112 112
113 //dont use dayOfWeek() to save space ! 113 //dont use dayOfWeek() to save space !
114 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) ); 114 label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
115 115
116 add->setText("+"); 116 add->setText("+");
117 117
118 if (d == QDate::currentDate()) { 118 if (d == QDate::currentDate()) {
119 QPalette pal=label->palette(); 119 QPalette pal=label->palette();
120 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 120 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
121 label->setPalette(pal); 121 label->setPalette(pal);
122 122
123 /* 123 /*
124 QFont f=label->font(); 124 QFont f=label->font();
125 f.setItalic(true); 125 f.setItalic(true);
126 label->setFont(f); 126 label->setFont(f);
127 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 127 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
128 */ 128 */
129 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 129 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
130 QPalette pal=label->palette(); 130 QPalette pal=label->palette();
131 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 131 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
132 label->setPalette(pal); 132 label->setPalette(pal);
133 } 133 }
134 134
135 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 135 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
136 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 136 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
137} 137}
138 138
139void DateBookWeekLstDayHdr::showDay() { 139void DateBookWeekLstDayHdr::showDay() {
140 emit showDate(date.year(), date.month(), date.day()); 140 emit showDate(date.year(), date.month(), date.day());
141} 141}
142 142
143void DateBookWeekLstDayHdr::newEvent() { 143void DateBookWeekLstDayHdr::newEvent() {
144 QDateTime start, stop; 144 QDateTime start, stop;
145 start=stop=date; 145 start=stop=date;
146 start.setTime(QTime(10,0)); 146 start.setTime(QTime(10,0));
147 stop.setTime(QTime(12,0)); 147 stop.setTime(QTime(12,0));
148 148
149 emit addEvent(start,stop,"",0); 149 emit addEvent(start,stop,"",0);
150} 150}
151DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 151DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
152 int weeklistviewconfig, 152 int weeklistviewconfig,
153 QWidget* parent, 153 QWidget* parent,
154 const char* name, 154 const char* name,
155 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 155 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
156{ 156{
157 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 157 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
158 QString s,start,middle,end,day; 158 QString s,start,middle,end,day;
159 159
160 qDebug("weeklistviewconfig=%d",weeklistviewconfig); 160 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
161 if(weeklistviewconfig==NONE) {// No times displayed. 161 if(weeklistviewconfig==NONE) {// No times displayed.
162 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 162 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
163 // middle.sprintf("<--->"); 163 // middle.sprintf("<--->");
164 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 164 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
165 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 165 // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
166 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 166 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
167 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 167 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
168 middle.sprintf(" |---"); 168 middle.sprintf(" |---");
169 end.sprintf("__|__"); 169 end.sprintf("__|__");
170 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 170 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
171 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 171 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
172 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 172 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
173 middle.sprintf("<--->"); 173 middle.sprintf("<--->");
174 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 174 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
175 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); 175 day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
176 } 176 }
177 177
178 if(ev.event().type() == Event::Normal) { 178 if(ev.event().type() == Event::Normal) {
179 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 179 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
180 s=day; 180 s=day;
181 } else if(ev.startDate()==ev.date()) {// start event. 181 } else if(ev.startDate()==ev.date()) {// start event.
182 s=start; 182 s=start;
183 } else if(ev.endDate()==ev.date()) { // end event. 183 } else if(ev.endDate()==ev.date()) { // end event.
184 s=end; 184 s=end;
185 } else {// middle day. 185 } else {// middle day.
186 s=middle; 186 s=middle;
187 } 187 }
188 } else { 188 } else {
189 s=""; 189 s="";
190 } 190 }
191 setText(QString(s) + " " + ev.description()); 191 setText(QString(s) + " " + ev.description());
192 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 192 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
193 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 193 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
194} 194}
195void DateBookWeekLstEvent::editMe() { 195void DateBookWeekLstEvent::editMe() {
196 emit editEvent(event.event()); 196 emit editEvent(event.event());
197} 197}
198 198
199 199
200DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 200DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
201 const QDate &d, bool onM, 201 const QDate &d, bool onM,
202 QWidget* parent, 202 QWidget* parent,
203 const char* name, WFlags fl) 203 const char* name, WFlags fl)
204 : QWidget( parent, name, fl ) 204 : QWidget( parent, name, fl )
205{ 205{
206 Config config("DateBook"); 206 Config config("DateBook");
207 config.setGroup("Main"); 207 config.setGroup("Main");
208 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 208 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
209 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); 209 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
210 210
211 bStartOnMonday=onM; 211 bStartOnMonday=onM;
212 setPalette(white); 212 setPalette(white);
213 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 213 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
214 214
215 QVBoxLayout *layout = new QVBoxLayout( this ); 215 QVBoxLayout *layout = new QVBoxLayout( this );
216 216
217 qBubbleSort(ev); 217 qBubbleSort(ev);
218 QValueListIterator<EffectiveEvent> it; 218 QValueListIterator<EffectiveEvent> it;
219 it=ev.begin(); 219 it=ev.begin();
220 220
221 int dayOrder[7]; 221 int dayOrder[7];
222 if (bStartOnMonday) { 222 if (bStartOnMonday) {
223 for (int d=0; d<7; d++) dayOrder[d]=d+1; 223 for (int d=0; d<7; d++) dayOrder[d]=d+1;
224 } else { 224 } else {
225 for (int d=0; d<7; d++) dayOrder[d]=d; 225 for (int d=0; d<7; d++) dayOrder[d]=d;
226 dayOrder[0]=7; 226 dayOrder[0]=7;
227 } 227 }
228 228
229 // Calculate offset to first day of week. 229 // Calculate offset to first day of week.
230 int dayoffset=d.dayOfWeek(); 230 int dayoffset=d.dayOfWeek();
231 if(bStartOnMonday) dayoffset--; 231 if(bStartOnMonday) dayoffset--;
232 else if( dayoffset == 7 ) dayoffset = 0; 232 else if( dayoffset == 7 ) dayoffset = 0;
233 233
234 for (int i=0; i<7; i++) { 234 for (int i=0; i<7; i++) {
235 // Header 235 // Header
236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
237 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 237 connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
238 connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 238 connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
239 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 239 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
240 layout->addWidget(hdr); 240 layout->addWidget(hdr);
241 241
242 // Events 242 // Events
243 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 243 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
244 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day. 244 if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {// Skip events ending at 00:00 starting at another day.
245 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 245 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
246 layout->addWidget(l); 246 layout->addWidget(l);
247 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 247 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
248 } 248 }
249 it++; 249 it++;
250 } 250 }
251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
252 } 252 }
253} 253}
254DateBookWeekLstView::~DateBookWeekLstView(){} 254DateBookWeekLstView::~DateBookWeekLstView(){}
255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
256 256
257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
258 QValueList<EffectiveEvent> &ev2, 258 QValueList<EffectiveEvent> &ev2,
259 QDate &d, bool onM, 259 QDate &d, bool onM,
260 QWidget* parent, 260 QWidget* parent,
261 const char* name, WFlags fl) 261 const char* name, WFlags fl)
262 : QWidget( parent, name, fl ) 262 : QWidget( parent, name, fl )
263{ 263{
264 QHBoxLayout *layout = new QHBoxLayout( this ); 264 QHBoxLayout *layout = new QHBoxLayout( this );
265 265
266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
267 layout->addWidget(w); 267 layout->addWidget(w);
268 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 268 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
269 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 269 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
270 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), 270 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
271 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 271 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
272 272
273 273
274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
275 layout->addWidget(w); 275 layout->addWidget(w);
276 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 276 connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
277 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 277 connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
278 connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 278 connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
279 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 279 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
280} 280}
281 281
282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
283 QWidget *parent, 283 QWidget *parent,
284 const char *name ) 284 const char *name )
285 : QWidget( parent, name ), 285 : QWidget( parent, name ),
286 db( newDB ), 286 db( newDB ),
287 startTime( 0 ), 287 startTime( 0 ),
288 ampm( ap ), 288 ampm( ap ),
289 bStartOnMonday(onM) 289 bStartOnMonday(onM)
290{ 290{
291 setFocusPolicy(StrongFocus); 291 setFocusPolicy(StrongFocus);
292 layout = new QVBoxLayout( this ); 292 layout = new QVBoxLayout( this );
293 layout->setMargin(0); 293 layout->setMargin(0);
294 294
295 header=new DateBookWeekLstHeader(onM, this); 295 header=new DateBookWeekLstHeader(onM, this);
296 layout->addWidget( header ); 296 layout->addWidget( header );
297 connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &))); 297 connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
299 299
300 scroll=new QScrollView(this); 300 scroll=new QScrollView(this);
301 scroll->setResizePolicy(QScrollView::AutoOneFit); 301 scroll->setResizePolicy(QScrollView::AutoOneFit);
302 layout->addWidget(scroll); 302 layout->addWidget(scroll);
303 303
304 view=NULL; 304 view=NULL;
305 Config config("DateBook"); 305 Config config("DateBook");
306 config.setGroup("Main"); 306 config.setGroup("Main");
307 dbl=config.readBoolEntry("weeklst_dbl", false); 307 dbl=config.readBoolEntry("weeklst_dbl", false);
308 header->dbl->setOn(dbl); 308 header->dbl->setOn(dbl);
309} 309}
310DateBookWeekLst::~DateBookWeekLst(){ 310DateBookWeekLst::~DateBookWeekLst(){
311 Config config("DateBook"); 311 Config config("DateBook");
312 config.setGroup("Main"); 312 config.setGroup("Main");
313 config.writeEntry("weeklst_dbl", dbl); 313 config.writeEntry("weeklst_dbl", dbl);
314} 314}
315 315
316void DateBookWeekLst::setDate(const QDate &d) { 316void DateBookWeekLst::setDate(const QDate &d) {
317 bdate=d; 317 bdate=d;
318 header->setDate(d); 318 header->setDate(d);
319} 319}
320 320
321void DateBookWeekLst::setDbl(bool on) { 321void DateBookWeekLst::setDbl(bool on) {
322 dbl=on; 322 dbl=on;
323 redraw(); 323 redraw();
324} 324}
325void DateBookWeekLst::redraw() {getEvents();} 325void DateBookWeekLst::redraw() {getEvents();}
326 326
327QDate DateBookWeekLst::date() { 327QDate DateBookWeekLst::date() {
328 return bdate; 328 return bdate;
329} 329}
330 330
331// return the date at the beginning of the week... 331// return the date at the beginning of the week...
332// copied from DateBookWeek 332// copied from DateBookWeek
333QDate DateBookWeekLst::weekDate() const 333QDate DateBookWeekLst::weekDate() const
334{ 334{
335 QDate d=bdate; 335 QDate d=bdate;
336 336
337 // Calculate offset to first day of week. 337 // Calculate offset to first day of week.
338 int dayoffset=d.dayOfWeek(); 338 int dayoffset=d.dayOfWeek();
339 if(bStartOnMonday) dayoffset--; 339 if(bStartOnMonday) dayoffset--;
340 else if( dayoffset == 7 ) 340 else if( dayoffset == 7 )
341 dayoffset = 0; 341 dayoffset = 0;
342 342
343 return d.addDays(-dayoffset); 343 return d.addDays(-dayoffset);
344} 344}
345 345
346void DateBookWeekLst::getEvents() { 346void DateBookWeekLst::getEvents() {
347 QDate start = weekDate(); //date(); 347 QDate start = weekDate(); //date();
348 QDate stop = start.addDays(6); 348 QDate stop = start.addDays(6);
349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
350 350
351 if (view) delete view; 351 if (view) delete view;
352 if (dbl) { 352 if (dbl) {
353 QDate start2=start.addDays(7); 353 QDate start2=start.addDays(7);
354 stop=start2.addDays(6); 354 stop=start2.addDays(6);
355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
357 } else { 357 } else {
358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
359 } 359 }
360 360
361 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 361 connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
362 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); 362 connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
363 connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), 363 connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
364 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 364 this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
365 365
366 scroll->addChild(view); 366 scroll->addChild(view);
367 view->show(); 367 view->show();
368 scroll->updateScrollBars(); 368 scroll->updateScrollBars();
369} 369}
370 370
371void DateBookWeekLst::dateChanged(QDate &newdate) { 371void DateBookWeekLst::dateChanged(QDate &newdate) {
372 bdate=newdate; 372 bdate=newdate;
373 getEvents(); 373 getEvents();
374} 374}
375 375
376void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 376void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
377{ 377{
378 switch(e->key()) { 378 switch(e->key()) {
379 case Key_Up: 379 case Key_Up:
380 scroll->scrollBy(0, -20); 380 scroll->scrollBy(0, -20);
381 break; 381 break;
382 case Key_Down: 382 case Key_Down:
383 scroll->scrollBy(0, 20); 383 scroll->scrollBy(0, 20);
384 break; 384 break;
385 case Key_Left: 385 case Key_Left:
386 header->prevWeek(); 386 header->prevWeek();
387 break; 387 break;
388 case Key_Right: 388 case Key_Right:
389 header->nextWeek(); 389 header->nextWeek();
390 break; 390 break;
391 default: 391 default:
392 e->ignore(); 392 e->ignore();
393 } 393 }
394} 394}
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 018bb5a..57bcd89 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -97,215 +97,215 @@ static void addOrPick( QComboBox* combo, const QString& t )
97 } 97 }
98 98
99 // Else add one 99 // Else add one
100 combo->insertItem(t); 100 combo->insertItem(t);
101 combo->setCurrentItem(combo->count()-1); 101 combo->setCurrentItem(combo->count()-1);
102} 102}
103 103
104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
105 QWidget* parent, const char* name ) 105 QWidget* parent, const char* name )
106 : DateEntryBase( parent, name ), 106 : DateEntryBase( parent, name ),
107 ampm( whichClock ), 107 ampm( whichClock ),
108 startWeekOnMonday( startOnMonday ), 108 startWeekOnMonday( startOnMonday ),
109 m_showStart(true) 109 m_showStart(true)
110 110
111{ 111{
112 init(); 112 init();
113 setDates(event.start(),event.end()); 113 setDates(event.start(),event.end());
114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
115 if(!event.description().isEmpty()) 115 if(!event.description().isEmpty())
116 addOrPick( comboDescription, event.description() ); 116 addOrPick( comboDescription, event.description() );
117 if(!event.location().isEmpty()) 117 if(!event.location().isEmpty())
118 addOrPick( comboLocation, event.location() ); 118 addOrPick( comboLocation, event.location() );
119 checkAlarm->setChecked( event.hasAlarm() ); 119 checkAlarm->setChecked( event.hasAlarm() );
120 checkAllDay->setChecked( event.type() == Event::AllDay ); 120 checkAllDay->setChecked( event.type() == Event::AllDay );
121 if(!event.notes().isEmpty()) noteStr=event.notes(); 121 if(!event.notes().isEmpty()) noteStr=event.notes();
122 else noteStr=""; 122 else noteStr="";
123 spinAlarm->setValue(event.alarmTime()); 123 spinAlarm->setValue(event.alarmTime());
124 if ( event.alarmSound() != Event::Silent ) 124 if ( event.alarmSound() != Event::Silent )
125 comboSound->setCurrentItem( 1 ); 125 comboSound->setCurrentItem( 1 );
126 if ( event.hasRepeat() ) { 126 if ( event.hasRepeat() ) {
127 rp = event.repeatPattern(); 127 rp = event.repeatPattern();
128 cmdRepeat->setText( tr("Repeat...") ); 128 cmdRepeat->setText( tr("Repeat...") );
129 } 129 }
130 setRepeatLabel(); 130 setRepeatLabel();
131} 131}
132 132
133void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 133void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
134{ 134{
135 startDate = s.date(); 135 startDate = s.date();
136 endDate = e.date(); 136 endDate = e.date();
137 startTime = s.time(); 137 startTime = s.time();
138 endTime = e.time(); 138 endTime = e.time();
139 139
140 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 140 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
141 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 141 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
142 142
143 updateTimeEdit(true,true); 143 updateTimeEdit(true,true);
144} 144}
145 145
146void DateEntry::updateTimeEdit(bool s, bool e) { 146void DateEntry::updateTimeEdit(bool s, bool e) {
147 147
148 // Comboboxes 148 // Comboboxes
149 QString strStart, strEnd; 149 QString strStart, strEnd;
150 int shour, ehour; 150 int shour, ehour;
151 if ( ampm ) { 151 if ( ampm ) {
152 shour = startTime.hour(); 152 shour = startTime.hour();
153 ehour = endTime.hour(); 153 ehour = endTime.hour();
154 if ( shour >= 12 ) { 154 if ( shour >= 12 ) {
155 if ( shour > 12 ) 155 if ( shour > 12 )
156 shour -= 12; 156 shour -= 12;
157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
158 } else { 158 } else {
159 if ( shour == 0 ) 159 if ( shour == 0 )
160 shour = 12; 160 shour = 12;
161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
162 } 162 }
163 if ( ehour == 24 && endTime.minute() == 0 ) { 163 if ( ehour == 24 && endTime.minute() == 0 ) {
164 strEnd = "11:59 PM"; // or "midnight" 164 strEnd = "11:59 PM"; // or "midnight"
165 } else if ( ehour >= 12 ) { 165 } else if ( ehour >= 12 ) {
166 if ( ehour > 12 ) 166 if ( ehour > 12 )
167 ehour -= 12; 167 ehour -= 12;
168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
169 } else { 169 } else {
170 if ( ehour == 0 ) 170 if ( ehour == 0 )
171 ehour = 12; 171 ehour = 12;
172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
173 } 173 }
174 } else { 174 } else {
175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
177 } 177 }
178 178
179 if (s) comboStart->setText(strStart); 179 if (s) comboStart->setText(strStart);
180 if (e) comboEnd->setText(strEnd); 180 if (e) comboEnd->setText(strEnd);
181} 181}
182 182
183void DateEntry::init() 183void DateEntry::init()
184{ 184{
185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
187 187
188 initCombos(); 188 initCombos();
189 QPopupMenu *m1 = new QPopupMenu( this ); 189 QPopupMenu *m1 = new QPopupMenu( this );
190 startPicker = new DateBookMonth( m1, 0, TRUE ); 190 startPicker = new DateBookMonth( m1, 0, TRUE );
191 m1->insertItem( startPicker ); 191 m1->insertItem( startPicker );
192 buttonStart->setPopup( m1 ); 192 buttonStart->setPopup( m1 );
193 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 193 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
194 this, SLOT( startDateChanged( int, int, int ) ) ); 194 this, SLOT( startDateChanged(int,int,int) ) );
195 195
196 //Let start button change both start and end dates 196 //Let start button change both start and end dates
197 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 197 connect( startPicker, SIGNAL( dateClicked(int,int,int) ),
198 this, SLOT( endDateChanged( int, int, int ) ) ); 198 this, SLOT( endDateChanged(int,int,int) ) );
199 connect( qApp, SIGNAL( clockChanged( bool ) ), 199 connect( qApp, SIGNAL( clockChanged(bool) ),
200 this, SLOT( slotChangeClock( bool ) ) ); 200 this, SLOT( slotChangeClock(bool) ) );
201 connect( qApp, SIGNAL(weekChanged(bool)), 201 connect( qApp, SIGNAL(weekChanged(bool)),
202 this, SLOT(slotChangeStartOfWeek(bool)) ); 202 this, SLOT(slotChangeStartOfWeek(bool)) );
203 203
204 connect( editNote, SIGNAL(clicked()), 204 connect( editNote, SIGNAL(clicked()),
205 this, SLOT(slotEditNote()) ); 205 this, SLOT(slotEditNote()) );
206 206
207 QPopupMenu *m2 = new QPopupMenu( this ); 207 QPopupMenu *m2 = new QPopupMenu( this );
208 endPicker = new DateBookMonth( m2, 0, TRUE ); 208 endPicker = new DateBookMonth( m2, 0, TRUE );
209 m2->insertItem( endPicker ); 209 m2->insertItem( endPicker );
210 buttonEnd->setPopup( m2 ); 210 buttonEnd->setPopup( m2 );
211 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), 211 connect( endPicker, SIGNAL( dateClicked(int,int,int) ),
212 this, SLOT( endDateChanged( int, int, int ) ) ); 212 this, SLOT( endDateChanged(int,int,int) ) );
213 213
214 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), 214 connect(timePickerStart, SIGNAL( timeChanged(const QTime&) ),
215 this, SLOT( startTimePicked(const QTime &) )); 215 this, SLOT( startTimePicked(const QTime&) ));
216 // install eventFilters 216 // install eventFilters
217 comboEnd->installEventFilter( this ); 217 comboEnd->installEventFilter( this );
218 comboStart->installEventFilter( this ); 218 comboStart->installEventFilter( this );
219} 219}
220 220
221/* 221/*
222 * Destroys the object and frees any allocated resources 222 * Destroys the object and frees any allocated resources
223 */ 223 */
224DateEntry::~DateEntry() 224DateEntry::~DateEntry()
225{ 225{
226 // no need to delete child widgets, Qt does it all for us 226 // no need to delete child widgets, Qt does it all for us
227 //cout << "Del: " << comboStart->currentText() << endl; 227 //cout << "Del: " << comboStart->currentText() << endl;
228} 228}
229 229
230/* 230/*
231 * public slot 231 * public slot
232 */ 232 */
233 233
234void DateEntry::slotEditNote() { 234void DateEntry::slotEditNote() {
235 QString s; 235 QString s;
236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
239 this,0,TRUE); 239 this,0,TRUE);
240 240
241 if ( QPEApplication::execDialog( &noteDlg ) ) { 241 if ( QPEApplication::execDialog( &noteDlg ) ) {
242 noteStr=noteDlg.note->text(); 242 noteStr=noteDlg.note->text();
243 } 243 }
244 244
245} 245}
246 246
247void DateEntry::endDateChanged( int y, int m, int d ) 247void DateEntry::endDateChanged( int y, int m, int d )
248{ 248{
249 endDate.setYMD( y, m, d ); 249 endDate.setYMD( y, m, d );
250 if ( endDate < startDate ) { 250 if ( endDate < startDate ) {
251 endDate = startDate; 251 endDate = startDate;
252 } 252 }
253 253
254 buttonEnd->setText( TimeString::shortDate( endDate ) ); 254 buttonEnd->setText( TimeString::shortDate( endDate ) );
255 255
256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
257} 257}
258 258
259static QTime parseTime( const QString& s, bool ampm ) 259static QTime parseTime( const QString& s, bool ampm )
260{ 260{
261 QTime tmpTime; 261 QTime tmpTime;
262 QStringList l = QStringList::split( ':', s ); 262 QStringList l = QStringList::split( ':', s );
263 int hour = l[0].toInt(); 263 int hour = l[0].toInt();
264 if ( ampm ) { 264 if ( ampm ) {
265 int i=0; 265 int i=0;
266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') 266 while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9')
267 i++; 267 i++;
268 QString digits = l[1].left(i); 268 QString digits = l[1].left(i);
269 if ( l[1].contains( "PM", FALSE ) ) { 269 if ( l[1].contains( "PM", FALSE ) ) {
270 if ( hour != 12 ) 270 if ( hour != 12 )
271 hour += 12; 271 hour += 12;
272 } else { 272 } else {
273 if ( hour == 12 ) 273 if ( hour == 12 )
274 hour = 0; 274 hour = 0;
275 } 275 }
276 l[1] = digits; 276 l[1] = digits;
277 } 277 }
278 int minute = l[1].toInt(); 278 int minute = l[1].toInt();
279 if ( minute > 59 ) 279 if ( minute > 59 )
280 minute = 59; 280 minute = 59;
281 else if ( minute < 0 ) 281 else if ( minute < 0 )
282 minute = 0; 282 minute = 0;
283 if ( hour > 23 ) { 283 if ( hour > 23 ) {
284 hour = 23; 284 hour = 23;
285 minute = 59; 285 minute = 59;
286 } else if ( hour < 0 ) 286 } else if ( hour < 0 )
287 hour = 0; 287 hour = 0;
288 tmpTime.setHMS( hour, minute, 0 ); 288 tmpTime.setHMS( hour, minute, 0 );
289 return tmpTime; 289 return tmpTime;
290} 290}
291 291
292/* 292/*
293 * public slot 293 * public slot
294 */ 294 */
295void DateEntry::endTimeChanged( const QString &s ) 295void DateEntry::endTimeChanged( const QString &s )
296{ 296{
297 endTimeChanged( parseTime(s,ampm) ); 297 endTimeChanged( parseTime(s,ampm) );
298} 298}
299 299
300void DateEntry::endTimeChanged( const QTime &t ) { 300void DateEntry::endTimeChanged( const QTime &t ) {
301 if ( endDate > startDate || t >= startTime ) { 301 if ( endDate > startDate || t >= startTime ) {
302 endTime = t; 302 endTime = t;
303 } else { 303 } else {
304 endTime = startTime; 304 endTime = startTime;
305 //comboEnd->setCurrentItem( comboStart->currentItem() ); 305 //comboEnd->setCurrentItem( comboStart->currentItem() );
306 } 306 }
307 timePickerStart->setHour(endTime.hour()); 307 timePickerStart->setHour(endTime.hour());
308 timePickerStart->setMinute(endTime.minute()); 308 timePickerStart->setMinute(endTime.minute());
309} 309}
310 310
311/* 311/*
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp
index 7cf36da..04c3cf3 100644
--- a/core/pim/datebook/repeatentry.cpp
+++ b/core/pim/datebook/repeatentry.cpp
@@ -266,194 +266,194 @@ void RepeatEntry::setupDaily()
266void RepeatEntry::setupWeekly() 266void RepeatEntry::setupWeekly()
267{ 267{
268 // reshow the buttons... 268 // reshow the buttons...
269 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") ); 269 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") );
270 fraExtra->setExclusive( FALSE ); 270 fraExtra->setExclusive( FALSE );
271 fraExtra->show(); 271 fraExtra->show();
272 if ( startWeekOnMonday ) { 272 if ( startWeekOnMonday ) {
273 cmdExtra1->setText( RepeatEntryBase::tr("Mon") ); 273 cmdExtra1->setText( RepeatEntryBase::tr("Mon") );
274 cmdExtra2->setText( RepeatEntryBase::tr("Tue") ); 274 cmdExtra2->setText( RepeatEntryBase::tr("Tue") );
275 cmdExtra3->setText( RepeatEntryBase::tr("Wed") ); 275 cmdExtra3->setText( RepeatEntryBase::tr("Wed") );
276 cmdExtra4->setText( RepeatEntryBase::tr("Thu") ); 276 cmdExtra4->setText( RepeatEntryBase::tr("Thu") );
277 cmdExtra5->setText( RepeatEntryBase::tr("Fri") ); 277 cmdExtra5->setText( RepeatEntryBase::tr("Fri") );
278 cmdExtra6->setText( RepeatEntryBase::tr("Sat") ); 278 cmdExtra6->setText( RepeatEntryBase::tr("Sat") );
279 cmdExtra7->setText( RepeatEntryBase::tr("Sun") ); 279 cmdExtra7->setText( RepeatEntryBase::tr("Sun") );
280 } else { 280 } else {
281 cmdExtra1->setText( RepeatEntryBase::tr("Sun") ); 281 cmdExtra1->setText( RepeatEntryBase::tr("Sun") );
282 cmdExtra2->setText( RepeatEntryBase::tr("Mon") ); 282 cmdExtra2->setText( RepeatEntryBase::tr("Mon") );
283 cmdExtra3->setText( RepeatEntryBase::tr("Tue") ); 283 cmdExtra3->setText( RepeatEntryBase::tr("Tue") );
284 cmdExtra4->setText( RepeatEntryBase::tr("Wed") ); 284 cmdExtra4->setText( RepeatEntryBase::tr("Wed") );
285 cmdExtra5->setText( RepeatEntryBase::tr("Thu") ); 285 cmdExtra5->setText( RepeatEntryBase::tr("Thu") );
286 cmdExtra6->setText( RepeatEntryBase::tr("Fri") ); 286 cmdExtra6->setText( RepeatEntryBase::tr("Fri") );
287 cmdExtra7->setText( RepeatEntryBase::tr("Sat") ); 287 cmdExtra7->setText( RepeatEntryBase::tr("Sat") );
288 } 288 }
289 // I hope clustering these improve performance.... 289 // I hope clustering these improve performance....
290 cmdExtra1->setOn( FALSE ); 290 cmdExtra1->setOn( FALSE );
291 cmdExtra2->setOn( FALSE ); 291 cmdExtra2->setOn( FALSE );
292 cmdExtra3->setOn( FALSE ); 292 cmdExtra3->setOn( FALSE );
293 cmdExtra4->setOn( FALSE ); 293 cmdExtra4->setOn( FALSE );
294 cmdExtra5->setOn( FALSE ); 294 cmdExtra5->setOn( FALSE );
295 cmdExtra6->setOn( FALSE ); 295 cmdExtra6->setOn( FALSE );
296 cmdExtra7->setOn( FALSE ); 296 cmdExtra7->setOn( FALSE );
297 297
298 cmdExtra1->show(); 298 cmdExtra1->show();
299 cmdExtra2->show(); 299 cmdExtra2->show();
300 cmdExtra3->show(); 300 cmdExtra3->show();
301 cmdExtra4->show(); 301 cmdExtra4->show();
302 cmdExtra5->show(); 302 cmdExtra5->show();
303 cmdExtra6->show(); 303 cmdExtra6->show();
304 cmdExtra7->show(); 304 cmdExtra7->show();
305 305
306 lblWeekVar->show(); 306 lblWeekVar->show();
307 spinFreq->setValue( 1 ); 307 spinFreq->setValue( 1 );
308 // might as well set the day too... 308 // might as well set the day too...
309 if ( startWeekOnMonday ) { 309 if ( startWeekOnMonday ) {
310 fraExtra->setButton( start.dayOfWeek() - 1 ); 310 fraExtra->setButton( start.dayOfWeek() - 1 );
311 } else { 311 } else {
312 fraExtra->setButton( start.dayOfWeek() % 7 ); 312 fraExtra->setButton( start.dayOfWeek() % 7 );
313 } 313 }
314 lblFreq->setText( tr("week(s)") ); 314 lblFreq->setText( tr("week(s)") );
315 lblVar2->show(); 315 lblVar2->show();
316 showRepeatStuff(); 316 showRepeatStuff();
317 setupRepeatLabel( 1 ); 317 setupRepeatLabel( 1 );
318} 318}
319 319
320void RepeatEntry::setupMonthly() 320void RepeatEntry::setupMonthly()
321{ 321{
322 hideExtras(); 322 hideExtras();
323 lblWeekVar->hide(); 323 lblWeekVar->hide();
324 fraExtra->setTitle( tr("Repeat By") ); 324 fraExtra->setTitle( tr("Repeat By") );
325 fraExtra->setExclusive( TRUE ); 325 fraExtra->setExclusive( TRUE );
326 fraExtra->show(); 326 fraExtra->show();
327 cmdExtra1->setText( tr("Day") ); 327 cmdExtra1->setText( tr("Day") );
328 cmdExtra1->show(); 328 cmdExtra1->show();
329 cmdExtra2->setText( tr("Date") ); 329 cmdExtra2->setText( tr("Date") );
330 cmdExtra2->show(); 330 cmdExtra2->show();
331 spinFreq->setValue( 1 ); 331 spinFreq->setValue( 1 );
332 lblFreq->setText( tr("month(s)") ); 332 lblFreq->setText( tr("month(s)") );
333 lblVar2->show(); 333 lblVar2->show();
334 showRepeatStuff(); 334 showRepeatStuff();
335 setupRepeatLabel( 1 ); 335 setupRepeatLabel( 1 );
336} 336}
337 337
338void RepeatEntry::setupYearly() 338void RepeatEntry::setupYearly()
339{ 339{
340 hideExtras(); 340 hideExtras();
341 lblWeekVar->hide(); 341 lblWeekVar->hide();
342 spinFreq->setValue( 1 ); 342 spinFreq->setValue( 1 );
343 lblFreq->setText( tr("year(s)") ); 343 lblFreq->setText( tr("year(s)") );
344 lblFreq->show(); 344 lblFreq->show();
345 lblFreq->show(); 345 lblFreq->show();
346 showRepeatStuff(); 346 showRepeatStuff();
347 lblVar2->show(); 347 lblVar2->show();
348 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); 348 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
349 lblRepeat->setText( strEvery ); 349 lblRepeat->setText( strEvery );
350 setupRepeatLabel( 1 ); 350 setupRepeatLabel( 1 );
351 351
352} 352}
353 353
354void RepeatEntry::init() 354void RepeatEntry::init()
355{ 355{
356 QPopupMenu *m1 = new QPopupMenu( this ); 356 QPopupMenu *m1 = new QPopupMenu( this );
357 repeatPicker = new DateBookMonth( m1, 0, TRUE ); 357 repeatPicker = new DateBookMonth( m1, 0, TRUE );
358 m1->insertItem( repeatPicker ); 358 m1->insertItem( repeatPicker );
359 cmdEnd->setPopup( m1 ); 359 cmdEnd->setPopup( m1 );
360 cmdEnd->setPopupDelay( 0 ); 360 cmdEnd->setPopupDelay( 0 );
361 361
362 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), 362 QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)),
363 this, SLOT(endDateChanged(int, int, int)) ); 363 this, SLOT(endDateChanged(int,int,int)) );
364 QObject::connect( qApp, SIGNAL(weekChanged(bool)), 364 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
365 this, SLOT(slotChangeStartOfWeek(bool)) ); 365 this, SLOT(slotChangeStartOfWeek(bool)) );
366 366
367 listRTypeButtons.setAutoDelete( TRUE ); 367 listRTypeButtons.setAutoDelete( TRUE );
368 listRTypeButtons.append( cmdNone ); 368 listRTypeButtons.append( cmdNone );
369 listRTypeButtons.append( cmdDay ); 369 listRTypeButtons.append( cmdDay );
370 listRTypeButtons.append( cmdWeek ); 370 listRTypeButtons.append( cmdWeek );
371 listRTypeButtons.append( cmdMonth ); 371 listRTypeButtons.append( cmdMonth );
372 listRTypeButtons.append( cmdYear ); 372 listRTypeButtons.append( cmdYear );
373 373
374 listExtra.setAutoDelete( TRUE ); 374 listExtra.setAutoDelete( TRUE );
375 listExtra.append( cmdExtra1 ); 375 listExtra.append( cmdExtra1 );
376 listExtra.append( cmdExtra2 ); 376 listExtra.append( cmdExtra2 );
377 listExtra.append( cmdExtra3 ); 377 listExtra.append( cmdExtra3 );
378 listExtra.append( cmdExtra4 ); 378 listExtra.append( cmdExtra4 );
379 listExtra.append( cmdExtra5 ); 379 listExtra.append( cmdExtra5 );
380 listExtra.append( cmdExtra6 ); 380 listExtra.append( cmdExtra6 );
381 listExtra.append( cmdExtra7 ); 381 listExtra.append( cmdExtra7 );
382} 382}
383 383
384void RepeatEntry::slotNoEnd( bool unused ) 384void RepeatEntry::slotNoEnd( bool unused )
385{ 385{
386 // if the item was toggled, then go ahead and set it to the maximum date 386 // if the item was toggled, then go ahead and set it to the maximum date
387 if ( unused ) { 387 if ( unused ) {
388 end.setYMD( 3000, 12, 31 ); 388 end.setYMD( 3000, 12, 31 );
389 cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); 389 cmdEnd->setText( RepeatEntryBase::tr("No End Date") );
390 } else { 390 } else {
391 end = start; 391 end = start;
392 cmdEnd->setText( TimeString::shortDate(end) ); 392 cmdEnd->setText( TimeString::shortDate(end) );
393 } 393 }
394} 394}
395 395
396void RepeatEntry::endDateChanged( int y, int m, int d ) 396void RepeatEntry::endDateChanged( int y, int m, int d )
397{ 397{
398 end.setYMD( y, m, d ); 398 end.setYMD( y, m, d );
399 if ( end < start ) 399 if ( end < start )
400 end = start; 400 end = start;
401 cmdEnd->setText( TimeString::shortDate( end ) ); 401 cmdEnd->setText( TimeString::shortDate( end ) );
402 repeatPicker->setDate( end.year(), end.month(), end.day() ); 402 repeatPicker->setDate( end.year(), end.month(), end.day() );
403} 403}
404 404
405void RepeatEntry::setupRepeatLabel( const QString &s ) 405void RepeatEntry::setupRepeatLabel( const QString &s )
406{ 406{
407 lblVar1->setText( s ); 407 lblVar1->setText( s );
408} 408}
409 409
410void RepeatEntry::setupRepeatLabel( int x ) 410void RepeatEntry::setupRepeatLabel( int x )
411{ 411{
412 // change the spelling based on the value of x 412 // change the spelling based on the value of x
413 QString strVar2; 413 QString strVar2;
414 414
415 if ( x > 1 ) 415 if ( x > 1 )
416 lblVar1->show(); 416 lblVar1->show();
417 else 417 else
418 lblVar1->hide(); 418 lblVar1->hide();
419 419
420 switch ( currInterval ) { 420 switch ( currInterval ) {
421 case NONE: 421 case NONE:
422 break; 422 break;
423 case DAY: 423 case DAY:
424 if ( x > 1 ) 424 if ( x > 1 )
425 strVar2 = tr( "days" ); 425 strVar2 = tr( "days" );
426 else 426 else
427 strVar2 = tr( "day" ); 427 strVar2 = tr( "day" );
428 break; 428 break;
429 case WEEK: 429 case WEEK:
430 if ( x > 1 ) 430 if ( x > 1 )
431 strVar2 = tr( "weeks" ); 431 strVar2 = tr( "weeks" );
432 else 432 else
433 strVar2 = tr( "week" ); 433 strVar2 = tr( "week" );
434 break; 434 break;
435 case MONTH: 435 case MONTH:
436 if ( x > 1 ) 436 if ( x > 1 )
437 strVar2 = RepeatEntryBase::tr( "months" ); 437 strVar2 = RepeatEntryBase::tr( "months" );
438 else 438 else
439 strVar2 = tr( "month" ); 439 strVar2 = tr( "month" );
440 break; 440 break;
441 case YEAR: 441 case YEAR:
442 if ( x > 1 ) 442 if ( x > 1 )
443 strVar2 = RepeatEntryBase::tr( "years" ); 443 strVar2 = RepeatEntryBase::tr( "years" );
444 else 444 else
445 strVar2 = tr( "year" ); 445 strVar2 = tr( "year" );
446 break; 446 break;
447 } 447 }
448 if ( !strVar2.isNull() ) 448 if ( !strVar2.isNull() )
449 lblVar2->setText( strVar2 ); 449 lblVar2->setText( strVar2 );
450} 450}
451 451
452void RepeatEntry::showRepeatStuff() 452void RepeatEntry::showRepeatStuff()
453{ 453{
454 cmdEnd->show(); 454 cmdEnd->show();
455 chkNoEnd->show(); 455 chkNoEnd->show();
456 lblFreq->show(); 456 lblFreq->show();
457 lblEvery->show(); 457 lblEvery->show();
458 lblFreq->show(); 458 lblFreq->show();
459 spinFreq->show(); 459 spinFreq->show();
diff --git a/core/pim/datebook2/mainwindow.cpp b/core/pim/datebook2/mainwindow.cpp
index 7ff2204..3937796 100644
--- a/core/pim/datebook2/mainwindow.cpp
+++ b/core/pim/datebook2/mainwindow.cpp
@@ -1,250 +1,250 @@
1 1
2#include <qcopchannel_qws.h> 2#include <qcopchannel_qws.h>
3#include <qwidgetstack.h> 3#include <qwidgetstack.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qaction.h> 5#include <qaction.h>
6#include <qpopupmenu.h> 6#include <qpopupmenu.h>
7#include <qtimer.h> 7#include <qtimer.h>
8 8
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include <qpe/ir.h> 10#include <qpe/ir.h>
11#include <qmenubar.h> 11#include <qmenubar.h>
12#include <qtoolbar.h> 12#include <qtoolbar.h>
13#include <qpe/qpemessagebox.h> 13#include <qpe/qpemessagebox.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15 15
16#include "editor.h" 16#include "editor.h"
17#include "show.h" 17#include "show.h"
18#include "templatemanager.h" 18#include "templatemanager.h"
19#include "bookmanager.h" 19#include "bookmanager.h"
20#include "mainwindow.h" 20#include "mainwindow.h"
21 21
22 22
23using namespace Datebook; 23using namespace Datebook;
24 24
25MainWindow::MainWindow() 25MainWindow::MainWindow()
26 : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" ) 26 : OPimMainWindow( "Datebook", 0, 0 ), m_descMan( "Descriptions" ), m_locMan( "Locations" )
27{ 27{
28 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 28 setIcon( Resource::loadPixmap( "datebook_icon" ) );
29 initUI(); 29 initUI();
30 initManagers(); 30 initManagers();
31 initView(); 31 initView();
32 initConfig(); 32 initConfig();
33 33
34 QTimer::singleShot(0, this, SLOT(populate() ) ); 34 QTimer::singleShot(0, this, SLOT(populate() ) );
35 35
36 QCopChannel* chan = new QCopChannel( "QPE/System", this ); 36 QCopChannel* chan = new QCopChannel( "QPE/System", this );
37 connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), 37 connect( chan, SIGNAL( received(const QCString&,const QByteArray&) ),
38 this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); 38 this, SLOT( slotReceive(const QCString&,const QByteArray&) ) );
39 39
40 chan = new QCopChannel( "QPE/Datebook", this ); 40 chan = new QCopChannel( "QPE/Datebook", this );
41 connect( chan, SIGNAL( received(const QCString&, const QByteArray& ) ), 41 connect( chan, SIGNAL( received(const QCString&,const QByteArray&) ),
42 this, SLOT( slotReceive( const QCString&, const QByteArray& ) ) ); 42 this, SLOT( slotReceive(const QCString&,const QByteArray&) ) );
43} 43}
44MainWindow::~MainWindow() { 44MainWindow::~MainWindow() {
45 m_tempMan.save(); 45 m_tempMan.save();
46 m_locMan.save(); 46 m_locMan.save();
47 m_descMan.save(); 47 m_descMan.save();
48 48
49 manager()->save(); 49 manager()->save();
50 delete m_manager; 50 delete m_manager;
51} 51}
52void MainWindow::doSetDocument( const QString& str ) { 52void MainWindow::doSetDocument( const QString& str ) {
53 53
54} 54}
55void MainWindow::flush() { 55void MainWindow::flush() {
56 manager()->save(); 56 manager()->save();
57} 57}
58void MainWindow::reload() { 58void MainWindow::reload() {
59 manager()->reload(); 59 manager()->reload();
60} 60}
61int MainWindow::create() { 61int MainWindow::create() {
62 return 0; 62 return 0;
63} 63}
64bool MainWindow::remove( int uid ) { 64bool MainWindow::remove( int uid ) {
65 manager()->remove( uid ); 65 manager()->remove( uid );
66 return true; 66 return true;
67} 67}
68void MainWindow::beam( int uid ) { 68void MainWindow::beam( int uid ) {
69 69
70} 70}
71void MainWindow::show( int uid ) { 71void MainWindow::show( int uid ) {
72 72
73 eventShow()->show( manager()->event( uid ) ); 73 eventShow()->show( manager()->event( uid ) );
74} 74}
75void MainWindow::add( const OPimRecord& ad) { 75void MainWindow::add( const OPimRecord& ad) {
76 manager()->add( ad ); 76 manager()->add( ad );
77} 77}
78void MainWindow::edit() { 78void MainWindow::edit() {
79 edit ( currentView()->currentItem() ); 79 edit ( currentView()->currentItem() );
80} 80}
81void MainWindow::edit( int uid ) { 81void MainWindow::edit( int uid ) {
82 82
83} 83}
84/* 84/*
85 * init tool bars layout and so on 85 * init tool bars layout and so on
86 */ 86 */
87void MainWindow::initUI() { 87void MainWindow::initUI() {
88 setToolBarsMovable( false ); 88 setToolBarsMovable( false );
89 89
90 m_stack = new QWidgetStack( this ); 90 m_stack = new QWidgetStack( this );
91 setCentralWidget( m_stack ); 91 setCentralWidget( m_stack );
92 92
93 m_toolBar = new QToolBar( this ); 93 m_toolBar = new QToolBar( this );
94 m_toolBar->setHorizontalStretchable( TRUE ); 94 m_toolBar->setHorizontalStretchable( TRUE );
95 95
96 QMenuBar* mb = new QMenuBar( m_toolBar ); 96 QMenuBar* mb = new QMenuBar( m_toolBar );
97 97
98 m_popView = new QPopupMenu( this ); 98 m_popView = new QPopupMenu( this );
99 m_popSetting = new QPopupMenu( this ); 99 m_popSetting = new QPopupMenu( this );
100 100
101 mb->insertItem( tr("View"), m_popView ); 101 mb->insertItem( tr("View"), m_popView );
102 mb->insertItem( tr("Settings" ), m_popSetting ); 102 mb->insertItem( tr("Settings" ), m_popSetting );
103 103
104 m_popTemplate = new QPopupMenu( this ); 104 m_popTemplate = new QPopupMenu( this );
105 m_popTemplate->setCheckable( TRUE ); 105 m_popTemplate->setCheckable( TRUE );
106 connect( m_popTemplate, SIGNAL(activated(int) ), 106 connect( m_popTemplate, SIGNAL(activated(int) ),
107 this, SLOT(slotNewFromTemplate(int) ) ); 107 this, SLOT(slotNewFromTemplate(int) ) );
108 m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0); 108 m_popView->insertItem(tr("New from template"), m_popTemplate, -1, 0);
109 109
110 110
111 QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"), 111 QAction* a = new QAction( tr("New Event"), Resource::loadPixmap("new"),
112 QString::null, 0, this, 0 ); 112 QString::null, 0, this, 0 );
113 a->addTo( m_toolBar ); 113 a->addTo( m_toolBar );
114 a->addTo( m_popView ); 114 a->addTo( m_popView );
115 connect(a, SIGNAL( activated() ), this, SLOT( create() ) ); 115 connect(a, SIGNAL( activated() ), this, SLOT( create() ) );
116 116
117 a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"), 117 a = new QAction( tr("Edit Event"), Resource::loadPixmap("edit"),
118 QString::null, 0, this, 0 ); 118 QString::null, 0, this, 0 );
119 a->addTo( m_popView ); 119 a->addTo( m_popView );
120 connect(a, SIGNAL( activated() ), this, SLOT( edit() ) ); 120 connect(a, SIGNAL( activated() ), this, SLOT( edit() ) );
121 121
122 a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"), 122 a = new QAction( tr("Today" ), Resource::loadPixmap( "datebook/to_day"),
123 QString::null, 0, this, 0 ); 123 QString::null, 0, this, 0 );
124 a->addTo( m_toolBar ); 124 a->addTo( m_toolBar );
125 connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) ); 125 connect(a, SIGNAL( activated() ), this, SLOT( slotGoToNow() ) );
126 126
127 a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ), 127 a = new QAction( tr("Find"), Resource::loadPixmap( "mag" ),
128 QString::null, 0, this, 0 ); 128 QString::null, 0, this, 0 );
129 a->addTo( m_toolBar ); 129 a->addTo( m_toolBar );
130 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 130 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
131 131
132 a = new QAction( tr("Configure"), QString::null, 0, 0 ); 132 a = new QAction( tr("Configure"), QString::null, 0, 0 );
133 a->addTo( m_popSetting ); 133 a->addTo( m_popSetting );
134 connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); 134 connect(a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
135 135
136 a = new QAction( tr("Configure Locations"), QString::null, 0, 0 ); 136 a = new QAction( tr("Configure Locations"), QString::null, 0, 0 );
137 a->addTo( m_popSetting ); 137 a->addTo( m_popSetting );
138 connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) ); 138 connect(a, SIGNAL( activated() ), this, SLOT( slotConfigureLocs() ) );
139 139
140 a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 ); 140 a = new QAction( tr("Configure Descriptions"), QString::null, 0, 0 );
141 a->addTo( m_popSetting ); 141 a->addTo( m_popSetting );
142 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) ); 142 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureDesc() ) );
143 143
144 a = new QAction( tr("Configure Templates"), QString::null, 0, 0 ); 144 a = new QAction( tr("Configure Templates"), QString::null, 0, 0 );
145 a->addTo( m_popSetting ); 145 a->addTo( m_popSetting );
146 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) ); 146 connect(a, SIGNAL( activated() ), this, SLOT(slotConfigureTemp() ) );
147 147
148 connect( qApp, SIGNAL(clockChanged(bool) ), 148 connect( qApp, SIGNAL(clockChanged(bool) ),
149 this, SLOT(slotClockChanged(bool) ) ); 149 this, SLOT(slotClockChanged(bool) ) );
150 connect( qApp, SIGNAL(weekChanged(bool) ), 150 connect( qApp, SIGNAL(weekChanged(bool) ),
151 this, SLOT(slotWeekChanged(bool) ) ); 151 this, SLOT(slotWeekChanged(bool) ) );
152 152
153 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), 153 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&) ),
154 this, SLOT(slotAppMessage( const QCString&, const QByteArray& ) ) ); 154 this, SLOT(slotAppMessage(const QCString&,const QByteArray&) ) );
155} 155}
156void MainWindow::initConfig() { 156void MainWindow::initConfig() {
157 157
158} 158}
159void MainWindow::initView() { 159void MainWindow::initView() {
160 160
161} 161}
162void MainWindow::initManagers() { 162void MainWindow::initManagers() {
163 m_manager = new BookManager; 163 m_manager = new BookManager;
164 164
165 m_tempMan.load(); 165 m_tempMan.load();
166 m_locMan.load(); 166 m_locMan.load();
167 m_descMan.load(); 167 m_descMan.load();
168 168
169 setTemplateMenu(); 169 setTemplateMenu();
170} 170}
171void MainWindow::raiseCurrentView() { 171void MainWindow::raiseCurrentView() {
172 172
173} 173}
174/* 174/*
175 * populate the view 175 * populate the view
176 */ 176 */
177void MainWindow::populate() { 177void MainWindow::populate() {
178 if (!manager()->isLoaded() ) 178 if (!manager()->isLoaded() )
179 manager()->load(); 179 manager()->load();
180} 180}
181void MainWindow::slotGoToNow() { 181void MainWindow::slotGoToNow() {
182 182
183} 183}
184View* MainWindow::currentView() { 184View* MainWindow::currentView() {
185 185
186} 186}
187void MainWindow::slotFind() { 187void MainWindow::slotFind() {
188 188
189} 189}
190void MainWindow::slotConfigure() { 190void MainWindow::slotConfigure() {
191 191
192} 192}
193void MainWindow::slotClockChanged( bool ) { 193void MainWindow::slotClockChanged( bool ) {
194 194
195} 195}
196void MainWindow::slotWeekChanged(bool ) { 196void MainWindow::slotWeekChanged(bool ) {
197 197
198} 198}
199void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) { 199void MainWindow::slotAppMessage( const QCString&, const QByteArray& ) {
200 200
201} 201}
202void MainWindow::slotReceive( const QCString&, const QByteArray& ) { 202void MainWindow::slotReceive( const QCString&, const QByteArray& ) {
203 203
204} 204}
205BookManager* MainWindow::manager() { 205BookManager* MainWindow::manager() {
206 return m_manager; 206 return m_manager;
207} 207}
208TemplateManager MainWindow::templateManager() { 208TemplateManager MainWindow::templateManager() {
209 return m_tempMan; 209 return m_tempMan;
210} 210}
211LocationManager MainWindow::locationManager() { 211LocationManager MainWindow::locationManager() {
212 return m_locMan; 212 return m_locMan;
213} 213}
214DescriptionManager MainWindow::descriptionManager() { 214DescriptionManager MainWindow::descriptionManager() {
215 return m_descMan; 215 return m_descMan;
216} 216}
217void MainWindow::setLocationManager( const LocationManager& loc) { 217void MainWindow::setLocationManager( const LocationManager& loc) {
218 m_locMan = loc; 218 m_locMan = loc;
219} 219}
220void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) { 220void MainWindow::setDescriptionManager( const DescriptionManager& dsc ) {
221 m_descMan = dsc; 221 m_descMan = dsc;
222} 222}
223Show* MainWindow::eventShow() { 223Show* MainWindow::eventShow() {
224 return m_show; 224 return m_show;
225} 225}
226void MainWindow::slotAction( QAction* act ) { 226void MainWindow::slotAction( QAction* act ) {
227 227
228} 228}
229void MainWindow::slotConfigureLocs() { 229void MainWindow::slotConfigureLocs() {
230 LocationManagerDialog dlg( locationManager() ); 230 LocationManagerDialog dlg( locationManager() );
231 dlg.setCaption( tr("Configure Locations") ); 231 dlg.setCaption( tr("Configure Locations") );
232 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { 232 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
233 setLocationManager( dlg.manager() ); 233 setLocationManager( dlg.manager() );
234 } 234 }
235} 235}
236void MainWindow::slotConfigureDesc() { 236void MainWindow::slotConfigureDesc() {
237 DescriptionManagerDialog dlg( descriptionManager() ); 237 DescriptionManagerDialog dlg( descriptionManager() );
238 dlg.setCaption( tr("Configure Descriptions") ); 238 dlg.setCaption( tr("Configure Descriptions") );
239 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { 239 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
240 setDescriptionManager( dlg.manager() ); 240 setDescriptionManager( dlg.manager() );
241 } 241 }
242} 242}
243void MainWindow::slotConfigureTemp() { 243void MainWindow::slotConfigureTemp() {
244 TemplateDialog dlg( templateManager(), editor() ); 244 TemplateDialog dlg( templateManager(), editor() );
245 dlg.setCaption( tr("Configure Templates") ); 245 dlg.setCaption( tr("Configure Templates") );
246 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { 246 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
247 m_tempMan = dlg.manager(); 247 m_tempMan = dlg.manager();
248 setTemplateMenu(); 248 setTemplateMenu();
249 } 249 }
250} 250}
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index bfe95b0..8b6a5df 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -108,193 +108,193 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
108 buttonBox->hide(); 108 buttonBox->hide();
109 109
110 searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); 110 searches.append( new AppLnkSearch( resultsList, tr("Applications") ) );
111 searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); 111 searches.append( new DocLnkSearch( resultsList, tr("Documents") ) );
112 searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); 112 searches.append( new TodoSearch( resultsList, tr("Todo List") ) );
113 searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); 113 searches.append( new DatebookSearch( resultsList, tr("Calendar") ) );
114 searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); 114 searches.append( new AdressSearch( resultsList, tr("Contacts") ) );
115 115
116 setCentralWidget( mainFrame ); 116 setCentralWidget( mainFrame );
117 117
118 popupTimer = new QTimer(); 118 popupTimer = new QTimer();
119 searchTimer = new QTimer(); 119 searchTimer = new QTimer();
120 120
121 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 121 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
122 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); 122 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged()));
123 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 123 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
124 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 124 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
125 125
126 signalMapper = new QSignalMapper( this ); 126 signalMapper = new QSignalMapper( this );
127 127
128 connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); 128 connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) );
129 129
130 makeMenu(); 130 makeMenu();
131 131
132 Config cfg( "osearch", Config::User ); 132 Config cfg( "osearch", Config::User );
133 cfg.setGroup( "search_settings" ); 133 cfg.setGroup( "search_settings" );
134 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); 134 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) );
135 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); 135 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) );
136// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); 136// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) );
137} 137}
138 138
139void MainWindow::makeMenu() 139void MainWindow::makeMenu()
140{ 140{
141 QToolBar *toolBar = new QToolBar( this ); 141 QToolBar *toolBar = new QToolBar( this );
142 QToolBar *searchBar = new QToolBar(this); 142 QToolBar *searchBar = new QToolBar(this);
143 QMenuBar *menuBar = new QMenuBar( toolBar ); 143 QMenuBar *menuBar = new QMenuBar( toolBar );
144 QPopupMenu *searchMenu = new QPopupMenu( menuBar ); 144 QPopupMenu *searchMenu = new QPopupMenu( menuBar );
145// QPopupMenu *viewMenu = new QPopupMenu( menuBar ); 145// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
146 QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); 146 QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
147 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); 147 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu );
148 148
149 setToolBarsMovable( false ); 149 setToolBarsMovable( false );
150 toolBar->setHorizontalStretchable( true ); 150 toolBar->setHorizontalStretchable( true );
151 menuBar->insertItem( tr( "Search" ), searchMenu ); 151 menuBar->insertItem( tr( "Search" ), searchMenu );
152 menuBar->insertItem( tr( "Settings" ), cfgMenu ); 152 menuBar->insertItem( tr( "Settings" ), cfgMenu );
153 153
154 //SETTINGS MENU 154 //SETTINGS MENU
155 cfgMenu->insertItem( tr( "Search" ), searchOptions ); 155 cfgMenu->insertItem( tr( "Search" ), searchOptions );
156 QPopupMenu *pop; 156 QPopupMenu *pop;
157 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 157 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
158 pop = s->popupMenu(); 158 pop = s->popupMenu();
159 if (pop){ 159 if (pop){
160 cfgMenu->insertItem( s->text(0), pop ); 160 cfgMenu->insertItem( s->text(0), pop );
161 } 161 }
162 } 162 }
163 163
164 164
165 //SEARCH 165 //SEARCH
166 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); 166 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 );
167 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); 167 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) );
168 // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); 168 // QWhatsThis::add( SearchAllAction, tr("Search everything...") );
169 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); 169 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) );
170 SearchAllAction->addTo( searchMenu ); 170 SearchAllAction->addTo( searchMenu );
171 searchMenu->insertItem( tr( "Options" ), searchOptions ); 171 searchMenu->insertItem( tr( "Options" ), searchOptions );
172 172
173 //SEARCH OPTIONS 173 //SEARCH OPTIONS
174 //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); 174 //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true );
175 //actionWholeWordsOnly->addTo( searchOptions ); 175 //actionWholeWordsOnly->addTo( searchOptions );
176 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); 176 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true );
177 actionCaseSensitiv->addTo( searchOptions ); 177 actionCaseSensitiv->addTo( searchOptions );
178 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); 178 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true );
179 actionWildcards->addTo( searchOptions ); 179 actionWildcards->addTo( searchOptions );
180 180
181 //SEARCH BAR 181 //SEARCH BAR
182 LabelEnterText = new QLabel( searchBar, "Label" ); 182 LabelEnterText = new QLabel( searchBar, "Label" );
183 LabelEnterText->setAutoMask( FALSE ); 183 LabelEnterText->setAutoMask( FALSE );
184 LabelEnterText->setText( tr( "Search for: " ) ); 184 LabelEnterText->setText( tr( "Search for: " ) );
185 185
186 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 186 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
187 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); 187 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
188 QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); 188 QWhatsThis::add( searchEdit, tr("Enter your search terms here") );
189 searchEdit->setFocus(); 189 searchEdit->setFocus();
190 searchBar->setHorizontalStretchable( TRUE ); 190 searchBar->setHorizontalStretchable( TRUE );
191 searchBar->setStretchableWidget( searchEdit ); 191 searchBar->setStretchableWidget( searchEdit );
192 192
193 //Search button 193 //Search button
194 SearchAllAction->addTo( searchBar ); 194 SearchAllAction->addTo( searchBar );
195 195
196 //image ripped of off opie-login/loginwindow.cpp 196 //image ripped of off opie-login/loginwindow.cpp
197 QPixmap image1( ( const char** ) image1_data ); 197 QPixmap image1( ( const char** ) image1_data );
198 198
199 //Clear text 199 //Clear text
200 ClearSearchText = new QToolButton( searchBar, "ClearSearchText"); 200 ClearSearchText = new QToolButton( searchBar, "ClearSearchText");
201 ClearSearchText->setText( tr( "" ) ); 201 ClearSearchText->setText( tr( "" ) );
202 ClearSearchText->setPixmap( image1 ); 202 ClearSearchText->setPixmap( image1 );
203 203
204 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),this, SLOT( setSearch( const QString & ) ) ); 204 connect( searchEdit, SIGNAL( textChanged(const QString&) ),this, SLOT( setSearch(const QString&) ) );
205 connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) ); 205 connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) );
206 206
207} 207}
208 208
209MainWindow::~MainWindow() 209MainWindow::~MainWindow()
210{ 210{
211 Config cfg( "osearch", Config::User ); 211 Config cfg( "osearch", Config::User );
212 cfg.setGroup( "search_settings" ); 212 cfg.setGroup( "search_settings" );
213 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); 213 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() );
214 cfg.writeEntry( "wildcards", actionWildcards->isOn() ); 214 cfg.writeEntry( "wildcards", actionWildcards->isOn() );
215 //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); 215 //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() );
216} 216}
217 217
218void MainWindow::setCurrent(QListViewItem *item) 218void MainWindow::setCurrent(QListViewItem *item)
219{ 219{
220 if (!item) return; 220 if (!item) return;
221 _currentItem = (OListViewItem*)item; 221 _currentItem = (OListViewItem*)item;
222 //_currentItem = dynamic_cast<OListViewItem*>(item); 222 //_currentItem = dynamic_cast<OListViewItem*>(item);
223 if (_currentItem->rtti() == OListViewItem::Result){ 223 if (_currentItem->rtti() == OListViewItem::Result){
224 ResultItem *res = (ResultItem*)item; 224 ResultItem *res = (ResultItem*)item;
225 // ResultItem *res = dynamic_cast<ResultItem*>(item); 225 // ResultItem *res = dynamic_cast<ResultItem*>(item);
226 richEdit->setText( res->toRichText() ); 226 richEdit->setText( res->toRichText() );
227 QIntDict<QString> acts = res->actions(); 227 QIntDict<QString> acts = res->actions();
228 QButton *button; 228 QButton *button;
229 for (uint i = 0; i < acts.count(); i++){ 229 for (uint i = 0; i < acts.count(); i++){
230 button = buttonMap[i]; 230 button = buttonMap[i];
231 if (!button) { 231 if (!button) {
232 qWarning(" no button for %s", (*acts[i]).latin1() ); 232 qWarning(" no button for %s", (*acts[i]).latin1() );
233 button = new QPushButton( buttonBox ); 233 button = new QPushButton( buttonBox );
234 buttonMap.insert( i, button ); 234 buttonMap.insert( i, button );
235 signalMapper->setMapping(button, i ); 235 signalMapper->setMapping(button, i );
236 connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); 236 connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) );
237 } 237 }
238 button->setText( *acts[i] ); 238 button->setText( *acts[i] );
239 button->show(); 239 button->show();
240 } 240 }
241 for (uint i = acts.count(); i < _buttonCount; i++){ 241 for (uint i = acts.count(); i < _buttonCount; i++){
242 button = buttonMap[i]; 242 button = buttonMap[i];
243 if (button) button->hide(); 243 if (button) button->hide();
244 } 244 }
245 _buttonCount = acts.count(); 245 _buttonCount = acts.count();
246 detailsFrame->show(); 246 detailsFrame->show();
247 buttonBox->show(); 247 buttonBox->show();
248 248
249 }else { 249 }else {
250 detailsFrame->hide(); 250 detailsFrame->hide();
251 buttonBox->hide(); 251 buttonBox->hide();
252 } 252 }
253 popupTimer->start( 300, true ); 253 popupTimer->start( 300, true );
254} 254}
255 255
256void MainWindow::stopTimer(QListViewItem*) 256void MainWindow::stopTimer(QListViewItem*)
257{ 257{
258 popupTimer->stop(); 258 popupTimer->stop();
259} 259}
260 260
261void MainWindow::showPopup() 261void MainWindow::showPopup()
262{ 262{
263 popupTimer->stop(); 263 popupTimer->stop();
264 if (!_currentItem) return; 264 if (!_currentItem) return;
265 QPopupMenu *pop = _currentItem->popupMenu(); 265 QPopupMenu *pop = _currentItem->popupMenu();
266 if (pop) pop->popup( QCursor::pos() ); 266 if (pop) pop->popup( QCursor::pos() );
267} 267}
268 268
269void MainWindow::setSearch( const QString &key ) 269void MainWindow::setSearch( const QString &key )
270{ 270{
271 searchTimer->stop(); 271 searchTimer->stop();
272 _searchString = key; 272 _searchString = key;
273 searchTimer->start( 300 ); 273 searchTimer->start( 300 );
274} 274}
275 275
276void MainWindow::searchStringChanged() 276void MainWindow::searchStringChanged()
277{ 277{
278#ifdef NEW_OWAIT 278#ifdef NEW_OWAIT
279 OWait("setting search string"); 279 OWait("setting search string");
280#endif 280#endif
281 searchTimer->stop(); 281 searchTimer->stop();
282 QString ss = _searchString; 282 QString ss = _searchString;
283 //ss = Global::stringQuote( _searchString ); 283 //ss = Global::stringQuote( _searchString );
284 //if (actionWholeWordsOnly->isOn()) 284 //if (actionWholeWordsOnly->isOn())
285 // ss = "\\s"+_searchString+"\\s"; 285 // ss = "\\s"+_searchString+"\\s";
286 //qDebug(" set searchString >%s<",ss.latin1()); 286 //qDebug(" set searchString >%s<",ss.latin1());
287 QRegExp re( ss ); 287 QRegExp re( ss );
288 re.setCaseSensitive( actionCaseSensitiv->isOn() ); 288 re.setCaseSensitive( actionCaseSensitiv->isOn() );
289 re.setWildcard( actionWildcards->isOn() ); 289 re.setWildcard( actionWildcards->isOn() );
290 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) 290 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
291 s->setSearch( re ); 291 s->setSearch( re );
292} 292}
293 293
294void MainWindow::searchAll() 294void MainWindow::searchAll()
295{ 295{
296#ifdef NEW_OWAIT 296#ifdef NEW_OWAIT
297 OWait("searching..."); 297 OWait("searching...");
298#endif 298#endif
299 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 299 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
300 s->doSearch(); 300 s->doSearch();
diff --git a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
index c8652f3..b0d456d 100644
--- a/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
+++ b/core/pim/today/plugins/addressbook/addresspluginwidget.cpp
@@ -1,137 +1,137 @@
1/* 1/*
2 * addresspluginwidget.cpp 2 * addresspluginwidget.cpp
3 * 3 *
4 * copyright : (c) 2003 by Stefan Eilers 4 * copyright : (c) 2003 by Stefan Eilers
5 * email : eilers.stefan@epost.de 5 * email : eilers.stefan@epost.de
6 * 6 *
7 * This implementation was derived from the todolist plugin implementation 7 * This implementation was derived from the todolist plugin implementation
8 * 8 *
9 */ 9 */
10/*************************************************************************** 10/***************************************************************************
11 * * 11 * *
12 * This program is free software; you can redistribute it and/or modify * 12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by * 13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or * 14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. * 15 * (at your option) any later version. *
16 * * 16 * *
17 ***************************************************************************/ 17 ***************************************************************************/
18 18
19#include "addresspluginwidget.h" 19#include "addresspluginwidget.h"
20 20
21 21
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24#include <opie/ocontact.h> 24#include <opie/ocontact.h>
25 25
26AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name ) 26AddressBookPluginWidget::AddressBookPluginWidget( QWidget *parent, const char* name )
27 : QWidget( parent, name ) { 27 : QWidget( parent, name ) {
28 28
29 addressLabel = 0l; 29 addressLabel = 0l;
30 m_contactdb = 0l; 30 m_contactdb = 0l;
31 layoutTodo = 0l; 31 layoutTodo = 0l;
32 32
33 // Hä ? Nonsense ! (se) 33 // Hä ? Nonsense ! (se)
34 if ( m_contactdb ) { 34 if ( m_contactdb ) {
35 delete m_contactdb; 35 delete m_contactdb;
36 } 36 }
37 37
38 m_contactdb = new OContactAccess("addressplugin"); 38 m_contactdb = new OContactAccess("addressplugin");
39 39
40 connect( m_contactdb, SIGNAL( signalChanged( const OContactAccess * ) ), 40 connect( m_contactdb, SIGNAL( signalChanged(const OContactAccess*) ),
41 this, SLOT( refresh( const OContactAccess * ) ) ); 41 this, SLOT( refresh(const OContactAccess*) ) );
42 42
43 43
44 readConfig(); 44 readConfig();
45 getAddress(); 45 getAddress();
46} 46}
47 47
48AddressBookPluginWidget::~AddressBookPluginWidget() { 48AddressBookPluginWidget::~AddressBookPluginWidget() {
49 delete m_contactdb; 49 delete m_contactdb;
50} 50}
51 51
52void AddressBookPluginWidget::refresh( const OContactAccess* ) 52void AddressBookPluginWidget::refresh( const OContactAccess* )
53{ 53{
54 qWarning(" AddressBookPluginWidget::Database was changed externally ! "); 54 qWarning(" AddressBookPluginWidget::Database was changed externally ! ");
55 m_contactdb->reload(); 55 m_contactdb->reload();
56 getAddress(); 56 getAddress();
57} 57}
58 58
59void AddressBookPluginWidget::reinitialize() { 59void AddressBookPluginWidget::reinitialize() {
60 readConfig(); 60 readConfig();
61 getAddress(); 61 getAddress();
62} 62}
63 63
64void AddressBookPluginWidget::readConfig() { 64void AddressBookPluginWidget::readConfig() {
65 Config cfg( "todayaddressplugin" ); 65 Config cfg( "todayaddressplugin" );
66 cfg.setGroup( "config" ); 66 cfg.setGroup( "config" );
67 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); 67 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 );
68 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); 68 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
69 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 ); 69 m_daysLookAhead = cfg.readNumEntry( "dayslookahead", 14 );
70 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 ); 70 m_urgentDays = cfg.readNumEntry( "urgentdays", 7 );
71 m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() ); 71 m_entryColor = cfg.readEntry("entrycolor", Qt::black.name() );
72 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() ); 72 m_headlineColor = cfg.readEntry( "headlinecolor", Qt::black.name() );
73 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() ); 73 m_urgentColor = cfg.readEntry( "urgentcolor", Qt::red.name() );
74 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true ); 74 m_showBirthdays = cfg.readBoolEntry( "showBirthdays", true );
75 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true ); 75 m_showAnniversaries = cfg.readBoolEntry( "showAnniversaries", true );
76} 76}
77 77
78 78
79/** 79/**
80 * Get the addresss 80 * Get the addresss
81 */ 81 */
82void AddressBookPluginWidget::getAddress() { 82void AddressBookPluginWidget::getAddress() {
83 83
84 if ( ! layoutTodo ){ 84 if ( ! layoutTodo ){
85 layoutTodo = new QVBoxLayout( this ); 85 layoutTodo = new QVBoxLayout( this );
86 } 86 }
87 87
88 if ( ! addressLabel ) { 88 if ( ! addressLabel ) {
89 addressLabel = new OClickableLabel( this ); 89 addressLabel = new OClickableLabel( this );
90 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) ); 90 connect( addressLabel, SIGNAL( clicked() ), this, SLOT( startAddressBook() ) );
91 layoutTodo->addWidget( addressLabel ); 91 layoutTodo->addWidget( addressLabel );
92 } 92 }
93 93
94 QString output; 94 QString output;
95 95
96 // Check whether the database provide the search option.. 96 // Check whether the database provide the search option..
97 if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ 97 if ( !m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
98 // Libopie seems to be old.. 98 // Libopie seems to be old..
99 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" ); 99 output = QObject::tr( "Database does not provide this search query ! Please upgrade libOpie !<br>" );
100 addressLabel->setText( output ); 100 addressLabel->setText( output );
101 return; 101 return;
102 } 102 }
103 103
104 // Define the query for birthdays and start search.. 104 // Define the query for birthdays and start search..
105 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead ); 105 QDate lookAheadDate = QDate::currentDate().addDays( m_daysLookAhead );
106 int ammount = 0; 106 int ammount = 0;
107 if ( m_showBirthdays ){ 107 if ( m_showBirthdays ){
108 qWarning("Searching from now (%s) until %s ! ", 108 qWarning("Searching from now (%s) until %s ! ",
109 QDate::currentDate().toString().latin1(), 109 QDate::currentDate().toString().latin1(),
110 lookAheadDate.toString().latin1() ); 110 lookAheadDate.toString().latin1() );
111 } 111 }
112 112
113 if ( m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){ 113 if ( m_contactdb->hasQuerySettings( OContactAccess::DateDiff ) ){
114 114
115 115
116 OContact querybirthdays; 116 OContact querybirthdays;
117 querybirthdays.setBirthday( lookAheadDate ); 117 querybirthdays.setBirthday( lookAheadDate );
118 118
119 m_list = m_contactdb->queryByExample( querybirthdays, 119 m_list = m_contactdb->queryByExample( querybirthdays,
120 OContactAccess::DateDiff ); 120 OContactAccess::DateDiff );
121 if ( m_list.count() > 0 ){ 121 if ( m_list.count() > 0 ){
122 output = "<font color=" + m_headlineColor + ">" 122 output = "<font color=" + m_headlineColor + ">"
123 + QObject::tr( "Next birthdays in <b> %1 </b> days:" ) 123 + QObject::tr( "Next birthdays in <b> %1 </b> days:" )
124 .arg( m_daysLookAhead ) 124 .arg( m_daysLookAhead )
125 + "</font> <br>"; 125 + "</font> <br>";
126 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 126 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
127 if ( ammount++ < m_maxLinesTask ){ 127 if ( ammount++ < m_maxLinesTask ){
128 // Now we want to calculate how many days 128 // Now we want to calculate how many days
129 //until birthday. We have to set 129 //until birthday. We have to set
130 // the correct year to calculate the day diff... 130 // the correct year to calculate the day diff...
131 QDate destdate = (*m_it).birthday(); 131 QDate destdate = (*m_it).birthday();
132 destdate.setYMD( QDate::currentDate().year(), 132 destdate.setYMD( QDate::currentDate().year(),
133 destdate.month(), destdate.day() ); 133 destdate.month(), destdate.day() );
134 if ( QDate::currentDate().daysTo(destdate) < 0 ) 134 if ( QDate::currentDate().daysTo(destdate) < 0 )
135 destdate.setYMD( QDate::currentDate().year()+1, 135 destdate.setYMD( QDate::currentDate().year()+1,
136 destdate.month(), destdate.day() ); 136 destdate.month(), destdate.day() );
137 137
diff --git a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
index b6707df..0820802 100644
--- a/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
+++ b/core/pim/today/plugins/datebook/datebookpluginwidget.cpp
@@ -6,135 +6,135 @@
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17 17
18#include "datebookpluginwidget.h" 18#include "datebookpluginwidget.h"
19 19
20#include <qpe/config.h> 20#include <qpe/config.h>
21 21
22#include <qtl.h> 22#include <qtl.h>
23 23
24DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name ) 24DatebookPluginWidget::DatebookPluginWidget( QWidget *parent, const char* name )
25 : QWidget(parent, name ) { 25 : QWidget(parent, name ) {
26 26
27 db = 0l; 27 db = 0l;
28 m_layoutDates = 0l; 28 m_layoutDates = 0l;
29 29
30 if ( m_layoutDates ) { 30 if ( m_layoutDates ) {
31 delete m_layoutDates; 31 delete m_layoutDates;
32 } 32 }
33 m_layoutDates = new QVBoxLayout( this ); 33 m_layoutDates = new QVBoxLayout( this );
34 m_layoutDates->setAutoAdd( true ); 34 m_layoutDates->setAutoAdd( true );
35 35
36 m_eventsList.setAutoDelete( true ); 36 m_eventsList.setAutoDelete( true );
37 37
38 readConfig(); 38 readConfig();
39 getDates(); 39 getDates();
40} 40}
41 41
42DatebookPluginWidget::~DatebookPluginWidget() { 42DatebookPluginWidget::~DatebookPluginWidget() {
43 delete db; 43 delete db;
44 delete m_layoutDates; 44 delete m_layoutDates;
45} 45}
46 46
47 47
48void DatebookPluginWidget::readConfig() { 48void DatebookPluginWidget::readConfig() {
49 Config cfg( "todaydatebookplugin" ); 49 Config cfg( "todaydatebookplugin" );
50 cfg.setGroup( "config" ); 50 cfg.setGroup( "config" );
51 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 ); 51 m_max_lines_meet = cfg.readNumEntry( "maxlinesmeet", 5 );
52 m_show_location = cfg.readNumEntry( "showlocation", 1 ); 52 m_show_location = cfg.readNumEntry( "showlocation", 1 );
53 m_show_notes = cfg.readNumEntry( "shownotes", 0 ); 53 m_show_notes = cfg.readNumEntry( "shownotes", 0 );
54 m_onlyLater = cfg.readNumEntry( "onlylater", 1 ); 54 m_onlyLater = cfg.readNumEntry( "onlylater", 1 );
55 m_moreDays = cfg.readNumEntry( "moredays", 0 ); 55 m_moreDays = cfg.readNumEntry( "moredays", 0 );
56 m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 ); 56 m_timeExtraLine = cfg.readNumEntry( "timeextraline", 1 );
57} 57}
58 58
59void DatebookPluginWidget::reinitialize() { 59void DatebookPluginWidget::reinitialize() {
60 readConfig(); 60 readConfig();
61 refresh(); 61 refresh();
62} 62}
63 63
64void DatebookPluginWidget::refresh() { 64void DatebookPluginWidget::refresh() {
65 m_eventsList.clear(); 65 m_eventsList.clear();
66 66
67 if ( m_layoutDates ) { 67 if ( m_layoutDates ) {
68 delete m_layoutDates; 68 delete m_layoutDates;
69 } 69 }
70 m_layoutDates = new QVBoxLayout( this ); 70 m_layoutDates = new QVBoxLayout( this );
71 m_layoutDates->setAutoAdd( true ); 71 m_layoutDates->setAutoAdd( true );
72 72
73 getDates(); 73 getDates();
74} 74}
75 75
76/** 76/**
77 * Get all events that are in the datebook xml file for today 77 * Get all events that are in the datebook xml file for today
78 */ 78 */
79void DatebookPluginWidget::getDates() { 79void DatebookPluginWidget::getDates() {
80 80
81 81
82 if ( db ) { 82 if ( db ) {
83 delete db; 83 delete db;
84 } 84 }
85 db = new DateBookDB; 85 db = new DateBookDB;
86 86
87 QDate date = QDate::currentDate(); 87 QDate date = QDate::currentDate();
88 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) ); 88 QValueList<EffectiveEvent> list = db->getEffectiveEvents( date, date.addDays( m_moreDays ) );
89 qBubbleSort( list ); 89 qBubbleSort( list );
90 int count = 0; 90 int count = 0;
91 91
92 if ( list.count() > 0 ) { 92 if ( list.count() > 0 ) {
93 93
94 for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) { 94 for ( QValueList<EffectiveEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ) {
95 95
96 if ( count < m_max_lines_meet ) { 96 if ( count < m_max_lines_meet ) {
97 if ( !m_onlyLater ) { 97 if ( !m_onlyLater ) {
98 count++; 98 count++;
99 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); 99 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine );
100 m_eventsList.append( l ); 100 m_eventsList.append( l );
101 l->show(); 101 l->show();
102 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); 102 QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) );
103 } else { 103 } else {
104 if ( ( QDateTime::currentDateTime() <= (*it).event().end() ) 104 if ( ( QDateTime::currentDateTime() <= (*it).event().end() )
105 // Show events which span over many days and are not elapsed. 105 // Show events which span over many days and are not elapsed.
106 || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) ) 106 || ( ( (*it).event().start().date() != date ) && ( QDateTime::currentDateTime() <= (*it).event().end() ) )
107 // Show repeated event for today that is not elapsed. 107 // Show repeated event for today that is not elapsed.
108 || ( ( (*it).event().repeatType() != Event::NoRepeat ) 108 || ( ( (*it).event().repeatType() != Event::NoRepeat )
109 && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() ) 109 && ( ( date.dayOfWeek() == (*it).date().dayOfWeek() )
110 && ( QTime::currentTime() < (*it).event().start().time() ) ) ) 110 && ( QTime::currentTime() < (*it).event().start().time() ) ) )
111 // Show repeated event for next days. 111 // Show repeated event for next days.
112 || ( ( (*it).event().repeatType() != Event::NoRepeat ) 112 || ( ( (*it).event().repeatType() != Event::NoRepeat )
113 && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) ) 113 && ( date.dayOfWeek() != (*it).date().dayOfWeek() ) )
114 ) 114 )
115 { 115 {
116 count++; 116 count++;
117 // show only later appointments 117 // show only later appointments
118 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine ); 118 DateBookEvent *l = new DateBookEvent( *it, this, m_show_location, m_show_notes, m_timeExtraLine );
119 m_eventsList.append( l ); 119 m_eventsList.append( l );
120 l->show(); 120 l->show();
121 QObject::connect ( l, SIGNAL( editEvent( const Event & ) ), l, SLOT( editEventSlot( const Event & ) ) ); 121 QObject::connect ( l, SIGNAL( editEvent(const Event&) ), l, SLOT( editEventSlot(const Event&) ) );
122 } 122 }
123 } 123 }
124 } 124 }
125 } 125 }
126 if ( m_onlyLater && count == 0 ) { 126 if ( m_onlyLater && count == 0 ) {
127 QLabel* noMoreEvents = new QLabel( this ); 127 QLabel* noMoreEvents = new QLabel( this );
128 m_eventsList.append( noMoreEvents ); 128 m_eventsList.append( noMoreEvents );
129 noMoreEvents->show(); 129 noMoreEvents->show();
130 noMoreEvents->setText( QObject::tr( "No more appointments today" ) ); 130 noMoreEvents->setText( QObject::tr( "No more appointments today" ) );
131 } 131 }
132 } else { 132 } else {
133 QLabel* noEvents = new QLabel( this ); 133 QLabel* noEvents = new QLabel( this );
134 m_eventsList.append( noEvents ); 134 m_eventsList.append( noEvents );
135 noEvents->show(); 135 noEvents->show();
136 noEvents->setText( QObject::tr( "No appointments today" ) ); 136 noEvents->setText( QObject::tr( "No appointments today" ) );
137 } 137 }
138} 138}
139 139
140 140
diff --git a/core/pim/today/plugins/mail/mailpluginwidget.cpp b/core/pim/today/plugins/mail/mailpluginwidget.cpp
index 4194270..a8e4c41 100644
--- a/core/pim/today/plugins/mail/mailpluginwidget.cpp
+++ b/core/pim/today/plugins/mail/mailpluginwidget.cpp
@@ -1,97 +1,97 @@
1/* 1/*
2 * mailpluginwidget.cpp 2 * mailpluginwidget.cpp
3 * 3 *
4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß 4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16#include "mailpluginwidget.h" 16#include "mailpluginwidget.h"
17 17
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
20 20
21MailPluginWidget::MailPluginWidget( QWidget *parent, const char* name) 21MailPluginWidget::MailPluginWidget( QWidget *parent, const char* name)
22 : QWidget(parent, name ) { 22 : QWidget(parent, name ) {
23 23
24 m_mailLabel = 0l; 24 m_mailLabel = 0l;
25 m_layout = 0l; 25 m_layout = 0l;
26 26
27 if ( m_mailLabel ) { 27 if ( m_mailLabel ) {
28 delete m_mailLabel; 28 delete m_mailLabel;
29 } 29 }
30 m_mailLabel = new OClickableLabel( this ); 30 m_mailLabel = new OClickableLabel( this );
31 connect( m_mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) ); 31 connect( m_mailLabel, SIGNAL( clicked() ), this, SLOT( startMail() ) );
32 32
33 if ( m_layout ) { 33 if ( m_layout ) {
34 delete m_layout; 34 delete m_layout;
35 } 35 }
36 m_layout = new QHBoxLayout( this ); 36 m_layout = new QHBoxLayout( this );
37 m_layout->setAutoAdd( true ); 37 m_layout->setAutoAdd( true );
38 38
39 39
40#if defined(Q_WS_QWS) 40#if defined(Q_WS_QWS)
41#if !defined(QT_NO_COP) 41#if !defined(QT_NO_COP)
42 QCopChannel *qCopChannel = new QCopChannel( "QPE/Pim" , this ); 42 QCopChannel *qCopChannel = new QCopChannel( "QPE/Pim" , this );
43 connect ( qCopChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 43 connect ( qCopChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
44 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 44 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
45#endif 45#endif
46#endif 46#endif
47 47
48 readConfig(); 48 readConfig();
49 getInfo(); 49 getInfo();
50} 50}
51 51
52 52
53void MailPluginWidget::channelReceived( const QCString &msg, const QByteArray & data ) { 53void MailPluginWidget::channelReceived( const QCString &msg, const QByteArray & data ) {
54 QDataStream stream( data, IO_ReadOnly ); 54 QDataStream stream( data, IO_ReadOnly );
55 if ( msg == "outgoingMails(int)" ) { 55 if ( msg == "outgoingMails(int)" ) {
56 stream >> m_outgoing; 56 stream >> m_outgoing;
57 } else if ( msg == "newMails(int)" ) { 57 } else if ( msg == "newMails(int)" ) {
58 stream >> m_newMails; 58 stream >> m_newMails;
59 } 59 }
60 getInfo(); 60 getInfo();
61} 61}
62MailPluginWidget::~MailPluginWidget() { 62MailPluginWidget::~MailPluginWidget() {
63 delete m_mailLabel; 63 delete m_mailLabel;
64 delete m_layout; 64 delete m_layout;
65} 65}
66 66
67 67
68void MailPluginWidget::readConfig() { 68void MailPluginWidget::readConfig() {
69 Config cfg( "todaymailplugin" ); 69 Config cfg( "todaymailplugin" );
70 cfg.setGroup( "config" ); 70 cfg.setGroup( "config" );
71 71
72 Config cfg2( "mail" ); 72 Config cfg2( "mail" );
73 cfg2.setGroup( "Status" ); 73 cfg2.setGroup( "Status" );
74 74
75 m_newMails = cfg2.readNumEntry( "newMails", 0 ); 75 m_newMails = cfg2.readNumEntry( "newMails", 0 );
76 m_outgoing = cfg2.readNumEntry( "outgoing", 0 ); 76 m_outgoing = cfg2.readNumEntry( "outgoing", 0 );
77} 77}
78 78
79 79
80void MailPluginWidget::refresh() { 80void MailPluginWidget::refresh() {
81 getInfo(); 81 getInfo();
82} 82}
83 83
84void MailPluginWidget::getInfo() { 84void MailPluginWidget::getInfo() {
85 85
86 86
87 87
88 m_mailLabel->setText( QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( m_newMails ).arg( m_outgoing ) ); 88 m_mailLabel->setText( QObject::tr( "<b>%1</b> new mail(s), <b>%2</b> outgoing" ).arg( m_newMails ).arg( m_outgoing ) );
89} 89}
90 90
91/** 91/**
92 * launches datebook 92 * launches datebook
93 */ 93 */
94void MailPluginWidget::startMail() { 94void MailPluginWidget::startMail() {
95 QCopEnvelope e("QPE/System", "execute(QString)"); 95 QCopEnvelope e("QPE/System", "execute(QString)");
96 e << QString( "opiemail" ); 96 e << QString( "opiemail" );
97} 97}
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 72cdfd6..812f8b5 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,153 +1,153 @@
1/* 1/*
2 * today.cpp 2 * today.cpp
3 * 3 *
4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß 4 * copyright : (c) 2002,2003,2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#define QTOPIA_INTERNAL_LANGLIST 17#define QTOPIA_INTERNAL_LANGLIST
18 18
19#include "today.h" 19#include "today.h"
20 20
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/contact.h> 25#include <qpe/contact.h>
26 26
27#include <qdir.h> 27#include <qdir.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30 30
31struct TodayPlugin { 31struct TodayPlugin {
32 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} 32 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
33 QLibrary *library; 33 QLibrary *library;
34 QInterfacePtr<TodayPluginInterface> iface; 34 QInterfacePtr<TodayPluginInterface> iface;
35 TodayPluginObject *guiPart; 35 TodayPluginObject *guiPart;
36 QWidget *guiBox; 36 QWidget *guiBox;
37 QString name; 37 QString name;
38 bool active; 38 bool active;
39 bool excludeRefresh; 39 bool excludeRefresh;
40 int pos; 40 int pos;
41}; 41};
42 42
43static QValueList<TodayPlugin> pluginList; 43static QValueList<TodayPlugin> pluginList;
44 44
45static QMap<QString, TodayPlugin> tempList; 45static QMap<QString, TodayPlugin> tempList;
46 46
47Today::Today( QWidget* parent, const char* name, WFlags fl ) 47Today::Today( QWidget* parent, const char* name, WFlags fl )
48 : TodayBase( parent, name, fl ) { 48 : TodayBase( parent, name, fl ) {
49 49
50 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); 50 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
51 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); 51 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
52 52
53#if defined(Q_WS_QWS) 53#if defined(Q_WS_QWS)
54#if !defined(QT_NO_COP) 54#if !defined(QT_NO_COP)
55 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 55 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
56 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 56 connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
57 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 57 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
58#endif 58#endif
59#endif 59#endif
60 60
61 setOwnerField(); 61 setOwnerField();
62 m_refreshTimer = new QTimer( this ); 62 m_refreshTimer = new QTimer( this );
63 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 63 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
64 m_refreshTimer->start( 15000 ); 64 m_refreshTimer->start( 15000 );
65 m_big_box = 0L; 65 m_big_box = 0L;
66 66
67 67
68 layout = new QVBoxLayout( this ); 68 layout = new QVBoxLayout( this );
69 layout->addWidget( Frame ); 69 layout->addWidget( Frame );
70 layout->addWidget( OwnerField ); 70 layout->addWidget( OwnerField );
71 71
72 m_sv = new QScrollView( this ); 72 m_sv = new QScrollView( this );
73 m_sv->setResizePolicy( QScrollView::AutoOneFit ); 73 m_sv->setResizePolicy( QScrollView::AutoOneFit );
74 m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); 74 m_sv->setHScrollBarMode( QScrollView::AlwaysOff );
75 m_sv->setFrameShape( QFrame::NoFrame ); 75 m_sv->setFrameShape( QFrame::NoFrame );
76 76
77 layout->addWidget( m_sv ); 77 layout->addWidget( m_sv );
78 layout->setStretchFactor( m_sv,4 ); 78 layout->setStretchFactor( m_sv,4 );
79 79
80 qApp->processEvents(); 80 qApp->processEvents();
81 loadPlugins(); 81 loadPlugins();
82 QPEApplication::showWidget( this ); 82 QPEApplication::showWidget( this );
83} 83}
84 84
85/** 85/**
86 * Qcop receive method. 86 * Qcop receive method.
87 */ 87 */
88void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 88void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
89 QDataStream stream( data, IO_ReadOnly ); 89 QDataStream stream( data, IO_ReadOnly );
90 if ( msg == "message(QString)" ) { 90 if ( msg == "message(QString)" ) {
91 QString message; 91 QString message;
92 stream >> message; 92 stream >> message;
93 setOwnerField( message ); 93 setOwnerField( message );
94 } 94 }
95} 95}
96 96
97void Today::setRefreshTimer( int interval ) { 97void Today::setRefreshTimer( int interval ) {
98 98
99 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 99 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
100 100
101 // 0 is "never" case 101 // 0 is "never" case
102 if ( !interval == 0 ) { 102 if ( !interval == 0 ) {
103 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 103 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
104 m_refreshTimer->changeInterval( interval ); 104 m_refreshTimer->changeInterval( interval );
105 } 105 }
106} 106}
107 107
108 108
109/** 109/**
110 * Initialises the owner field with the default value, the username 110 * Initialises the owner field with the default value, the username
111 */ 111 */
112void Today::setOwnerField() { 112void Today::setOwnerField() {
113 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 113 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
114 if ( QFile::exists( file ) ) { 114 if ( QFile::exists( file ) ) {
115 Contact cont = Contact::readVCard( file )[0]; 115 Contact cont = Contact::readVCard( file )[0];
116 QString returnString = cont.fullName(); 116 QString returnString = cont.fullName();
117 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 117 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
118 } else { 118 } else {
119 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 119 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
120 } 120 }
121} 121}
122 122
123/** 123/**
124 * Set the owner field with a given QString, for example per qcop. 124 * Set the owner field with a given QString, for example per qcop.
125 */ 125 */
126void Today::setOwnerField( QString &message ) { 126void Today::setOwnerField( QString &message ) {
127 if ( !message.isEmpty() ) { 127 if ( !message.isEmpty() ) {
128 OwnerField->setText( "<b>" + message + "</b>" ); 128 OwnerField->setText( "<b>" + message + "</b>" );
129 } 129 }
130} 130}
131 131
132/** 132/**
133 * Init stuff needed for today. Reads the config file. 133 * Init stuff needed for today. Reads the config file.
134 */ 134 */
135void Today::init() { 135void Today::init() {
136 // read config 136 // read config
137 Config cfg( "today" ); 137 Config cfg( "today" );
138 138
139 cfg.setGroup( "Plugins" ); 139 cfg.setGroup( "Plugins" );
140 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 140 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
141 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 141 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
142 142
143 cfg.setGroup( "General" ); 143 cfg.setGroup( "General" );
144 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 144 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
145 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); 145 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
146 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 146 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
147 147
148 // set the date in top label 148 // set the date in top label
149 QDate date = QDate::currentDate(); 149 QDate date = QDate::currentDate();
150 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); 150 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
151 151
152 if ( m_hideBanner ) { 152 if ( m_hideBanner ) {
153 Opiezilla->hide(); 153 Opiezilla->hide();
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp
index 5c51515..a6f53e1 100644
--- a/core/pim/today/todayconfig.cpp
+++ b/core/pim/today/todayconfig.cpp
@@ -1,184 +1,184 @@
1/* 1/*
2 * todayconfig.cpp 2 * todayconfig.cpp
3 * 3 *
4 * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß 4 * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include "todayconfig.h" 17#include "todayconfig.h"
18 18
19#include <qpe/config.h> 19#include <qpe/config.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qspinbox.h> 26#include <qspinbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qheader.h> 28#include <qheader.h>
29#include <qvbox.h> 29#include <qvbox.h>
30#include <qtoolbutton.h> 30#include <qtoolbutton.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32 32
33class ToolButton : public QToolButton { 33class ToolButton : public QToolButton {
34 34
35public: 35public:
36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 36 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
37 : QToolButton( parent, name ) { 37 : QToolButton( parent, name ) {
38 setPixmap( Resource::loadPixmap( icon ) ); 38 setPixmap( Resource::loadPixmap( icon ) );
39 setAutoRaise( TRUE ); 39 setAutoRaise( TRUE );
40 setFocusPolicy( QWidget::NoFocus ); 40 setFocusPolicy( QWidget::NoFocus );
41 setToggleButton( t ); 41 setToggleButton( t );
42 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 42 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
43 } 43 }
44}; 44};
45 45
46 46
47/** 47/**
48 * The class has currently quite some duplicate code. 48 * The class has currently quite some duplicate code.
49 * By that way it would be real easy to have it as seperate app in settings tab 49 * By that way it would be real easy to have it as seperate app in settings tab
50 * 50 *
51 */ 51 */
52TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) 52TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
53 : QDialog( parent, name, modal, WStyle_ContextHelp ) { 53 : QDialog( parent, name, modal, WStyle_ContextHelp ) {
54 54
55 setCaption( tr( "Today Config" ) ); 55 setCaption( tr( "Today Config" ) );
56 56
57 QVBoxLayout *layout = new QVBoxLayout( this ); 57 QVBoxLayout *layout = new QVBoxLayout( this );
58 TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 58 TabWidget3 = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
59 layout->addWidget( TabWidget3 ); 59 layout->addWidget( TabWidget3 );
60 60
61 tab_2 = new QWidget( TabWidget3, "tab_2" ); 61 tab_2 = new QWidget( TabWidget3, "tab_2" );
62 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 ); 62 QVBoxLayout *tab2Layout = new QVBoxLayout( tab_2, 4 ,4 );
63 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 ); 63 QLabel *l = new QLabel( tr( "Load which plugins in what order:" ), tab_2 );
64 tab2Layout->addWidget( l ); 64 tab2Layout->addWidget( l );
65 QHBox *hbox1 = new QHBox( tab_2 ); 65 QHBox *hbox1 = new QHBox( tab_2 );
66 m_appletListView = new QListView( hbox1 ); 66 m_appletListView = new QListView( hbox1 );
67 m_appletListView->addColumn( "PluginList" ); 67 m_appletListView->addColumn( "PluginList" );
68 m_appletListView->header()->hide(); 68 m_appletListView->header()->hide();
69 m_appletListView->setSorting( -1 ); 69 m_appletListView->setSorting( -1 );
70 QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); 70 QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) );
71 QVBox *vbox1 = new QVBox( hbox1 ); 71 QVBox *vbox1 = new QVBox( hbox1 );
72 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 72 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
73 new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); 73 new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
74 tab2Layout->addWidget( hbox1 ); 74 tab2Layout->addWidget( hbox1 );
75 TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) ); 75 TabWidget3->addTab( tab_2, "pass", tr( "active/order" ) );
76 76
77 // Misc tab 77 // Misc tab
78 tab_3 = new QWidget( TabWidget3, "tab_3" ); 78 tab_3 = new QWidget( TabWidget3, "tab_3" );
79 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); 79 QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 );
80 80
81 m_guiMisc = new TodayConfigMiscBase( tab_3 ); 81 m_guiMisc = new TodayConfigMiscBase( tab_3 );
82 82
83 tab3Layout->addWidget( m_guiMisc ); 83 tab3Layout->addWidget( m_guiMisc );
84 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); 84 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) );
85 85
86 m_applets_changed = false; 86 m_applets_changed = false;
87 87
88 connect ( m_appletListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( appletChanged ( ) ) ); 88 connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) );
89 89
90 readConfig(); 90 readConfig();
91 QPEApplication::showDialog( this ); 91 QPEApplication::showDialog( this );
92} 92}
93 93
94 94
95/** 95/**
96 * Autostart, uses the new (opie only) autostart method in the launcher code. 96 * Autostart, uses the new (opie only) autostart method in the launcher code.
97 * If registered against that today ist started on each resume. 97 * If registered against that today ist started on each resume.
98 */ 98 */
99void TodayConfig::setAutoStart() { 99void TodayConfig::setAutoStart() {
100 Config cfg( "today" ); 100 Config cfg( "today" );
101 cfg.setGroup( "Autostart" ); 101 cfg.setGroup( "Autostart" );
102 if ( m_autoStart ) { 102 if ( m_autoStart ) {
103 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); 103 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" );
104 e << QString( "add" ); 104 e << QString( "add" );
105 e << QString( "today" ); 105 e << QString( "today" );
106 e << QString( "%1" ).arg( m_autoStartTimer ); 106 e << QString( "%1" ).arg( m_autoStartTimer );
107 } else { 107 } else {
108 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" ); 108 QCopEnvelope e( "QPE/System", "autoStart(QString,QString)" );
109 e << QString( "remove" ); 109 e << QString( "remove" );
110 e << QString( "today" ); 110 e << QString( "today" );
111 } 111 }
112} 112}
113 113
114/** 114/**
115 * Read the config part 115 * Read the config part
116 */ 116 */
117void TodayConfig::readConfig() { 117void TodayConfig::readConfig() {
118 Config cfg( "today" ); 118 Config cfg( "today" );
119 cfg.setGroup( "Autostart" ); 119 cfg.setGroup( "Autostart" );
120 m_autoStart = cfg.readNumEntry( "autostart", 1 ); 120 m_autoStart = cfg.readNumEntry( "autostart", 1 );
121 m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); 121 m_guiMisc->CheckBoxAuto->setChecked( m_autoStart );
122 m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 ); 122 m_autoStartTimer = cfg.readNumEntry( "autostartdelay", 0 );
123 m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer ); 123 m_guiMisc->SpinBoxTime->setValue( m_autoStartTimer );
124 124
125 cfg.setGroup( "General" ); 125 cfg.setGroup( "General" );
126 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 126 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
127 m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); 127 m_guiMisc->SpinBoxIconSize->setValue( m_iconSize );
128 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); 128 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 );
129 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); 129 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) );
130 130
131 131
132 cfg.setGroup( "Plugins" ); 132 cfg.setGroup( "Plugins" );
133 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 133 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
134} 134}
135 135
136/** 136/**
137 * Write the config part 137 * Write the config part
138 */ 138 */
139void TodayConfig::writeConfig() { 139void TodayConfig::writeConfig() {
140 Config cfg( "today" ); 140 Config cfg( "today" );
141 cfg.setGroup( "Plugins" ); 141 cfg.setGroup( "Plugins" );
142 if ( m_applets_changed ) { 142 if ( m_applets_changed ) {
143 QStringList exclude; 143 QStringList exclude;
144 QStringList include; 144 QStringList include;
145 QStringList all_applets; 145 QStringList all_applets;
146 146
147 QListViewItemIterator list_it( m_appletListView ); 147 QListViewItemIterator list_it( m_appletListView );
148 148
149 // this makes sure the names get saved in the order selected 149 // this makes sure the names get saved in the order selected
150 for ( ; list_it.current(); ++list_it ) { 150 for ( ; list_it.current(); ++list_it ) {
151 QMap <QString, QCheckListItem *>::Iterator it; 151 QMap <QString, QCheckListItem *>::Iterator it;
152 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { 152 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) {
153 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 153 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
154 exclude << it.key(); 154 exclude << it.key();
155 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 155 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
156 include << it.key(); 156 include << it.key();
157 } 157 }
158 if ( list_it.current() == (*it) ) { 158 if ( list_it.current() == (*it) ) {
159 all_applets << it.key(); 159 all_applets << it.key();
160 } 160 }
161 } 161 }
162 } 162 }
163 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 163 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
164 cfg.writeEntry( "IncludeApplets", include, ',' ); 164 cfg.writeEntry( "IncludeApplets", include, ',' );
165 cfg.writeEntry( "AllApplets", all_applets, ',' ); 165 cfg.writeEntry( "AllApplets", all_applets, ',' );
166 } 166 }
167 167
168 cfg.setGroup( "Autostart" ); 168 cfg.setGroup( "Autostart" );
169 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); 169 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked();
170 cfg.writeEntry( "autostart", m_autoStart ); 170 cfg.writeEntry( "autostart", m_autoStart );
171 m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); 171 m_autoStartTimer = m_guiMisc->SpinBoxTime->value();
172 cfg.writeEntry( "autostartdelay", m_autoStartTimer ); 172 cfg.writeEntry( "autostartdelay", m_autoStartTimer );
173 m_iconSize = m_guiMisc->SpinBoxIconSize->value(); 173 m_iconSize = m_guiMisc->SpinBoxIconSize->value();
174 174
175 cfg.setGroup( "General" ); 175 cfg.setGroup( "General" );
176 cfg.writeEntry( "IconSize", m_iconSize ); 176 cfg.writeEntry( "IconSize", m_iconSize );
177 cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() ); 177 cfg.writeEntry( "HideBanner", m_guiMisc->CheckBoxHide->isChecked() );
178 cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 ); 178 cfg.writeEntry( "checkinterval", m_guiMisc->SpinRefresh->value()*1000 );
179 179
180 // set autostart settings 180 // set autostart settings
181 setAutoStart(); 181 setAutoStart();
182} 182}
183 183
184 184
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index b68aad2..a244e58 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -96,193 +96,193 @@ void MainWindow::initActions() {
96 m_edit->insertItem(QWidget::tr("New from template"), m_template, 96 m_edit->insertItem(QWidget::tr("New from template"), m_template,
97 -1, 0 ); 97 -1, 0 );
98 98
99 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 99 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ),
100 QString::null, 0, this, 0 ); 100 QString::null, 0, this, 0 );
101 connect(a, SIGNAL( activated() ), 101 connect(a, SIGNAL( activated() ),
102 this, SLOT( slotNew() ) ); 102 this, SLOT( slotNew() ) );
103 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 103 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) );
104 a->addTo(m_tool ); 104 a->addTo(m_tool );
105 a->addTo(m_edit ); 105 a->addTo(m_edit );
106 106
107 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), 107 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
108 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
109 connect(a, SIGNAL(activated() ), 109 connect(a, SIGNAL(activated() ),
110 this, SLOT( slotEdit() ) ); 110 this, SLOT( slotEdit() ) );
111 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); 111 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
112 a->addTo( m_tool ); 112 a->addTo( m_tool );
113 a->addTo( m_edit ); 113 a->addTo( m_edit );
114 m_editAction = a; 114 m_editAction = a;
115 115
116 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); 116 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 );
117 connect(a, SIGNAL( activated() ), 117 connect(a, SIGNAL( activated() ),
118 this, SLOT( slotShowDetails() ) ); 118 this, SLOT( slotShowDetails() ) );
119 a->addTo( m_edit ); 119 a->addTo( m_edit );
120 120
121 m_edit->insertSeparator(); 121 m_edit->insertSeparator();
122 122
123 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), 123 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
124 QString::null, 0, this, 0 ); 124 QString::null, 0, this, 0 );
125 connect(a, SIGNAL(activated() ), 125 connect(a, SIGNAL(activated() ),
126 this, SLOT(slotDelete() ) ); 126 this, SLOT(slotDelete() ) );
127 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); 127 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
128 a->addTo( m_tool ); 128 a->addTo( m_tool );
129 a->addTo( m_edit ); 129 a->addTo( m_edit );
130 m_deleteAction = a; 130 m_deleteAction = a;
131 131
132 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); 132 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 );
133 connect(a, SIGNAL( activated() ), 133 connect(a, SIGNAL( activated() ),
134 this, SLOT( slotDeleteAll() ) ); 134 this, SLOT( slotDeleteAll() ) );
135 a->addTo(m_edit ); 135 a->addTo(m_edit );
136 m_deleteAllAction = a; 136 m_deleteAllAction = a;
137 137
138 a = new QAction( QString::null, QWidget::tr("Delete completed"), 138 a = new QAction( QString::null, QWidget::tr("Delete completed"),
139 0, this, 0 ); 139 0, this, 0 );
140 connect(a, SIGNAL( activated() ), 140 connect(a, SIGNAL( activated() ),
141 this, SLOT( slotDeleteCompleted() ) ); 141 this, SLOT( slotDeleteCompleted() ) );
142 a->addTo(m_edit ); 142 a->addTo(m_edit );
143 a->setEnabled( TRUE ); 143 a->setEnabled( TRUE );
144 m_deleteCompleteAction = a; 144 m_deleteCompleteAction = a;
145 145
146 m_edit->insertSeparator(); 146 m_edit->insertSeparator();
147 147
148 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); 148 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
149 connect(a, SIGNAL( activated() ), 149 connect(a, SIGNAL( activated() ),
150 this, SLOT( slotDuplicate() ) ); 150 this, SLOT( slotDuplicate() ) );
151 a->addTo(m_edit ); 151 a->addTo(m_edit );
152 m_duplicateAction = a; 152 m_duplicateAction = a;
153 153
154 m_edit->insertSeparator(); 154 m_edit->insertSeparator();
155 155
156 if ( Ir::supported() ) { 156 if ( Ir::supported() ) {
157 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); 157 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 );
158 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 158 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
159 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); 159 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) );
160 a->addTo( m_edit ); 160 a->addTo( m_edit );
161 a->addTo( m_tool ); 161 a->addTo( m_tool );
162 } 162 }
163 163
164#if 0 164#if 0
165 // Options menu 165 // Options menu
166 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), 166 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ),
167 QString::null, 0, this, 0 ); 167 QString::null, 0, this, 0 );
168 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 168 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
169 a->addTo( m_options ); 169 a->addTo( m_options );
170 m_findAction = a; 170 m_findAction = a;
171 171
172 172
173 m_options->insertSeparator(); 173 m_options->insertSeparator();
174#endif 174#endif
175 175
176 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 176 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
177 0, this, 0, TRUE ); 177 0, this, 0, TRUE );
178 m_completedAction->addTo( m_options ); 178 m_completedAction->addTo( m_options );
179 m_completedAction->setOn( showCompleted() ); 179 m_completedAction->setOn( showCompleted() );
180 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 180 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
181 181
182 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 182 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"),
183 0, this, 0, TRUE ); 183 0, this, 0, TRUE );
184 a->addTo( m_options ); 184 a->addTo( m_options );
185 a->setOn( showOverDue() ); 185 a->setOn( showOverDue() );
186 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 186 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
187 187
188 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 188 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
189 0, this, 0, TRUE ); 189 0, this, 0, TRUE );
190 m_showDeadLineAction->addTo( m_options ); 190 m_showDeadLineAction->addTo( m_options );
191 m_showDeadLineAction->setOn( showDeadline() ); 191 m_showDeadLineAction->setOn( showDeadline() );
192 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); 192 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) );
193 193
194 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 194 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"),
195 0, this, 0, TRUE ); 195 0, this, 0, TRUE );
196 m_showQuickTaskAction->addTo( m_options ); 196 m_showQuickTaskAction->addTo( m_options );
197 m_showQuickTaskAction->setOn( showQuickTask() ); 197 m_showQuickTaskAction->setOn( showQuickTask() );
198 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 198 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
199 199
200 m_options->insertSeparator(); 200 m_options->insertSeparator();
201 201
202 m_bar->insertItem( QWidget::tr("Data") ,m_edit ); 202 m_bar->insertItem( QWidget::tr("Data") ,m_edit );
203 m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); 203 m_bar->insertItem( QWidget::tr("Category"), m_catMenu );
204 m_bar->insertItem( QWidget::tr("Options"), m_options ); 204 m_bar->insertItem( QWidget::tr("Options"), m_options );
205 205
206 m_curQuick = new QuickEditImpl( this, m_quicktask ); 206 m_curQuick = new QuickEditImpl( this, m_quicktask );
207 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); 207 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE );
208 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 208 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
209 209
210} 210}
211/* m_curCat from Config */ 211/* m_curCat from Config */
212void MainWindow::initConfig() { 212void MainWindow::initConfig() {
213 Config config( "todo" ); 213 Config config( "todo" );
214 config.setGroup( "View" ); 214 config.setGroup( "View" );
215 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 215 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
216 m_curCat = config.readEntry( "Category", QString::null ); 216 m_curCat = config.readEntry( "Category", QString::null );
217 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 217 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
218 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 218 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
219 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 219 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
220} 220}
221void MainWindow::initUI() { 221void MainWindow::initUI() {
222 222
223 m_stack = new OWidgetStack(this, "main stack"); 223 m_stack = new OWidgetStack(this, "main stack");
224 224
225 setCentralWidget( m_stack ); 225 setCentralWidget( m_stack );
226 226
227 setToolBarsMovable( FALSE ); 227 setToolBarsMovable( FALSE );
228 228
229 QToolBar *menubarholder = new QToolBar( this ); 229 QToolBar *menubarholder = new QToolBar( this );
230 menubarholder->setHorizontalStretchable( TRUE ); 230 menubarholder->setHorizontalStretchable( TRUE );
231 m_bar = new QMenuBar( menubarholder ); 231 m_bar = new QMenuBar( menubarholder );
232 232
233 m_tool = new QToolBar( this ); 233 m_tool = new QToolBar( this );
234 234
235 /** QPopupMenu */ 235 /** QPopupMenu */
236 m_edit = new QPopupMenu( this ); 236 m_edit = new QPopupMenu( this );
237 m_options = new QPopupMenu( this ); 237 m_options = new QPopupMenu( this );
238 m_catMenu = new QPopupMenu( this ); 238 m_catMenu = new QPopupMenu( this );
239 m_template = new QPopupMenu( this ); 239 m_template = new QPopupMenu( this );
240 240
241 m_catMenu->setCheckable( TRUE ); 241 m_catMenu->setCheckable( TRUE );
242 m_template->setCheckable( TRUE ); 242 m_template->setCheckable( TRUE );
243 243
244 connect(m_catMenu, SIGNAL(activated(int) ), 244 connect(m_catMenu, SIGNAL(activated(int) ),
245 this, SLOT(setCategory(int) ) ); 245 this, SLOT(setCategory(int) ) );
246 connect(m_template, SIGNAL(activated(int) ), 246 connect(m_template, SIGNAL(activated(int) ),
247 this, SLOT(slotNewFromTemplate(int) ) ); 247 this, SLOT(slotNewFromTemplate(int) ) );
248} 248}
249void MainWindow::initViews() { 249void MainWindow::initViews() {
250 250
251 TableView* tableView = new TableView( this, m_stack ); 251 TableView* tableView = new TableView( this, m_stack );
252 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); 252 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) );
253 m_stack->addWidget( tableView, m_counter++ ); 253 m_stack->addWidget( tableView, m_counter++ );
254 m_views.append( tableView ); 254 m_views.append( tableView );
255 m_curView = tableView; 255 m_curView = tableView;
256 connectBase( tableView ); 256 connectBase( tableView );
257 /* add QString type + QString configname to 257 /* add QString type + QString configname to
258 * the View menu 258 * the View menu
259 * and subdirs for multiple views 259 * and subdirs for multiple views
260 */ 260 */
261} 261}
262void MainWindow::initEditor() { 262void MainWindow::initEditor() {
263 m_curEdit = new Editor(); 263 m_curEdit = new Editor();
264} 264}
265void MainWindow::initShow() { 265void MainWindow::initShow() {
266 m_curShow = new TextViewShow(this, this); 266 m_curShow = new TextViewShow(this, this);
267 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 267 m_stack->addWidget( m_curShow->widget() , m_counter++ );
268} 268}
269MainWindow::~MainWindow() { 269MainWindow::~MainWindow() {
270 delete templateManager(); 270 delete templateManager();
271} 271}
272void MainWindow::connectBase( ViewBase* ) { 272void MainWindow::connectBase( ViewBase* ) {
273 // once templates and signals mix we'll use it again 273 // once templates and signals mix we'll use it again
274} 274}
275QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 275QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
276 QPopupMenu* menu = new QPopupMenu(); 276 QPopupMenu* menu = new QPopupMenu();
277 277
278 m_editAction->addTo( menu ); 278 m_editAction->addTo( menu );
279 m_deleteAction->addTo( menu ); 279 m_deleteAction->addTo( menu );
280 m_duplicateAction->addTo( menu ); 280 m_duplicateAction->addTo( menu );
281 281
282 menu->insertSeparator(); 282 menu->insertSeparator();
283 283
284 /* 284 /*
285 * if this event recurs we allow 285 * if this event recurs we allow
286 * to detach it. 286 * to detach it.
287 * remove all 287 * remove all
288 */ 288 */
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index ab1ce94..d1e50f7 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,90 +1,90 @@
1#include <qlayout.h> 1#include <qlayout.h>
2 2
3#include "taskeditoroverview.h" 3#include "taskeditoroverview.h"
4#include "taskeditorstatus.h" 4#include "taskeditorstatus.h"
5#include "taskeditoralarms.h" 5#include "taskeditoralarms.h"
6 6
7#include "otaskeditor.h" 7#include "otaskeditor.h"
8 8
9OTaskEditor::OTaskEditor(int cur) 9OTaskEditor::OTaskEditor(int cur)
10 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 10 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
11 init(); 11 init();
12 init( cur ); 12 init( cur );
13} 13}
14OTaskEditor::OTaskEditor( const OPimTodo& to) 14OTaskEditor::OTaskEditor( const OPimTodo& to)
15 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 15 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
16 init(); 16 init();
17 init( to ); 17 init( to );
18} 18}
19OTaskEditor::~OTaskEditor() { 19OTaskEditor::~OTaskEditor() {
20 20
21} 21}
22void OTaskEditor::init( int cur ) { 22void OTaskEditor::init( int cur ) {
23 OPimTodo to; 23 OPimTodo to;
24 to.setUid( 1 ); // generate a new uid 24 to.setUid( 1 ); // generate a new uid
25 if ( cur != 0 ) 25 if ( cur != 0 )
26 to.setCategories( cur ); 26 to.setCategories( cur );
27 load(to); 27 load(to);
28} 28}
29void OTaskEditor::init( const OPimTodo& to ) { 29void OTaskEditor::init( const OPimTodo& to ) {
30 load( to ); 30 load( to );
31} 31}
32OPimTodo OTaskEditor::todo()const{ 32OPimTodo OTaskEditor::todo()const{
33 qWarning("saving!"); 33 qWarning("saving!");
34 OPimTodo to ( m_todo ); 34 OPimTodo to ( m_todo );
35 m_overView->save( to ); 35 m_overView->save( to );
36 m_stat->save( to ); 36 m_stat->save( to );
37 to.setRecurrence( m_rec->recurrence() ); 37 to.setRecurrence( m_rec->recurrence() );
38 m_alarm->save( to ); 38 m_alarm->save( to );
39 39
40 return to; 40 return to;
41} 41}
42void OTaskEditor::load(const OPimTodo& to) { 42void OTaskEditor::load(const OPimTodo& to) {
43 m_overView->load( to ); 43 m_overView->load( to );
44 m_stat->load( to ); 44 m_stat->load( to );
45 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); 45 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
46 m_alarm->load( to ); 46 m_alarm->load( to );
47 47
48 m_todo = to; 48 m_todo = to;
49} 49}
50void OTaskEditor::init() { 50void OTaskEditor::init() {
51 setCaption(tr("Task Editor") ); 51 setCaption(tr("Task Editor") );
52 52
53 QVBoxLayout* layo = new QVBoxLayout( this ); 53 QVBoxLayout* layo = new QVBoxLayout( this );
54 m_tab = new OTabWidget( this ); 54 m_tab = new OTabWidget( this );
55 layo->addWidget( m_tab ); 55 layo->addWidget( m_tab );
56 56
57 /* 57 /*
58 * Add the Widgets 58 * Add the Widgets
59 */ 59 */
60 m_overView = new TaskEditorOverView( m_tab ); 60 m_overView = new TaskEditorOverView( m_tab );
61 m_tab->addTab( m_overView, "todo/info", tr("Information") ); 61 m_tab->addTab( m_overView, "todo/info", tr("Information") );
62 62
63 m_stat = new TaskEditorStatus( m_tab ); 63 m_stat = new TaskEditorStatus( m_tab );
64 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") ); 64 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") );
65 65
66 m_alarm = new TaskEditorAlarms( m_tab ); 66 m_alarm = new TaskEditorAlarms( m_tab );
67 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") ); 67 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") );
68 68
69// m_remind = new TaskEditorAlarms( m_tab ); 69// m_remind = new TaskEditorAlarms( m_tab );
70// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") ); 70// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") );
71 71
72// QLabel* lbl = new QLabel( m_tab ); 72// QLabel* lbl = new QLabel( m_tab );
73// lbl->setText( tr("X-Ref") ); 73// lbl->setText( tr("X-Ref") );
74// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") ); 74// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") );
75 75
76 m_rec = new OPimRecurrenceWidget( true, QDate::currentDate(), this ); 76 m_rec = new OPimRecurrenceWidget( true, QDate::currentDate(), this );
77 m_tab->addTab( m_rec, "repeat", tr("Recurrence") ); 77 m_tab->addTab( m_rec, "repeat", tr("Recurrence") );
78 78
79 79
80 /* signal and slots */ 80 /* signal and slots */
81 connect(m_overView, SIGNAL(recurranceEnabled(bool) ), 81 connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
82 m_rec, SLOT(setEnabled(bool) ) ); 82 m_rec, SLOT(setEnabled(bool) ) );
83 83
84 /* connect due date changed to the recurrence tab */ 84 /* connect due date changed to the recurrence tab */
85 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ), 85 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ),
86 m_rec, SLOT(setStartDate(const QDate& ) ) ); 86 m_rec, SLOT(setStartDate(const QDate&) ) );
87 87
88 88
89 m_tab->setCurrentTab( m_overView ); 89 m_tab->setCurrentTab( m_overView );
90} 90}
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 5bbf880..0d298f4 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -23,200 +23,200 @@
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#include <stdlib.h> 28#include <stdlib.h>
29#include <cmath> 29#include <cmath>
30#include <cctype> 30#include <cctype>
31 31
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36 36
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <opie2/opimrecurrence.h> 40#include <opie2/opimrecurrence.h>
41 41
42#include "mainwindow.h" 42#include "mainwindow.h"
43//#include "tableitems.h" 43//#include "tableitems.h"
44#include "tableview.h" 44#include "tableview.h"
45 45
46using namespace Todo; 46using namespace Todo;
47 47
48namespace { 48namespace {
49 static const int BoxSize = 14; 49 static const int BoxSize = 14;
50 static const int RowHeight = 20; 50 static const int RowHeight = 20;
51} 51}
52 52
53TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { 53TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) {
54} 54}
55void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { 55void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) {
56 m_wid = wid; 56 m_wid = wid;
57 m_row = row; 57 m_row = row;
58 m_col = col; 58 m_col = col;
59} 59}
60void TableView::EditorWidget::releaseCellWidget() { 60void TableView::EditorWidget::releaseCellWidget() {
61 m_wid = 0; 61 m_wid = 0;
62 m_row = m_col = -1; 62 m_row = m_col = -1;
63} 63}
64QWidget* TableView::EditorWidget::cellWidget()const { 64QWidget* TableView::EditorWidget::cellWidget()const {
65 return m_wid; 65 return m_wid;
66} 66}
67int TableView::EditorWidget::cellRow()const { 67int TableView::EditorWidget::cellRow()const {
68 return m_row; 68 return m_row;
69} 69}
70int TableView::EditorWidget::cellCol()const { 70int TableView::EditorWidget::cellCol()const {
71 return m_col; 71 return m_col;
72} 72}
73 73
74 74
75void TableView::initConfig() { 75void TableView::initConfig() {
76 Config config( "todo" ); 76 Config config( "todo" );
77 config.setGroup( "Options" ); 77 config.setGroup( "Options" );
78 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); 78 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 );
79 for (int i = 0; i < numCols(); i++ ) { 79 for (int i = 0; i < numCols(); i++ ) {
80 int width = config.readNumEntry("Width"+QString::number(i), -1 ); 80 int width = config.readNumEntry("Width"+QString::number(i), -1 );
81 setColumnWidth(i, width == -1 ? columnWidth(i) : width ); 81 setColumnWidth(i, width == -1 ? columnWidth(i) : width );
82 } 82 }
83} 83}
84 84
85TableView::TableView( MainWindow* window, QWidget* wid ) 85TableView::TableView( MainWindow* window, QWidget* wid )
86 : QTable( wid ), TodoView( window ) { 86 : QTable( wid ), TodoView( window ) {
87 87
88 setName("TableView"); 88 setName("TableView");
89 // Load icons 89 // Load icons
90 // TODO - probably should be done globally somewhere else, 90 // TODO - probably should be done globally somewhere else,
91 // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h 91 // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h
92 m_pic_completed = Resource::loadPixmap( "todo/completed" ); 92 m_pic_completed = Resource::loadPixmap( "todo/completed" );
93 QString namestr; 93 QString namestr;
94 for ( unsigned int i = 1; i < 6; i++ ) { 94 for ( unsigned int i = 1; i < 6; i++ ) {
95 namestr = "todo/priority"; 95 namestr = "todo/priority";
96 namestr.append( QString::number( i ) ); 96 namestr.append( QString::number( i ) );
97 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); 97 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr );
98 } 98 }
99 99
100 setUpdatesEnabled( false ); 100 setUpdatesEnabled( false );
101 viewport()->setUpdatesEnabled( false ); 101 viewport()->setUpdatesEnabled( false );
102 m_enablePaint = false; 102 m_enablePaint = false;
103 setNumRows(0); 103 setNumRows(0);
104 setNumCols(4); 104 setNumCols(4);
105 105
106 horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); 106 horizontalHeader()->setLabel( 0, QWidget::tr("C.") );
107 horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); 107 horizontalHeader()->setLabel( 1, QWidget::tr("Priority") );
108 horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) ); 108 horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) );
109 horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); 109 horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") );
110 110
111 setShowDeadline( todoWindow()->showDeadline() ); 111 setShowDeadline( todoWindow()->showDeadline() );
112 112
113 setSorting( TRUE ); 113 setSorting( TRUE );
114 setSelectionMode( NoSelection ); 114 setSelectionMode( NoSelection );
115 115
116 setLeftMargin( 0 ); 116 setLeftMargin( 0 );
117 verticalHeader()->hide(); 117 verticalHeader()->hide();
118 118
119 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 119 connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ),
120 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 120 this, SLOT( slotClicked(int,int,int,const QPoint&) ) );
121 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 121 connect((QTable*)this, SIGNAL( pressed(int,int,int,const QPoint&) ),
122 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 122 this, SLOT( slotPressed(int,int,int,const QPoint&) ) );
123 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 123 connect((QTable*)this, SIGNAL(valueChanged(int,int) ),
124 this, SLOT( slotValueChanged(int, int) ) ); 124 this, SLOT( slotValueChanged(int,int) ) );
125 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 125 connect((QTable*)this, SIGNAL(currentChanged(int,int) ),
126 this, SLOT( slotCurrentChanged(int, int) ) ); 126 this, SLOT( slotCurrentChanged(int,int) ) );
127 127
128 m_menuTimer = new QTimer( this ); 128 m_menuTimer = new QTimer( this );
129 connect( m_menuTimer, SIGNAL(timeout()), 129 connect( m_menuTimer, SIGNAL(timeout()),
130 this, SLOT(slotShowMenu()) ); 130 this, SLOT(slotShowMenu()) );
131 131
132 /* now let's init the config */ 132 /* now let's init the config */
133 initConfig(); 133 initConfig();
134 134
135 135
136 m_enablePaint = true; 136 m_enablePaint = true;
137 setUpdatesEnabled( true ); 137 setUpdatesEnabled( true );
138 viewport()->setUpdatesEnabled( true ); 138 viewport()->setUpdatesEnabled( true );
139 viewport()->update(); 139 viewport()->update();
140 setSortOrder( 0 ); 140 setSortOrder( 0 );
141 setAscending( TRUE ); 141 setAscending( TRUE );
142 m_first = true; 142 m_first = true;
143 143
144 144
145} 145}
146/* a new day has started 146/* a new day has started
147 * update the day 147 * update the day
148 */ 148 */
149void TableView::newDay() { 149void TableView::newDay() {
150 clear(); 150 clear();
151 updateView(); 151 updateView();
152} 152}
153TableView::~TableView() { 153TableView::~TableView() {
154 Config config( "todo" ); 154 Config config( "todo" );
155 config.setGroup( "Options" ); 155 config.setGroup( "Options" );
156 for (int i = 0; i < numCols(); i++ ) 156 for (int i = 0; i < numCols(); i++ )
157 config.writeEntry("Width"+QString::number(i), columnWidth(i) ); 157 config.writeEntry("Width"+QString::number(i), columnWidth(i) );
158} 158}
159void TableView::slotShowMenu() { 159void TableView::slotShowMenu() {
160 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); 160 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
161 menu->exec(QCursor::pos() ); 161 menu->exec(QCursor::pos() );
162 delete menu; 162 delete menu;
163} 163}
164QString TableView::type() const { 164QString TableView::type() const {
165 return QString::fromLatin1( tr("Table View") ); 165 return QString::fromLatin1( tr("Table View") );
166} 166}
167int TableView::current() { 167int TableView::current() {
168 if (numRows() == 0 ) return 0; 168 if (numRows() == 0 ) return 0;
169 int uid = sorted().uidAt(currentRow() ); 169 int uid = sorted().uidAt(currentRow() );
170 170
171 return uid; 171 return uid;
172} 172}
173int TableView::next() { 173int TableView::next() {
174 if ( numRows() == 0 ) return 0; 174 if ( numRows() == 0 ) return 0;
175 if ( currentRow() + 1 >= numRows() ) return 0; 175 if ( currentRow() + 1 >= numRows() ) return 0;
176 setCurrentCell( currentRow() +1, currentColumn() ); 176 setCurrentCell( currentRow() +1, currentColumn() );
177 return sorted().uidAt( currentRow() ); 177 return sorted().uidAt( currentRow() );
178} 178}
179int TableView::prev() { 179int TableView::prev() {
180 if ( numRows() == 0 ) return 0; 180 if ( numRows() == 0 ) return 0;
181 if ( currentRow() - 1 < 0 ) return 0; 181 if ( currentRow() - 1 < 0 ) return 0;
182 setCurrentCell( currentRow() -1, currentColumn() ); 182 setCurrentCell( currentRow() -1, currentColumn() );
183 return sorted().uidAt( currentRow() ); 183 return sorted().uidAt( currentRow() );
184 184
185} 185}
186QString TableView::currentRepresentation() { 186QString TableView::currentRepresentation() {
187 OPimTodo to = sorted()[currentRow()]; 187 OPimTodo to = sorted()[currentRow()];
188 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; 188 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
189} 189}
190/* show overdue */ 190/* show overdue */
191void TableView::showOverDue( bool ) { 191void TableView::showOverDue( bool ) {
192 clear(); 192 clear();
193 updateView(); 193 updateView();
194} 194}
195 195
196void TableView::updateView( ) { 196void TableView::updateView( ) {
197 qWarning("update view"); 197 qWarning("update view");
198 m_row = false; 198 m_row = false;
199 static int id; 199 static int id;
200 id = startTimer(4000 ); 200 id = startTimer(4000 );
201 /* FIXME we want one page to be read! 201 /* FIXME we want one page to be read!
202 * 202 *
203 * Calculate that screensize 203 * Calculate that screensize
204 */ 204 */
205 todoWindow()->setReadAhead( 4 ); 205 todoWindow()->setReadAhead( 4 );
206 sort(); 206 sort();
207 OPimTodoAccess::List::Iterator it, end; 207 OPimTodoAccess::List::Iterator it, end;
208 it = sorted().begin(); 208 it = sorted().begin();
209 end = sorted().end(); 209 end = sorted().end();
210 210
211 qWarning("setTodos"); 211 qWarning("setTodos");
212 QTime time; 212 QTime time;
213 time.start(); 213 time.start();
214 m_enablePaint = false; 214 m_enablePaint = false;
215 setUpdatesEnabled( false ); 215 setUpdatesEnabled( false );
216 viewport()->setUpdatesEnabled( false ); 216 viewport()->setUpdatesEnabled( false );
217 217
218 setNumRows( it.count() ); 218 setNumRows( it.count() );
219 if ( it.count() == 0 ) 219 if ( it.count() == 0 )
220 killTimer(id); 220 killTimer(id);
221 221
222// int elc = time.elapsed(); 222// int elc = time.elapsed();
diff --git a/core/pim/todo/taskeditoralarms.cpp b/core/pim/todo/taskeditoralarms.cpp
index 930c94e..a512fb0 100644
--- a/core/pim/todo/taskeditoralarms.cpp
+++ b/core/pim/todo/taskeditoralarms.cpp
@@ -1,179 +1,179 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "taskeditoralarms.h" 29#include "taskeditoralarms.h"
30 30
31#include <opie2/opimnotifymanager.h> 31#include <opie2/opimnotifymanager.h>
32#include <opie2/otimepicker.h> 32#include <opie2/otimepicker.h>
33 33
34#include <qpe/datebookmonth.h> 34#include <qpe/datebookmonth.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36 36
37#include <qlistview.h> 37#include <qlistview.h>
38#include <qlayout.h> 38#include <qlayout.h>
39 39
40 40
41class AlarmItem : public QListViewItem { 41class AlarmItem : public QListViewItem {
42public: 42public:
43 AlarmItem( QListView*, const OPimAlarm& ); 43 AlarmItem( QListView*, const OPimAlarm& );
44 ~AlarmItem(); 44 ~AlarmItem();
45 45
46 OPimAlarm alarm()const; 46 OPimAlarm alarm()const;
47 void setAlarm( const OPimAlarm& ); 47 void setAlarm( const OPimAlarm& );
48private: 48private:
49 QDateTime m_dt; 49 QDateTime m_dt;
50 int m_type; 50 int m_type;
51}; 51};
52AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt) 52AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt)
53 : QListViewItem(view) { 53 : QListViewItem(view) {
54 setAlarm( dt ); 54 setAlarm( dt );
55} 55}
56void AlarmItem::setAlarm( const OPimAlarm& dt ) { 56void AlarmItem::setAlarm( const OPimAlarm& dt ) {
57 m_dt = dt.dateTime(); 57 m_dt = dt.dateTime();
58 m_type = dt.sound(); 58 m_type = dt.sound();
59 setText( 0, TimeString::dateString( m_dt.date() ) ); 59 setText( 0, TimeString::dateString( m_dt.date() ) );
60 setText( 1, TimeString::timeString( m_dt.time() ) ); 60 setText( 1, TimeString::timeString( m_dt.time() ) );
61 setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") ); 61 setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") );
62} 62}
63AlarmItem::~AlarmItem() { 63AlarmItem::~AlarmItem() {
64} 64}
65OPimAlarm AlarmItem::alarm()const{ 65OPimAlarm AlarmItem::alarm()const{
66 OPimAlarm al( m_type, m_dt ); 66 OPimAlarm al( m_type, m_dt );
67 67
68 return al; 68 return al;
69} 69}
70 70
71TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl ) 71TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl )
72 : QWidget( parent, name, fl ) 72 : QWidget( parent, name, fl )
73{ 73{
74 m_date = m_type = m_time = 0; 74 m_date = m_type = m_time = 0;
75 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 ); 75 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 );
76 76
77 lstAlarms = new QListView( this ); 77 lstAlarms = new QListView( this );
78 lstAlarms->addColumn( tr("Date") ); 78 lstAlarms->addColumn( tr("Date") );
79 lstAlarms->addColumn( tr("Time") ); 79 lstAlarms->addColumn( tr("Time") );
80 lstAlarms->addColumn( tr("Type") ); 80 lstAlarms->addColumn( tr("Type") );
81 81
82 connect( lstAlarms, SIGNAL(clicked ( QListViewItem *, const QPoint &, int ) ), 82 connect( lstAlarms, SIGNAL(clicked(QListViewItem*,const QPoint&,int) ),
83 this, SLOT(inlineEdit(QListViewItem*, const QPoint&, int ) ) ); 83 this, SLOT(inlineEdit(QListViewItem*,const QPoint&,int) ) );
84 84
85 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 ); 85 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 );
86 86
87 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this ); 87 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this );
88 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 88 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
89 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) ); 89 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
90 layout->addWidget( btn, 1, 0 ); 90 layout->addWidget( btn, 1, 0 );
91/* use when we've reminders too */ 91/* use when we've reminders too */
92#if 0 92#if 0
93 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this ); 93 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this );
94 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 94 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
95 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) ); 95 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
96 layout->addWidget( btn, 1, 1 ); 96 layout->addWidget( btn, 1, 1 );
97#endif 97#endif
98 98
99 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); 99 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
100 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 100 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
101 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) ); 101 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) );
102 layout->addWidget( btn, 1, 2 ); 102 layout->addWidget( btn, 1, 2 );
103} 103}
104 104
105TaskEditorAlarms::~TaskEditorAlarms(){ 105TaskEditorAlarms::~TaskEditorAlarms(){
106} 106}
107 107
108void TaskEditorAlarms::slotNew(){ 108void TaskEditorAlarms::slotNew(){
109 (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) ); 109 (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) );
110} 110}
111 111
112void TaskEditorAlarms::slotEdit(){ 112void TaskEditorAlarms::slotEdit(){
113} 113}
114 114
115void TaskEditorAlarms::slotDelete(){ 115void TaskEditorAlarms::slotDelete(){
116 QListViewItem* item = lstAlarms->currentItem(); 116 QListViewItem* item = lstAlarms->currentItem();
117 if (!item) return; 117 if (!item) return;
118 118
119 lstAlarms->takeItem( item ); delete item; 119 lstAlarms->takeItem( item ); delete item;
120 120
121 121
122} 122}
123 123
124void TaskEditorAlarms::load( const OPimTodo& todo) { 124void TaskEditorAlarms::load( const OPimTodo& todo) {
125 lstAlarms->clear(); 125 lstAlarms->clear();
126 if (!todo.hasNotifiers() ) return; 126 if (!todo.hasNotifiers() ) return;
127 127
128 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 128 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
129 129
130 if (als.isEmpty() ) return; 130 if (als.isEmpty() ) return;
131 131
132 OPimNotifyManager::Alarms::Iterator it = als.begin(); 132 OPimNotifyManager::Alarms::Iterator it = als.begin();
133 for ( ; it != als.end(); ++it ) 133 for ( ; it != als.end(); ++it )
134 (void)new AlarmItem( lstAlarms, (*it) ); 134 (void)new AlarmItem( lstAlarms, (*it) );
135 135
136 136
137} 137}
138void TaskEditorAlarms::save( OPimTodo& todo ) { 138void TaskEditorAlarms::save( OPimTodo& todo ) {
139 if (lstAlarms->childCount() <= 0 ) return; 139 if (lstAlarms->childCount() <= 0 ) return;
140 140
141 OPimNotifyManager::Alarms alarms; 141 OPimNotifyManager::Alarms alarms;
142 142
143 for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) { 143 for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) {
144 AlarmItem *alItem = static_cast<AlarmItem*>(item); 144 AlarmItem *alItem = static_cast<AlarmItem*>(item);
145 alarms.append( alItem->alarm() ); 145 alarms.append( alItem->alarm() );
146 } 146 }
147 147
148 OPimNotifyManager& manager = todo.notifiers(); 148 OPimNotifyManager& manager = todo.notifiers();
149 manager.setAlarms( alarms ); 149 manager.setAlarms( alarms );
150} 150}
151void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) { 151void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) {
152 if (!alarm) return; 152 if (!alarm) return;
153 153
154 AlarmItem* item = static_cast<AlarmItem*>(alarm); 154 AlarmItem* item = static_cast<AlarmItem*>(alarm);
155 switch( col ) { 155 switch( col ) {
156 // date 156 // date
157 case 0: 157 case 0:
158 return inlineSetDate( item, p ); 158 return inlineSetDate( item, p );
159 // time 159 // time
160 case 1: 160 case 1:
161 return inlineSetTime( item ); 161 return inlineSetTime( item );
162 // type 162 // type
163 case 2: 163 case 2:
164 return inlineSetType( item, p ); 164 return inlineSetType( item, p );
165 } 165 }
166} 166}
167void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) { 167void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) {
168 QPopupMenu* pop = popup( 0 ); 168 QPopupMenu* pop = popup( 0 );
169 m_dbMonth->setDate( item->alarm().dateTime().date() ); 169 m_dbMonth->setDate( item->alarm().dateTime().date() );
170 pop->exec(p); 170 pop->exec(p);
171 171
172 OPimAlarm al = item->alarm(); 172 OPimAlarm al = item->alarm();
173 QDateTime dt = al.dateTime(); 173 QDateTime dt = al.dateTime();
174 dt.setDate( m_dbMonth->selectedDate() ); 174 dt.setDate( m_dbMonth->selectedDate() );
175 al.setDateTime( dt ); 175 al.setDateTime( dt );
176 item->setAlarm( al ); 176 item->setAlarm( al );
177} 177}
178void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) { 178void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) {
179 int type; 179 int type;
diff --git a/core/pim/todo/taskeditorstatus.cpp b/core/pim/todo/taskeditorstatus.cpp
index 367dd58..16351e0 100644
--- a/core/pim/todo/taskeditorstatus.cpp
+++ b/core/pim/todo/taskeditorstatus.cpp
@@ -7,226 +7,226 @@
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "taskeditorstatus.h" 29#include "taskeditorstatus.h"
30 30
31#include <opie2/opimmaintainer.h> 31#include <opie2/opimmaintainer.h>
32#include <opie2/opimstate.h> 32#include <opie2/opimstate.h>
33 33
34#include <qpe/datebookmonth.h> 34#include <qpe/datebookmonth.h>
35 35
36#include <qcheckbox.h> 36#include <qcheckbox.h>
37#include <qcombobox.h> 37#include <qcombobox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qlayout.h> 39#include <qlayout.h>
40#include <qwhatsthis.h> 40#include <qwhatsthis.h>
41 41
42// FIXME add the hack slots instead of setPopup!!!! 42// FIXME add the hack slots instead of setPopup!!!!
43// drw you shouldn't have removed them 43// drw you shouldn't have removed them
44 44
45TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags fl ) 45TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags fl )
46 : QWidget( parent, name, fl ) 46 : QWidget( parent, name, fl )
47{ 47{
48 QDate curDate = QDate::currentDate(); 48 QDate curDate = QDate::currentDate();
49 m_start = m_comp = m_due = curDate; 49 m_start = m_comp = m_due = curDate;
50 QString curDateStr = TimeString::longDateString( curDate ); 50 QString curDateStr = TimeString::longDateString( curDate );
51 51
52 QVBoxLayout *vb = new QVBoxLayout( this ); 52 QVBoxLayout *vb = new QVBoxLayout( this );
53 53
54 QScrollView *sv = new QScrollView( this ); 54 QScrollView *sv = new QScrollView( this );
55 vb->addWidget( sv ); 55 vb->addWidget( sv );
56 sv->setResizePolicy( QScrollView::AutoOneFit ); 56 sv->setResizePolicy( QScrollView::AutoOneFit );
57 sv->setFrameStyle( QFrame::NoFrame ); 57 sv->setFrameStyle( QFrame::NoFrame );
58 58
59 QWidget *container = new QWidget( sv->viewport() ); 59 QWidget *container = new QWidget( sv->viewport() );
60 sv->addChild( container ); 60 sv->addChild( container );
61 61
62 QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 ); 62 QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 );
63 63
64 // Status 64 // Status
65 QLabel *label = new QLabel( tr( "Status:" ), container ); 65 QLabel *label = new QLabel( tr( "Status:" ), container );
66 layout->addWidget( label, 0, 0 ); 66 layout->addWidget( label, 0, 0 );
67 QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) ); 67 QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) );
68 cmbStatus = new QComboBox( FALSE, container ); 68 cmbStatus = new QComboBox( FALSE, container );
69 cmbStatus->insertItem( tr( "Started" ) ); 69 cmbStatus->insertItem( tr( "Started" ) );
70 cmbStatus->insertItem( tr( "Postponed" ) ); 70 cmbStatus->insertItem( tr( "Postponed" ) );
71 cmbStatus->insertItem( tr( "Finished" ) ); 71 cmbStatus->insertItem( tr( "Finished" ) );
72 cmbStatus->insertItem( tr( "Not started" ) ); 72 cmbStatus->insertItem( tr( "Not started" ) );
73 layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 ); 73 layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 );
74 QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) ); 74 QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) );
75 75
76 // Progress 76 // Progress
77 label = new QLabel( tr( "Progress:" ), container ); 77 label = new QLabel( tr( "Progress:" ), container );
78 layout->addWidget( label, 1, 0 ); 78 layout->addWidget( label, 1, 0 );
79 QWhatsThis::add( label, tr( "Select progress made on this task here." ) ); 79 QWhatsThis::add( label, tr( "Select progress made on this task here." ) );
80 cmbProgress = new QComboBox( FALSE, container ); 80 cmbProgress = new QComboBox( FALSE, container );
81 cmbProgress->insertItem( tr( "0 %" ) ); 81 cmbProgress->insertItem( tr( "0 %" ) );
82 cmbProgress->insertItem( tr( "20 %" ) ); 82 cmbProgress->insertItem( tr( "20 %" ) );
83 cmbProgress->insertItem( tr( "40 %" ) ); 83 cmbProgress->insertItem( tr( "40 %" ) );
84 cmbProgress->insertItem( tr( "60 %" ) ); 84 cmbProgress->insertItem( tr( "60 %" ) );
85 cmbProgress->insertItem( tr( "80 %" ) ); 85 cmbProgress->insertItem( tr( "80 %" ) );
86 cmbProgress->insertItem( tr( "100 %" ) ); 86 cmbProgress->insertItem( tr( "100 %" ) );
87 layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 ); 87 layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 );
88 QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) ); 88 QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) );
89 89
90 // Start date 90 // Start date
91 ckbStart = new QCheckBox( tr( "Start Date:" ), container ); 91 ckbStart = new QCheckBox( tr( "Start Date:" ), container );
92 layout->addWidget( ckbStart, 2, 0 ); 92 layout->addWidget( ckbStart, 2, 0 );
93 QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) ); 93 QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) );
94 connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) ); 94 connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) );
95 btnStart = new QPushButton( curDateStr, container ); 95 btnStart = new QPushButton( curDateStr, container );
96 btnStart->setEnabled( FALSE ); 96 btnStart->setEnabled( FALSE );
97 layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 ); 97 layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 );
98 QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) ); 98 QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) );
99 QPopupMenu *popup = new QPopupMenu( this ); 99 QPopupMenu *popup = new QPopupMenu( this );
100 m_startBook = new DateBookMonth( popup, 0, TRUE ); 100 m_startBook = new DateBookMonth( popup, 0, TRUE );
101 popup->insertItem( m_startBook ); 101 popup->insertItem( m_startBook );
102 btnStart->setPopup( popup ); 102 btnStart->setPopup( popup );
103 connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ), 103 connect( m_startBook, SIGNAL( dateClicked(int,int,int) ),
104 this, SLOT( slotStartChanged( int, int, int ) ) ); 104 this, SLOT( slotStartChanged(int,int,int) ) );
105 105
106 // Due date 106 // Due date
107 ckbDue = new QCheckBox( tr( "Due Date:" ), container ); 107 ckbDue = new QCheckBox( tr( "Due Date:" ), container );
108 layout->addWidget( ckbDue, 3, 0 ); 108 layout->addWidget( ckbDue, 3, 0 );
109 QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) ); 109 QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) );
110 connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) ); 110 connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) );
111 btnDue = new QPushButton( curDateStr, container ); 111 btnDue = new QPushButton( curDateStr, container );
112 btnDue->setEnabled( FALSE ); 112 btnDue->setEnabled( FALSE );
113 layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 ); 113 layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 );
114 QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) ); 114 QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) );
115 popup = new QPopupMenu( this ); 115 popup = new QPopupMenu( this );
116 m_dueBook = new DateBookMonth( popup, 0, TRUE ); 116 m_dueBook = new DateBookMonth( popup, 0, TRUE );
117 popup->insertItem( m_dueBook ); 117 popup->insertItem( m_dueBook );
118 btnDue->setPopup( popup ); 118 btnDue->setPopup( popup );
119 connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ), 119 connect( m_dueBook, SIGNAL( dateClicked(int,int,int) ),
120 this, SLOT( slotDueChanged( int, int, int ) ) ); 120 this, SLOT( slotDueChanged(int,int,int) ) );
121 121
122 // Completed 122 // Completed
123 ckbComp = new QCheckBox( tr( "Completed:" ), container ); 123 ckbComp = new QCheckBox( tr( "Completed:" ), container );
124 layout->addWidget( ckbComp, 4, 0 ); 124 layout->addWidget( ckbComp, 4, 0 );
125 QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) ); 125 QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) );
126 connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) ); 126 connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) );
127 btnComp = new QPushButton( curDateStr, container ); 127 btnComp = new QPushButton( curDateStr, container );
128 btnComp->setEnabled( FALSE ); 128 btnComp->setEnabled( FALSE );
129 layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 ); 129 layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 );
130 QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) ); 130 QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) );
131 popup = new QPopupMenu( this ); 131 popup = new QPopupMenu( this );
132 m_compBook = new DateBookMonth( popup, 0, TRUE ); 132 m_compBook = new DateBookMonth( popup, 0, TRUE );
133 popup->insertItem( m_compBook ); 133 popup->insertItem( m_compBook );
134 btnComp->setPopup( popup ); 134 btnComp->setPopup( popup );
135 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ), 135 connect( m_compBook, SIGNAL( dateClicked(int,int,int) ),
136 this, SLOT( slotCompChanged( int, int, int ) ) ); 136 this, SLOT( slotCompChanged(int,int,int) ) );
137 137
138 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); 138 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding );
139 layout->addItem( spacer, 5, 0 ); 139 layout->addItem( spacer, 5, 0 );
140 140
141 // Maintainer mode 141 // Maintainer mode
142#if 0 142#if 0
143 label = new QLabel( tr( "Maintainer Mode:" ), container ); 143 label = new QLabel( tr( "Maintainer Mode:" ), container );
144 layout->addWidget( label, 6, 0 ); 144 layout->addWidget( label, 6, 0 );
145 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) ); 145 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) );
146 cmbMaintMode = new QComboBox( FALSE, container ); 146 cmbMaintMode = new QComboBox( FALSE, container );
147 cmbMaintMode->insertItem( tr( "Nothing" ) ); 147 cmbMaintMode->insertItem( tr( "Nothing" ) );
148 cmbMaintMode->insertItem( tr( "Responsible" ) ); 148 cmbMaintMode->insertItem( tr( "Responsible" ) );
149 cmbMaintMode->insertItem( tr( "Done By" ) ); 149 cmbMaintMode->insertItem( tr( "Done By" ) );
150 cmbMaintMode->insertItem( tr( "Coordinating" ) ); 150 cmbMaintMode->insertItem( tr( "Coordinating" ) );
151// layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 ); 151// layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 );
152 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) ); 152 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) );
153 153
154 // Maintainer 154 // Maintainer
155 label = new QLabel( tr( "Maintainer:" ), container ); 155 label = new QLabel( tr( "Maintainer:" ), container );
156 layout->addWidget( label, 7, 0 ); 156 layout->addWidget( label, 7, 0 );
157 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) ); 157 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) );
158 txtMaintainer = new QLabel( tr( "test" ), container ); 158 txtMaintainer = new QLabel( tr( "test" ), container );
159 txtMaintainer->setTextFormat( QLabel::RichText ); 159 txtMaintainer->setTextFormat( QLabel::RichText );
160 layout->addWidget( txtMaintainer, 7, 1 ); 160 layout->addWidget( txtMaintainer, 7, 1 );
161 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) ); 161 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) );
162 tbtMaintainer = new QToolButton( container ); 162 tbtMaintainer = new QToolButton( container );
163 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) ); 163 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) );
164// layout->addWidget( tbtMaintainer, 7, 2 ); 164// layout->addWidget( tbtMaintainer, 7, 2 );
165 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) ); 165 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) );
166#endif 166#endif
167} 167}
168 168
169TaskEditorStatus::~TaskEditorStatus() 169TaskEditorStatus::~TaskEditorStatus()
170{ 170{
171} 171}
172 172
173void TaskEditorStatus::load( const OPimTodo &todo ) 173void TaskEditorStatus::load( const OPimTodo &todo )
174{ 174{
175 QDate date = QDate::currentDate(); 175 QDate date = QDate::currentDate();
176 QString str = TimeString::longDateString( date ); 176 QString str = TimeString::longDateString( date );
177 177
178 // Status 178 // Status
179 int state = todo.hasState()? todo.state().state() : OPimState::NotStarted; 179 int state = todo.hasState()? todo.state().state() : OPimState::NotStarted;
180 if ( state == OPimState::Undefined ) 180 if ( state == OPimState::Undefined )
181 state = OPimState::NotStarted; 181 state = OPimState::NotStarted;
182 cmbStatus->setCurrentItem( state ); 182 cmbStatus->setCurrentItem( state );
183 183
184 // Progress 184 // Progress
185 cmbProgress->setCurrentItem( todo.progress() / 20 ); 185 cmbProgress->setCurrentItem( todo.progress() / 20 );
186 186
187 // Start date 187 // Start date
188 ckbStart->setChecked( todo.hasStartDate() ); 188 ckbStart->setChecked( todo.hasStartDate() );
189 btnStart->setEnabled( todo.hasStartDate() ); 189 btnStart->setEnabled( todo.hasStartDate() );
190 if ( todo.hasStartDate() ) 190 if ( todo.hasStartDate() )
191 { 191 {
192 m_start = todo.startDate(); 192 m_start = todo.startDate();
193 btnStart->setText( TimeString::longDateString( m_start ) ); 193 btnStart->setText( TimeString::longDateString( m_start ) );
194 } 194 }
195 else 195 else
196 btnStart->setText( str ); 196 btnStart->setText( str );
197 197
198 // Due date 198 // Due date
199 ckbDue->setChecked( todo.hasDueDate() ); 199 ckbDue->setChecked( todo.hasDueDate() );
200 btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); 200 btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
201 btnDue->setEnabled( todo.hasDueDate() ); 201 btnDue->setEnabled( todo.hasDueDate() );
202 m_due = todo.dueDate(); 202 m_due = todo.dueDate();
203 203
204 // Completed 204 // Completed
205 ckbComp->setChecked( todo.isCompleted() ); 205 ckbComp->setChecked( todo.isCompleted() );
206 btnComp->setEnabled( todo.hasCompletedDate() ); 206 btnComp->setEnabled( todo.hasCompletedDate() );
207 if ( todo.hasCompletedDate() ) 207 if ( todo.hasCompletedDate() )
208 { 208 {
209 m_comp = todo.completedDate(); 209 m_comp = todo.completedDate();
210 btnComp->setText( TimeString::longDateString( m_comp ) ); 210 btnComp->setText( TimeString::longDateString( m_comp ) );
211 } 211 }
212 else 212 else
213 btnComp->setText( str ); 213 btnComp->setText( str );
214 214
215 // Maintainer Mode 215 // Maintainer Mode
216#if 0 216#if 0
217 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing; 217 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing;
218 if ( state == OPimMaintainer::Undefined ) 218 if ( state == OPimMaintainer::Undefined )
219 state = OPimMaintainer::Nothing; 219 state = OPimMaintainer::Nothing;
220 cmbMaintMode->setCurrentItem( state ); 220 cmbMaintMode->setCurrentItem( state );
221#endif 221#endif
222 // Maintainer - not implemented yet 222 // Maintainer - not implemented yet
223} 223}
224 224
225void TaskEditorStatus::save( OPimTodo &todo ) 225void TaskEditorStatus::save( OPimTodo &todo )
226{ 226{
227 QDate inval; 227 QDate inval;
228 228
229 // Status 229 // Status
230 todo.setState( OPimState( cmbStatus->currentItem() ) ); 230 todo.setState( OPimState( cmbStatus->currentItem() ) );
231 231
232 // Progress 232 // Progress