summaryrefslogtreecommitdiff
authorchicken <chicken>2004-03-01 17:39:51 (UTC)
committer chicken <chicken>2004-03-01 17:39:51 (UTC)
commitbdac663be648746b868757a6fc9e6c443e6f51b1 (patch) (unidiff)
tree880ee397824e6e99317d8788856bb8cc781b6fe0
parent5f6f3f7d9356e24ac5284b7ccc10a75451ea94ee (diff)
downloadopie-bdac663be648746b868757a6fc9e6c443e6f51b1.zip
opie-bdac663be648746b868757a6fc9e6c443e6f51b1.tar.gz
opie-bdac663be648746b868757a6fc9e6c443e6f51b1.tar.bz2
fix includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/ablabel.cpp3
-rw-r--r--core/pim/addressbook/abtable.cpp9
-rw-r--r--core/pim/addressbook/addressbook.cpp16
-rw-r--r--core/pim/addressbook/configdlg.cpp1
-rw-r--r--core/pim/addressbook/contacteditor.cpp11
-rw-r--r--core/pim/addressbook/main.cpp1
-rw-r--r--core/pim/addressbook/picker.cpp2
-rw-r--r--core/pim/datebook/datebook.cpp15
-rw-r--r--core/pim/datebook/datebookdayallday.cpp10
-rw-r--r--core/pim/datebook/datebookdayheaderimpl.cpp4
-rw-r--r--core/pim/datebook/datebooksettings.cpp1
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp4
-rw-r--r--core/pim/datebook/datebookweeklst.cpp1
-rw-r--r--core/pim/datebook/dateentryimpl.cpp11
-rw-r--r--core/pim/datebook/main.cpp1
-rw-r--r--core/pim/datebook/noteentryimpl.cpp2
-rw-r--r--core/pim/datebook/repeatentry.cpp4
-rw-r--r--core/pim/osearch/adresssearch.cpp2
-rw-r--r--core/pim/osearch/applnkitem.cpp1
-rw-r--r--core/pim/osearch/applnksearch.cpp1
-rw-r--r--core/pim/osearch/contactitem.cpp1
-rw-r--r--core/pim/osearch/datebooksearch.cpp2
-rw-r--r--core/pim/osearch/doclnkitem.cpp1
-rw-r--r--core/pim/osearch/doclnksearch.cpp1
-rw-r--r--core/pim/osearch/eventitem.cpp2
-rw-r--r--core/pim/osearch/main.cpp1
-rw-r--r--core/pim/osearch/mainwindow.cpp2
-rw-r--r--core/pim/osearch/olistview.cpp1
-rw-r--r--core/pim/osearch/resultitem.cpp1
-rw-r--r--core/pim/osearch/searchgroup.cpp3
-rw-r--r--core/pim/osearch/todoitem.cpp1
-rw-r--r--core/pim/osearch/todosearch.cpp1
-rw-r--r--core/pim/today/today.cpp1
-rw-r--r--core/pim/todo/mainwindow.cpp6
34 files changed, 1 insertions, 123 deletions
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp
index 1914f71..076e2e0 100644
--- a/core/pim/addressbook/ablabel.cpp
+++ b/core/pim/addressbook/ablabel.cpp
@@ -1,147 +1,144 @@
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 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** 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 "ablabel.h" 21#include "ablabel.h"
22 22
23#include <qpe/stringutil.h>
24 23
25#include <qregexp.h>
26#include <qstylesheet.h>
27 24
28AbLabel::AbLabel( QWidget *parent, const char *name ): 25AbLabel::AbLabel( QWidget *parent, const char *name ):
29 QTextView( parent, name ), 26 QTextView( parent, name ),
30 m_empty( false ) 27 m_empty( false )
31{ 28{
32} 29}
33 30
34AbLabel::~AbLabel() 31AbLabel::~AbLabel()
35{ 32{
36} 33}
37 34
38void AbLabel::setContacts( const OContactAccess::List& viewList ) 35void AbLabel::setContacts( const OContactAccess::List& viewList )
39{ 36{
40 m_viewList = viewList; 37 m_viewList = viewList;
41 if (m_viewList.count() != 0){ 38 if (m_viewList.count() != 0){
42 m_empty = false; 39 m_empty = false;
43 m_itCurContact = m_viewList.begin(); 40 m_itCurContact = m_viewList.begin();
44 sync(); 41 sync();
45 }else{ 42 }else{
46 // m_itCurContact.clear(); 43 // m_itCurContact.clear();
47 m_empty = true; 44 m_empty = true;
48 setText( "" ); 45 setText( "" );
49 } 46 }
50} 47}
51 48
52int AbLabel::currentEntry_UID() 49int AbLabel::currentEntry_UID()
53{ 50{
54 OContact contact = currentEntry(); 51 OContact contact = currentEntry();
55 52
56 if ( contact.isEmpty() ) 53 if ( contact.isEmpty() )
57 return 0; 54 return 0;
58 else 55 else
59 return ( contact.uid() ); 56 return ( contact.uid() );
60} 57}
61 58
62OContact AbLabel::currentEntry() 59OContact AbLabel::currentEntry()
63{ 60{
64 if ( ! m_empty ) 61 if ( ! m_empty )
65 return ( *m_itCurContact ); 62 return ( *m_itCurContact );
66 else 63 else
67 return OContact(); 64 return OContact();
68} 65}
69 66
70 67
71bool AbLabel::selectContact( int UID ) 68bool AbLabel::selectContact( int UID )
72{ 69{
73 70
74 for ( int r = 0; r < m_viewList.count(); ++r ) { 71 for ( int r = 0; r < m_viewList.count(); ++r ) {
75 if ( m_viewList.uidAt( r ) == UID ){ 72 if ( m_viewList.uidAt( r ) == UID ){
76 m_itCurContact.setCurrent( r ); 73 m_itCurContact.setCurrent( r );
77 break; 74 break;
78 } 75 }
79 } 76 }
80 77
81 sync(); 78 sync();
82 79
83 return true; 80 return true;
84} 81}
85 82
86 83
87 84
88void AbLabel::sync() 85void AbLabel::sync()
89{ 86{
90 QString text = (*m_itCurContact).toRichText(); 87 QString text = (*m_itCurContact).toRichText();
91 setText( text ); 88 setText( text );
92} 89}
93 90
94void AbLabel::keyPressEvent( QKeyEvent *e ) 91void AbLabel::keyPressEvent( QKeyEvent *e )
95{ 92{
96 93
97 // Commonly handled keys 94 // Commonly handled keys
98 if ( !m_empty ){ 95 if ( !m_empty ){
99 switch( e->key() ) { 96 switch( e->key() ) {
100 case Qt::Key_Left: 97 case Qt::Key_Left:
101 qWarning( "Left.."); 98 qWarning( "Left..");
102 case Qt::Key_Right: 99 case Qt::Key_Right:
103 qWarning( "Right.."); 100 qWarning( "Right..");
104 case Qt::Key_F33: 101 case Qt::Key_F33:
105 qWarning( "OK.."); 102 qWarning( "OK..");
106 emit signalOkPressed(); 103 emit signalOkPressed();
107 break; 104 break;
108 case Qt::Key_Up: 105 case Qt::Key_Up:
109 qWarning( "UP.."); 106 qWarning( "UP..");
110 if ( ( visibleHeight() < contentsHeight() ) && 107 if ( ( visibleHeight() < contentsHeight() ) &&
111 ( verticalScrollBar()->value() > verticalScrollBar()->minValue() ) ) 108 ( verticalScrollBar()->value() > verticalScrollBar()->minValue() ) )
112 scrollBy( 0, -(visibleHeight()-20) ); 109 scrollBy( 0, -(visibleHeight()-20) );
113 else { 110 else {
114 --m_itCurContact; 111 --m_itCurContact;
115 if ( *m_itCurContact != OContact() ) 112 if ( *m_itCurContact != OContact() )
116 sync(); 113 sync();
117 else 114 else
118 m_itCurContact = m_viewList.end(); 115 m_itCurContact = m_viewList.end();
119 } 116 }
120 117
121 break; 118 break;
122 case Qt::Key_Down: 119 case Qt::Key_Down:
123 qWarning( "DOWN.."); 120 qWarning( "DOWN..");
124 // qWarning( "visible: %d, content: %d",visibleHeight(),contentsHeight()); 121 // qWarning( "visible: %d, content: %d",visibleHeight(),contentsHeight());
125 // qWarning( "value: %d; barMaxValue: %d", verticalScrollBar()->value() 122 // qWarning( "value: %d; barMaxValue: %d", verticalScrollBar()->value()
126 // , verticalScrollBar()->maxValue() ); 123 // , verticalScrollBar()->maxValue() );
127 if ( ( visibleHeight() < contentsHeight() ) && 124 if ( ( visibleHeight() < contentsHeight() ) &&
128 ( verticalScrollBar()->value() < verticalScrollBar()->maxValue() ) ) 125 ( verticalScrollBar()->value() < verticalScrollBar()->maxValue() ) )
129 scrollBy( 0, visibleHeight()-20 ); 126 scrollBy( 0, visibleHeight()-20 );
130 else { 127 else {
131 ++m_itCurContact; 128 ++m_itCurContact;
132 if ( *m_itCurContact != OContact() ) 129 if ( *m_itCurContact != OContact() )
133 sync(); 130 sync();
134 else 131 else
135 m_itCurContact = m_viewList.begin(); 132 m_itCurContact = m_viewList.begin();
136 } 133 }
137 break; 134 break;
138 case Qt::Key_Return: // fall through 135 case Qt::Key_Return: // fall through
139 case Qt::Key_Space: // fall through 136 case Qt::Key_Space: // fall through
140 case Qt::Key_Enter: // we want to switch back 137 case Qt::Key_Enter: // we want to switch back
141 emit signalOkPressed(); 138 emit signalOkPressed();
142 break; 139 break;
143 default: break; 140 default: break;
144 } 141 }
145 } 142 }
146 143
147} 144}
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 70330c7..f7bff58 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,848 +1,839 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of Qt Palmtop Environment. 5** This file is part of Qt Palmtop Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22 22
23#include <qpe/categoryselect.h>
24#include <qpe/config.h>
25#include <qpe/stringutil.h>
26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/timestring.h> 23#include <qpe/timestring.h>
28#include <qpe/resource.h> 24#include <qpe/resource.h>
29 25
30#include <opie/orecordlist.h> 26#include <opie/orecordlist.h>
31 27
32#include <qasciidict.h>
33#include <qdatetime.h>
34#include <qfile.h>
35#include <qregexp.h>
36#include <qmessagebox.h>
37 28
38#include "abtable.h" 29#include "abtable.h"
39 30
40#include <errno.h> 31#include <errno.h>
41#include <fcntl.h> 32#include <fcntl.h>
42#include <unistd.h> 33#include <unistd.h>
43#include <stdlib.h> 34#include <stdlib.h>
44 35
45#include <ctype.h> //toupper() for key hack 36#include <ctype.h> //toupper() for key hack
46 37
47#if 0 38#if 0
48 39
49/*! 40/*!
50 \class AbTableItem abtable.h 41 \class AbTableItem abtable.h
51 42
52 \brief QTableItem based class for showing a field of an entry 43 \brief QTableItem based class for showing a field of an entry
53*/ 44*/
54 45
55AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 46AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
56 const QString &secondSortKey) 47 const QString &secondSortKey)
57 : QTableItem( t, et, s ) 48 : QTableItem( t, et, s )
58{ 49{
59 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); 50 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
60 sortKey = Qtopia::buildSortKey( s, secondSortKey ); 51 sortKey = Qtopia::buildSortKey( s, secondSortKey );
61} 52}
62 53
63int AbTableItem::alignment() const 54int AbTableItem::alignment() const
64{ 55{
65 return AlignLeft|AlignVCenter; 56 return AlignLeft|AlignVCenter;
66} 57}
67 58
68QString AbTableItem::key() const 59QString AbTableItem::key() const
69{ 60{
70 return sortKey; 61 return sortKey;
71} 62}
72 63
73// 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...
74void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 65void AbTableItem::setItem( const QString &txt, const QString &secondKey )
75{ 66{
76 setText( txt ); 67 setText( txt );
77 sortKey = Qtopia::buildSortKey( txt, secondKey ); 68 sortKey = Qtopia::buildSortKey( txt, secondKey );
78 69
79 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); 70 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
80} 71}
81 72
82/*! 73/*!
83 \class AbPickItem abtable.h 74 \class AbPickItem abtable.h
84 75
85 \brief QTableItem based class for showing slection of an entry 76 \brief QTableItem based class for showing slection of an entry
86*/ 77*/
87 78
88AbPickItem::AbPickItem( QTable *t ) : 79AbPickItem::AbPickItem( QTable *t ) :
89 QTableItem(t, WhenCurrent, "?") 80 QTableItem(t, WhenCurrent, "?")
90{ 81{
91} 82}
92 83
93QWidget *AbPickItem::createEditor() const 84QWidget *AbPickItem::createEditor() const
94{ 85{
95 QComboBox* combo = new QComboBox( table()->viewport() ); 86 QComboBox* combo = new QComboBox( table()->viewport() );
96 ( (AbPickItem*)this )->cb = combo; 87 ( (AbPickItem*)this )->cb = combo;
97 AbTable* t = static_cast<AbTable*>(table()); 88 AbTable* t = static_cast<AbTable*>(table());
98 QStringList c = t->choiceNames(); 89 QStringList c = t->choiceNames();
99 int cur = 0; 90 int cur = 0;
100 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { 91 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
101 if ( *it == text() ) 92 if ( *it == text() )
102 cur = combo->count(); 93 cur = combo->count();
103 combo->insertItem(*it); 94 combo->insertItem(*it);
104 } 95 }
105 combo->setCurrentItem(cur); 96 combo->setCurrentItem(cur);
106 return combo; 97 return combo;
107} 98}
108 99
109void AbPickItem::setContentFromEditor( QWidget *w ) 100void AbPickItem::setContentFromEditor( QWidget *w )
110{ 101{
111 if ( w->inherits("QComboBox") ) 102 if ( w->inherits("QComboBox") )
112 setText( ( (QComboBox*)w )->currentText() ); 103 setText( ( (QComboBox*)w )->currentText() );
113 else 104 else
114 QTableItem::setContentFromEditor( w ); 105 QTableItem::setContentFromEditor( w );
115} 106}
116 107
117#endif 108#endif
118 109
119/*! 110/*!
120 \class AbTable abtable.h 111 \class AbTable abtable.h
121 112
122 \brief QTable based class for showing a list of entries 113 \brief QTable based class for showing a list of entries
123*/ 114*/
124 115
125AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) 116AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
126 : QTable( parent, name ), 117 : QTable( parent, name ),
127 lastSortCol( -1 ), 118 lastSortCol( -1 ),
128 asc( TRUE ), 119 asc( TRUE ),
129 intFields( order ), 120 intFields( order ),
130 enablePainting( true ), 121 enablePainting( true ),
131 columnVisible( true ), 122 columnVisible( true ),
132 countNested( 0 ) 123 countNested( 0 )
133{ 124{
134 //qWarning("C'tor start"); 125 //qWarning("C'tor start");
135 126
136 setSelectionMode( NoSelection ); 127 setSelectionMode( NoSelection );
137 init(); 128 init();
138 setSorting( TRUE ); 129 setSorting( TRUE );
139 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), 130 connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
140 this, SLOT(itemClicked(int,int)) ); 131 this, SLOT(itemClicked(int,int)) );
141 132
142 // contactList.clear(); 133 // contactList.clear();
143 //qWarning("C'tor end"); 134 //qWarning("C'tor end");
144} 135}
145 136
146AbTable::~AbTable() 137AbTable::~AbTable()
147{ 138{
148} 139}
149 140
150void AbTable::init() 141void AbTable::init()
151{ 142{
152 // :SX showChar = '\0'; 143 // :SX showChar = '\0';
153 setNumRows( 0 ); 144 setNumRows( 0 );
154 setNumCols( 2 ); 145 setNumCols( 2 );
155 146
156 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 147 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
157 horizontalHeader()->setLabel( 1, tr( "Contact" )); 148 horizontalHeader()->setLabel( 1, tr( "Contact" ));
158 setLeftMargin( 0 ); 149 setLeftMargin( 0 );
159 verticalHeader()->hide(); 150 verticalHeader()->hide();
160 columnVisible = true; 151 columnVisible = true;
161} 152}
162 153
163void AbTable::setContacts( const OContactAccess::List& viewList ) 154void AbTable::setContacts( const OContactAccess::List& viewList )
164{ 155{
165 qWarning("AbTable::setContacts()"); 156 qWarning("AbTable::setContacts()");
166 157
167 clear(); 158 clear();
168 m_viewList = viewList; 159 m_viewList = viewList;
169 160
170 setSorting( false ); 161 setSorting( false );
171 setPaintingEnabled( FALSE ); 162 setPaintingEnabled( FALSE );
172 163
173 OContactAccess::List::Iterator it; 164 OContactAccess::List::Iterator it;
174 setNumRows( m_viewList.count() ); 165 setNumRows( m_viewList.count() );
175 //int row = 0; 166 //int row = 0;
176 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 167 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
177 // insertIntoTable( *it, row++ ); 168 // insertIntoTable( *it, row++ );
178 169
179 // setSorting( true ); 170 // setSorting( true );
180 171
181 // resort(); 172 // resort();
182 173
183 updateVisible(); 174 updateVisible();
184 175
185 setPaintingEnabled( TRUE ); 176 setPaintingEnabled( TRUE );
186 177
187} 178}
188 179
189void AbTable::setOrderedList( const QValueList<int> ordered ) 180void AbTable::setOrderedList( const QValueList<int> ordered )
190{ 181{
191 intFields = ordered; 182 intFields = ordered;
192} 183}
193 184
194 185
195bool AbTable::selectContact( int UID ) 186bool AbTable::selectContact( int UID )
196{ 187{
197 qWarning( "AbTable::selectContact( %d )", UID ); 188 qWarning( "AbTable::selectContact( %d )", UID );
198 int rows = numRows(); 189 int rows = numRows();
199 OContact* foundContact = 0l; 190 OContact* foundContact = 0l;
200 bool found = false; 191 bool found = false;
201 192
202 setPaintingEnabled( FALSE ); 193 setPaintingEnabled( FALSE );
203 qWarning( "search start" ); 194 qWarning( "search start" );
204 for ( int r = 0; r < rows; ++r ) { 195 for ( int r = 0; r < rows; ++r ) {
205 if ( m_viewList.uidAt( r ) == UID ){ 196 if ( m_viewList.uidAt( r ) == UID ){
206 ensureCellVisible( r, 0 ); 197 ensureCellVisible( r, 0 );
207 setCurrentCell( r, 0 ); 198 setCurrentCell( r, 0 );
208 found = true; 199 found = true;
209 break; 200 break;
210 } 201 }
211 } 202 }
212 qWarning( "search end" ); 203 qWarning( "search end" );
213 204
214 if ( !found ){ 205 if ( !found ){
215 ensureCellVisible( 0,0 ); 206 ensureCellVisible( 0,0 );
216 setCurrentCell( 0, 0 ); 207 setCurrentCell( 0, 0 );
217 } 208 }
218 209
219 setPaintingEnabled( TRUE ); 210 setPaintingEnabled( TRUE );
220 211
221 return true; 212 return true;
222} 213}
223 214
224#if 0 215#if 0
225void AbTable::insertIntoTable( const OContact& cnt, int row ) 216void AbTable::insertIntoTable( const OContact& cnt, int row )
226{ 217{
227 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); 218 qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
228 QString strName; 219 QString strName;
229 ContactItem contactItem; 220 ContactItem contactItem;
230 221
231 strName = findContactName( cnt ); 222 strName = findContactName( cnt );
232 contactItem = findContactContact( cnt, row ); 223 contactItem = findContactContact( cnt, row );
233 224
234 AbTableItem *ati; 225 AbTableItem *ati;
235 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); 226 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value );
236 contactList.insert( ati, cnt ); 227 contactList.insert( ati, cnt );
237 setItem( row, 0, ati ); 228 setItem( row, 0, ati );
238 ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); 229 ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName);
239 if ( !contactItem.icon.isNull() ) 230 if ( !contactItem.icon.isNull() )
240 ati->setPixmap( contactItem.icon ); 231 ati->setPixmap( contactItem.icon );
241 setItem( row, 1, ati ); 232 setItem( row, 1, ati );
242 233
243 //### cannot do this; table only has two columns at this point 234 //### cannot do this; table only has two columns at this point
244 // setItem( row, 2, new AbPickItem( this ) ); 235 // setItem( row, 2, new AbPickItem( this ) );
245 236
246} 237}
247#endif 238#endif
248 239
249 240
250void AbTable::columnClicked( int col ) 241void AbTable::columnClicked( int col )
251{ 242{
252 if ( !sorting() ) 243 if ( !sorting() )
253 return; 244 return;
254 245
255 if ( lastSortCol == -1 ) 246 if ( lastSortCol == -1 )
256 lastSortCol = col; 247 lastSortCol = col;
257 248
258 if ( col == lastSortCol ) { 249 if ( col == lastSortCol ) {
259 asc = !asc; 250 asc = !asc;
260 } else { 251 } else {
261 lastSortCol = col; 252 lastSortCol = col;
262 asc = TRUE; 253 asc = TRUE;
263 } 254 }
264 //QMessageBox::information( this, "resort", "columnClicked" ); 255 //QMessageBox::information( this, "resort", "columnClicked" );
265 resort(); 256 resort();
266} 257}
267 258
268void AbTable::resort() 259void AbTable::resort()
269{ 260{
270 qWarning( "void AbTable::resort() NOT POSSIBLE !!" ); 261 qWarning( "void AbTable::resort() NOT POSSIBLE !!" );
271#if 0 262#if 0
272 setPaintingEnabled( FALSE ); 263 setPaintingEnabled( FALSE );
273 if ( sorting() ) { 264 if ( sorting() ) {
274 if ( lastSortCol == -1 ) 265 if ( lastSortCol == -1 )
275 lastSortCol = 0; 266 lastSortCol = 0;
276 sortColumn( lastSortCol, asc, TRUE ); 267 sortColumn( lastSortCol, asc, TRUE );
277 //QMessageBox::information( this, "resort", "resort" ); 268 //QMessageBox::information( this, "resort", "resort" );
278 updateVisible(); 269 updateVisible();
279 } 270 }
280 setPaintingEnabled( TRUE ); 271 setPaintingEnabled( TRUE );
281#endif 272#endif
282} 273}
283 274
284OContact AbTable::currentEntry() 275OContact AbTable::currentEntry()
285 { 276 {
286 return m_viewList[currentRow()]; 277 return m_viewList[currentRow()];
287} 278}
288 279
289int AbTable::currentEntry_UID() 280int AbTable::currentEntry_UID()
290{ 281{
291 return ( currentEntry().uid() ); 282 return ( currentEntry().uid() );
292} 283}
293 284
294void AbTable::clear() 285void AbTable::clear()
295{ 286{
296 qWarning( "void AbTable::clear()" ); 287 qWarning( "void AbTable::clear()" );
297 // contactList.clear(); 288 // contactList.clear();
298 289
299 setPaintingEnabled( FALSE ); 290 setPaintingEnabled( FALSE );
300 for ( int r = 0; r < numRows(); ++r ) { 291 for ( int r = 0; r < numRows(); ++r ) {
301 for ( int c = 0; c < numCols(); ++c ) { 292 for ( int c = 0; c < numCols(); ++c ) {
302 if ( cellWidget( r, c ) ) 293 if ( cellWidget( r, c ) )
303 clearCellWidget( r, c ); 294 clearCellWidget( r, c );
304 clearCell( r, c ); 295 clearCell( r, c );
305 } 296 }
306 } 297 }
307 setNumRows( 0 ); 298 setNumRows( 0 );
308 setPaintingEnabled( TRUE ); 299 setPaintingEnabled( TRUE );
309} 300}
310 301
311// Refresh updates column 2 if the contactsettings changed 302// Refresh updates column 2 if the contactsettings changed
312void AbTable::refresh() 303void AbTable::refresh()
313{ 304{
314 qWarning( "void AbTable::refresh() NOT IMPLEMENTED !!" ); 305 qWarning( "void AbTable::refresh() NOT IMPLEMENTED !!" );
315 306
316#if 0 307#if 0
317 int rows = numRows(); 308 int rows = numRows();
318 AbTableItem *abi; 309 AbTableItem *abi;
319 ContactItem contactItem; 310 ContactItem contactItem;
320 311
321 setPaintingEnabled( FALSE ); 312 setPaintingEnabled( FALSE );
322 for ( int r = 0; r < rows; ++r ) { 313 for ( int r = 0; r < rows; ++r ) {
323 abi = static_cast<AbTableItem*>( item(r, 0) ); 314 abi = static_cast<AbTableItem*>( item(r, 0) );
324 contactItem = findContactContact( contactList[abi], r ); 315 contactItem = findContactContact( contactList[abi], r );
325 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); 316 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() );
326 if ( !contactItem.icon.isNull() ){ 317 if ( !contactItem.icon.isNull() ){
327 static_cast<AbTableItem*>( item(r, 1) )-> 318 static_cast<AbTableItem*>( item(r, 1) )->
328 setPixmap( contactItem.icon ); 319 setPixmap( contactItem.icon );
329 }else{ 320 }else{
330 static_cast<AbTableItem*>( item(r, 1) )-> 321 static_cast<AbTableItem*>( item(r, 1) )->
331 setPixmap( QPixmap() ); 322 setPixmap( QPixmap() );
332 } 323 }
333 } 324 }
334 resort(); 325 resort();
335 setPaintingEnabled( TRUE ); 326 setPaintingEnabled( TRUE );
336 327
337#endif 328#endif
338} 329}
339 330
340void AbTable::keyPressEvent( QKeyEvent *e ) 331void AbTable::keyPressEvent( QKeyEvent *e )
341{ 332{
342 char key = toupper( e->ascii() ); 333 char key = toupper( e->ascii() );
343 334
344 if ( key >= 'A' && key <= 'Z' ) 335 if ( key >= 'A' && key <= 'Z' )
345 moveTo( key ); 336 moveTo( key );
346 337
347 //qWarning("Received key .."); 338 //qWarning("Received key ..");
348 switch( e->key() ) { 339 switch( e->key() ) {
349 case Qt::Key_Space: 340 case Qt::Key_Space:
350 case Qt::Key_Return: 341 case Qt::Key_Return:
351 case Qt::Key_Enter: 342 case Qt::Key_Enter:
352 emit signalSwitch(); 343 emit signalSwitch();
353 break; 344 break;
354 // case Qt::Key_Up: 345 // case Qt::Key_Up:
355 // qWarning("a"); 346 // qWarning("a");
356 // emit signalKeyUp(); 347 // emit signalKeyUp();
357 // break; 348 // break;
358 // case Qt::Key_Down: 349 // case Qt::Key_Down:
359 // qWarning("b"); 350 // qWarning("b");
360 // emit signalKeyDown(); 351 // emit signalKeyDown();
361 // break; 352 // break;
362 default: 353 default:
363 QTable::keyPressEvent( e ); 354 QTable::keyPressEvent( e );
364 } 355 }
365 356
366} 357}
367 358
368void AbTable::moveTo( char c ) 359void AbTable::moveTo( char c )
369{ 360{
370 qWarning( "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" ); 361 qWarning( "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" );
371 362
372#if 0 363#if 0
373 int rows = numRows(); 364 int rows = numRows();
374 QString value; 365 QString value;
375 AbTableItem *abi; 366 AbTableItem *abi;
376 int r; 367 int r;
377 if ( asc ) { 368 if ( asc ) {
378 r = 0; 369 r = 0;
379 while ( r < rows-1) { 370 while ( r < rows-1) {
380 abi = static_cast<AbTableItem*>( item(r, 0) ); 371 abi = static_cast<AbTableItem*>( item(r, 0) );
381 QChar first = abi->key()[0]; 372 QChar first = abi->key()[0];
382 //### is there a bug in QChar to char comparison??? 373 //### is there a bug in QChar to char comparison???
383 if ( first.row() || first.cell() >= c ) 374 if ( first.row() || first.cell() >= c )
384 break; 375 break;
385 r++; 376 r++;
386 } 377 }
387 } else { 378 } else {
388 //### should probably disable reverse sorting instead 379 //### should probably disable reverse sorting instead
389 r = rows - 1; 380 r = rows - 1;
390 while ( r > 0 ) { 381 while ( r > 0 ) {
391 abi = static_cast<AbTableItem*>( item(r, 0) ); 382 abi = static_cast<AbTableItem*>( item(r, 0) );
392 QChar first = abi->key()[0]; 383 QChar first = abi->key()[0];
393 //### is there a bug in QChar to char comparison??? 384 //### is there a bug in QChar to char comparison???
394 if ( first.row() || first.cell() >= c ) 385 if ( first.row() || first.cell() >= c )
395 break; 386 break;
396 r--; 387 r--;
397 } 388 }
398 } 389 }
399 setCurrentCell( r, currentColumn() ); 390 setCurrentCell( r, currentColumn() );
400 391
401#endif 392#endif
402} 393}
403 394
404#if 0 395#if 0
405// Useless.. Nobody uses it .. (se) 396// Useless.. Nobody uses it .. (se)
406QString AbTable::findContactName( const OContact &entry ) 397QString AbTable::findContactName( const OContact &entry )
407{ 398{
408 // We use the fileAs, then company, defaultEmail 399 // We use the fileAs, then company, defaultEmail
409 QString str; 400 QString str;
410 str = entry.fileAs(); 401 str = entry.fileAs();
411 if ( str.isEmpty() ) { 402 if ( str.isEmpty() ) {
412 str = entry.company(); 403 str = entry.company();
413 if ( str.isEmpty() ) { 404 if ( str.isEmpty() ) {
414 str = entry.defaultEmail(); 405 str = entry.defaultEmail();
415 } 406 }
416 } 407 }
417 return str; 408 return str;
418} 409}
419#endif 410#endif
420 411
421 412
422void AbTable::resizeRows() { 413void AbTable::resizeRows() {
423 /* 414 /*
424 if (numRows()) { 415 if (numRows()) {
425 for (int i = 0; i < numRows(); i++) { 416 for (int i = 0; i < numRows(); i++) {
426 setRowHeight( i, size ); 417 setRowHeight( i, size );
427 } 418 }
428 } 419 }
429 updateVisible(); 420 updateVisible();
430 */ 421 */
431} 422}
432 423
433 424
434void AbTable::realignTable() 425void AbTable::realignTable()
435{ 426{
436 //qWarning( "void AbTable::realignTable()" ); 427 //qWarning( "void AbTable::realignTable()" );
437 428
438 setPaintingEnabled( FALSE ); 429 setPaintingEnabled( FALSE );
439 430
440 resizeRows(); 431 resizeRows();
441 fitColumns(); 432 fitColumns();
442 433
443 setPaintingEnabled( TRUE ); 434 setPaintingEnabled( TRUE );
444 435
445} 436}
446 437
447 438
448 439
449 440
450#if QT_VERSION <= 230 441#if QT_VERSION <= 230
451#ifndef SINGLE_APP 442#ifndef SINGLE_APP
452void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) 443void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
453{ 444{
454 // Region of the rect we should draw 445 // Region of the rect we should draw
455 QRegion reg( QRect( cx, cy, cw, ch ) ); 446 QRegion reg( QRect( cx, cy, cw, ch ) );
456 // Subtract the table from it 447 // Subtract the table from it
457 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); 448 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
458 // And draw the rectangles (transformed as needed) 449 // And draw the rectangles (transformed as needed)
459 QArray<QRect> r = reg.rects(); 450 QArray<QRect> r = reg.rects();
460 for (unsigned int i=0; i<r.count(); i++) 451 for (unsigned int i=0; i<r.count(); i++)
461 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); 452 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
462} 453}
463#endif 454#endif
464#endif 455#endif
465 456
466 457
467// int AbTable::rowHeight( int ) const 458// int AbTable::rowHeight( int ) const
468// { 459// {
469// return 18; 460// return 18;
470// } 461// }
471 462
472// int AbTable::rowPos( int row ) const 463// int AbTable::rowPos( int row ) const
473// { 464// {
474// return 18*row; 465// return 18*row;
475// } 466// }
476 467
477// int AbTable::rowAt( int pos ) const 468// int AbTable::rowAt( int pos ) const
478// { 469// {
479// return QMIN( pos/18, numRows()-1 ); 470// return QMIN( pos/18, numRows()-1 );
480// } 471// }
481 472
482 473
483 474
484void AbTable::fitColumns() 475void AbTable::fitColumns()
485{ 476{
486 qWarning( "void AbTable::fitColumns()" ); 477 qWarning( "void AbTable::fitColumns()" );
487 int contentsWidth = visibleWidth() / 2; 478 int contentsWidth = visibleWidth() / 2;
488 // Fix to better value 479 // Fix to better value
489 // contentsWidth = 130; 480 // contentsWidth = 130;
490 481
491 setPaintingEnabled( FALSE ); 482 setPaintingEnabled( FALSE );
492 483
493 if ( columnVisible == false ){ 484 if ( columnVisible == false ){
494 showColumn(0); 485 showColumn(0);
495 columnVisible = true; 486 columnVisible = true;
496 } 487 }
497 488
498 //qWarning("Width: %d", contentsWidth); 489 //qWarning("Width: %d", contentsWidth);
499 490
500 setColumnWidth( 0, contentsWidth ); 491 setColumnWidth( 0, contentsWidth );
501 adjustColumn(1); 492 adjustColumn(1);
502 if ( columnWidth(1) < contentsWidth ) 493 if ( columnWidth(1) < contentsWidth )
503 setColumnWidth( 1, contentsWidth ); 494 setColumnWidth( 1, contentsWidth );
504 495
505 setPaintingEnabled( TRUE ); 496 setPaintingEnabled( TRUE );
506} 497}
507 498
508void AbTable::show() 499void AbTable::show()
509{ 500{
510 //qWarning( "void AbTable::show()" ); 501 //qWarning( "void AbTable::show()" );
511 realignTable(); 502 realignTable();
512 QTable::show(); 503 QTable::show();
513} 504}
514 505
515#if 0 506#if 0
516void AbTable::setChoiceNames( const QStringList& list) 507void AbTable::setChoiceNames( const QStringList& list)
517{ 508{
518 choicenames = list; 509 choicenames = list;
519 if ( choicenames.isEmpty() ) { 510 if ( choicenames.isEmpty() ) {
520 // hide pick column 511 // hide pick column
521 setNumCols( 2 ); 512 setNumCols( 2 );
522 } else { 513 } else {
523 // show pick column 514 // show pick column
524 setNumCols( 3 ); 515 setNumCols( 3 );
525 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 516 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
526 horizontalHeader()->setLabel( 2, tr( "Pick" )); 517 horizontalHeader()->setLabel( 2, tr( "Pick" ));
527 } 518 }
528 fitColumns(); 519 fitColumns();
529} 520}
530#endif 521#endif
531 522
532void AbTable::itemClicked(int,int col) 523void AbTable::itemClicked(int,int col)
533{ 524{
534 //qWarning( "AbTable::itemClicked(int, col:%d)", col); 525 //qWarning( "AbTable::itemClicked(int, col:%d)", col);
535 if ( col == 2 ) { 526 if ( col == 2 ) {
536 return; 527 return;
537 } else { 528 } else {
538 // qWarning ("Emitting signalSwitch()"); 529 // qWarning ("Emitting signalSwitch()");
539 emit signalSwitch(); 530 emit signalSwitch();
540 } 531 }
541} 532}
542 533
543#if 0 534#if 0
544QStringList AbTable::choiceNames() const 535QStringList AbTable::choiceNames() const
545{ 536{
546 return choicenames; 537 return choicenames;
547} 538}
548 539
549#endif 540#endif
550void AbTable::setChoiceSelection( const QValueList<int>& list ) 541void AbTable::setChoiceSelection( const QValueList<int>& list )
551{ 542{
552 intFields = list; 543 intFields = list;
553} 544}
554 545
555QStringList AbTable::choiceSelection(int /*index*/) const 546QStringList AbTable::choiceSelection(int /*index*/) const
556{ 547{
557 QStringList r; 548 QStringList r;
558 /* ###### 549 /* ######
559 550
560 QString selname = choicenames.at(index); 551 QString selname = choicenames.at(index);
561 for (each row) { 552 for (each row) {
562 OContact *c = contactForRow(row); 553 OContact *c = contactForRow(row);
563 if ( text(row,2) == selname ) { 554 if ( text(row,2) == selname ) {
564 r.append(c->email); 555 r.append(c->email);
565 } 556 }
566 } 557 }
567 558
568 */ 559 */
569 return r; 560 return r;
570} 561}
571 562
572 563
573void AbTable::updateVisible() 564void AbTable::updateVisible()
574{ 565{
575 //qWarning("void AbTable::updateVisible()"); 566 //qWarning("void AbTable::updateVisible()");
576 567
577 int visible, 568 int visible,
578 totalRows, 569 totalRows,
579 row, 570 row,
580 selectedRow = 0; 571 selectedRow = 0;
581 572
582 visible = 0; 573 visible = 0;
583 574
584 setPaintingEnabled( FALSE ); 575 setPaintingEnabled( FALSE );
585 576
586 realignTable(); 577 realignTable();
587 578
588 totalRows = numRows(); 579 totalRows = numRows();
589 for ( row = 0; row < totalRows; row++ ) { 580 for ( row = 0; row < totalRows; row++ ) {
590 if ( rowHeight(row) == 0 ) { 581 if ( rowHeight(row) == 0 ) {
591 showRow( row ); 582 showRow( row );
592 adjustRow( row ); 583 adjustRow( row );
593 if ( isSelected( row,0 ) || isSelected( row,1 ) ) 584 if ( isSelected( row,0 ) || isSelected( row,1 ) )
594 selectedRow = row; 585 selectedRow = row;
595 } 586 }
596 visible++; 587 visible++;
597 } 588 }
598 589
599 if ( selectedRow ) 590 if ( selectedRow )
600 setCurrentCell( selectedRow, 0 ); 591 setCurrentCell( selectedRow, 0 );
601 592
602 if ( !visible ) 593 if ( !visible )
603 setCurrentCell( -1, 0 ); 594 setCurrentCell( -1, 0 );
604 595
605 setPaintingEnabled( TRUE ); 596 setPaintingEnabled( TRUE );
606} 597}
607 598
608 599
609void AbTable::setPaintingEnabled( bool e ) 600void AbTable::setPaintingEnabled( bool e )
610{ 601{
611 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 602 //qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
612 603
613 if ( e ) { 604 if ( e ) {
614 if ( countNested > 0 ) 605 if ( countNested > 0 )
615 --countNested; 606 --countNested;
616 if ( ! countNested ){ 607 if ( ! countNested ){
617 setUpdatesEnabled( true ); 608 setUpdatesEnabled( true );
618 enablePainting = true; 609 enablePainting = true;
619 rowHeightChanged( 0 ); 610 rowHeightChanged( 0 );
620 viewport()->update(); 611 viewport()->update();
621 } 612 }
622 } else { 613 } else {
623 ++countNested; 614 ++countNested;
624 enablePainting = false; 615 enablePainting = false;
625 setUpdatesEnabled( false ); 616 setUpdatesEnabled( false );
626 } 617 }
627 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); 618 //qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
628} 619}
629 620
630void AbTable::viewportPaintEvent( QPaintEvent* e ) { 621void AbTable::viewportPaintEvent( QPaintEvent* e ) {
631 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); 622 //qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
632 if ( enablePainting ) 623 if ( enablePainting )
633 QTable::viewportPaintEvent( e ); 624 QTable::viewportPaintEvent( e );
634} 625}
635 626
636void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 627void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
637 const QColorGroup &cg = colorGroup(); 628 const QColorGroup &cg = colorGroup();
638 629
639 p->save(); 630 p->save();
640 631
641 //qWarning( "Paint row: %d", row ); 632 //qWarning( "Paint row: %d", row );
642 633
643 OContact act_contact = m_viewList[row]; 634 OContact act_contact = m_viewList[row];
644 635
645 // Paint alternating background bars 636 // Paint alternating background bars
646 if ( (row % 2 ) == 0 ) { 637 if ( (row % 2 ) == 0 ) {
647 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 638 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
648 p->setPen( QPen( cg.text() ) ); 639 p->setPen( QPen( cg.text() ) );
649 } 640 }
650 else { 641 else {
651 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); 642 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
652 p->setPen( QPen( cg.buttonText() ) ); 643 p->setPen( QPen( cg.buttonText() ) );
653 } 644 }
654 645
655 QFont f = p->font(); 646 QFont f = p->font();
656 QFontMetrics fm(f); 647 QFontMetrics fm(f);
657 648
658 int marg = 2; 649 int marg = 2;
659 int x = 0; 650 int x = 0;
660 int y = ( cr.height() - 14 ) / 2; 651 int y = ( cr.height() - 14 ) / 2;
661 652
662 QString nameText = act_contact.fileAs(); 653 QString nameText = act_contact.fileAs();
663 654
664 switch( col ){ 655 switch( col ){
665 case 0: 656 case 0:
666 p->drawText( x + marg,2 + fm.ascent(), nameText ); 657 p->drawText( x + marg,2 + fm.ascent(), nameText );
667 break; 658 break;
668 case 1:{ 659 case 1:{
669 660
670 ContactItem contactItem = findContactContact( act_contact, 0 ); 661 ContactItem contactItem = findContactContact( act_contact, 0 );
671 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ 662 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */
672 QString contactText = contactItem.value; 663 QString contactText = contactItem.value;
673 664
674 if ( !contactPic.isNull() ) 665 if ( !contactPic.isNull() )
675 { 666 {
676 p->drawPixmap( x + marg, y, contactPic ); 667 p->drawPixmap( x + marg, y, contactPic );
677 p->drawText( x + marg + contactPic.width() 668 p->drawText( x + marg + contactPic.width()
678 + 4,2 + fm.ascent(), contactText ); 669 + 4,2 + fm.ascent(), contactText );
679 } 670 }
680 else 671 else
681 { 672 {
682 p->drawText( x + marg,2 + fm.ascent(), contactText ); 673 p->drawText( x + marg,2 + fm.ascent(), contactText );
683 } 674 }
684 } 675 }
685 break; 676 break;
686 677
687 } 678 }
688 p->restore(); 679 p->restore();
689} 680}
690 681
691void AbTable::rowHeightChanged( int row ) 682void AbTable::rowHeightChanged( int row )
692{ 683{
693 if ( enablePainting ) 684 if ( enablePainting )
694 QTable::rowHeightChanged( row ); 685 QTable::rowHeightChanged( row );
695} 686}
696ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ ) 687ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ )
697{ 688{
698 689
699 ContactItem item; 690 ContactItem item;
700 691
701 item.value = ""; 692 item.value = "";
702 693
703 for ( QValueList<int>::ConstIterator it = intFields.begin(); 694 for ( QValueList<int>::ConstIterator it = intFields.begin();
704 it != intFields.end(); ++it ) { 695 it != intFields.end(); ++it ) {
705 switch ( *it ) { 696 switch ( *it ) {
706 default: 697 default:
707 break; 698 break;
708 case Qtopia::Title: 699 case Qtopia::Title:
709 item.value = entry.title(); 700 item.value = entry.title();
710 break; 701 break;
711 case Qtopia::Suffix: 702 case Qtopia::Suffix:
712 item.value = entry.suffix(); 703 item.value = entry.suffix();
713 break; 704 break;
714 case Qtopia::FileAs: 705 case Qtopia::FileAs:
715 item.value = entry.fileAs(); 706 item.value = entry.fileAs();
716 break; 707 break;
717 case Qtopia::DefaultEmail: 708 case Qtopia::DefaultEmail:
718 item.value = entry.defaultEmail(); 709 item.value = entry.defaultEmail();
719 if ( !item.value.isEmpty() ) 710 if ( !item.value.isEmpty() )
720 item.icon = Resource::loadPixmap( "addressbook/email" ); 711 item.icon = Resource::loadPixmap( "addressbook/email" );
721 break; 712 break;
722 case Qtopia::Emails: 713 case Qtopia::Emails:
723 item.value = entry.emails(); 714 item.value = entry.emails();
724 if ( !item.value.isEmpty() ) 715 if ( !item.value.isEmpty() )
725 item.icon = Resource::loadPixmap( "addressbook/email" ); 716 item.icon = Resource::loadPixmap( "addressbook/email" );
726 break; 717 break;
727 case Qtopia::HomeStreet: 718 case Qtopia::HomeStreet:
728 item.value = entry.homeStreet(); 719 item.value = entry.homeStreet();
729 break; 720 break;
730 case Qtopia::HomeCity: 721 case Qtopia::HomeCity:
731 item.value = entry.homeCity(); 722 item.value = entry.homeCity();
732 break; 723 break;
733 case Qtopia::HomeState: 724 case Qtopia::HomeState:
734 item.value = entry.homeState(); 725 item.value = entry.homeState();
735 break; 726 break;
736 case Qtopia::HomeZip: 727 case Qtopia::HomeZip:
737 item.value = entry.homeZip(); 728 item.value = entry.homeZip();
738 break; 729 break;
739 case Qtopia::HomeCountry: 730 case Qtopia::HomeCountry:
740 item.value = entry.homeCountry(); 731 item.value = entry.homeCountry();
741 break; 732 break;
742 case Qtopia::HomePhone: 733 case Qtopia::HomePhone:
743 item.value = entry.homePhone(); 734 item.value = entry.homePhone();
744 if ( !item.value.isEmpty() ) 735 if ( !item.value.isEmpty() )
745 item.icon = Resource::loadPixmap( "addressbook/phonehome" ); 736 item.icon = Resource::loadPixmap( "addressbook/phonehome" );
746 break; 737 break;
747 case Qtopia::HomeFax: 738 case Qtopia::HomeFax:
748 item.value = entry.homeFax(); 739 item.value = entry.homeFax();
749 if ( !item.value.isEmpty() ) 740 if ( !item.value.isEmpty() )
750 item.icon = Resource::loadPixmap( "addressbook/faxhome" ); 741 item.icon = Resource::loadPixmap( "addressbook/faxhome" );
751 break; 742 break;
752 case Qtopia::HomeMobile: 743 case Qtopia::HomeMobile:
753 item.value = entry.homeMobile(); 744 item.value = entry.homeMobile();
754 if ( !item.value.isEmpty() ) 745 if ( !item.value.isEmpty() )
755 item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); 746 item.icon = Resource::loadPixmap( "addressbook/mobilehome" );
756 break; 747 break;
757 case Qtopia::HomeWebPage: 748 case Qtopia::HomeWebPage:
758 item.value = entry.homeWebpage(); 749 item.value = entry.homeWebpage();
759 if ( !item.value.isEmpty() ) 750 if ( !item.value.isEmpty() )
760 item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); 751 item.icon = Resource::loadPixmap( "addressbook/webpagehome" );
761 break; 752 break;
762 case Qtopia::Company: 753 case Qtopia::Company:
763 item.value = entry.company(); 754 item.value = entry.company();
764 break; 755 break;
765 case Qtopia::BusinessCity: 756 case Qtopia::BusinessCity:
766 item.value = entry.businessCity(); 757 item.value = entry.businessCity();
767 break; 758 break;
768 case Qtopia::BusinessStreet: 759 case Qtopia::BusinessStreet:
769 item.value = entry.businessStreet(); 760 item.value = entry.businessStreet();
770 break; 761 break;
771 case Qtopia::BusinessZip: 762 case Qtopia::BusinessZip:
772 item.value = entry.businessZip(); 763 item.value = entry.businessZip();
773 break; 764 break;
774 case Qtopia::BusinessCountry: 765 case Qtopia::BusinessCountry:
775 item.value = entry.businessCountry(); 766 item.value = entry.businessCountry();
776 break; 767 break;
777 case Qtopia::BusinessWebPage: 768 case Qtopia::BusinessWebPage:
778 item.value = entry.businessWebpage(); 769 item.value = entry.businessWebpage();
779 if ( !item.value.isEmpty() ) 770 if ( !item.value.isEmpty() )
780 item.icon = Resource::loadPixmap( "addressbook/webpagework" ); 771 item.icon = Resource::loadPixmap( "addressbook/webpagework" );
781 break; 772 break;
782 case Qtopia::JobTitle: 773 case Qtopia::JobTitle:
783 item.value = entry.jobTitle(); 774 item.value = entry.jobTitle();
784 break; 775 break;
785 case Qtopia::Department: 776 case Qtopia::Department:
786 item.value = entry.department(); 777 item.value = entry.department();
787 break; 778 break;
788 case Qtopia::Office: 779 case Qtopia::Office:
789 item.value = entry.office(); 780 item.value = entry.office();
790 break; 781 break;
791 case Qtopia::BusinessPhone: 782 case Qtopia::BusinessPhone:
792 item.value = entry.businessPhone(); 783 item.value = entry.businessPhone();
793 if ( !item.value.isEmpty() ) 784 if ( !item.value.isEmpty() )
794 item.icon = Resource::loadPixmap( "addressbook/phonework" ); 785 item.icon = Resource::loadPixmap( "addressbook/phonework" );
795 break; 786 break;
796 case Qtopia::BusinessFax: 787 case Qtopia::BusinessFax:
797 item.value = entry.businessFax(); 788 item.value = entry.businessFax();
798 if ( !item.value.isEmpty() ) 789 if ( !item.value.isEmpty() )
799 item.icon = Resource::loadPixmap( "addressbook/faxwork" ); 790 item.icon = Resource::loadPixmap( "addressbook/faxwork" );
800 break; 791 break;
801 case Qtopia::BusinessMobile: 792 case Qtopia::BusinessMobile:
802 item.value = entry.businessMobile(); 793 item.value = entry.businessMobile();
803 if ( !item.value.isEmpty() ) 794 if ( !item.value.isEmpty() )
804 item.icon = Resource::loadPixmap( "addressbook/mobilework" ); 795 item.icon = Resource::loadPixmap( "addressbook/mobilework" );
805 break; 796 break;
806 case Qtopia::BusinessPager: 797 case Qtopia::BusinessPager:
807 item.value = entry.businessPager(); 798 item.value = entry.businessPager();
808 break; 799 break;
809 case Qtopia::Profession: 800 case Qtopia::Profession:
810 item.value = entry.profession(); 801 item.value = entry.profession();
811 break; 802 break;
812 case Qtopia::Assistant: 803 case Qtopia::Assistant:
813 item.value = entry.assistant(); 804 item.value = entry.assistant();
814 break; 805 break;
815 case Qtopia::Manager: 806 case Qtopia::Manager:
816 item.value = entry.manager(); 807 item.value = entry.manager();
817 break; 808 break;
818 case Qtopia::Spouse: 809 case Qtopia::Spouse:
819 item.value = entry.spouse(); 810 item.value = entry.spouse();
820 break; 811 break;
821 case Qtopia::Gender: 812 case Qtopia::Gender:
822 item.value = entry.gender(); 813 item.value = entry.gender();
823 break; 814 break;
824 case Qtopia::Birthday: 815 case Qtopia::Birthday:
825 if ( ! entry.birthday().isNull() ){ 816 if ( ! entry.birthday().isNull() ){
826 item.value = TimeString::numberDateString( entry.birthday() ); 817 item.value = TimeString::numberDateString( entry.birthday() );
827 } 818 }
828 break; 819 break;
829 case Qtopia::Anniversary: 820 case Qtopia::Anniversary:
830 if ( ! entry.anniversary().isNull() ){ 821 if ( ! entry.anniversary().isNull() ){
831 item.value = TimeString::numberDateString( entry.anniversary() ); 822 item.value = TimeString::numberDateString( entry.anniversary() );
832 } 823 }
833 break; 824 break;
834 case Qtopia::Nickname: 825 case Qtopia::Nickname:
835 item.value = entry.nickname(); 826 item.value = entry.nickname();
836 break; 827 break;
837 case Qtopia::Children: 828 case Qtopia::Children:
838 item.value = entry.children(); 829 item.value = entry.children();
839 break; 830 break;
840 case Qtopia::Notes: 831 case Qtopia::Notes:
841 item.value = entry.notes(); 832 item.value = entry.notes();
842 break; 833 break;
843 } 834 }
844 if ( !item.value.isEmpty() ) 835 if ( !item.value.isEmpty() )
845 break; 836 break;
846 } 837 }
847 return item; 838 return item;
848} 839}
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 1c7ddd4..9cf55b3 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,1057 +1,1041 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of the Open Palmtop Environment (see www.opie.info). 5** This file is part of the Open Palmtop Environment (see www.opie.info).
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#define QTOPIA_INTERNAL_FD 20#define QTOPIA_INTERNAL_FD
21 21
22#include "contacteditor.h"
23#include "ablabel.h"
24#include "abview.h"
25#include "abtable.h"
26// #include "addresssettings.h" 22// #include "addresssettings.h"
27#include "addressbook.h" 23#include "addressbook.h"
28 24
29 25
30#include <opie/ofileselector.h> 26#include <opie/ofileselector.h>
31#include <opie/ofiledialog.h> 27#include <opie/ofiledialog.h>
32#include <opie/ocontact.h> 28#include <opie/ocontact.h>
33#include <opie/ocontactaccessbackend_vcard.h> 29#include <opie/ocontactaccessbackend_vcard.h>
34 30
35#include <qpe/resource.h> 31#include <qpe/resource.h>
36#include <qpe/ir.h> 32#include <qpe/ir.h>
37#include <qpe/qpemessagebox.h> 33#include <qpe/qpemessagebox.h>
38#include <qpe/qcopenvelope_qws.h>
39#include <qtoolbar.h>
40#include <qmenubar.h> 34#include <qmenubar.h>
41// #include <qtoolbar.h> 35// #include <qtoolbar.h>
42// #include <qmenubar.h> 36// #include <qmenubar.h>
43#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
44#include <qpe/config.h>
45 38
46#include <qaction.h> 39#include <qaction.h>
47#include <qdialog.h>
48#include <qdir.h>
49#include <qfile.h>
50#include <qimage.h>
51#include <qlayout.h> 40#include <qlayout.h>
52#include <qmessagebox.h> 41#include <qmessagebox.h>
53#include <qpixmap.h>
54#include <qpopupmenu.h>
55#include <qstringlist.h>
56#include <qtoolbutton.h> 42#include <qtoolbutton.h>
57#include <qwhatsthis.h>
58#include <qdatetime.h>
59 43
60#include <stdlib.h> 44#include <stdlib.h>
61#include <sys/stat.h> 45#include <sys/stat.h>
62#include <sys/types.h> 46#include <sys/types.h>
63#include <fcntl.h> 47#include <fcntl.h>
64#include <unistd.h> 48#include <unistd.h>
65 49
66 50
67#include "picker.h" 51#include "picker.h"
68#include "configdlg.h" 52#include "configdlg.h"
69 53
70extern QString addressbookPersonalVCardName(); 54extern QString addressbookPersonalVCardName();
71 55
72AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 56AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
73 WFlags f ) 57 WFlags f )
74 : QMainWindow( parent, name, f ), 58 : QMainWindow( parent, name, f ),
75 catMenu (0l), 59 catMenu (0l),
76 abEditor(0l), 60 abEditor(0l),
77 syncing(FALSE), 61 syncing(FALSE),
78 m_tableViewButton(0l), 62 m_tableViewButton(0l),
79 m_cardViewButton(0l) 63 m_cardViewButton(0l)
80{ 64{
81 isLoading = true; 65 isLoading = true;
82 66
83 m_config.load(); 67 m_config.load();
84 68
85 setCaption( tr("Contacts") ); 69 setCaption( tr("Contacts") );
86 setIcon( Resource::loadPixmap( "AddressBook" ) ); 70 setIcon( Resource::loadPixmap( "AddressBook" ) );
87 71
88 // Settings for Main Menu 72 // Settings for Main Menu
89 // setToolBarsMovable( false ); 73 // setToolBarsMovable( false );
90 setToolBarsMovable( !m_config.fixedBars() ); 74 setToolBarsMovable( !m_config.fixedBars() );
91 setRightJustification( true ); 75 setRightJustification( true );
92 76
93 QToolBar *bar = new QToolBar( this ); 77 QToolBar *bar = new QToolBar( this );
94 bar->setHorizontalStretchable( TRUE ); 78 bar->setHorizontalStretchable( TRUE );
95 79
96 QMenuBar *mbList = new QMenuBar( bar ); 80 QMenuBar *mbList = new QMenuBar( bar );
97 mbList->setMargin( 0 ); 81 mbList->setMargin( 0 );
98 82
99 QPopupMenu *edit = new QPopupMenu( mbList ); 83 QPopupMenu *edit = new QPopupMenu( mbList );
100 mbList->insertItem( tr( "Contact" ), edit ); 84 mbList->insertItem( tr( "Contact" ), edit );
101 85
102 // Category Menu 86 // Category Menu
103 catMenu = new QPopupMenu( this ); 87 catMenu = new QPopupMenu( this );
104 catMenu->setCheckable( TRUE ); 88 catMenu->setCheckable( TRUE );
105 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 89 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
106 mbList->insertItem( tr("View"), catMenu ); 90 mbList->insertItem( tr("View"), catMenu );
107 91
108 // Create Toolbar 92 // Create Toolbar
109 listTools = new QToolBar( this, "list operations" ); 93 listTools = new QToolBar( this, "list operations" );
110 listTools->setHorizontalStretchable( true ); 94 listTools->setHorizontalStretchable( true );
111 addToolBar( listTools ); 95 addToolBar( listTools );
112 moveToolBar( listTools, m_config.getToolBarPos() ); 96 moveToolBar( listTools, m_config.getToolBarPos() );
113 97
114 // View Icons 98 // View Icons
115 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), 99 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ),
116 QString::null, 0, this, 0 ); 100 QString::null, 0, this, 0 );
117 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); 101 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
118 m_tableViewButton->setToggleAction( true ); 102 m_tableViewButton->setToggleAction( true );
119 m_tableViewButton->addTo( listTools ); 103 m_tableViewButton->addTo( listTools );
120 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 );
121 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); 105 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
122 m_cardViewButton->setToggleAction( true ); 106 m_cardViewButton->setToggleAction( true );
123 m_cardViewButton->addTo( listTools ); 107 m_cardViewButton->addTo( listTools );
124 108
125 listTools->addSeparator(); 109 listTools->addSeparator();
126 110
127 // Other Buttons 111 // Other Buttons
128 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 112 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
129 0, this, 0 ); 113 0, this, 0 );
130 actionNew = a; 114 actionNew = a;
131 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 115 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
132 a->addTo( edit ); 116 a->addTo( edit );
133 a->addTo( listTools ); 117 a->addTo( listTools );
134 118
135 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 119 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
136 0, this, 0 ); 120 0, this, 0 );
137 actionEdit = a; 121 actionEdit = a;
138 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
139 a->addTo( edit ); 123 a->addTo( edit );
140 a->addTo( listTools ); 124 a->addTo( listTools );
141 125
142 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 126 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
143 0, this, 0 ); 127 0, this, 0 );
144 actionTrash = a; 128 actionTrash = a;
145 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 129 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
146 a->addTo( edit ); 130 a->addTo( edit );
147 a->addTo( listTools ); 131 a->addTo( listTools );
148 132
149 133
150 // make it possible to go directly to businesscard via qcop call 134 // make it possible to go directly to businesscard via qcop call
151 //#if defined(Q_WS_QWS) // Why this ? (se) 135 //#if defined(Q_WS_QWS) // Why this ? (se)
152#if !defined(QT_NO_COP) 136#if !defined(QT_NO_COP)
153 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); 137 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
154 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 138 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
155 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 139 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
156#endif 140#endif
157 // #endif 141 // #endif
158 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 142 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
159 QString::null, 0, this, 0 ); 143 QString::null, 0, this, 0 );
160 actionFind = a; 144 actionFind = a;
161 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); 145 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
162 a->addTo( edit ); 146 a->addTo( edit );
163 a->addTo( listTools ); 147 a->addTo( listTools );
164 148
165 // Much better search widget, taken from QTReader.. (se) 149 // Much better search widget, taken from QTReader.. (se)
166 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); 150 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
167 searchBar->setHorizontalStretchable( TRUE ); 151 searchBar->setHorizontalStretchable( TRUE );
168 searchBar->hide(); 152 searchBar->hide();
169 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 153 searchEdit = new QLineEdit( searchBar, "searchEdit" );
170 154
171 // QFont f("unifont", 16 /*, QFont::Bold*/); 155 // QFont f("unifont", 16 /*, QFont::Bold*/);
172 // searchEdit->setFont( f ); 156 // searchEdit->setFont( f );
173 157
174 searchBar->setStretchableWidget( searchEdit ); 158 searchBar->setStretchableWidget( searchEdit );
175 connect( searchEdit, SIGNAL( returnPressed( ) ), 159 connect( searchEdit, SIGNAL( returnPressed( ) ),
176 this, SLOT( slotFind( ) ) ); 160 this, SLOT( slotFind( ) ) );
177 161
178 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 );
179 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 163 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
180 a->addTo( searchBar ); 164 a->addTo( searchBar );
181 165
182 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 );
183 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 167 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
184 a->addTo( searchBar ); 168 a->addTo( searchBar );
185 169
186 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), 170 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ),
187 QString::null, 0, this, 0 ); 171 QString::null, 0, this, 0 );
188 //a->setEnabled( FALSE ); we got support for it now :) zecke 172 //a->setEnabled( FALSE ); we got support for it now :) zecke
189 actionMail = a; 173 actionMail = a;
190 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 174 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
191 a->addTo( edit ); 175 a->addTo( edit );
192 a->addTo( listTools ); 176 a->addTo( listTools );
193 177
194 if ( Ir::supported() ) { 178 if ( Ir::supported() ) {
195 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 179 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
196 0, this, 0 ); 180 0, this, 0 );
197 actionBeam = a; 181 actionBeam = a;
198 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 182 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
199 a->addTo( edit ); 183 a->addTo( edit );
200 a->addTo( listTools ); 184 a->addTo( listTools );
201 } 185 }
202 186
203 edit->insertSeparator(); 187 edit->insertSeparator();
204 188
205 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,
206 0, this, 0); 190 0, this, 0);
207 actionPersonal = a; 191 actionPersonal = a;
208 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 192 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
209 a->addTo( edit ); 193 a->addTo( edit );
210 194
211 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,
212 0, this, 0); 196 0, this, 0);
213 actionPersonal = a; 197 actionPersonal = a;
214 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); 198 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) );
215 a->addTo( edit ); 199 a->addTo( edit );
216 200
217 edit->insertSeparator(); 201 edit->insertSeparator();
218 202
219 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), 203 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
220 QString::null, 0, this, 0 , TRUE ); 204 QString::null, 0, this, 0 , TRUE );
221 actionPersonal = a; 205 actionPersonal = a;
222 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 206 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
223 a->addTo( edit ); 207 a->addTo( edit );
224 208
225 209
226#ifdef __DEBUG_RELEASE 210#ifdef __DEBUG_RELEASE
227 // Remove this function for public Release ! This is only 211 // Remove this function for public Release ! This is only
228 // for debug purposes .. 212 // for debug purposes ..
229 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 213 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
230 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 214 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
231 a->addTo( edit ); 215 a->addTo( edit );
232#endif 216#endif
233 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 217 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null,
234 0, this, 0 ); 218 0, this, 0 );
235 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 219 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
236 a->addTo( edit ); 220 a->addTo( edit );
237 221
238 // Create Views 222 // Create Views
239 listContainer = new QWidget( this ); 223 listContainer = new QWidget( this );
240 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 224 QVBoxLayout *vb = new QVBoxLayout( listContainer );
241 225
242 m_abView = new AbView( listContainer, m_config.orderList() ); 226 m_abView = new AbView( listContainer, m_config.orderList() );
243 vb->addWidget( m_abView ); 227 vb->addWidget( m_abView );
244 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 228 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
245 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), 229 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
246 this, SLOT( slotViewSwitched( int ) ) ); 230 this, SLOT( slotViewSwitched( int ) ) );
247 231
248 232
249 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
250 234
251 // m_abView->load(); // Already done by c'tor . 235 // m_abView->load(); // Already done by c'tor .
252 236
253 // Letter Picker 237 // Letter Picker
254 pLabel = new LetterPicker( listContainer ); 238 pLabel = new LetterPicker( listContainer );
255 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
256 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); 240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
257 241
258 vb->addWidget( pLabel ); 242 vb->addWidget( pLabel );
259 243
260 // All Categories into view-menu.. 244 // All Categories into view-menu..
261 populateCategories(); 245 populateCategories();
262 246
263 // Fontsize 247 // Fontsize
264 defaultFont = new QFont( m_abView->font() ); 248 defaultFont = new QFont( m_abView->font() );
265 slotSetFont(m_config.fontSize()); 249 slotSetFont(m_config.fontSize());
266 m_curFontSize = m_config.fontSize(); 250 m_curFontSize = m_config.fontSize();
267 251
268 setCentralWidget(listContainer); 252 setCentralWidget(listContainer);
269 253
270 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 254 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
271 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 255 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
272 connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) ); 256 connect( qApp, SIGNAL( reload() ), this, SLOT( reload() ) );
273 connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ), 257 connect( qApp, SIGNAL( appMessage(const QCString &, const QByteArray &) ),
274 this, SLOT( appMessage(const QCString &, const QByteArray &) ) ); 258 this, SLOT( appMessage(const QCString &, const QByteArray &) ) );
275 259
276 260
277 isLoading = false; 261 isLoading = false;
278} 262}
279 263
280 264
281void AddressbookWindow::slotConfig() 265void AddressbookWindow::slotConfig()
282{ 266{
283 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 267 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
284 dlg -> setConfig( m_config ); 268 dlg -> setConfig( m_config );
285 if ( QPEApplication::execDialog( dlg ) ) { 269 if ( QPEApplication::execDialog( dlg ) ) {
286 qWarning ("Config Dialog accepted!"); 270 qWarning ("Config Dialog accepted!");
287 m_config = dlg -> getConfig(); 271 m_config = dlg -> getConfig();
288 if ( m_curFontSize != m_config.fontSize() ){ 272 if ( m_curFontSize != m_config.fontSize() ){
289 qWarning("Font was changed!"); 273 qWarning("Font was changed!");
290 m_curFontSize = m_config.fontSize(); 274 m_curFontSize = m_config.fontSize();
291 emit slotSetFont( m_curFontSize ); 275 emit slotSetFont( m_curFontSize );
292 } 276 }
293 m_abView -> setListOrder( m_config.orderList() ); 277 m_abView -> setListOrder( m_config.orderList() );
294 } 278 }
295 279
296 delete dlg; 280 delete dlg;
297} 281}
298 282
299 283
300void AddressbookWindow::slotSetFont( int size ) 284void AddressbookWindow::slotSetFont( int size )
301{ 285{
302 qWarning("void AddressbookWindow::slotSetFont( %d )", size); 286 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
303 287
304 if (size > 2 || size < 0) 288 if (size > 2 || size < 0)
305 size = 1; 289 size = 1;
306 290
307 m_config.setFontSize( size ); 291 m_config.setFontSize( size );
308 292
309 QFont *currentFont; 293 QFont *currentFont;
310 294
311 switch (size) { 295 switch (size) {
312 case 0: 296 case 0:
313 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
314 currentFont = new QFont (m_abView->font()); 298 currentFont = new QFont (m_abView->font());
315 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
316 // abList->resizeRows(); 300 // abList->resizeRows();
317 break; 301 break;
318 case 1: 302 case 1:
319 m_abView->setFont( *defaultFont ); 303 m_abView->setFont( *defaultFont );
320 currentFont = new QFont (m_abView->font()); 304 currentFont = new QFont (m_abView->font());
321 // // abList->resizeRows(currentFont->pixelSize() + 7); 305 // // abList->resizeRows(currentFont->pixelSize() + 7);
322 // abList->resizeRows(); 306 // abList->resizeRows();
323 break; 307 break;
324 case 2: 308 case 2:
325 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
326 currentFont = new QFont (m_abView->font()); 310 currentFont = new QFont (m_abView->font());
327 // //abList->resizeRows(currentFont->pixelSize() + 7); 311 // //abList->resizeRows(currentFont->pixelSize() + 7);
328 // abList->resizeRows(); 312 // abList->resizeRows();
329 break; 313 break;
330 } 314 }
331} 315}
332 316
333 317
334 318
335void AddressbookWindow::importvCard() { 319void AddressbookWindow::importvCard() {
336 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 320 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
337 if(!str.isEmpty() ){ 321 if(!str.isEmpty() ){
338 setDocument((const QString&) str ); 322 setDocument((const QString&) str );
339 } 323 }
340 324
341} 325}
342void AddressbookWindow::exportvCard() 326void AddressbookWindow::exportvCard()
343{ 327{
344 qWarning(" void AddressbookWindow::exportvCard()"); 328 qWarning(" void AddressbookWindow::exportvCard()");
345 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); 329 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this );
346 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ 330 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){
347 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); 331 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 );
348 OContact curCont = m_abView->currentEntry(); 332 OContact curCont = m_abView->currentEntry();
349 if ( !curCont.isEmpty() ){ 333 if ( !curCont.isEmpty() ){
350 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 334 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
351 filename ); 335 filename );
352 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); 336 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true );
353 if ( access ){ 337 if ( access ){
354 access->add( curCont ); 338 access->add( curCont );
355 access->save(); 339 access->save();
356 } 340 }
357 delete access; 341 delete access;
358 }else 342 }else
359 QMessageBox::critical( 0, "Export VCard", 343 QMessageBox::critical( 0, "Export VCard",
360 QString( tr( "You have to select a contact !") ) ); 344 QString( tr( "You have to select a contact !") ) );
361 345
362 }else 346 }else
363 QMessageBox::critical( 0, "Export VCard", 347 QMessageBox::critical( 0, "Export VCard",
364 QString( tr( "You have to set a filename !") ) ); 348 QString( tr( "You have to set a filename !") ) );
365} 349}
366 350
367void AddressbookWindow::setDocument( const QString &filename ) 351void AddressbookWindow::setDocument( const QString &filename )
368{ 352{
369 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); 353 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
370 354
371 if ( filename.find(".vcf") != int(filename.length()) - 4 ){ 355 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
372 356
373 357
374 358
375 switch( QMessageBox::information( this, tr ( "Right file type ?" ), 359 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
376 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), 360 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ),
377 tr( "&Yes" ), tr( "&No" ), QString::null, 361 tr( "&Yes" ), tr( "&No" ), QString::null,
378 0, // Enter == button 0 362 0, // Enter == button 0
379 2 ) ) { // Escape == button 2 363 2 ) ) { // Escape == button 2
380 case 0: 364 case 0:
381 qWarning("YES clicked"); 365 qWarning("YES clicked");
382 break; 366 break;
383 case 1: 367 case 1:
384 qWarning("NO clicked"); 368 qWarning("NO clicked");
385 return; 369 return;
386 break; 370 break;
387 } 371 }
388 } 372 }
389 373
390 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 374 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
391 filename ); 375 filename );
392 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 376 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
393 OContactAccess::List allList = access->allRecords(); 377 OContactAccess::List allList = access->allRecords();
394 qWarning( "Found number of contacts in File: %d", allList.count() ); 378 qWarning( "Found number of contacts in File: %d", allList.count() );
395 379
396 if ( !allList.count() ) { 380 if ( !allList.count() ) {
397 QMessageBox::information( this, "Import VCard", 381 QMessageBox::information( this, "Import VCard",
398 "It was impossible to import\nthe VCard.\n" 382 "It was impossible to import\nthe VCard.\n"
399 "The VCard may be corrupted!" ); 383 "The VCard may be corrupted!" );
400 } 384 }
401 385
402 bool doAsk = true; 386 bool doAsk = true;
403 OContactAccess::List::Iterator it; 387 OContactAccess::List::Iterator it;
404 for ( it = allList.begin(); it != allList.end(); ++it ){ 388 for ( it = allList.begin(); it != allList.end(); ++it ){
405 qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); 389 qWarning("Adding Contact from: %s", (*it).fullName().latin1() );
406 if ( doAsk ){ 390 if ( doAsk ){
407 switch( QMessageBox::information( this, tr ( "Add Contact?" ), 391 switch( QMessageBox::information( this, tr ( "Add Contact?" ),
408 tr( "Do you really want add contact for \n%1?" ) 392 tr( "Do you really want add contact for \n%1?" )
409 .arg( (*it).fullName().latin1() ), 393 .arg( (*it).fullName().latin1() ),
410 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), 394 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"),
411 0, // Enter == button 0 395 0, // Enter == button 0
412 2 ) ) { // Escape == button 2 396 2 ) ) { // Escape == button 2
413 case 0: 397 case 0:
414 qWarning("YES clicked"); 398 qWarning("YES clicked");
415 m_abView->addEntry( *it ); 399 m_abView->addEntry( *it );
416 break; 400 break;
417 case 1: 401 case 1:
418 qWarning("NO clicked"); 402 qWarning("NO clicked");
419 break; 403 break;
420 case 2: 404 case 2:
421 qWarning("YesAll clicked"); 405 qWarning("YesAll clicked");
422 doAsk = false; 406 doAsk = false;
423 break; 407 break;
424 } 408 }
425 }else 409 }else
426 m_abView->addEntry( *it ); 410 m_abView->addEntry( *it );
427 411
428 } 412 }
429 413
430 delete access; 414 delete access;
431} 415}
432 416
433void AddressbookWindow::resizeEvent( QResizeEvent *e ) 417void AddressbookWindow::resizeEvent( QResizeEvent *e )
434{ 418{
435 QMainWindow::resizeEvent( e ); 419 QMainWindow::resizeEvent( e );
436 420
437 421
438} 422}
439 423
440AddressbookWindow::~AddressbookWindow() 424AddressbookWindow::~AddressbookWindow()
441{ 425{
442 ToolBarDock dock; 426 ToolBarDock dock;
443 int dummy; 427 int dummy;
444 bool bDummy; 428 bool bDummy;
445 getLocation ( listTools, dock, dummy, bDummy, dummy ); 429 getLocation ( listTools, dock, dummy, bDummy, dummy );
446 m_config.setToolBarDock( dock ); 430 m_config.setToolBarDock( dock );
447 m_config.save(); 431 m_config.save();
448} 432}
449 433
450void AddressbookWindow::slotUpdateToolbar() 434void AddressbookWindow::slotUpdateToolbar()
451{ 435{
452 OContact ce = m_abView->currentEntry(); 436 OContact ce = m_abView->currentEntry();
453 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 437 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
454} 438}
455 439
456void AddressbookWindow::slotListNew() 440void AddressbookWindow::slotListNew()
457{ 441{
458 OContact cnt; 442 OContact cnt;
459 if( !syncing ) { 443 if( !syncing ) {
460 editEntry( NewEntry ); 444 editEntry( NewEntry );
461 } else { 445 } else {
462 QMessageBox::warning(this, tr("Contacts"), 446 QMessageBox::warning(this, tr("Contacts"),
463 tr("Can not edit data, currently syncing")); 447 tr("Can not edit data, currently syncing"));
464 } 448 }
465} 449}
466 450
467// void AddressbookWindow::slotListView() 451// void AddressbookWindow::slotListView()
468// { 452// {
469 // m_abView -> init( abList->currentEntry() ); 453 // m_abView -> init( abList->currentEntry() );
470 // // :SX mView->sync(); 454 // // :SX mView->sync();
471 // //:SXshowView(); 455 // //:SXshowView();
472// } 456// }
473 457
474void AddressbookWindow::slotListDelete() 458void AddressbookWindow::slotListDelete()
475{ 459{
476 if(!syncing) { 460 if(!syncing) {
477 OContact tmpEntry = m_abView ->currentEntry(); 461 OContact tmpEntry = m_abView ->currentEntry();
478 462
479 // get a name, do the best we can... 463 // get a name, do the best we can...
480 QString strName = tmpEntry.fullName(); 464 QString strName = tmpEntry.fullName();
481 if ( strName.isEmpty() ) { 465 if ( strName.isEmpty() ) {
482 strName = tmpEntry.company(); 466 strName = tmpEntry.company();
483 if ( strName.isEmpty() ) 467 if ( strName.isEmpty() )
484 strName = "No Name"; 468 strName = "No Name";
485 } 469 }
486 470
487 471
488 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 472 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
489 strName ) ) { 473 strName ) ) {
490 m_abView->removeEntry( tmpEntry.uid() ); 474 m_abView->removeEntry( tmpEntry.uid() );
491 } 475 }
492 } else { 476 } else {
493 QMessageBox::warning( this, tr("Contacts"), 477 QMessageBox::warning( this, tr("Contacts"),
494 tr("Can not edit data, currently syncing") ); 478 tr("Can not edit data, currently syncing") );
495 } 479 }
496} 480}
497 481
498void AddressbookWindow::slotFindOpen() 482void AddressbookWindow::slotFindOpen()
499{ 483{
500 searchBar->show(); 484 searchBar->show();
501 m_abView -> inSearch(); 485 m_abView -> inSearch();
502 searchEdit->setFocus(); 486 searchEdit->setFocus();
503} 487}
504void AddressbookWindow::slotFindClose() 488void AddressbookWindow::slotFindClose()
505{ 489{
506 searchBar->hide(); 490 searchBar->hide();
507 m_abView -> offSearch(); 491 m_abView -> offSearch();
508 // m_abView->setFocus(); 492 // m_abView->setFocus();
509} 493}
510 494
511 495
512void AddressbookWindow::slotFind() 496void AddressbookWindow::slotFind()
513{ 497{
514 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 498 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
515 499
516 searchEdit->clearFocus(); 500 searchEdit->clearFocus();
517 // m_abView->setFocus(); 501 // m_abView->setFocus();
518 502
519} 503}
520 504
521void AddressbookWindow::slotViewBack() 505void AddressbookWindow::slotViewBack()
522{ 506{
523 // :SX showList(); 507 // :SX showList();
524} 508}
525 509
526void AddressbookWindow::slotViewEdit() 510void AddressbookWindow::slotViewEdit()
527{ 511{
528 if(!syncing) { 512 if(!syncing) {
529 if (actionPersonal->isOn()) { 513 if (actionPersonal->isOn()) {
530 editPersonal(); 514 editPersonal();
531 } else { 515 } else {
532 editEntry( EditEntry ); 516 editEntry( EditEntry );
533 } 517 }
534 } else { 518 } else {
535 QMessageBox::warning( this, tr("Contacts"), 519 QMessageBox::warning( this, tr("Contacts"),
536 tr("Can not edit data, currently syncing") ); 520 tr("Can not edit data, currently syncing") );
537 } 521 }
538} 522}
539 523
540 524
541 525
542void AddressbookWindow::writeMail() 526void AddressbookWindow::writeMail()
543{ 527{
544 OContact c = m_abView -> currentEntry(); 528 OContact c = m_abView -> currentEntry();
545 QString name = c.fileAs(); 529 QString name = c.fileAs();
546 QString email = c.defaultEmail(); 530 QString email = c.defaultEmail();
547 531
548 // I prefer the OPIE-Environment variable before the 532 // I prefer the OPIE-Environment variable before the
549 // QPE-one.. 533 // QPE-one..
550 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 534 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
551 if ( basepath.isEmpty() ) 535 if ( basepath.isEmpty() )
552 basepath = QString::fromLatin1( getenv("QPEDIR") ); 536 basepath = QString::fromLatin1( getenv("QPEDIR") );
553 537
554 // Try to access the preferred. If not possible, try to 538 // Try to access the preferred. If not possible, try to
555 // switch to the other one.. 539 // switch to the other one..
556 if ( m_config.useQtMail() ){ 540 if ( m_config.useQtMail() ){
557 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 541 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
558 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 542 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
559 qWarning ("QCop"); 543 qWarning ("QCop");
560 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 544 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
561 e << name << email; 545 e << name << email;
562 return; 546 return;
563 } else 547 } else
564 m_config.setUseOpieMail( true ); 548 m_config.setUseOpieMail( true );
565 } 549 }
566 if ( m_config.useOpieMail() ){ 550 if ( m_config.useOpieMail() ){
567 qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1()); 551 qWarning ("Accessing: %s", (basepath + "/bin/opiemail").latin1());
568 if ( QFile::exists( basepath + "/bin/opiemail" ) ){ 552 if ( QFile::exists( basepath + "/bin/opiemail" ) ){
569 qWarning ("QCop"); 553 qWarning ("QCop");
570 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); 554 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)");
571 e << name << email; 555 e << name << email;
572 return; 556 return;
573 } else 557 } else
574 m_config.setUseQtMail( true ); 558 m_config.setUseQtMail( true );
575 } 559 }
576 560
577} 561}
578 562
579static const char * beamfile = "/tmp/obex/contact.vcf"; 563static const char * beamfile = "/tmp/obex/contact.vcf";
580 564
581void AddressbookWindow::slotBeam() 565void AddressbookWindow::slotBeam()
582{ 566{
583 QString beamFilename; 567 QString beamFilename;
584 OContact c; 568 OContact c;
585 if ( actionPersonal->isOn() ) { 569 if ( actionPersonal->isOn() ) {
586 beamFilename = addressbookPersonalVCardName(); 570 beamFilename = addressbookPersonalVCardName();
587 if ( !QFile::exists( beamFilename ) ) 571 if ( !QFile::exists( beamFilename ) )
588 return; // can't beam a non-existent file 572 return; // can't beam a non-existent file
589 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 573 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
590 beamFilename ); 574 beamFilename );
591 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 575 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
592 OContactAccess::List allList = access->allRecords(); 576 OContactAccess::List allList = access->allRecords();
593 OContactAccess::List::Iterator it = allList.begin(); // Just take first 577 OContactAccess::List::Iterator it = allList.begin(); // Just take first
594 c = *it; 578 c = *it;
595 579
596 delete access; 580 delete access;
597 } else { 581 } else {
598 unlink( beamfile ); // delete if exists 582 unlink( beamfile ); // delete if exists
599 mkdir("/tmp/obex/", 0755); 583 mkdir("/tmp/obex/", 0755);
600 c = m_abView -> currentEntry(); 584 c = m_abView -> currentEntry();
601 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 585 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
602 beamfile ); 586 beamfile );
603 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 587 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
604 access->add( c ); 588 access->add( c );
605 access->save(); 589 access->save();
606 delete access; 590 delete access;
607 591
608 beamFilename = beamfile; 592 beamFilename = beamfile;
609 } 593 }
610 594
611 qWarning("Beaming: %s", beamFilename.latin1() ); 595 qWarning("Beaming: %s", beamFilename.latin1() );
612 596
613 Ir *ir = new Ir( this ); 597 Ir *ir = new Ir( this );
614 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 598 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
615 QString description = c.fullName(); 599 QString description = c.fullName();
616 ir->send( beamFilename, description, "text/x-vCard" ); 600 ir->send( beamFilename, description, "text/x-vCard" );
617} 601}
618 602
619void AddressbookWindow::beamDone( Ir *ir ) 603void AddressbookWindow::beamDone( Ir *ir )
620{ 604{
621 605
622 delete ir; 606 delete ir;
623 unlink( beamfile ); 607 unlink( beamfile );
624} 608}
625 609
626 610
627static void parseName( const QString& name, QString *first, QString *middle, 611static void parseName( const QString& name, QString *first, QString *middle,
628 QString * last ) 612 QString * last )
629{ 613{
630 614
631 int comma = name.find ( "," ); 615 int comma = name.find ( "," );
632 QString rest; 616 QString rest;
633 if ( comma > 0 ) { 617 if ( comma > 0 ) {
634 *last = name.left( comma ); 618 *last = name.left( comma );
635 comma++; 619 comma++;
636 while ( comma < int(name.length()) && name[comma] == ' ' ) 620 while ( comma < int(name.length()) && name[comma] == ' ' )
637 comma++; 621 comma++;
638 rest = name.mid( comma ); 622 rest = name.mid( comma );
639 } else { 623 } else {
640 int space = name.findRev( ' ' ); 624 int space = name.findRev( ' ' );
641 *last = name.mid( space+1 ); 625 *last = name.mid( space+1 );
642 rest = name.left( space ); 626 rest = name.left( space );
643 } 627 }
644 int space = rest.find( ' ' ); 628 int space = rest.find( ' ' );
645 if ( space <= 0 ) { 629 if ( space <= 0 ) {
646 *first = rest; 630 *first = rest;
647 } else { 631 } else {
648 *first = rest.left( space ); 632 *first = rest.left( space );
649 *middle = rest.mid( space+1 ); 633 *middle = rest.mid( space+1 );
650 } 634 }
651 635
652} 636}
653 637
654 638
655void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 639void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
656{ 640{
657 bool needShow = FALSE; 641 bool needShow = FALSE;
658 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); 642 qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() );
659 643
660 644
661 if (msg == "editPersonal()") { 645 if (msg == "editPersonal()") {
662 editPersonal(); 646 editPersonal();
663 } else if (msg == "editPersonalAndClose()") { 647 } else if (msg == "editPersonalAndClose()") {
664 editPersonal(); 648 editPersonal();
665 close(); 649 close();
666 } else if ( msg == "addContact(QString,QString)" ) { 650 } else if ( msg == "addContact(QString,QString)" ) {
667 QDataStream stream(data,IO_ReadOnly); 651 QDataStream stream(data,IO_ReadOnly);
668 QString name, email; 652 QString name, email;
669 stream >> name >> email; 653 stream >> name >> email;
670 654
671 OContact cnt; 655 OContact cnt;
672 QString fn, mn, ln; 656 QString fn, mn, ln;
673 parseName( name, &fn, &mn, &ln ); 657 parseName( name, &fn, &mn, &ln );
674 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 658 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
675 cnt.setFirstName( fn ); 659 cnt.setFirstName( fn );
676 cnt.setMiddleName( mn ); 660 cnt.setMiddleName( mn );
677 cnt.setLastName( ln ); 661 cnt.setLastName( ln );
678 cnt.insertEmails( email ); 662 cnt.insertEmails( email );
679 cnt.setDefaultEmail( email ); 663 cnt.setDefaultEmail( email );
680 cnt.setFileAs(); 664 cnt.setFileAs();
681 665
682 m_abView -> addEntry( cnt ); 666 m_abView -> addEntry( cnt );
683 667
684 // :SXm_abView()->init( cnt ); 668 // :SXm_abView()->init( cnt );
685 editEntry( EditEntry ); 669 editEntry( EditEntry );
686 } else if ( msg == "beamBusinessCard()" ) { 670 } else if ( msg == "beamBusinessCard()" ) {
687 QString beamFilename = addressbookPersonalVCardName(); 671 QString beamFilename = addressbookPersonalVCardName();
688 if ( !QFile::exists( beamFilename ) ) 672 if ( !QFile::exists( beamFilename ) )
689 return; // can't beam a non-existent file 673 return; // can't beam a non-existent file
690 674
691 Ir *ir = new Ir( this ); 675 Ir *ir = new Ir( this );
692 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 676 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
693 QString description = "mycard.vcf"; 677 QString description = "mycard.vcf";
694 ir->send( beamFilename, description, "text/x-vCard" ); 678 ir->send( beamFilename, description, "text/x-vCard" );
695 } else if ( msg == "show(int)" ) { 679 } else if ( msg == "show(int)" ) {
696 raise(); 680 raise();
697 QDataStream stream(data,IO_ReadOnly); 681 QDataStream stream(data,IO_ReadOnly);
698 int uid; 682 int uid;
699 stream >> uid; 683 stream >> uid;
700 684
701 qWarning( "Showing uid: %d" , uid ); 685 qWarning( "Showing uid: %d" , uid );
702 686
703 // Deactivate Personal View.. 687 // Deactivate Personal View..
704 if ( actionPersonal->isOn() ){ 688 if ( actionPersonal->isOn() ){
705 actionPersonal->setOn( false ); 689 actionPersonal->setOn( false );
706 slotPersonalView(); 690 slotPersonalView();
707 } 691 }
708 692
709 // Reset category and show as card.. 693 // Reset category and show as card..
710 m_abView -> setShowByCategory( QString::null ); 694 m_abView -> setShowByCategory( QString::null );
711 m_abView -> setCurrentUid( uid ); 695 m_abView -> setCurrentUid( uid );
712 slotViewSwitched ( AbView::CardView ); 696 slotViewSwitched ( AbView::CardView );
713 697
714 needShow = true; 698 needShow = true;
715 699
716 700
717 } else if ( msg == "edit(int)" ) { 701 } else if ( msg == "edit(int)" ) {
718 QDataStream stream(data,IO_ReadOnly); 702 QDataStream stream(data,IO_ReadOnly);
719 int uid; 703 int uid;
720 stream >> uid; 704 stream >> uid;
721 705
722 // Deactivate Personal View.. 706 // Deactivate Personal View..
723 if ( actionPersonal->isOn() ){ 707 if ( actionPersonal->isOn() ){
724 actionPersonal->setOn( false ); 708 actionPersonal->setOn( false );
725 slotPersonalView(); 709 slotPersonalView();
726 } 710 }
727 711
728 // Reset category and edit.. 712 // Reset category and edit..
729 m_abView -> setShowByCategory( QString::null ); 713 m_abView -> setShowByCategory( QString::null );
730 m_abView -> setCurrentUid( uid ); 714 m_abView -> setCurrentUid( uid );
731 slotViewEdit(); 715 slotViewEdit();
732 } 716 }
733 717
734 if (needShow) 718 if (needShow)
735 QPEApplication::setKeepRunning(); 719 QPEApplication::setKeepRunning();
736 720
737} 721}
738 722
739void AddressbookWindow::editEntry( EntryMode entryMode ) 723void AddressbookWindow::editEntry( EntryMode entryMode )
740{ 724{
741 OContact entry; 725 OContact entry;
742 if ( !abEditor ) { 726 if ( !abEditor ) {
743 abEditor = new ContactEditor( entry, this, "editor" ); 727 abEditor = new ContactEditor( entry, this, "editor" );
744 } 728 }
745 if ( entryMode == EditEntry ) 729 if ( entryMode == EditEntry )
746 abEditor->setEntry( m_abView -> currentEntry() ); 730 abEditor->setEntry( m_abView -> currentEntry() );
747 else if ( entryMode == NewEntry ) 731 else if ( entryMode == NewEntry )
748 abEditor->setEntry( entry ); 732 abEditor->setEntry( entry );
749 // other things may change the caption. 733 // other things may change the caption.
750 abEditor->setCaption( tr("Edit Address") ); 734 abEditor->setCaption( tr("Edit Address") );
751 735
752 // fix the foxus... 736 // fix the foxus...
753 abEditor->setNameFocus(); 737 abEditor->setNameFocus();
754 if ( QPEApplication::execDialog( abEditor ) ) { 738 if ( QPEApplication::execDialog( abEditor ) ) {
755 setFocus(); 739 setFocus();
756 if ( entryMode == NewEntry ) { 740 if ( entryMode == NewEntry ) {
757 OContact insertEntry = abEditor->entry(); 741 OContact insertEntry = abEditor->entry();
758 insertEntry.assignUid(); 742 insertEntry.assignUid();
759 m_abView -> addEntry( insertEntry ); 743 m_abView -> addEntry( insertEntry );
760 m_abView -> setCurrentUid( insertEntry.uid() ); 744 m_abView -> setCurrentUid( insertEntry.uid() );
761 } else { 745 } else {
762 OContact replEntry = abEditor->entry(); 746 OContact replEntry = abEditor->entry();
763 747
764 if ( !replEntry.isValidUid() ) 748 if ( !replEntry.isValidUid() )
765 replEntry.assignUid(); 749 replEntry.assignUid();
766 750
767 m_abView -> replaceEntry( replEntry ); 751 m_abView -> replaceEntry( replEntry );
768 } 752 }
769 } 753 }
770 // populateCategories(); 754 // populateCategories();
771 755
772} 756}
773 757
774void AddressbookWindow::editPersonal() 758void AddressbookWindow::editPersonal()
775{ 759{
776 OContact entry; 760 OContact entry;
777 761
778 // Switch to personal view if not selected 762 // Switch to personal view if not selected
779 // but take care of the menu, too 763 // but take care of the menu, too
780 if ( ! actionPersonal->isOn() ){ 764 if ( ! actionPersonal->isOn() ){
781 qWarning("*** ++++"); 765 qWarning("*** ++++");
782 actionPersonal->setOn( true ); 766 actionPersonal->setOn( true );
783 slotPersonalView(); 767 slotPersonalView();
784 } 768 }
785 769
786 if ( !abEditor ) { 770 if ( !abEditor ) {
787 abEditor = new ContactEditor( entry, this, "editor" ); 771 abEditor = new ContactEditor( entry, this, "editor" );
788 } 772 }
789 773
790 abEditor->setCaption(tr("Edit My Personal Details")); 774 abEditor->setCaption(tr("Edit My Personal Details"));
791 abEditor->setPersonalView( true ); 775 abEditor->setPersonalView( true );
792 editEntry( EditEntry ); 776 editEntry( EditEntry );
793 abEditor->setPersonalView( false ); 777 abEditor->setPersonalView( false );
794 778
795} 779}
796 780
797 781
798void AddressbookWindow::slotPersonalView() 782void AddressbookWindow::slotPersonalView()
799{ 783{
800 qWarning("slotPersonalView()"); 784 qWarning("slotPersonalView()");
801 if (!actionPersonal->isOn()) { 785 if (!actionPersonal->isOn()) {
802 // we just turned it off 786 // we just turned it off
803 qWarning("slotPersonalView()-> OFF"); 787 qWarning("slotPersonalView()-> OFF");
804 setCaption( tr("Contacts") ); 788 setCaption( tr("Contacts") );
805 actionNew->setEnabled(TRUE); 789 actionNew->setEnabled(TRUE);
806 actionTrash->setEnabled(TRUE); 790 actionTrash->setEnabled(TRUE);
807 actionFind->setEnabled(TRUE); 791 actionFind->setEnabled(TRUE);
808 actionMail->setEnabled(TRUE); 792 actionMail->setEnabled(TRUE);
809 // slotUpdateToolbar(); 793 // slotUpdateToolbar();
810 794
811 m_abView->showPersonal( false ); 795 m_abView->showPersonal( false );
812 796
813 return; 797 return;
814 } 798 }
815 799
816 qWarning("slotPersonalView()-> ON"); 800 qWarning("slotPersonalView()-> ON");
817 // XXX need to disable some QActions. 801 // XXX need to disable some QActions.
818 actionNew->setEnabled(FALSE); 802 actionNew->setEnabled(FALSE);
819 actionTrash->setEnabled(FALSE); 803 actionTrash->setEnabled(FALSE);
820 actionFind->setEnabled(FALSE); 804 actionFind->setEnabled(FALSE);
821 actionMail->setEnabled(FALSE); 805 actionMail->setEnabled(FALSE);
822 806
823 setCaption( tr("Contacts - My Personal Details") ); 807 setCaption( tr("Contacts - My Personal Details") );
824 808
825 m_abView->showPersonal( true ); 809 m_abView->showPersonal( true );
826 810
827} 811}
828 812
829 813
830void AddressbookWindow::listIsEmpty( bool empty ) 814void AddressbookWindow::listIsEmpty( bool empty )
831{ 815{
832 if ( !empty ) { 816 if ( !empty ) {
833 deleteButton->setEnabled( TRUE ); 817 deleteButton->setEnabled( TRUE );
834 } 818 }
835} 819}
836 820
837void AddressbookWindow::reload() 821void AddressbookWindow::reload()
838{ 822{
839 syncing = FALSE; 823 syncing = FALSE;
840 m_abView->clear(); 824 m_abView->clear();
841 m_abView->reload(); 825 m_abView->reload();
842} 826}
843 827
844void AddressbookWindow::flush() 828void AddressbookWindow::flush()
845{ 829{
846 syncing = TRUE; 830 syncing = TRUE;
847 m_abView->save(); 831 m_abView->save();
848} 832}
849 833
850 834
851void AddressbookWindow::closeEvent( QCloseEvent *e ) 835void AddressbookWindow::closeEvent( QCloseEvent *e )
852{ 836{
853 if(active_view == AbView::CardView){ 837 if(active_view == AbView::CardView){
854 slotViewSwitched( AbView::TableView ); 838 slotViewSwitched( AbView::TableView );
855 e->ignore(); 839 e->ignore();
856 return; 840 return;
857 } 841 }
858 if(syncing) { 842 if(syncing) {
859 /* shouldn't we save, I hear you say? well its already been set 843 /* shouldn't we save, I hear you say? well its already been set
860 so that an edit can not occur during a sync, and we flushed 844 so that an edit can not occur during a sync, and we flushed
861 at the start of the sync, so there is no need to save 845 at the start of the sync, so there is no need to save
862 Saving however itself would cause problems. */ 846 Saving however itself would cause problems. */
863 e->accept(); 847 e->accept();
864 return; 848 return;
865 } 849 }
866 //################## shouldn't always save 850 //################## shouldn't always save
867 // True, but the database handles this automatically ! (se) 851 // True, but the database handles this automatically ! (se)
868 if ( save() ) 852 if ( save() )
869 e->accept(); 853 e->accept();
870 else 854 else
871 e->ignore(); 855 e->ignore();
872} 856}
873 857
874/* 858/*
875 Returns TRUE if it is OK to exit 859 Returns TRUE if it is OK to exit
876*/ 860*/
877 861
878bool AddressbookWindow::save() 862bool AddressbookWindow::save()
879{ 863{
880 if ( !m_abView->save() ) { 864 if ( !m_abView->save() ) {
881 if ( QMessageBox::critical( 0, tr( "Out of space" ), 865 if ( QMessageBox::critical( 0, tr( "Out of space" ),
882 tr("Unable to save information.\n" 866 tr("Unable to save information.\n"
883 "Free up some space\n" 867 "Free up some space\n"
884 "and try again.\n" 868 "and try again.\n"
885 "\nQuit anyway?"), 869 "\nQuit anyway?"),
886 QMessageBox::Yes|QMessageBox::Escape, 870 QMessageBox::Yes|QMessageBox::Escape,
887 QMessageBox::No|QMessageBox::Default ) 871 QMessageBox::No|QMessageBox::Default )
888 != QMessageBox::No ) 872 != QMessageBox::No )
889 return TRUE; 873 return TRUE;
890 else 874 else
891 return FALSE; 875 return FALSE;
892 } 876 }
893 return TRUE; 877 return TRUE;
894} 878}
895 879
896#ifdef __DEBUG_RELEASE 880#ifdef __DEBUG_RELEASE
897void AddressbookWindow::slotSave() 881void AddressbookWindow::slotSave()
898{ 882{
899 save(); 883 save();
900} 884}
901#endif 885#endif
902 886
903 887
904void AddressbookWindow::slotNotFound() 888void AddressbookWindow::slotNotFound()
905{ 889{
906 qWarning("Got notfound signal!"); 890 qWarning("Got notfound signal!");
907 QMessageBox::information( this, tr( "Not Found" ), 891 QMessageBox::information( this, tr( "Not Found" ),
908 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); 892 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" );
909 893
910 894
911} 895}
912void AddressbookWindow::slotWrapAround() 896void AddressbookWindow::slotWrapAround()
913{ 897{
914 qWarning("Got wrap signal!"); 898 qWarning("Got wrap signal!");
915 // if ( doNotifyWrapAround ) 899 // if ( doNotifyWrapAround )
916 // QMessageBox::information( this, tr( "End of list" ), 900 // QMessageBox::information( this, tr( "End of list" ),
917 // tr( "End of list. Wrap around now...!" ) + "\n" ); 901 // tr( "End of list. Wrap around now...!" ) + "\n" );
918 902
919} 903}
920 904
921void AddressbookWindow::slotSetCategory( int c ) 905void AddressbookWindow::slotSetCategory( int c )
922{ 906{
923 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); 907 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
924 908
925 QString cat, book; 909 QString cat, book;
926 AbView::Views view = AbView::TableView; 910 AbView::Views view = AbView::TableView;
927 911
928 if ( c <= 0 ) 912 if ( c <= 0 )
929 return; 913 return;
930 914
931 // Switch view 915 // Switch view
932 if ( c < 3 ) 916 if ( c < 3 )
933 for ( unsigned int i = 1; i < 3; i++ ){ 917 for ( unsigned int i = 1; i < 3; i++ ){
934 if ( catMenu ) 918 if ( catMenu )
935 catMenu->setItemChecked( i, c == (int)i ); 919 catMenu->setItemChecked( i, c == (int)i );
936 } 920 }
937 else 921 else
938 // Checkmark Category Menu Item Selected 922 // Checkmark Category Menu Item Selected
939 for ( unsigned int i = 3; i < catMenu->count(); i++ ) 923 for ( unsigned int i = 3; i < catMenu->count(); i++ )
940 catMenu->setItemChecked( i, c == (int)i ); 924 catMenu->setItemChecked( i, c == (int)i );
941 925
942 // Now switch to the selected category 926 // Now switch to the selected category
943 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 927 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
944 if (catMenu->isItemChecked( i )) { 928 if (catMenu->isItemChecked( i )) {
945 if ( i == 1 ){ // default List view 929 if ( i == 1 ){ // default List view
946 book = QString::null; 930 book = QString::null;
947 view = AbView::TableView; 931 view = AbView::TableView;
948 }else if ( i == 2 ){ 932 }else if ( i == 2 ){
949 book = tr( "Cards" ); 933 book = tr( "Cards" );
950 view = AbView::CardView; 934 view = AbView::CardView;
951 // }else if ( i == 3 ){ 935 // }else if ( i == 3 ){
952 // book = tr( "Personal" ); 936 // book = tr( "Personal" );
953 // view = AbView:: PersonalView; 937 // view = AbView:: PersonalView;
954 }else if ( i == 3 ){ // default All Categories 938 }else if ( i == 3 ){ // default All Categories
955 cat = QString::null; 939 cat = QString::null;
956 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled 940 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
957 cat = "Unfiled"; 941 cat = "Unfiled";
958 qWarning ("Unfiled selected!"); 942 qWarning ("Unfiled selected!");
959 }else{ 943 }else{
960 cat = m_abView->categories()[i - 4]; 944 cat = m_abView->categories()[i - 4];
961 } 945 }
962 } 946 }
963 } 947 }
964 948
965 // Switch to the selected View 949 // Switch to the selected View
966 slotViewSwitched( view ); 950 slotViewSwitched( view );
967 951
968 // Tell the view about the selected category 952 // Tell the view about the selected category
969 m_abView -> setShowByCategory( cat ); 953 m_abView -> setShowByCategory( cat );
970 954
971 if ( book.isEmpty() ) 955 if ( book.isEmpty() )
972 book = "List"; 956 book = "List";
973 if ( cat.isEmpty() ) 957 if ( cat.isEmpty() )
974 cat = "All"; 958 cat = "All";
975 959
976 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); 960 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
977} 961}
978 962
979void AddressbookWindow::slotViewSwitched( int view ) 963void AddressbookWindow::slotViewSwitched( int view )
980{ 964{
981 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); 965 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
982 int menu = 0; 966 int menu = 0;
983 967
984 // Switch to selected view 968 // Switch to selected view
985 switch ( view ){ 969 switch ( view ){
986 case AbView::TableView: 970 case AbView::TableView:
987 menu = 1; 971 menu = 1;
988 m_tableViewButton->setOn(true); 972 m_tableViewButton->setOn(true);
989 m_cardViewButton->setOn(false); 973 m_cardViewButton->setOn(false);
990 break; 974 break;
991 case AbView::CardView: 975 case AbView::CardView:
992 menu = 2; 976 menu = 2;
993 m_tableViewButton->setOn(false); 977 m_tableViewButton->setOn(false);
994 m_cardViewButton->setOn(true); 978 m_cardViewButton->setOn(true);
995 break; 979 break;
996 } 980 }
997 for ( unsigned int i = 1; i < 3; i++ ){ 981 for ( unsigned int i = 1; i < 3; i++ ){
998 if ( catMenu ) 982 if ( catMenu )
999 catMenu->setItemChecked( i, menu == (int)i ); 983 catMenu->setItemChecked( i, menu == (int)i );
1000 } 984 }
1001 985
1002 // Tell the view about the selected view 986 // Tell the view about the selected view
1003 m_abView -> setShowToView ( (AbView::Views) view ); 987 m_abView -> setShowToView ( (AbView::Views) view );
1004 active_view = view; 988 active_view = view;
1005} 989}
1006 990
1007 991
1008void AddressbookWindow::slotListView() 992void AddressbookWindow::slotListView()
1009{ 993{
1010 slotViewSwitched( AbView::TableView ); 994 slotViewSwitched( AbView::TableView );
1011} 995}
1012 996
1013void AddressbookWindow::slotCardView() 997void AddressbookWindow::slotCardView()
1014{ 998{
1015 slotViewSwitched( AbView::CardView ); 999 slotViewSwitched( AbView::CardView );
1016} 1000}
1017 1001
1018void AddressbookWindow::slotSetLetter( char c ) { 1002void AddressbookWindow::slotSetLetter( char c ) {
1019 1003
1020 m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); 1004 m_abView->setShowByLetter( c, m_config.letterPickerSearch() );
1021 1005
1022} 1006}
1023 1007
1024 1008
1025void AddressbookWindow::populateCategories() 1009void AddressbookWindow::populateCategories()
1026{ 1010{
1027 catMenu->clear(); 1011 catMenu->clear();
1028 1012
1029 int id, rememberId; 1013 int id, rememberId;
1030 id = 1; 1014 id = 1;
1031 rememberId = 0; 1015 rememberId = 0;
1032 1016
1033 catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ ); 1017 catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ );
1034 catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ ); 1018 catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ );
1035 // catMenu->insertItem( tr( "Personal" ), id++ ); 1019 // catMenu->insertItem( tr( "Personal" ), id++ );
1036 catMenu->insertSeparator(); 1020 catMenu->insertSeparator();
1037 1021
1038 catMenu->insertItem( tr( "All" ), id++ ); 1022 catMenu->insertItem( tr( "All" ), id++ );
1039 QStringList categories = m_abView->categories(); 1023 QStringList categories = m_abView->categories();
1040 categories.append( tr( "Unfiled" ) ); 1024 categories.append( tr( "Unfiled" ) );
1041 for ( QStringList::Iterator it = categories.begin(); 1025 for ( QStringList::Iterator it = categories.begin();
1042 it != categories.end(); ++it ) { 1026 it != categories.end(); ++it ) {
1043 catMenu->insertItem( *it, id ); 1027 catMenu->insertItem( *it, id );
1044 if ( *it == m_abView -> showCategory() ) 1028 if ( *it == m_abView -> showCategory() )
1045 rememberId = id; 1029 rememberId = id;
1046 ++id; 1030 ++id;
1047 } 1031 }
1048 1032
1049 1033
1050 if ( m_abView -> showCategory().isEmpty() ) { 1034 if ( m_abView -> showCategory().isEmpty() ) {
1051 slotSetCategory( 3 ); 1035 slotSetCategory( 3 );
1052 } 1036 }
1053 else { 1037 else {
1054 slotSetCategory( rememberId ); 1038 slotSetCategory( rememberId );
1055 } 1039 }
1056} 1040}
1057 1041
diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp
index 981f5e0..dee0f11 100644
--- a/core/pim/addressbook/configdlg.cpp
+++ b/core/pim/addressbook/configdlg.cpp
@@ -1,154 +1,153 @@
1#include "configdlg.h" 1#include "configdlg.h"
2 2
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qradiobutton.h> 4#include <qradiobutton.h>
5#include <qlistbox.h> 5#include <qlistbox.h>
6#include <qpushbutton.h> 6#include <qpushbutton.h>
7#include <qiconset.h>
8 7
9#include <qpe/resource.h> 8#include <qpe/resource.h>
10 9
11#include <opie/ocontact.h> 10#include <opie/ocontact.h>
12#include "opie/ocontactfields.h" 11#include "opie/ocontactfields.h"
13 12
14ConfigDlg::ConfigDlg( QWidget *parent, const char *name): 13ConfigDlg::ConfigDlg( QWidget *parent, const char *name):
15 ConfigDlg_Base(parent, name, true ) 14 ConfigDlg_Base(parent, name, true )
16{ 15{
17 contFields = OContactFields::trfields(); 16 contFields = OContactFields::trfields();
18 17
19 // We add all Fields into the Listbox 18 // We add all Fields into the Listbox
20 for (uint i=0; i < contFields.count(); i++) { 19 for (uint i=0; i < contFields.count(); i++) {
21 allFieldListBox->insertItem( contFields[i] ); 20 allFieldListBox->insertItem( contFields[i] );
22 } 21 }
23 22
24 // Reset Widget Flags: This was not changeable by designer :( 23 // Reset Widget Flags: This was not changeable by designer :(
25 setWFlags ( WStyle_ContextHelp ); 24 setWFlags ( WStyle_ContextHelp );
26 25
27 // Set Pics to Buttons and Tabs 26 // Set Pics to Buttons and Tabs
28 m_upButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/up" ) ) ); 27 m_upButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/up" ) ) );
29 m_downButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/down" ) ) ); 28 m_downButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/down" ) ) );
30 m_addButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/add" ) ) ); 29 m_addButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/add" ) ) );
31 m_removeButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/sub" ) ) ); 30 m_removeButton->setIconSet( QIconSet( Resource::loadPixmap( "addressbook/sub" ) ) );
32 31
33 32
34 // Get the translation maps between Field ID and translated strings 33 // Get the translation maps between Field ID and translated strings
35 m_mapStrToID = OContactFields::trFieldsToId(); 34 m_mapStrToID = OContactFields::trFieldsToId();
36 m_mapIDToStr = OContactFields::idToTrFields(); 35 m_mapIDToStr = OContactFields::idToTrFields();
37 36
38 connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) ); 37 connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) );
39 connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) ); 38 connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) );
40 connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) ); 39 connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) );
41 connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) ); 40 connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) );
42} 41}
43 42
44void ConfigDlg::slotItemUp() 43void ConfigDlg::slotItemUp()
45{ 44{
46 qWarning( "void ConfigDlg::slotItemUp()" ); 45 qWarning( "void ConfigDlg::slotItemUp()" );
47 46
48 int i = fieldListBox->currentItem(); 47 int i = fieldListBox->currentItem();
49 if ( i > 0 ) { 48 if ( i > 0 ) {
50 QString item = fieldListBox->currentText(); 49 QString item = fieldListBox->currentText();
51 fieldListBox->removeItem( i ); 50 fieldListBox->removeItem( i );
52 fieldListBox->insertItem( item, i-1 ); 51 fieldListBox->insertItem( item, i-1 );
53 fieldListBox->setCurrentItem( i-1 ); 52 fieldListBox->setCurrentItem( i-1 );
54 } 53 }
55 54
56} 55}
57 56
58void ConfigDlg::slotItemDown() 57void ConfigDlg::slotItemDown()
59{ 58{
60 qWarning( "void ConfigDlg::slotItemDown()" ); 59 qWarning( "void ConfigDlg::slotItemDown()" );
61 60
62 int i = fieldListBox->currentItem(); 61 int i = fieldListBox->currentItem();
63 if ( i < (int)fieldListBox->count() - 1 ) { 62 if ( i < (int)fieldListBox->count() - 1 ) {
64 QString item = fieldListBox->currentText(); 63 QString item = fieldListBox->currentText();
65 fieldListBox->removeItem( i ); 64 fieldListBox->removeItem( i );
66 fieldListBox->insertItem( item, i+1 ); 65 fieldListBox->insertItem( item, i+1 );
67 fieldListBox->setCurrentItem( i+1 ); 66 fieldListBox->setCurrentItem( i+1 );
68 } 67 }
69} 68}
70 69
71void ConfigDlg::slotItemAdd() 70void ConfigDlg::slotItemAdd()
72{ 71{
73 qWarning( "void ConfigDlg::slotItemAdd()" ); 72 qWarning( "void ConfigDlg::slotItemAdd()" );
74 73
75 int i = allFieldListBox->currentItem(); 74 int i = allFieldListBox->currentItem();
76 if ( i > 0 ) { 75 if ( i > 0 ) {
77 QString item = allFieldListBox->currentText(); 76 QString item = allFieldListBox->currentText();
78 qWarning("ADding %s", item.latin1()); 77 qWarning("ADding %s", item.latin1());
79 fieldListBox->insertItem( item ); 78 fieldListBox->insertItem( item );
80 } 79 }
81} 80}
82 81
83void ConfigDlg::slotItemRemove() 82void ConfigDlg::slotItemRemove()
84{ 83{
85 qWarning( "void ConfigDlg::slotItemRemove()" ); 84 qWarning( "void ConfigDlg::slotItemRemove()" );
86 85
87 int i = fieldListBox->currentItem(); 86 int i = fieldListBox->currentItem();
88 if ( i > 0 ) { 87 if ( i > 0 ) {
89 fieldListBox->removeItem( i ); 88 fieldListBox->removeItem( i );
90 } 89 }
91} 90}
92 91
93void ConfigDlg::setConfig( const AbConfig& cnf ) 92void ConfigDlg::setConfig( const AbConfig& cnf )
94{ 93{
95 m_config = cnf; 94 m_config = cnf;
96 95
97 m_useRegExp->setChecked( m_config.useRegExp() ); 96 m_useRegExp->setChecked( m_config.useRegExp() );
98 m_useWildCard->setChecked( m_config.useWildCards() ); 97 m_useWildCard->setChecked( m_config.useWildCards() );
99 m_useQtMail->setChecked( m_config.useQtMail() ); 98 m_useQtMail->setChecked( m_config.useQtMail() );
100 m_useOpieMail->setChecked( m_config.useOpieMail() ); 99 m_useOpieMail->setChecked( m_config.useOpieMail() );
101 m_useCaseSensitive->setChecked( m_config.beCaseSensitive() ); 100 m_useCaseSensitive->setChecked( m_config.beCaseSensitive() );
102 101
103 switch( m_config.fontSize() ){ 102 switch( m_config.fontSize() ){
104 case 0: 103 case 0:
105 m_smallFont->setChecked( true ); 104 m_smallFont->setChecked( true );
106 m_normalFont->setChecked( false ); 105 m_normalFont->setChecked( false );
107 m_largeFont->setChecked( false ); 106 m_largeFont->setChecked( false );
108 break; 107 break;
109 case 1: 108 case 1:
110 m_smallFont->setChecked( false ); 109 m_smallFont->setChecked( false );
111 m_normalFont->setChecked( true ); 110 m_normalFont->setChecked( true );
112 m_largeFont->setChecked( false ); 111 m_largeFont->setChecked( false );
113 break; 112 break;
114 case 2: 113 case 2:
115 m_smallFont->setChecked( false ); 114 m_smallFont->setChecked( false );
116 m_normalFont->setChecked( false ); 115 m_normalFont->setChecked( false );
117 m_largeFont->setChecked( true ); 116 m_largeFont->setChecked( true );
118 break; 117 break;
119 } 118 }
120 119
121 for( uint i = 0; i < m_config.orderList().count(); i++ ) { 120 for( uint i = 0; i < m_config.orderList().count(); i++ ) {
122 fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] ); 121 fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] );
123 } 122 }
124 123
125 m_fixedBars->setChecked( m_config.fixedBars() ); 124 m_fixedBars->setChecked( m_config.fixedBars() );
126 m_moveBars->setChecked( !m_config.fixedBars() ); 125 m_moveBars->setChecked( !m_config.fixedBars() );
127} 126}
128 127
129AbConfig ConfigDlg::getConfig() 128AbConfig ConfigDlg::getConfig()
130{ 129{
131 m_config.setUseRegExp( m_useRegExp->isOn() ); 130 m_config.setUseRegExp( m_useRegExp->isOn() );
132 m_config.setUseWildCards( m_useWildCard->isOn() ); 131 m_config.setUseWildCards( m_useWildCard->isOn() );
133 m_config.setUseQtMail( m_useQtMail->isOn() ); 132 m_config.setUseQtMail( m_useQtMail->isOn() );
134 m_config.setUseOpieMail( m_useOpieMail->isOn() ); 133 m_config.setUseOpieMail( m_useOpieMail->isOn() );
135 m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() ); 134 m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() );
136 135
137 if ( m_smallFont->isChecked() ) 136 if ( m_smallFont->isChecked() )
138 m_config.setFontSize( 0 ); 137 m_config.setFontSize( 0 );
139 if ( m_normalFont->isChecked() ) 138 if ( m_normalFont->isChecked() )
140 m_config.setFontSize( 1 ); 139 m_config.setFontSize( 1 );
141 if ( m_largeFont->isChecked() ) 140 if ( m_largeFont->isChecked() )
142 m_config.setFontSize( 2 ); 141 m_config.setFontSize( 2 );
143 142
144 QValueList<int> orderlist; 143 QValueList<int> orderlist;
145 for( int i = 0; i < (int)fieldListBox->count(); i++ ) { 144 for( int i = 0; i < (int)fieldListBox->count(); i++ ) {
146 orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] ); 145 orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] );
147 } 146 }
148 m_config.setOrderList( orderlist ); 147 m_config.setOrderList( orderlist );
149 148
150 m_config.setFixedBars( m_fixedBars->isChecked() ); 149 m_config.setFixedBars( m_fixedBars->isChecked() );
151 150
152 return m_config; 151 return m_config;
153} 152}
154 153
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 7932781..b1eb042 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,1757 +1,1746 @@
1/* 1/*
2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> 2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
3 * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) 3 * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
4 * 4 *
5 * This file is an add-on for the OPIE Palmtop Environment 5 * This file is an add-on for the OPIE Palmtop Environment
6 * 6 *
7 * This file may be distributed and/or modified under the terms of the 7 * This file may be distributed and/or modified under the terms of the
8 * GNU General Public License version 2 as published by the Free Software 8 * GNU General Public License version 2 as published by the Free Software
9 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging 9 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
10 * of this file. 10 * of this file.
11 * 11 *
12 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 * 14 *
15 * 15 *
16 * This is a rewrite of the abeditor.h file, modified to provide a more 16 * This is a rewrite of the abeditor.h file, modified to provide a more
17 * intuitive interface to TrollTech's original Address Book editor. This 17 * intuitive interface to TrollTech's original Address Book editor. This
18 * is made to operate exactly in interface with the exception of name. 18 * is made to operate exactly in interface with the exception of name.
19 * 19 *
20 */ 20 */
21 21
22#include "contacteditor.h" 22#include "contacteditor.h"
23#include "addresspicker.h"
24 23
25#include <qpe/categoryselect.h> 24#include <qpe/categoryselect.h>
26#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
27#include <qpe/qpedialog.h> 26#include <qpe/qpedialog.h>
28#include <qpe/timeconversion.h>
29#include <opie/ocontact.h> 27#include <opie/ocontact.h>
30#include <qpe/resource.h> 28#include <qpe/resource.h>
31 29
32#include <qcombobox.h>
33#include <qlabel.h> 30#include <qlabel.h>
34#include <qtabwidget.h> 31#include <qtabwidget.h>
35#include <qlayout.h> 32#include <qlayout.h>
36#include <qlineedit.h> 33#include <qlineedit.h>
37#include <qmultilineedit.h> 34#include <qmultilineedit.h>
38#include <qscrollview.h>
39#include <qtoolbutton.h> 35#include <qtoolbutton.h>
40#include <qpushbutton.h>
41#include <qmainwindow.h>
42#include <qvaluelist.h>
43#include <qpopupmenu.h>
44#include <qlistbox.h> 36#include <qlistbox.h>
45#include <qhbox.h>
46#include <qaction.h>
47#include <qiconset.h>
48#include <qmessagebox.h> 37#include <qmessagebox.h>
49#include <qwhatsthis.h> 38#include <qwhatsthis.h>
50 39
51#include <assert.h> 40#include <assert.h>
52 41
53static inline bool containsAlphaNum( const QString &str ); 42static inline bool containsAlphaNum( const QString &str );
54static inline bool constainsWhiteSpace( const QString &str ); 43static inline bool constainsWhiteSpace( const QString &str );
55 44
56// helper functions, convert our comma delimited list to proper 45// helper functions, convert our comma delimited list to proper
57// file format... 46// file format...
58void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 47void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
59 QString &strAll ); 48 QString &strAll );
60 49
61// helper convert from file format to comma delimited... 50// helper convert from file format to comma delimited...
62void parseEmailTo( const QString &strDefaultEmail, 51void parseEmailTo( const QString &strDefaultEmail,
63 const QString &strOtherEmail, QString &strBack ); 52 const QString &strOtherEmail, QString &strBack );
64 53
65 ContactEditor::ContactEditor(const OContact &entry, 54 ContactEditor::ContactEditor(const OContact &entry,
66 QWidget *parent, 55 QWidget *parent,
67 const char *name, 56 const char *name,
68 WFlags ) 57 WFlags )
69 : QDialog( parent, name, TRUE, WStyle_ContextHelp ), 58 : QDialog( parent, name, TRUE, WStyle_ContextHelp ),
70 defaultEmailChooserPosition( -1 ), 59 defaultEmailChooserPosition( -1 ),
71 m_personalView ( false ), 60 m_personalView ( false ),
72 cmbDefaultEmail( 0 ), 61 cmbDefaultEmail( 0 ),
73 initializing ( false ) 62 initializing ( false )
74{ 63{
75 64
76 initializing = true; 65 initializing = true;
77 66
78 init(); 67 init();
79 setEntry( entry ); 68 setEntry( entry );
80 // cmbDefaultEmail = 0; 69 // cmbDefaultEmail = 0;
81 // defaultEmailChooserPosition = -1; 70 // defaultEmailChooserPosition = -1;
82 71
83 initializing = false; 72 initializing = false;
84} 73}
85 74
86ContactEditor::~ContactEditor() { 75ContactEditor::~ContactEditor() {
87} 76}
88 77
89void ContactEditor::init() { 78void ContactEditor::init() {
90 qWarning("init() START"); 79 qWarning("init() START");
91 80
92 uint i = 0; 81 uint i = 0;
93 82
94 QStringList trlChooserNames; 83 QStringList trlChooserNames;
95 84
96 for (i = 0; i <= 6; i++) { 85 for (i = 0; i <= 6; i++) {
97 slHomeAddress.append( "" ); 86 slHomeAddress.append( "" );
98 slBusinessAddress.append( "" ); 87 slBusinessAddress.append( "" );
99 } 88 }
100 89
101 trlChooserNames = OContactFields::trphonefields( false ); 90 trlChooserNames = OContactFields::trphonefields( false );
102 slChooserNames = OContactFields::untrphonefields( false ); 91 slChooserNames = OContactFields::untrphonefields( false );
103 slDynamicEntries = OContactFields::untrdetailsfields( false ); 92 slDynamicEntries = OContactFields::untrdetailsfields( false );
104 trlDynamicEntries = OContactFields::trdetailsfields( false ); 93 trlDynamicEntries = OContactFields::trdetailsfields( false );
105 94
106 // Ok, we have to remove elements from the list of dynamic entries 95 // Ok, we have to remove elements from the list of dynamic entries
107 // which are now stored in special (not dynamic) widgets.. 96 // which are now stored in special (not dynamic) widgets..
108 // Otherwise we will get problems with field assignments! (se) 97 // Otherwise we will get problems with field assignments! (se)
109 slDynamicEntries.remove("Anniversary"); 98 slDynamicEntries.remove("Anniversary");
110 slDynamicEntries.remove("Birthday"); 99 slDynamicEntries.remove("Birthday");
111 slDynamicEntries.remove("Gender"); 100 slDynamicEntries.remove("Gender");
112 101
113 // The same with translated fields.. But I will 102 // The same with translated fields.. But I will
114 // use the translation map to avoid mismatches.. 103 // use the translation map to avoid mismatches..
115 QMap<int, QString> translMap = OContactFields::idToTrFields(); 104 QMap<int, QString> translMap = OContactFields::idToTrFields();
116 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); 105 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] );
117 trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); 106 trlDynamicEntries.remove( translMap[Qtopia::Birthday] );
118 trlDynamicEntries.remove( translMap[Qtopia::Gender] ); 107 trlDynamicEntries.remove( translMap[Qtopia::Gender] );
119 108
120 // Last Check to be sure.. 109 // Last Check to be sure..
121 assert( slDynamicEntries.count() == trlDynamicEntries.count() ); 110 assert( slDynamicEntries.count() == trlDynamicEntries.count() );
122 assert( slChooserNames.count() == trlChooserNames.count() ); 111 assert( slChooserNames.count() == trlChooserNames.count() );
123 112
124 for (i = 0; i < slChooserNames.count(); i++) 113 for (i = 0; i < slChooserNames.count(); i++)
125 slChooserValues.append(""); 114 slChooserValues.append("");
126 115
127 116
128 QVBoxLayout *vb = new QVBoxLayout( this ); 117 QVBoxLayout *vb = new QVBoxLayout( this );
129 118
130 tabMain = new QTabWidget( this ); 119 tabMain = new QTabWidget( this );
131 vb->addWidget( tabMain ); 120 vb->addWidget( tabMain );
132 121
133 QWidget *tabViewport = new QWidget ( tabMain ); 122 QWidget *tabViewport = new QWidget ( tabMain );
134 123
135 vb = new QVBoxLayout( tabViewport ); 124 vb = new QVBoxLayout( tabViewport );
136 125
137 svGeneral = new QScrollView( tabViewport ); 126 svGeneral = new QScrollView( tabViewport );
138 vb->addWidget( svGeneral, 0, 0 ); 127 vb->addWidget( svGeneral, 0, 0 );
139 svGeneral->setResizePolicy( QScrollView::AutoOneFit ); 128 svGeneral->setResizePolicy( QScrollView::AutoOneFit );
140 // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff ); 129 // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff );
141 // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff ); 130 // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff );
142 svGeneral->setFrameStyle( QFrame::NoFrame ); 131 svGeneral->setFrameStyle( QFrame::NoFrame );
143 132
144 QWidget *container = new QWidget( svGeneral->viewport() ); 133 QWidget *container = new QWidget( svGeneral->viewport() );
145 svGeneral->addChild( container ); 134 svGeneral->addChild( container );
146 135
147 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); 136 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 );
148 gl->setResizeMode( QLayout::FreeResize ); 137 gl->setResizeMode( QLayout::FreeResize );
149 138
150 btnFullName = new QPushButton( tr( "Full Name..." ), container ); 139 btnFullName = new QPushButton( tr( "Full Name..." ), container );
151 QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) ); 140 QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) );
152 gl->addWidget( btnFullName, 0, 0 ); 141 gl->addWidget( btnFullName, 0, 0 );
153 txtFullName = new QLineEdit( container ); 142 txtFullName = new QLineEdit( container );
154 QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) ); 143 QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) );
155 gl->addWidget( txtFullName, 0, 1 ); 144 gl->addWidget( txtFullName, 0, 1 );
156 145
157 QLabel *l = new QLabel( tr( "Job Title" ), container ); 146 QLabel *l = new QLabel( tr( "Job Title" ), container );
158 QWhatsThis::add( l, tr( "The jobtitle.." ) ); 147 QWhatsThis::add( l, tr( "The jobtitle.." ) );
159 gl->addWidget( l, 1, 0 ); 148 gl->addWidget( l, 1, 0 );
160 txtJobTitle = new QLineEdit( container ); 149 txtJobTitle = new QLineEdit( container );
161 QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) ); 150 QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) );
162 gl->addWidget( txtJobTitle, 1, 1 ); 151 gl->addWidget( txtJobTitle, 1, 1 );
163 152
164 l = new QLabel( tr("Suffix"), container ); 153 l = new QLabel( tr("Suffix"), container );
165 QWhatsThis::add( l, tr( "Something like \"jr.\".." ) ); 154 QWhatsThis::add( l, tr( "Something like \"jr.\".." ) );
166 gl->addWidget( l, 2, 0 ); 155 gl->addWidget( l, 2, 0 );
167 txtSuffix = new QLineEdit( container ); 156 txtSuffix = new QLineEdit( container );
168 QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) ); 157 QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) );
169 gl->addWidget( txtSuffix, 2, 1 ); 158 gl->addWidget( txtSuffix, 2, 1 );
170 159
171 l = new QLabel( tr( "Organization" ), container ); 160 l = new QLabel( tr( "Organization" ), container );
172 QWhatsThis::add( l, tr( "The working place of the contact" ) ); 161 QWhatsThis::add( l, tr( "The working place of the contact" ) );
173 gl->addWidget( l, 3, 0 ); 162 gl->addWidget( l, 3, 0 );
174 txtOrganization = new QLineEdit( container ); 163 txtOrganization = new QLineEdit( container );
175 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) ); 164 QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) );
176 gl->addWidget( txtOrganization, 3, 1 ); 165 gl->addWidget( txtOrganization, 3, 1 );
177 166
178 // Chooser 1 167 // Chooser 1
179 cmbChooserField1 = new QComboBox( FALSE, container ); 168 cmbChooserField1 = new QComboBox( FALSE, container );
180 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) ); 169 QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) );
181 cmbChooserField1->setMaximumWidth( 90 ); 170 cmbChooserField1->setMaximumWidth( 90 );
182 gl->addWidget( cmbChooserField1, 4, 0 ); 171 gl->addWidget( cmbChooserField1, 4, 0 );
183 // Textfield for chooser 1. 172 // Textfield for chooser 1.
184 // Now use Widgetstack to contain the textfield and the default-email combo ! 173 // Now use Widgetstack to contain the textfield and the default-email combo !
185 m_widgetStack1 = new QWidgetStack( container ); 174 m_widgetStack1 = new QWidgetStack( container );
186 txtChooserField1 = new QLineEdit( m_widgetStack1 ); 175 txtChooserField1 = new QLineEdit( m_widgetStack1 );
187 m_widgetStack1 -> addWidget( txtChooserField1, TextField ); 176 m_widgetStack1 -> addWidget( txtChooserField1, TextField );
188 gl->addWidget( m_widgetStack1, 4, 1 ); 177 gl->addWidget( m_widgetStack1, 4, 1 );
189 m_widgetStack1 -> raiseWidget( TextField ); 178 m_widgetStack1 -> raiseWidget( TextField );
190 179
191 // Chooser 2 180 // Chooser 2
192 cmbChooserField2 = new QComboBox( FALSE, container ); 181 cmbChooserField2 = new QComboBox( FALSE, container );
193 QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) ); 182 QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) );
194 cmbChooserField2->setMaximumWidth( 90 ); 183 cmbChooserField2->setMaximumWidth( 90 );
195 gl->addWidget( cmbChooserField2, 5, 0 ); 184 gl->addWidget( cmbChooserField2, 5, 0 );
196 // Textfield for chooser 2 185 // Textfield for chooser 2
197 // Now use WidgetStack to contain the textfield and the default-email combo! 186 // Now use WidgetStack to contain the textfield and the default-email combo!
198 m_widgetStack2 = new QWidgetStack( container ); 187 m_widgetStack2 = new QWidgetStack( container );
199 txtChooserField2 = new QLineEdit( m_widgetStack2 ); 188 txtChooserField2 = new QLineEdit( m_widgetStack2 );
200 m_widgetStack2 -> addWidget( txtChooserField2, TextField ); 189 m_widgetStack2 -> addWidget( txtChooserField2, TextField );
201 gl->addWidget( m_widgetStack2, 5, 1 ); 190 gl->addWidget( m_widgetStack2, 5, 1 );
202 m_widgetStack2 -> raiseWidget( TextField ); 191 m_widgetStack2 -> raiseWidget( TextField );
203 192
204 // Chooser 3 193 // Chooser 3
205 cmbChooserField3 = new QComboBox( FALSE, container ); 194 cmbChooserField3 = new QComboBox( FALSE, container );
206 QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) ); 195 QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) );
207 cmbChooserField3->setMaximumWidth( 90 ); 196 cmbChooserField3->setMaximumWidth( 90 );
208 gl->addWidget( cmbChooserField3, 6, 0 ); 197 gl->addWidget( cmbChooserField3, 6, 0 );
209 // Textfield for chooser 2 198 // Textfield for chooser 2
210 // Now use WidgetStack to contain the textfield and the default-email combo! 199 // Now use WidgetStack to contain the textfield and the default-email combo!
211 m_widgetStack3 = new QWidgetStack( container ); 200 m_widgetStack3 = new QWidgetStack( container );
212 txtChooserField3 = new QLineEdit( m_widgetStack3 ); 201 txtChooserField3 = new QLineEdit( m_widgetStack3 );
213 m_widgetStack3 -> addWidget( txtChooserField3, TextField ); 202 m_widgetStack3 -> addWidget( txtChooserField3, TextField );
214 gl->addWidget( m_widgetStack3, 6, 1 ); 203 gl->addWidget( m_widgetStack3, 6, 1 );
215 m_widgetStack3 -> raiseWidget( TextField ); 204 m_widgetStack3 -> raiseWidget( TextField );
216 205
217 l = new QLabel( tr( "File As" ), container ); 206 l = new QLabel( tr( "File As" ), container );
218 QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) ); 207 QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) );
219 gl->addWidget( l, 7, 0 ); 208 gl->addWidget( l, 7, 0 );
220 cmbFileAs = new QComboBox( TRUE, container ); 209 cmbFileAs = new QComboBox( TRUE, container );
221 gl->addWidget( cmbFileAs, 7, 1 ); 210 gl->addWidget( cmbFileAs, 7, 1 );
222 211
223 labCat = new QLabel( tr( "Category" ), container ); 212 labCat = new QLabel( tr( "Category" ), container );
224 gl->addWidget( labCat, 8, 0 ); 213 gl->addWidget( labCat, 8, 0 );
225 cmbCat = new CategorySelect( container ); 214 cmbCat = new CategorySelect( container );
226 gl->addWidget( cmbCat, 8, 1 ); 215 gl->addWidget( cmbCat, 8, 1 );
227 labCat->show(); 216 labCat->show();
228 cmbCat->show(); 217 cmbCat->show();
229 218
230 btnNote = new QPushButton( tr( "Notes..." ), container ); 219 btnNote = new QPushButton( tr( "Notes..." ), container );
231 gl->addWidget( btnNote, 9, 1 ); 220 gl->addWidget( btnNote, 9, 1 );
232 221
233 tabMain->insertTab( tabViewport, tr( "General" ) ); 222 tabMain->insertTab( tabViewport, tr( "General" ) );
234 223
235 tabViewport = new QWidget ( tabMain ); 224 tabViewport = new QWidget ( tabMain );
236 225
237 vb = new QVBoxLayout( tabViewport ); 226 vb = new QVBoxLayout( tabViewport );
238 227
239 svAddress = new QScrollView( tabViewport ); 228 svAddress = new QScrollView( tabViewport );
240 vb->addWidget( svAddress, 0, 0 ); 229 vb->addWidget( svAddress, 0, 0 );
241 svAddress->setResizePolicy( QScrollView::AutoOneFit ); 230 svAddress->setResizePolicy( QScrollView::AutoOneFit );
242 svAddress->setFrameStyle( QFrame::NoFrame ); 231 svAddress->setFrameStyle( QFrame::NoFrame );
243 232
244 container = new QWidget( svAddress->viewport() ); 233 container = new QWidget( svAddress->viewport() );
245 svAddress->addChild( container ); 234 svAddress->addChild( container );
246 235
247 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem 236 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem
248 237
249 cmbAddress = new QComboBox( FALSE, container ); 238 cmbAddress = new QComboBox( FALSE, container );
250 cmbAddress->insertItem( tr( "Business" ) ); 239 cmbAddress->insertItem( tr( "Business" ) );
251 cmbAddress->insertItem( tr( "Home" ) ); 240 cmbAddress->insertItem( tr( "Home" ) );
252 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); 241 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 );
253 242
254 l = new QLabel( tr( "Address" ), container ); 243 l = new QLabel( tr( "Address" ), container );
255 gl->addWidget( l, 1, 0 ); 244 gl->addWidget( l, 1, 0 );
256 txtAddress = new QLineEdit( container ); 245 txtAddress = new QLineEdit( container );
257 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); 246 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 );
258 247
259 l = new QLabel( tr( "City" ), container ); 248 l = new QLabel( tr( "City" ), container );
260 gl->addWidget( l, 2, 0 ); 249 gl->addWidget( l, 2, 0 );
261 txtCity = new QLineEdit( container ); 250 txtCity = new QLineEdit( container );
262 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); 251 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 );
263 252
264 l = new QLabel( tr( "State" ), container ); 253 l = new QLabel( tr( "State" ), container );
265 gl->addWidget( l, 3, 0 ); 254 gl->addWidget( l, 3, 0 );
266 txtState = new QLineEdit( container ); 255 txtState = new QLineEdit( container );
267 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); 256 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 );
268 257
269 l = new QLabel( tr( "Zip Code" ), container ); 258 l = new QLabel( tr( "Zip Code" ), container );
270 gl->addWidget( l, 4, 0 ); 259 gl->addWidget( l, 4, 0 );
271 txtZip = new QLineEdit( container ); 260 txtZip = new QLineEdit( container );
272 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); 261 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 );
273 262
274 l = new QLabel( tr( "Country" ), container ); 263 l = new QLabel( tr( "Country" ), container );
275 gl->addWidget( l, 5, 0 ); 264 gl->addWidget( l, 5, 0 );
276 cmbCountry = new QComboBox( TRUE, container ); 265 cmbCountry = new QComboBox( TRUE, container );
277 cmbCountry->insertItem( tr( "" ) ); 266 cmbCountry->insertItem( tr( "" ) );
278 cmbCountry->insertItem( tr ( "United States" ) ); 267 cmbCountry->insertItem( tr ( "United States" ) );
279 cmbCountry->insertItem( tr ( "United Kingdom" ) ); 268 cmbCountry->insertItem( tr ( "United Kingdom" ) );
280 cmbCountry->insertItem( tr ( "Afghanistan" ) ); 269 cmbCountry->insertItem( tr ( "Afghanistan" ) );
281 cmbCountry->insertItem( tr ( "Albania" ) ); 270 cmbCountry->insertItem( tr ( "Albania" ) );
282 cmbCountry->insertItem( tr ( "Algeria" ) ); 271 cmbCountry->insertItem( tr ( "Algeria" ) );
283 cmbCountry->insertItem( tr ( "American Samoa" ) ); 272 cmbCountry->insertItem( tr ( "American Samoa" ) );
284 cmbCountry->insertItem( tr ( "Andorra" ) ); 273 cmbCountry->insertItem( tr ( "Andorra" ) );
285 cmbCountry->insertItem( tr ( "Angola" ) ); 274 cmbCountry->insertItem( tr ( "Angola" ) );
286 cmbCountry->insertItem( tr ( "Anguilla" ) ); 275 cmbCountry->insertItem( tr ( "Anguilla" ) );
287 cmbCountry->insertItem( tr ( "Antarctica" ) ); 276 cmbCountry->insertItem( tr ( "Antarctica" ) );
288 cmbCountry->insertItem( tr ( "Argentina" ) ); 277 cmbCountry->insertItem( tr ( "Argentina" ) );
289 cmbCountry->insertItem( tr ( "Armenia" ) ); 278 cmbCountry->insertItem( tr ( "Armenia" ) );
290 cmbCountry->insertItem( tr ( "Aruba" ) ); 279 cmbCountry->insertItem( tr ( "Aruba" ) );
291 cmbCountry->insertItem( tr ( "Australia" ) ); 280 cmbCountry->insertItem( tr ( "Australia" ) );
292 cmbCountry->insertItem( tr ( "Austria" ) ); 281 cmbCountry->insertItem( tr ( "Austria" ) );
293 cmbCountry->insertItem( tr ( "Azerbaijan" ) ); 282 cmbCountry->insertItem( tr ( "Azerbaijan" ) );
294 cmbCountry->insertItem( tr ( "Bahamas" ) ); 283 cmbCountry->insertItem( tr ( "Bahamas" ) );
295 cmbCountry->insertItem( tr ( "Bahrain" ) ); 284 cmbCountry->insertItem( tr ( "Bahrain" ) );
296 cmbCountry->insertItem( tr ( "Bangladesh" ) ); 285 cmbCountry->insertItem( tr ( "Bangladesh" ) );
297 cmbCountry->insertItem( tr ( "Barbados" ) ); 286 cmbCountry->insertItem( tr ( "Barbados" ) );
298 cmbCountry->insertItem( tr ( "Belarus" ) ); 287 cmbCountry->insertItem( tr ( "Belarus" ) );
299 cmbCountry->insertItem( tr ( "Belgium" ) ); 288 cmbCountry->insertItem( tr ( "Belgium" ) );
300 cmbCountry->insertItem( tr ( "Belize" ) ); 289 cmbCountry->insertItem( tr ( "Belize" ) );
301 cmbCountry->insertItem( tr ( "Benin" ) ); 290 cmbCountry->insertItem( tr ( "Benin" ) );
302 cmbCountry->insertItem( tr ( "Bermuda" ) ); 291 cmbCountry->insertItem( tr ( "Bermuda" ) );
303 cmbCountry->insertItem( tr ( "Bhutan" ) ); 292 cmbCountry->insertItem( tr ( "Bhutan" ) );
304 cmbCountry->insertItem( tr ( "Bolivia" ) ); 293 cmbCountry->insertItem( tr ( "Bolivia" ) );
305 cmbCountry->insertItem( tr ( "Botswana" ) ); 294 cmbCountry->insertItem( tr ( "Botswana" ) );
306 cmbCountry->insertItem( tr ( "Bouvet Island" ) ); 295 cmbCountry->insertItem( tr ( "Bouvet Island" ) );
307 cmbCountry->insertItem( tr ( "Brazil" ) ); 296 cmbCountry->insertItem( tr ( "Brazil" ) );
308 cmbCountry->insertItem( tr ( "Brunei Darussalam" ) ); 297 cmbCountry->insertItem( tr ( "Brunei Darussalam" ) );
309 cmbCountry->insertItem( tr ( "Bulgaria" ) ); 298 cmbCountry->insertItem( tr ( "Bulgaria" ) );
310 cmbCountry->insertItem( tr ( "Burkina Faso" ) ); 299 cmbCountry->insertItem( tr ( "Burkina Faso" ) );
311 cmbCountry->insertItem( tr ( "Burundi" ) ); 300 cmbCountry->insertItem( tr ( "Burundi" ) );
312 cmbCountry->insertItem( tr ( "Cambodia" ) ); 301 cmbCountry->insertItem( tr ( "Cambodia" ) );
313 cmbCountry->insertItem( tr ( "Cameroon" ) ); 302 cmbCountry->insertItem( tr ( "Cameroon" ) );
314 cmbCountry->insertItem( tr ( "Canada" ) ); 303 cmbCountry->insertItem( tr ( "Canada" ) );
315 cmbCountry->insertItem( tr ( "Cape Verde" ) ); 304 cmbCountry->insertItem( tr ( "Cape Verde" ) );
316 cmbCountry->insertItem( tr ( "Cayman Islands" ) ); 305 cmbCountry->insertItem( tr ( "Cayman Islands" ) );
317 cmbCountry->insertItem( tr ( "Chad" ) ); 306 cmbCountry->insertItem( tr ( "Chad" ) );
318 cmbCountry->insertItem( tr ( "Chile" ) ); 307 cmbCountry->insertItem( tr ( "Chile" ) );
319 cmbCountry->insertItem( tr ( "China" ) ); 308 cmbCountry->insertItem( tr ( "China" ) );
320 cmbCountry->insertItem( tr ( "Christmas Island" ) ); 309 cmbCountry->insertItem( tr ( "Christmas Island" ) );
321 cmbCountry->insertItem( tr ( "Colombia" ) ); 310 cmbCountry->insertItem( tr ( "Colombia" ) );
322 cmbCountry->insertItem( tr ( "Comoros" ) ); 311 cmbCountry->insertItem( tr ( "Comoros" ) );
323 cmbCountry->insertItem( tr ( "Congo" ) ); 312 cmbCountry->insertItem( tr ( "Congo" ) );
324 cmbCountry->insertItem( tr ( "Cook Island" ) ); 313 cmbCountry->insertItem( tr ( "Cook Island" ) );
325 cmbCountry->insertItem( tr ( "Costa Rica" ) ); 314 cmbCountry->insertItem( tr ( "Costa Rica" ) );
326 cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) ); 315 cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) );
327 cmbCountry->insertItem( tr ( "Croatia" ) ); 316 cmbCountry->insertItem( tr ( "Croatia" ) );
328 cmbCountry->insertItem( tr ( "Cuba" ) ); 317 cmbCountry->insertItem( tr ( "Cuba" ) );
329 cmbCountry->insertItem( tr ( "Cyprus" ) ); 318 cmbCountry->insertItem( tr ( "Cyprus" ) );
330 cmbCountry->insertItem( tr ( "Czech Republic" ) ); 319 cmbCountry->insertItem( tr ( "Czech Republic" ) );
331 cmbCountry->insertItem( tr ( "Denmark" ) ); 320 cmbCountry->insertItem( tr ( "Denmark" ) );
332 cmbCountry->insertItem( tr ( "Djibouti" ) ); 321 cmbCountry->insertItem( tr ( "Djibouti" ) );
333 cmbCountry->insertItem( tr ( "Dominica" ) ); 322 cmbCountry->insertItem( tr ( "Dominica" ) );
334 cmbCountry->insertItem( tr ( "Dominican Republic" ) ); 323 cmbCountry->insertItem( tr ( "Dominican Republic" ) );
335 cmbCountry->insertItem( tr ( "East Timor" ) ); 324 cmbCountry->insertItem( tr ( "East Timor" ) );
336 cmbCountry->insertItem( tr ( "Ecuador" ) ); 325 cmbCountry->insertItem( tr ( "Ecuador" ) );
337 cmbCountry->insertItem( tr ( "Egypt" ) ); 326 cmbCountry->insertItem( tr ( "Egypt" ) );
338 cmbCountry->insertItem( tr ( "El Salvador" ) ); 327 cmbCountry->insertItem( tr ( "El Salvador" ) );
339 cmbCountry->insertItem( tr ( "Equatorial Guinea" ) ); 328 cmbCountry->insertItem( tr ( "Equatorial Guinea" ) );
340 cmbCountry->insertItem( tr ( "Eritrea" ) ); 329 cmbCountry->insertItem( tr ( "Eritrea" ) );
341 cmbCountry->insertItem( tr ( "Estonia" ) ); 330 cmbCountry->insertItem( tr ( "Estonia" ) );
342 cmbCountry->insertItem( tr ( "Ethiopia" ) ); 331 cmbCountry->insertItem( tr ( "Ethiopia" ) );
343 cmbCountry->insertItem( tr ( "Falkland Islands" ) ); 332 cmbCountry->insertItem( tr ( "Falkland Islands" ) );
344 cmbCountry->insertItem( tr ( "Faroe Islands" ) ); 333 cmbCountry->insertItem( tr ( "Faroe Islands" ) );
345 cmbCountry->insertItem( tr ( "Fiji" ) ); 334 cmbCountry->insertItem( tr ( "Fiji" ) );
346 cmbCountry->insertItem( tr ( "Finland" ) ); 335 cmbCountry->insertItem( tr ( "Finland" ) );
347 cmbCountry->insertItem( tr ( "France" ) ); 336 cmbCountry->insertItem( tr ( "France" ) );
348 cmbCountry->insertItem( tr ( "French Guiana" ) ); 337 cmbCountry->insertItem( tr ( "French Guiana" ) );
349 cmbCountry->insertItem( tr ( "French Polynesia" ) ); 338 cmbCountry->insertItem( tr ( "French Polynesia" ) );
350 cmbCountry->insertItem( tr ( "Gabon" ) ); 339 cmbCountry->insertItem( tr ( "Gabon" ) );
351 cmbCountry->insertItem( tr ( "Gambia" ) ); 340 cmbCountry->insertItem( tr ( "Gambia" ) );
352 cmbCountry->insertItem( tr ( "Georgia" ) ); 341 cmbCountry->insertItem( tr ( "Georgia" ) );
353 cmbCountry->insertItem( tr ( "Germany" ) ); 342 cmbCountry->insertItem( tr ( "Germany" ) );
354 cmbCountry->insertItem( tr ( "Ghana" ) ); 343 cmbCountry->insertItem( tr ( "Ghana" ) );
355 cmbCountry->insertItem( tr ( "Gibraltar" ) ); 344 cmbCountry->insertItem( tr ( "Gibraltar" ) );
356 cmbCountry->insertItem( tr ( "Greece" ) ); 345 cmbCountry->insertItem( tr ( "Greece" ) );
357 cmbCountry->insertItem( tr ( "Greenland" ) ); 346 cmbCountry->insertItem( tr ( "Greenland" ) );
358 cmbCountry->insertItem( tr ( "Grenada" ) ); 347 cmbCountry->insertItem( tr ( "Grenada" ) );
359 cmbCountry->insertItem( tr ( "Guadeloupe" ) ); 348 cmbCountry->insertItem( tr ( "Guadeloupe" ) );
360 cmbCountry->insertItem( tr ( "Guam" ) ); 349 cmbCountry->insertItem( tr ( "Guam" ) );
361 cmbCountry->insertItem( tr ( "Guatemala" ) ); 350 cmbCountry->insertItem( tr ( "Guatemala" ) );
362 cmbCountry->insertItem( tr ( "Guinea" ) ); 351 cmbCountry->insertItem( tr ( "Guinea" ) );
363 cmbCountry->insertItem( tr ( "Guinea-Bissau" ) ); 352 cmbCountry->insertItem( tr ( "Guinea-Bissau" ) );
364 cmbCountry->insertItem( tr ( "Guyana" ) ); 353 cmbCountry->insertItem( tr ( "Guyana" ) );
365 cmbCountry->insertItem( tr ( "Haiti" ) ); 354 cmbCountry->insertItem( tr ( "Haiti" ) );
366 cmbCountry->insertItem( tr ( "Holy See" ) ); 355 cmbCountry->insertItem( tr ( "Holy See" ) );
367 cmbCountry->insertItem( tr ( "Honduras" ) ); 356 cmbCountry->insertItem( tr ( "Honduras" ) );
368 cmbCountry->insertItem( tr ( "Hong Kong" ) ); 357 cmbCountry->insertItem( tr ( "Hong Kong" ) );
369 cmbCountry->insertItem( tr ( "Hungary" ) ); 358 cmbCountry->insertItem( tr ( "Hungary" ) );
370 cmbCountry->insertItem( tr ( "Iceland" ) ); 359 cmbCountry->insertItem( tr ( "Iceland" ) );
371 cmbCountry->insertItem( tr ( "India" ) ); 360 cmbCountry->insertItem( tr ( "India" ) );
372 cmbCountry->insertItem( tr ( "Indonesia" ) ); 361 cmbCountry->insertItem( tr ( "Indonesia" ) );
373 cmbCountry->insertItem( tr ( "Ireland" ) ); 362 cmbCountry->insertItem( tr ( "Ireland" ) );
374 cmbCountry->insertItem( tr ( "Israel" ) ); 363 cmbCountry->insertItem( tr ( "Israel" ) );
375 cmbCountry->insertItem( tr ( "Italy" ) ); 364 cmbCountry->insertItem( tr ( "Italy" ) );
376 cmbCountry->insertItem( tr ( "Jamaica" ) ); 365 cmbCountry->insertItem( tr ( "Jamaica" ) );
377 cmbCountry->insertItem( tr ( "Japan" ) ); 366 cmbCountry->insertItem( tr ( "Japan" ) );
378 cmbCountry->insertItem( tr ( "Jordan" ) ); 367 cmbCountry->insertItem( tr ( "Jordan" ) );
379 cmbCountry->insertItem( tr ( "Kazakhstan" ) ); 368 cmbCountry->insertItem( tr ( "Kazakhstan" ) );
380 cmbCountry->insertItem( tr ( "Kenya" ) ); 369 cmbCountry->insertItem( tr ( "Kenya" ) );
381 cmbCountry->insertItem( tr ( "Kiribati" ) ); 370 cmbCountry->insertItem( tr ( "Kiribati" ) );
382 cmbCountry->insertItem( tr ( "Korea" ) ); 371 cmbCountry->insertItem( tr ( "Korea" ) );
383 cmbCountry->insertItem( tr ( "Kuwait" ) ); 372 cmbCountry->insertItem( tr ( "Kuwait" ) );
384 cmbCountry->insertItem( tr ( "Kyrgyzstan" ) ); 373 cmbCountry->insertItem( tr ( "Kyrgyzstan" ) );
385 cmbCountry->insertItem( tr ( "Laos" ) ); 374 cmbCountry->insertItem( tr ( "Laos" ) );
386 cmbCountry->insertItem( tr ( "Latvia" ) ); 375 cmbCountry->insertItem( tr ( "Latvia" ) );
387 cmbCountry->insertItem( tr ( "Lebanon" ) ); 376 cmbCountry->insertItem( tr ( "Lebanon" ) );
388 cmbCountry->insertItem( tr ( "Lesotho" ) ); 377 cmbCountry->insertItem( tr ( "Lesotho" ) );
389 cmbCountry->insertItem( tr ( "Liberia" ) ); 378 cmbCountry->insertItem( tr ( "Liberia" ) );
390 cmbCountry->insertItem( tr ( "Liechtenstein" ) ); 379 cmbCountry->insertItem( tr ( "Liechtenstein" ) );
391 cmbCountry->insertItem( tr ( "Lithuania" ) ); 380 cmbCountry->insertItem( tr ( "Lithuania" ) );
392 cmbCountry->insertItem( tr ( "Luxembourg" ) ); 381 cmbCountry->insertItem( tr ( "Luxembourg" ) );
393 cmbCountry->insertItem( tr ( "Macau" ) ); 382 cmbCountry->insertItem( tr ( "Macau" ) );
394 cmbCountry->insertItem( tr ( "Macedonia" ) ); 383 cmbCountry->insertItem( tr ( "Macedonia" ) );
395 cmbCountry->insertItem( tr ( "Madagascar" ) ); 384 cmbCountry->insertItem( tr ( "Madagascar" ) );
396 cmbCountry->insertItem( tr ( "Malawi" ) ); 385 cmbCountry->insertItem( tr ( "Malawi" ) );
397 cmbCountry->insertItem( tr ( "Malaysia" ) ); 386 cmbCountry->insertItem( tr ( "Malaysia" ) );
398 cmbCountry->insertItem( tr ( "Maldives" ) ); 387 cmbCountry->insertItem( tr ( "Maldives" ) );
399 cmbCountry->insertItem( tr ( "Mali" ) ); 388 cmbCountry->insertItem( tr ( "Mali" ) );
400 cmbCountry->insertItem( tr ( "Malta" ) ); 389 cmbCountry->insertItem( tr ( "Malta" ) );
401 cmbCountry->insertItem( tr ( "Martinique" ) ); 390 cmbCountry->insertItem( tr ( "Martinique" ) );
402 cmbCountry->insertItem( tr ( "Mauritania" ) ); 391 cmbCountry->insertItem( tr ( "Mauritania" ) );
403 cmbCountry->insertItem( tr ( "Mauritius" ) ); 392 cmbCountry->insertItem( tr ( "Mauritius" ) );
404 cmbCountry->insertItem( tr ( "Mayotte" ) ); 393 cmbCountry->insertItem( tr ( "Mayotte" ) );
405 cmbCountry->insertItem( tr ( "Mexico" ) ); 394 cmbCountry->insertItem( tr ( "Mexico" ) );
406 cmbCountry->insertItem( tr ( "Micronesia" ) ); 395 cmbCountry->insertItem( tr ( "Micronesia" ) );
407 cmbCountry->insertItem( tr ( "Moldova" ) ); 396 cmbCountry->insertItem( tr ( "Moldova" ) );
408 cmbCountry->insertItem( tr ( "Monaco" ) ); 397 cmbCountry->insertItem( tr ( "Monaco" ) );
409 cmbCountry->insertItem( tr ( "Mongolia" ) ); 398 cmbCountry->insertItem( tr ( "Mongolia" ) );
410 cmbCountry->insertItem( tr ( "Montserrat" ) ); 399 cmbCountry->insertItem( tr ( "Montserrat" ) );
411 cmbCountry->insertItem( tr ( "Morocco" ) ); 400 cmbCountry->insertItem( tr ( "Morocco" ) );
412 cmbCountry->insertItem( tr ( "Mozambique" ) ); 401 cmbCountry->insertItem( tr ( "Mozambique" ) );
413 cmbCountry->insertItem( tr ( "Myanmar" ) ); 402 cmbCountry->insertItem( tr ( "Myanmar" ) );
414 cmbCountry->insertItem( tr ( "Namibia" ) ); 403 cmbCountry->insertItem( tr ( "Namibia" ) );
415 cmbCountry->insertItem( tr ( "Nauru" ) ); 404 cmbCountry->insertItem( tr ( "Nauru" ) );
416 cmbCountry->insertItem( tr ( "Nepal" ) ); 405 cmbCountry->insertItem( tr ( "Nepal" ) );
417 cmbCountry->insertItem( tr ( "Netherlands" ) ); 406 cmbCountry->insertItem( tr ( "Netherlands" ) );
418 cmbCountry->insertItem( tr ( "New Caledonia" ) ); 407 cmbCountry->insertItem( tr ( "New Caledonia" ) );
419 cmbCountry->insertItem( tr ( "New Zealand" ) ); 408 cmbCountry->insertItem( tr ( "New Zealand" ) );
420 cmbCountry->insertItem( tr ( "Nicaragua" ) ); 409 cmbCountry->insertItem( tr ( "Nicaragua" ) );
421 cmbCountry->insertItem( tr ( "Niger" ) ); 410 cmbCountry->insertItem( tr ( "Niger" ) );
422 cmbCountry->insertItem( tr ( "Nigeria" ) ); 411 cmbCountry->insertItem( tr ( "Nigeria" ) );
423 cmbCountry->insertItem( tr ( "Niue" ) ); 412 cmbCountry->insertItem( tr ( "Niue" ) );
424 cmbCountry->insertItem( tr ( "Norway" ) ); 413 cmbCountry->insertItem( tr ( "Norway" ) );
425 cmbCountry->insertItem( tr ( "Oman" ) ); 414 cmbCountry->insertItem( tr ( "Oman" ) );
426 cmbCountry->insertItem( tr ( "Pakistan" ) ); 415 cmbCountry->insertItem( tr ( "Pakistan" ) );
427 cmbCountry->insertItem( tr ( "Palau" ) ); 416 cmbCountry->insertItem( tr ( "Palau" ) );
428 cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) ); 417 cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) );
429 cmbCountry->insertItem( tr ( "Panama" ) ); 418 cmbCountry->insertItem( tr ( "Panama" ) );
430 cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); 419 cmbCountry->insertItem( tr ( "Papua New Guinea" ) );
431 cmbCountry->insertItem( tr ( "Paraguay" ) ); 420 cmbCountry->insertItem( tr ( "Paraguay" ) );
432 cmbCountry->insertItem( tr ( "Peru" ) ); 421 cmbCountry->insertItem( tr ( "Peru" ) );
433 cmbCountry->insertItem( tr ( "Philippines" ) ); 422 cmbCountry->insertItem( tr ( "Philippines" ) );
434 cmbCountry->insertItem( tr ( "Pitcairn Islands" ) ); 423 cmbCountry->insertItem( tr ( "Pitcairn Islands" ) );
435 cmbCountry->insertItem( tr ( "Poland" ) ); 424 cmbCountry->insertItem( tr ( "Poland" ) );
436 cmbCountry->insertItem( tr ( "Portugal" ) ); 425 cmbCountry->insertItem( tr ( "Portugal" ) );
437 cmbCountry->insertItem( tr ( "Puerto Rico" ) ); 426 cmbCountry->insertItem( tr ( "Puerto Rico" ) );
438 cmbCountry->insertItem( tr ( "Qatar" ) ); 427 cmbCountry->insertItem( tr ( "Qatar" ) );
439 cmbCountry->insertItem( tr ( "Reunion" ) ); 428 cmbCountry->insertItem( tr ( "Reunion" ) );
440 cmbCountry->insertItem( tr ( "Romania" ) ); 429 cmbCountry->insertItem( tr ( "Romania" ) );
441 cmbCountry->insertItem( tr ( "Russia" ) ); 430 cmbCountry->insertItem( tr ( "Russia" ) );
442 cmbCountry->insertItem( tr ( "Rwanda" ) ); 431 cmbCountry->insertItem( tr ( "Rwanda" ) );
443 cmbCountry->insertItem( tr ( "Saint Lucia" ) ); 432 cmbCountry->insertItem( tr ( "Saint Lucia" ) );
444 cmbCountry->insertItem( tr ( "Samoa" ) ); 433 cmbCountry->insertItem( tr ( "Samoa" ) );
445 cmbCountry->insertItem( tr ( "San Marino" ) ); 434 cmbCountry->insertItem( tr ( "San Marino" ) );
446 cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); 435 cmbCountry->insertItem( tr ( "Saudi Arabia" ) );
447 cmbCountry->insertItem( tr ( "Senegal" ) ); 436 cmbCountry->insertItem( tr ( "Senegal" ) );
448 cmbCountry->insertItem( tr ( "Seychelles" ) ); 437 cmbCountry->insertItem( tr ( "Seychelles" ) );
449 cmbCountry->insertItem( tr ( "Sierra Leone" ) ); 438 cmbCountry->insertItem( tr ( "Sierra Leone" ) );
450 cmbCountry->insertItem( tr ( "Singapore" ) ); 439 cmbCountry->insertItem( tr ( "Singapore" ) );
451 cmbCountry->insertItem( tr ( "Slovakia" ) ); 440 cmbCountry->insertItem( tr ( "Slovakia" ) );
452 cmbCountry->insertItem( tr ( "Slovenia" ) ); 441 cmbCountry->insertItem( tr ( "Slovenia" ) );
453 cmbCountry->insertItem( tr ( "Solomon Islands" ) ); 442 cmbCountry->insertItem( tr ( "Solomon Islands" ) );
454 cmbCountry->insertItem( tr ( "Somalia" ) ); 443 cmbCountry->insertItem( tr ( "Somalia" ) );
455 cmbCountry->insertItem( tr ( "South Africa" ) ); 444 cmbCountry->insertItem( tr ( "South Africa" ) );
456 cmbCountry->insertItem( tr ( "Spain" ) ); 445 cmbCountry->insertItem( tr ( "Spain" ) );
457 cmbCountry->insertItem( tr ( "Sri Lanka" ) ); 446 cmbCountry->insertItem( tr ( "Sri Lanka" ) );
458 cmbCountry->insertItem( tr ( "St. Helena" ) ); 447 cmbCountry->insertItem( tr ( "St. Helena" ) );
459 cmbCountry->insertItem( tr ( "Sudan" ) ); 448 cmbCountry->insertItem( tr ( "Sudan" ) );
460 cmbCountry->insertItem( tr ( "Suriname" ) ); 449 cmbCountry->insertItem( tr ( "Suriname" ) );
461 cmbCountry->insertItem( tr ( "Swaziland" ) ); 450 cmbCountry->insertItem( tr ( "Swaziland" ) );
462 cmbCountry->insertItem( tr ( "Sweden" ) ); 451 cmbCountry->insertItem( tr ( "Sweden" ) );
463 cmbCountry->insertItem( tr ( "Switzerland" ) ); 452 cmbCountry->insertItem( tr ( "Switzerland" ) );
464 cmbCountry->insertItem( tr ( "Taiwan" ) ); 453 cmbCountry->insertItem( tr ( "Taiwan" ) );
465 cmbCountry->insertItem( tr ( "Tajikistan" ) ); 454 cmbCountry->insertItem( tr ( "Tajikistan" ) );
466 cmbCountry->insertItem( tr ( "Tanzania" ) ); 455 cmbCountry->insertItem( tr ( "Tanzania" ) );
467 cmbCountry->insertItem( tr ( "Thailand" ) ); 456 cmbCountry->insertItem( tr ( "Thailand" ) );
468 cmbCountry->insertItem( tr ( "Togo" ) ); 457 cmbCountry->insertItem( tr ( "Togo" ) );
469 cmbCountry->insertItem( tr ( "Tokelau" ) ); 458 cmbCountry->insertItem( tr ( "Tokelau" ) );
470 cmbCountry->insertItem( tr ( "Tonga" ) ); 459 cmbCountry->insertItem( tr ( "Tonga" ) );
471 cmbCountry->insertItem( tr ( "Tunisia" ) ); 460 cmbCountry->insertItem( tr ( "Tunisia" ) );
472 cmbCountry->insertItem( tr ( "Turkey" ) ); 461 cmbCountry->insertItem( tr ( "Turkey" ) );
473 cmbCountry->insertItem( tr ( "Turkmenistan" ) ); 462 cmbCountry->insertItem( tr ( "Turkmenistan" ) );
474 cmbCountry->insertItem( tr ( "Tuvalu" ) ); 463 cmbCountry->insertItem( tr ( "Tuvalu" ) );
475 cmbCountry->insertItem( tr ( "Uganda" ) ); 464 cmbCountry->insertItem( tr ( "Uganda" ) );
476 cmbCountry->insertItem( tr ( "Ukraine" ) ); 465 cmbCountry->insertItem( tr ( "Ukraine" ) );
477 cmbCountry->insertItem( tr ( "Uruguay" ) ); 466 cmbCountry->insertItem( tr ( "Uruguay" ) );
478 cmbCountry->insertItem( tr ( "Uzbekistan" ) ); 467 cmbCountry->insertItem( tr ( "Uzbekistan" ) );
479 cmbCountry->insertItem( tr ( "Vanuatu" ) ); 468 cmbCountry->insertItem( tr ( "Vanuatu" ) );
480 cmbCountry->insertItem( tr ( "Venezuela" ) ); 469 cmbCountry->insertItem( tr ( "Venezuela" ) );
481 cmbCountry->insertItem( tr ( "Vietnam" ) ); 470 cmbCountry->insertItem( tr ( "Vietnam" ) );
482 cmbCountry->insertItem( tr ( "Virgin Islands" ) ); 471 cmbCountry->insertItem( tr ( "Virgin Islands" ) );
483 cmbCountry->insertItem( tr ( "Western Sahara" ) ); 472 cmbCountry->insertItem( tr ( "Western Sahara" ) );
484 cmbCountry->insertItem( tr ( "Yemen" ) ); 473 cmbCountry->insertItem( tr ( "Yemen" ) );
485 cmbCountry->insertItem( tr ( "Yugoslavia" ) ); 474 cmbCountry->insertItem( tr ( "Yugoslavia" ) );
486 cmbCountry->insertItem( tr ( "Zambia" ) ); 475 cmbCountry->insertItem( tr ( "Zambia" ) );
487 cmbCountry->insertItem( tr ( "Zimbabwe" ) ); 476 cmbCountry->insertItem( tr ( "Zimbabwe" ) );
488 if (cmbCountry->listBox()!=0) 477 if (cmbCountry->listBox()!=0)
489 cmbCountry->listBox()->sort(); 478 cmbCountry->listBox()->sort();
490 479
491 cmbCountry->setMaximumWidth( 135 ); 480 cmbCountry->setMaximumWidth( 135 );
492 481
493 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); 482 gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
494 483
495 // Chooser 4 484 // Chooser 4
496 cmbChooserField4 = new QComboBox( FALSE, container ); 485 cmbChooserField4 = new QComboBox( FALSE, container );
497 cmbChooserField4->setMaximumWidth( 90 ); 486 cmbChooserField4->setMaximumWidth( 90 );
498 gl->addWidget( cmbChooserField4, 6, 0 ); 487 gl->addWidget( cmbChooserField4, 6, 0 );
499 // Textfield for chooser 2 488 // Textfield for chooser 2
500 // 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!
501 m_widgetStack4 = new QWidgetStack( container ); 490 m_widgetStack4 = new QWidgetStack( container );
502 txtChooserField4 = new QLineEdit( m_widgetStack4 ); 491 txtChooserField4 = new QLineEdit( m_widgetStack4 );
503 m_widgetStack4 -> addWidget( txtChooserField4, TextField ); 492 m_widgetStack4 -> addWidget( txtChooserField4, TextField );
504 gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); 493 gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 );
505 m_widgetStack4 -> raiseWidget( TextField ); 494 m_widgetStack4 -> raiseWidget( TextField );
506 495
507 QSpacerItem *space = new QSpacerItem(1,1, 496 QSpacerItem *space = new QSpacerItem(1,1,
508 QSizePolicy::Maximum, 497 QSizePolicy::Maximum,
509 QSizePolicy::MinimumExpanding ); 498 QSizePolicy::MinimumExpanding );
510 gl->addItem( space, 7, 0 ); 499 gl->addItem( space, 7, 0 );
511 500
512 tabMain->insertTab( tabViewport, tr( "Address" ) ); 501 tabMain->insertTab( tabViewport, tr( "Address" ) );
513 502
514 tabViewport = new QWidget ( tabMain ); 503 tabViewport = new QWidget ( tabMain );
515 504
516 vb = new QVBoxLayout( tabViewport ); 505 vb = new QVBoxLayout( tabViewport );
517 506
518 svDetails = new QScrollView( tabViewport ); 507 svDetails = new QScrollView( tabViewport );
519 vb->addWidget( svDetails, 0, 0 ); 508 vb->addWidget( svDetails, 0, 0 );
520 svDetails->setResizePolicy( QScrollView::AutoOneFit ); 509 svDetails->setResizePolicy( QScrollView::AutoOneFit );
521 svDetails->setFrameStyle( QFrame::NoFrame ); 510 svDetails->setFrameStyle( QFrame::NoFrame );
522 511
523 container = new QWidget( svDetails->viewport() ); 512 container = new QWidget( svDetails->viewport() );
524 svDetails->addChild( container ); 513 svDetails->addChild( container );
525 514
526 gl = new QGridLayout( container, 1, 2, 2, 4 ); 515 gl = new QGridLayout( container, 1, 2, 2, 4 );
527 516
528 int counter = 0; 517 int counter = 0;
529 518
530 // Birthday 519 // Birthday
531 QHBox* hBox = new QHBox( container ); 520 QHBox* hBox = new QHBox( container );
532 l = new QLabel( tr("Birthday"), container ); 521 l = new QLabel( tr("Birthday"), container );
533 gl->addWidget( l, counter, 0 ); 522 gl->addWidget( l, counter, 0 );
534 523
535 QPopupMenu* m1 = new QPopupMenu( container ); 524 QPopupMenu* m1 = new QPopupMenu( container );
536 birthdayPicker = new DateBookMonth( m1, 0, TRUE ); 525 birthdayPicker = new DateBookMonth( m1, 0, TRUE );
537 m1->insertItem( birthdayPicker ); 526 m1->insertItem( birthdayPicker );
538 527
539 birthdayButton= new QToolButton( hBox, "buttonStart" ); 528 birthdayButton= new QToolButton( hBox, "buttonStart" );
540 birthdayButton->setPopup( m1 ); 529 birthdayButton->setPopup( m1 );
541 birthdayButton->setPopupDelay(0); 530 birthdayButton->setPopupDelay(0);
542 531
543 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 532 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
544 tr( "Delete" ), 533 tr( "Delete" ),
545 hBox, 0 ); 534 hBox, 0 );
546 535
547 gl->addWidget( hBox, counter , 1 ); 536 gl->addWidget( hBox, counter , 1 );
548 537
549 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), 538 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ),
550 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); 539 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) );
551 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); 540 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
552 541
553 ++counter; 542 ++counter;
554 543
555 // Anniversary 544 // Anniversary
556 hBox = new QHBox( container ); 545 hBox = new QHBox( container );
557 l = new QLabel( tr("Anniversary"), container ); 546 l = new QLabel( tr("Anniversary"), container );
558 gl->addWidget( l, counter, 0 ); 547 gl->addWidget( l, counter, 0 );
559 548
560 m1 = new QPopupMenu( container ); 549 m1 = new QPopupMenu( container );
561 anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); 550 anniversaryPicker = new DateBookMonth( m1, 0, TRUE );
562 m1->insertItem( anniversaryPicker ); 551 m1->insertItem( anniversaryPicker );
563 552
564 anniversaryButton= new QToolButton( hBox, "buttonStart" ); 553 anniversaryButton= new QToolButton( hBox, "buttonStart" );
565 anniversaryButton->setPopup( m1 ); 554 anniversaryButton->setPopup( m1 );
566 anniversaryButton->setPopupDelay(0); 555 anniversaryButton->setPopupDelay(0);
567 556
568 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 557 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
569 tr( "Delete" ), 558 tr( "Delete" ),
570 hBox, 0 ); 559 hBox, 0 );
571 gl->addWidget( hBox, counter , 1 ); 560 gl->addWidget( hBox, counter , 1 );
572 561
573 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), 562 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ),
574 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); 563 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) );
575 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); 564 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
576 565
577 ++counter; 566 ++counter;
578 567
579 // Gender 568 // Gender
580 l = new QLabel( tr("Gender"), container ); 569 l = new QLabel( tr("Gender"), container );
581 gl->addWidget( l, counter, 0 ); 570 gl->addWidget( l, counter, 0 );
582 cmbGender = new QComboBox( container ); 571 cmbGender = new QComboBox( container );
583 cmbGender->insertItem( "", 0 ); 572 cmbGender->insertItem( "", 0 );
584 cmbGender->insertItem( tr("Male"), 1); 573 cmbGender->insertItem( tr("Male"), 1);
585 cmbGender->insertItem( tr("Female"), 2); 574 cmbGender->insertItem( tr("Female"), 2);
586 gl->addWidget( cmbGender, counter, 1 ); 575 gl->addWidget( cmbGender, counter, 1 );
587 576
588 ++counter; 577 ++counter;
589 578
590 // Create Labels and lineedit fields for every dynamic entry 579 // Create Labels and lineedit fields for every dynamic entry
591 QStringList::ConstIterator it = slDynamicEntries.begin(); 580 QStringList::ConstIterator it = slDynamicEntries.begin();
592 QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); 581 QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId();
593 QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); 582 QMap<int, QString> mapIdToStr = OContactFields::idToTrFields();
594 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { 583 for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
595 584
596 if (((*it) == "Anniversary") || 585 if (((*it) == "Anniversary") ||
597 ((*it) == "Birthday")|| ((*it) == "Gender")) continue; 586 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
598 587
599 l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); 588 l = new QLabel( mapIdToStr[mapStrToID[*it]], container );
600 listName.append( l ); 589 listName.append( l );
601 gl->addWidget( l, i, 0 ); 590 gl->addWidget( l, i, 0 );
602 QLineEdit *e = new QLineEdit( container ); 591 QLineEdit *e = new QLineEdit( container );
603 listValue.append( e ); 592 listValue.append( e );
604 gl->addWidget( e, i, 1); 593 gl->addWidget( e, i, 1);
605 } 594 }
606 // Fill labels with names.. 595 // Fill labels with names..
607 //loadFields(); 596 //loadFields();
608 597
609 598
610 tabMain->insertTab( tabViewport, tr( "Details" ) ); 599 tabMain->insertTab( tabViewport, tr( "Details" ) );
611 600
612 dlgNote = new QDialog( this, "Note Dialog", TRUE ); 601 dlgNote = new QDialog( this, "Note Dialog", TRUE );
613 dlgNote->setCaption( tr("Enter Note") ); 602 dlgNote->setCaption( tr("Enter Note") );
614 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); 603 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
615 txtNote = new QMultiLineEdit( dlgNote ); 604 txtNote = new QMultiLineEdit( dlgNote );
616 vbNote->addWidget( txtNote ); 605 vbNote->addWidget( txtNote );
617 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); 606 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
618 607
619 dlgName = new QDialog( this, "Name Dialog", TRUE ); 608 dlgName = new QDialog( this, "Name Dialog", TRUE );
620 dlgName->setCaption( tr("Edit Name") ); 609 dlgName->setCaption( tr("Edit Name") );
621 gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); 610 gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
622 611
623 l = new QLabel( tr("First Name"), dlgName ); 612 l = new QLabel( tr("First Name"), dlgName );
624 gl->addWidget( l, 0, 0 ); 613 gl->addWidget( l, 0, 0 );
625 txtFirstName = new QLineEdit( dlgName ); 614 txtFirstName = new QLineEdit( dlgName );
626 gl->addWidget( txtFirstName, 0, 1 ); 615 gl->addWidget( txtFirstName, 0, 1 );
627 616
628 l = new QLabel( tr("Middle Name"), dlgName ); 617 l = new QLabel( tr("Middle Name"), dlgName );
629 gl->addWidget( l, 1, 0 ); 618 gl->addWidget( l, 1, 0 );
630 txtMiddleName = new QLineEdit( dlgName ); 619 txtMiddleName = new QLineEdit( dlgName );
631 gl->addWidget( txtMiddleName, 1, 1 ); 620 gl->addWidget( txtMiddleName, 1, 1 );
632 621
633 l = new QLabel( tr("Last Name"), dlgName ); 622 l = new QLabel( tr("Last Name"), dlgName );
634 gl->addWidget( l, 2, 0 ); 623 gl->addWidget( l, 2, 0 );
635 txtLastName = new QLineEdit( dlgName ); 624 txtLastName = new QLineEdit( dlgName );
636 gl->addWidget( txtLastName, 2, 1 ); 625 gl->addWidget( txtLastName, 2, 1 );
637 626
638 // l = new QLabel( tr("Suffix"), dlgName ); 627 // l = new QLabel( tr("Suffix"), dlgName );
639 // gl->addWidget( l, 3, 0 ); 628 // gl->addWidget( l, 3, 0 );
640 // txtSuffix = new QLineEdit( dlgName ); 629 // txtSuffix = new QLineEdit( dlgName );
641 // gl->addWidget( txtSuffix, 3, 1 ); 630 // gl->addWidget( txtSuffix, 3, 1 );
642 space = new QSpacerItem(1,1, 631 space = new QSpacerItem(1,1,
643 QSizePolicy::Maximum, 632 QSizePolicy::Maximum,
644 QSizePolicy::MinimumExpanding ); 633 QSizePolicy::MinimumExpanding );
645 gl->addItem( space, 4, 0 ); 634 gl->addItem( space, 4, 0 );
646 635
647 cmbChooserField1->insertStringList( trlChooserNames ); 636 cmbChooserField1->insertStringList( trlChooserNames );
648 cmbChooserField2->insertStringList( trlChooserNames ); 637 cmbChooserField2->insertStringList( trlChooserNames );
649 cmbChooserField3->insertStringList( trlChooserNames ); 638 cmbChooserField3->insertStringList( trlChooserNames );
650 cmbChooserField4->insertStringList( trlChooserNames ); 639 cmbChooserField4->insertStringList( trlChooserNames );
651 640
652 cmbChooserField1->setCurrentItem( 0 ); 641 cmbChooserField1->setCurrentItem( 0 );
653 cmbChooserField2->setCurrentItem( 1 ); 642 cmbChooserField2->setCurrentItem( 1 );
654 cmbChooserField3->setCurrentItem( 2 ); 643 cmbChooserField3->setCurrentItem( 2 );
655 644
656 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 645 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
657 646
658 connect( txtFullName, SIGNAL(textChanged(const QString &)), 647 connect( txtFullName, SIGNAL(textChanged(const QString &)),
659 this, SLOT(slotFullNameChange(const QString &)) ); 648 this, SLOT(slotFullNameChange(const QString &)) );
660 connect( txtSuffix, SIGNAL(textChanged(const QString &)), 649 connect( txtSuffix, SIGNAL(textChanged(const QString &)),
661 this, SLOT(slotSuffixChange(const QString &)) ); 650 this, SLOT(slotSuffixChange(const QString &)) );
662 connect( txtOrganization, SIGNAL(textChanged(const QString &)), 651 connect( txtOrganization, SIGNAL(textChanged(const QString &)),
663 this, SLOT(slotOrganizationChange(const QString &)) ); 652 this, SLOT(slotOrganizationChange(const QString &)) );
664 connect( txtChooserField1, SIGNAL(textChanged(const QString &)), 653 connect( txtChooserField1, SIGNAL(textChanged(const QString &)),
665 this, SLOT(slotChooser1Change(const QString &)) ); 654 this, SLOT(slotChooser1Change(const QString &)) );
666 connect( txtChooserField2, SIGNAL(textChanged(const QString &)), 655 connect( txtChooserField2, SIGNAL(textChanged(const QString &)),
667 this, SLOT(slotChooser2Change(const QString &)) ); 656 this, SLOT(slotChooser2Change(const QString &)) );
668 connect( txtChooserField3, SIGNAL(textChanged(const QString &)), 657 connect( txtChooserField3, SIGNAL(textChanged(const QString &)),
669 this, SLOT(slotChooser3Change(const QString &)) ); 658 this, SLOT(slotChooser3Change(const QString &)) );
670 connect( txtChooserField4, SIGNAL(textChanged(const QString &)), 659 connect( txtChooserField4, SIGNAL(textChanged(const QString &)),
671 this, SLOT(slotChooser4Change(const QString &)) ); 660 this, SLOT(slotChooser4Change(const QString &)) );
672 connect( txtAddress, SIGNAL(textChanged(const QString &)), 661 connect( txtAddress, SIGNAL(textChanged(const QString &)),
673 this, SLOT(slotAddressChange(const QString &)) ); 662 this, SLOT(slotAddressChange(const QString &)) );
674 connect( txtCity, SIGNAL(textChanged(const QString &)), 663 connect( txtCity, SIGNAL(textChanged(const QString &)),
675 this, SLOT(slotCityChange(const QString &)) ); 664 this, SLOT(slotCityChange(const QString &)) );
676 connect( txtState, SIGNAL(textChanged(const QString &)), 665 connect( txtState, SIGNAL(textChanged(const QString &)),
677 this, SLOT(slotStateChange(const QString &)) ); 666 this, SLOT(slotStateChange(const QString &)) );
678 connect( txtZip, SIGNAL(textChanged(const QString &)), 667 connect( txtZip, SIGNAL(textChanged(const QString &)),
679 this, SLOT(slotZipChange(const QString &)) ); 668 this, SLOT(slotZipChange(const QString &)) );
680 connect( cmbCountry, SIGNAL(textChanged(const QString &)), 669 connect( cmbCountry, SIGNAL(textChanged(const QString &)),
681 this, SLOT(slotCountryChange(const QString &)) ); 670 this, SLOT(slotCountryChange(const QString &)) );
682 connect( cmbCountry, SIGNAL(activated(const QString &)), 671 connect( cmbCountry, SIGNAL(activated(const QString &)),
683 this, SLOT(slotCountryChange(const QString &)) ); 672 this, SLOT(slotCountryChange(const QString &)) );
684 connect( cmbChooserField1, SIGNAL(activated(int)), 673 connect( cmbChooserField1, SIGNAL(activated(int)),
685 this, SLOT(slotCmbChooser1Change(int)) ); 674 this, SLOT(slotCmbChooser1Change(int)) );
686 connect( cmbChooserField2, SIGNAL(activated(int)), 675 connect( cmbChooserField2, SIGNAL(activated(int)),
687 this, SLOT(slotCmbChooser2Change(int)) ); 676 this, SLOT(slotCmbChooser2Change(int)) );
688 connect( cmbChooserField3, SIGNAL(activated(int)), 677 connect( cmbChooserField3, SIGNAL(activated(int)),
689 this, SLOT(slotCmbChooser3Change(int)) ); 678 this, SLOT(slotCmbChooser3Change(int)) );
690 connect( cmbChooserField4, SIGNAL(activated(int)), 679 connect( cmbChooserField4, SIGNAL(activated(int)),
691 this, SLOT(slotCmbChooser4Change(int)) ); 680 this, SLOT(slotCmbChooser4Change(int)) );
692 connect( cmbAddress, SIGNAL(activated(int)), 681 connect( cmbAddress, SIGNAL(activated(int)),
693 this, SLOT(slotAddressTypeChange(int)) ); 682 this, SLOT(slotAddressTypeChange(int)) );
694 683
695 new QPEDialogListener(this); 684 new QPEDialogListener(this);
696 685
697 setPersonalView ( m_personalView ); 686 setPersonalView ( m_personalView );
698 687
699 qWarning("init() END"); 688 qWarning("init() END");
700} 689}
701 690
702void ContactEditor::defaultEmailChanged(int i){ 691void ContactEditor::defaultEmailChanged(int i){
703 qDebug("defaultEmailChanged"); 692 qDebug("defaultEmailChanged");
704 693
705 // was sollte das ? (se) 694 // was sollte das ? (se)
706 // int index = cmbChooserField1->currentItem(); 695 // int index = cmbChooserField1->currentItem();
707 // slChooserValues[index] = cmbDefaultEmail->text(i); 696 // slChooserValues[index] = cmbDefaultEmail->text(i);
708 697
709 defaultEmail = cmbDefaultEmail->text(i); 698 defaultEmail = cmbDefaultEmail->text(i);
710 qDebug ("Changed to: %s", defaultEmail.latin1()); 699 qDebug ("Changed to: %s", defaultEmail.latin1());
711 700
712} 701}
713 702
714void ContactEditor::populateDefaultEmailCmb(){ 703void ContactEditor::populateDefaultEmailCmb(){
715 704
716 // 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
717 // we get a lot of trouble.. Therfore create an invisible one.. 706 // we get a lot of trouble.. Therfore create an invisible one..
718 if ( !cmbDefaultEmail ){ 707 if ( !cmbDefaultEmail ){
719 cmbDefaultEmail = new QComboBox(this); 708 cmbDefaultEmail = new QComboBox(this);
720 cmbDefaultEmail -> hide(); 709 cmbDefaultEmail -> hide();
721 } 710 }
722 cmbDefaultEmail->clear(); 711 cmbDefaultEmail->clear();
723 cmbDefaultEmail->insertStringList( emails ); 712 cmbDefaultEmail->insertStringList( emails );
724 // cmbDefaultEmail->show(); 713 // cmbDefaultEmail->show();
725 714
726 // Select default email in combo.. 715 // Select default email in combo..
727 bool found = false; 716 bool found = false;
728 for ( int i = 0; i < cmbDefaultEmail->count(); i++){ 717 for ( int i = 0; i < cmbDefaultEmail->count(); i++){
729 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", 718 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",
730 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); 719 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1());
731 720
732 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ 721 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
733 cmbDefaultEmail->setCurrentItem( i ); 722 cmbDefaultEmail->setCurrentItem( i );
734 qDebug("set"); 723 qDebug("set");
735 found = true; 724 found = true;
736 } 725 }
737 } 726 }
738 727
739 // 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
740 // first one.. 729 // first one..
741 if ( !found ) 730 if ( !found )
742 defaultEmail = cmbDefaultEmail->text(0); 731 defaultEmail = cmbDefaultEmail->text(0);
743} 732}
744 733
745// Called when any combobox was changed. 734// Called when any combobox was changed.
746// "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
747// be handled by something else.. 736// be handled by something else..
748bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) { 737bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) {
749 QString type = slChooserNames[index]; 738 QString type = slChooserNames[index];
750 qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos ); 739 qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos );
751 740
752 if ( !initializing ) 741 if ( !initializing )
753 contactfields.setFieldOrder( widgetPos-1, index ); 742 contactfields.setFieldOrder( widgetPos-1, index );
754 743
755 // Create and connect combobox for selecting the default email 744 // Create and connect combobox for selecting the default email
756 if ( type == "Default Email"){ 745 if ( type == "Default Email"){
757 qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition); 746 qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition);
758 747
759 // More than one default-email chooser is not allowed ! 748 // More than one default-email chooser is not allowed !
760 if ( ( defaultEmailChooserPosition != -1 ) && 749 if ( ( defaultEmailChooserPosition != -1 ) &&
761 defaultEmailChooserPosition != widgetPos && !initializing){ 750 defaultEmailChooserPosition != widgetPos && !initializing){
762 chooserError( widgetPos ); 751 chooserError( widgetPos );
763 return true; 752 return true;
764 } 753 }
765 754
766 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); 755 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
767 if ( cmbo ){ 756 if ( cmbo ){
768 inputStack->raiseWidget( TextField ); 757 inputStack->raiseWidget( TextField );
769 inputStack -> removeWidget( cmbo ); 758 inputStack -> removeWidget( cmbo );
770 delete cmbo; 759 delete cmbo;
771 } 760 }
772 cmbo = new QComboBox( inputStack ); 761 cmbo = new QComboBox( inputStack );
773 cmbo -> insertStringList( emails ); 762 cmbo -> insertStringList( emails );
774 763
775 inputStack -> addWidget( cmbo, Combo ); 764 inputStack -> addWidget( cmbo, Combo );
776 inputStack -> raiseWidget( Combo ); 765 inputStack -> raiseWidget( Combo );
777 766
778 defaultEmailChooserPosition = widgetPos; 767 defaultEmailChooserPosition = widgetPos;
779 cmbDefaultEmail = cmbo; 768 cmbDefaultEmail = cmbo;
780 769
781 connect( cmbo,SIGNAL( activated(int) ), 770 connect( cmbo,SIGNAL( activated(int) ),
782 SLOT( defaultEmailChanged(int) ) ); 771 SLOT( defaultEmailChanged(int) ) );
783 772
784 // Set current default email 773 // Set current default email
785 populateDefaultEmailCmb(); 774 populateDefaultEmailCmb();
786 775
787 776
788 } else { 777 } else {
789 // Something else was selected: Hide combo.. 778 // Something else was selected: Hide combo..
790 qWarning(" Hiding default-email combo" ); 779 qWarning(" Hiding default-email combo" );
791 if ( defaultEmailChooserPosition == widgetPos ){ 780 if ( defaultEmailChooserPosition == widgetPos ){
792 defaultEmailChooserPosition = -1; 781 defaultEmailChooserPosition = -1;
793 } 782 }
794 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo ); 783 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
795 if ( cmbo ){ 784 if ( cmbo ){
796 inputStack->raiseWidget( TextField ); 785 inputStack->raiseWidget( TextField );
797 inputStack -> removeWidget( cmbo ); 786 inputStack -> removeWidget( cmbo );
798 cmbDefaultEmail = 0l; 787 cmbDefaultEmail = 0l;
799 delete cmbo; 788 delete cmbo;
800 } 789 }
801 790
802 // Caller should initialize the responsible textfield, therefore 791 // Caller should initialize the responsible textfield, therefore
803 // "false" is returned 792 // "false" is returned
804 return false; 793 return false;
805 } 794 }
806 795
807 // Everything is worked off .. 796 // Everything is worked off ..
808 return true; 797 return true;
809 798
810} 799}
811 800
812// Currently accessed when we select default-email more than once ! 801// Currently accessed when we select default-email more than once !
813void ContactEditor::chooserError( int index ) 802void ContactEditor::chooserError( int index )
814{ 803{
815 qWarning("ContactEditor::chooserError( %d )", index); 804 qWarning("ContactEditor::chooserError( %d )", index);
816 QMessageBox::warning( this, "Chooser Error", 805 QMessageBox::warning( this, "Chooser Error",
817 "Multiple selection of this\n" 806 "Multiple selection of this\n"
818 "Item is not allowed !\n\n" 807 "Item is not allowed !\n\n"
819 "First deselect the previous one !", 808 "First deselect the previous one !",
820 "&OK", 0, 0, 809 "&OK", 0, 0,
821 0, 0 ); 810 0, 0 );
822 811
823 // Reset the selected Chooser. Unfortunately the chooser 812 // Reset the selected Chooser. Unfortunately the chooser
824 // generates no signal, therfore we have to 813 // generates no signal, therfore we have to
825 // call the cmbChooserChange function manually.. 814 // call the cmbChooserChange function manually..
826 switch( index ){ 815 switch( index ){
827 case 1: 816 case 1:
828 cmbChooserField1 -> setCurrentItem( 0 ); 817 cmbChooserField1 -> setCurrentItem( 0 );
829 slotCmbChooser1Change( 0 ); 818 slotCmbChooser1Change( 0 );
830 break; 819 break;
831 case 2: 820 case 2:
832 cmbChooserField2 -> setCurrentItem( 0 ); 821 cmbChooserField2 -> setCurrentItem( 0 );
833 slotCmbChooser2Change( 0 ); 822 slotCmbChooser2Change( 0 );
834 break; 823 break;
835 case 3: 824 case 3:
836 cmbChooserField3 -> setCurrentItem( 0 ); 825 cmbChooserField3 -> setCurrentItem( 0 );
837 slotCmbChooser3Change( 0 ); 826 slotCmbChooser3Change( 0 );
838 break; 827 break;
839 case 4: 828 case 4:
840 cmbChooserField4 -> setCurrentItem( 0 ); 829 cmbChooserField4 -> setCurrentItem( 0 );
841 slotCmbChooser4Change( 0 ); 830 slotCmbChooser4Change( 0 );
842 break; 831 break;
843 } 832 }
844} 833}
845 834
846// Called when something was changed in a textfield (shouldn't it called textchanged? (se)) 835// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
847void ContactEditor::chooserChange( const QString &textChanged, int index, 836void ContactEditor::chooserChange( const QString &textChanged, int index,
848 QLineEdit* , int widgetPos ) { 837 QLineEdit* , int widgetPos ) {
849 838
850 QString type = slChooserNames[index]; // :SX 839 QString type = slChooserNames[index]; // :SX
851 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", 840 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
852 type.latin1(),textChanged.latin1(), index, widgetPos ); 841 type.latin1(),textChanged.latin1(), index, widgetPos );
853 842
854 if ( type == "Default Email"){ 843 if ( type == "Default Email"){
855 qWarning ("??? Wozu??: %s", textChanged.latin1()); 844 qWarning ("??? Wozu??: %s", textChanged.latin1());
856 defaultEmail = textChanged; 845 defaultEmail = textChanged;
857 846
858 populateDefaultEmailCmb(); 847 populateDefaultEmailCmb();
859 848
860 }else if (type == "Emails"){ 849 }else if (type == "Emails"){
861 qDebug("emails"); 850 qDebug("emails");
862 851
863 QString de; 852 QString de;
864 emails = QStringList::split (",", textChanged ); 853 emails = QStringList::split (",", textChanged );
865 854
866 populateDefaultEmailCmb(); 855 populateDefaultEmailCmb();
867 } 856 }
868 857
869 slChooserValues[index] = textChanged; 858 slChooserValues[index] = textChanged;
870 859
871} 860}
872 861
873void ContactEditor::slotChooser1Change( const QString &textChanged ) { 862void ContactEditor::slotChooser1Change( const QString &textChanged ) {
874 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); 863 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
875 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); 864 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
876} 865}
877 866
878void ContactEditor::slotChooser2Change( const QString &textChanged ) { 867void ContactEditor::slotChooser2Change( const QString &textChanged ) {
879 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); 868 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1());
880 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); 869 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
881 870
882} 871}
883 872
884void ContactEditor::slotChooser3Change( const QString &textChanged ) { 873void ContactEditor::slotChooser3Change( const QString &textChanged ) {
885 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); 874 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1());
886 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); 875 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
887} 876}
888 877
889void ContactEditor::slotChooser4Change( const QString &textChanged ) { 878void ContactEditor::slotChooser4Change( const QString &textChanged ) {
890 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); 879 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1());
891 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); 880 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
892} 881}
893 882
894void ContactEditor::slotAddressChange( const QString &textChanged ) { 883void ContactEditor::slotAddressChange( const QString &textChanged ) {
895 884
896 if ( cmbAddress->currentItem() == 0 ) { 885 if ( cmbAddress->currentItem() == 0 ) {
897 slBusinessAddress[0] = textChanged; 886 slBusinessAddress[0] = textChanged;
898 } else { 887 } else {
899 slHomeAddress[0] = textChanged; 888 slHomeAddress[0] = textChanged;
900 } 889 }
901} 890}
902 891
903void ContactEditor::slotAddress2Change( const QString &textChanged ) { 892void ContactEditor::slotAddress2Change( const QString &textChanged ) {
904 893
905 if ( cmbAddress->currentItem() == 0 ) { 894 if ( cmbAddress->currentItem() == 0 ) {
906 slBusinessAddress[1] = textChanged; 895 slBusinessAddress[1] = textChanged;
907 } else { 896 } else {
908 slHomeAddress[1] = textChanged; 897 slHomeAddress[1] = textChanged;
909 } 898 }
910} 899}
911 900
912void ContactEditor::slotPOBoxChange( const QString &textChanged ) { 901void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
913 902
914 if ( cmbAddress->currentItem() == 0 ) { 903 if ( cmbAddress->currentItem() == 0 ) {
915 slBusinessAddress[2] = textChanged; 904 slBusinessAddress[2] = textChanged;
916 } else { 905 } else {
917 slHomeAddress[2] = textChanged; 906 slHomeAddress[2] = textChanged;
918 } 907 }
919} 908}
920 909
921void ContactEditor::slotCityChange( const QString &textChanged ) { 910void ContactEditor::slotCityChange( const QString &textChanged ) {
922 911
923 if ( cmbAddress->currentItem() == 0 ) { 912 if ( cmbAddress->currentItem() == 0 ) {
924 slBusinessAddress[3] = textChanged; 913 slBusinessAddress[3] = textChanged;
925 } else { 914 } else {
926 slHomeAddress[3] = textChanged; 915 slHomeAddress[3] = textChanged;
927 } 916 }
928} 917}
929 918
930void ContactEditor::slotStateChange( const QString &textChanged ) { 919void ContactEditor::slotStateChange( const QString &textChanged ) {
931 920
932 921
933 if ( cmbAddress->currentItem() == 0 ) { 922 if ( cmbAddress->currentItem() == 0 ) {
934 slBusinessAddress[4] = textChanged; 923 slBusinessAddress[4] = textChanged;
935 } else { 924 } else {
936 slHomeAddress[4] = textChanged; 925 slHomeAddress[4] = textChanged;
937 } 926 }
938} 927}
939 928
940void ContactEditor::slotZipChange( const QString &textChanged ) { 929void ContactEditor::slotZipChange( const QString &textChanged ) {
941 930
942 if ( cmbAddress->currentItem() == 0 ) { 931 if ( cmbAddress->currentItem() == 0 ) {
943 slBusinessAddress[5] = textChanged; 932 slBusinessAddress[5] = textChanged;
944 } else { 933 } else {
945 slHomeAddress[5] = textChanged; 934 slHomeAddress[5] = textChanged;
946 } 935 }
947} 936}
948 937
949void ContactEditor::slotCountryChange( const QString &textChanged ) { 938void ContactEditor::slotCountryChange( const QString &textChanged ) {
950 939
951 if ( cmbAddress->currentItem() == 0 ) { 940 if ( cmbAddress->currentItem() == 0 ) {
952 slBusinessAddress[6] = textChanged; 941 slBusinessAddress[6] = textChanged;
953 } else { 942 } else {
954 slHomeAddress[6] = textChanged; 943 slHomeAddress[6] = textChanged;
955 } 944 }
956} 945}
957 946
958 947
959void ContactEditor::slotCmbChooser1Change( int index ) { 948void ContactEditor::slotCmbChooser1Change( int index ) {
960 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); 949 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
961 if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){ 950 if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){
962 951
963 txtChooserField1->setText( slChooserValues[index] ); 952 txtChooserField1->setText( slChooserValues[index] );
964 txtChooserField1->setFocus(); 953 txtChooserField1->setFocus();
965 954
966 } 955 }
967 956
968} 957}
969 958
970void ContactEditor::slotCmbChooser2Change( int index ) { 959void ContactEditor::slotCmbChooser2Change( int index ) {
971 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); 960 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
972 961
973 if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){ 962 if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){
974 963
975 txtChooserField2->setText( slChooserValues[index] ); 964 txtChooserField2->setText( slChooserValues[index] );
976 txtChooserField2->setFocus(); 965 txtChooserField2->setFocus();
977 966
978 } 967 }
979} 968}
980 969
981void ContactEditor::slotCmbChooser3Change( int index ) { 970void ContactEditor::slotCmbChooser3Change( int index ) {
982 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); 971 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
983 972
984 if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){ 973 if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){
985 974
986 txtChooserField3->setText( slChooserValues[index] ); 975 txtChooserField3->setText( slChooserValues[index] );
987 txtChooserField3->setFocus(); 976 txtChooserField3->setFocus();
988 977
989 } 978 }
990} 979}
991 980
992void ContactEditor::slotCmbChooser4Change( int index ) { 981void ContactEditor::slotCmbChooser4Change( int index ) {
993 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); 982 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
994 983
995 if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){ 984 if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){
996 985
997 txtChooserField4->setText( slChooserValues[index] ); 986 txtChooserField4->setText( slChooserValues[index] );
998 txtChooserField4->setFocus(); 987 txtChooserField4->setFocus();
999 988
1000 } 989 }
1001} 990}
1002 991
1003void ContactEditor::slotAddressTypeChange( int index ) { 992void ContactEditor::slotAddressTypeChange( int index ) {
1004 993
1005 994
1006 if ( !initializing ) 995 if ( !initializing )
1007 contactfields.setFieldOrder( 4, index ); 996 contactfields.setFieldOrder( 4, index );
1008 997
1009 998
1010 if ( index == 0 ) { 999 if ( index == 0 ) {
1011 1000
1012 txtAddress->setText( slBusinessAddress[0] ); 1001 txtAddress->setText( slBusinessAddress[0] );
1013 //txtAddress2->setText( (*slBusinessAddress)[1] ); 1002 //txtAddress2->setText( (*slBusinessAddress)[1] );
1014 //txtPOBox->setText( (*slBusinessAddress)[2] ); 1003 //txtPOBox->setText( (*slBusinessAddress)[2] );
1015 txtCity->setText( slBusinessAddress[3] ); 1004 txtCity->setText( slBusinessAddress[3] );
1016 txtState->setText( slBusinessAddress[4] ); 1005 txtState->setText( slBusinessAddress[4] );
1017 txtZip->setText( slBusinessAddress[5] ); 1006 txtZip->setText( slBusinessAddress[5] );
1018 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1007 QLineEdit *txtTmp = cmbCountry->lineEdit();
1019 txtTmp->setText( slBusinessAddress[6] ); 1008 txtTmp->setText( slBusinessAddress[6] );
1020 1009
1021 } else { 1010 } else {
1022 1011
1023 txtAddress->setText( slHomeAddress[0] ); 1012 txtAddress->setText( slHomeAddress[0] );
1024 //txtAddress2->setText( (*slHomeAddress)[1] ); 1013 //txtAddress2->setText( (*slHomeAddress)[1] );
1025 //txtPOBox->setText( (*slHomeAddress)[2] ); 1014 //txtPOBox->setText( (*slHomeAddress)[2] );
1026 txtCity->setText( slHomeAddress[3] ); 1015 txtCity->setText( slHomeAddress[3] );
1027 txtState->setText( slHomeAddress[4] ); 1016 txtState->setText( slHomeAddress[4] );
1028 txtZip->setText( slHomeAddress[5] ); 1017 txtZip->setText( slHomeAddress[5] );
1029 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1018 QLineEdit *txtTmp = cmbCountry->lineEdit();
1030 txtTmp->setText( slHomeAddress[6] ); 1019 txtTmp->setText( slHomeAddress[6] );
1031 1020
1032 } 1021 }
1033 1022
1034} 1023}
1035 1024
1036void ContactEditor::slotFullNameChange( const QString &textChanged ) { 1025void ContactEditor::slotFullNameChange( const QString &textChanged ) {
1037 1026
1038 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() ); 1027 qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() );
1039 1028
1040 int index = cmbFileAs->currentItem(); 1029 int index = cmbFileAs->currentItem();
1041 1030
1042 cmbFileAs->clear(); 1031 cmbFileAs->clear();
1043 1032
1044 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) ); 1033 cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) );
1045 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) ); 1034 cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) );
1046 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) ); 1035 cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
1047 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) ); 1036 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) );
1048 if ( ! txtSuffix->text().isEmpty() ) 1037 if ( ! txtSuffix->text().isEmpty() )
1049 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() ); 1038 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() );
1050 1039
1051 cmbFileAs->setCurrentItem( index ); 1040 cmbFileAs->setCurrentItem( index );
1052 1041
1053 1042
1054} 1043}
1055 1044
1056void ContactEditor::slotSuffixChange( const QString& ) { 1045void ContactEditor::slotSuffixChange( const QString& ) {
1057 // Just want to update the FileAs combo if the suffix was changed.. 1046 // Just want to update the FileAs combo if the suffix was changed..
1058 slotFullNameChange( txtFullName->text() ); 1047 slotFullNameChange( txtFullName->text() );
1059} 1048}
1060 1049
1061void ContactEditor::slotOrganizationChange( const QString &textChanged ){ 1050void ContactEditor::slotOrganizationChange( const QString &textChanged ){
1062 qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() ); 1051 qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() );
1063 // Special handling for storing Companies: 1052 // Special handling for storing Companies:
1064 // If no Fullname is given, we store the Company-Name as lastname 1053 // If no Fullname is given, we store the Company-Name as lastname
1065 // to handle it like a person.. 1054 // to handle it like a person..
1066 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) ) 1055 if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) )
1067 txtFullName->setText( textChanged ); 1056 txtFullName->setText( textChanged );
1068 1057
1069} 1058}
1070 1059
1071void ContactEditor::accept() { 1060void ContactEditor::accept() {
1072 1061
1073 if ( isEmpty() ) { 1062 if ( isEmpty() ) {
1074 cleanupFields(); 1063 cleanupFields();
1075 reject(); 1064 reject();
1076 } else { 1065 } else {
1077 saveEntry(); 1066 saveEntry();
1078 cleanupFields(); 1067 cleanupFields();
1079 QDialog::accept(); 1068 QDialog::accept();
1080 } 1069 }
1081 1070
1082} 1071}
1083 1072
1084void ContactEditor::slotNote() { 1073void ContactEditor::slotNote() {
1085 1074
1086 if ( ! QPEApplication::execDialog( dlgNote ) ) { 1075 if ( ! QPEApplication::execDialog( dlgNote ) ) {
1087 txtNote->setText( ent.notes() ); 1076 txtNote->setText( ent.notes() );
1088 } 1077 }
1089} 1078}
1090 1079
1091void ContactEditor::slotName() { 1080void ContactEditor::slotName() {
1092 1081
1093 QString tmpName; 1082 QString tmpName;
1094 1083
1095 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1084 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
1096 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1085 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
1097 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1086 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
1098 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1087 // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
1099 1088
1100 if ( QPEApplication::execDialog( dlgName ) ) { 1089 if ( QPEApplication::execDialog( dlgName ) ) {
1101 if ( txtLastName->text().contains( ' ', TRUE ) ) 1090 if ( txtLastName->text().contains( ' ', TRUE ) )
1102 tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text(); 1091 tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text();
1103 else 1092 else
1104 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text(); 1093 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text();
1105 1094
1106 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1095 txtFullName->setText( tmpName.simplifyWhiteSpace() );
1107 slotFullNameChange( txtFullName->text() ); 1096 slotFullNameChange( txtFullName->text() );
1108 } 1097 }
1109 1098
1110} 1099}
1111 1100
1112void ContactEditor::setNameFocus() { 1101void ContactEditor::setNameFocus() {
1113 1102
1114 txtFullName->setFocus(); 1103 txtFullName->setFocus();
1115 1104
1116} 1105}
1117 1106
1118bool ContactEditor::isEmpty() { 1107bool ContactEditor::isEmpty() {
1119 // Test and see if the record should be saved. 1108 // Test and see if the record should be saved.
1120 // More strict than the original qtopia, needs name or fileas to save 1109 // More strict than the original qtopia, needs name or fileas to save
1121 1110
1122 QString t = txtFullName->text(); 1111 QString t = txtFullName->text();
1123 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1112 if ( !t.isEmpty() && containsAlphaNum( t ) )
1124 return false; 1113 return false;
1125 1114
1126 t = cmbFileAs->currentText(); 1115 t = cmbFileAs->currentText();
1127 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1116 if ( !t.isEmpty() && containsAlphaNum( t ) )
1128 return false; 1117 return false;
1129 1118
1130 return true; 1119 return true;
1131 1120
1132} 1121}
1133 1122
1134QString ContactEditor::parseName( const QString fullName, int type ) { 1123QString ContactEditor::parseName( const QString fullName, int type ) {
1135 1124
1136 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1125 QString simplifiedName( fullName.simplifyWhiteSpace() );
1137 QString strFirstName; 1126 QString strFirstName;
1138 QString strMiddleName; 1127 QString strMiddleName;
1139 QString strLastName; 1128 QString strLastName;
1140 QString strTitle; 1129 QString strTitle;
1141 int commapos; 1130 int commapos;
1142 bool haveLastName = false; 1131 bool haveLastName = false;
1143 1132
1144 qWarning("Fullname: %s", simplifiedName.latin1()); 1133 qWarning("Fullname: %s", simplifiedName.latin1());
1145 1134
1146 commapos = simplifiedName.find( ',', 0, TRUE); 1135 commapos = simplifiedName.find( ',', 0, TRUE);
1147 if ( commapos >= 0 ) { 1136 if ( commapos >= 0 ) {
1148 qWarning(" Commapos: %d", commapos ); 1137 qWarning(" Commapos: %d", commapos );
1149 1138
1150 // A comma (",") separates the lastname from one or 1139 // A comma (",") separates the lastname from one or
1151 // many first names. Thus, remove the lastname from the 1140 // many first names. Thus, remove the lastname from the
1152 // String and parse the firstnames. 1141 // String and parse the firstnames.
1153 1142
1154 strLastName = simplifiedName.left( commapos ); 1143 strLastName = simplifiedName.left( commapos );
1155 simplifiedName= simplifiedName.mid( commapos + 1 ); 1144 simplifiedName= simplifiedName.mid( commapos + 1 );
1156 haveLastName = true; 1145 haveLastName = true;
1157 qWarning("Fullname without ',': %s", simplifiedName.latin1()); 1146 qWarning("Fullname without ',': %s", simplifiedName.latin1());
1158 1147
1159 // If we have any lastname, we should now split all first names. 1148 // If we have any lastname, we should now split all first names.
1160 // The first one will be the used as first, the rest as "middle names" 1149 // The first one will be the used as first, the rest as "middle names"
1161 1150
1162 QStringList allFirstNames = QStringList::split(" ", simplifiedName); 1151 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
1163 QStringList::Iterator it = allFirstNames.begin(); 1152 QStringList::Iterator it = allFirstNames.begin();
1164 strFirstName = *it++; 1153 strFirstName = *it++;
1165 QStringList allSecondNames; 1154 QStringList allSecondNames;
1166 for ( ; it != allFirstNames.end(); ++it ) 1155 for ( ; it != allFirstNames.end(); ++it )
1167 allSecondNames.append( *it ); 1156 allSecondNames.append( *it );
1168 1157
1169 strMiddleName = allSecondNames.join(" "); 1158 strMiddleName = allSecondNames.join(" ");
1170 1159
1171 } else { 1160 } else {
1172 1161
1173 // No comma separator used: We use the first word as firstname, the 1162 // No comma separator used: We use the first word as firstname, the
1174 // last as second/lastname and everything in the middle as middlename 1163 // last as second/lastname and everything in the middle as middlename
1175 1164
1176 QStringList allNames = QStringList::split(" ", simplifiedName); 1165 QStringList allNames = QStringList::split(" ", simplifiedName);
1177 QStringList::Iterator it = allNames.begin(); 1166 QStringList::Iterator it = allNames.begin();
1178 strFirstName = *it++; 1167 strFirstName = *it++;
1179 QStringList allSecondNames; 1168 QStringList allSecondNames;
1180 for ( ; it != --allNames.end(); ++it ) 1169 for ( ; it != --allNames.end(); ++it )
1181 allSecondNames.append( *it ); 1170 allSecondNames.append( *it );
1182 1171
1183 strMiddleName = allSecondNames.join(" "); 1172 strMiddleName = allSecondNames.join(" ");
1184 strLastName = *(--allNames.end()); 1173 strLastName = *(--allNames.end());
1185 1174
1186 } 1175 }
1187 1176
1188 if ( strFirstName == strLastName ) 1177 if ( strFirstName == strLastName )
1189 strFirstName = ""; 1178 strFirstName = "";
1190 1179
1191 qWarning(" strFirstName: %s", strFirstName.latin1()); 1180 qWarning(" strFirstName: %s", strFirstName.latin1());
1192 qWarning(" strMiddleName: %s", strMiddleName.latin1()); 1181 qWarning(" strMiddleName: %s", strMiddleName.latin1());
1193 qWarning(" strLastName: %s", strLastName.latin1()); 1182 qWarning(" strLastName: %s", strLastName.latin1());
1194 qWarning(" strTitle: %s", strTitle.latin1()); 1183 qWarning(" strTitle: %s", strTitle.latin1());
1195 1184
1196 switch (type) { 1185 switch (type) {
1197 case NAME_FL: 1186 case NAME_FL:
1198 return strFirstName + " " + strLastName; 1187 return strFirstName + " " + strLastName;
1199 1188
1200 case NAME_LF: 1189 case NAME_LF:
1201 return strLastName + ", " + strFirstName; 1190 return strLastName + ", " + strFirstName;
1202 1191
1203 case NAME_LFM: 1192 case NAME_LFM:
1204 return strLastName + ", " + strFirstName + " " + strMiddleName; 1193 return strLastName + ", " + strFirstName + " " + strMiddleName;
1205 1194
1206 case NAME_FML: 1195 case NAME_FML:
1207 return strFirstName + " " + strMiddleName + " " + strLastName ; 1196 return strFirstName + " " + strMiddleName + " " + strLastName ;
1208 1197
1209 case NAME_F: 1198 case NAME_F:
1210 return strFirstName; 1199 return strFirstName;
1211 1200
1212 case NAME_M: 1201 case NAME_M:
1213 return strMiddleName; 1202 return strMiddleName;
1214 1203
1215 case NAME_L: 1204 case NAME_L:
1216 return strLastName; 1205 return strLastName;
1217 1206
1218 case NAME_S: 1207 case NAME_S:
1219 return txtSuffix->text(); 1208 return txtSuffix->text();
1220 1209
1221 } 1210 }
1222 return QString::null; 1211 return QString::null;
1223} 1212}
1224 1213
1225void ContactEditor::cleanupFields() { 1214void ContactEditor::cleanupFields() {
1226 QStringList::Iterator it = slChooserValues.begin(); 1215 QStringList::Iterator it = slChooserValues.begin();
1227 1216
1228 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { 1217 for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
1229 (*it) = ""; 1218 (*it) = "";
1230 } 1219 }
1231 1220
1232 for ( int i = 0; i < 7; i++ ) { 1221 for ( int i = 0; i < 7; i++ ) {
1233 slHomeAddress[i] = ""; 1222 slHomeAddress[i] = "";
1234 slBusinessAddress[i] = ""; 1223 slBusinessAddress[i] = "";
1235 } 1224 }
1236 1225
1237 QListIterator<QLineEdit> itLV( listValue ); 1226 QListIterator<QLineEdit> itLV( listValue );
1238 for ( ; itLV.current(); ++itLV ) { 1227 for ( ; itLV.current(); ++itLV ) {
1239 (*itLV)->setText( "" ); 1228 (*itLV)->setText( "" );
1240 } 1229 }
1241 1230
1242 txtFirstName->setText(""); 1231 txtFirstName->setText("");
1243 txtMiddleName->setText(""); 1232 txtMiddleName->setText("");
1244 txtLastName->setText(""); 1233 txtLastName->setText("");
1245 txtSuffix->setText(""); 1234 txtSuffix->setText("");
1246 txtNote->setText(""); 1235 txtNote->setText("");
1247 txtFullName->setText(""); 1236 txtFullName->setText("");
1248 txtJobTitle->setText(""); 1237 txtJobTitle->setText("");
1249 txtOrganization->setText(""); 1238 txtOrganization->setText("");
1250 txtChooserField1->setText(""); 1239 txtChooserField1->setText("");
1251 txtChooserField2->setText(""); 1240 txtChooserField2->setText("");
1252 txtChooserField3->setText(""); 1241 txtChooserField3->setText("");
1253 txtAddress->setText(""); 1242 txtAddress->setText("");
1254 txtCity->setText(""); 1243 txtCity->setText("");
1255 txtState->setText(""); 1244 txtState->setText("");
1256 txtZip->setText(""); 1245 txtZip->setText("");
1257 QLineEdit *txtTmp = cmbCountry->lineEdit(); 1246 QLineEdit *txtTmp = cmbCountry->lineEdit();
1258 txtTmp->setText(""); 1247 txtTmp->setText("");
1259 txtTmp = cmbFileAs->lineEdit(); 1248 txtTmp = cmbFileAs->lineEdit();
1260 txtTmp->setText(""); 1249 txtTmp->setText("");
1261 1250
1262} 1251}
1263 1252
1264void ContactEditor::setEntry( const OContact &entry ) { 1253void ContactEditor::setEntry( const OContact &entry ) {
1265 1254
1266 initializing = true; 1255 initializing = true;
1267 1256
1268 // Cleanup and activate the general Page .. 1257 // Cleanup and activate the general Page ..
1269 cleanupFields(); 1258 cleanupFields();
1270 tabMain->setCurrentPage( 0 ); 1259 tabMain->setCurrentPage( 0 );
1271 1260
1272 ent = entry; 1261 ent = entry;
1273 1262
1274 emails = QStringList(ent.emailList()); 1263 emails = QStringList(ent.emailList());
1275 defaultEmail = ent.defaultEmail(); 1264 defaultEmail = ent.defaultEmail();
1276 if (defaultEmail.isEmpty()) defaultEmail = emails[0]; 1265 if (defaultEmail.isEmpty()) defaultEmail = emails[0];
1277 qDebug("default email=%s",defaultEmail.latin1()); 1266 qDebug("default email=%s",defaultEmail.latin1());
1278 1267
1279 txtFirstName->setText( ent.firstName() ); 1268 txtFirstName->setText( ent.firstName() );
1280 txtMiddleName->setText( ent.middleName() ); 1269 txtMiddleName->setText( ent.middleName() );
1281 txtLastName->setText( ent.lastName() ); 1270 txtLastName->setText( ent.lastName() );
1282 txtSuffix->setText( ent.suffix() ); 1271 txtSuffix->setText( ent.suffix() );
1283 1272
1284 // QString *tmpString = new QString; 1273 // QString *tmpString = new QString;
1285 // *tmpString = ent.firstName() + " " + ent.middleName() + 1274 // *tmpString = ent.firstName() + " " + ent.middleName() +
1286 // + " " + ent.lastName() + " " + ent.suffix(); 1275 // + " " + ent.lastName() + " " + ent.suffix();
1287 //txtFullName->setText( tmpString->simplifyWhiteSpace() ); 1276 //txtFullName->setText( tmpString->simplifyWhiteSpace() );
1288 1277
1289 if ( !ent.isEmpty() ){ 1278 if ( !ent.isEmpty() ){
1290 // Lastnames with multiple words need to be protected by a comma ! 1279 // Lastnames with multiple words need to be protected by a comma !
1291 if ( ent.lastName().contains( ' ', TRUE ) ) 1280 if ( ent.lastName().contains( ' ', TRUE ) )
1292 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() ); 1281 txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
1293 else 1282 else
1294 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() ); 1283 txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
1295 } 1284 }
1296 1285
1297 cmbFileAs->setEditText( ent.fileAs() ); 1286 cmbFileAs->setEditText( ent.fileAs() );
1298 1287
1299 //if (hasTitle) 1288 //if (hasTitle)
1300 txtJobTitle->setText( ent.jobTitle() ); 1289 txtJobTitle->setText( ent.jobTitle() );
1301 1290
1302 //if (hasCompany) 1291 //if (hasCompany)
1303 txtOrganization->setText( ent.company() ); 1292 txtOrganization->setText( ent.company() );
1304 1293
1305 //if (hasNotes) 1294 //if (hasNotes)
1306 txtNote->setText( ent.notes() ); 1295 txtNote->setText( ent.notes() );
1307 1296
1308 //if (hasStreet) { 1297 //if (hasStreet) {
1309 slHomeAddress[0] = ent.homeStreet(); 1298 slHomeAddress[0] = ent.homeStreet();
1310 slBusinessAddress[0] = ent.businessStreet(); 1299 slBusinessAddress[0] = ent.businessStreet();
1311 //} 1300 //}
1312 1301
1313 //if (hasCity) { 1302 //if (hasCity) {
1314 slHomeAddress[3] = ent.homeCity(); 1303 slHomeAddress[3] = ent.homeCity();
1315 slBusinessAddress[3] = ent.businessCity(); 1304 slBusinessAddress[3] = ent.businessCity();
1316 //} 1305 //}
1317 1306
1318 //if (hasState) { 1307 //if (hasState) {
1319 slHomeAddress[4] = ent.homeState(); 1308 slHomeAddress[4] = ent.homeState();
1320 slBusinessAddress[4] = ent.businessState(); 1309 slBusinessAddress[4] = ent.businessState();
1321 //} 1310 //}
1322 1311
1323 //if (hasZip) { 1312 //if (hasZip) {
1324 slHomeAddress[5] = ent.homeZip(); 1313 slHomeAddress[5] = ent.homeZip();
1325 slBusinessAddress[5] = ent.businessZip(); 1314 slBusinessAddress[5] = ent.businessZip();
1326 //} 1315 //}
1327 1316
1328 //if (hasCountry) { 1317 //if (hasCountry) {
1329 slHomeAddress[6] = ent.homeCountry(); 1318 slHomeAddress[6] = ent.homeCountry();
1330 slBusinessAddress[6] = ent.businessCountry(); 1319 slBusinessAddress[6] = ent.businessCountry();
1331 //} 1320 //}
1332 1321
1333 QStringList::ConstIterator it; 1322 QStringList::ConstIterator it;
1334 QListIterator<QLineEdit> itLE( listValue ); 1323 QListIterator<QLineEdit> itLE( listValue );
1335 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) { 1324 for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
1336 1325
1337 qWarning(" Filling dynamic Field: %s", (*it).latin1() ); 1326 qWarning(" Filling dynamic Field: %s", (*it).latin1() );
1338 1327
1339 if ( *it == "Department" ) 1328 if ( *it == "Department" )
1340 (*itLE)->setText( ent.department() ); 1329 (*itLE)->setText( ent.department() );
1341 1330
1342 if ( *it == "Company" ) 1331 if ( *it == "Company" )
1343 (*itLE)->setText( ent.company() ); 1332 (*itLE)->setText( ent.company() );
1344 1333
1345 if ( *it == "Office" ) 1334 if ( *it == "Office" )
1346 (*itLE)->setText( ent.office() ); 1335 (*itLE)->setText( ent.office() );
1347 1336
1348 if ( *it == "Profession" ) 1337 if ( *it == "Profession" )
1349 (*itLE)->setText( ent.profession() ); 1338 (*itLE)->setText( ent.profession() );
1350 1339
1351 if ( *it == "Assistant" ) 1340 if ( *it == "Assistant" )
1352 (*itLE)->setText( ent.assistant() ); 1341 (*itLE)->setText( ent.assistant() );
1353 1342
1354 if ( *it == "Manager" ) 1343 if ( *it == "Manager" )
1355 (*itLE)->setText( ent.manager() ); 1344 (*itLE)->setText( ent.manager() );
1356 1345
1357 if ( *it == "Spouse" ) 1346 if ( *it == "Spouse" )
1358 (*itLE)->setText( ent.spouse() ); 1347 (*itLE)->setText( ent.spouse() );
1359 1348
1360 if ( *it == "Nickname" ){ 1349 if ( *it == "Nickname" ){
1361 qWarning("**** Nichname: %s", ent.nickname().latin1() ); 1350 qWarning("**** Nichname: %s", ent.nickname().latin1() );
1362 (*itLE)->setText( ent.nickname() ); 1351 (*itLE)->setText( ent.nickname() );
1363 } 1352 }
1364 1353
1365 if ( *it == "Children" ) 1354 if ( *it == "Children" )
1366 (*itLE)->setText( ent.children() ); 1355 (*itLE)->setText( ent.children() );
1367 1356
1368 } 1357 }
1369 1358
1370 QStringList::Iterator itV; 1359 QStringList::Iterator itV;
1371 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1360 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1372 1361
1373 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) 1362 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
1374 *itV = ent.businessPhone(); 1363 *itV = ent.businessPhone();
1375 /* 1364 /*
1376 if ( *it == "Business 2 Phone" ) 1365 if ( *it == "Business 2 Phone" )
1377 *itV = ent.business2Phone(); 1366 *itV = ent.business2Phone();
1378 */ 1367 */
1379 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) 1368 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
1380 *itV = ent.businessFax(); 1369 *itV = ent.businessFax();
1381 1370
1382 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) 1371 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
1383 *itV = ent.businessMobile(); 1372 *itV = ent.businessMobile();
1384 /* 1373 /*
1385 if ( *it == "Company Phone" ) 1374 if ( *it == "Company Phone" )
1386 *itV = ent.companyPhone(); 1375 *itV = ent.companyPhone();
1387 */ 1376 */
1388 if ( *it == "Default Email" ) 1377 if ( *it == "Default Email" )
1389 *itV = ent.defaultEmail(); 1378 *itV = ent.defaultEmail();
1390 1379
1391 if ( *it == "Emails" ) 1380 if ( *it == "Emails" )
1392 *itV = ent.emailList().join(", "); // :SX 1381 *itV = ent.emailList().join(", "); // :SX
1393 1382
1394 if ( *it == "Home Phone" ) 1383 if ( *it == "Home Phone" )
1395 *itV = ent.homePhone(); 1384 *itV = ent.homePhone();
1396 /* 1385 /*
1397 if ( *it == "Home 2 Phone" ) 1386 if ( *it == "Home 2 Phone" )
1398 *itV = ent.home2Phone(); 1387 *itV = ent.home2Phone();
1399 */ 1388 */
1400 if ( *it == "Home Fax" ) 1389 if ( *it == "Home Fax" )
1401 *itV = ent.homeFax(); 1390 *itV = ent.homeFax();
1402 1391
1403 if ( *it == "Home Mobile" ) 1392 if ( *it == "Home Mobile" )
1404 *itV = ent.homeMobile(); 1393 *itV = ent.homeMobile();
1405 /* 1394 /*
1406 if ( *it == "Car Phone" ) 1395 if ( *it == "Car Phone" )
1407 *itV = ent.carPhone(); 1396 *itV = ent.carPhone();
1408 1397
1409 if ( *it == "ISDN Phone" ) 1398 if ( *it == "ISDN Phone" )
1410 *itV = ent.ISDNPhone(); 1399 *itV = ent.ISDNPhone();
1411 1400
1412 if ( *it == "Other Phone" ) 1401 if ( *it == "Other Phone" )
1413 *itV = ent.otherPhone(); 1402 *itV = ent.otherPhone();
1414 */ 1403 */
1415 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1404 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1416 *itV = ent.businessPager(); 1405 *itV = ent.businessPager();
1417 /* 1406 /*
1418 if ( *it == "Home Pager") 1407 if ( *it == "Home Pager")
1419 *itV = ent.homePager(); 1408 *itV = ent.homePager();
1420 1409
1421 if ( *it == "AIM IM" ) 1410 if ( *it == "AIM IM" )
1422 *itV = ent.AIMIM(); 1411 *itV = ent.AIMIM();
1423 1412
1424 if ( *it == "ICQ IM" ) 1413 if ( *it == "ICQ IM" )
1425 *itV = ent.ICQIM(); 1414 *itV = ent.ICQIM();
1426 1415
1427 if ( *it == "Jabber IM" ) 1416 if ( *it == "Jabber IM" )
1428 *itV = ent.jabberIM(); 1417 *itV = ent.jabberIM();
1429 1418
1430 if ( *it == "MSN IM" ) 1419 if ( *it == "MSN IM" )
1431 *itV = ent.MSNIM(); 1420 *itV = ent.MSNIM();
1432 1421
1433 if ( *it == "Yahoo IM" ) 1422 if ( *it == "Yahoo IM" )
1434 *itV = ent.yahooIM(); 1423 *itV = ent.yahooIM();
1435 */ 1424 */
1436 if ( *it == "Home Web Page" ) 1425 if ( *it == "Home Web Page" )
1437 *itV = ent.homeWebpage(); 1426 *itV = ent.homeWebpage();
1438 1427
1439 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1428 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1440 *itV = ent.businessWebpage(); 1429 *itV = ent.businessWebpage();
1441 1430
1442 1431
1443 } 1432 }
1444 1433
1445 1434
1446 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); 1435 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
1447 1436
1448 QString gender = ent.gender(); 1437 QString gender = ent.gender();
1449 cmbGender->setCurrentItem( gender.toInt() ); 1438 cmbGender->setCurrentItem( gender.toInt() );
1450 1439
1451 txtNote->setText( ent.notes() ); 1440 txtNote->setText( ent.notes() );
1452 1441
1453 slotAddressTypeChange( cmbAddress->currentItem() ); 1442 slotAddressTypeChange( cmbAddress->currentItem() );
1454 1443
1455 // Get combo-settings from contact and set preset.. 1444 // Get combo-settings from contact and set preset..
1456 contactfields.loadFromRecord( ent ); 1445 contactfields.loadFromRecord( ent );
1457 cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) ); 1446 cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) );
1458 cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) ); 1447 cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) );
1459 cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) ); 1448 cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) );
1460 cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) ); 1449 cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) );
1461 cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) ); 1450 cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) );
1462 slotCmbChooser1Change( cmbChooserField1->currentItem() ); 1451 slotCmbChooser1Change( cmbChooserField1->currentItem() );
1463 slotCmbChooser2Change( cmbChooserField2->currentItem() ); 1452 slotCmbChooser2Change( cmbChooserField2->currentItem() );
1464 slotCmbChooser3Change( cmbChooserField3->currentItem() ); 1453 slotCmbChooser3Change( cmbChooserField3->currentItem() );
1465 slotCmbChooser4Change( cmbChooserField4->currentItem() ); 1454 slotCmbChooser4Change( cmbChooserField4->currentItem() );
1466 slotAddressTypeChange( cmbAddress->currentItem() ); 1455 slotAddressTypeChange( cmbAddress->currentItem() );
1467 1456
1468 updateDatePicker(); 1457 updateDatePicker();
1469 1458
1470 initializing = false; 1459 initializing = false;
1471} 1460}
1472void ContactEditor::updateDatePicker() 1461void ContactEditor::updateDatePicker()
1473{ 1462{
1474 // Set DatePicker 1463 // Set DatePicker
1475 if ( !ent.birthday().isNull() ){ 1464 if ( !ent.birthday().isNull() ){
1476 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); 1465 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
1477 birthdayPicker->setDate( ent.birthday() ); 1466 birthdayPicker->setDate( ent.birthday() );
1478 } else 1467 } else
1479 birthdayButton->setText( tr ("Unknown") ); 1468 birthdayButton->setText( tr ("Unknown") );
1480 1469
1481 if ( !ent.anniversary().isNull() ){ 1470 if ( !ent.anniversary().isNull() ){
1482 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); 1471 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
1483 anniversaryPicker->setDate( ent.anniversary() ); 1472 anniversaryPicker->setDate( ent.anniversary() );
1484 } else 1473 } else
1485 anniversaryButton->setText( tr ("Unknown") ); 1474 anniversaryButton->setText( tr ("Unknown") );
1486 1475
1487} 1476}
1488 1477
1489void ContactEditor::saveEntry() { 1478void ContactEditor::saveEntry() {
1490 1479
1491 // Store current combo into contact 1480 // Store current combo into contact
1492 contactfields.saveToRecord( ent ); 1481 contactfields.saveToRecord( ent );
1493 1482
1494 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); 1483 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
1495 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); 1484 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
1496 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); 1485 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
1497 // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); 1486 // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
1498 1487
1499 ent.setFirstName( txtFirstName->text() ); 1488 ent.setFirstName( txtFirstName->text() );
1500 ent.setLastName( txtLastName->text() ); 1489 ent.setLastName( txtLastName->text() );
1501 ent.setMiddleName( txtMiddleName->text() ); 1490 ent.setMiddleName( txtMiddleName->text() );
1502 ent.setSuffix( txtSuffix->text() ); 1491 ent.setSuffix( txtSuffix->text() );
1503 1492
1504 ent.setFileAs( cmbFileAs->currentText() ); 1493 ent.setFileAs( cmbFileAs->currentText() );
1505 1494
1506 ent.setCategories( cmbCat->currentCategories() ); 1495 ent.setCategories( cmbCat->currentCategories() );
1507 1496
1508 1497
1509 //if (hasTitle) 1498 //if (hasTitle)
1510 ent.setJobTitle( txtJobTitle->text() ); 1499 ent.setJobTitle( txtJobTitle->text() );
1511 1500
1512 //if (hasCompany) 1501 //if (hasCompany)
1513 ent.setCompany( txtOrganization->text() ); 1502 ent.setCompany( txtOrganization->text() );
1514 1503
1515 //if (hasNotes) 1504 //if (hasNotes)
1516 ent.setNotes( txtNote->text() ); 1505 ent.setNotes( txtNote->text() );
1517 1506
1518 //if (hasStreet) { 1507 //if (hasStreet) {
1519 ent.setHomeStreet( slHomeAddress[0] ); 1508 ent.setHomeStreet( slHomeAddress[0] );
1520 ent.setBusinessStreet( slBusinessAddress[0] ); 1509 ent.setBusinessStreet( slBusinessAddress[0] );
1521 //} 1510 //}
1522 1511
1523 //if (hasCity) { 1512 //if (hasCity) {
1524 ent.setHomeCity( slHomeAddress[3] ); 1513 ent.setHomeCity( slHomeAddress[3] );
1525 ent.setBusinessCity( slBusinessAddress[3] ); 1514 ent.setBusinessCity( slBusinessAddress[3] );
1526 //} 1515 //}
1527 1516
1528 //if (hasState) { 1517 //if (hasState) {
1529 ent.setHomeState( slHomeAddress[4] ); 1518 ent.setHomeState( slHomeAddress[4] );
1530 ent.setBusinessState( slBusinessAddress[4] ); 1519 ent.setBusinessState( slBusinessAddress[4] );
1531 //} 1520 //}
1532 1521
1533 //if (hasZip) { 1522 //if (hasZip) {
1534 ent.setHomeZip( slHomeAddress[5] ); 1523 ent.setHomeZip( slHomeAddress[5] );
1535 ent.setBusinessZip( slBusinessAddress[5] ); 1524 ent.setBusinessZip( slBusinessAddress[5] );
1536 //} 1525 //}
1537 1526
1538 //if (hasCountry) { 1527 //if (hasCountry) {
1539 ent.setHomeCountry( slHomeAddress[6] ); 1528 ent.setHomeCountry( slHomeAddress[6] );
1540 ent.setBusinessCountry( slBusinessAddress[6] ); 1529 ent.setBusinessCountry( slBusinessAddress[6] );
1541 //} 1530 //}
1542 1531
1543 QStringList::ConstIterator it; 1532 QStringList::ConstIterator it;
1544 QListIterator<QLineEdit> itLE( listValue ); 1533 QListIterator<QLineEdit> itLE( listValue );
1545 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { 1534 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) {
1546 1535
1547 if ( *it == "Department" ) 1536 if ( *it == "Department" )
1548 ent.setDepartment( (*itLE)->text() ); 1537 ent.setDepartment( (*itLE)->text() );
1549 1538
1550 if ( *it == "Company" ) 1539 if ( *it == "Company" )
1551 ent.setCompany( (*itLE)->text() ); 1540 ent.setCompany( (*itLE)->text() );
1552 1541
1553 if ( *it == "Office" ) 1542 if ( *it == "Office" )
1554 ent.setOffice( (*itLE)->text() ); 1543 ent.setOffice( (*itLE)->text() );
1555 1544
1556 if ( *it == "Profession" ) 1545 if ( *it == "Profession" )
1557 ent.setProfession( (*itLE)->text() ); 1546 ent.setProfession( (*itLE)->text() );
1558 1547
1559 if ( *it == "Assistant" ) 1548 if ( *it == "Assistant" )
1560 ent.setAssistant( (*itLE)->text() ); 1549 ent.setAssistant( (*itLE)->text() );
1561 1550
1562 if ( *it == "Manager" ) 1551 if ( *it == "Manager" )
1563 ent.setManager( (*itLE)->text() ); 1552 ent.setManager( (*itLE)->text() );
1564 1553
1565 if ( *it == "Spouse" ) 1554 if ( *it == "Spouse" )
1566 ent.setSpouse( (*itLE)->text() ); 1555 ent.setSpouse( (*itLE)->text() );
1567 1556
1568 if ( *it == "Nickname" ) 1557 if ( *it == "Nickname" )
1569 ent.setNickname( (*itLE)->text() ); 1558 ent.setNickname( (*itLE)->text() );
1570 1559
1571 if ( *it == "Children" ) 1560 if ( *it == "Children" )
1572 ent.setChildren( (*itLE)->text() ); 1561 ent.setChildren( (*itLE)->text() );
1573 1562
1574 } 1563 }
1575 1564
1576 1565
1577 QStringList::ConstIterator itV; 1566 QStringList::ConstIterator itV;
1578 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1567 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1579 1568
1580 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) 1569 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
1581 ent.setBusinessPhone( *itV ); 1570 ent.setBusinessPhone( *itV );
1582 1571
1583 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) 1572 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
1584 ent.setBusinessFax( *itV ); 1573 ent.setBusinessFax( *itV );
1585 1574
1586 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) 1575 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
1587 ent.setBusinessMobile( *itV ); 1576 ent.setBusinessMobile( *itV );
1588 1577
1589 if ( *it == "Emails" ){ 1578 if ( *it == "Emails" ){
1590 QString allemail; 1579 QString allemail;
1591 QString defaultmail; 1580 QString defaultmail;
1592 parseEmailFrom( emails.join(","), defaultmail, allemail ); 1581 parseEmailFrom( emails.join(","), defaultmail, allemail );
1593 if ( defaultEmail.isEmpty() ){ 1582 if ( defaultEmail.isEmpty() ){
1594 qWarning("Default email was not set by user!"); 1583 qWarning("Default email was not set by user!");
1595 qWarning("Using first email in list: %s", defaultmail.latin1()); 1584 qWarning("Using first email in list: %s", defaultmail.latin1());
1596 ent.setDefaultEmail( defaultmail ); 1585 ent.setDefaultEmail( defaultmail );
1597 } 1586 }
1598 ent.setEmails( allemail ); 1587 ent.setEmails( allemail );
1599 } 1588 }
1600 1589
1601 if ( *it == "Default Email") 1590 if ( *it == "Default Email")
1602 ent.setDefaultEmail( defaultEmail /* *itV */ ); 1591 ent.setDefaultEmail( defaultEmail /* *itV */ );
1603 1592
1604 if ( *it == "Home Phone" ) 1593 if ( *it == "Home Phone" )
1605 ent.setHomePhone( *itV ); 1594 ent.setHomePhone( *itV );
1606 1595
1607 if ( *it == "Home Fax" ) 1596 if ( *it == "Home Fax" )
1608 ent.setHomeFax( *itV ); 1597 ent.setHomeFax( *itV );
1609 1598
1610 if ( *it == "Home Mobile" ) 1599 if ( *it == "Home Mobile" )
1611 ent.setHomeMobile( *itV ); 1600 ent.setHomeMobile( *itV );
1612 1601
1613 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1602 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1614 ent.setBusinessPager( *itV ); 1603 ent.setBusinessPager( *itV );
1615 1604
1616 if ( *it == "Home Web Page" ) 1605 if ( *it == "Home Web Page" )
1617 ent.setHomeWebpage( *itV ); 1606 ent.setHomeWebpage( *itV );
1618 1607
1619 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1608 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1620 ent.setBusinessWebpage( *itV ); 1609 ent.setBusinessWebpage( *itV );
1621 1610
1622 1611
1623 } 1612 }
1624 1613
1625 int gender = cmbGender->currentItem(); 1614 int gender = cmbGender->currentItem();
1626 ent.setGender( QString::number( gender ) ); 1615 ent.setGender( QString::number( gender ) );
1627 1616
1628 QString str = txtNote->text(); 1617 QString str = txtNote->text();
1629 if ( !str.isNull() ) 1618 if ( !str.isNull() )
1630 ent.setNotes( str ); 1619 ent.setNotes( str );
1631 1620
1632} 1621}
1633 1622
1634void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 1623void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
1635 QString &strAll ) 1624 QString &strAll )
1636{ 1625{
1637 int where, 1626 int where,
1638 start; 1627 start;
1639 if ( txt.isEmpty() ) 1628 if ( txt.isEmpty() )
1640 return; 1629 return;
1641 // find the first 1630 // find the first
1642 where = txt.find( ',' ); 1631 where = txt.find( ',' );
1643 if ( where < 0 ) { 1632 if ( where < 0 ) {
1644 strDefaultEmail = txt; 1633 strDefaultEmail = txt;
1645 strAll = txt; 1634 strAll = txt;
1646 } else { 1635 } else {
1647 strDefaultEmail = txt.left( where ).stripWhiteSpace(); 1636 strDefaultEmail = txt.left( where ).stripWhiteSpace();
1648 strAll = strDefaultEmail; 1637 strAll = strDefaultEmail;
1649 while ( where > -1 ) { 1638 while ( where > -1 ) {
1650 strAll.append(" "); 1639 strAll.append(" ");
1651 start = where; 1640 start = where;
1652 where = txt.find( ',', where + 1 ); 1641 where = txt.find( ',', where + 1 );
1653 if ( where > - 1 ) 1642 if ( where > - 1 )
1654 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); 1643 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
1655 else // grab until the end... 1644 else // grab until the end...
1656 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); 1645 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
1657 } 1646 }
1658 } 1647 }
1659} 1648}
1660 1649
1661void parseEmailTo( const QString &strDefaultEmail, 1650void parseEmailTo( const QString &strDefaultEmail,
1662 const QString &strOtherEmail, QString &strBack ) 1651 const QString &strOtherEmail, QString &strBack )
1663{ 1652{
1664 // create a comma dilimeted set of emails... 1653 // create a comma dilimeted set of emails...
1665 // use the power of short circuiting... 1654 // use the power of short circuiting...
1666 bool foundDefault = false; 1655 bool foundDefault = false;
1667 QString strTmp; 1656 QString strTmp;
1668 int start = 0; 1657 int start = 0;
1669 int where; 1658 int where;
1670 // start at the beginng. 1659 // start at the beginng.
1671 strBack = strDefaultEmail; 1660 strBack = strDefaultEmail;
1672 where = 0; 1661 where = 0;
1673 while ( where > -1 ) { 1662 while ( where > -1 ) {
1674 start = where; 1663 start = where;
1675 where = strOtherEmail.find( ' ', where + 1 ); 1664 where = strOtherEmail.find( ' ', where + 1 );
1676 if ( where > 0 ) { 1665 if ( where > 0 ) {
1677 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); 1666 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
1678 } else 1667 } else
1679 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); 1668 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
1680 if ( foundDefault || strTmp != strDefaultEmail ) { 1669 if ( foundDefault || strTmp != strDefaultEmail ) {
1681 strBack.append( ", " ); 1670 strBack.append( ", " );
1682 strBack.append( strTmp ); 1671 strBack.append( strTmp );
1683 } else 1672 } else
1684 foundDefault = true; 1673 foundDefault = true;
1685 } 1674 }
1686} 1675}
1687 1676
1688 1677
1689static inline bool containsAlphaNum( const QString &str ) 1678static inline bool containsAlphaNum( const QString &str )
1690{ 1679{
1691 int i, 1680 int i,
1692 count = str.length(); 1681 count = str.length();
1693 for ( i = 0; i < count; i++ ) 1682 for ( i = 0; i < count; i++ )
1694 if ( !str[i].isSpace() ) 1683 if ( !str[i].isSpace() )
1695 return TRUE; 1684 return TRUE;
1696 return FALSE; 1685 return FALSE;
1697} 1686}
1698 1687
1699static inline bool constainsWhiteSpace( const QString &str ) 1688static inline bool constainsWhiteSpace( const QString &str )
1700{ 1689{
1701 int i, 1690 int i,
1702 count = str.length(); 1691 count = str.length();
1703 for (i = 0; i < count; i++ ) 1692 for (i = 0; i < count; i++ )
1704 if ( str[i].isSpace() ) 1693 if ( str[i].isSpace() )
1705 return TRUE; 1694 return TRUE;
1706 return FALSE; 1695 return FALSE;
1707} 1696}
1708 1697
1709void ContactEditor::setPersonalView( bool personal ) 1698void ContactEditor::setPersonalView( bool personal )
1710{ 1699{
1711 m_personalView = personal; 1700 m_personalView = personal;
1712 1701
1713 // Currently disbled due to the fact that 1702 // Currently disbled due to the fact that
1714 // show will not work... 1703 // show will not work...
1715 return; 1704 return;
1716 1705
1717 if ( personal ){ 1706 if ( personal ){
1718 cmbCat->hide(); 1707 cmbCat->hide();
1719 labCat->hide(); 1708 labCat->hide();
1720 1709
1721 } else{ 1710 } else{
1722 cmbCat->show(); 1711 cmbCat->show();
1723 labCat->show(); 1712 labCat->show();
1724 } 1713 }
1725} 1714}
1726 1715
1727void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) 1716void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
1728{ 1717{
1729 QDate date; 1718 QDate date;
1730 date.setYMD( year, month, day ); 1719 date.setYMD( year, month, day );
1731 QString dateString = TimeString::numberDateString( date ); 1720 QString dateString = TimeString::numberDateString( date );
1732 anniversaryButton->setText( dateString ); 1721 anniversaryButton->setText( dateString );
1733 ent.setAnniversary ( date ); 1722 ent.setAnniversary ( date );
1734} 1723}
1735 1724
1736void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) 1725void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
1737{ 1726{
1738 QDate date; 1727 QDate date;
1739 date.setYMD( year, month, day ); 1728 date.setYMD( year, month, day );
1740 QString dateString = TimeString::numberDateString( date ); 1729 QString dateString = TimeString::numberDateString( date );
1741 birthdayButton->setText( dateString ); 1730 birthdayButton->setText( dateString );
1742 ent.setBirthday ( date ); 1731 ent.setBirthday ( date );
1743} 1732}
1744 1733
1745void ContactEditor::slotRemoveBirthday() 1734void ContactEditor::slotRemoveBirthday()
1746{ 1735{
1747 qWarning("void ContactEditor::slotRemoveBirthday()"); 1736 qWarning("void ContactEditor::slotRemoveBirthday()");
1748 ent.setBirthday( QDate() ); 1737 ent.setBirthday( QDate() );
1749 updateDatePicker(); 1738 updateDatePicker();
1750} 1739}
1751 1740
1752void ContactEditor::slotRemoveAnniversary() 1741void ContactEditor::slotRemoveAnniversary()
1753{ 1742{
1754 qWarning("void ContactEditor::slotRemoveAnniversary()"); 1743 qWarning("void ContactEditor::slotRemoveAnniversary()");
1755 ent.setAnniversary( QDate() ); 1744 ent.setAnniversary( QDate() );
1756 updateDatePicker(); 1745 updateDatePicker();
1757} 1746}
diff --git a/core/pim/addressbook/main.cpp b/core/pim/addressbook/main.cpp
index 97bfa6d..47d370a 100644
--- a/core/pim/addressbook/main.cpp
+++ b/core/pim/addressbook/main.cpp
@@ -1,28 +1,27 @@
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 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** 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 "addressbook.h" 21#include "addressbook.h"
22 22
23#include <qpe/qpeapplication.h>
24 23
25#include <opie/oapplicationfactory.h> 24#include <opie/oapplicationfactory.h>
26 25
27OPIE_EXPORT_APP( OApplicationFactory<AddressbookWindow> ) 26OPIE_EXPORT_APP( OApplicationFactory<AddressbookWindow> )
28 27
diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp
index 9e0c78a..7a20591 100644
--- a/core/pim/addressbook/picker.cpp
+++ b/core/pim/addressbook/picker.cpp
@@ -1,245 +1,243 @@
1#include "picker.h" 1#include "picker.h"
2 2
3#include <qfont.h>
4#include <qstring.h>
5#include <qtimer.h> 3#include <qtimer.h>
6#include <qlayout.h> 4#include <qlayout.h>
7 5
8char PickerLabel::lastLetter = '\0'; 6char PickerLabel::lastLetter = '\0';
9 7
10PickerLabel::PickerLabel( QWidget *parent, const char *name ) 8PickerLabel::PickerLabel( QWidget *parent, const char *name )
11 : QLabel ( parent, name ) 9 : QLabel ( parent, name )
12{ 10{
13 currentLetter = 0; 11 currentLetter = 0;
14 //lastLetter = 0; 12 //lastLetter = 0;
15 13
16 letter1 = '\0'; 14 letter1 = '\0';
17 letter2 = '\0'; 15 letter2 = '\0';
18 letter3 = '\0'; 16 letter3 = '\0';
19 17
20 // setFont( QFont( "smallsmooth", 9 ) ); 18 // setFont( QFont( "smallsmooth", 9 ) );
21 setFont( QFont::defaultFont() ); 19 setFont( QFont::defaultFont() );
22 setTextFormat( Qt::RichText ); 20 setTextFormat( Qt::RichText );
23 21
24} 22}
25 23
26PickerLabel::~PickerLabel() 24PickerLabel::~PickerLabel()
27{ 25{
28 26
29} 27}
30 28
31void PickerLabel::setLetters( char ch1, char ch2, char ch3 ) 29void PickerLabel::setLetters( char ch1, char ch2, char ch3 )
32{ 30{
33 QString tmpStr; 31 QString tmpStr;
34 32
35 if (ch1 != '\0') 33 if (ch1 != '\0')
36 letter1 = ch1; 34 letter1 = ch1;
37 else 35 else
38 letter1 = ' '; 36 letter1 = ' ';
39 37
40 if (ch2 != '\0') 38 if (ch2 != '\0')
41 letter2 = ch2; 39 letter2 = ch2;
42 else 40 else
43 letter2 = ' '; 41 letter2 = ' ';
44 42
45 if (ch3 != '\0') 43 if (ch3 != '\0')
46 letter3 = ch3; 44 letter3 = ch3;
47 else 45 else
48 letter3 = ' '; 46 letter3 = ' ';
49 47
50 tmpStr = "<qt>"; 48 tmpStr = "<qt>";
51 tmpStr += letter1; 49 tmpStr += letter1;
52 tmpStr += letter2; 50 tmpStr += letter2;
53 tmpStr += letter3; 51 tmpStr += letter3;
54 tmpStr += "</qt>"; 52 tmpStr += "</qt>";
55 53
56 setText(tmpStr); 54 setText(tmpStr);
57 55
58 currentLetter = 0; 56 currentLetter = 0;
59 57
60} 58}
61 59
62void PickerLabel::clearLetter() 60void PickerLabel::clearLetter()
63{ 61{
64 62
65 QString tmpStr; 63 QString tmpStr;
66 64
67 tmpStr = "<qt>"; 65 tmpStr = "<qt>";
68 tmpStr += letter1; 66 tmpStr += letter1;
69 tmpStr += letter2; 67 tmpStr += letter2;
70 tmpStr += letter3; 68 tmpStr += letter3;
71 tmpStr += "</qt>"; 69 tmpStr += "</qt>";
72 70
73 setText(tmpStr); 71 setText(tmpStr);
74 72
75 currentLetter = 0; 73 currentLetter = 0;
76 74
77} 75}
78 76
79void PickerLabel::mousePressEvent( QMouseEvent* e ) 77void PickerLabel::mousePressEvent( QMouseEvent* e )
80{ 78{
81 // If one pickerlabel is was, and an other is now selected, we 79 // If one pickerlabel is was, and an other is now selected, we
82 // have to simulate the releaseevent.. Otherwise the new label 80 // have to simulate the releaseevent.. Otherwise the new label
83 // will not get a highlighted letter.. 81 // will not get a highlighted letter..
84 // Maybe there is a more intelligent solution, but this works and I am tired.. (se) 82 // Maybe there is a more intelligent solution, but this works and I am tired.. (se)
85 if ( ( currentLetter == 0 ) && ( lastLetter != '\0' ) ) mouseReleaseEvent( e ); 83 if ( ( currentLetter == 0 ) && ( lastLetter != '\0' ) ) mouseReleaseEvent( e );
86} 84}
87 85
88void PickerLabel::mouseReleaseEvent( QMouseEvent* /* e */ ) 86void PickerLabel::mouseReleaseEvent( QMouseEvent* /* e */ )
89{ 87{
90 QString tmpStr; 88 QString tmpStr;
91 89
92 if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3 && lastLetter != '\0') 90 if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3 && lastLetter != '\0')
93 QTimer::singleShot( 0, this, SLOT(emitClearSignal()) ); 91 QTimer::singleShot( 0, this, SLOT(emitClearSignal()) );
94 92
95 switch (currentLetter) { 93 switch (currentLetter) {
96 case 0: 94 case 0:
97 tmpStr = "<qt><u><b><font color=\"#FF00FF\">"; 95 tmpStr = "<qt><u><b><font color=\"#FF00FF\">";
98 tmpStr += letter1; 96 tmpStr += letter1;
99 tmpStr += "</font></b></u>"; 97 tmpStr += "</font></b></u>";
100 tmpStr += letter2; 98 tmpStr += letter2;
101 tmpStr += letter3; 99 tmpStr += letter3;
102 tmpStr += "</qt>"; 100 tmpStr += "</qt>";
103 101
104 setText(tmpStr); 102 setText(tmpStr);
105 103
106 currentLetter++; 104 currentLetter++;
107 lastLetter = letter1; 105 lastLetter = letter1;
108 emit selectedLetter( letter1 ); 106 emit selectedLetter( letter1 );
109 break; 107 break;
110 108
111 case 1: 109 case 1:
112 tmpStr = "<qt>"; 110 tmpStr = "<qt>";
113 tmpStr += letter1; 111 tmpStr += letter1;
114 tmpStr += "<u><b><font color=\"#FF00FF\">"; 112 tmpStr += "<u><b><font color=\"#FF00FF\">";
115 tmpStr += letter2; 113 tmpStr += letter2;
116 tmpStr += "</font></b></u>"; 114 tmpStr += "</font></b></u>";
117 tmpStr += letter3; 115 tmpStr += letter3;
118 tmpStr += "</qt>"; 116 tmpStr += "</qt>";
119 117
120 setText(tmpStr); 118 setText(tmpStr);
121 119
122 currentLetter++; 120 currentLetter++;
123 lastLetter = letter2; 121 lastLetter = letter2;
124 emit selectedLetter( letter2 ); 122 emit selectedLetter( letter2 );
125 break; 123 break;
126 124
127 case 2: 125 case 2:
128 tmpStr = "<qt>"; 126 tmpStr = "<qt>";
129 tmpStr += letter1; 127 tmpStr += letter1;
130 tmpStr += letter2; 128 tmpStr += letter2;
131 tmpStr += "<u><b><font color=\"#FF00FF\">"; 129 tmpStr += "<u><b><font color=\"#FF00FF\">";
132 tmpStr += letter3; 130 tmpStr += letter3;
133 tmpStr += "</font></b></u></qt>"; 131 tmpStr += "</font></b></u></qt>";
134 132
135 setText(tmpStr); 133 setText(tmpStr);
136 134
137 currentLetter++; 135 currentLetter++;
138 lastLetter = letter3; 136 lastLetter = letter3;
139 emit selectedLetter( letter3 ); 137 emit selectedLetter( letter3 );
140 break; 138 break;
141 139
142 default: 140 default:
143 clearLetter(); 141 clearLetter();
144 lastLetter = '\0'; 142 lastLetter = '\0';
145 emit selectedLetter( '\0' ); 143 emit selectedLetter( '\0' );
146 144
147 145
148 } 146 }
149} 147}
150 148
151void PickerLabel::emitClearSignal() { 149void PickerLabel::emitClearSignal() {
152 emit clearAll(); 150 emit clearAll();
153} 151}
154 152
155LetterPicker::LetterPicker( QWidget *parent, const char *name ) 153LetterPicker::LetterPicker( QWidget *parent, const char *name )
156 : QFrame( parent, name ) 154 : QFrame( parent, name )
157{ 155{
158 QHBoxLayout *l = new QHBoxLayout(this); 156 QHBoxLayout *l = new QHBoxLayout(this);
159 157
160 lblABC = new PickerLabel( this ); 158 lblABC = new PickerLabel( this );
161 l->addWidget( lblABC ); 159 l->addWidget( lblABC );
162 160
163 lblDEF = new PickerLabel( this ); 161 lblDEF = new PickerLabel( this );
164 l->addWidget( lblDEF ); 162 l->addWidget( lblDEF );
165 163
166 lblGHI = new PickerLabel( this ); 164 lblGHI = new PickerLabel( this );
167 l->addWidget( lblGHI ); 165 l->addWidget( lblGHI );
168 166
169 lblJKL = new PickerLabel( this ); 167 lblJKL = new PickerLabel( this );
170 l->addWidget( lblJKL ); 168 l->addWidget( lblJKL );
171 169
172 lblMNO = new PickerLabel( this ); 170 lblMNO = new PickerLabel( this );
173 l->addWidget( lblMNO ); 171 l->addWidget( lblMNO );
174 172
175 lblPQR = new PickerLabel( this ); 173 lblPQR = new PickerLabel( this );
176 l->addWidget( lblPQR ); 174 l->addWidget( lblPQR );
177 175
178 lblSTU = new PickerLabel( this ); 176 lblSTU = new PickerLabel( this );
179 l->addWidget( lblSTU ); 177 l->addWidget( lblSTU );
180 178
181 lblVWX = new PickerLabel( this ); 179 lblVWX = new PickerLabel( this );
182 l->addWidget( lblVWX ); 180 l->addWidget( lblVWX );
183 181
184 lblYZ = new PickerLabel( this ); 182 lblYZ = new PickerLabel( this );
185 l->addWidget( lblYZ ); 183 l->addWidget( lblYZ );
186 184
187 lblABC->setLetters( 'A', 'B', 'C' ); 185 lblABC->setLetters( 'A', 'B', 'C' );
188 lblDEF->setLetters( 'D', 'E', 'F' ); 186 lblDEF->setLetters( 'D', 'E', 'F' );
189 lblGHI->setLetters( 'G', 'H', 'I' ); 187 lblGHI->setLetters( 'G', 'H', 'I' );
190 lblJKL->setLetters( 'J', 'K', 'L' ); 188 lblJKL->setLetters( 'J', 'K', 'L' );
191 lblMNO->setLetters( 'M', 'N', 'O' ); 189 lblMNO->setLetters( 'M', 'N', 'O' );
192 lblPQR->setLetters( 'P', 'Q', 'R' ); 190 lblPQR->setLetters( 'P', 'Q', 'R' );
193 lblSTU->setLetters( 'S', 'T', 'U' ); 191 lblSTU->setLetters( 'S', 'T', 'U' );
194 lblVWX->setLetters( 'V', 'W', 'X' ); 192 lblVWX->setLetters( 'V', 'W', 'X' );
195 lblYZ->setLetters( 'Y', 'Z', '#' ); 193 lblYZ->setLetters( 'Y', 'Z', '#' );
196 194
197 connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 195 connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
198 connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 196 connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
199 connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 197 connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
200 connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 198 connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
201 connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 199 connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
202 connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 200 connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
203 connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 201 connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
204 connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 202 connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
205 connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); 203 connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
206 connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear())); 204 connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear()));
207 connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear())); 205 connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear()));
208 connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear())); 206 connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear()));
209 connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear())); 207 connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear()));
210 connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear())); 208 connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear()));
211 connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear())); 209 connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear()));
212 connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear())); 210 connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear()));
213 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear())); 211 connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear()));
214 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear())); 212 connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear()));
215 213
216} 214}
217 215
218LetterPicker::~LetterPicker() 216LetterPicker::~LetterPicker()
219{ 217{
220} 218}
221 219
222QSizePolicy LetterPicker::sizePolicy () const 220QSizePolicy LetterPicker::sizePolicy () const
223{ 221{
224 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum); 222 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum);
225} 223}
226 224
227void LetterPicker::clear() 225void LetterPicker::clear()
228{ 226{
229 lblABC->clearLetter(); 227 lblABC->clearLetter();
230 lblDEF->clearLetter(); 228 lblDEF->clearLetter();
231 lblGHI->clearLetter(); 229 lblGHI->clearLetter();
232 lblJKL->clearLetter(); 230 lblJKL->clearLetter();
233 lblMNO->clearLetter(); 231 lblMNO->clearLetter();
234 lblPQR->clearLetter(); 232 lblPQR->clearLetter();
235 lblSTU->clearLetter(); 233 lblSTU->clearLetter();
236 lblVWX->clearLetter(); 234 lblVWX->clearLetter();
237 lblYZ->clearLetter(); 235 lblYZ->clearLetter();
238} 236}
239 237
240void LetterPicker::newLetter( char letter ) 238void LetterPicker::newLetter( char letter )
241{ 239{
242 qWarning("LetterClicked"); 240 qWarning("LetterClicked");
243 emit letterClicked( letter ); 241 emit letterClicked( letter );
244 242
245} 243}
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 24affd0..af26302 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,1087 +1,1072 @@
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** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "datebook.h" 25#include "datebook.h"
26#include "datebookday.h" 26#include "datebookday.h"
27#include "datebooksettings.h" 27#include "datebooksettings.h"
28#include "datebookweek.h" 28#include "datebookweek.h"
29#include "datebookweeklst.h" 29#include "datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <qpe/datebookmonth.h> 32#include <qpe/datebookmonth.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpedebug.h>
36#include <qpe/event.h>
37#include <qpe/finddialog.h> 35#include <qpe/finddialog.h>
38#include <qpe/ir.h> 36#include <qpe/ir.h>
39#include <qmenubar.h>
40#include <qpe/qpemessagebox.h> 37#include <qpe/qpemessagebox.h>
41#include <qpe/resource.h> 38#include <qpe/resource.h>
42#include <qpe/sound.h> 39#include <qpe/sound.h>
43#include <qpe/timestring.h>
44#include <qtoolbar.h> 40#include <qtoolbar.h>
45#include <qpe/tzselect.h> 41#include <qpe/tzselect.h>
46#include <qpe/xmlreader.h>
47 42
48#include <qaction.h> 43#include <qaction.h>
49#include <qcopchannel_qws.h> 44#include <qcopchannel_qws.h>
50#include <qdatetime.h>
51#include <qdialog.h>
52#include <qfile.h>
53#include <qlabel.h>
54#include <qlayout.h> 45#include <qlayout.h>
55#include <qmessagebox.h> 46#include <qmessagebox.h>
56#include <qpopupmenu.h>
57#include <qpushbutton.h>
58#include <qregexp.h>
59#include <qtextcodec.h>
60#include <qtextstream.h>
61#include <qtimer.h> 47#include <qtimer.h>
62#include <qtl.h> 48#include <qtl.h>
63#include <qwidgetstack.h> 49#include <qwidgetstack.h>
64#include <qwindowsystem_qws.h>
65 50
66#include <sys/stat.h> 51#include <sys/stat.h>
67#include <sys/types.h> 52#include <sys/types.h>
68#include <fcntl.h> 53#include <fcntl.h>
69#include <unistd.h> 54#include <unistd.h>
70 55
71#include <stdlib.h> 56#include <stdlib.h>
72 57
73DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 58DateBook::DateBook( QWidget *parent, const char *, WFlags f )
74 : QMainWindow( parent, "datebook", f ), 59 : QMainWindow( parent, "datebook", f ),
75 aPreset( FALSE ), 60 aPreset( FALSE ),
76 presetTime( -1 ), 61 presetTime( -1 ),
77 startTime( 8 ), // an acceptable default 62 startTime( 8 ), // an acceptable default
78 rowStyle( 0 ), 63 rowStyle( 0 ),
79 bJumpToCurTime(FALSE), 64 bJumpToCurTime(FALSE),
80 syncing(FALSE), 65 syncing(FALSE),
81 inSearch(FALSE), 66 inSearch(FALSE),
82 alarmCounter(0) 67 alarmCounter(0)
83{ 68{
84 bool needEvilHack= false; // if we need an Evil Hack 69 bool needEvilHack= false; // if we need an Evil Hack
85 QTime t; 70 QTime t;
86 t.start(); 71 t.start();
87 db = new DateBookDBHack; 72 db = new DateBookDBHack;
88 qDebug("loading db t=%d", t.elapsed() ); 73 qDebug("loading db t=%d", t.elapsed() );
89 loadSettings(); 74 loadSettings();
90 setCaption( tr("Calendar") ); 75 setCaption( tr("Calendar") );
91 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 76 setIcon( Resource::loadPixmap( "datebook_icon" ) );
92 77
93 setToolBarsMovable( FALSE ); 78 setToolBarsMovable( FALSE );
94 79
95 views = new QWidgetStack( this ); 80 views = new QWidgetStack( this );
96 setCentralWidget( views ); 81 setCentralWidget( views );
97 82
98 dayView = 0; 83 dayView = 0;
99 weekView = 0; 84 weekView = 0;
100 weekLstView = 0; 85 weekLstView = 0;
101 monthView = 0; 86 monthView = 0;
102 87
103// QToolBar *bar = new QToolBar( this ); 88// QToolBar *bar = new QToolBar( this );
104// bar->setHorizontalStretchable( TRUE ); 89// bar->setHorizontalStretchable( TRUE );
105 90
106// QMenuBar *mb = new QMenuBar( bar ); 91// QMenuBar *mb = new QMenuBar( bar );
107// mb->setMargin( 0 ); 92// mb->setMargin( 0 );
108 93
109// QPopupMenu *view = new QPopupMenu( this ); 94// QPopupMenu *view = new QPopupMenu( this );
110// mb->insertItem( tr( "View" ), view ); 95// mb->insertItem( tr( "View" ), view );
111 96
112 QToolBar *sub_bar = new QToolBar(this); 97 QToolBar *sub_bar = new QToolBar(this);
113 sub_bar->setHorizontalStretchable(TRUE); 98 sub_bar->setHorizontalStretchable(TRUE);
114 99
115 QActionGroup *g = new QActionGroup( this ); 100 QActionGroup *g = new QActionGroup( this );
116 g->setExclusive( TRUE ); 101 g->setExclusive( TRUE );
117 102
118 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 );
119 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 104 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
120 a->addTo( sub_bar ); 105 a->addTo( sub_bar );
121 106
122 sub_bar->addSeparator(); 107 sub_bar->addSeparator();
123 108
124 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 );
125 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 110 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
126 a->addTo( sub_bar ); 111 a->addTo( sub_bar );
127 //a->addTo( view ); 112 //a->addTo( view );
128 113
129 sub_bar->addSeparator(); 114 sub_bar->addSeparator();
130 115
131 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 );
132 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 117 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
133 a->addTo( sub_bar ); 118 a->addTo( sub_bar );
134// a->addTo( view ); 119// a->addTo( view );
135 a->setToggleAction( TRUE ); 120 a->setToggleAction( TRUE );
136 a->setOn( TRUE ); 121 a->setOn( TRUE );
137 dayAction = a; 122 dayAction = a;
138 123
139 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 );
140 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 125 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
141 a->addTo( sub_bar ); 126 a->addTo( sub_bar );
142// a->addTo( view ); 127// a->addTo( view );
143 a->setToggleAction( TRUE ); 128 a->setToggleAction( TRUE );
144 weekAction = a; 129 weekAction = a;
145 130
146 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 );
147 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
148 a->addTo( sub_bar ); 133 a->addTo( sub_bar );
149// a->addTo( view ); 134// a->addTo( view );
150 a->setToggleAction( TRUE ); 135 a->setToggleAction( TRUE );
151 weekLstAction = a; 136 weekLstAction = a;
152 137
153 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 );
154 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 139 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
155 a->addTo( sub_bar ); 140 a->addTo( sub_bar );
156// a->addTo( view ); 141// a->addTo( view );
157 a->setToggleAction( TRUE ); 142 a->setToggleAction( TRUE );
158 monthAction = a; 143 monthAction = a;
159 144
160 sub_bar->addSeparator(); 145 sub_bar->addSeparator();
161 146
162 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 );
163 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 148 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
164 a->addTo( sub_bar ); 149 a->addTo( sub_bar );
165 150
166 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 );
167 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 152 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
168 a->addTo( sub_bar ); 153 a->addTo( sub_bar );
169 154
170 if(defaultView==DAY) viewDay(); 155 if(defaultView==DAY) viewDay();
171 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 156 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
172 if(defaultView==WEEKLST) viewWeekLst(); 157 if(defaultView==WEEKLST) viewWeekLst();
173 if(defaultView==MONTH) viewMonth(); 158 if(defaultView==MONTH) viewMonth();
174 159
175 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 160 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
176 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 161 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
177 162
178#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 163#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
179 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&)) );
180#endif 165#endif
181 166
182 // listen on QPE/System 167 // listen on QPE/System
183#if defined(Q_WS_QWS) 168#if defined(Q_WS_QWS)
184#if !defined(QT_NO_COP) 169#if !defined(QT_NO_COP)
185 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 170 QCopChannel *channel = new QCopChannel( "QPE/System", this );
186 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&)) );
187 channel = new QCopChannel( "QPE/Datebook", this ); 172 channel = new QCopChannel( "QPE/Datebook", this );
188 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&)) );
189#endif 174#endif
190#endif 175#endif
191 176
192 qDebug("done t=%d", t.elapsed() ); 177 qDebug("done t=%d", t.elapsed() );
193 178
194 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 179 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
195 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 180 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
196 /* 181 /*
197 * Here is a problem description: 182 * Here is a problem description:
198 * When Weekview is the default view 183 * When Weekview is the default view
199 * a DateBookWeekView get's created 184 * a DateBookWeekView get's created
200 * redraw() get's called. So what? 185 * redraw() get's called. So what?
201 * Remember that we're still in the c'tor 186 * Remember that we're still in the c'tor
202 * and no final layout has happened? Ok 187 * and no final layout has happened? Ok
203 * now all Events get arranged. Their x 188 * now all Events get arranged. Their x
204 * position get's determined by a QHeader 189 * position get's determined by a QHeader
205 * position. But the QHeader isn't layouted or 190 * position. But the QHeader isn't layouted or
206 * at the right position. redraw() is a slot 191 * at the right position. redraw() is a slot
207 * so we'll call it then via a singleShot 192 * so we'll call it then via a singleShot
208 * from view() 193 * from view()
209 */ 194 */
210 if( needEvilHack ){ 195 if( needEvilHack ){
211 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 196 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
212 } 197 }
213} 198}
214 199
215void DateBook::receive( const QCString &msg, const QByteArray &data ) 200void DateBook::receive( const QCString &msg, const QByteArray &data )
216{ 201{
217 QDataStream stream( data, IO_ReadOnly ); 202 QDataStream stream( data, IO_ReadOnly );
218 if ( msg == "timeChange(QString)" ) { 203 if ( msg == "timeChange(QString)" ) {
219 // update active view! 204 // update active view!
220 if ( dayAction->isOn() ) 205 if ( dayAction->isOn() )
221 viewDay(); 206 viewDay();
222 else if ( weekAction->isOn() ) 207 else if ( weekAction->isOn() )
223 viewWeek(); 208 viewWeek();
224 else if ( monthAction->isOn() ) 209 else if ( monthAction->isOn() )
225 viewMonth(); 210 viewMonth();
226 } 211 }
227 else if (msg == "editEvent(int)") { 212 else if (msg == "editEvent(int)") {
228 int uid; 213 int uid;
229 stream >> uid; 214 stream >> uid;
230 Event e=db->eventByUID(uid); 215 Event e=db->eventByUID(uid);
231 editEvent(e); 216 editEvent(e);
232 }else if (msg == "viewDefault(QDate)"){ 217 }else if (msg == "viewDefault(QDate)"){
233 QDate day; 218 QDate day;
234 stream >> day; 219 stream >> day;
235 viewDefault(day); 220 viewDefault(day);
236 } 221 }
237} 222}
238 223
239DateBook::~DateBook() 224DateBook::~DateBook()
240{ 225{
241} 226}
242 227
243void DateBook::slotSettings() 228void DateBook::slotSettings()
244{ 229{
245 DateBookSettings frmSettings( ampm, this ); 230 DateBookSettings frmSettings( ampm, this );
246 frmSettings.setStartTime( startTime ); 231 frmSettings.setStartTime( startTime );
247 frmSettings.setAlarmPreset( aPreset, presetTime ); 232 frmSettings.setAlarmPreset( aPreset, presetTime );
248 frmSettings.setJumpToCurTime( bJumpToCurTime ); 233 frmSettings.setJumpToCurTime( bJumpToCurTime );
249 frmSettings.setRowStyle( rowStyle ); 234 frmSettings.setRowStyle( rowStyle );
250 frmSettings.comboDefaultView->setCurrentItem(defaultView-1); 235 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
251 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); 236 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
252 237
253 bool found=false; 238 bool found=false;
254 for (int i=0; i<(frmSettings.comboLocation->count()); i++) { 239 for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
255 if ( frmSettings.comboLocation->text(i) == defaultLocation ) { 240 if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
256 frmSettings.comboLocation->setCurrentItem(i); 241 frmSettings.comboLocation->setCurrentItem(i);
257 found=true; 242 found=true;
258 break; 243 break;
259 } 244 }
260 } 245 }
261 if(!found) { 246 if(!found) {
262 frmSettings.comboLocation->insertItem(defaultLocation); 247 frmSettings.comboLocation->insertItem(defaultLocation);
263 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); 248 frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1);
264 } 249 }
265 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); 250 frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar"));
266 251
267 if ( QPEApplication::execDialog( &frmSettings ) ) { 252 if ( QPEApplication::execDialog( &frmSettings ) ) {
268 aPreset = frmSettings.alarmPreset(); 253 aPreset = frmSettings.alarmPreset();
269 presetTime = frmSettings.presetTime(); 254 presetTime = frmSettings.presetTime();
270 startTime = frmSettings.startTime(); 255 startTime = frmSettings.startTime();
271 bJumpToCurTime = frmSettings.jumpToCurTime(); 256 bJumpToCurTime = frmSettings.jumpToCurTime();
272 rowStyle = frmSettings.rowStyle(); 257 rowStyle = frmSettings.rowStyle();
273 defaultView=frmSettings.comboDefaultView->currentItem()+1; 258 defaultView=frmSettings.comboDefaultView->currentItem()+1;
274 weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); 259 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
275 defaultLocation=frmSettings.comboLocation->currentText(); 260 defaultLocation=frmSettings.comboLocation->currentText();
276 defaultCategories=frmSettings.comboCategory->currentCategories(); 261 defaultCategories=frmSettings.comboCategory->currentCategories();
277 262
278 if ( dayView ) { 263 if ( dayView ) {
279 dayView->setStartViewTime( startTime ); 264 dayView->setStartViewTime( startTime );
280 dayView->setJumpToCurTime( bJumpToCurTime ); 265 dayView->setJumpToCurTime( bJumpToCurTime );
281 dayView->setRowStyle( rowStyle ); 266 dayView->setRowStyle( rowStyle );
282 } 267 }
283 if ( weekView ) { 268 if ( weekView ) {
284 weekView->setStartViewTime( startTime ); 269 weekView->setStartViewTime( startTime );
285 } 270 }
286 saveSettings(); 271 saveSettings();
287 272
288 // make the change obvious 273 // make the change obvious
289 if ( views->visibleWidget() ) { 274 if ( views->visibleWidget() ) {
290 if ( views->visibleWidget() == dayView ) 275 if ( views->visibleWidget() == dayView )
291 dayView->redraw(); 276 dayView->redraw();
292 else if ( views->visibleWidget() == weekView ) 277 else if ( views->visibleWidget() == weekView )
293 weekView->redraw(); 278 weekView->redraw();
294 else if ( views->visibleWidget() == weekLstView ) 279 else if ( views->visibleWidget() == weekLstView )
295 weekLstView->redraw(); 280 weekLstView->redraw();
296 } 281 }
297 } 282 }
298} 283}
299 284
300void DateBook::fileNew() 285void DateBook::fileNew()
301{ 286{
302 slotNewEventFromKey(""); 287 slotNewEventFromKey("");
303} 288}
304 289
305QString DateBook::checkEvent(const Event &e) 290QString DateBook::checkEvent(const Event &e)
306{ 291{
307 /* check if overlaps with itself */ 292 /* check if overlaps with itself */
308 bool checkFailed = FALSE; 293 bool checkFailed = FALSE;
309 294
310 /* check the next 12 repeats. should catch most problems */ 295 /* check the next 12 repeats. should catch most problems */
311 QDate current_date = e.start().date(); 296 QDate current_date = e.start().date();
312 Event previous = e; 297 Event previous = e;
313 for(int i = 0; i < 12; i++) 298 for(int i = 0; i < 12; i++)
314 { 299 {
315 QDateTime next; 300 QDateTime next;
316 if (!nextOccurance(previous, current_date.addDays(1), next)) { 301 if (!nextOccurance(previous, current_date.addDays(1), next)) {
317 break; // no more repeats 302 break; // no more repeats
318 } 303 }
319 if(next < previous.end()) { 304 if(next < previous.end()) {
320 checkFailed = TRUE; 305 checkFailed = TRUE;
321 break; 306 break;
322 } 307 }
323 current_date = next.date(); 308 current_date = next.date();
324 } 309 }
325 310
326 if(checkFailed) 311 if(checkFailed)
327 return tr("Event duration is potentially longer\n" 312 return tr("Event duration is potentially longer\n"
328 "than interval between repeats."); 313 "than interval between repeats.");
329 314
330 return QString::null; 315 return QString::null;
331} 316}
332 317
333QDate DateBook::currentDate() 318QDate DateBook::currentDate()
334{ 319{
335 QDate d = QDate::currentDate(); 320 QDate d = QDate::currentDate();
336 321
337 if ( dayView && views->visibleWidget() == dayView ) { 322 if ( dayView && views->visibleWidget() == dayView ) {
338 d = dayView->date(); 323 d = dayView->date();
339 } else if ( weekView && views->visibleWidget() == weekView ) { 324 } else if ( weekView && views->visibleWidget() == weekView ) {
340 d = weekView->date(); 325 d = weekView->date();
341 } else if ( weekLstView && views->visibleWidget() == weekLstView ) { 326 } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
342 d = weekLstView->date(); 327 d = weekLstView->date();
343 } else if ( monthView && views->visibleWidget() == monthView ) { 328 } else if ( monthView && views->visibleWidget() == monthView ) {
344 d = monthView->selectedDate(); 329 d = monthView->selectedDate();
345 } 330 }
346 331
347 return d; 332 return d;
348} 333}
349 334
350void DateBook::view(int v, const QDate &d) { 335void DateBook::view(int v, const QDate &d) {
351 if (v==DAY) { 336 if (v==DAY) {
352 initDay(); 337 initDay();
353 dayAction->setOn( TRUE ); 338 dayAction->setOn( TRUE );
354 dayView->setDate( d ); 339 dayView->setDate( d );
355 views->raiseWidget( dayView ); 340 views->raiseWidget( dayView );
356 dayView->redraw(); 341 dayView->redraw();
357 } else if (v==WEEK) { 342 } else if (v==WEEK) {
358 initWeek(); 343 initWeek();
359 weekAction->setOn( TRUE ); 344 weekAction->setOn( TRUE );
360 weekView->setDate( d ); 345 weekView->setDate( d );
361 views->raiseWidget( weekView ); 346 views->raiseWidget( weekView );
362 weekView->redraw(); 347 weekView->redraw();
363 } else if (v==WEEKLST) { 348 } else if (v==WEEKLST) {
364 initWeekLst(); 349 initWeekLst();
365 weekLstAction->setOn( TRUE ); 350 weekLstAction->setOn( TRUE );
366 weekLstView->setDate(d); 351 weekLstView->setDate(d);
367 views->raiseWidget( weekLstView ); 352 views->raiseWidget( weekLstView );
368 weekLstView->redraw(); 353 weekLstView->redraw();
369 } else if (v==MONTH) { 354 } else if (v==MONTH) {
370 initMonth(); 355 initMonth();
371 monthAction->setOn( TRUE ); 356 monthAction->setOn( TRUE );
372 monthView->setDate( d.year(), d.month(), d.day() ); 357 monthView->setDate( d.year(), d.month(), d.day() );
373 views->raiseWidget( monthView ); 358 views->raiseWidget( monthView );
374 monthView->redraw(); 359 monthView->redraw();
375 } 360 }
376} 361}
377 362
378void DateBook::viewDefault(const QDate &d) { 363void DateBook::viewDefault(const QDate &d) {
379 view(defaultView,d); 364 view(defaultView,d);
380} 365}
381 366
382void DateBook::viewDay() { 367void DateBook::viewDay() {
383 view(DAY,currentDate()); 368 view(DAY,currentDate());
384} 369}
385 370
386void DateBook::viewWeek() { 371void DateBook::viewWeek() {
387 view(WEEK,currentDate()); 372 view(WEEK,currentDate());
388} 373}
389 374
390void DateBook::viewWeekLst() { 375void DateBook::viewWeekLst() {
391 view(WEEKLST,currentDate()); 376 view(WEEKLST,currentDate());
392} 377}
393 378
394void DateBook::viewMonth() { 379void DateBook::viewMonth() {
395 view(MONTH,currentDate()); 380 view(MONTH,currentDate());
396} 381}
397 382
398void DateBook::insertEvent( const Event &e ) 383void DateBook::insertEvent( const Event &e )
399{ 384{
400 Event dupEvent=e; 385 Event dupEvent=e;
401 if(!dupEvent.isValidUid() ) // tkcRom seems to be different 386 if(!dupEvent.isValidUid() ) // tkcRom seems to be different
402 dupEvent.assignUid(); 387 dupEvent.assignUid();
403 dupEvent.setLocation(defaultLocation); 388 dupEvent.setLocation(defaultLocation);
404 dupEvent.setCategories(defaultCategories); 389 dupEvent.setCategories(defaultCategories);
405 db->addEvent(dupEvent); 390 db->addEvent(dupEvent);
406 emit newEvent(); 391 emit newEvent();
407} 392}
408 393
409void DateBook::duplicateEvent( const Event &e ) 394void DateBook::duplicateEvent( const Event &e )
410{ 395{
411 // Alot of code duplication, as this is almost like editEvent(); 396 // Alot of code duplication, as this is almost like editEvent();
412 if (syncing) { 397 if (syncing) {
413 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); 398 QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
414 return; 399 return;
415 } 400 }
416 401
417 Event dupevent(e);// Make a duplicate. 402 Event dupevent(e);// Make a duplicate.
418 403
419 // workaround added for text input. 404 // workaround added for text input.
420 QDialog editDlg( this, 0, TRUE ); 405 QDialog editDlg( this, 0, TRUE );
421 DateEntry *entry; 406 DateEntry *entry;
422 editDlg.setCaption( tr("Duplicate Event") ); 407 editDlg.setCaption( tr("Duplicate Event") );
423 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 408 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
424 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 409 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
425 sv->setResizePolicy( QScrollView::AutoOneFit ); 410 sv->setResizePolicy( QScrollView::AutoOneFit );
426 // KLUDGE!!! 411 // KLUDGE!!!
427 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 412 sv->setHScrollBarMode( QScrollView::AlwaysOff );
428 vb->addWidget( sv ); 413 vb->addWidget( sv );
429 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); 414 entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
430 entry->timezone->setEnabled( FALSE ); 415 entry->timezone->setEnabled( FALSE );
431 sv->addChild( entry ); 416 sv->addChild( entry );
432 417
433 while ( QPEApplication::execDialog( &editDlg ) ) { 418 while ( QPEApplication::execDialog( &editDlg ) ) {
434 Event newEv = entry->event(); 419 Event newEv = entry->event();
435 QString error = checkEvent(newEv); 420 QString error = checkEvent(newEv);
436 if (!error.isNull()) { 421 if (!error.isNull()) {
437 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) 422 if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
438 continue; 423 continue;
439 } 424 }
440 /* 425 /*
441 * The problem: 426 * The problem:
442 * 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
443 * the recurrence was created 428 * the recurrence was created
444 * so we need to update that time as well 429 * so we need to update that time as well
445 */ 430 */
446 Event::RepeatPattern rp = newEv.repeatPattern(); 431 Event::RepeatPattern rp = newEv.repeatPattern();
447 rp.createTime = ::time( NULL ); 432 rp.createTime = ::time( NULL );
448 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern... 433 newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
449 if( newEv.uid() == e.uid() || !newEv.isValidUid() ) 434 if( newEv.uid() == e.uid() || !newEv.isValidUid() )
450 newEv.assignUid(); 435 newEv.assignUid();
451 436
452 db->addEvent(newEv); 437 db->addEvent(newEv);
453 emit newEvent(); 438 emit newEvent();
454 break; 439 break;
455 } 440 }
456} 441}
457 442
458void DateBook::editEvent( const Event &e ) 443void DateBook::editEvent( const Event &e )
459{ 444{
460 if (syncing) { 445 if (syncing) {
461 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") );
462 return; 447 return;
463 } 448 }
464 449
465 // workaround added for text input. 450 // workaround added for text input.
466 QDialog editDlg( this, 0, TRUE ); 451 QDialog editDlg( this, 0, TRUE );
467 DateEntry *entry; 452 DateEntry *entry;
468 editDlg.setCaption( tr("Edit Event") ); 453 editDlg.setCaption( tr("Edit Event") );
469 QVBoxLayout *vb = new QVBoxLayout( &editDlg ); 454 QVBoxLayout *vb = new QVBoxLayout( &editDlg );
470 QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); 455 QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
471 sv->setResizePolicy( QScrollView::AutoOneFit ); 456 sv->setResizePolicy( QScrollView::AutoOneFit );
472 // KLUDGE!!! 457 // KLUDGE!!!
473 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 458 sv->setHScrollBarMode( QScrollView::AlwaysOff );
474 vb->addWidget( sv ); 459 vb->addWidget( sv );
475 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); 460 entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
476 entry->timezone->setEnabled( FALSE ); 461 entry->timezone->setEnabled( FALSE );
477 sv->addChild( entry ); 462 sv->addChild( entry );
478 463
479 while ( QPEApplication::execDialog( &editDlg ) ) { 464 while ( QPEApplication::execDialog( &editDlg ) ) {
480 Event newEv = entry->event(); 465 Event newEv = entry->event();
481 if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) 466 if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
482 break; 467 break;
483 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid 468 newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
484 QString error = checkEvent(newEv); 469 QString error = checkEvent(newEv);
485 if (!error.isNull()) { 470 if (!error.isNull()) {
486 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;
487 } 472 }
488 db->editEvent(e, newEv); 473 db->editEvent(e, newEv);
489 emit newEvent(); 474 emit newEvent();
490 break; 475 break;
491 } 476 }
492} 477}
493 478
494void DateBook::removeEvent( const Event &e ) 479void DateBook::removeEvent( const Event &e )
495{ 480{
496 if (syncing) { 481 if (syncing) {
497 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") );
498 return; 483 return;
499 } 484 }
500 485
501 QString strName = e.description(); 486 QString strName = e.description();
502 487
503 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) 488 if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
504 return; 489 return;
505 490
506 db->removeEvent( e ); 491 db->removeEvent( e );
507 if ( views->visibleWidget() == dayView && dayView ) 492 if ( views->visibleWidget() == dayView && dayView )
508 dayView->redraw(); 493 dayView->redraw();
509 494
510} 495}
511 496
512void DateBook::addEvent( const Event &e ) 497void DateBook::addEvent( const Event &e )
513{ 498{
514 QDate d = e.start().date(); 499 QDate d = e.start().date();
515 initDay(); 500 initDay();
516 dayView->setDate( d ); 501 dayView->setDate( d );
517} 502}
518 503
519void DateBook::showDay( int year, int month, int day ) 504void DateBook::showDay( int year, int month, int day )
520{ 505{
521 QDate d(year, month, day); 506 QDate d(year, month, day);
522 view(DAY,d); 507 view(DAY,d);
523} 508}
524 509
525void DateBook::initDay() 510void DateBook::initDay()
526{ 511{
527 if ( !dayView ) { 512 if ( !dayView ) {
528 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); 513 dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
529 views->addWidget( dayView, DAY ); 514 views->addWidget( dayView, DAY );
530 dayView->setJumpToCurTime( bJumpToCurTime ); 515 dayView->setJumpToCurTime( bJumpToCurTime );
531 dayView->setStartViewTime( startTime ); 516 dayView->setStartViewTime( startTime );
532 dayView->setRowStyle( rowStyle ); 517 dayView->setRowStyle( rowStyle );
533 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); 518 connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
534 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) ); 519 connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
535 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) ); 520 connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
536 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 521 connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
537 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) ); 522 connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
538 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) ); 523 connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) );
539 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) ); 524 connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) );
540 } 525 }
541} 526}
542 527
543void DateBook::initWeek() 528void DateBook::initWeek()
544{ 529{
545 if ( !weekView ) { 530 if ( !weekView ) {
546 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); 531 weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
547 weekView->setStartViewTime( startTime ); 532 weekView->setStartViewTime( startTime );
548 views->addWidget( weekView, WEEK ); 533 views->addWidget( weekView, WEEK );
549 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 ) ) );
550 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) ); 535 connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
551 } 536 }
552 537
553 //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
554 //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
555 //number of the current week. 540 //number of the current week.
556 int yearNumber, totWeeks; 541 int yearNumber, totWeeks;
557 calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); 542 calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
558 543
559 QDate d = QDate( yearNumber, 12, 31 ); 544 QDate d = QDate( yearNumber, 12, 31 );
560 calcWeek( d, totWeeks, yearNumber, onMonday ); 545 calcWeek( d, totWeeks, yearNumber, onMonday );
561 546
562 while ( totWeeks == 1 ) { 547 while ( totWeeks == 1 ) {
563 d = d.addDays( -1 ); 548 d = d.addDays( -1 );
564 calcWeek( d, totWeeks, yearNumber, onMonday ); 549 calcWeek( d, totWeeks, yearNumber, onMonday );
565 } 550 }
566} 551}
567 552
568void DateBook::initWeekLst() { 553void DateBook::initWeekLst() {
569 if ( !weekLstView ) { 554 if ( !weekLstView ) {
570 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" ); 555 weekLstView = new DateBookWeekLst( ampm, onMonday, db, views, "weeklst view" );
571 views->addWidget( weekLstView, WEEKLST ); 556 views->addWidget( weekLstView, WEEKLST );
572 557
573 //weekLstView->setStartViewTime( startTime ); 558 //weekLstView->setStartViewTime( startTime );
574 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 ) ) );
575 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 &) ),
576 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) ); 561 this, SLOT( slotNewEntry( const QDateTime &, const QDateTime &, const QString & , const QString &) ) );
577 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) ); 562 connect( this, SIGNAL( newEvent() ), weekLstView, SLOT( redraw() ) );
578 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) ); 563 connect( weekLstView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
579 } 564 }
580} 565}
581 566
582 567
583void DateBook::initMonth() 568void DateBook::initMonth()
584{ 569{
585 if ( !monthView ) { 570 if ( !monthView ) {
586 monthView = new DateBookMonth( views, "month view", FALSE, db ); 571 monthView = new DateBookMonth( views, "month view", FALSE, db );
587 views->addWidget( monthView, MONTH ); 572 views->addWidget( monthView, MONTH );
588 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 ) ) );
589 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) ); 574 connect( this, SIGNAL( newEvent() ), monthView, SLOT( redraw() ) );
590 qApp->processEvents(); 575 qApp->processEvents();
591 } 576 }
592} 577}
593 578
594void DateBook::loadSettings() 579void DateBook::loadSettings()
595{ 580{
596 Config qpeconfig( "qpe" ); 581 Config qpeconfig( "qpe" );
597 qpeconfig.setGroup("Time"); 582 qpeconfig.setGroup("Time");
598 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE ); 583 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
599 onMonday = qpeconfig.readBoolEntry( "MONDAY" ); 584 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
600 585
601 Config config("DateBook"); 586 Config config("DateBook");
602 config.setGroup("Main"); 587 config.setGroup("Main");
603 startTime = config.readNumEntry("startviewtime", 8); 588 startTime = config.readNumEntry("startviewtime", 8);
604 aPreset = config.readBoolEntry("alarmpreset"); 589 aPreset = config.readBoolEntry("alarmpreset");
605 presetTime = config.readNumEntry("presettime"); 590 presetTime = config.readNumEntry("presettime");
606 bJumpToCurTime = config.readBoolEntry("jumptocurtime"); 591 bJumpToCurTime = config.readBoolEntry("jumptocurtime");
607 rowStyle = config.readNumEntry("rowstyle"); 592 rowStyle = config.readNumEntry("rowstyle");
608 defaultView = config.readNumEntry("defaultview",DAY); 593 defaultView = config.readNumEntry("defaultview",DAY);
609 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL); 594 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
610 595
611 defaultLocation=config.readEntry("defaultLocation"); 596 defaultLocation=config.readEntry("defaultLocation");
612 QString tmpString=config.readEntry("defaultCategories"); 597 QString tmpString=config.readEntry("defaultCategories");
613 QStringList tmpStringList=QStringList::split(",",tmpString); 598 QStringList tmpStringList=QStringList::split(",",tmpString);
614 defaultCategories.truncate(0); 599 defaultCategories.truncate(0);
615 600
616 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) { 601 for( QStringList::Iterator i=tmpStringList.begin(); i!=tmpStringList.end(); i++) {
617 defaultCategories.resize(defaultCategories.count()+1); 602 defaultCategories.resize(defaultCategories.count()+1);
618 defaultCategories[defaultCategories.count()-1]=(*i).toInt(); 603 defaultCategories[defaultCategories.count()-1]=(*i).toInt();
619 } 604 }
620} 605}
621 606
622void DateBook::saveSettings() 607void DateBook::saveSettings()
623{ 608{
624 Config config( "qpe" ); 609 Config config( "qpe" );
625 Config configDB( "DateBook" ); 610 Config configDB( "DateBook" );
626 configDB.setGroup( "Main" ); 611 configDB.setGroup( "Main" );
627 configDB.writeEntry("startviewtime",startTime); 612 configDB.writeEntry("startviewtime",startTime);
628 configDB.writeEntry("alarmpreset",aPreset); 613 configDB.writeEntry("alarmpreset",aPreset);
629 configDB.writeEntry("presettime",presetTime); 614 configDB.writeEntry("presettime",presetTime);
630 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 615 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
631 configDB.writeEntry("rowstyle", rowStyle); 616 configDB.writeEntry("rowstyle", rowStyle);
632 configDB.writeEntry("defaultview",defaultView); 617 configDB.writeEntry("defaultview",defaultView);
633 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig); 618 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
634 619
635 configDB.writeEntry("defaultLocation",defaultLocation); 620 configDB.writeEntry("defaultLocation",defaultLocation);
636 QStringList tmpStringList; 621 QStringList tmpStringList;
637 for( uint i=0; i<defaultCategories.count(); i++) { 622 for( uint i=0; i<defaultCategories.count(); i++) {
638 tmpStringList << QString::number(defaultCategories[i]); 623 tmpStringList << QString::number(defaultCategories[i]);
639 } 624 }
640 configDB.writeEntry("defaultCategories",tmpStringList.join(",")); 625 configDB.writeEntry("defaultCategories",tmpStringList.join(","));
641} 626}
642 627
643void DateBook::appMessage(const QCString& msg, const QByteArray& data) 628void DateBook::appMessage(const QCString& msg, const QByteArray& data)
644{ 629{
645 bool needShow = FALSE; 630 bool needShow = FALSE;
646 if ( msg == "alarm(QDateTime,int)" ) { 631 if ( msg == "alarm(QDateTime,int)" ) {
647 QDataStream ds(data,IO_ReadOnly); 632 QDataStream ds(data,IO_ReadOnly);
648 QDateTime when; int warn; 633 QDateTime when; int warn;
649 ds >> when >> warn; 634 ds >> when >> warn;
650 635
651 // check to make it's okay to continue, 636 // check to make it's okay to continue,
652 // this is the case that the time was set ahead, and 637 // this is the case that the time was set ahead, and
653 // we are forced given a stale alarm... 638 // we are forced given a stale alarm...
654 QDateTime current = QDateTime::currentDateTime(); 639 QDateTime current = QDateTime::currentDateTime();
655 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() )
656 return; 641 return;
657 642
658 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 643 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
659 if ( list.count() > 0 ) { 644 if ( list.count() > 0 ) {
660 QString msg; 645 QString msg;
661 bool bSound = FALSE; 646 bool bSound = FALSE;
662 int stopTimer = 0; 647 int stopTimer = 0;
663 bool found = FALSE; 648 bool found = FALSE;
664 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { 649 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
665 if ( (*it).event().hasAlarm() ) { 650 if ( (*it).event().hasAlarm() ) {
666 found = TRUE; 651 found = TRUE;
667 msg += "<CENTER><B>" + (*it).description() + "</B>" 652 msg += "<CENTER><B>" + (*it).description() + "</B>"
668 + "<BR>" + (*it).location() + "<BR>" 653 + "<BR>" + (*it).location() + "<BR>"
669 + TimeString::dateString((*it).event().start(),ampm) 654 + TimeString::dateString((*it).event().start(),ampm)
670 + (warn 655 + (warn
671 ? tr(" (in " + QString::number(warn) 656 ? tr(" (in " + QString::number(warn)
672 + tr(" minutes)")) 657 + tr(" minutes)"))
673 : QString("")) 658 : QString(""))
674 + "<BR>" 659 + "<BR>"
675 + (*it).notes() + "</CENTER>"; 660 + (*it).notes() + "</CENTER>";
676 if ( (*it).event().alarmSound() != Event::Silent ) { 661 if ( (*it).event().alarmSound() != Event::Silent ) {
677 bSound = TRUE; 662 bSound = TRUE;
678 } 663 }
679 } 664 }
680 } 665 }
681 if ( found ) { 666 if ( found ) {
682 if ( bSound ) { 667 if ( bSound ) {
683 Sound::soundAlarm(); 668 Sound::soundAlarm();
684 alarmCounter = 0; 669 alarmCounter = 0;
685 stopTimer = startTimer( 5000 ); 670 stopTimer = startTimer( 5000 );
686 } 671 }
687 QDialog dlg( this, 0, TRUE ); 672 QDialog dlg( this, 0, TRUE );
688 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 673 QVBoxLayout *vb = new QVBoxLayout( &dlg );
689 QScrollView *view = new QScrollView( &dlg, "scrollView"); 674 QScrollView *view = new QScrollView( &dlg, "scrollView");
690 view->setResizePolicy( QScrollView::AutoOneFit ); 675 view->setResizePolicy( QScrollView::AutoOneFit );
691 vb->addWidget( view ); 676 vb->addWidget( view );
692 QLabel *lblMsg = new QLabel( msg, &dlg ); 677 QLabel *lblMsg = new QLabel( msg, &dlg );
693 view->addChild( lblMsg ); 678 view->addChild( lblMsg );
694 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 679 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
695 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 680 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
696 vb->addWidget( cmdOk ); 681 vb->addWidget( cmdOk );
697 682
698 needShow = QPEApplication::execDialog( &dlg ); 683 needShow = QPEApplication::execDialog( &dlg );
699 684
700 if ( bSound ) 685 if ( bSound )
701 killTimer( stopTimer ); 686 killTimer( stopTimer );
702 } 687 }
703 } 688 }
704 } else if ( msg == "nextView()" ) { 689 } else if ( msg == "nextView()" ) {
705 needShow = true; 690 needShow = true;
706 if ( !qApp-> activeWindow ( )) { 691 if ( !qApp-> activeWindow ( )) {
707 needShow = TRUE; 692 needShow = TRUE;
708 } else { 693 } else {
709 QWidget* cur = views->visibleWidget(); 694 QWidget* cur = views->visibleWidget();
710 if ( cur ) { 695 if ( cur ) {
711 if ( cur == dayView ) 696 if ( cur == dayView )
712 viewWeek(); 697 viewWeek();
713 else if ( cur == weekView ) 698 else if ( cur == weekView )
714 viewWeekLst(); 699 viewWeekLst();
715 else if ( cur == weekLstView ) 700 else if ( cur == weekLstView )
716 viewMonth(); 701 viewMonth();
717 else if ( cur == monthView ) 702 else if ( cur == monthView )
718 viewDay(); 703 viewDay();
719 needShow = TRUE; 704 needShow = TRUE;
720 } 705 }
721 } 706 }
722 } else if (msg == "editEvent(int)") { 707 } else if (msg == "editEvent(int)") {
723 /* simple copy from receive */ 708 /* simple copy from receive */
724 QDataStream stream(data,IO_ReadOnly); 709 QDataStream stream(data,IO_ReadOnly);
725 int uid; 710 int uid;
726 stream >> uid; 711 stream >> uid;
727 Event e=db->eventByUID(uid); 712 Event e=db->eventByUID(uid);
728 editEvent(e); 713 editEvent(e);
729 } else if (msg == "viewDefault(QDate)"){ 714 } else if (msg == "viewDefault(QDate)"){
730 /* simple copy from receive */ 715 /* simple copy from receive */
731 QDataStream stream(data,IO_ReadOnly); 716 QDataStream stream(data,IO_ReadOnly);
732 QDate day; 717 QDate day;
733 stream >> day; 718 stream >> day;
734 viewDefault(day); 719 viewDefault(day);
735 needShow = true; 720 needShow = true;
736 } 721 }
737 722
738 if ( needShow ) { 723 if ( needShow ) {
739#if defined(Q_WS_QWS) || defined(_WS_QWS_) 724#if defined(Q_WS_QWS) || defined(_WS_QWS_)
740 // showMaximized(); 725 // showMaximized();
741#else 726#else
742 // show(); 727 // show();
743#endif 728#endif
744 // raise(); 729 // raise();
745 QPEApplication::setKeepRunning(); 730 QPEApplication::setKeepRunning();
746 // setActiveWindow(); 731 // setActiveWindow();
747 } 732 }
748} 733}
749 734
750void DateBook::reload() 735void DateBook::reload()
751{ 736{
752 db->reload(); 737 db->reload();
753 if ( dayAction->isOn() ) viewDay(); 738 if ( dayAction->isOn() ) viewDay();
754 else if ( weekAction->isOn() ) viewWeek(); 739 else if ( weekAction->isOn() ) viewWeek();
755 else if ( monthAction->isOn() ) viewMonth(); 740 else if ( monthAction->isOn() ) viewMonth();
756 syncing = FALSE; 741 syncing = FALSE;
757} 742}
758 743
759void DateBook::flush() 744void DateBook::flush()
760{ 745{
761 syncing = TRUE; 746 syncing = TRUE;
762 db->save(); 747 db->save();
763} 748}
764 749
765void DateBook::timerEvent( QTimerEvent *e ) 750void DateBook::timerEvent( QTimerEvent *e )
766{ 751{
767 if ( alarmCounter < 10 ) { 752 if ( alarmCounter < 10 ) {
768 alarmCounter++; 753 alarmCounter++;
769 Sound::soundAlarm(); 754 Sound::soundAlarm();
770 } else { 755 } else {
771 killTimer( e->timerId() ); 756 killTimer( e->timerId() );
772 } 757 }
773} 758}
774 759
775void DateBook::changeClock( bool newClock ) 760void DateBook::changeClock( bool newClock )
776{ 761{
777 ampm = newClock; 762 ampm = newClock;
778 // repaint the affected objects... 763 // repaint the affected objects...
779 if (dayView) dayView->redraw(); 764 if (dayView) dayView->redraw();
780 if (weekView) weekView->redraw(); 765 if (weekView) weekView->redraw();
781 if (weekLstView) weekLstView->redraw(); 766 if (weekLstView) weekLstView->redraw();
782} 767}
783 768
784void DateBook::changeWeek( bool m ) 769void DateBook::changeWeek( bool m )
785{ 770{
786 /* no need to redraw, each widget catches. Do need to 771 /* no need to redraw, each widget catches. Do need to
787 store though for widgets we haven't made yet */ 772 store though for widgets we haven't made yet */
788 onMonday = m; 773 onMonday = m;
789} 774}
790 775
791void DateBook::slotToday() 776void DateBook::slotToday()
792{ 777{
793 // we need to view today using default view 778 // we need to view today using default view
794 view(defaultView,QDate::currentDate()); 779 view(defaultView,QDate::currentDate());
795} 780}
796 781
797void DateBook::closeEvent( QCloseEvent *e ) 782void DateBook::closeEvent( QCloseEvent *e )
798{ 783{
799 if(syncing) { 784 if(syncing) {
800 /* no need to save, did that at flush */ 785 /* no need to save, did that at flush */
801 e->accept(); 786 e->accept();
802 return; 787 return;
803 } 788 }
804 789
805 // save settings will generate it's own error messages, no 790 // save settings will generate it's own error messages, no
806 // need to do checking ourselves. 791 // need to do checking ourselves.
807 saveSettings(); 792 saveSettings();
808 if ( db->save() ) { 793 if ( db->save() ) {
809 e->accept(); 794 e->accept();
810 } else { 795 } else {
811 if ( QMessageBox::critical( this, tr( "Out of space" ), 796 if ( QMessageBox::critical( this, tr( "Out of space" ),
812 tr("Calendar was unable to save\n" 797 tr("Calendar was unable to save\n"
813 "your changes.\n" 798 "your changes.\n"
814 "Free up some space and try again.\n" 799 "Free up some space and try again.\n"
815 "\nQuit anyway?"), 800 "\nQuit anyway?"),
816 QMessageBox::Yes|QMessageBox::Escape, 801 QMessageBox::Yes|QMessageBox::Escape,
817 QMessageBox::No|QMessageBox::Default ) 802 QMessageBox::No|QMessageBox::Default )
818 != QMessageBox::No ) 803 != QMessageBox::No )
819 e->accept(); 804 e->accept();
820 else 805 else
821 e->ignore(); 806 e->ignore();
822 } 807 }
823} 808}
824 809
825// Entering directly from the "keyboard" 810// Entering directly from the "keyboard"
826void DateBook::slotNewEventFromKey( const QString &str ) 811void DateBook::slotNewEventFromKey( const QString &str )
827{ 812{
828 if (syncing) { 813 if (syncing) {
829 QMessageBox::warning( this, tr("Calendar"), 814 QMessageBox::warning( this, tr("Calendar"),
830 tr( "Can not edit data, currently syncing") ); 815 tr( "Can not edit data, currently syncing") );
831 return; 816 return;
832 } 817 }
833 818
834 // 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
835 // So we can assume some things. We want the string 820 // So we can assume some things. We want the string
836 // passed in to be part of the description. 821 // passed in to be part of the description.
837 QDateTime start, end; 822 QDateTime start, end;
838 if ( views->visibleWidget() == dayView ) { 823 if ( views->visibleWidget() == dayView ) {
839 dayView->selectedDates( start, end ); 824 dayView->selectedDates( start, end );
840 } else if ( views->visibleWidget() == monthView ) { 825 } else if ( views->visibleWidget() == monthView ) {
841 QDate d = monthView->selectedDate(); 826 QDate d = monthView->selectedDate();
842 start = end = d; 827 start = end = d;
843 start.setTime( QTime( 10, 0 ) ); 828 start.setTime( QTime( 10, 0 ) );
844 end.setTime( QTime( 12, 0 ) ); 829 end.setTime( QTime( 12, 0 ) );
845 } else if ( views->visibleWidget() == weekView ) { 830 } else if ( views->visibleWidget() == weekView ) {
846 QDate d = weekView->date(); 831 QDate d = weekView->date();
847 start = end = d; 832 start = end = d;
848 start.setTime( QTime( 10, 0 ) ); 833 start.setTime( QTime( 10, 0 ) );
849 end.setTime( QTime( 12, 0 ) ); 834 end.setTime( QTime( 12, 0 ) );
850 } else if ( views->visibleWidget() == weekLstView ) { 835 } else if ( views->visibleWidget() == weekLstView ) {
851 QDate d = weekLstView->date(); 836 QDate d = weekLstView->date();
852 start = end = d; 837 start = end = d;
853 start.setTime( QTime( 10, 0 ) ); 838 start.setTime( QTime( 10, 0 ) );
854 end.setTime( QTime( 12, 0 ) ); 839 end.setTime( QTime( 12, 0 ) );
855 } 840 }
856 slotNewEntry(start, end, str); 841 slotNewEntry(start, end, str);
857} 842}
858void 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) {
859 // argh! This really needs to be encapsulated in a class 844 // argh! This really needs to be encapsulated in a class
860 // or function. 845 // or function.
861 QDialog newDlg( this, 0, TRUE ); 846 QDialog newDlg( this, 0, TRUE );
862 newDlg.setCaption( DateEntryBase::tr("New Event") ); 847 newDlg.setCaption( DateEntryBase::tr("New Event") );
863 DateEntry *e; 848 DateEntry *e;
864 QVBoxLayout *vb = new QVBoxLayout( &newDlg ); 849 QVBoxLayout *vb = new QVBoxLayout( &newDlg );
865 QScrollView *sv = new QScrollView( &newDlg ); 850 QScrollView *sv = new QScrollView( &newDlg );
866 sv->setResizePolicy( QScrollView::AutoOneFit ); 851 sv->setResizePolicy( QScrollView::AutoOneFit );
867 sv->setFrameStyle( QFrame::NoFrame ); 852 sv->setFrameStyle( QFrame::NoFrame );
868 sv->setHScrollBarMode( QScrollView::AlwaysOff ); 853 sv->setHScrollBarMode( QScrollView::AlwaysOff );
869 vb->addWidget( sv ); 854 vb->addWidget( sv );
870 855
871 Event ev; 856 Event ev;
872 ev.setDescription( str ); 857 ev.setDescription( str );
873 // When the new gui comes in, change this... 858 // When the new gui comes in, change this...
874 if(location==0) { 859 if(location==0) {
875 if(defaultLocation.isEmpty()) { 860 if(defaultLocation.isEmpty()) {
876 ev.setLocation(tr("(Unknown)")); 861 ev.setLocation(tr("(Unknown)"));
877 } else { 862 } else {
878 ev.setLocation( defaultLocation ); 863 ev.setLocation( defaultLocation );
879 } 864 }
880 } else { 865 } else {
881 ev.setLocation(location); 866 ev.setLocation(location);
882 } 867 }
883 ev.setCategories(defaultCategories); 868 ev.setCategories(defaultCategories);
884 ev.setStart( start ); 869 ev.setStart( start );
885 ev.setEnd( end ); 870 ev.setEnd( end );
886 871
887 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 872 e = new DateEntry( onMonday, ev, ampm, &newDlg );
888 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 873 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
889 sv->addChild( e ); 874 sv->addChild( e );
890 while ( QPEApplication::execDialog( &newDlg ) ) { 875 while ( QPEApplication::execDialog( &newDlg ) ) {
891 ev = e->event(); 876 ev = e->event();
892 ev.assignUid(); 877 ev.assignUid();
893 QString error = checkEvent( ev ); 878 QString error = checkEvent( ev );
894 if ( !error.isNull() ) { 879 if ( !error.isNull() ) {
895 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 )
896 continue; 881 continue;
897 } 882 }
898 db->addEvent( ev ); 883 db->addEvent( ev );
899 emit newEvent(); 884 emit newEvent();
900 break; 885 break;
901 } 886 }
902} 887}
903 888
904void DateBook::setDocument( const QString &filename ) 889void DateBook::setDocument( const QString &filename )
905{ 890{
906 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 891 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
907 892
908 QValueList<Event> tl = Event::readVCalendar( filename ); 893 QValueList<Event> tl = Event::readVCalendar( filename );
909 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 894 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
910 db->addEvent( *it ); 895 db->addEvent( *it );
911 } 896 }
912} 897}
913 898
914static const char * beamfile = "/tmp/obex/event.vcs"; 899static const char * beamfile = "/tmp/obex/event.vcs";
915 900
916void DateBook::beamEvent( const Event &e ) 901void DateBook::beamEvent( const Event &e )
917{ 902{
918 qDebug("trying to beamn"); 903 qDebug("trying to beamn");
919 unlink( beamfile ); // delete if exists 904 unlink( beamfile ); // delete if exists
920 mkdir("/tmp/obex/", 0755); 905 mkdir("/tmp/obex/", 0755);
921 Event::writeVCalendar( beamfile, e ); 906 Event::writeVCalendar( beamfile, e );
922 Ir *ir = new Ir( this ); 907 Ir *ir = new Ir( this );
923 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 908 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
924 QString description = e.description(); 909 QString description = e.description();
925 ir->send( beamfile, description, "text/x-vCalendar" ); 910 ir->send( beamfile, description, "text/x-vCalendar" );
926} 911}
927 912
928void DateBook::beamDone( Ir *ir ) 913void DateBook::beamDone( Ir *ir )
929{ 914{
930 delete ir; 915 delete ir;
931 unlink( beamfile ); 916 unlink( beamfile );
932} 917}
933 918
934void DateBook::slotFind() 919void DateBook::slotFind()
935{ 920{
936 // move it to the day view... 921 // move it to the day view...
937 viewDay(); 922 viewDay();
938 FindDialog frmFind( "Calendar", this ); // no tr needed 923 FindDialog frmFind( "Calendar", this ); // no tr needed
939 frmFind.setUseDate( true ); 924 frmFind.setUseDate( true );
940 frmFind.setDate( currentDate() ); 925 frmFind.setDate( currentDate() );
941 QObject::connect( &frmFind, 926 QObject::connect( &frmFind,
942 SIGNAL(signalFindClicked(const QString&, const QDate&, 927 SIGNAL(signalFindClicked(const QString&, const QDate&,
943 bool, bool, int)), 928 bool, bool, int)),
944 this, 929 this,
945 SLOT(slotDoFind(const QString&, const QDate&, 930 SLOT(slotDoFind(const QString&, const QDate&,
946 bool, bool, int)) ); 931 bool, bool, int)) );
947 QObject::connect( this, 932 QObject::connect( this,
948 SIGNAL(signalNotFound()), 933 SIGNAL(signalNotFound()),
949 &frmFind, 934 &frmFind,
950 SLOT(slotNotFound()) ); 935 SLOT(slotNotFound()) );
951 QObject::connect( this, 936 QObject::connect( this,
952 SIGNAL(signalWrapAround()), 937 SIGNAL(signalWrapAround()),
953 &frmFind, 938 &frmFind,
954 SLOT(slotWrapAround()) ); 939 SLOT(slotWrapAround()) );
955 frmFind.move(0,0); 940 frmFind.move(0,0);
956 frmFind.exec(); 941 frmFind.exec();
957 inSearch = false; 942 inSearch = false;
958} 943}
959 944
960bool catComp( QArray<int> cats, int category ) 945bool catComp( QArray<int> cats, int category )
961{ 946{
962 bool returnMe; 947 bool returnMe;
963 int i, 948 int i,
964 count; 949 count;
965 950
966 count = int(cats.count()); 951 count = int(cats.count());
967 returnMe = false; 952 returnMe = false;
968 if ( (category == -1 && count == 0) || category == -2 ) 953 if ( (category == -1 && count == 0) || category == -2 )
969 returnMe = true; 954 returnMe = true;
970 else { 955 else {
971 for ( i = 0; i < count; i++ ) { 956 for ( i = 0; i < count; i++ ) {
972 if ( category == cats[i] ) { 957 if ( category == cats[i] ) {
973 returnMe = true; 958 returnMe = true;
974 break; 959 break;
975 } 960 }
976 } 961 }
977 } 962 }
978 return returnMe; 963 return returnMe;
979} 964}
980 965
981 966
982void DateBook::slotDoFind( const QString& txt, const QDate &dt, 967void DateBook::slotDoFind( const QString& txt, const QDate &dt,
983 bool caseSensitive, bool /*backwards*/, 968 bool caseSensitive, bool /*backwards*/,
984 int category ) 969 int category )
985{ 970{
986 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), 971 QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ),
987 next; 972 next;
988 973
989 QRegExp r( txt ); 974 QRegExp r( txt );
990 r.setCaseSensitive( caseSensitive ); 975 r.setCaseSensitive( caseSensitive );
991 976
992 977
993 static Event rev, nonrev; 978 static Event rev, nonrev;
994 if ( !inSearch ) { 979 if ( !inSearch ) {
995 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 980 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
996 nonrev.setStart( rev.start() ); 981 nonrev.setStart( rev.start() );
997 inSearch = true; 982 inSearch = true;
998 } 983 }
999 static QDate searchDate = dt; 984 static QDate searchDate = dt;
1000 // if true at the end we will start at the begin again and afterwards 985 // if true at the end we will start at the begin again and afterwards
1001 // we will emit string not found 986 // we will emit string not found
1002 static bool wrapAround = true; 987 static bool wrapAround = true;
1003 bool candidtate; 988 bool candidtate;
1004 candidtate = false; 989 candidtate = false;
1005 990
1006 QValueList<Event> repeats = db->getRawRepeats(); 991 QValueList<Event> repeats = db->getRawRepeats();
1007 992
1008 // find the candidate for the first repeat that matches... 993 // find the candidate for the first repeat that matches...
1009 // first check if there can ever be a match and then compute 994 // first check if there can ever be a match and then compute
1010 // the next occurence from start. See if this event is closer 995 // the next occurence from start. See if this event is closer
1011 // to the beginning (start. next < dtEnd) and not smaller then the last 996 // to the beginning (start. next < dtEnd) and not smaller then the last
1012 // result. If we find a canditate we set the dtEnd to the time 997 // result. If we find a canditate we set the dtEnd to the time
1013 // of the ocurrence and rev to this occurence. 998 // of the ocurrence and rev to this occurence.
1014 // set wrap around to true because there might be more events coming 999 // set wrap around to true because there might be more events coming
1015 // and we're not at the end. 1000 // and we're not at the end.
1016 QValueListConstIterator<Event> it; 1001 QValueListConstIterator<Event> it;
1017 QDate start = dt; 1002 QDate start = dt;
1018 for ( it = repeats.begin(); it != repeats.end(); ++it ) { 1003 for ( it = repeats.begin(); it != repeats.end(); ++it ) {
1019 if ( catComp( (*it).categories(), category ) ) { 1004 if ( catComp( (*it).categories(), category ) ) {
1020 if ( (*it).match( r ) ) { 1005 if ( (*it).match( r ) ) {
1021 if ( nextOccurance( *it, start, next ) ) { 1006 if ( nextOccurance( *it, start, next ) ) {
1022 if ( next < dtEnd && !(next <= rev.start() ) ) { 1007 if ( next < dtEnd && !(next <= rev.start() ) ) {
1023 rev = *it; 1008 rev = *it;
1024 dtEnd = next; 1009 dtEnd = next;
1025 rev.setStart( next ); 1010 rev.setStart( next );
1026 candidtate = true; 1011 candidtate = true;
1027 wrapAround = true; 1012 wrapAround = true;
1028 } 1013 }
1029 } 1014 }
1030 } 1015 }
1031 } 1016 }
1032 } 1017 }
1033 1018
1034 // now the for first non repeat... 1019 // now the for first non repeat...
1035 // dtEnd is set by the previous iteration of repeatingEvents 1020 // dtEnd is set by the previous iteration of repeatingEvents
1036 // check if we find a closer item. Also set dtEnd to find even 1021 // check if we find a closer item. Also set dtEnd to find even
1037 // more close occurrence 1022 // more close occurrence
1038 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); 1023 QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() );
1039 qHeapSort( nonRepeats.begin(), nonRepeats.end() ); 1024 qHeapSort( nonRepeats.begin(), nonRepeats.end() );
1040 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { 1025 for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) {
1041 if ( catComp( (*it).categories(), category ) ) { 1026 if ( catComp( (*it).categories(), category ) ) {
1042 if ( (*it).start() < dtEnd ) { 1027 if ( (*it).start() < dtEnd ) {
1043 if ( (*it).match( r ) && !(*it <= nonrev) ) { 1028 if ( (*it).match( r ) && !(*it <= nonrev) ) {
1044 nonrev = *it; 1029 nonrev = *it;
1045 dtEnd = nonrev.start(); 1030 dtEnd = nonrev.start();
1046 candidtate = true; 1031 candidtate = true;
1047 wrapAround = true; 1032 wrapAround = true;
1048 break; 1033 break;
1049 } 1034 }
1050 } 1035 }
1051 } 1036 }
1052 } 1037 }
1053 if ( candidtate ) { 1038 if ( candidtate ) {
1054 dayView->setStartViewTime( dtEnd.time().hour() ); 1039 dayView->setStartViewTime( dtEnd.time().hour() );
1055 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 1040 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
1056 dtEnd.date().day() ); 1041 dtEnd.date().day() );
1057 } else { 1042 } else {
1058 if ( wrapAround ) { 1043 if ( wrapAround ) {
1059 emit signalWrapAround(); 1044 emit signalWrapAround();
1060 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 1045 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
1061 nonrev.setStart( rev.start() ); 1046 nonrev.setStart( rev.start() );
1062 } else 1047 } else
1063 emit signalNotFound(); 1048 emit signalNotFound();
1064 wrapAround = !wrapAround; 1049 wrapAround = !wrapAround;
1065 } 1050 }
1066} 1051}
1067 1052
1068Event DateBookDBHack::eventByUID(int uid) { 1053Event DateBookDBHack::eventByUID(int uid) {
1069 1054
1070 // FIXME: Dirty Hacks to get hold of the private event lists 1055 // FIXME: Dirty Hacks to get hold of the private event lists
1071 QDate start; 1056 QDate start;
1072 QDate end=start.addDays(-1); 1057 QDate end=start.addDays(-1);
1073 QValueList<Event> myEventList=getNonRepeatingEvents(start,end); 1058 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
1074 QValueList<Event> myRepeatEvents=getRawRepeats(); 1059 QValueList<Event> myRepeatEvents=getRawRepeats();
1075 1060
1076 QValueList<Event>::ConstIterator it; 1061 QValueList<Event>::ConstIterator it;
1077 1062
1078 for (it = myEventList.begin(); it != myEventList.end(); it++) { 1063 for (it = myEventList.begin(); it != myEventList.end(); it++) {
1079 if ((*it).uid() == uid) return *it; 1064 if ((*it).uid() == uid) return *it;
1080 } 1065 }
1081 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { 1066 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
1082 if ((*it).uid() == uid) return *it; 1067 if ((*it).uid() == uid) return *it;
1083 } 1068 }
1084 1069
1085 Event ev; 1070 Event ev;
1086 return ev; // return at least 1071 return ev; // return at least
1087} 1072}
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 1244fd3..d43d31a 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -1,236 +1,226 @@
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 <qpushbutton.h>
12#include <qlayout.h> 11#include <qlayout.h>
13#include <qvariant.h>
14#include <qtooltip.h>
15#include <qwhatsthis.h>
16#include <qobjectlist.h>
17#include <qpe/event.h>
18#include <qpe/ir.h> 12#include <qpe/ir.h>
19#include <qpe/datebookdb.h>
20#include <qpe/resource.h>
21#include <qpopupmenu.h> 13#include <qpopupmenu.h>
22#include <qtimer.h> 14#include <qtimer.h>
23#include <qregexp.h>
24#include <qdatetime.h>
25 15
26#include "datebookday.h" 16#include "datebookday.h"
27 17
28/* 18/*
29 * Constructs a DatebookdayAllday which is a child of 'parent', with the 19 * Constructs a DatebookdayAllday which is a child of 'parent', with the
30 * name 'name' and widget flags set to 'f' 20 * name 'name' and widget flags set to 'f'
31 */ 21 */
32DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) 22DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags )
33 : QScrollView( parent, name ),item_count(0),dateBook(db) 23 : QScrollView( parent, name ),item_count(0),dateBook(db)
34{ 24{
35 if ( !name ) 25 if ( !name )
36 setName( "DatebookdayAllday" ); 26 setName( "DatebookdayAllday" );
37 setMinimumSize( QSize( 0, 0 ) ); 27 setMinimumSize( QSize( 0, 0 ) );
38 setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); 28 setMaximumHeight(3* (QFontMetrics(font()).height()+4) );
39 29
40 m_MainFrame = new QFrame(viewport()); 30 m_MainFrame = new QFrame(viewport());
41 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); 31 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
42 setFrameStyle(QFrame::NoFrame|QFrame::Plain); 32 setFrameStyle(QFrame::NoFrame|QFrame::Plain);
43 setResizePolicy( QScrollView::Default ); 33 setResizePolicy( QScrollView::Default );
44 setHScrollBarMode( AlwaysOff ); 34 setHScrollBarMode( AlwaysOff );
45 addChild(m_MainFrame); 35 addChild(m_MainFrame);
46 36
47 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); 37 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame );
48 datebookdayalldayLayout->setSpacing( 0 ); 38 datebookdayalldayLayout->setSpacing( 0 );
49 datebookdayalldayLayout->setMargin( 0 ); 39 datebookdayalldayLayout->setMargin( 0 );
50 40
51 lblDesc = new DatebookEventDesc(parent->parentWidget(),""); 41 lblDesc = new DatebookEventDesc(parent->parentWidget(),"");
52 lblDesc->setBackgroundColor(Qt::yellow); 42 lblDesc->setBackgroundColor(Qt::yellow);
53 lblDesc->hide(); 43 lblDesc->hide();
54 subWidgets.setAutoDelete(true); 44 subWidgets.setAutoDelete(true);
55} 45}
56 46
57/* 47/*
58 * Destroys the object and frees any allocated resources 48 * Destroys the object and frees any allocated resources
59 */ 49 */
60DatebookdayAllday::~DatebookdayAllday() 50DatebookdayAllday::~DatebookdayAllday()
61{ 51{
62 // 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
63} 53}
64 54
65DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) 55DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
66{ 56{
67 DatebookAlldayDisp * lb; 57 DatebookAlldayDisp * lb;
68 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); 58 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL);
69 lb->show(); 59 lb->show();
70 datebookdayalldayLayout->addWidget(lb); 60 datebookdayalldayLayout->addWidget(lb);
71 subWidgets.append(lb); 61 subWidgets.append(lb);
72 62
73 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&)));
74 ++item_count; 64 ++item_count;
75 65
76 return lb; 66 return lb;
77} 67}
78 68
79void DatebookdayAllday::removeAllEvents() 69void DatebookdayAllday::removeAllEvents()
80{ 70{
81 subWidgets.clear(); 71 subWidgets.clear();
82 item_count = 0; 72 item_count = 0;
83} 73}
84 74
85DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, 75DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
86 QWidget* parent,const char* name,WFlags f) 76 QWidget* parent,const char* name,WFlags f)
87 : QLabel(parent,name,f),m_Ev(ev),dateBook(db) 77 : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
88{ 78{
89 QString strDesc = m_Ev.description(); 79 QString strDesc = m_Ev.description();
90 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 80 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
91 setBackgroundColor(yellow); 81 setBackgroundColor(yellow);
92 setText(strDesc); 82 setText(strDesc);
93 setFrameStyle(QFrame::Raised|QFrame::Panel); 83 setFrameStyle(QFrame::Raised|QFrame::Panel);
94 84
95 int s = QFontMetrics(font()).height()+4; 85 int s = QFontMetrics(font()).height()+4;
96 setMaximumHeight( s ); 86 setMaximumHeight( s );
97 setMinimumSize( QSize( 0, s ) ); 87 setMinimumSize( QSize( 0, s ) );
98} 88}
99 89
100DatebookAlldayDisp::~DatebookAlldayDisp() 90DatebookAlldayDisp::~DatebookAlldayDisp()
101{ 91{
102} 92}
103 93
104void DatebookAlldayDisp::beam_single_event() 94void DatebookAlldayDisp::beam_single_event()
105{ 95{
106 // create an Event and beam it... 96 // create an Event and beam it...
107 /* 97 /*
108 * 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
109 * the values of effective m_Events 99 * the values of effective m_Events
110 * 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...
111 */ 101 */
112 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 102 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
113 Event m_Event( m_Ev.event() ); 103 Event m_Event( m_Ev.event() );
114 104
115 QDateTime dt( m_Ev.date(), m_Ev.start() ); 105 QDateTime dt( m_Ev.date(), m_Ev.start() );
116 m_Event.setStart( dt ); 106 m_Event.setStart( dt );
117 107
118 dt.setTime( m_Ev.end() ); 108 dt.setTime( m_Ev.end() );
119 m_Event.setEnd( dt ); 109 m_Event.setEnd( dt );
120 emit beamMe( m_Event ); 110 emit beamMe( m_Event );
121 }else { 111 }else {
122 /* 112 /*
123 * at least the the Times are right now 113 * at least the the Times are right now
124 */ 114 */
125 QDateTime start( m_Ev.event().start() ); 115 QDateTime start( m_Ev.event().start() );
126 QDateTime end ( m_Ev.event().end () ); 116 QDateTime end ( m_Ev.event().end () );
127 117
128 /* 118 /*
129 * 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
130 */ 120 */
131 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { 121 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
132 start.setDate( m_Ev.date() ); 122 start.setDate( m_Ev.date() );
133 }else { 123 }else {
134 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 );
135 start.setDate( dt ); 125 start.setDate( dt );
136 } 126 }
137 127
138 /* 128 /*
139 * ok we know now the end date... 129 * ok we know now the end date...
140 * else 130 * else
141 * 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
142 * and then add it to the new start date... 132 * and then add it to the new start date...
143 */ 133 */
144 if ( m_Ev.end() != QTime(23, 59, 59 ) ) { 134 if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
145 end.setDate( m_Ev.date() ); 135 end.setDate( m_Ev.date() );
146 }else{ 136 }else{
147 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() );
148 end.setDate( start.date().addDays( days ) ); 138 end.setDate( start.date().addDays( days ) );
149 } 139 }
150 Event m_Event( m_Ev.event() ); 140 Event m_Event( m_Ev.event() );
151 m_Event.setStart( start ); 141 m_Event.setStart( start );
152 m_Event.setEnd ( end ); 142 m_Event.setEnd ( end );
153 emit beamMe( m_Event ); 143 emit beamMe( m_Event );
154 } 144 }
155} 145}
156 146
157void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 147void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
158{ 148{
159 Event ev = m_Ev.event(); 149 Event ev = m_Ev.event();
160 QColor b = backgroundColor(); 150 QColor b = backgroundColor();
161 setBackgroundColor(green); 151 setBackgroundColor(green);
162 update(); 152 update();
163 QPopupMenu m; 153 QPopupMenu m;
164 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 154 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
165 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 155 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
166 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 156 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
167 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 157 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
168 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 );
169 m.insertItem( tr( "Info"),6); 159 m.insertItem( tr( "Info"),6);
170 int r = m.exec( e->globalPos() ); 160 int r = m.exec( e->globalPos() );
171 setBackgroundColor(b); 161 setBackgroundColor(b);
172 update(); 162 update();
173 switch (r) { 163 switch (r) {
174 case 1: 164 case 1:
175 emit editMe( ev ); 165 emit editMe( ev );
176 break; 166 break;
177 case 2: 167 case 2:
178 emit deleteMe( ev ); 168 emit deleteMe( ev );
179 break; 169 break;
180 case 3: 170 case 3:
181 emit beamMe( ev ); 171 emit beamMe( ev );
182 break; 172 break;
183 case 4: 173 case 4:
184 emit duplicateMe( ev ); 174 emit duplicateMe( ev );
185 break; 175 break;
186 case 5: 176 case 5:
187 beam_single_event(); 177 beam_single_event();
188 break; 178 break;
189 case 6: 179 case 6:
190 emit displayMe( ev ); 180 emit displayMe( ev );
191 break; 181 break;
192 default: 182 default:
193 break; 183 break;
194 } 184 }
195} 185}
196 186
197DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) 187DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name)
198 :QLabel(parent,name) 188 :QLabel(parent,name)
199{ 189{
200 m_Timer=new QTimer(this); 190 m_Timer=new QTimer(this);
201 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); 191 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide()));
202 setFrameStyle(QFrame::Sunken|QFrame::Panel); 192 setFrameStyle(QFrame::Sunken|QFrame::Panel);
203 setTextFormat(RichText); 193 setTextFormat(RichText);
204} 194}
205 195
206DatebookEventDesc::~DatebookEventDesc() 196DatebookEventDesc::~DatebookEventDesc()
207{ 197{
208} 198}
209 199
210void DatebookEventDesc::mousePressEvent(QMouseEvent*) 200void DatebookEventDesc::mousePressEvent(QMouseEvent*)
211{ 201{
212 hide(); 202 hide();
213 if (m_Timer->isActive()) m_Timer->stop(); 203 if (m_Timer->isActive()) m_Timer->stop();
214} 204}
215 205
216void DatebookEventDesc::disp_event(const Event&e) 206void DatebookEventDesc::disp_event(const Event&e)
217{ 207{
218 if (m_Timer->isActive()) m_Timer->stop(); 208 if (m_Timer->isActive()) m_Timer->stop();
219 QString text; 209 QString text;
220 text = "<b><i>"+e.description()+"</i></b><br>"; 210 text = "<b><i>"+e.description()+"</i></b><br>";
221 if (e.notes().length()>0) { 211 if (e.notes().length()>0) {
222 text+="<b>"+e.notes()+"</b><br>"; 212 text+="<b>"+e.notes()+"</b><br>";
223 } 213 }
224 if (e.location().length()>0) { 214 if (e.location().length()>0) {
225 text+="<i>"+e.location()+"</i><br>"; 215 text+="<i>"+e.location()+"</i><br>";
226 } 216 }
227 text = text.replace(QRegExp("\n"),"<br>"); 217 text = text.replace(QRegExp("\n"),"<br>");
228 setText(text); 218 setText(text);
229 QSize s = sizeHint(); 219 QSize s = sizeHint();
230 s+=QSize(10,10); 220 s+=QSize(10,10);
231 resize(s); 221 resize(s);
232 move( QMAX(0,(parentWidget()->width()-width()) / 2), 222 move( QMAX(0,(parentWidget()->width()-width()) / 2),
233 (parentWidget()->height()-height())/2 ); 223 (parentWidget()->height()-height())/2 );
234 show(); 224 show();
235 m_Timer->start(2000,true); 225 m_Timer->start(2000,true);
236} 226}
diff --git a/core/pim/datebook/datebookdayheaderimpl.cpp b/core/pim/datebook/datebookdayheaderimpl.cpp
index 3e965f5..213c843 100644
--- a/core/pim/datebook/datebookdayheaderimpl.cpp
+++ b/core/pim/datebook/datebookdayheaderimpl.cpp
@@ -1,204 +1,200 @@
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 "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#include <qpe/timestring.h>
25 24
26#include <qbuttongroup.h> 25#include <qbuttongroup.h>
27#include <qpopupmenu.h>
28#include <qstringlist.h>
29#include <qtimer.h>
30#include <qtoolbutton.h> 26#include <qtoolbutton.h>
31 27
32 28
33/* 29/*
34 * Constructs a DateBookDayHeader which is a child of 'parent', with the 30 * Constructs a DateBookDayHeader which is a child of 'parent', with the
35 * name 'name' and widget flags set to 'f' 31 * name 'name' and widget flags set to 'f'
36 * 32 *
37 * 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
38 * TRUE to construct a modal dialog. 34 * TRUE to construct a modal dialog.
39 */ 35 */
40DateBookDayHeader::DateBookDayHeader( bool useMonday, 36DateBookDayHeader::DateBookDayHeader( bool useMonday,
41 QWidget* parent, const char* name ) 37 QWidget* parent, const char* name )
42 : DateBookDayHeaderBase( parent, name ), 38 : DateBookDayHeaderBase( parent, name ),
43 bUseMonday( useMonday ) 39 bUseMonday( useMonday )
44{ 40{
45 connect(date,SIGNAL(pressed()),this,SLOT(pickDate())); 41 connect(date,SIGNAL(pressed()),this,SLOT(pickDate()));
46 42
47 setupNames(); 43 setupNames();
48 44
49 forward->setPixmap( Resource::loadPixmap( "forward" ) ); 45 forward->setPixmap( Resource::loadPixmap( "forward" ) );
50 back->setPixmap( Resource::loadPixmap( "back" ) ); 46 back->setPixmap( Resource::loadPixmap( "back" ) );
51 forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) ); 47 forwardweek->setPixmap( Resource::loadPixmap( "fastforward" ) );
52 backweek->setPixmap( Resource::loadPixmap( "fastback" ) ); 48 backweek->setPixmap( Resource::loadPixmap( "fastback" ) );
53 49
54 setBackgroundMode( PaletteButton ); 50 setBackgroundMode( PaletteButton );
55 grpDays->setBackgroundMode( PaletteButton ); 51 grpDays->setBackgroundMode( PaletteButton );
56} 52}
57 53
58/* 54/*
59 * Destroys the object and frees any allocated resources 55 * Destroys the object and frees any allocated resources
60 */ 56 */
61DateBookDayHeader::~DateBookDayHeader() 57DateBookDayHeader::~DateBookDayHeader()
62{ 58{
63 // 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
64} 60}
65 61
66void DateBookDayHeader::setStartOfWeek( bool onMonday ) 62void DateBookDayHeader::setStartOfWeek( bool onMonday )
67{ 63{
68 bUseMonday = onMonday; 64 bUseMonday = onMonday;
69 setupNames(); 65 setupNames();
70 setDate( currDate.year(), currDate.month(), currDate.day() ); 66 setDate( currDate.year(), currDate.month(), currDate.day() );
71} 67}
72 68
73void DateBookDayHeader::setupNames() 69void DateBookDayHeader::setupNames()
74{ 70{
75 if ( bUseMonday ) { 71 if ( bUseMonday ) {
76 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 72 cmdDay1->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
77 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 73 cmdDay2->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
78 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 74 cmdDay3->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
79 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 75 cmdDay4->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
80 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 76 cmdDay5->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
81 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 77 cmdDay6->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
82 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 78 cmdDay7->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
83 } else { 79 } else {
84 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) ); 80 cmdDay1->setText( DateBookDayHeaderBase::tr("Sunday").left(1) );
85 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) ); 81 cmdDay2->setText( DateBookDayHeaderBase::tr("Monday").left(1) );
86 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) ); 82 cmdDay3->setText( DateBookDayHeaderBase::tr("Tuesday").left(1) );
87 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) ); 83 cmdDay4->setText( DateBookDayHeaderBase::tr("Wednesday").left(1) );
88 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) ); 84 cmdDay5->setText( DateBookDayHeaderBase::tr("Thursday").left(1) );
89 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) ); 85 cmdDay6->setText( DateBookDayHeaderBase::tr("Friday").left(1) );
90 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) ); 86 cmdDay7->setText( DateBookDayHeaderBase::tr("Saturday").left(1) );
91 } 87 }
92} 88}
93 89
94 90
95void DateBookDayHeader::pickDate() 91void DateBookDayHeader::pickDate()
96{ 92{
97 static QPopupMenu *m1 = 0; 93 static QPopupMenu *m1 = 0;
98 static DateBookMonth *picker = 0; 94 static DateBookMonth *picker = 0;
99 if ( !m1 ) { 95 if ( !m1 ) {
100 m1 = new QPopupMenu( this ); 96 m1 = new QPopupMenu( this );
101 picker = new DateBookMonth( m1, 0, TRUE ); 97 picker = new DateBookMonth( m1, 0, TRUE );
102 m1->insertItem( picker ); 98 m1->insertItem( picker );
103 connect( picker, SIGNAL( dateClicked( int, int, int ) ), 99 connect( picker, SIGNAL( dateClicked( int, int, int ) ),
104 this, SLOT( setDate( int, int, int ) ) ); 100 this, SLOT( setDate( int, int, int ) ) );
105 connect( m1, SIGNAL( aboutToHide() ), 101 connect( m1, SIGNAL( aboutToHide() ),
106 this, SLOT( gotHide() ) ); 102 this, SLOT( gotHide() ) );
107 } 103 }
108 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 104 picker->setDate( currDate.year(), currDate.month(), currDate.day() );
109 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height()))); 105 m1->popup(mapToGlobal(date->pos()+QPoint(0,date->height())));
110 picker->setFocus(); 106 picker->setFocus();
111} 107}
112 108
113void DateBookDayHeader::gotHide() 109void DateBookDayHeader::gotHide()
114{ 110{
115 // we have to redo the button... 111 // we have to redo the button...
116 date->setDown( false ); 112 date->setDown( false );
117} 113}
118 114
119/* 115/*
120 * public slot 116 * public slot
121 */ 117 */
122void DateBookDayHeader::goBack() 118void DateBookDayHeader::goBack()
123{ 119{
124 currDate = currDate.addDays( -1 ); 120 currDate = currDate.addDays( -1 );
125 setDate( currDate.year(), currDate.month(), currDate.day() ); 121 setDate( currDate.year(), currDate.month(), currDate.day() );
126} 122}
127/* 123/*
128 * public slot 124 * public slot
129 */ 125 */
130void DateBookDayHeader::goForward() 126void DateBookDayHeader::goForward()
131{ 127{
132 currDate = currDate.addDays( 1 ); 128 currDate = currDate.addDays( 1 );
133 setDate( currDate.year(), currDate.month(), currDate.day() ); 129 setDate( currDate.year(), currDate.month(), currDate.day() );
134} 130}
135/* 131/*
136 * public slot 132 * public slot
137 */ 133 */
138void DateBookDayHeader::goBackWeek() 134void DateBookDayHeader::goBackWeek()
139{ 135{
140 currDate = currDate.addDays( -7 ); 136 currDate = currDate.addDays( -7 );
141 setDate( currDate.year(), currDate.month(), currDate.day() ); 137 setDate( currDate.year(), currDate.month(), currDate.day() );
142} 138}
143/* 139/*
144 * public slot 140 * public slot
145 */ 141 */
146void DateBookDayHeader::goForwardWeek() 142void DateBookDayHeader::goForwardWeek()
147{ 143{
148 currDate = currDate.addDays( 7 ); 144 currDate = currDate.addDays( 7 );
149 setDate( currDate.year(), currDate.month(), currDate.day() ); 145 setDate( currDate.year(), currDate.month(), currDate.day() );
150} 146}
151 147
152 148
153/* 149/*
154 * public slot 150 * public slot
155 */ 151 */
156void DateBookDayHeader::setDate( int y, int m, int d ) 152void DateBookDayHeader::setDate( int y, int m, int d )
157{ 153{
158 currDate.setYMD( y, m, d ); 154 currDate.setYMD( y, m, d );
159 date->setText( TimeString::shortDate( currDate ) ); 155 date->setText( TimeString::shortDate( currDate ) );
160 156
161 int iDayOfWeek = currDate.dayOfWeek(); 157 int iDayOfWeek = currDate.dayOfWeek();
162 // cleverly adjust the day depending on how we start the week 158 // cleverly adjust the day depending on how we start the week
163 if ( bUseMonday ) 159 if ( bUseMonday )
164 iDayOfWeek--; 160 iDayOfWeek--;
165 else { 161 else {
166 if ( iDayOfWeek == 7 ) // Sunday 162 if ( iDayOfWeek == 7 ) // Sunday
167 iDayOfWeek = 0; 163 iDayOfWeek = 0;
168 } 164 }
169 grpDays->setButton( iDayOfWeek ); 165 grpDays->setButton( iDayOfWeek );
170 emit dateChanged( y, m, d ); 166 emit dateChanged( y, m, d );
171} 167}
172 168
173/* 169/*
174 * public slot 170 * public slot
175 */ 171 */
176void DateBookDayHeader::setDay( int day ) 172void DateBookDayHeader::setDay( int day )
177{ 173{
178 int realDay; 174 int realDay;
179 int dayOfWeek = currDate.dayOfWeek(); 175 int dayOfWeek = currDate.dayOfWeek();
180 176
181 // a little adjustment is needed... 177 // a little adjustment is needed...
182 if ( bUseMonday ) 178 if ( bUseMonday )
183 realDay = day + 1 ; 179 realDay = day + 1 ;
184 else if ( !bUseMonday && day == 0 ) // sunday 180 else if ( !bUseMonday && day == 0 ) // sunday
185 realDay = 7; 181 realDay = 7;
186 else 182 else
187 realDay = day; 183 realDay = day;
188 // special cases first... 184 // special cases first...
189 if ( realDay == 7 && !bUseMonday ) { 185 if ( realDay == 7 && !bUseMonday ) {
190 while ( currDate.dayOfWeek() != realDay ) 186 while ( currDate.dayOfWeek() != realDay )
191 currDate = currDate.addDays( -1 ); 187 currDate = currDate.addDays( -1 );
192 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) { 188 } else if ( !bUseMonday && dayOfWeek == 7 && dayOfWeek > realDay ) {
193 while ( currDate.dayOfWeek() != realDay ) 189 while ( currDate.dayOfWeek() != realDay )
194 currDate = currDate.addDays( 1 ); 190 currDate = currDate.addDays( 1 );
195 } else if ( dayOfWeek < realDay ) { 191 } else if ( dayOfWeek < realDay ) {
196 while ( currDate.dayOfWeek() < realDay ) 192 while ( currDate.dayOfWeek() < realDay )
197 currDate = currDate.addDays( 1 ); 193 currDate = currDate.addDays( 1 );
198 } else if ( dayOfWeek > realDay ) { 194 } else if ( dayOfWeek > realDay ) {
199 while ( currDate.dayOfWeek() > realDay ) 195 while ( currDate.dayOfWeek() > realDay )
200 currDate = currDate.addDays( -1 ); 196 currDate = currDate.addDays( -1 );
201 } 197 }
202 // update the date... 198 // update the date...
203 setDate( currDate.year(), currDate.month(), currDate.day() ); 199 setDate( currDate.year(), currDate.month(), currDate.day() );
204} 200}
diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp
index 675b17f..a6d04ba 100644
--- a/core/pim/datebook/datebooksettings.cpp
+++ b/core/pim/datebook/datebooksettings.cpp
@@ -1,156 +1,155 @@
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#include <qcombobox.h>
28 27
29DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, 28DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent,
30 const char *name, bool modal, WFlags fl ) 29 const char *name, bool modal, WFlags fl )
31 : DateBookSettingsBase( parent, name, modal, fl ), 30 : DateBookSettingsBase( parent, name, modal, fl ),
32 ampm( whichClock ) 31 ampm( whichClock )
33{ 32{
34 init(); 33 init();
35 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) ); 34 QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) );
36 QArray<int> categories; 35 QArray<int> categories;
37 comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); 36 comboCategory->setCategories( categories, "Calendar", tr("Calendar") );
38} 37}
39 38
40DateBookSettings::~DateBookSettings() 39DateBookSettings::~DateBookSettings()
41{ 40{
42} 41}
43 42
44void DateBookSettings::setStartTime( int newStartViewTime ) 43void DateBookSettings::setStartTime( int newStartViewTime )
45{ 44{
46 if ( ampm ) { 45 if ( ampm ) {
47 if ( newStartViewTime >= 12 ) { 46 if ( newStartViewTime >= 12 ) {
48 newStartViewTime %= 12; 47 newStartViewTime %= 12;
49 if ( newStartViewTime == 0 ) 48 if ( newStartViewTime == 0 )
50 newStartViewTime = 12; 49 newStartViewTime = 12;
51 spinStart->setSuffix( tr(":00 PM") ); 50 spinStart->setSuffix( tr(":00 PM") );
52 } 51 }
53 else if ( newStartViewTime == 0 ) { 52 else if ( newStartViewTime == 0 ) {
54 newStartViewTime = 12; 53 newStartViewTime = 12;
55 spinStart->setSuffix( tr(":00 AM") ); 54 spinStart->setSuffix( tr(":00 AM") );
56 } 55 }
57 oldtime = newStartViewTime; 56 oldtime = newStartViewTime;
58 } 57 }
59 spinStart->setValue( newStartViewTime ); 58 spinStart->setValue( newStartViewTime );
60} 59}
61 60
62int DateBookSettings::startTime() const 61int DateBookSettings::startTime() const
63{ 62{
64 int returnMe = spinStart->value(); 63 int returnMe = spinStart->value();
65 if ( ampm ) { 64 if ( ampm ) {
66 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) 65 if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) )
67 returnMe += 12; 66 returnMe += 12;
68 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) 67 else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE))
69 returnMe = 0; 68 returnMe = 0;
70 } 69 }
71 return returnMe; 70 return returnMe;
72} 71}
73 72
74 73
75void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) 74void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime )
76{ 75{
77 chkAlarmPreset->setChecked( bAlarm ); 76 chkAlarmPreset->setChecked( bAlarm );
78 if ( presetTime >=5 ) 77 if ( presetTime >=5 )
79 spinPreset->setValue( presetTime ); 78 spinPreset->setValue( presetTime );
80} 79}
81 80
82bool DateBookSettings::alarmPreset() const 81bool DateBookSettings::alarmPreset() const
83{ 82{
84 return chkAlarmPreset->isChecked(); 83 return chkAlarmPreset->isChecked();
85} 84}
86 85
87int DateBookSettings::presetTime() const 86int DateBookSettings::presetTime() const
88{ 87{
89 return spinPreset->value(); 88 return spinPreset->value();
90} 89}
91 90
92 91
93void DateBookSettings::slot12Hour( int i ) 92void DateBookSettings::slot12Hour( int i )
94{ 93{
95 if ( ampm ) { 94 if ( ampm ) {
96 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { 95 if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) {
97 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 96 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
98 spinStart->setSuffix( tr(":00 PM") ); 97 spinStart->setSuffix( tr(":00 PM") );
99 } else { 98 } else {
100 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) 99 if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 )
101 spinStart->setSuffix( tr(":00 AM") ); 100 spinStart->setSuffix( tr(":00 AM") );
102 } 101 }
103 oldtime = i; 102 oldtime = i;
104 } 103 }
105} 104}
106 105
107void DateBookSettings::init() 106void DateBookSettings::init()
108{ 107{
109 if ( ampm ) { 108 if ( ampm ) {
110 spinStart->setMinValue( 1 ); 109 spinStart->setMinValue( 1 );
111 spinStart->setMaxValue( 12 ); 110 spinStart->setMaxValue( 12 );
112 spinStart->setValue( 12 ); 111 spinStart->setValue( 12 );
113 spinStart->setSuffix( tr(":00 AM") ); 112 spinStart->setSuffix( tr(":00 AM") );
114 oldtime = 12; 113 oldtime = 12;
115 } else { 114 } else {
116 spinStart->setMinValue( 0 ); 115 spinStart->setMinValue( 0 );
117 spinStart->setMaxValue( 23 ); 116 spinStart->setMaxValue( 23 );
118 spinStart->setSuffix( tr(":00") ); 117 spinStart->setSuffix( tr(":00") );
119 } 118 }
120} 119}
121 120
122void DateBookSettings::slotChangeClock( bool whichClock ) 121void DateBookSettings::slotChangeClock( bool whichClock )
123{ 122{
124 int saveMe; 123 int saveMe;
125 saveMe = spinStart->value(); 124 saveMe = spinStart->value();
126 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { 125 if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) {
127 if ( saveMe == 12 ) 126 if ( saveMe == 12 )
128 saveMe = 0; 127 saveMe = 0;
129 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { 128 } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) {
130 if ( saveMe != 12 ) 129 if ( saveMe != 12 )
131 saveMe += 12; 130 saveMe += 12;
132 } 131 }
133 ampm = whichClock; 132 ampm = whichClock;
134 init(); 133 init();
135 setStartTime( saveMe ); 134 setStartTime( saveMe );
136} 135}
137 136
138void DateBookSettings::setJumpToCurTime( bool bJump ) 137void DateBookSettings::setJumpToCurTime( bool bJump )
139{ 138{
140 chkJumpToCurTime->setChecked( bJump ); 139 chkJumpToCurTime->setChecked( bJump );
141} 140}
142 141
143bool DateBookSettings::jumpToCurTime() const 142bool DateBookSettings::jumpToCurTime() const
144{ 143{
145 return chkJumpToCurTime->isChecked(); 144 return chkJumpToCurTime->isChecked();
146} 145}
147 146
148void DateBookSettings::setRowStyle( int style ) 147void DateBookSettings::setRowStyle( int style )
149{ 148{
150 comboRowStyle->setCurrentItem( style ); 149 comboRowStyle->setCurrentItem( style );
151} 150}
152 151
153int DateBookSettings::rowStyle() const 152int DateBookSettings::rowStyle() const
154{ 153{
155 return comboRowStyle->currentItem(); 154 return comboRowStyle->currentItem();
156} 155}
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index 84b4f1b..eaa9730 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,124 +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 "datebookweekheader.h"
22#include "datebookweek.h" 21#include "datebookweek.h"
23#include <qlabel.h>
24#include <qspinbox.h>
25#include <qdatetime.h>
26#include <qpe/resource.h> 22#include <qpe/resource.h>
27#include <qpe/datebookmonth.h> 23#include <qpe/datebookmonth.h>
28 24
29#include <qtoolbutton.h> 25#include <qtoolbutton.h>
30 26
31/* 27/*
32 * Constructs a DateBookWeekHeader which is a child of 'parent', with the 28 * Constructs a DateBookWeekHeader which is a child of 'parent', with the
33 * name 'name' and widget flags set to 'f' 29 * name 'name' and widget flags set to 'f'
34 */ 30 */
35DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) 31DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl )
36 : DateBookWeekHeaderBase( parent, name, fl ), 32 : DateBookWeekHeaderBase( parent, name, fl ),
37 bStartOnMonday( startOnMonday ) 33 bStartOnMonday( startOnMonday )
38{ 34{
39 setBackgroundMode( PaletteButton ); 35 setBackgroundMode( PaletteButton );
40 labelDate->setBackgroundMode( PaletteButton ); 36 labelDate->setBackgroundMode( PaletteButton );
41 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 37 backmonth->setPixmap( Resource::loadPixmap("fastback") );
42 backweek->setPixmap( Resource::loadPixmap("back") ); 38 backweek->setPixmap( Resource::loadPixmap("back") );
43 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 39 forwardweek->setPixmap( Resource::loadPixmap("forward") );
44 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 40 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
45} 41}
46 42
47/* 43/*
48 * Destroys the object and frees any allocated resources 44 * Destroys the object and frees any allocated resources
49 */ 45 */
50DateBookWeekHeader::~DateBookWeekHeader() 46DateBookWeekHeader::~DateBookWeekHeader()
51{ 47{
52 // 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
53} 49}
54 50
55void DateBookWeekHeader::pickDate() 51void DateBookWeekHeader::pickDate()
56{ 52{
57 static QPopupMenu *m1 = 0; 53 static QPopupMenu *m1 = 0;
58 static DateBookMonth *picker = 0; 54 static DateBookMonth *picker = 0;
59 if ( !m1 ) { 55 if ( !m1 ) {
60 m1 = new QPopupMenu( this ); 56 m1 = new QPopupMenu( this );
61 picker = new DateBookMonth( m1, 0, TRUE ); 57 picker = new DateBookMonth( m1, 0, TRUE );
62 m1->insertItem( picker ); 58 m1->insertItem( picker );
63 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 ) ) );
64 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) ); 60 // connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
65 } 61 }
66 picker->setDate( date.year(), date.month(), date.day() ); 62 picker->setDate( date.year(), date.month(), date.day() );
67 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 63 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
68 picker->setFocus(); 64 picker->setFocus();
69} 65}
70 66
71void DateBookWeekHeader::nextMonth() 67void DateBookWeekHeader::nextMonth()
72{ 68{
73 qWarning("nextMonth() " ); 69 qWarning("nextMonth() " );
74 setDate(date.addDays(28)); 70 setDate(date.addDays(28));
75} 71}
76void DateBookWeekHeader::prevMonth() 72void DateBookWeekHeader::prevMonth()
77{ 73{
78 qWarning("prevMonth() " ); 74 qWarning("prevMonth() " );
79 setDate(date.addDays(-28)); 75 setDate(date.addDays(-28));
80} 76}
81void DateBookWeekHeader::nextWeek() 77void DateBookWeekHeader::nextWeek()
82{ 78{
83 qWarning("nextWeek() " ); 79 qWarning("nextWeek() " );
84 setDate(date.addDays(7)); 80 setDate(date.addDays(7));
85} 81}
86void DateBookWeekHeader::prevWeek() 82void DateBookWeekHeader::prevWeek()
87{ 83{
88 qWarning("prevWeek() "); 84 qWarning("prevWeek() ");
89 setDate(date.addDays(-7)); 85 setDate(date.addDays(-7));
90} 86}
91 87
92void DateBookWeekHeader::setDate( int y, int m, int d ) 88void DateBookWeekHeader::setDate( int y, int m, int d )
93{ 89{
94 setDate(QDate(y,m,d)); 90 setDate(QDate(y,m,d));
95} 91}
96 92
97void DateBookWeekHeader::setDate(const QDate &d) { 93void DateBookWeekHeader::setDate(const QDate &d) {
98 int year,week,dayofweek; 94 int year,week,dayofweek;
99 date=d; 95 date=d;
100 dayofweek=d.dayOfWeek(); 96 dayofweek=d.dayOfWeek();
101 if(bStartOnMonday) 97 if(bStartOnMonday)
102 dayofweek--; 98 dayofweek--;
103 else if( dayofweek == 7 ) 99 else if( dayofweek == 7 )
104 // 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..
105 dayofweek = 0; 101 dayofweek = 0;
106 102
107 date=date.addDays(-dayofweek); 103 date=date.addDays(-dayofweek);
108 calcWeek(date,week,year,bStartOnMonday); 104 calcWeek(date,week,year,bStartOnMonday);
109 QDate start=date; 105 QDate start=date;
110 QDate stop=start.addDays(6); 106 QDate stop=start.addDays(6);
111 labelDate->setText( QString::number(start.day()) + "." + 107 labelDate->setText( QString::number(start.day()) + "." +
112 Calendar::nameOfMonth( start.month()) + "-" + 108 Calendar::nameOfMonth( start.month()) + "-" +
113 QString::number(stop.day()) + "." + 109 QString::number(stop.day()) + "." +
114 Calendar::nameOfMonth( stop.month()) +" ("+ 110 Calendar::nameOfMonth( stop.month()) +" ("+
115 tr("w")+":"+QString::number( week ) +")"); 111 tr("w")+":"+QString::number( week ) +")");
116 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!
117 emit dateChanged(date); 113 emit dateChanged(date);
118} 114}
119 115
120void DateBookWeekHeader::setStartOfWeek( bool onMonday ) 116void DateBookWeekHeader::setStartOfWeek( bool onMonday )
121{ 117{
122 bStartOnMonday = onMonday; 118 bStartOnMonday = onMonday;
123 setDate( date ); 119 setDate( date );
124} 120}
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 24fb0ba..42a1753 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,395 +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#include <qpe/calendar.h>
10 9
11#include <qlayout.h> 10#include <qlayout.h>
12#include <qtoolbutton.h> 11#include <qtoolbutton.h>
13#include <qtl.h> 12#include <qtl.h>
14 13
15bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); 14bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
16 15
17DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) 16DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
18 : DateBookWeekLstHeaderBase(parent, name, fl) 17 : DateBookWeekLstHeaderBase(parent, name, fl)
19{ 18{
20 setBackgroundMode( PaletteButton ); 19 setBackgroundMode( PaletteButton );
21 labelDate->setBackgroundMode( PaletteButton ); 20 labelDate->setBackgroundMode( PaletteButton );
22 forwardweek->setBackgroundMode( PaletteButton ); 21 forwardweek->setBackgroundMode( PaletteButton );
23 forwardweek->setPixmap( Resource::loadPixmap("forward") ); 22 forwardweek->setPixmap( Resource::loadPixmap("forward") );
24 forwardmonth->setBackgroundMode( PaletteButton ); 23 forwardmonth->setBackgroundMode( PaletteButton );
25 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") ); 24 forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
26 backweek->setBackgroundMode( PaletteButton ); 25 backweek->setBackgroundMode( PaletteButton );
27 backweek->setPixmap( Resource::loadPixmap("back") ); 26 backweek->setPixmap( Resource::loadPixmap("back") );
28 backmonth->setBackgroundMode( PaletteButton ); 27 backmonth->setBackgroundMode( PaletteButton );
29 backmonth->setPixmap( Resource::loadPixmap("fastback") ); 28 backmonth->setPixmap( Resource::loadPixmap("fastback") );
30 DateBookWeekLstHeaderBaseLayout->setSpacing(0); 29 DateBookWeekLstHeaderBaseLayout->setSpacing(0);
31 DateBookWeekLstHeaderBaseLayout->setMargin(0); 30 DateBookWeekLstHeaderBaseLayout->setMargin(0);
32 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding)); 31 //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
33 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 32 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
34 33
35 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth())); 34 connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
36 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek())); 35 connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
37 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek())); 36 connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
38 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth())); 37 connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
39 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate())); 38 connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
40 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool))); 39 connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
41 bStartOnMonday=onM; 40 bStartOnMonday=onM;
42} 41}
43DateBookWeekLstHeader::~DateBookWeekLstHeader(){} 42DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
44 43
45void DateBookWeekLstHeader::setDate(const QDate &d) { 44void DateBookWeekLstHeader::setDate(const QDate &d) {
46 int year,week,dayofweek; 45 int year,week,dayofweek;
47 date=d; 46 date=d;
48 dayofweek=d.dayOfWeek(); 47 dayofweek=d.dayOfWeek();
49 if(bStartOnMonday) 48 if(bStartOnMonday)
50 dayofweek--; 49 dayofweek--;
51 else if( dayofweek == 7 ) 50 else if( dayofweek == 7 )
52 /* 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 */
53 dayofweek = 0; 52 dayofweek = 0;
54 53
55 date=date.addDays(-dayofweek); 54 date=date.addDays(-dayofweek);
56 55
57 calcWeek(date,week,year,bStartOnMonday); 56 calcWeek(date,week,year,bStartOnMonday);
58 QDate start=date; 57 QDate start=date;
59 QDate stop=start.addDays(6); 58 QDate stop=start.addDays(6);
60 labelDate->setText( QString::number(start.day()) + "." + 59 labelDate->setText( QString::number(start.day()) + "." +
61 Calendar::nameOfMonth( start.month() ) + "-" + 60 Calendar::nameOfMonth( start.month() ) + "-" +
62 QString::number(stop.day()) + "." + 61 QString::number(stop.day()) + "." +
63 Calendar::nameOfMonth( stop.month()) +" ("+ 62 Calendar::nameOfMonth( stop.month()) +" ("+
64 tr("w")+":"+QString::number( week ) +")"); 63 tr("w")+":"+QString::number( week ) +")");
65 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!
66 emit dateChanged(date); 65 emit dateChanged(date);
67} 66}
68 67
69void DateBookWeekLstHeader::pickDate() { 68void DateBookWeekLstHeader::pickDate() {
70 static QPopupMenu *m1 = 0; 69 static QPopupMenu *m1 = 0;
71 static DateBookMonth *picker = 0; 70 static DateBookMonth *picker = 0;
72 if ( !m1 ) { 71 if ( !m1 ) {
73 m1 = new QPopupMenu( this ); 72 m1 = new QPopupMenu( this );
74 picker = new DateBookMonth( m1, 0, TRUE ); 73 picker = new DateBookMonth( m1, 0, TRUE );
75 m1->insertItem( picker ); 74 m1->insertItem( picker );
76 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 ) ) );
77 //connect( m1, SIGNAL( aboutToHide() ), 76 //connect( m1, SIGNAL( aboutToHide() ),
78 //this, SLOT( gotHide() ) ); 77 //this, SLOT( gotHide() ) );
79 } 78 }
80 picker->setDate( date.year(), date.month(), date.day() ); 79 picker->setDate( date.year(), date.month(), date.day() );
81 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height()))); 80 m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
82 picker->setFocus(); 81 picker->setFocus();
83} 82}
84void DateBookWeekLstHeader::setDate(int y, int m, int d) { 83void DateBookWeekLstHeader::setDate(int y, int m, int d) {
85 setDate(QDate(y,m,d)); 84 setDate(QDate(y,m,d));
86} 85}
87 86
88void DateBookWeekLstHeader::nextWeek() { 87void DateBookWeekLstHeader::nextWeek() {
89 setDate(date.addDays(7)); 88 setDate(date.addDays(7));
90} 89}
91void DateBookWeekLstHeader::prevWeek() { 90void DateBookWeekLstHeader::prevWeek() {
92 setDate(date.addDays(-7)); 91 setDate(date.addDays(-7));
93} 92}
94void DateBookWeekLstHeader::nextMonth() 93void DateBookWeekLstHeader::nextMonth()
95{ 94{
96 setDate(date.addDays(28)); 95 setDate(date.addDays(28));
97} 96}
98void DateBookWeekLstHeader::prevMonth() 97void DateBookWeekLstHeader::prevMonth()
99{ 98{
100 setDate(date.addDays(-28)); 99 setDate(date.addDays(-28));
101} 100}
102 101
103DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, 102DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
104 QWidget* parent, 103 QWidget* parent,
105 const char* name, 104 const char* name,
106 WFlags fl ) 105 WFlags fl )
107 : DateBookWeekLstDayHdrBase(parent, name, fl) { 106 : DateBookWeekLstDayHdrBase(parent, name, fl) {
108 107
109 date=d; 108 date=d;
110 109
111 static const QString wdays=tr("MTWTFSSM", "Week days"); 110 static const QString wdays=tr("MTWTFSSM", "Week days");
112 char day=wdays[d.dayOfWeek()-1]; 111 char day=wdays[d.dayOfWeek()-1];
113 112
114 //dont use dayOfWeek() to save space ! 113 //dont use dayOfWeek() to save space !
115 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()) );
116 115
117 add->setText("+"); 116 add->setText("+");
118 117
119 if (d == QDate::currentDate()) { 118 if (d == QDate::currentDate()) {
120 QPalette pal=label->palette(); 119 QPalette pal=label->palette();
121 pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); 120 pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
122 label->setPalette(pal); 121 label->setPalette(pal);
123 122
124 /* 123 /*
125 QFont f=label->font(); 124 QFont f=label->font();
126 f.setItalic(true); 125 f.setItalic(true);
127 label->setFont(f); 126 label->setFont(f);
128 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); 127 label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
129 */ 128 */
130 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday 129 } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
131 QPalette pal=label->palette(); 130 QPalette pal=label->palette();
132 pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); 131 pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
133 label->setPalette(pal); 132 label->setPalette(pal);
134 } 133 }
135 134
136 connect (label, SIGNAL(clicked()), this, SLOT(showDay())); 135 connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
137 connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); 136 connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
138} 137}
139 138
140void DateBookWeekLstDayHdr::showDay() { 139void DateBookWeekLstDayHdr::showDay() {
141 emit showDate(date.year(), date.month(), date.day()); 140 emit showDate(date.year(), date.month(), date.day());
142} 141}
143 142
144void DateBookWeekLstDayHdr::newEvent() { 143void DateBookWeekLstDayHdr::newEvent() {
145 QDateTime start, stop; 144 QDateTime start, stop;
146 start=stop=date; 145 start=stop=date;
147 start.setTime(QTime(10,0)); 146 start.setTime(QTime(10,0));
148 stop.setTime(QTime(12,0)); 147 stop.setTime(QTime(12,0));
149 148
150 emit addEvent(start,stop,"",0); 149 emit addEvent(start,stop,"",0);
151} 150}
152DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, 151DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
153 int weeklistviewconfig, 152 int weeklistviewconfig,
154 QWidget* parent, 153 QWidget* parent,
155 const char* name, 154 const char* name,
156 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) 155 WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
157{ 156{
158 // old values... lastday = "__|__", middle=" |---", Firstday="00:00", 157 // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
159 QString s,start,middle,end,day; 158 QString s,start,middle,end,day;
160 159
161 qDebug("weeklistviewconfig=%d",weeklistviewconfig); 160 qDebug("weeklistviewconfig=%d",weeklistviewconfig);
162 if(weeklistviewconfig==NONE) {// No times displayed. 161 if(weeklistviewconfig==NONE) {// No times displayed.
163 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 162 // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
164 // middle.sprintf("<--->"); 163 // middle.sprintf("<--->");
165 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 164 // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
166 // 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());
167 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time. 166 } else if(weeklistviewconfig==NORMAL) {// "Normal", only display start time.
168 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 167 start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
169 middle.sprintf(" |---"); 168 middle.sprintf(" |---");
170 end.sprintf("__|__"); 169 end.sprintf("__|__");
171 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); 170 day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
172 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. 171 } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
173 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); 172 start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
174 middle.sprintf("<--->"); 173 middle.sprintf("<--->");
175 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); 174 end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
176 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());
177 } 176 }
178 177
179 if(ev.event().type() == Event::Normal) { 178 if(ev.event().type() == Event::Normal) {
180 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event. 179 if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) {// day event.
181 s=day; 180 s=day;
182 } else if(ev.startDate()==ev.date()) {// start event. 181 } else if(ev.startDate()==ev.date()) {// start event.
183 s=start; 182 s=start;
184 } else if(ev.endDate()==ev.date()) { // end event. 183 } else if(ev.endDate()==ev.date()) { // end event.
185 s=end; 184 s=end;
186 } else {// middle day. 185 } else {// middle day.
187 s=middle; 186 s=middle;
188 } 187 }
189 } else { 188 } else {
190 s=""; 189 s="";
191 } 190 }
192 setText(QString(s) + " " + ev.description()); 191 setText(QString(s) + " " + ev.description());
193 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 192 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
194 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 193 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
195} 194}
196void DateBookWeekLstEvent::editMe() { 195void DateBookWeekLstEvent::editMe() {
197 emit editEvent(event.event()); 196 emit editEvent(event.event());
198} 197}
199 198
200 199
201DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, 200DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
202 const QDate &d, bool onM, 201 const QDate &d, bool onM,
203 QWidget* parent, 202 QWidget* parent,
204 const char* name, WFlags fl) 203 const char* name, WFlags fl)
205 : QWidget( parent, name, fl ) 204 : QWidget( parent, name, fl )
206{ 205{
207 Config config("DateBook"); 206 Config config("DateBook");
208 config.setGroup("Main"); 207 config.setGroup("Main");
209 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); 208 int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
210 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig); 209 qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
211 210
212 bStartOnMonday=onM; 211 bStartOnMonday=onM;
213 setPalette(white); 212 setPalette(white);
214 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); 213 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
215 214
216 QVBoxLayout *layout = new QVBoxLayout( this ); 215 QVBoxLayout *layout = new QVBoxLayout( this );
217 216
218 qBubbleSort(ev); 217 qBubbleSort(ev);
219 QValueListIterator<EffectiveEvent> it; 218 QValueListIterator<EffectiveEvent> it;
220 it=ev.begin(); 219 it=ev.begin();
221 220
222 int dayOrder[7]; 221 int dayOrder[7];
223 if (bStartOnMonday) { 222 if (bStartOnMonday) {
224 for (int d=0; d<7; d++) dayOrder[d]=d+1; 223 for (int d=0; d<7; d++) dayOrder[d]=d+1;
225 } else { 224 } else {
226 for (int d=0; d<7; d++) dayOrder[d]=d; 225 for (int d=0; d<7; d++) dayOrder[d]=d;
227 dayOrder[0]=7; 226 dayOrder[0]=7;
228 } 227 }
229 228
230 // Calculate offset to first day of week. 229 // Calculate offset to first day of week.
231 int dayoffset=d.dayOfWeek(); 230 int dayoffset=d.dayOfWeek();
232 if(bStartOnMonday) dayoffset--; 231 if(bStartOnMonday) dayoffset--;
233 else if( dayoffset == 7 ) dayoffset = 0; 232 else if( dayoffset == 7 ) dayoffset = 0;
234 233
235 for (int i=0; i<7; i++) { 234 for (int i=0; i<7; i++) {
236 // Header 235 // Header
237 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); 236 DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
238 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)));
239 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 &)),
240 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 239 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
241 layout->addWidget(hdr); 240 layout->addWidget(hdr);
242 241
243 // Events 242 // Events
244 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { 243 while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
245 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.
246 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); 245 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
247 layout->addWidget(l); 246 layout->addWidget(l);
248 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 247 connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
249 } 248 }
250 it++; 249 it++;
251 } 250 }
252 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 251 layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
253 } 252 }
254} 253}
255DateBookWeekLstView::~DateBookWeekLstView(){} 254DateBookWeekLstView::~DateBookWeekLstView(){}
256void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} 255void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
257 256
258DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 257DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
259 QValueList<EffectiveEvent> &ev2, 258 QValueList<EffectiveEvent> &ev2,
260 QDate &d, bool onM, 259 QDate &d, bool onM,
261 QWidget* parent, 260 QWidget* parent,
262 const char* name, WFlags fl) 261 const char* name, WFlags fl)
263 : QWidget( parent, name, fl ) 262 : QWidget( parent, name, fl )
264{ 263{
265 QHBoxLayout *layout = new QHBoxLayout( this ); 264 QHBoxLayout *layout = new QHBoxLayout( this );
266 265
267 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); 266 DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
268 layout->addWidget(w); 267 layout->addWidget(w);
269 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 268 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
270 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)));
271 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 &)),
272 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 271 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
273 272
274 273
275 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); 274 w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
276 layout->addWidget(w); 275 layout->addWidget(w);
277 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 276 connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
278 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)));
279 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 &)),
280 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 279 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
281} 280}
282 281
283DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, 282DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
284 QWidget *parent, 283 QWidget *parent,
285 const char *name ) 284 const char *name )
286 : QWidget( parent, name ), 285 : QWidget( parent, name ),
287 db( newDB ), 286 db( newDB ),
288 startTime( 0 ), 287 startTime( 0 ),
289 ampm( ap ), 288 ampm( ap ),
290 bStartOnMonday(onM) 289 bStartOnMonday(onM)
291{ 290{
292 setFocusPolicy(StrongFocus); 291 setFocusPolicy(StrongFocus);
293 layout = new QVBoxLayout( this ); 292 layout = new QVBoxLayout( this );
294 layout->setMargin(0); 293 layout->setMargin(0);
295 294
296 header=new DateBookWeekLstHeader(onM, this); 295 header=new DateBookWeekLstHeader(onM, this);
297 layout->addWidget( header ); 296 layout->addWidget( header );
298 connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &))); 297 connect(header, SIGNAL(dateChanged(QDate &)), this, SLOT(dateChanged(QDate &)));
299 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); 298 connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
300 299
301 scroll=new QScrollView(this); 300 scroll=new QScrollView(this);
302 scroll->setResizePolicy(QScrollView::AutoOneFit); 301 scroll->setResizePolicy(QScrollView::AutoOneFit);
303 layout->addWidget(scroll); 302 layout->addWidget(scroll);
304 303
305 view=NULL; 304 view=NULL;
306 Config config("DateBook"); 305 Config config("DateBook");
307 config.setGroup("Main"); 306 config.setGroup("Main");
308 dbl=config.readBoolEntry("weeklst_dbl", false); 307 dbl=config.readBoolEntry("weeklst_dbl", false);
309 header->dbl->setOn(dbl); 308 header->dbl->setOn(dbl);
310} 309}
311DateBookWeekLst::~DateBookWeekLst(){ 310DateBookWeekLst::~DateBookWeekLst(){
312 Config config("DateBook"); 311 Config config("DateBook");
313 config.setGroup("Main"); 312 config.setGroup("Main");
314 config.writeEntry("weeklst_dbl", dbl); 313 config.writeEntry("weeklst_dbl", dbl);
315} 314}
316 315
317void DateBookWeekLst::setDate(const QDate &d) { 316void DateBookWeekLst::setDate(const QDate &d) {
318 bdate=d; 317 bdate=d;
319 header->setDate(d); 318 header->setDate(d);
320} 319}
321 320
322void DateBookWeekLst::setDbl(bool on) { 321void DateBookWeekLst::setDbl(bool on) {
323 dbl=on; 322 dbl=on;
324 redraw(); 323 redraw();
325} 324}
326void DateBookWeekLst::redraw() {getEvents();} 325void DateBookWeekLst::redraw() {getEvents();}
327 326
328QDate DateBookWeekLst::date() { 327QDate DateBookWeekLst::date() {
329 return bdate; 328 return bdate;
330} 329}
331 330
332// return the date at the beginning of the week... 331// return the date at the beginning of the week...
333// copied from DateBookWeek 332// copied from DateBookWeek
334QDate DateBookWeekLst::weekDate() const 333QDate DateBookWeekLst::weekDate() const
335{ 334{
336 QDate d=bdate; 335 QDate d=bdate;
337 336
338 // Calculate offset to first day of week. 337 // Calculate offset to first day of week.
339 int dayoffset=d.dayOfWeek(); 338 int dayoffset=d.dayOfWeek();
340 if(bStartOnMonday) dayoffset--; 339 if(bStartOnMonday) dayoffset--;
341 else if( dayoffset == 7 ) 340 else if( dayoffset == 7 )
342 dayoffset = 0; 341 dayoffset = 0;
343 342
344 return d.addDays(-dayoffset); 343 return d.addDays(-dayoffset);
345} 344}
346 345
347void DateBookWeekLst::getEvents() { 346void DateBookWeekLst::getEvents() {
348 QDate start = weekDate(); //date(); 347 QDate start = weekDate(); //date();
349 QDate stop = start.addDays(6); 348 QDate stop = start.addDays(6);
350 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop); 349 QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
351 350
352 if (view) delete view; 351 if (view) delete view;
353 if (dbl) { 352 if (dbl) {
354 QDate start2=start.addDays(7); 353 QDate start2=start.addDays(7);
355 stop=start2.addDays(6); 354 stop=start2.addDays(6);
356 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop); 355 QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
357 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll); 356 view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
358 } else { 357 } else {
359 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll); 358 view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
360 } 359 }
361 360
362 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); 361 connect (view, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
363 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)));
364 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 &)),
365 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); 364 this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
366 365
367 scroll->addChild(view); 366 scroll->addChild(view);
368 view->show(); 367 view->show();
369 scroll->updateScrollBars(); 368 scroll->updateScrollBars();
370} 369}
371 370
372void DateBookWeekLst::dateChanged(QDate &newdate) { 371void DateBookWeekLst::dateChanged(QDate &newdate) {
373 bdate=newdate; 372 bdate=newdate;
374 getEvents(); 373 getEvents();
375} 374}
376 375
377void DateBookWeekLst::keyPressEvent(QKeyEvent *e) 376void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
378{ 377{
379 switch(e->key()) { 378 switch(e->key()) {
380 case Key_Up: 379 case Key_Up:
381 scroll->scrollBy(0, -20); 380 scroll->scrollBy(0, -20);
382 break; 381 break;
383 case Key_Down: 382 case Key_Down:
384 scroll->scrollBy(0, 20); 383 scroll->scrollBy(0, 20);
385 break; 384 break;
386 case Key_Left: 385 case Key_Left:
387 header->prevWeek(); 386 header->prevWeek();
388 break; 387 break;
389 case Key_Right: 388 case Key_Right:
390 header->nextWeek(); 389 header->nextWeek();
391 break; 390 break;
392 default: 391 default:
393 e->ignore(); 392 e->ignore();
394 } 393 }
395} 394}
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 856837c..018bb5a 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -1,570 +1,559 @@
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 "dateentryimpl.h" 21#include "dateentryimpl.h"
22#include "repeatentry.h" 22#include "repeatentry.h"
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/categoryselect.h> 25#include <qpe/categoryselect.h>
26#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
27#include <qpe/global.h>
28#include <qpe/timeconversion.h>
29#include <qpe/timestring.h>
30#include <qpe/tzselect.h> 27#include <qpe/tzselect.h>
31 28
32#include <qevent.h>
33#include <qcheckbox.h>
34#include <qcombobox.h>
35#include <qlayout.h>
36#include <qlineedit.h> 29#include <qlineedit.h>
37#include <qmultilineedit.h>
38#include <qpopupmenu.h>
39#include <qscrollview.h>
40#include <qspinbox.h> 30#include <qspinbox.h>
41#include <qtoolbutton.h>
42 31
43#include <opie/otimepicker.h> 32#include <opie/otimepicker.h>
44#include "onoteedit.h" 33#include "onoteedit.h"
45 34
46#include <stdlib.h> 35#include <stdlib.h>
47#include <stdio.h> 36#include <stdio.h>
48 37
49/* 38/*
50 * Constructs a DateEntry which is a child of 'parent', with the 39 * Constructs a DateEntry which is a child of 'parent', with the
51 * name 'name' and widget flags set to 'f' 40 * name 'name' and widget flags set to 'f'
52 * 41 *
53 * The dialog will by default be modeless, unless you set 'modal' to 42 * The dialog will by default be modeless, unless you set 'modal' to
54 * TRUE to construct a modal dialog. 43 * TRUE to construct a modal dialog.
55 */ 44 */
56 45
57DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, 46DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
58 const QDateTime &end, bool whichClock, QWidget* parent, 47 const QDateTime &end, bool whichClock, QWidget* parent,
59 const char* name ) 48 const char* name )
60 : DateEntryBase( parent, name ), 49 : DateEntryBase( parent, name ),
61 ampm( whichClock ), 50 ampm( whichClock ),
62 startWeekOnMonday( startOnMonday ), 51 startWeekOnMonday( startOnMonday ),
63 m_showStart(true) 52 m_showStart(true)
64{ 53{
65 init(); 54 init();
66 setDates(start,end); 55 setDates(start,end);
67 setFocusProxy(comboDescription); 56 setFocusProxy(comboDescription);
68} 57}
69 58
70bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) 59bool DateEntry::eventFilter(QObject *obj, QEvent *ev )
71{ 60{
72 if( ev->type() == QEvent::FocusIn ){ 61 if( ev->type() == QEvent::FocusIn ){
73 if( obj == comboStart ){ 62 if( obj == comboStart ){
74 timePickerStart->setHour(startTime.hour()); 63 timePickerStart->setHour(startTime.hour());
75 timePickerStart->setMinute(startTime.minute()); 64 timePickerStart->setMinute(startTime.minute());
76 TimePickerLabel->setText( tr("Start Time" ) ); 65 TimePickerLabel->setText( tr("Start Time" ) );
77 m_showStart= true; 66 m_showStart= true;
78 }else if( obj == comboEnd ){ 67 }else if( obj == comboEnd ){
79 timePickerStart->setHour(endTime.hour()); 68 timePickerStart->setHour(endTime.hour());
80 timePickerStart->setMinute(endTime.minute()); 69 timePickerStart->setMinute(endTime.minute());
81 TimePickerLabel->setText( tr("End Time") ); 70 TimePickerLabel->setText( tr("End Time") );
82 m_showStart = false; 71 m_showStart = false;
83 } 72 }
84 } else if( ev->type() == QEvent::FocusOut ){ 73 } else if( ev->type() == QEvent::FocusOut ){
85// if( obj == comboEnd ){ 74// if( obj == comboEnd ){
86// QString s; 75// QString s;
87// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); 76// s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute());
88// comboEnd->setText(s); 77// comboEnd->setText(s);
89// } 78// }
90// else if( obj == comboStart ){ 79// else if( obj == comboStart ){
91// QString s; 80// QString s;
92// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); 81// s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute());
93// comboStart->setText(s); 82// comboStart->setText(s);
94// } 83// }
95 } 84 }
96 85
97 return false; 86 return false;
98} 87}
99 88
100static void addOrPick( QComboBox* combo, const QString& t ) 89static void addOrPick( QComboBox* combo, const QString& t )
101{ 90{
102 // Pick an item if one excists 91 // Pick an item if one excists
103 for (int i=0; i<combo->count(); i++) { 92 for (int i=0; i<combo->count(); i++) {
104 if ( combo->text(i) == t ) { 93 if ( combo->text(i) == t ) {
105 combo->setCurrentItem(i); 94 combo->setCurrentItem(i);
106 return; 95 return;
107 } 96 }
108 } 97 }
109 98
110 // Else add one 99 // Else add one
111 combo->insertItem(t); 100 combo->insertItem(t);
112 combo->setCurrentItem(combo->count()-1); 101 combo->setCurrentItem(combo->count()-1);
113} 102}
114 103
115DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, 104DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock,
116 QWidget* parent, const char* name ) 105 QWidget* parent, const char* name )
117 : DateEntryBase( parent, name ), 106 : DateEntryBase( parent, name ),
118 ampm( whichClock ), 107 ampm( whichClock ),
119 startWeekOnMonday( startOnMonday ), 108 startWeekOnMonday( startOnMonday ),
120 m_showStart(true) 109 m_showStart(true)
121 110
122{ 111{
123 init(); 112 init();
124 setDates(event.start(),event.end()); 113 setDates(event.start(),event.end());
125 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); 114 comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") );
126 if(!event.description().isEmpty()) 115 if(!event.description().isEmpty())
127 addOrPick( comboDescription, event.description() ); 116 addOrPick( comboDescription, event.description() );
128 if(!event.location().isEmpty()) 117 if(!event.location().isEmpty())
129 addOrPick( comboLocation, event.location() ); 118 addOrPick( comboLocation, event.location() );
130 checkAlarm->setChecked( event.hasAlarm() ); 119 checkAlarm->setChecked( event.hasAlarm() );
131 checkAllDay->setChecked( event.type() == Event::AllDay ); 120 checkAllDay->setChecked( event.type() == Event::AllDay );
132 if(!event.notes().isEmpty()) noteStr=event.notes(); 121 if(!event.notes().isEmpty()) noteStr=event.notes();
133 else noteStr=""; 122 else noteStr="";
134 spinAlarm->setValue(event.alarmTime()); 123 spinAlarm->setValue(event.alarmTime());
135 if ( event.alarmSound() != Event::Silent ) 124 if ( event.alarmSound() != Event::Silent )
136 comboSound->setCurrentItem( 1 ); 125 comboSound->setCurrentItem( 1 );
137 if ( event.hasRepeat() ) { 126 if ( event.hasRepeat() ) {
138 rp = event.repeatPattern(); 127 rp = event.repeatPattern();
139 cmdRepeat->setText( tr("Repeat...") ); 128 cmdRepeat->setText( tr("Repeat...") );
140 } 129 }
141 setRepeatLabel(); 130 setRepeatLabel();
142} 131}
143 132
144void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) 133void DateEntry::setDates( const QDateTime& s, const QDateTime& e )
145{ 134{
146 startDate = s.date(); 135 startDate = s.date();
147 endDate = e.date(); 136 endDate = e.date();
148 startTime = s.time(); 137 startTime = s.time();
149 endTime = e.time(); 138 endTime = e.time();
150 139
151 startDateChanged( s.date().year(), s.date().month(), s.date().day() ); 140 startDateChanged( s.date().year(), s.date().month(), s.date().day() );
152 endDateChanged( e.date().year(), e.date().month(), e.date().day() ); 141 endDateChanged( e.date().year(), e.date().month(), e.date().day() );
153 142
154 updateTimeEdit(true,true); 143 updateTimeEdit(true,true);
155} 144}
156 145
157void DateEntry::updateTimeEdit(bool s, bool e) { 146void DateEntry::updateTimeEdit(bool s, bool e) {
158 147
159 // Comboboxes 148 // Comboboxes
160 QString strStart, strEnd; 149 QString strStart, strEnd;
161 int shour, ehour; 150 int shour, ehour;
162 if ( ampm ) { 151 if ( ampm ) {
163 shour = startTime.hour(); 152 shour = startTime.hour();
164 ehour = endTime.hour(); 153 ehour = endTime.hour();
165 if ( shour >= 12 ) { 154 if ( shour >= 12 ) {
166 if ( shour > 12 ) 155 if ( shour > 12 )
167 shour -= 12; 156 shour -= 12;
168 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); 157 strStart.sprintf( "%d:%02d PM", shour, startTime.minute() );
169 } else { 158 } else {
170 if ( shour == 0 ) 159 if ( shour == 0 )
171 shour = 12; 160 shour = 12;
172 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); 161 strStart.sprintf( "%d:%02d AM", shour, startTime.minute() );
173 } 162 }
174 if ( ehour == 24 && endTime.minute() == 0 ) { 163 if ( ehour == 24 && endTime.minute() == 0 ) {
175 strEnd = "11:59 PM"; // or "midnight" 164 strEnd = "11:59 PM"; // or "midnight"
176 } else if ( ehour >= 12 ) { 165 } else if ( ehour >= 12 ) {
177 if ( ehour > 12 ) 166 if ( ehour > 12 )
178 ehour -= 12; 167 ehour -= 12;
179 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); 168 strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() );
180 } else { 169 } else {
181 if ( ehour == 0 ) 170 if ( ehour == 0 )
182 ehour = 12; 171 ehour = 12;
183 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); 172 strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() );
184 } 173 }
185 } else { 174 } else {
186 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); 175 strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() );
187 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); 176 strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() );
188 } 177 }
189 178
190 if (s) comboStart->setText(strStart); 179 if (s) comboStart->setText(strStart);
191 if (e) comboEnd->setText(strEnd); 180 if (e) comboEnd->setText(strEnd);
192} 181}
193 182
194void DateEntry::init() 183void DateEntry::init()
195{ 184{
196 comboDescription->setInsertionPolicy(QComboBox::AtCurrent); 185 comboDescription->setInsertionPolicy(QComboBox::AtCurrent);
197 comboLocation->setInsertionPolicy(QComboBox::AtCurrent); 186 comboLocation->setInsertionPolicy(QComboBox::AtCurrent);
198 187
199 initCombos(); 188 initCombos();
200 QPopupMenu *m1 = new QPopupMenu( this ); 189 QPopupMenu *m1 = new QPopupMenu( this );
201 startPicker = new DateBookMonth( m1, 0, TRUE ); 190 startPicker = new DateBookMonth( m1, 0, TRUE );
202 m1->insertItem( startPicker ); 191 m1->insertItem( startPicker );
203 buttonStart->setPopup( m1 ); 192 buttonStart->setPopup( m1 );
204 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 193 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
205 this, SLOT( startDateChanged( int, int, int ) ) ); 194 this, SLOT( startDateChanged( int, int, int ) ) );
206 195
207 //Let start button change both start and end dates 196 //Let start button change both start and end dates
208 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), 197 connect( startPicker, SIGNAL( dateClicked( int, int, int ) ),
209 this, SLOT( endDateChanged( int, int, int ) ) ); 198 this, SLOT( endDateChanged( int, int, int ) ) );
210 connect( qApp, SIGNAL( clockChanged( bool ) ), 199 connect( qApp, SIGNAL( clockChanged( bool ) ),
211 this, SLOT( slotChangeClock( bool ) ) ); 200 this, SLOT( slotChangeClock( bool ) ) );
212 connect( qApp, SIGNAL(weekChanged(bool)), 201 connect( qApp, SIGNAL(weekChanged(bool)),
213 this, SLOT(slotChangeStartOfWeek(bool)) ); 202 this, SLOT(slotChangeStartOfWeek(bool)) );
214 203
215 connect( editNote, SIGNAL(clicked()), 204 connect( editNote, SIGNAL(clicked()),
216 this, SLOT(slotEditNote()) ); 205 this, SLOT(slotEditNote()) );
217 206
218 QPopupMenu *m2 = new QPopupMenu( this ); 207 QPopupMenu *m2 = new QPopupMenu( this );
219 endPicker = new DateBookMonth( m2, 0, TRUE ); 208 endPicker = new DateBookMonth( m2, 0, TRUE );
220 m2->insertItem( endPicker ); 209 m2->insertItem( endPicker );
221 buttonEnd->setPopup( m2 ); 210 buttonEnd->setPopup( m2 );
222 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), 211 connect( endPicker, SIGNAL( dateClicked( int, int, int ) ),
223 this, SLOT( endDateChanged( int, int, int ) ) ); 212 this, SLOT( endDateChanged( int, int, int ) ) );
224 213
225 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), 214 connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ),
226 this, SLOT( startTimePicked(const QTime &) )); 215 this, SLOT( startTimePicked(const QTime &) ));
227 // install eventFilters 216 // install eventFilters
228 comboEnd->installEventFilter( this ); 217 comboEnd->installEventFilter( this );
229 comboStart->installEventFilter( this ); 218 comboStart->installEventFilter( this );
230} 219}
231 220
232/* 221/*
233 * Destroys the object and frees any allocated resources 222 * Destroys the object and frees any allocated resources
234 */ 223 */
235DateEntry::~DateEntry() 224DateEntry::~DateEntry()
236{ 225{
237 // 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
238 //cout << "Del: " << comboStart->currentText() << endl; 227 //cout << "Del: " << comboStart->currentText() << endl;
239} 228}
240 229
241/* 230/*
242 * public slot 231 * public slot
243 */ 232 */
244 233
245void DateEntry::slotEditNote() { 234void DateEntry::slotEditNote() {
246 QString s; 235 QString s;
247 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>"; 236 s = "<B>"+ TimeString::longDateString( startDate ) + "</B>";
248// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); 237// s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month());
249 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, 238 NoteEntry noteDlg(s+comboDescription->currentText(), noteStr,
250 this,0,TRUE); 239 this,0,TRUE);
251 240
252 if ( QPEApplication::execDialog( &noteDlg ) ) { 241 if ( QPEApplication::execDialog( &noteDlg ) ) {
253 noteStr=noteDlg.note->text(); 242 noteStr=noteDlg.note->text();
254 } 243 }
255 244
256} 245}
257 246
258void DateEntry::endDateChanged( int y, int m, int d ) 247void DateEntry::endDateChanged( int y, int m, int d )
259{ 248{
260 endDate.setYMD( y, m, d ); 249 endDate.setYMD( y, m, d );
261 if ( endDate < startDate ) { 250 if ( endDate < startDate ) {
262 endDate = startDate; 251 endDate = startDate;
263 } 252 }
264 253
265 buttonEnd->setText( TimeString::shortDate( endDate ) ); 254 buttonEnd->setText( TimeString::shortDate( endDate ) );
266 255
267 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); 256 endPicker->setDate( endDate.year(), endDate.month(), endDate.day() );
268} 257}
269 258
270static QTime parseTime( const QString& s, bool ampm ) 259static QTime parseTime( const QString& s, bool ampm )
271{ 260{
272 QTime tmpTime; 261 QTime tmpTime;
273 QStringList l = QStringList::split( ':', s ); 262 QStringList l = QStringList::split( ':', s );
274 int hour = l[0].toInt(); 263 int hour = l[0].toInt();
275 if ( ampm ) { 264 if ( ampm ) {
276 int i=0; 265 int i=0;
277 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')
278 i++; 267 i++;
279 QString digits = l[1].left(i); 268 QString digits = l[1].left(i);
280 if ( l[1].contains( "PM", FALSE ) ) { 269 if ( l[1].contains( "PM", FALSE ) ) {
281 if ( hour != 12 ) 270 if ( hour != 12 )
282 hour += 12; 271 hour += 12;
283 } else { 272 } else {
284 if ( hour == 12 ) 273 if ( hour == 12 )
285 hour = 0; 274 hour = 0;
286 } 275 }
287 l[1] = digits; 276 l[1] = digits;
288 } 277 }
289 int minute = l[1].toInt(); 278 int minute = l[1].toInt();
290 if ( minute > 59 ) 279 if ( minute > 59 )
291 minute = 59; 280 minute = 59;
292 else if ( minute < 0 ) 281 else if ( minute < 0 )
293 minute = 0; 282 minute = 0;
294 if ( hour > 23 ) { 283 if ( hour > 23 ) {
295 hour = 23; 284 hour = 23;
296 minute = 59; 285 minute = 59;
297 } else if ( hour < 0 ) 286 } else if ( hour < 0 )
298 hour = 0; 287 hour = 0;
299 tmpTime.setHMS( hour, minute, 0 ); 288 tmpTime.setHMS( hour, minute, 0 );
300 return tmpTime; 289 return tmpTime;
301} 290}
302 291
303/* 292/*
304 * public slot 293 * public slot
305 */ 294 */
306void DateEntry::endTimeChanged( const QString &s ) 295void DateEntry::endTimeChanged( const QString &s )
307{ 296{
308 endTimeChanged( parseTime(s,ampm) ); 297 endTimeChanged( parseTime(s,ampm) );
309} 298}
310 299
311void DateEntry::endTimeChanged( const QTime &t ) { 300void DateEntry::endTimeChanged( const QTime &t ) {
312 if ( endDate > startDate || t >= startTime ) { 301 if ( endDate > startDate || t >= startTime ) {
313 endTime = t; 302 endTime = t;
314 } else { 303 } else {
315 endTime = startTime; 304 endTime = startTime;
316 //comboEnd->setCurrentItem( comboStart->currentItem() ); 305 //comboEnd->setCurrentItem( comboStart->currentItem() );
317 } 306 }
318 timePickerStart->setHour(endTime.hour()); 307 timePickerStart->setHour(endTime.hour());
319 timePickerStart->setMinute(endTime.minute()); 308 timePickerStart->setMinute(endTime.minute());
320} 309}
321 310
322/* 311/*
323 * public slot 312 * public slot
324 */ 313 */
325void DateEntry::startDateChanged( int y, int m, int d ) 314void DateEntry::startDateChanged( int y, int m, int d )
326{ 315{
327 QDate prev = startDate; 316 QDate prev = startDate;
328 startDate.setYMD( y, m, d ); 317 startDate.setYMD( y, m, d );
329 if ( rp.type == Event::Weekly && 318 if ( rp.type == Event::Weekly &&
330 startDate.dayOfWeek() != prev.dayOfWeek() ) { 319 startDate.dayOfWeek() != prev.dayOfWeek() ) {
331 // if we change the start of a weekly repeating event 320 // if we change the start of a weekly repeating event
332 // set the repeating day appropriately 321 // set the repeating day appropriately
333 char mask = 1 << (prev.dayOfWeek()-1); 322 char mask = 1 << (prev.dayOfWeek()-1);
334 rp.days &= (~mask); 323 rp.days &= (~mask);
335 rp.days |= 1 << (startDate.dayOfWeek()-1); 324 rp.days |= 1 << (startDate.dayOfWeek()-1);
336 } 325 }
337 326
338 buttonStart->setText( TimeString::shortDate( startDate ) ); 327 buttonStart->setText( TimeString::shortDate( startDate ) );
339 328
340 // our pickers must be reset... 329 // our pickers must be reset...
341 startPicker->setDate( y, m, d ); 330 startPicker->setDate( y, m, d );
342 endPicker->setDate( y, m, d ); 331 endPicker->setDate( y, m, d );
343} 332}
344 333
345/* 334/*
346 * public slot 335 * public slot
347 */ 336 */
348void DateEntry::startTimeEdited( const QString &s ) 337void DateEntry::startTimeEdited( const QString &s )
349{ 338{
350 startTimeChanged(parseTime(s,ampm)); 339 startTimeChanged(parseTime(s,ampm));
351 updateTimeEdit(false,true); 340 updateTimeEdit(false,true);
352 timePickerStart->setHour(startTime.hour()); 341 timePickerStart->setHour(startTime.hour());
353 timePickerStart->setMinute(startTime.minute()); 342 timePickerStart->setMinute(startTime.minute());
354} 343}
355 344
356void DateEntry::startTimeChanged( const QTime &t ) 345void DateEntry::startTimeChanged( const QTime &t )
357{ 346{
358 int duration=startTime.secsTo(endTime); 347 int duration=startTime.secsTo(endTime);
359 startTime = t; 348 startTime = t;
360 endTime=t.addSecs(duration); 349 endTime=t.addSecs(duration);
361} 350}
362void DateEntry::startTimePicked( const QTime &t ) { 351void DateEntry::startTimePicked( const QTime &t ) {
363 if(m_showStart ){ 352 if(m_showStart ){
364 startTimeChanged(t); 353 startTimeChanged(t);
365 updateTimeEdit(true,true); 354 updateTimeEdit(true,true);
366 }else{ 355 }else{
367 endTimeChanged(t); 356 endTimeChanged(t);
368 updateTimeEdit(false, true ); 357 updateTimeEdit(false, true );
369 } 358 }
370} 359}
371 360
372/* 361/*
373 * public slot 362 * public slot
374 */ 363 */
375void DateEntry::typeChanged( const QString &s ) 364void DateEntry::typeChanged( const QString &s )
376{ 365{
377 bool b = s != "All Day"; 366 bool b = s != "All Day";
378 buttonStart->setEnabled( b ); 367 buttonStart->setEnabled( b );
379 comboStart->setEnabled( b ); 368 comboStart->setEnabled( b );
380 comboEnd->setEnabled( b ); 369 comboEnd->setEnabled( b );
381} 370}
382 371
383void DateEntry::slotRepeat() 372void DateEntry::slotRepeat()
384{ 373{
385 // Work around for compiler Bug.. 374 // Work around for compiler Bug..
386 RepeatEntry *e; 375 RepeatEntry *e;
387 376
388 // it is better in my opinion to just grab this from the mother, 377 // it is better in my opinion to just grab this from the mother,
389 // since, this dialog doesn't need to keep track of it... 378 // since, this dialog doesn't need to keep track of it...
390 if ( rp.type != Event::NoRepeat ) 379 if ( rp.type != Event::NoRepeat )
391 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this); 380 e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
392 else 381 else
393 e = new RepeatEntry( startWeekOnMonday, startDate, this ); 382 e = new RepeatEntry( startWeekOnMonday, startDate, this );
394 383
395 if ( QPEApplication::execDialog( e ) ) { 384 if ( QPEApplication::execDialog( e ) ) {
396 rp = e->repeatPattern(); 385 rp = e->repeatPattern();
397 setRepeatLabel(); 386 setRepeatLabel();
398 } 387 }
399 // deleting sounds like a nice idea... 388 // deleting sounds like a nice idea...
400 delete e; 389 delete e;
401} 390}
402 391
403void DateEntry::slotChangeStartOfWeek( bool onMonday ) 392void DateEntry::slotChangeStartOfWeek( bool onMonday )
404{ 393{
405 startWeekOnMonday = onMonday; 394 startWeekOnMonday = onMonday;
406} 395}
407 396
408Event DateEntry::event() 397Event DateEntry::event()
409{ 398{
410 Event ev; 399 Event ev;
411 Event::SoundTypeChoice st; 400 Event::SoundTypeChoice st;
412 ev.setDescription( comboDescription->currentText() ); 401 ev.setDescription( comboDescription->currentText() );
413 ev.setLocation( comboLocation->currentText() ); 402 ev.setLocation( comboLocation->currentText() );
414 ev.setCategories( comboCategory->currentCategories() ); 403 ev.setCategories( comboCategory->currentCategories() );
415 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal ); 404 ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
416 if ( startDate > endDate ) { 405 if ( startDate > endDate ) {
417 QDate tmp = endDate; 406 QDate tmp = endDate;
418 endDate = startDate; 407 endDate = startDate;
419 startDate = tmp; 408 startDate = tmp;
420 } 409 }
421 410
422 // This is now done in the changed slots 411 // This is now done in the changed slots
423 // startTime = parseTime( comboStart->text(), ampm ); 412 // startTime = parseTime( comboStart->text(), ampm );
424 //endTime = parseTime( comboEnd->text(), ampm ); 413 //endTime = parseTime( comboEnd->text(), ampm );
425 414
426 if ( startTime > endTime && endDate == startDate ) { 415 if ( startTime > endTime && endDate == startDate ) {
427 QTime tmp = endTime; 416 QTime tmp = endTime;
428 endTime = startTime; 417 endTime = startTime;
429 startTime = tmp; 418 startTime = tmp;
430 } 419 }
431 // don't set the time if theres no need too 420 // don't set the time if theres no need too
432 if ( ev.type() == Event::AllDay ) { 421 if ( ev.type() == Event::AllDay ) {
433 startTime.setHMS( 0, 0, 0 ); 422 startTime.setHMS( 0, 0, 0 );
434 endTime.setHMS( 23, 59, 59 ); 423 endTime.setHMS( 23, 59, 59 );
435 } 424 }
436 425
437 // adjust start and end times based on timezone 426 // adjust start and end times based on timezone
438 QDateTime start( startDate, startTime ); 427 QDateTime start( startDate, startTime );
439 QDateTime end( endDate, endTime ); 428 QDateTime end( endDate, endTime );
440 time_t start_utc, end_utc; 429 time_t start_utc, end_utc;
441 430
442// qDebug( "tz: %s", timezone->currentZone().latin1() ); 431// qDebug( "tz: %s", timezone->currentZone().latin1() );
443 432
444 // get real timezone 433 // get real timezone
445 QString realTZ; 434 QString realTZ;
446 realTZ = QString::fromLocal8Bit( getenv("TZ") ); 435 realTZ = QString::fromLocal8Bit( getenv("TZ") );
447 436
448 // set timezone 437 // set timezone
449 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 ) 438 if ( setenv( "TZ", timezone->currentZone(), true ) != 0 )
450 qWarning( "There was a problem setting the timezone." ); 439 qWarning( "There was a problem setting the timezone." );
451 440
452 // convert to UTC based on selected TZ (calling tzset internally) 441 // convert to UTC based on selected TZ (calling tzset internally)
453 start_utc = TimeConversion::toUTC( start ); 442 start_utc = TimeConversion::toUTC( start );
454 end_utc = TimeConversion::toUTC( end ); 443 end_utc = TimeConversion::toUTC( end );
455 444
456 // done playing around... put it all back 445 // done playing around... put it all back
457 unsetenv( "TZ" ); 446 unsetenv( "TZ" );
458 if ( !realTZ.isNull() ) 447 if ( !realTZ.isNull() )
459 if ( setenv( "TZ", realTZ, true ) != 0 ) 448 if ( setenv( "TZ", realTZ, true ) != 0 )
460 qWarning( "There was a problem setting the timezone." ); 449 qWarning( "There was a problem setting the timezone." );
461 450
462 // convert UTC to local time (calling tzset internally) 451 // convert UTC to local time (calling tzset internally)
463 ev.setStart( TimeConversion::fromUTC( start_utc ) ); 452 ev.setStart( TimeConversion::fromUTC( start_utc ) );
464 ev.setEnd( TimeConversion::fromUTC( end_utc ) ); 453 ev.setEnd( TimeConversion::fromUTC( end_utc ) );
465 454
466 // we only have one type of sound at the moment... LOUD!!! 455 // we only have one type of sound at the moment... LOUD!!!
467 if ( comboSound->currentItem() != 0 ) 456 if ( comboSound->currentItem() != 0 )
468 st = Event::Loud; 457 st = Event::Loud;
469 else 458 else
470 st = Event::Silent; 459 st = Event::Silent;
471 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st ); 460 ev.setAlarm( checkAlarm->isChecked(), spinAlarm->value(), st );
472 if ( rp.type != Event::NoRepeat ) 461 if ( rp.type != Event::NoRepeat )
473 ev.setRepeat( TRUE, rp ); 462 ev.setRepeat( TRUE, rp );
474 ev.setNotes( noteStr ); 463 ev.setNotes( noteStr );
475 464
476 //cout << "Start: " << comboStart->currentText() << endl; 465 //cout << "Start: " << comboStart->currentText() << endl;
477 466
478 return ev; 467 return ev;
479} 468}
480 469
481void DateEntry::setRepeatLabel() 470void DateEntry::setRepeatLabel()
482{ 471{
483 472
484 switch( rp.type ) { 473 switch( rp.type ) {
485 case Event::Daily: 474 case Event::Daily:
486 cmdRepeat->setText( tr("Daily...") ); 475 cmdRepeat->setText( tr("Daily...") );
487 break; 476 break;
488 case Event::Weekly: 477 case Event::Weekly:
489 cmdRepeat->setText( tr("Weekly...") ); 478 cmdRepeat->setText( tr("Weekly...") );
490 break; 479 break;
491 case Event::MonthlyDay: 480 case Event::MonthlyDay:
492 case Event::MonthlyDate: 481 case Event::MonthlyDate:
493 cmdRepeat->setText( tr("Monthly...") ); 482 cmdRepeat->setText( tr("Monthly...") );
494 break; 483 break;
495 case Event::Yearly: 484 case Event::Yearly:
496 cmdRepeat->setText( tr("Yearly...") ); 485 cmdRepeat->setText( tr("Yearly...") );
497 break; 486 break;
498 default: 487 default:
499 cmdRepeat->setText( tr("No Repeat...") ); 488 cmdRepeat->setText( tr("No Repeat...") );
500 } 489 }
501} 490}
502 491
503void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound ) 492void DateEntry::setAlarmEnabled( bool alarmPreset, int presetTime, Event::SoundTypeChoice sound )
504{ 493{
505 checkAlarm->setChecked( alarmPreset ); 494 checkAlarm->setChecked( alarmPreset );
506 spinAlarm->setValue( presetTime ); 495 spinAlarm->setValue( presetTime );
507 if ( sound != Event::Silent ) 496 if ( sound != Event::Silent )
508 comboSound->setCurrentItem( 1 ); 497 comboSound->setCurrentItem( 1 );
509 else 498 else
510 comboSound->setCurrentItem( 0 ); 499 comboSound->setCurrentItem( 0 );
511} 500}
512 501
513void DateEntry::initCombos() 502void DateEntry::initCombos()
514{ 503{
515 /* 504 /*
516 comboStart->clear(); 505 comboStart->clear();
517 comboEnd->clear(); 506 comboEnd->clear();
518 if ( ampm ) { 507 if ( ampm ) {
519 for ( int i = 0; i < 24; i++ ) { 508 for ( int i = 0; i < 24; i++ ) {
520 if ( i == 0 ) { 509 if ( i == 0 ) {
521 comboStart->insertItem( "12:00 AM" ); 510 comboStart->insertItem( "12:00 AM" );
522 comboStart->insertItem( "12:30 AM" ); 511 comboStart->insertItem( "12:30 AM" );
523 comboEnd->insertItem( "12:00 AM" ); 512 comboEnd->insertItem( "12:00 AM" );
524 comboEnd->insertItem( "12:30 AM" ); 513 comboEnd->insertItem( "12:30 AM" );
525 } else if ( i == 12 ) { 514 } else if ( i == 12 ) {
526 comboStart->insertItem( "12:00 PM" ); 515 comboStart->insertItem( "12:00 PM" );
527 comboStart->insertItem( "12:30 PM" ); 516 comboStart->insertItem( "12:30 PM" );
528 comboEnd->insertItem( "12:00 PM" ); 517 comboEnd->insertItem( "12:00 PM" );
529 comboEnd->insertItem( "12:30 PM" ); 518 comboEnd->insertItem( "12:30 PM" );
530 } else if ( i > 12 ) { 519 } else if ( i > 12 ) {
531 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" ); 520 comboStart->insertItem( QString::number( i - 12 ) + ":00 PM" );
532 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" ); 521 comboStart->insertItem( QString::number( i - 12 ) + ":30 PM" );
533 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" ); 522 comboEnd->insertItem( QString::number( i - 12 ) + ":00 PM" );
534 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" ); 523 comboEnd->insertItem( QString::number( i - 12 ) + ":30 PM" );
535 } else { 524 } else {
536 comboStart->insertItem( QString::number( i) + ":00 AM" ); 525 comboStart->insertItem( QString::number( i) + ":00 AM" );
537 comboStart->insertItem( QString::number( i ) + ":30 AM" ); 526 comboStart->insertItem( QString::number( i ) + ":30 AM" );
538 comboEnd->insertItem( QString::number( i ) + ":00 AM" ); 527 comboEnd->insertItem( QString::number( i ) + ":00 AM" );
539 comboEnd->insertItem( QString::number( i ) + ":30 AM" ); 528 comboEnd->insertItem( QString::number( i ) + ":30 AM" );
540 } 529 }
541 } 530 }
542 } else { 531 } else {
543 for ( int i = 0; i < 24; i++ ) { 532 for ( int i = 0; i < 24; i++ ) {
544 if ( i < 10 ) { 533 if ( i < 10 ) {
545 comboStart->insertItem( QString("0") 534 comboStart->insertItem( QString("0")
546 + QString::number(i) + ":00" ); 535 + QString::number(i) + ":00" );
547 comboStart->insertItem( QString("0") 536 comboStart->insertItem( QString("0")
548 + QString::number(i) + ":30" ); 537 + QString::number(i) + ":30" );
549 comboEnd->insertItem( QString("0") 538 comboEnd->insertItem( QString("0")
550 + QString::number(i) + ":00" ); 539 + QString::number(i) + ":00" );
551 comboEnd->insertItem( QString("0") 540 comboEnd->insertItem( QString("0")
552 + QString::number(i) + ":30" ); 541 + QString::number(i) + ":30" );
553 } else { 542 } else {
554 comboStart->insertItem( QString::number(i) + ":00" ); 543 comboStart->insertItem( QString::number(i) + ":00" );
555 comboStart->insertItem( QString::number(i) + ":30" ); 544 comboStart->insertItem( QString::number(i) + ":30" );
556 comboEnd->insertItem( QString::number(i) + ":00" ); 545 comboEnd->insertItem( QString::number(i) + ":00" );
557 comboEnd->insertItem( QString::number(i) + ":30" ); 546 comboEnd->insertItem( QString::number(i) + ":30" );
558 } 547 }
559 } 548 }
560 } 549 }
561 */ 550 */
562} 551}
563 552
564void DateEntry::slotChangeClock( bool whichClock ) 553void DateEntry::slotChangeClock( bool whichClock )
565{ 554{
566 ampm = whichClock; 555 ampm = whichClock;
567 initCombos(); 556 initCombos();
568 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) ); 557 setDates( QDateTime( startDate, startTime ), QDateTime( endDate, endTime ) );
569} 558}
570 559
diff --git a/core/pim/datebook/main.cpp b/core/pim/datebook/main.cpp
index 8004690..421e457 100644
--- a/core/pim/datebook/main.cpp
+++ b/core/pim/datebook/main.cpp
@@ -1,25 +1,24 @@
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 "datebook.h" 21#include "datebook.h"
22#include <qpe/qpeapplication.h>
23#include <opie/oapplicationfactory.h> 22#include <opie/oapplicationfactory.h>
24 23
25OPIE_EXPORT_APP( OApplicationFactory<DateBook> ) 24OPIE_EXPORT_APP( OApplicationFactory<DateBook> )
diff --git a/core/pim/datebook/noteentryimpl.cpp b/core/pim/datebook/noteentryimpl.cpp
index 0e45985..14fe98e 100644
--- a/core/pim/datebook/noteentryimpl.cpp
+++ b/core/pim/datebook/noteentryimpl.cpp
@@ -1,17 +1,15 @@
1#include "noteentryimpl.h" 1#include "noteentryimpl.h"
2#include "qstring.h"
3#include "qmultilinedit.h"
4#include "qlabel.h" 2#include "qlabel.h"
5#include "onoteedit.h" 3#include "onoteedit.h"
6 4
7NoteEntry::NoteEntry(const QString &title, const QString &noteStr, 5NoteEntry::NoteEntry(const QString &title, const QString &noteStr,
8 QWidget* parent, const char* name, bool modal, 6 QWidget* parent, const char* name, bool modal,
9 WFlags fl) : 7 WFlags fl) :
10 NoteEntryBase(parent, name, modal, fl) { 8 NoteEntryBase(parent, name, modal, fl) {
11 9
12 10
13 eventLabel->setText(title); 11 eventLabel->setText(title);
14 note->setText(noteStr); 12 note->setText(noteStr);
15 int l=note->length(); 13 int l=note->length();
16 note->setCursorPosition(l,l,false); 14 note->setCursorPosition(l,l,false);
17} 15}
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp
index b1a162d..7cf36da 100644
--- a/core/pim/datebook/repeatentry.cpp
+++ b/core/pim/datebook/repeatentry.cpp
@@ -1,617 +1,613 @@
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 "repeatentry.h" 21#include "repeatentry.h"
22 22
23#include <qpe/datebookmonth.h> 23#include <qpe/datebookmonth.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/timestring.h>
26 25
27#include <qbuttongroup.h>
28#include <qlabel.h> 26#include <qlabel.h>
29#include <qpopupmenu.h>
30#include <qspinbox.h> 27#include <qspinbox.h>
31#include <qtoolbutton.h>
32 28
33#include <time.h> 29#include <time.h>
34 30
35// Global Templates for use in setting up the repeat label... 31// Global Templates for use in setting up the repeat label...
36// the problem is these strings get initialized before QPEApplication can install the translator -zecke 32// the problem is these strings get initialized before QPEApplication can install the translator -zecke
37namespace { 33namespace {
38QString strDayTemplate; 34QString strDayTemplate;
39QString strYearTemplate; 35QString strYearTemplate;
40QString strMonthDateTemplate; 36QString strMonthDateTemplate;
41QString strMonthDayTemplate; 37QString strMonthDayTemplate;
42QString strWeekTemplate; 38QString strWeekTemplate;
43QString dayLabel[7]; 39QString dayLabel[7];
44} 40}
45 41
46/* 42/*
47 * static linkage to not polute the symbol table... 43 * static linkage to not polute the symbol table...
48 * The problem is that const and static linkage are resolved prior to installing a translator 44 * The problem is that const and static linkage are resolved prior to installing a translator
49 * leading to that the above strings are translted but to the original we delay the init of these strings... 45 * leading to that the above strings are translted but to the original we delay the init of these strings...
50 * -zecke 46 * -zecke
51 */ 47 */
52static void fillStrings() { 48static void fillStrings() {
53 strDayTemplate = QObject::tr("Every"); 49 strDayTemplate = QObject::tr("Every");
54 strYearTemplate = QObject::tr("%1 %2 every "); 50 strYearTemplate = QObject::tr("%1 %2 every ");
55 strMonthDateTemplate = QObject::tr("The %1 every "); 51 strMonthDateTemplate = QObject::tr("The %1 every ");
56 strMonthDayTemplate = QObject::tr("The %1 %1 of every"); 52 strMonthDayTemplate = QObject::tr("The %1 %1 of every");
57 strWeekTemplate = QObject::tr("Every "); 53 strWeekTemplate = QObject::tr("Every ");
58 dayLabel[0] = QObject::tr("Monday"); 54 dayLabel[0] = QObject::tr("Monday");
59 dayLabel[1] = QObject::tr("Tuesday"); 55 dayLabel[1] = QObject::tr("Tuesday");
60 dayLabel[2] = QObject::tr("Wednesday"); 56 dayLabel[2] = QObject::tr("Wednesday");
61 dayLabel[3] = QObject::tr("Thursday"); 57 dayLabel[3] = QObject::tr("Thursday");
62 dayLabel[4] = QObject::tr("Friday"); 58 dayLabel[4] = QObject::tr("Friday");
63 dayLabel[5] = QObject::tr("Saturday"); 59 dayLabel[5] = QObject::tr("Saturday");
64 dayLabel[6] = QObject::tr("Sunday"); 60 dayLabel[6] = QObject::tr("Sunday");
65} 61}
66 62
67 static QString numberPlacing( int x );// return the proper word format for 63 static QString numberPlacing( int x );// return the proper word format for
68 // x (1st, 2nd, etc) 64 // x (1st, 2nd, etc)
69static int week( const QDate &dt ); // what week in the month is dt? 65static int week( const QDate &dt ); // what week in the month is dt?
70 66
71RepeatEntry::RepeatEntry( bool startOnMonday, 67RepeatEntry::RepeatEntry( bool startOnMonday,
72 const QDate &newStart, QWidget *parent, 68 const QDate &newStart, QWidget *parent,
73 const char *name, bool modal, WFlags fl ) 69 const char *name, bool modal, WFlags fl )
74 : RepeatEntryBase( parent, name, modal, fl ), 70 : RepeatEntryBase( parent, name, modal, fl ),
75 start( newStart ), 71 start( newStart ),
76 currInterval( NONE ), 72 currInterval( NONE ),
77 startWeekOnMonday( startOnMonday ) 73 startWeekOnMonday( startOnMonday )
78{ 74{
79 if (strDayTemplate.isEmpty() ) 75 if (strDayTemplate.isEmpty() )
80 fillStrings(); 76 fillStrings();
81 77
82 init(); 78 init();
83 fraType->setButton( currInterval ); 79 fraType->setButton( currInterval );
84 chkNoEnd->setChecked( TRUE ); 80 chkNoEnd->setChecked( TRUE );
85 setupNone(); 81 setupNone();
86} 82}
87 83
88RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, 84RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp,
89 const QDate &startDate, 85 const QDate &startDate,
90 QWidget *parent, const char *name, bool modal, 86 QWidget *parent, const char *name, bool modal,
91 WFlags fl ) 87 WFlags fl )
92 : RepeatEntryBase( parent, name, modal, fl ), 88 : RepeatEntryBase( parent, name, modal, fl ),
93 start( startDate ), 89 start( startDate ),
94 end( rp.endDate() ), 90 end( rp.endDate() ),
95 startWeekOnMonday( startOnMonday ) 91 startWeekOnMonday( startOnMonday )
96{ 92{
97 if (strDayTemplate.isEmpty() ) 93 if (strDayTemplate.isEmpty() )
98 fillStrings(); 94 fillStrings();
99 // do some stuff with the repeat pattern 95 // do some stuff with the repeat pattern
100 init(); 96 init();
101 switch ( rp.type ) { 97 switch ( rp.type ) {
102 default: 98 default:
103 case Event::NoRepeat: 99 case Event::NoRepeat:
104 currInterval = NONE; 100 currInterval = NONE;
105 setupNone(); 101 setupNone();
106 break; 102 break;
107 case Event::Daily: 103 case Event::Daily:
108 currInterval = DAY; 104 currInterval = DAY;
109 setupDaily(); 105 setupDaily();
110 break; 106 break;
111 case Event::Weekly: 107 case Event::Weekly:
112 currInterval = WEEK; 108 currInterval = WEEK;
113 setupWeekly(); 109 setupWeekly();
114 int day, buttons; 110 int day, buttons;
115 for ( day = 0x01, buttons = 0; buttons < 7; 111 for ( day = 0x01, buttons = 0; buttons < 7;
116 day = day << 1, buttons++ ) { 112 day = day << 1, buttons++ ) {
117 if ( rp.days & day ) { 113 if ( rp.days & day ) {
118 if ( startWeekOnMonday ) 114 if ( startWeekOnMonday )
119 fraExtra->setButton( buttons ); 115 fraExtra->setButton( buttons );
120 else { 116 else {
121 if ( buttons == 7 ) 117 if ( buttons == 7 )
122 fraExtra->setButton( 0 ); 118 fraExtra->setButton( 0 );
123 else 119 else
124 fraExtra->setButton( buttons + 1 ); 120 fraExtra->setButton( buttons + 1 );
125 } 121 }
126 } 122 }
127 } 123 }
128 slotWeekLabel(); 124 slotWeekLabel();
129 break; 125 break;
130 case Event::MonthlyDay: 126 case Event::MonthlyDay:
131 currInterval = MONTH; 127 currInterval = MONTH;
132 setupMonthly(); 128 setupMonthly();
133 fraExtra->setButton( 0 ); 129 fraExtra->setButton( 0 );
134 slotMonthLabel( 0 ); 130 slotMonthLabel( 0 );
135 break; 131 break;
136 case Event::MonthlyDate: 132 case Event::MonthlyDate:
137 currInterval = MONTH; 133 currInterval = MONTH;
138 setupMonthly(); 134 setupMonthly();
139 fraExtra->setButton( 1 ); 135 fraExtra->setButton( 1 );
140 slotMonthLabel( 1 ); 136 slotMonthLabel( 1 );
141 break; 137 break;
142 case Event::Yearly: 138 case Event::Yearly:
143 currInterval = YEAR; 139 currInterval = YEAR;
144 setupYearly(); 140 setupYearly();
145 break; 141 break;
146 } 142 }
147 fraType->setButton( currInterval ); 143 fraType->setButton( currInterval );
148 spinFreq->setValue( rp.frequency ); 144 spinFreq->setValue( rp.frequency );
149 if ( !rp.hasEndDate ) { 145 if ( !rp.hasEndDate ) {
150 cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); 146 cmdEnd->setText( RepeatEntryBase::tr("No End Date") );
151 chkNoEnd->setChecked( TRUE ); 147 chkNoEnd->setChecked( TRUE );
152 } else 148 } else
153 cmdEnd->setText( TimeString::shortDate( end ) ); 149 cmdEnd->setText( TimeString::shortDate( end ) );
154} 150}
155 151
156RepeatEntry::~RepeatEntry() 152RepeatEntry::~RepeatEntry()
157{ 153{
158} 154}
159 155
160Event::RepeatPattern RepeatEntry::repeatPattern() 156Event::RepeatPattern RepeatEntry::repeatPattern()
161{ 157{
162 QListIterator<QToolButton> it( listRTypeButtons ); 158 QListIterator<QToolButton> it( listRTypeButtons );
163 QListIterator<QToolButton> itExtra( listExtra ); 159 QListIterator<QToolButton> itExtra( listExtra );
164 Event::RepeatPattern rpTmp; 160 Event::RepeatPattern rpTmp;
165 int i; 161 int i;
166 for ( i = 0; *it; ++it, i++ ) { 162 for ( i = 0; *it; ++it, i++ ) {
167 if ( (*it)->isOn() ) { 163 if ( (*it)->isOn() ) {
168 switch ( i ) { 164 switch ( i ) {
169 case NONE: 165 case NONE:
170 rpTmp.type = Event::NoRepeat; 166 rpTmp.type = Event::NoRepeat;
171 break; 167 break;
172 case DAY: 168 case DAY:
173 rpTmp.type = Event::Daily; 169 rpTmp.type = Event::Daily;
174 break; 170 break;
175 case WEEK: 171 case WEEK:
176 rpTmp.type = Event::Weekly; 172 rpTmp.type = Event::Weekly;
177 rpTmp.days = 0; 173 rpTmp.days = 0;
178 int day; 174 int day;
179 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 175 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
180 if ( (*itExtra)->isOn() ) { 176 if ( (*itExtra)->isOn() ) {
181 if ( startWeekOnMonday ) 177 if ( startWeekOnMonday )
182 rpTmp.days |= day; 178 rpTmp.days |= day;
183 else { 179 else {
184 if ( day == 1 ) 180 if ( day == 1 )
185 rpTmp.days |= Event::SUN; 181 rpTmp.days |= Event::SUN;
186 else 182 else
187 rpTmp.days |= day >> 1; 183 rpTmp.days |= day >> 1;
188 } 184 }
189 } 185 }
190 } 186 }
191 break; 187 break;
192 case MONTH: 188 case MONTH:
193 if ( cmdExtra1->isOn() ) 189 if ( cmdExtra1->isOn() )
194 rpTmp.type = Event::MonthlyDay; 190 rpTmp.type = Event::MonthlyDay;
195 else if ( cmdExtra2->isOn() ) 191 else if ( cmdExtra2->isOn() )
196 rpTmp.type = Event::MonthlyDate; 192 rpTmp.type = Event::MonthlyDate;
197 // figure out the montly day... 193 // figure out the montly day...
198 rpTmp.position = week( start ); 194 rpTmp.position = week( start );
199 break; 195 break;
200 case YEAR: 196 case YEAR:
201 rpTmp.type = Event::Yearly; 197 rpTmp.type = Event::Yearly;
202 break; 198 break;
203 } 199 }
204 break; // no need to keep looking! 200 break; // no need to keep looking!
205 } 201 }
206 } 202 }
207 rpTmp.frequency = spinFreq->value(); 203 rpTmp.frequency = spinFreq->value();
208 rpTmp.hasEndDate = !chkNoEnd->isChecked(); 204 rpTmp.hasEndDate = !chkNoEnd->isChecked();
209 if ( rpTmp.hasEndDate ) { 205 if ( rpTmp.hasEndDate ) {
210 rpTmp.setEndDate( end ); 206 rpTmp.setEndDate( end );
211 } 207 }
212 // timestamp it... 208 // timestamp it...
213 rpTmp.createTime = time( NULL ); 209 rpTmp.createTime = time( NULL );
214 return rpTmp; 210 return rpTmp;
215} 211}
216 212
217void RepeatEntry::slotSetRType( int rtype ) 213void RepeatEntry::slotSetRType( int rtype )
218{ 214{
219 // now call the right function based on the type... 215 // now call the right function based on the type...
220 currInterval = static_cast<repeatButtons>(rtype); 216 currInterval = static_cast<repeatButtons>(rtype);
221 switch ( currInterval ) { 217 switch ( currInterval ) {
222 case NONE: 218 case NONE:
223 setupNone(); 219 setupNone();
224 break; 220 break;
225 case DAY: 221 case DAY:
226 setupDaily(); 222 setupDaily();
227 break; 223 break;
228 case WEEK: 224 case WEEK:
229 setupWeekly(); 225 setupWeekly();
230 slotWeekLabel(); 226 slotWeekLabel();
231 break; 227 break;
232 case MONTH: 228 case MONTH:
233 setupMonthly(); 229 setupMonthly();
234 cmdExtra2->setOn( TRUE ); 230 cmdExtra2->setOn( TRUE );
235 slotMonthLabel( 1 ); 231 slotMonthLabel( 1 );
236 break; 232 break;
237 case YEAR: 233 case YEAR:
238 setupYearly(); 234 setupYearly();
239 break; 235 break;
240 } 236 }
241} 237}
242 238
243void RepeatEntry::setupNone() 239void RepeatEntry::setupNone()
244{ 240{
245 lblRepeat->setText( tr("No Repeat") ); 241 lblRepeat->setText( tr("No Repeat") );
246 lblVar1->hide(); 242 lblVar1->hide();
247 lblVar2->hide(); 243 lblVar2->hide();
248 hideExtras(); 244 hideExtras();
249 cmdEnd->hide(); 245 cmdEnd->hide();
250 lblFreq->hide(); 246 lblFreq->hide();
251 lblEvery->hide(); 247 lblEvery->hide();
252 lblFreq->hide(); 248 lblFreq->hide();
253 spinFreq->hide(); 249 spinFreq->hide();
254 lblEnd->hide(); 250 lblEnd->hide();
255 lblWeekVar->hide(); 251 lblWeekVar->hide();
256} 252}
257 253
258void RepeatEntry::setupDaily() 254void RepeatEntry::setupDaily()
259{ 255{
260 hideExtras(); 256 hideExtras();
261 lblWeekVar->hide(); 257 lblWeekVar->hide();
262 spinFreq->setValue( 1 ); 258 spinFreq->setValue( 1 );
263 lblFreq->setText( tr("day(s)") ); 259 lblFreq->setText( tr("day(s)") );
264 lblVar2->show(); 260 lblVar2->show();
265 showRepeatStuff(); 261 showRepeatStuff();
266 lblRepeat->setText( strDayTemplate ); 262 lblRepeat->setText( strDayTemplate );
267 setupRepeatLabel( 1 ); 263 setupRepeatLabel( 1 );
268} 264}
269 265
270void RepeatEntry::setupWeekly() 266void RepeatEntry::setupWeekly()
271{ 267{
272 // reshow the buttons... 268 // reshow the buttons...
273 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") ); 269 fraExtra->setTitle( RepeatEntryBase::tr("Repeat On") );
274 fraExtra->setExclusive( FALSE ); 270 fraExtra->setExclusive( FALSE );
275 fraExtra->show(); 271 fraExtra->show();
276 if ( startWeekOnMonday ) { 272 if ( startWeekOnMonday ) {
277 cmdExtra1->setText( RepeatEntryBase::tr("Mon") ); 273 cmdExtra1->setText( RepeatEntryBase::tr("Mon") );
278 cmdExtra2->setText( RepeatEntryBase::tr("Tue") ); 274 cmdExtra2->setText( RepeatEntryBase::tr("Tue") );
279 cmdExtra3->setText( RepeatEntryBase::tr("Wed") ); 275 cmdExtra3->setText( RepeatEntryBase::tr("Wed") );
280 cmdExtra4->setText( RepeatEntryBase::tr("Thu") ); 276 cmdExtra4->setText( RepeatEntryBase::tr("Thu") );
281 cmdExtra5->setText( RepeatEntryBase::tr("Fri") ); 277 cmdExtra5->setText( RepeatEntryBase::tr("Fri") );
282 cmdExtra6->setText( RepeatEntryBase::tr("Sat") ); 278 cmdExtra6->setText( RepeatEntryBase::tr("Sat") );
283 cmdExtra7->setText( RepeatEntryBase::tr("Sun") ); 279 cmdExtra7->setText( RepeatEntryBase::tr("Sun") );
284 } else { 280 } else {
285 cmdExtra1->setText( RepeatEntryBase::tr("Sun") ); 281 cmdExtra1->setText( RepeatEntryBase::tr("Sun") );
286 cmdExtra2->setText( RepeatEntryBase::tr("Mon") ); 282 cmdExtra2->setText( RepeatEntryBase::tr("Mon") );
287 cmdExtra3->setText( RepeatEntryBase::tr("Tue") ); 283 cmdExtra3->setText( RepeatEntryBase::tr("Tue") );
288 cmdExtra4->setText( RepeatEntryBase::tr("Wed") ); 284 cmdExtra4->setText( RepeatEntryBase::tr("Wed") );
289 cmdExtra5->setText( RepeatEntryBase::tr("Thu") ); 285 cmdExtra5->setText( RepeatEntryBase::tr("Thu") );
290 cmdExtra6->setText( RepeatEntryBase::tr("Fri") ); 286 cmdExtra6->setText( RepeatEntryBase::tr("Fri") );
291 cmdExtra7->setText( RepeatEntryBase::tr("Sat") ); 287 cmdExtra7->setText( RepeatEntryBase::tr("Sat") );
292 } 288 }
293 // I hope clustering these improve performance.... 289 // I hope clustering these improve performance....
294 cmdExtra1->setOn( FALSE ); 290 cmdExtra1->setOn( FALSE );
295 cmdExtra2->setOn( FALSE ); 291 cmdExtra2->setOn( FALSE );
296 cmdExtra3->setOn( FALSE ); 292 cmdExtra3->setOn( FALSE );
297 cmdExtra4->setOn( FALSE ); 293 cmdExtra4->setOn( FALSE );
298 cmdExtra5->setOn( FALSE ); 294 cmdExtra5->setOn( FALSE );
299 cmdExtra6->setOn( FALSE ); 295 cmdExtra6->setOn( FALSE );
300 cmdExtra7->setOn( FALSE ); 296 cmdExtra7->setOn( FALSE );
301 297
302 cmdExtra1->show(); 298 cmdExtra1->show();
303 cmdExtra2->show(); 299 cmdExtra2->show();
304 cmdExtra3->show(); 300 cmdExtra3->show();
305 cmdExtra4->show(); 301 cmdExtra4->show();
306 cmdExtra5->show(); 302 cmdExtra5->show();
307 cmdExtra6->show(); 303 cmdExtra6->show();
308 cmdExtra7->show(); 304 cmdExtra7->show();
309 305
310 lblWeekVar->show(); 306 lblWeekVar->show();
311 spinFreq->setValue( 1 ); 307 spinFreq->setValue( 1 );
312 // might as well set the day too... 308 // might as well set the day too...
313 if ( startWeekOnMonday ) { 309 if ( startWeekOnMonday ) {
314 fraExtra->setButton( start.dayOfWeek() - 1 ); 310 fraExtra->setButton( start.dayOfWeek() - 1 );
315 } else { 311 } else {
316 fraExtra->setButton( start.dayOfWeek() % 7 ); 312 fraExtra->setButton( start.dayOfWeek() % 7 );
317 } 313 }
318 lblFreq->setText( tr("week(s)") ); 314 lblFreq->setText( tr("week(s)") );
319 lblVar2->show(); 315 lblVar2->show();
320 showRepeatStuff(); 316 showRepeatStuff();
321 setupRepeatLabel( 1 ); 317 setupRepeatLabel( 1 );
322} 318}
323 319
324void RepeatEntry::setupMonthly() 320void RepeatEntry::setupMonthly()
325{ 321{
326 hideExtras(); 322 hideExtras();
327 lblWeekVar->hide(); 323 lblWeekVar->hide();
328 fraExtra->setTitle( tr("Repeat By") ); 324 fraExtra->setTitle( tr("Repeat By") );
329 fraExtra->setExclusive( TRUE ); 325 fraExtra->setExclusive( TRUE );
330 fraExtra->show(); 326 fraExtra->show();
331 cmdExtra1->setText( tr("Day") ); 327 cmdExtra1->setText( tr("Day") );
332 cmdExtra1->show(); 328 cmdExtra1->show();
333 cmdExtra2->setText( tr("Date") ); 329 cmdExtra2->setText( tr("Date") );
334 cmdExtra2->show(); 330 cmdExtra2->show();
335 spinFreq->setValue( 1 ); 331 spinFreq->setValue( 1 );
336 lblFreq->setText( tr("month(s)") ); 332 lblFreq->setText( tr("month(s)") );
337 lblVar2->show(); 333 lblVar2->show();
338 showRepeatStuff(); 334 showRepeatStuff();
339 setupRepeatLabel( 1 ); 335 setupRepeatLabel( 1 );
340} 336}
341 337
342void RepeatEntry::setupYearly() 338void RepeatEntry::setupYearly()
343{ 339{
344 hideExtras(); 340 hideExtras();
345 lblWeekVar->hide(); 341 lblWeekVar->hide();
346 spinFreq->setValue( 1 ); 342 spinFreq->setValue( 1 );
347 lblFreq->setText( tr("year(s)") ); 343 lblFreq->setText( tr("year(s)") );
348 lblFreq->show(); 344 lblFreq->show();
349 lblFreq->show(); 345 lblFreq->show();
350 showRepeatStuff(); 346 showRepeatStuff();
351 lblVar2->show(); 347 lblVar2->show();
352 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()) );
353 lblRepeat->setText( strEvery ); 349 lblRepeat->setText( strEvery );
354 setupRepeatLabel( 1 ); 350 setupRepeatLabel( 1 );
355 351
356} 352}
357 353
358void RepeatEntry::init() 354void RepeatEntry::init()
359{ 355{
360 QPopupMenu *m1 = new QPopupMenu( this ); 356 QPopupMenu *m1 = new QPopupMenu( this );
361 repeatPicker = new DateBookMonth( m1, 0, TRUE ); 357 repeatPicker = new DateBookMonth( m1, 0, TRUE );
362 m1->insertItem( repeatPicker ); 358 m1->insertItem( repeatPicker );
363 cmdEnd->setPopup( m1 ); 359 cmdEnd->setPopup( m1 );
364 cmdEnd->setPopupDelay( 0 ); 360 cmdEnd->setPopupDelay( 0 );
365 361
366 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)), 362 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)),
367 this, SLOT(endDateChanged(int, int, int)) ); 363 this, SLOT(endDateChanged(int, int, int)) );
368 QObject::connect( qApp, SIGNAL(weekChanged(bool)), 364 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
369 this, SLOT(slotChangeStartOfWeek(bool)) ); 365 this, SLOT(slotChangeStartOfWeek(bool)) );
370 366
371 listRTypeButtons.setAutoDelete( TRUE ); 367 listRTypeButtons.setAutoDelete( TRUE );
372 listRTypeButtons.append( cmdNone ); 368 listRTypeButtons.append( cmdNone );
373 listRTypeButtons.append( cmdDay ); 369 listRTypeButtons.append( cmdDay );
374 listRTypeButtons.append( cmdWeek ); 370 listRTypeButtons.append( cmdWeek );
375 listRTypeButtons.append( cmdMonth ); 371 listRTypeButtons.append( cmdMonth );
376 listRTypeButtons.append( cmdYear ); 372 listRTypeButtons.append( cmdYear );
377 373
378 listExtra.setAutoDelete( TRUE ); 374 listExtra.setAutoDelete( TRUE );
379 listExtra.append( cmdExtra1 ); 375 listExtra.append( cmdExtra1 );
380 listExtra.append( cmdExtra2 ); 376 listExtra.append( cmdExtra2 );
381 listExtra.append( cmdExtra3 ); 377 listExtra.append( cmdExtra3 );
382 listExtra.append( cmdExtra4 ); 378 listExtra.append( cmdExtra4 );
383 listExtra.append( cmdExtra5 ); 379 listExtra.append( cmdExtra5 );
384 listExtra.append( cmdExtra6 ); 380 listExtra.append( cmdExtra6 );
385 listExtra.append( cmdExtra7 ); 381 listExtra.append( cmdExtra7 );
386} 382}
387 383
388void RepeatEntry::slotNoEnd( bool unused ) 384void RepeatEntry::slotNoEnd( bool unused )
389{ 385{
390 // 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
391 if ( unused ) { 387 if ( unused ) {
392 end.setYMD( 3000, 12, 31 ); 388 end.setYMD( 3000, 12, 31 );
393 cmdEnd->setText( RepeatEntryBase::tr("No End Date") ); 389 cmdEnd->setText( RepeatEntryBase::tr("No End Date") );
394 } else { 390 } else {
395 end = start; 391 end = start;
396 cmdEnd->setText( TimeString::shortDate(end) ); 392 cmdEnd->setText( TimeString::shortDate(end) );
397 } 393 }
398} 394}
399 395
400void RepeatEntry::endDateChanged( int y, int m, int d ) 396void RepeatEntry::endDateChanged( int y, int m, int d )
401{ 397{
402 end.setYMD( y, m, d ); 398 end.setYMD( y, m, d );
403 if ( end < start ) 399 if ( end < start )
404 end = start; 400 end = start;
405 cmdEnd->setText( TimeString::shortDate( end ) ); 401 cmdEnd->setText( TimeString::shortDate( end ) );
406 repeatPicker->setDate( end.year(), end.month(), end.day() ); 402 repeatPicker->setDate( end.year(), end.month(), end.day() );
407} 403}
408 404
409void RepeatEntry::setupRepeatLabel( const QString &s ) 405void RepeatEntry::setupRepeatLabel( const QString &s )
410{ 406{
411 lblVar1->setText( s ); 407 lblVar1->setText( s );
412} 408}
413 409
414void RepeatEntry::setupRepeatLabel( int x ) 410void RepeatEntry::setupRepeatLabel( int x )
415{ 411{
416 // change the spelling based on the value of x 412 // change the spelling based on the value of x
417 QString strVar2; 413 QString strVar2;
418 414
419 if ( x > 1 ) 415 if ( x > 1 )
420 lblVar1->show(); 416 lblVar1->show();
421 else 417 else
422 lblVar1->hide(); 418 lblVar1->hide();
423 419
424 switch ( currInterval ) { 420 switch ( currInterval ) {
425 case NONE: 421 case NONE:
426 break; 422 break;
427 case DAY: 423 case DAY:
428 if ( x > 1 ) 424 if ( x > 1 )
429 strVar2 = tr( "days" ); 425 strVar2 = tr( "days" );
430 else 426 else
431 strVar2 = tr( "day" ); 427 strVar2 = tr( "day" );
432 break; 428 break;
433 case WEEK: 429 case WEEK:
434 if ( x > 1 ) 430 if ( x > 1 )
435 strVar2 = tr( "weeks" ); 431 strVar2 = tr( "weeks" );
436 else 432 else
437 strVar2 = tr( "week" ); 433 strVar2 = tr( "week" );
438 break; 434 break;
439 case MONTH: 435 case MONTH:
440 if ( x > 1 ) 436 if ( x > 1 )
441 strVar2 = RepeatEntryBase::tr( "months" ); 437 strVar2 = RepeatEntryBase::tr( "months" );
442 else 438 else
443 strVar2 = tr( "month" ); 439 strVar2 = tr( "month" );
444 break; 440 break;
445 case YEAR: 441 case YEAR:
446 if ( x > 1 ) 442 if ( x > 1 )
447 strVar2 = RepeatEntryBase::tr( "years" ); 443 strVar2 = RepeatEntryBase::tr( "years" );
448 else 444 else
449 strVar2 = tr( "year" ); 445 strVar2 = tr( "year" );
450 break; 446 break;
451 } 447 }
452 if ( !strVar2.isNull() ) 448 if ( !strVar2.isNull() )
453 lblVar2->setText( strVar2 ); 449 lblVar2->setText( strVar2 );
454} 450}
455 451
456void RepeatEntry::showRepeatStuff() 452void RepeatEntry::showRepeatStuff()
457{ 453{
458 cmdEnd->show(); 454 cmdEnd->show();
459 chkNoEnd->show(); 455 chkNoEnd->show();
460 lblFreq->show(); 456 lblFreq->show();
461 lblEvery->show(); 457 lblEvery->show();
462 lblFreq->show(); 458 lblFreq->show();
463 spinFreq->show(); 459 spinFreq->show();
464 lblEnd->show(); 460 lblEnd->show();
465 lblRepeat->setText( RepeatEntryBase::tr("Every") ); 461 lblRepeat->setText( RepeatEntryBase::tr("Every") );
466} 462}
467 463
468void RepeatEntry::slotWeekLabel() 464void RepeatEntry::slotWeekLabel()
469{ 465{
470 QString str; 466 QString str;
471 QListIterator<QToolButton> it( listExtra ); 467 QListIterator<QToolButton> it( listExtra );
472 unsigned int i; 468 unsigned int i;
473 unsigned int keepMe; 469 unsigned int keepMe;
474 bool bNeedCarriage = FALSE; 470 bool bNeedCarriage = FALSE;
475 // don't do something we'll regret!!! 471 // don't do something we'll regret!!!
476 if ( currInterval != WEEK ) 472 if ( currInterval != WEEK )
477 return; 473 return;
478 474
479 if ( startWeekOnMonday ) 475 if ( startWeekOnMonday )
480 keepMe = start.dayOfWeek() - 1; 476 keepMe = start.dayOfWeek() - 1;
481 else 477 else
482 keepMe = start.dayOfWeek() % 7; 478 keepMe = start.dayOfWeek() % 7;
483 479
484 QStringList list; 480 QStringList list;
485 for ( i = 0; *it; ++it, i++ ) { 481 for ( i = 0; *it; ++it, i++ ) {
486 // a crazy check, if you are repeating weekly, the current day 482 // a crazy check, if you are repeating weekly, the current day
487 // must be selected!!! 483 // must be selected!!!
488 if ( i == keepMe && !( (*it)->isOn() ) ) 484 if ( i == keepMe && !( (*it)->isOn() ) )
489 (*it)->setOn( TRUE ); 485 (*it)->setOn( TRUE );
490 if ( (*it)->isOn() ) { 486 if ( (*it)->isOn() ) {
491 if ( startWeekOnMonday ) 487 if ( startWeekOnMonday )
492 list.append( dayLabel[i] ); 488 list.append( dayLabel[i] );
493 else { 489 else {
494 if ( i == 0 ) 490 if ( i == 0 )
495 list.append( dayLabel[6] ); 491 list.append( dayLabel[6] );
496 else 492 else
497 list.append( dayLabel[i - 1] ); 493 list.append( dayLabel[i - 1] );
498 } 494 }
499 } 495 }
500 } 496 }
501 QStringList::Iterator itStr; 497 QStringList::Iterator itStr;
502 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { 498 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
503 if ( i == 3 ) 499 if ( i == 3 )
504 bNeedCarriage = TRUE; 500 bNeedCarriage = TRUE;
505 else 501 else
506 bNeedCarriage = FALSE; 502 bNeedCarriage = FALSE;
507 if ( str.isNull() ) 503 if ( str.isNull() )
508 str = *itStr; 504 str = *itStr;
509 else if ( i == list.count() - 1 ) { 505 else if ( i == list.count() - 1 ) {
510 if ( i < 2 ) 506 if ( i < 2 )
511 str += tr(" and ") + *itStr; 507 str += tr(" and ") + *itStr;
512 else { 508 else {
513 if ( bNeedCarriage ) 509 if ( bNeedCarriage )
514 str += tr( ",\nand " ) + *itStr; 510 str += tr( ",\nand " ) + *itStr;
515 else 511 else
516 str += tr( ", and " ) + *itStr; 512 str += tr( ", and " ) + *itStr;
517 } 513 }
518 } else { 514 } else {
519 if ( bNeedCarriage ) 515 if ( bNeedCarriage )
520 str += ",\n" + *itStr; 516 str += ",\n" + *itStr;
521 else 517 else
522 str += ", " + *itStr; 518 str += ", " + *itStr;
523 } 519 }
524 } 520 }
525 str = str.prepend( tr("on ") ); 521 str = str.prepend( tr("on ") );
526 lblWeekVar->setText( str ); 522 lblWeekVar->setText( str );
527} 523}
528 524
529void RepeatEntry::slotMonthLabel( int type ) 525void RepeatEntry::slotMonthLabel( int type )
530{ 526{
531 QString str; 527 QString str;
532 if ( currInterval != MONTH || type > 1 ) 528 if ( currInterval != MONTH || type > 1 )
533 return; 529 return;
534 if ( type == 1 ) 530 if ( type == 1 )
535 str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); 531 str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
536 else 532 else
537 str = strMonthDayTemplate.arg( numberPlacing(week(start))) 533 str = strMonthDayTemplate.arg( numberPlacing(week(start)))
538 .arg( dayLabel[start.dayOfWeek() - 1] ); 534 .arg( dayLabel[start.dayOfWeek() - 1] );
539 lblRepeat->setText( str ); 535 lblRepeat->setText( str );
540} 536}
541 537
542void RepeatEntry::slotChangeStartOfWeek( bool onMonday ) 538void RepeatEntry::slotChangeStartOfWeek( bool onMonday )
543{ 539{
544 startWeekOnMonday = onMonday; 540 startWeekOnMonday = onMonday;
545 // we need to make this unintrusive as possible... 541 // we need to make this unintrusive as possible...
546 int saveSpin = spinFreq->value(); 542 int saveSpin = spinFreq->value();
547 char days = 0; 543 char days = 0;
548 int day; 544 int day;
549 QListIterator<QToolButton> itExtra( listExtra ); 545 QListIterator<QToolButton> itExtra( listExtra );
550 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { 546 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
551 if ( (*itExtra)->isOn() ) { 547 if ( (*itExtra)->isOn() ) {
552 if ( !startWeekOnMonday ) 548 if ( !startWeekOnMonday )
553 days |= day; 549 days |= day;
554 else { 550 else {
555 if ( day == 1 ) 551 if ( day == 1 )
556 days |= Event::SUN; 552 days |= Event::SUN;
557 else 553 else
558 days |= day >> 1; 554 days |= day >> 1;
559 } 555 }
560 } 556 }
561 } 557 }
562 setupWeekly(); 558 setupWeekly();
563 spinFreq->setValue( saveSpin ); 559 spinFreq->setValue( saveSpin );
564 int buttons; 560 int buttons;
565 for ( day = 0x01, buttons = 0; buttons < 7; 561 for ( day = 0x01, buttons = 0; buttons < 7;
566 day = day << 1, buttons++ ) { 562 day = day << 1, buttons++ ) {
567 if ( days & day ) { 563 if ( days & day ) {
568 if ( startWeekOnMonday ) 564 if ( startWeekOnMonday )
569 fraExtra->setButton( buttons ); 565 fraExtra->setButton( buttons );
570 else { 566 else {
571 if ( buttons == 7 ) 567 if ( buttons == 7 )
572 fraExtra->setButton( 0 ); 568 fraExtra->setButton( 0 );
573 else 569 else
574 fraExtra->setButton( buttons + 1 ); 570 fraExtra->setButton( buttons + 1 );
575 } 571 }
576 } 572 }
577 } 573 }
578 slotWeekLabel(); 574 slotWeekLabel();
579} 575}
580 576
581static int week( const QDate &start ) 577static int week( const QDate &start )
582{ 578{
583 // figure out the week... 579 // figure out the week...
584 int stop = start.day(), 580 int stop = start.day(),
585 sentinel = start.dayOfWeek(), 581 sentinel = start.dayOfWeek(),
586 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), 582 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(),
587 week = 1, 583 week = 1,
588 i; 584 i;
589 for ( i = 1; i < stop; i++ ) { 585 for ( i = 1; i < stop; i++ ) {
590 if ( dayOfWeek++ == sentinel ) 586 if ( dayOfWeek++ == sentinel )
591 week++; 587 week++;
592 if ( dayOfWeek > 7 ) 588 if ( dayOfWeek > 7 )
593 dayOfWeek = 0; 589 dayOfWeek = 0;
594 } 590 }
595 return week; 591 return week;
596} 592}
597 593
598static QString numberPlacing( int x ) 594static QString numberPlacing( int x )
599{ 595{
600 // I hope this works in other languages besides english... 596 // I hope this works in other languages besides english...
601 QString str = QString::number( x ); 597 QString str = QString::number( x );
602 switch ( x % 10 ) { 598 switch ( x % 10 ) {
603 case 1: 599 case 1:
604 str += QWidget::tr( "st" ); 600 str += QWidget::tr( "st" );
605 break; 601 break;
606 case 2: 602 case 2:
607 str += QWidget::tr( "nd" ); 603 str += QWidget::tr( "nd" );
608 break; 604 break;
609 case 3: 605 case 3:
610 str += QWidget::tr( "rd" ); 606 str += QWidget::tr( "rd" );
611 break; 607 break;
612 default: 608 default:
613 str += QWidget::tr( "th" ); 609 str += QWidget::tr( "th" );
614 break; 610 break;
615 } 611 }
616 return str; 612 return str;
617} 613}
diff --git a/core/pim/osearch/adresssearch.cpp b/core/pim/osearch/adresssearch.cpp
index dbd6df6..6891f03 100644
--- a/core/pim/osearch/adresssearch.cpp
+++ b/core/pim/osearch/adresssearch.cpp
@@ -1,61 +1,59 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "adresssearch.h" 13#include "adresssearch.h"
14#include "contactitem.h" 14#include "contactitem.h"
15 15
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17 17
18#include <qstring.h>
19#include <qiconset.h>
20//#include <qwhatsthis.h> 18//#include <qwhatsthis.h>
21 19
22AdressSearch::AdressSearch(QListView* parent, QString name): 20AdressSearch::AdressSearch(QListView* parent, QString name):
23 SearchGroup(parent, name) 21 SearchGroup(parent, name)
24{ 22{
25 _contacts = 0; 23 _contacts = 0;
26 QIconSet is = Resource::loadIconSet( "addressbook/AddressBookSmall" ); 24 QIconSet is = Resource::loadIconSet( "addressbook/AddressBookSmall" );
27 setPixmap( 0, is.pixmap( QIconSet::Large, true ) ); 25 setPixmap( 0, is.pixmap( QIconSet::Large, true ) );
28 26
29 27
30 //QWhatsThis::add( this, QObject::tr("Search the addressbook") ); 28 //QWhatsThis::add( this, QObject::tr("Search the addressbook") );
31 /*QPixmap pix = Resource::loadPixmap( "addressbook/AddressBook" ); 29 /*QPixmap pix = Resource::loadPixmap( "addressbook/AddressBook" );
32 QImage img = pix.convertToImage(); 30 QImage img = pix.convertToImage();
33 img.smoothScale( 14, 14 ); 31 img.smoothScale( 14, 14 );
34 pix.convertFromImage( img ); 32 pix.convertFromImage( img );
35 setPixmap( 0, pix );*/ 33 setPixmap( 0, pix );*/
36} 34}
37 35
38 36
39AdressSearch::~AdressSearch() 37AdressSearch::~AdressSearch()
40{ 38{
41 delete _contacts; 39 delete _contacts;
42} 40}
43 41
44void AdressSearch::load() 42void AdressSearch::load()
45{ 43{
46 _contacts = new OPimContactAccess("osearch"); 44 _contacts = new OPimContactAccess("osearch");
47} 45}
48 46
49int AdressSearch::search() 47int AdressSearch::search()
50{ 48{
51 OPimRecordList<OPimContact> results = _contacts->matchRegexp(_search); 49 OPimRecordList<OPimContact> results = _contacts->matchRegexp(_search);
52 for (uint i = 0; i < results.count(); i++) { 50 for (uint i = 0; i < results.count(); i++) {
53 (void)new ContactItem( this, new OPimContact( results[i] )); 51 (void)new ContactItem( this, new OPimContact( results[i] ));
54 } 52 }
55 return results.count(); 53 return results.count();
56} 54}
57 55
58void AdressSearch::insertItem( void* ) 56void AdressSearch::insertItem( void* )
59{ 57{
60 58
61} 59}
diff --git a/core/pim/osearch/applnkitem.cpp b/core/pim/osearch/applnkitem.cpp
index 06c2b1e..19e765e 100644
--- a/core/pim/osearch/applnkitem.cpp
+++ b/core/pim/osearch/applnkitem.cpp
@@ -1,61 +1,60 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "applnkitem.h" 13#include "applnkitem.h"
14 14
15#include <qpe/applnk.h> 15#include <qpe/applnk.h>
16#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
17 17
18#include <qfileinfo.h>
19 18
20AppLnkItem::AppLnkItem(OListViewItem* parent, AppLnk *app) 19AppLnkItem::AppLnkItem(OListViewItem* parent, AppLnk *app)
21 : ResultItem(parent) 20 : ResultItem(parent)
22{ 21{
23 _app = app; 22 _app = app;
24 setText(0, _app->name() ); 23 setText(0, _app->name() );
25 setPixmap(0, _app->pixmap() ); 24 setPixmap(0, _app->pixmap() );
26} 25}
27 26
28 27
29AppLnkItem::~AppLnkItem() 28AppLnkItem::~AppLnkItem()
30{ 29{
31} 30}
32 31
33 32
34QString AppLnkItem::toRichText() 33QString AppLnkItem::toRichText()
35{ 34{
36 QString text; 35 QString text;
37 text += "<b><h3>" + _app->name() + "</b></h3><br>"; 36 text += "<b><h3>" + _app->name() + "</b></h3><br>";
38 text += _app->comment() + "<br>"; 37 text += _app->comment() + "<br>";
39 text += "<br>`" + _app->exec() + "`<br>"; 38 text += "<br>`" + _app->exec() + "`<br>";
40 text += "<br>`" + _app->file() + "`<br>"; 39 text += "<br>`" + _app->file() + "`<br>";
41 text += "<br>`" + _app->linkFile() + "`<br>"; 40 text += "<br>`" + _app->linkFile() + "`<br>";
42 return text; 41 return text;
43} 42}
44 43
45void AppLnkItem::action( int act ) 44void AppLnkItem::action( int act )
46{ 45{
47 if (!_app->isValid()) qDebug("INVALID"); 46 if (!_app->isValid()) qDebug("INVALID");
48 if (act == 0) _app->execute(); 47 if (act == 0) _app->execute();
49 else if (act == 1){ 48 else if (act == 1){
50 QCopEnvelope e("QPE/Application/advancedfm", "setDocument(QString)"); 49 QCopEnvelope e("QPE/Application/advancedfm", "setDocument(QString)");
51 e << _app->linkFile(); 50 e << _app->linkFile();
52 } 51 }
53} 52}
54 53
55QIntDict<QString> AppLnkItem::actions() 54QIntDict<QString> AppLnkItem::actions()
56{ 55{
57 QIntDict<QString> result; 56 QIntDict<QString> result;
58 result.insert( 0, new QString( QObject::tr("execute") ) ); 57 result.insert( 0, new QString( QObject::tr("execute") ) );
59 result.insert( 1, new QString( QObject::tr("open in filemanager") ) ); 58 result.insert( 1, new QString( QObject::tr("open in filemanager") ) );
60 return result; 59 return result;
61} 60}
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp
index 1c84d66..758baf2 100644
--- a/core/pim/osearch/applnksearch.cpp
+++ b/core/pim/osearch/applnksearch.cpp
@@ -1,70 +1,69 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "applnksearch.h" 13#include "applnksearch.h"
14#include "applnkitem.h" 14#include "applnkitem.h"
15 15
16#include <qpe/applnk.h> 16#include <qpe/applnk.h>
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18#include <qpe/resource.h> 18#include <qpe/resource.h>
19 19
20#include <qiconset.h>
21 20
22AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) 21AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name)
23{ 22{
24 _apps = 0; 23 _apps = 0;
25 QIconSet is = Resource::loadIconSet( "osearch/applicationsSmall" ); 24 QIconSet is = Resource::loadIconSet( "osearch/applicationsSmall" );
26 //QIconSet is = Resource::loadIconSet( "AppsIcon" ); 25 //QIconSet is = Resource::loadIconSet( "AppsIcon" );
27 setPixmap( 0, is.pixmap( QIconSet::Large, true ) ); 26 setPixmap( 0, is.pixmap( QIconSet::Large, true ) );
28} 27}
29 28
30 29
31AppLnkSearch::~AppLnkSearch() 30AppLnkSearch::~AppLnkSearch()
32{ 31{
33 delete _apps; 32 delete _apps;
34} 33}
35 34
36 35
37void AppLnkSearch::load() 36void AppLnkSearch::load()
38{ 37{
39 _apps = new AppLnkSet(QPEApplication::qpeDir()); 38 _apps = new AppLnkSet(QPEApplication::qpeDir());
40} 39}
41 40
42int AppLnkSearch::search() 41int AppLnkSearch::search()
43{ 42{
44 QList<AppLnk> appList = _apps->children(); 43 QList<AppLnk> appList = _apps->children();
45 44
46 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ 45 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){
47 if ( (_search.match( app->name() ) != -1) 46 if ( (_search.match( app->name() ) != -1)
48 || (_search.match(app->comment()) != -1) 47 || (_search.match(app->comment()) != -1)
49 || (_search.match(app->exec()) != -1) ) { 48 || (_search.match(app->exec()) != -1) ) {
50 insertItem( app ); 49 insertItem( app );
51 }else 50 }else
52 if (searchFile( app )) 51 if (searchFile( app ))
53 insertItem( app ); 52 insertItem( app );
54 qApp->processEvents( 100 ); 53 qApp->processEvents( 100 );
55 } 54 }
56 return _resultCount; 55 return _resultCount;
57} 56}
58 57
59void AppLnkSearch::insertItem( void *rec ) 58void AppLnkSearch::insertItem( void *rec )
60{ 59{
61 (void)new AppLnkItem( this, (AppLnk*)rec ); 60 (void)new AppLnkItem( this, (AppLnk*)rec );
62 _resultCount++; 61 _resultCount++;
63} 62}
64 63
65void AppLnkSearch::setSearch(QRegExp re) 64void AppLnkSearch::setSearch(QRegExp re)
66{ 65{
67 setOpen( false ); 66 setOpen( false );
68 SearchGroup::setSearch( re ); 67 SearchGroup::setSearch( re );
69} 68}
70 69
diff --git a/core/pim/osearch/contactitem.cpp b/core/pim/osearch/contactitem.cpp
index eedc374..639af46 100644
--- a/core/pim/osearch/contactitem.cpp
+++ b/core/pim/osearch/contactitem.cpp
@@ -1,142 +1,141 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "contactitem.h" 13#include "contactitem.h"
14 14
15#include <qpe/resource.h> 15#include <qpe/resource.h>
16#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
17 17
18#include <qpixmap.h>
19 18
20 19
21ContactItem::ContactItem(OListViewItem* parent, OPimContact *contact) 20ContactItem::ContactItem(OListViewItem* parent, OPimContact *contact)
22: ResultItem(parent) 21: ResultItem(parent)
23{ 22{
24 _contact = contact; 23 _contact = contact;
25 setText(0, _contact->toShortText()); 24 setText(0, _contact->toShortText());
26 setIcon(); 25 setIcon();
27} 26}
28 27
29void ContactItem::setIcon() 28void ContactItem::setIcon()
30{ 29{
31 QPixmap icon; 30 QPixmap icon;
32 switch ( _contact->lastHitField() ) { 31 switch ( _contact->lastHitField() ) {
33 case -1: 32 case -1:
34 icon = Resource::loadPixmap( "reset" ); 33 icon = Resource::loadPixmap( "reset" );
35 break; 34 break;
36 case Qtopia::BusinessPhone: 35 case Qtopia::BusinessPhone:
37 icon = Resource::loadPixmap( "addressbook/phonework" ); 36 icon = Resource::loadPixmap( "addressbook/phonework" );
38 break; 37 break;
39 case Qtopia::BusinessFax: 38 case Qtopia::BusinessFax:
40 icon = Resource::loadPixmap( "addressbook/faxwork" ); 39 icon = Resource::loadPixmap( "addressbook/faxwork" );
41 break; 40 break;
42 case Qtopia::BusinessMobile: 41 case Qtopia::BusinessMobile:
43 icon = Resource::loadPixmap( "addressbook/mobilework" ); 42 icon = Resource::loadPixmap( "addressbook/mobilework" );
44 break; 43 break;
45 case Qtopia::DefaultEmail: 44 case Qtopia::DefaultEmail:
46 case Qtopia::Emails: 45 case Qtopia::Emails:
47 icon = Resource::loadPixmap( "addressbook/email" ); 46 icon = Resource::loadPixmap( "addressbook/email" );
48 break; 47 break;
49 case Qtopia::HomePhone: 48 case Qtopia::HomePhone:
50 icon = Resource::loadPixmap( "addressbook/phonehome" ); 49 icon = Resource::loadPixmap( "addressbook/phonehome" );
51 break; 50 break;
52 case Qtopia::HomeFax: 51 case Qtopia::HomeFax:
53 icon = Resource::loadPixmap( "addressbook/faxhome" ); 52 icon = Resource::loadPixmap( "addressbook/faxhome" );
54 break; 53 break;
55 case Qtopia::HomeMobile: 54 case Qtopia::HomeMobile:
56 icon = Resource::loadPixmap( "addressbook/mobilehome" ); 55 icon = Resource::loadPixmap( "addressbook/mobilehome" );
57 break; 56 break;
58 case Qtopia::HomeWebPage: 57 case Qtopia::HomeWebPage:
59 icon = Resource::loadPixmap( "addressbook/webpagehome" ); 58 icon = Resource::loadPixmap( "addressbook/webpagehome" );
60 break; 59 break;
61 case Qtopia::BusinessWebPage: 60 case Qtopia::BusinessWebPage:
62 icon = Resource::loadPixmap( "addressbook/webpagework" ); 61 icon = Resource::loadPixmap( "addressbook/webpagework" );
63 break; 62 break;
64 case Qtopia::Title: 63 case Qtopia::Title:
65 case Qtopia::JobTitle: 64 case Qtopia::JobTitle:
66 case Qtopia::FirstName: 65 case Qtopia::FirstName:
67 case Qtopia::MiddleName: 66 case Qtopia::MiddleName:
68 case Qtopia::LastName: 67 case Qtopia::LastName:
69 case Qtopia::Suffix: 68 case Qtopia::Suffix:
70 case Qtopia::Nickname: 69 case Qtopia::Nickname:
71 case Qtopia::FileAs: 70 case Qtopia::FileAs:
72 icon = Resource::loadPixmap( "addressbook/identity" ); 71 icon = Resource::loadPixmap( "addressbook/identity" );
73 break; 72 break;
74 case Qtopia::HomeStreet: 73 case Qtopia::HomeStreet:
75 case Qtopia::HomeCity: 74 case Qtopia::HomeCity:
76 case Qtopia::HomeState: 75 case Qtopia::HomeState:
77 case Qtopia::HomeZip: 76 case Qtopia::HomeZip:
78 case Qtopia::HomeCountry: 77 case Qtopia::HomeCountry:
79 icon = Resource::loadPixmap( "osearch/addresshome" ); 78 icon = Resource::loadPixmap( "osearch/addresshome" );
80 break; 79 break;
81 case Qtopia::Company: 80 case Qtopia::Company:
82 case Qtopia::BusinessCity: 81 case Qtopia::BusinessCity:
83 case Qtopia::BusinessStreet: 82 case Qtopia::BusinessStreet:
84 case Qtopia::BusinessZip: 83 case Qtopia::BusinessZip:
85 case Qtopia::BusinessCountry: 84 case Qtopia::BusinessCountry:
86 case Qtopia::Department: 85 case Qtopia::Department:
87 case Qtopia::Office: 86 case Qtopia::Office:
88 case Qtopia::Manager: 87 case Qtopia::Manager:
89 case Qtopia::BusinessPager: 88 case Qtopia::BusinessPager:
90 case Qtopia::Profession: 89 case Qtopia::Profession:
91 icon = Resource::loadPixmap( "osearch/addresshome" ); 90 icon = Resource::loadPixmap( "osearch/addresshome" );
92 break; 91 break;
93 case Qtopia::Assistant: 92 case Qtopia::Assistant:
94 case Qtopia::Spouse: 93 case Qtopia::Spouse:
95 case Qtopia::Children: 94 case Qtopia::Children:
96 icon = Resource::loadPixmap( "osearch/personal" ); 95 icon = Resource::loadPixmap( "osearch/personal" );
97 break; 96 break;
98 case Qtopia::Birthday: 97 case Qtopia::Birthday:
99 case Qtopia::Anniversary: 98 case Qtopia::Anniversary:
100 icon = Resource::loadPixmap( "osearch/clock" ); 99 icon = Resource::loadPixmap( "osearch/clock" );
101 break; 100 break;
102 case Qtopia::Notes: 101 case Qtopia::Notes:
103 icon = Resource::loadPixmap( "txt" ); 102 icon = Resource::loadPixmap( "txt" );
104 break; 103 break;
105 default: 104 default:
106 icon = Resource::loadPixmap( "DocsIcon" ); 105 icon = Resource::loadPixmap( "DocsIcon" );
107 break; 106 break;
108 } 107 }
109 setPixmap( 0, icon ); 108 setPixmap( 0, icon );
110} 109}
111 110
112ContactItem::~ContactItem() 111ContactItem::~ContactItem()
113{ 112{
114 delete _contact; 113 delete _contact;
115} 114}
116 115
117 116
118QString ContactItem::toRichText() 117QString ContactItem::toRichText()
119{ 118{
120 return _contact->toRichText(); 119 return _contact->toRichText();
121} 120}
122 121
123void ContactItem::action( int act ) 122void ContactItem::action( int act )
124{ 123{
125if (act == 0){ 124if (act == 0){
126 QCopEnvelope e("QPE/Application/addressbook", "show(int)"); 125 QCopEnvelope e("QPE/Application/addressbook", "show(int)");
127 e << _contact->uid(); 126 e << _contact->uid();
128}else if(act == 1){ 127}else if(act == 1){
129 QCopEnvelope e("QPE/Application/addressbook", "edit(int)"); 128 QCopEnvelope e("QPE/Application/addressbook", "edit(int)");
130 e << _contact->uid(); 129 e << _contact->uid();
131} 130}
132 131
133} 132}
134 133
135QIntDict<QString> ContactItem::actions() 134QIntDict<QString> ContactItem::actions()
136{ 135{
137 QIntDict<QString> result; 136 QIntDict<QString> result;
138 result.insert( 0, new QString( QObject::tr("show") ) ); 137 result.insert( 0, new QString( QObject::tr("show") ) );
139 result.insert( 1, new QString( QObject::tr("edit") ) ); 138 result.insert( 1, new QString( QObject::tr("edit") ) );
140 return result; 139 return result;
141 140
142} 141}
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp
index 2b4660a..eeea54b 100644
--- a/core/pim/osearch/datebooksearch.cpp
+++ b/core/pim/osearch/datebooksearch.cpp
@@ -1,95 +1,93 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "datebooksearch.h" 13#include "datebooksearch.h"
14#include "eventitem.h" 14#include "eventitem.h"
15 15
16#include <opie2/opimevent.h> 16#include <opie2/opimevent.h>
17#include <opie2/opimrecurrence.h> 17#include <opie2/opimrecurrence.h>
18 18
19 19
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22 22
23#include <qiconset.h>
24#include <qaction.h> 23#include <qaction.h>
25#include <qdatetime.h>
26#include <qpopupmenu.h> 24#include <qpopupmenu.h>
27 25
28 26
29 27
30DatebookSearch::DatebookSearch(QListView* parent, QString name) 28DatebookSearch::DatebookSearch(QListView* parent, QString name)
31: SearchGroup(parent, name), _dates(0), _popupMenu(0) 29: SearchGroup(parent, name), _dates(0), _popupMenu(0)
32{ 30{
33 QIconSet is = Resource::loadIconSet( "datebook/DateBookSmall" ); 31 QIconSet is = Resource::loadIconSet( "datebook/DateBookSmall" );
34 setPixmap( 0, is.pixmap( QIconSet::Large, true ) ); 32 setPixmap( 0, is.pixmap( QIconSet::Large, true ) );
35 actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true ); 33 actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true );
36 actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true ); 34 actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true );
37 Config cfg( "osearch", Config::User ); 35 Config cfg( "osearch", Config::User );
38 cfg.setGroup( "datebook_settings" ); 36 cfg.setGroup( "datebook_settings" );
39 actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) ); 37 actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) );
40 actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) ); 38 actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) );
41} 39}
42 40
43DatebookSearch::~DatebookSearch() 41DatebookSearch::~DatebookSearch()
44{ 42{
45 qDebug("SAVE DATEBOOK SEARCH CONFIG"); 43 qDebug("SAVE DATEBOOK SEARCH CONFIG");
46 Config cfg( "osearch", Config::User ); 44 Config cfg( "osearch", Config::User );
47 cfg.setGroup( "datebook_settings" ); 45 cfg.setGroup( "datebook_settings" );
48 cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() ); 46 cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() );
49 cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() ); 47 cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() );
50 delete _dates; 48 delete _dates;
51 delete _popupMenu; 49 delete _popupMenu;
52 delete actionShowPastEvents; 50 delete actionShowPastEvents;
53 delete actionSearchInDates; 51 delete actionSearchInDates;
54} 52}
55 53
56 54
57void DatebookSearch::load() 55void DatebookSearch::load()
58{ 56{
59 _dates = new ODateBookAccess(); 57 _dates = new ODateBookAccess();
60 _dates->load(); 58 _dates->load();
61} 59}
62 60
63int DatebookSearch::search() 61int DatebookSearch::search()
64{ 62{
65 OPimRecordList<OPimEvent> results = _dates->matchRegexp(_search); 63 OPimRecordList<OPimEvent> results = _dates->matchRegexp(_search);
66 for (uint i = 0; i < results.count(); i++) 64 for (uint i = 0; i < results.count(); i++)
67 insertItem( new OPimEvent( results[i] ) ); 65 insertItem( new OPimEvent( results[i] ) );
68 return _resultCount; 66 return _resultCount;
69} 67}
70 68
71void DatebookSearch::insertItem( void *rec ) 69void DatebookSearch::insertItem( void *rec )
72{ 70{
73 OPimEvent *ev = (OPimEvent*)rec; 71 OPimEvent *ev = (OPimEvent*)rec;
74 if ( !actionShowPastEvents->isOn() && 72 if ( !actionShowPastEvents->isOn() &&
75 ev->endDateTime() < QDateTime::currentDateTime() && 73 ev->endDateTime() < QDateTime::currentDateTime() &&
76 !ev->recurrence().doesRecur() 74 !ev->recurrence().doesRecur()
77 ) return; 75 ) return;
78 if ( !actionSearchInDates->isOn() && ( 76 if ( !actionSearchInDates->isOn() && (
79 ev->lastHitField() == Qtopia::StartDateTime || 77 ev->lastHitField() == Qtopia::StartDateTime ||
80 ev->lastHitField() == Qtopia::EndDateTime ) 78 ev->lastHitField() == Qtopia::EndDateTime )
81 ) return; 79 ) return;
82 new EventItem( this, ev ); 80 new EventItem( this, ev );
83 _resultCount++; 81 _resultCount++;
84} 82}
85 83
86QPopupMenu* DatebookSearch::popupMenu() 84QPopupMenu* DatebookSearch::popupMenu()
87{ 85{
88 if (!_popupMenu){ 86 if (!_popupMenu){
89 _popupMenu = new QPopupMenu( 0 ); 87 _popupMenu = new QPopupMenu( 0 );
90 actionShowPastEvents->addTo( _popupMenu ); 88 actionShowPastEvents->addTo( _popupMenu );
91 actionSearchInDates->addTo( _popupMenu ); 89 actionSearchInDates->addTo( _popupMenu );
92 } 90 }
93 return _popupMenu; 91 return _popupMenu;
94} 92}
95 93
diff --git a/core/pim/osearch/doclnkitem.cpp b/core/pim/osearch/doclnkitem.cpp
index 1516b8e..df8e856 100644
--- a/core/pim/osearch/doclnkitem.cpp
+++ b/core/pim/osearch/doclnkitem.cpp
@@ -1,80 +1,79 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "doclnkitem.h" 13#include "doclnkitem.h"
14 14
15#include <qpe/applnk.h> 15#include <qpe/applnk.h>
16#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
17 17
18#include <qfile.h>
19#include <qtextstream.h> 18#include <qtextstream.h>
20#include <qfileinfo.h> 19#include <qfileinfo.h>
21 20
22DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app) 21DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app)
23 : ResultItem(parent) 22 : ResultItem(parent)
24{ 23{
25 _doc = app; 24 _doc = app;
26 setText(0, _doc->name() ); 25 setText(0, _doc->name() );
27 setPixmap(0, _doc->pixmap() ); 26 setPixmap(0, _doc->pixmap() );
28} 27}
29 28
30DocLnkItem::~DocLnkItem() 29DocLnkItem::~DocLnkItem()
31{ 30{
32} 31}
33 32
34QString DocLnkItem::toRichText() 33QString DocLnkItem::toRichText()
35{ 34{
36 QString text; 35 QString text;
37 text += "<b><h3>" + _doc->name() + "</b></h3><br>"; 36 text += "<b><h3>" + _doc->name() + "</b></h3><br>";
38 text += _doc->comment() + "<br>"; 37 text += _doc->comment() + "<br>";
39 text += QObject::tr("File: ") + _doc->file() + "<br>"; 38 text += QObject::tr("File: ") + _doc->file() + "<br>";
40 text += QObject::tr("Link: ") + _doc->linkFile() + "<br>"; 39 text += QObject::tr("Link: ") + _doc->linkFile() + "<br>";
41 text += QObject::tr("Mimetype: ") + _doc->type() + "<br>"; 40 text += QObject::tr("Mimetype: ") + _doc->type() + "<br>";
42 if ( _doc->type().contains( "text" ) ){ 41 if ( _doc->type().contains( "text" ) ){
43 text += "<br><br><hr><br>"; 42 text += "<br><br><hr><br>";
44 QFile f(_doc->file()); 43 QFile f(_doc->file());
45 if ( f.open(IO_ReadOnly) ) { 44 if ( f.open(IO_ReadOnly) ) {
46 QTextStream t( &f ); 45 QTextStream t( &f );
47 while ( !t.eof() ) 46 while ( !t.eof() )
48 text += t.readLine() + "<br>"; 47 text += t.readLine() + "<br>";
49 } 48 }
50 f.close(); 49 f.close();
51 } 50 }
52 /* text += "<br><br>`"; 51 /* text += "<br><br>`";
53 text += _doc->exec(); 52 text += _doc->exec();
54 text += "`";*/ 53 text += "`";*/
55 QStringList list = _doc->mimeTypes(); 54 QStringList list = _doc->mimeTypes();
56 int i = 0; 55 int i = 0;
57 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 56 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
58 text += QString::number( i++) + " - " + *it ; 57 text += QString::number( i++) + " - " + *it ;
59 } 58 }
60 return text; 59 return text;
61} 60}
62 61
63void DocLnkItem::action( int act ) 62void DocLnkItem::action( int act )
64{ 63{
65 qDebug("action %i",act); 64 qDebug("action %i",act);
66 if (!_doc->isValid()) qDebug("INVALID"); 65 if (!_doc->isValid()) qDebug("INVALID");
67 if (act == 0) _doc->execute(); 66 if (act == 0) _doc->execute();
68 else if (act == 1){ 67 else if (act == 1){
69 QCopEnvelope e("QPE/Application/advancedfm", "setDocument(QString)"); 68 QCopEnvelope e("QPE/Application/advancedfm", "setDocument(QString)");
70 e << _doc->file(); 69 e << _doc->file();
71 } 70 }
72} 71}
73 72
74QIntDict<QString> DocLnkItem::actions() 73QIntDict<QString> DocLnkItem::actions()
75{ 74{
76 QIntDict<QString> result; 75 QIntDict<QString> result;
77 result.insert( 0, new QString( QObject::tr("open with ") + _doc->exec() ) ); 76 result.insert( 0, new QString( QObject::tr("open with ") + _doc->exec() ) );
78 result.insert( 1, new QString( QObject::tr("open in filemanager") ) ); 77 result.insert( 1, new QString( QObject::tr("open in filemanager") ) );
79 return result; 78 return result;
80} 79}
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp
index c73dcbf..3f0d223 100644
--- a/core/pim/osearch/doclnksearch.cpp
+++ b/core/pim/osearch/doclnksearch.cpp
@@ -1,99 +1,98 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13 13
14 14
15#include "doclnkitem.h" 15#include "doclnkitem.h"
16#include "doclnksearch.h" 16#include "doclnksearch.h"
17 17
18#include <opie2/owait.h> 18#include <opie2/owait.h>
19 19
20#include <qpe/applnk.h> 20#include <qpe/applnk.h>
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qaction.h> 25#include <qaction.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qiconset.h>
28#include <qpopupmenu.h> 27#include <qpopupmenu.h>
29#include <qtextstream.h> 28#include <qtextstream.h>
30 29
31 30
32DocLnkSearch::DocLnkSearch(QListView* parent, QString name) 31DocLnkSearch::DocLnkSearch(QListView* parent, QString name)
33: AppLnkSearch(parent, name), _popupMenu(0) 32: AppLnkSearch(parent, name), _popupMenu(0)
34{ 33{
35 QIconSet is = Resource::loadIconSet( "osearch/documentsSmall" ); 34 QIconSet is = Resource::loadIconSet( "osearch/documentsSmall" );
36 setPixmap( 0, is.pixmap( QIconSet::Automatic, true ) ); 35 setPixmap( 0, is.pixmap( QIconSet::Automatic, true ) );
37 36
38 actionSearchInFiles = new QAction( QObject::tr("search content"),QString::null, 0, 0, 0, true ); 37 actionSearchInFiles = new QAction( QObject::tr("search content"),QString::null, 0, 0, 0, true );
39 Config cfg( "osearch", Config::User ); 38 Config cfg( "osearch", Config::User );
40 cfg.setGroup( "doclnk_settings" ); 39 cfg.setGroup( "doclnk_settings" );
41 actionSearchInFiles->setOn( cfg.readBoolEntry( "search_content", false ) ); 40 actionSearchInFiles->setOn( cfg.readBoolEntry( "search_content", false ) );
42} 41}
43 42
44 43
45DocLnkSearch::~DocLnkSearch() 44DocLnkSearch::~DocLnkSearch()
46{ 45{
47 Config cfg( "osearch", Config::User ); 46 Config cfg( "osearch", Config::User );
48 cfg.setGroup( "doclnk_settings" ); 47 cfg.setGroup( "doclnk_settings" );
49 cfg.writeEntry( "search_content", actionSearchInFiles->isOn() ); 48 cfg.writeEntry( "search_content", actionSearchInFiles->isOn() );
50} 49}
51 50
52void DocLnkSearch::load() 51void DocLnkSearch::load()
53{ 52{
54 _apps = new DocLnkSet(QPEApplication::documentDir()); 53 _apps = new DocLnkSet(QPEApplication::documentDir());
55} 54}
56 55
57bool DocLnkSearch::searchFile( AppLnk *app ) 56bool DocLnkSearch::searchFile( AppLnk *app )
58{ 57{
59 if (!actionSearchInFiles->isOn()) return false; 58 if (!actionSearchInFiles->isOn()) return false;
60 DocLnk *doc = (DocLnk*)app; 59 DocLnk *doc = (DocLnk*)app;
61 bool found = false; 60 bool found = false;
62 if ( doc->type().contains( "text" ) ){ 61 if ( doc->type().contains( "text" ) ){
63#ifdef NEW_OWAIT 62#ifdef NEW_OWAIT
64 QString ouput = QObject::tr("searching %1").arg(doc->file()); 63 QString ouput = QObject::tr("searching %1").arg(doc->file());
65 OWait( output ); 64 OWait( output );
66#endif 65#endif
67 QFile f(doc->file()); 66 QFile f(doc->file());
68 if ( f.open(IO_ReadOnly) ) { 67 if ( f.open(IO_ReadOnly) ) {
69 QTextStream t( &f ); 68 QTextStream t( &f );
70 while ( !t.eof() ) 69 while ( !t.eof() )
71 if (_search.match( t.readLine()) != -1) { 70 if (_search.match( t.readLine()) != -1) {
72 found = true; 71 found = true;
73 break; 72 break;
74 } 73 }
75 } 74 }
76 f.close(); 75 f.close();
77 } 76 }
78 return found; 77 return found;
79} 78}
80 79
81void DocLnkSearch::insertItem( void *rec ) 80void DocLnkSearch::insertItem( void *rec )
82{ 81{
83 (void)new DocLnkItem( this, (DocLnk*)rec ); 82 (void)new DocLnkItem( this, (DocLnk*)rec );
84 _resultCount++; 83 _resultCount++;
85} 84}
86 85
87 86
88QPopupMenu* DocLnkSearch::popupMenu() 87QPopupMenu* DocLnkSearch::popupMenu()
89{ 88{
90 if (!_popupMenu){ 89 if (!_popupMenu){
91 _popupMenu = new QPopupMenu( 0 ); 90 _popupMenu = new QPopupMenu( 0 );
92 actionSearchInFiles->addTo( _popupMenu ); 91 actionSearchInFiles->addTo( _popupMenu );
93 } 92 }
94 return _popupMenu; 93 return _popupMenu;
95 //(void) new DocLnkItem( this, (DocLnk*)rec ); 94 //(void) new DocLnkItem( this, (DocLnk*)rec );
96 // rec is undeclared here 95 // rec is undeclared here
97#warning FIXME 96#warning FIXME
98 _resultCount++; 97 _resultCount++;
99} 98}
diff --git a/core/pim/osearch/eventitem.cpp b/core/pim/osearch/eventitem.cpp
index f6e34fe..8dcfc70 100644
--- a/core/pim/osearch/eventitem.cpp
+++ b/core/pim/osearch/eventitem.cpp
@@ -1,86 +1,84 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "eventitem.h" 13#include "eventitem.h"
14 14
15 15
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qcopenvelope_qws.h> 17#include <qpe/qcopenvelope_qws.h>
18 18
19#include <qdatetime.h>
20#include <qpixmap.h>
21 19
22EventItem::EventItem(OListViewItem* parent, OPimEvent *event) 20EventItem::EventItem(OListViewItem* parent, OPimEvent *event)
23 : ResultItem(parent) 21 : ResultItem(parent)
24{ 22{
25 _event = event; 23 _event = event;
26 setText(0, _event->toShortText() ); 24 setText(0, _event->toShortText() );
27 setIcon(); 25 setIcon();
28} 26}
29 27
30 28
31EventItem::~EventItem() 29EventItem::~EventItem()
32{ 30{
33} 31}
34 32
35 33
36QString EventItem::toRichText() 34QString EventItem::toRichText()
37{ 35{
38 return _event->toRichText(); 36 return _event->toRichText();
39} 37}
40 38
41void EventItem::action( int act ) 39void EventItem::action( int act )
42{ 40{
43 if (act == 0){ 41 if (act == 0){
44 QCopEnvelope e("QPE/Application/datebook", "viewDefault(QDate)"); 42 QCopEnvelope e("QPE/Application/datebook", "viewDefault(QDate)");
45 e << _event->startDateTime().date(); 43 e << _event->startDateTime().date();
46 }else if(act == 1){ 44 }else if(act == 1){
47 QCopEnvelope e("QPE/Application/datebook", "editEvent(int)"); 45 QCopEnvelope e("QPE/Application/datebook", "editEvent(int)");
48 e << _event->uid(); 46 e << _event->uid();
49 } 47 }
50} 48}
51 49
52QIntDict<QString> EventItem::actions() 50QIntDict<QString> EventItem::actions()
53{ 51{
54 QIntDict<QString> result; 52 QIntDict<QString> result;
55 result.insert( 0, new QString( QObject::tr("show") ) ); 53 result.insert( 0, new QString( QObject::tr("show") ) );
56 result.insert( 1, new QString( QObject::tr("edit") ) ); 54 result.insert( 1, new QString( QObject::tr("edit") ) );
57 return result; 55 return result;
58} 56}
59 57
60void EventItem::setIcon() 58void EventItem::setIcon()
61{ 59{
62 QPixmap icon; 60 QPixmap icon;
63 switch ( _event->lastHitField() ) { 61 switch ( _event->lastHitField() ) {
64 case -1: 62 case -1:
65 icon = Resource::loadPixmap( "reset" ); 63 icon = Resource::loadPixmap( "reset" );
66 // QWhatsThis::add( icon, QObject::tr("Enter your search terms here") ); 64 // QWhatsThis::add( icon, QObject::tr("Enter your search terms here") );
67 break; 65 break;
68 case Qtopia::DatebookDescription: 66 case Qtopia::DatebookDescription:
69 icon = Resource::loadPixmap( "osearch/summary" ); 67 icon = Resource::loadPixmap( "osearch/summary" );
70 break; 68 break;
71 case Qtopia::Notes: 69 case Qtopia::Notes:
72 icon = Resource::loadPixmap( "txt" ); 70 icon = Resource::loadPixmap( "txt" );
73 break; 71 break;
74 case Qtopia::Location: 72 case Qtopia::Location:
75 icon = Resource::loadPixmap( "home" ); 73 icon = Resource::loadPixmap( "home" );
76 break; 74 break;
77 case Qtopia::StartDateTime: 75 case Qtopia::StartDateTime:
78 case Qtopia::EndDateTime: 76 case Qtopia::EndDateTime:
79 icon = Resource::loadPixmap( "osearch/clock" ); 77 icon = Resource::loadPixmap( "osearch/clock" );
80 break; 78 break;
81 default: 79 default:
82 icon = Resource::loadPixmap( "DocsIcon" ); 80 icon = Resource::loadPixmap( "DocsIcon" );
83 break; 81 break;
84 } 82 }
85 setPixmap( 0, icon ); 83 setPixmap( 0, icon );
86} 84}
diff --git a/core/pim/osearch/main.cpp b/core/pim/osearch/main.cpp
index 9a03818..e0a2de3 100644
--- a/core/pim/osearch/main.cpp
+++ b/core/pim/osearch/main.cpp
@@ -1,7 +1,6 @@
1 1
2#include "mainwindow.h" 2#include "mainwindow.h"
3 3
4#include <qpe/qpeapplication.h>
5#include <opie/oapplicationfactory.h> 4#include <opie/oapplicationfactory.h>
6 5
7OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 6OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index 95f5967..bfe95b0 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -1,317 +1,317 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11 11
12 12
13#include "olistview.h" 13#include "olistview.h"
14#include "olistviewitem.h" 14#include "olistviewitem.h"
15#include "resultitem.h" 15#include "resultitem.h"
16#include "adresssearch.h" 16#include "adresssearch.h"
17#include "todosearch.h" 17#include "todosearch.h"
18#include "datebooksearch.h" 18#include "datebooksearch.h"
19#include "applnksearch.h" 19#include "applnksearch.h"
20#include "doclnksearch.h" 20#include "doclnksearch.h"
21#include "mainwindow.h" 21#include "mainwindow.h"
22 22
23#include <opie2/owait.h> 23#include <opie2/owait.h>
24 24
25#include <qpe/qpemessagebox.h> 25#include <qpe/qpemessagebox.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28 28
29
29#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
30#include <qpe/config.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32 32
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qaction.h> 34#include <qaction.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37#include <qtoolbutton.h> 37#include <qtoolbutton.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qlabel.h> 39#include <qlabel.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qhbuttongroup.h> 41#include <qhbuttongroup.h>
42#include <qhbox.h> 42#include <qhbox.h>
43#include <qpushbutton.h> 43#include <qpushbutton.h>
44#include <qintdict.h> 44#include <qintdict.h>
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qsignalmapper.h> 47#include <qsignalmapper.h>
48#include <qtextbrowser.h> 48#include <qtextbrowser.h>
49#include <qregexp.h> 49#include <qregexp.h>
50#include <qwhatsthis.h> 50#include <qwhatsthis.h>
51#include <qmenubar.h> 51#include <qmenubar.h>
52 52
53 53
54 54
55static const char* const image1_data[] = { 55static const char* const image1_data[] = {
56"14 14 3 1", 56"14 14 3 1",
57". c None", 57". c None",
58"# c #000000", 58"# c #000000",
59"a c #ff0000", 59"a c #ff0000",
60"..............", 60"..............",
61"..##.......###", 61"..##.......###",
62".#aa#....##aa#", 62".#aa#....##aa#",
63"#aaaa#.##aaaa#", 63"#aaaa#.##aaaa#",
64".##aaa#aaaaa##", 64".##aaa#aaaaa##",
65"...#aaaaaaa#..", 65"...#aaaaaaa#..",
66"....#aaaaa#...", 66"....#aaaaa#...",
67"...#aaaaa#....", 67"...#aaaaa#....",
68"..#aaaaaaa#...", 68"..#aaaaaaa#...",
69".#aaaaaaaaa#..", 69".#aaaaaaaaa#..",
70"#aaaa###aaaa#.", 70"#aaaa###aaaa#.",
71"#aaa#..##aaa#.", 71"#aaa#..##aaa#.",
72"#aaa#...#aa#..", 72"#aaa#...#aa#..",
73".###.....##..."}; 73".###.....##..."};
74 74
75 75
76MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 76MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
77 QMainWindow( parent, name, f ), _currentItem(0) 77 QMainWindow( parent, name, f ), _currentItem(0)
78{ 78{
79 setCaption( tr("OSearch") ); 79 setCaption( tr("OSearch") );
80 80
81 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 81 setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
82 82
83 QFrame *mainFrame = new QFrame( this, "mainFrame" ); 83 QFrame *mainFrame = new QFrame( this, "mainFrame" );
84 mainFrame->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 84 mainFrame->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
85 85
86 mainLayout = new QVBoxLayout( mainFrame ); 86 mainLayout = new QVBoxLayout( mainFrame );
87 mainLayout->setSpacing( 0 ); 87 mainLayout->setSpacing( 0 );
88 mainLayout->setMargin( 3 ); 88 mainLayout->setMargin( 3 );
89 89
90 resultsList = new OListView( mainFrame ); 90 resultsList = new OListView( mainFrame );
91 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 91 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
92 mainLayout->addWidget( resultsList ); 92 mainLayout->addWidget( resultsList );
93 93
94 detailsFrame = new QFrame( mainFrame, "detailsFrame" ); 94 detailsFrame = new QFrame( mainFrame, "detailsFrame" );
95 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); 95 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
96 richEdit = new QTextView( detailsFrame ); 96 richEdit = new QTextView( detailsFrame );
97 QWhatsThis::add( richEdit, tr("The details of the current result") ); 97 QWhatsThis::add( richEdit, tr("The details of the current result") );
98 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 98 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
99 detailsLayout->addWidget( richEdit ); 99 detailsLayout->addWidget( richEdit );
100 100
101 buttonBox = new QHBox( mainFrame, "Button Box" ); 101 buttonBox = new QHBox( mainFrame, "Button Box" );
102 102
103 _buttonCount = 0; 103 _buttonCount = 0;
104 104
105 mainLayout->addWidget( detailsFrame ); 105 mainLayout->addWidget( detailsFrame );
106 mainLayout->addWidget( buttonBox ); 106 mainLayout->addWidget( buttonBox );
107 detailsFrame->hide(); 107 detailsFrame->hide();
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();
301 //resultsList->repaint(); 301 //resultsList->repaint();
302 } 302 }
303} 303}
304 304
305void MainWindow::slotAction( int act ) 305void MainWindow::slotAction( int act )
306{ 306{
307 if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){ 307 if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){
308 ResultItem *res = (ResultItem*)_currentItem; 308 ResultItem *res = (ResultItem*)_currentItem;
309 // ResultItem *res = dynamic_cast<ResultItem*>(item); 309 // ResultItem *res = dynamic_cast<ResultItem*>(item);
310 res->action(act); 310 res->action(act);
311 } 311 }
312} 312}
313 313
314void MainWindow::optionChanged(int ) 314void MainWindow::optionChanged(int )
315{ 315{
316 searchStringChanged(); 316 searchStringChanged();
317} 317}
diff --git a/core/pim/osearch/olistview.cpp b/core/pim/osearch/olistview.cpp
index 7a7cb26..8fbb31d 100644
--- a/core/pim/osearch/olistview.cpp
+++ b/core/pim/osearch/olistview.cpp
@@ -1,40 +1,39 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org> 9 // (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
10 10
11#include "olistview.h" 11#include "olistview.h"
12#include "olistviewitem.h" 12#include "olistviewitem.h"
13 13
14#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
15 15
16#include <qmessagebox.h>
17 16
18 17
19OListView::OListView(QWidget *parent, const char *name ) 18OListView::OListView(QWidget *parent, const char *name )
20 : QListView(parent,name) 19 : QListView(parent,name)
21{ 20{
22 21
23 setRootIsDecorated( true ); 22 setRootIsDecorated( true );
24 addColumn(tr("Results"),qApp->desktop()->width() - 9 ); 23 addColumn(tr("Results"),qApp->desktop()->width() - 9 );
25 //setColumnWidthMode(0, Manual); 24 //setColumnWidthMode(0, Manual);
26 25
27 setSorting( -1 ); 26 setSorting( -1 );
28 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); 27 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
29} 28}
30 29
31 30
32OListView::~OListView() 31OListView::~OListView()
33{ 32{
34} 33}
35 34
36void OListView::expand(QListViewItem *item) 35void OListView::expand(QListViewItem *item)
37{ 36{
38 ((OListViewItem*)item)->expand(); 37 ((OListViewItem*)item)->expand();
39} 38}
40 39
diff --git a/core/pim/osearch/resultitem.cpp b/core/pim/osearch/resultitem.cpp
index f051b12..41c22c0 100644
--- a/core/pim/osearch/resultitem.cpp
+++ b/core/pim/osearch/resultitem.cpp
@@ -1,27 +1,26 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "resultitem.h" 13#include "resultitem.h"
14 14
15 15
16#include <qmessagebox.h>
17 16
18ResultItem::ResultItem(OListViewItem* parent) 17ResultItem::ResultItem(OListViewItem* parent)
19: OListViewItem(parent) 18: OListViewItem(parent)
20{ 19{
21 20
22} 21}
23 22
24 23
25ResultItem::~ResultItem() 24ResultItem::~ResultItem()
26{ 25{
27} 26}
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp
index 5377b9f..7a0b5a7 100644
--- a/core/pim/osearch/searchgroup.cpp
+++ b/core/pim/osearch/searchgroup.cpp
@@ -1,92 +1,89 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "olistviewitem.h"
14#include "searchgroup.h" 13#include "searchgroup.h"
15 14
16#include <opie2/owait.h> 15#include <opie2/owait.h>
17 16
18#include <qobject.h>
19#include <qregexp.h>
20#include <qapplication.h> 17#include <qapplication.h>
21 18
22#ifndef NEW_OWAIT 19#ifndef NEW_OWAIT
23static OWait *wait = 0; 20static OWait *wait = 0;
24#endif 21#endif
25 22
26SearchGroup::SearchGroup(QListView* parent, QString name) 23SearchGroup::SearchGroup(QListView* parent, QString name)
27: OListViewItem(parent, name) 24: OListViewItem(parent, name)
28{ 25{
29 _name = name; 26 _name = name;
30 loaded = false; 27 loaded = false;
31} 28}
32 29
33 30
34SearchGroup::~SearchGroup() 31SearchGroup::~SearchGroup()
35{ 32{
36} 33}
37 34
38 35
39void SearchGroup::expand() 36void SearchGroup::expand()
40{ 37{
41 //expanded = true; 38 //expanded = true;
42 if (_lastSearch != _search) clearList(); 39 if (_lastSearch != _search) clearList();
43 if (_search.isEmpty()) return; 40 if (_search.isEmpty()) return;
44 OListViewItem *dummy = new OListViewItem( this, "searching..."); 41 OListViewItem *dummy = new OListViewItem( this, "searching...");
45 setOpen( true ); 42 setOpen( true );
46 repaint(); 43 repaint();
47 int res_count = realSearch(); 44 int res_count = realSearch();
48 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); 45 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
49 delete dummy; 46 delete dummy;
50 repaint(); 47 repaint();
51} 48}
52 49
53void SearchGroup::doSearch() 50void SearchGroup::doSearch()
54{ 51{
55 clearList(); 52 clearList();
56 if (_search.isEmpty()) return; 53 if (_search.isEmpty()) return;
57 _resultCount = realSearch(); 54 _resultCount = realSearch();
58 //repaint(); 55 //repaint();
59} 56}
60 57
61void SearchGroup::setSearch(QRegExp re) 58void SearchGroup::setSearch(QRegExp re)
62{ 59{
63 if (re == _search) return; 60 if (re == _search) return;
64 setText(0, _name+" - "+re.pattern() ); 61 setText(0, _name+" - "+re.pattern() );
65 _search = re; 62 _search = re;
66 if (isOpen()) expand(); 63 if (isOpen()) expand();
67 else new OListViewItem( this, "searching..."); 64 else new OListViewItem( this, "searching...");
68} 65}
69 66
70int SearchGroup::realSearch() 67int SearchGroup::realSearch()
71{ 68{
72 if (_lastSearch == _search) return _resultCount; 69 if (_lastSearch == _search) return _resultCount;
73#ifndef NEW_OWAIT 70#ifndef NEW_OWAIT
74 if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" ); 71 if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" );
75 wait->show(); 72 wait->show();
76 qApp->processEvents(); 73 qApp->processEvents();
77#else 74#else
78 qDebug("********** NEW_OWAIT *************"); 75 qDebug("********** NEW_OWAIT *************");
79 OWait( "searching" ); 76 OWait( "searching" );
80#endif 77#endif
81 if (!loaded) load(); 78 if (!loaded) load();
82 _resultCount = 0; 79 _resultCount = 0;
83 _resultCount = search(); 80 _resultCount = search();
84 _lastSearch = _search; 81 _lastSearch = _search;
85 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")"); 82 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")");
86 83
87#ifndef NEW_OWAIT 84#ifndef NEW_OWAIT
88 wait->hide(); 85 wait->hide();
89#endif 86#endif
90 return _resultCount; 87 return _resultCount;
91} 88}
92 89
diff --git a/core/pim/osearch/todoitem.cpp b/core/pim/osearch/todoitem.cpp
index c20f1fd..be780a1 100644
--- a/core/pim/osearch/todoitem.cpp
+++ b/core/pim/osearch/todoitem.cpp
@@ -1,83 +1,82 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "todoitem.h" 13#include "todoitem.h"
14 14
15 15
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qcopenvelope_qws.h> 17#include <qpe/qcopenvelope_qws.h>
18 18
19#include <qpixmap.h>
20 19
21 20
22TodoItem::TodoItem(OListViewItem* parent, OPimTodo *todo) 21TodoItem::TodoItem(OListViewItem* parent, OPimTodo *todo)
23: ResultItem(parent) 22: ResultItem(parent)
24{ 23{
25 _todo = todo; 24 _todo = todo;
26 setText( 0, todo->toShortText() ); 25 setText( 0, todo->toShortText() );
27 setIcon(); 26 setIcon();
28} 27}
29 28
30TodoItem::~TodoItem() 29TodoItem::~TodoItem()
31{ 30{
32 delete _todo; 31 delete _todo;
33} 32}
34 33
35QString TodoItem::toRichText() 34QString TodoItem::toRichText()
36{ 35{
37 return _todo->toRichText(); 36 return _todo->toRichText();
38} 37}
39 38
40void TodoItem::action( int act ) 39void TodoItem::action( int act )
41{ 40{
42 if (act == 0){ 41 if (act == 0){
43 QCopEnvelope e("QPE/Application/todolist", "show(int)"); 42 QCopEnvelope e("QPE/Application/todolist", "show(int)");
44 e << _todo->uid(); 43 e << _todo->uid();
45 }else if (act == 1){ 44 }else if (act == 1){
46 QCopEnvelope e("QPE/Application/todolist", "edit(int)"); 45 QCopEnvelope e("QPE/Application/todolist", "edit(int)");
47 e << _todo->uid(); 46 e << _todo->uid();
48 } 47 }
49} 48}
50 49
51QIntDict<QString> TodoItem::actions() 50QIntDict<QString> TodoItem::actions()
52{ 51{
53 QIntDict<QString> result; 52 QIntDict<QString> result;
54 result.insert( 0, new QString( QObject::tr("show") ) ); 53 result.insert( 0, new QString( QObject::tr("show") ) );
55 result.insert( 1, new QString( QObject::tr("edit") ) ); 54 result.insert( 1, new QString( QObject::tr("edit") ) );
56 return result; 55 return result;
57} 56}
58 57
59void TodoItem::setIcon() 58void TodoItem::setIcon()
60{ 59{
61 QPixmap icon; 60 QPixmap icon;
62 switch ( _todo->lastHitField() ) { 61 switch ( _todo->lastHitField() ) {
63 case -1: 62 case -1:
64 icon = Resource::loadPixmap( "reset" ); 63 icon = Resource::loadPixmap( "reset" );
65 break; 64 break;
66 case OPimTodo::Description: 65 case OPimTodo::Description:
67 icon = Resource::loadPixmap( "txt" ); 66 icon = Resource::loadPixmap( "txt" );
68 break; 67 break;
69 case OPimTodo::Summary: 68 case OPimTodo::Summary:
70 icon = Resource::loadPixmap( "osearch/summary" ); 69 icon = Resource::loadPixmap( "osearch/summary" );
71 break; 70 break;
72 case OPimTodo::Priority: 71 case OPimTodo::Priority:
73 icon = Resource::loadPixmap( "todo/priority1" ); 72 icon = Resource::loadPixmap( "todo/priority1" );
74 break; 73 break;
75 case OPimTodo::HasDate: 74 case OPimTodo::HasDate:
76 icon = Resource::loadPixmap( "osearch/clock" ); 75 icon = Resource::loadPixmap( "osearch/clock" );
77 break; 76 break;
78 default: 77 default:
79 icon = Resource::loadPixmap( "DocsIcon" ); 78 icon = Resource::loadPixmap( "DocsIcon" );
80 break; 79 break;
81 } 80 }
82 setPixmap( 0, icon ); 81 setPixmap( 0, icon );
83} 82}
diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp
index 5042803..cdf3a1c 100644
--- a/core/pim/osearch/todosearch.cpp
+++ b/core/pim/osearch/todosearch.cpp
@@ -1,80 +1,79 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "todosearch.h" 13#include "todosearch.h"
14#include "todoitem.h" 14#include "todoitem.h"
15 15
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18 18
19#include <qiconset.h>
20#include <qaction.h> 19#include <qaction.h>
21#include <qpopupmenu.h> 20#include <qpopupmenu.h>
22 21
23 22
24TodoSearch::TodoSearch(QListView* parent, QString name) 23TodoSearch::TodoSearch(QListView* parent, QString name)
25: SearchGroup(parent, name), _todos(0), _popupMenu(0) 24: SearchGroup(parent, name), _todos(0), _popupMenu(0)
26{ 25{
27 //AppLnkSet als(QPEApplication::qpeDir()); 26 //AppLnkSet als(QPEApplication::qpeDir());
28 //setPixmap( 0, als.findExec("todolist")->pixmap() ); 27 //setPixmap( 0, als.findExec("todolist")->pixmap() );
29 QIconSet is = Resource::loadIconSet( "todo/TodoListSmall" ); 28 QIconSet is = Resource::loadIconSet( "todo/TodoListSmall" );
30 setPixmap( 0, is.pixmap( QIconSet::Large, true ) ); 29 setPixmap( 0, is.pixmap( QIconSet::Large, true ) );
31 actionShowCompleted = new QAction( QObject::tr("show completed tasks"),QString::null, 0, 0, 0, true ); 30 actionShowCompleted = new QAction( QObject::tr("show completed tasks"),QString::null, 0, 0, 0, true );
32 Config cfg( "osearch", Config::User ); 31 Config cfg( "osearch", Config::User );
33 cfg.setGroup( "todo_settings" ); 32 cfg.setGroup( "todo_settings" );
34 actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) ); 33 actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) );
35 34
36} 35}
37 36
38 37
39TodoSearch::~TodoSearch() 38TodoSearch::~TodoSearch()
40{ 39{
41 Config cfg( "osearch", Config::User ); 40 Config cfg( "osearch", Config::User );
42 cfg.setGroup( "todo_settings" ); 41 cfg.setGroup( "todo_settings" );
43 cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() ); 42 cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() );
44 delete _popupMenu; 43 delete _popupMenu;
45 delete actionShowCompleted; 44 delete actionShowCompleted;
46 delete _todos; 45 delete _todos;
47} 46}
48 47
49 48
50void TodoSearch::load() 49void TodoSearch::load()
51{ 50{
52 _todos = new OPimTodoAccess(); 51 _todos = new OPimTodoAccess();
53 _todos->load(); 52 _todos->load();
54} 53}
55 54
56int TodoSearch::search() 55int TodoSearch::search()
57{ 56{
58 OPimRecordList<OPimTodo> results = _todos->matchRegexp(_search); 57 OPimRecordList<OPimTodo> results = _todos->matchRegexp(_search);
59 for (uint i = 0; i < results.count(); i++) 58 for (uint i = 0; i < results.count(); i++)
60 insertItem( new OPimTodo( results[i] )); 59 insertItem( new OPimTodo( results[i] ));
61 return _resultCount; 60 return _resultCount;
62} 61}
63 62
64void TodoSearch::insertItem( void *rec ) 63void TodoSearch::insertItem( void *rec )
65{ 64{
66 OPimTodo *todo = (OPimTodo*)rec; 65 OPimTodo *todo = (OPimTodo*)rec;
67 if (!actionShowCompleted->isOn() && 66 if (!actionShowCompleted->isOn() &&
68 todo->isCompleted() ) return; 67 todo->isCompleted() ) return;
69 (void)new TodoItem( this, todo ); 68 (void)new TodoItem( this, todo );
70 _resultCount++; 69 _resultCount++;
71} 70}
72 71
73QPopupMenu* TodoSearch::popupMenu() 72QPopupMenu* TodoSearch::popupMenu()
74{ 73{
75 if (!_popupMenu){ 74 if (!_popupMenu){
76 _popupMenu = new QPopupMenu( 0 ); 75 _popupMenu = new QPopupMenu( 0 );
77 actionShowCompleted->addTo( _popupMenu ); 76 actionShowCompleted->addTo( _popupMenu );
78 } 77 }
79 return _popupMenu; 78 return _popupMenu;
80} 79}
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index b55a4a7..72cdfd6 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,476 +1,475 @@
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/global.h>
25#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
26#include <qpe/contact.h> 25#include <qpe/contact.h>
27 26
28#include <qdir.h> 27#include <qdir.h>
29#include <qtimer.h> 28#include <qtimer.h>
30#include <qwhatsthis.h> 29#include <qwhatsthis.h>
31 30
32struct TodayPlugin { 31struct TodayPlugin {
33 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} 32 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
34 QLibrary *library; 33 QLibrary *library;
35 QInterfacePtr<TodayPluginInterface> iface; 34 QInterfacePtr<TodayPluginInterface> iface;
36 TodayPluginObject *guiPart; 35 TodayPluginObject *guiPart;
37 QWidget *guiBox; 36 QWidget *guiBox;
38 QString name; 37 QString name;
39 bool active; 38 bool active;
40 bool excludeRefresh; 39 bool excludeRefresh;
41 int pos; 40 int pos;
42}; 41};
43 42
44static QValueList<TodayPlugin> pluginList; 43static QValueList<TodayPlugin> pluginList;
45 44
46static QMap<QString, TodayPlugin> tempList; 45static QMap<QString, TodayPlugin> tempList;
47 46
48Today::Today( QWidget* parent, const char* name, WFlags fl ) 47Today::Today( QWidget* parent, const char* name, WFlags fl )
49 : TodayBase( parent, name, fl ) { 48 : TodayBase( parent, name, fl ) {
50 49
51 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); 50 QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) );
52 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); 51 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) );
53 52
54#if defined(Q_WS_QWS) 53#if defined(Q_WS_QWS)
55#if !defined(QT_NO_COP) 54#if !defined(QT_NO_COP)
56 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 55 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
57 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 56 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
58 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 57 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
59#endif 58#endif
60#endif 59#endif
61 60
62 setOwnerField(); 61 setOwnerField();
63 m_refreshTimer = new QTimer( this ); 62 m_refreshTimer = new QTimer( this );
64 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 63 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
65 m_refreshTimer->start( 15000 ); 64 m_refreshTimer->start( 15000 );
66 m_big_box = 0L; 65 m_big_box = 0L;
67 66
68 67
69 layout = new QVBoxLayout( this ); 68 layout = new QVBoxLayout( this );
70 layout->addWidget( Frame ); 69 layout->addWidget( Frame );
71 layout->addWidget( OwnerField ); 70 layout->addWidget( OwnerField );
72 71
73 m_sv = new QScrollView( this ); 72 m_sv = new QScrollView( this );
74 m_sv->setResizePolicy( QScrollView::AutoOneFit ); 73 m_sv->setResizePolicy( QScrollView::AutoOneFit );
75 m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); 74 m_sv->setHScrollBarMode( QScrollView::AlwaysOff );
76 m_sv->setFrameShape( QFrame::NoFrame ); 75 m_sv->setFrameShape( QFrame::NoFrame );
77 76
78 layout->addWidget( m_sv ); 77 layout->addWidget( m_sv );
79 layout->setStretchFactor( m_sv,4 ); 78 layout->setStretchFactor( m_sv,4 );
80 79
81 qApp->processEvents(); 80 qApp->processEvents();
82 loadPlugins(); 81 loadPlugins();
83 QPEApplication::showWidget( this ); 82 QPEApplication::showWidget( this );
84} 83}
85 84
86/** 85/**
87 * Qcop receive method. 86 * Qcop receive method.
88 */ 87 */
89void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 88void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
90 QDataStream stream( data, IO_ReadOnly ); 89 QDataStream stream( data, IO_ReadOnly );
91 if ( msg == "message(QString)" ) { 90 if ( msg == "message(QString)" ) {
92 QString message; 91 QString message;
93 stream >> message; 92 stream >> message;
94 setOwnerField( message ); 93 setOwnerField( message );
95 } 94 }
96} 95}
97 96
98void Today::setRefreshTimer( int interval ) { 97void Today::setRefreshTimer( int interval ) {
99 98
100 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 99 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
101 100
102 // 0 is "never" case 101 // 0 is "never" case
103 if ( !interval == 0 ) { 102 if ( !interval == 0 ) {
104 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 103 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
105 m_refreshTimer->changeInterval( interval ); 104 m_refreshTimer->changeInterval( interval );
106 } 105 }
107} 106}
108 107
109 108
110/** 109/**
111 * Initialises the owner field with the default value, the username 110 * Initialises the owner field with the default value, the username
112 */ 111 */
113void Today::setOwnerField() { 112void Today::setOwnerField() {
114 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 113 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
115 if ( QFile::exists( file ) ) { 114 if ( QFile::exists( file ) ) {
116 Contact cont = Contact::readVCard( file )[0]; 115 Contact cont = Contact::readVCard( file )[0];
117 QString returnString = cont.fullName(); 116 QString returnString = cont.fullName();
118 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 117 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
119 } else { 118 } else {
120 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 119 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
121 } 120 }
122} 121}
123 122
124/** 123/**
125 * 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.
126 */ 125 */
127void Today::setOwnerField( QString &message ) { 126void Today::setOwnerField( QString &message ) {
128 if ( !message.isEmpty() ) { 127 if ( !message.isEmpty() ) {
129 OwnerField->setText( "<b>" + message + "</b>" ); 128 OwnerField->setText( "<b>" + message + "</b>" );
130 } 129 }
131} 130}
132 131
133/** 132/**
134 * Init stuff needed for today. Reads the config file. 133 * Init stuff needed for today. Reads the config file.
135 */ 134 */
136void Today::init() { 135void Today::init() {
137 // read config 136 // read config
138 Config cfg( "today" ); 137 Config cfg( "today" );
139 138
140 cfg.setGroup( "Plugins" ); 139 cfg.setGroup( "Plugins" );
141 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 140 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
142 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 141 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
143 142
144 cfg.setGroup( "General" ); 143 cfg.setGroup( "General" );
145 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 144 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
146 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); 145 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
147 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 146 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
148 147
149 // set the date in top label 148 // set the date in top label
150 QDate date = QDate::currentDate(); 149 QDate date = QDate::currentDate();
151 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); 150 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
152 151
153 if ( m_hideBanner ) { 152 if ( m_hideBanner ) {
154 Opiezilla->hide(); 153 Opiezilla->hide();
155 TodayLabel->hide(); 154 TodayLabel->hide();
156 } else { 155 } else {
157 Opiezilla->show(); 156 Opiezilla->show();
158 TodayLabel->show(); 157 TodayLabel->show();
159 } 158 }
160 159
161 if ( m_big_box ) { 160 if ( m_big_box ) {
162 delete m_big_box; 161 delete m_big_box;
163 } 162 }
164 163
165 m_big_box = new QWidget( m_sv->viewport() ); 164 m_big_box = new QWidget( m_sv->viewport() );
166 m_sv->addChild( m_big_box ); 165 m_sv->addChild( m_big_box );
167 m_bblayout = new QVBoxLayout ( m_big_box ); 166 m_bblayout = new QVBoxLayout ( m_big_box );
168} 167}
169 168
170/** 169/**
171 * Load the plugins 170 * Load the plugins
172 */ 171 */
173void Today::loadPlugins() { 172void Today::loadPlugins() {
174 173
175 init(); 174 init();
176 175
177 QValueList<TodayPlugin>::Iterator tit; 176 QValueList<TodayPlugin>::Iterator tit;
178 if ( !pluginList.isEmpty() ) { 177 if ( !pluginList.isEmpty() ) {
179 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 178 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
180 (*tit).guiBox->hide(); 179 (*tit).guiBox->hide();
181 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); 180 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) );
182 delete (*tit).guiBox; 181 delete (*tit).guiBox;
183 (*tit).library->unload(); 182 (*tit).library->unload();
184 delete (*tit).library; 183 delete (*tit).library;
185 } 184 }
186 pluginList.clear(); 185 pluginList.clear();
187 } 186 }
188 187
189 QString path = QPEApplication::qpeDir() + "/plugins/today"; 188 QString path = QPEApplication::qpeDir() + "/plugins/today";
190#ifdef Q_OS_MACX 189#ifdef Q_OS_MACX
191 qWarning("Searching for Plugins in: %s", path.latin1()); 190 qWarning("Searching for Plugins in: %s", path.latin1());
192 QDir dir( path, "lib*.dylib" ); 191 QDir dir( path, "lib*.dylib" );
193#else 192#else
194 QDir dir( path, "lib*.so" ); 193 QDir dir( path, "lib*.so" );
195#endif 194#endif
196 195
197 QStringList list = dir.entryList(); 196 QStringList list = dir.entryList();
198 QStringList::Iterator it; 197 QStringList::Iterator it;
199 198
200 // QMap<QString, TodayPlugin> tempList; 199 // QMap<QString, TodayPlugin> tempList;
201 200
202 for ( it = list.begin(); it != list.end(); ++it ) { 201 for ( it = list.begin(); it != list.end(); ++it ) {
203 QInterfacePtr<TodayPluginInterface> iface; 202 QInterfacePtr<TodayPluginInterface> iface;
204 QLibrary *lib = new QLibrary( path + "/" + *it ); 203 QLibrary *lib = new QLibrary( path + "/" + *it );
205 204
206 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 205 qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
207 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { 206 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
208 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); 207 qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() );
209 qDebug( QString(*it) ); 208 qDebug( QString(*it) );
210 209
211 TodayPlugin plugin; 210 TodayPlugin plugin;
212 plugin.library = lib; 211 plugin.library = lib;
213 plugin.iface = iface; 212 plugin.iface = iface;
214 plugin.name = QString(*it); 213 plugin.name = QString(*it);
215 214
216 QString type = (*it).left( (*it).find(".") ); 215 QString type = (*it).left( (*it).find(".") );
217 216
218 QString lang; 217 QString lang;
219 Config config("locale"); 218 Config config("locale");
220 config.setGroup("Language"); 219 config.setGroup("Language");
221 lang = config.readEntry( "Language", "en" ); 220 lang = config.readEntry( "Language", "en" );
222 221
223 qDebug( "Languages: " + lang ); 222 qDebug( "Languages: " + lang );
224 QTranslator * trans = new QTranslator( qApp ); 223 QTranslator * trans = new QTranslator( qApp );
225 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; 224 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm";
226 if ( trans->load( tfn ) ) { 225 if ( trans->load( tfn ) ) {
227 qApp->installTranslator( trans ); 226 qApp->installTranslator( trans );
228 } else { 227 } else {
229 delete trans; 228 delete trans;
230 } 229 }
231 230
232 231
233 // find out if plugins should be shown 232 // find out if plugins should be shown
234 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 233 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
235 plugin.active = true; 234 plugin.active = true;
236 } else { 235 } else {
237 plugin.active = false; 236 plugin.active = false;
238 } 237 }
239 238
240 plugin.guiPart = plugin.iface->guiPart(); 239 plugin.guiPart = plugin.iface->guiPart();
241 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 240 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
242 241
243 // package the whole thing into a qwidget so it can be shown and hidden 242 // package the whole thing into a qwidget so it can be shown and hidden
244 plugin.guiBox = new QWidget( m_big_box ); 243 plugin.guiBox = new QWidget( m_big_box );
245 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 244 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
246 QPixmap plugPix; 245 QPixmap plugPix;
247 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 246 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
248 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 247 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
249 plugIcon->setPixmap( plugPix ); 248 plugIcon->setPixmap( plugPix );
250 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 249 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
251 plugIcon->setName( plugin.guiPart->appName() ); 250 plugIcon->setName( plugin.guiPart->appName() );
252 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 251 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
253 252
254 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); 253 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
255 boxLayout->addWidget( plugIcon, 0, AlignTop ); 254 boxLayout->addWidget( plugIcon, 0, AlignTop );
256 boxLayout->addWidget( plugWidget, 0, AlignTop ); 255 boxLayout->addWidget( plugWidget, 0, AlignTop );
257 boxLayout->setStretchFactor( plugIcon, 1 ); 256 boxLayout->setStretchFactor( plugIcon, 1 );
258 boxLayout->setStretchFactor( plugWidget, 9 ); 257 boxLayout->setStretchFactor( plugWidget, 9 );
259 258
260 // "prebuffer" it in one more list, to get the sorting done 259 // "prebuffer" it in one more list, to get the sorting done
261 tempList.insert( plugin.name, plugin ); 260 tempList.insert( plugin.name, plugin );
262 261
263 // on first start the list is off course empty 262 // on first start the list is off course empty
264 if ( m_allApplets.isEmpty() ) { 263 if ( m_allApplets.isEmpty() ) {
265 pluginList.append( plugin ); 264 pluginList.append( plugin );
266 m_bblayout->addWidget( plugin.guiBox ); 265 m_bblayout->addWidget( plugin.guiBox );
267 } 266 }
268 267
269 // if plugin is not yet in the list, add it to the layout too 268 // if plugin is not yet in the list, add it to the layout too
270 else if ( !m_allApplets.contains( plugin.name ) ) { 269 else if ( !m_allApplets.contains( plugin.name ) ) {
271 pluginList.append( plugin ); 270 pluginList.append( plugin );
272 } 271 }
273 } else { 272 } else {
274 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); 273 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() );
275 delete lib; 274 delete lib;
276 } 275 }
277 276
278 } 277 }
279 278
280 279
281 if ( !m_allApplets.isEmpty() ) { 280 if ( !m_allApplets.isEmpty() ) {
282 TodayPlugin tempPlugin; 281 TodayPlugin tempPlugin;
283 QStringList::Iterator stringit; 282 QStringList::Iterator stringit;
284 283
285 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 284 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
286 tempPlugin = ( tempList.find( *stringit ) ).data(); 285 tempPlugin = ( tempList.find( *stringit ) ).data();
287 if ( !( (tempPlugin.name).isEmpty() ) ) { 286 if ( !( (tempPlugin.name).isEmpty() ) ) {
288 pluginList.append( tempPlugin ); 287 pluginList.append( tempPlugin );
289 m_bblayout->addWidget( tempPlugin.guiBox ); 288 m_bblayout->addWidget( tempPlugin.guiBox );
290 } 289 }
291 } 290 }
292 } 291 }
293 m_bblayout->addStretch( 2 ); 292 m_bblayout->addStretch( 2 );
294 draw(); 293 draw();
295} 294}
296 295
297 296
298 297
299 298
300/** 299/**
301 * Repaint method. Reread all fields. 300 * Repaint method. Reread all fields.
302 */ 301 */
303void Today::draw() { 302void Today::draw() {
304 303
305 if ( pluginList.count() == 0 ) { 304 if ( pluginList.count() == 0 ) {
306 QLabel *noPlugins = new QLabel( this ); 305 QLabel *noPlugins = new QLabel( this );
307 noPlugins->setText( tr( "No plugins found" ) ); 306 noPlugins->setText( tr( "No plugins found" ) );
308 layout->addWidget( noPlugins ); 307 layout->addWidget( noPlugins );
309 return; 308 return;
310 } 309 }
311 310
312 uint count = 0; 311 uint count = 0;
313 TodayPlugin plugin; 312 TodayPlugin plugin;
314 for ( uint i = 0; i < pluginList.count(); i++ ) { 313 for ( uint i = 0; i < pluginList.count(); i++ ) {
315 plugin = pluginList[i]; 314 plugin = pluginList[i];
316 315
317 if ( plugin.active ) { 316 if ( plugin.active ) {
318 // qDebug( plugin.name + " is ACTIVE " ); 317 // qDebug( plugin.name + " is ACTIVE " );
319 plugin.guiBox->show(); 318 plugin.guiBox->show();
320 } else { 319 } else {
321 // qDebug( plugin.name + " is INACTIVE" ); 320 // qDebug( plugin.name + " is INACTIVE" );
322 plugin.guiBox->hide(); 321 plugin.guiBox->hide();
323 } 322 }
324 count++; 323 count++;
325 } 324 }
326 325
327 if ( count == 0 ) { 326 if ( count == 0 ) {
328 QLabel *noPluginsActive = new QLabel( this ); 327 QLabel *noPluginsActive = new QLabel( this );
329 noPluginsActive->setText( tr( "No plugins activated" ) ); 328 noPluginsActive->setText( tr( "No plugins activated" ) );
330 layout->addWidget( noPluginsActive ); 329 layout->addWidget( noPluginsActive );
331 } 330 }
332 repaint(); 331 repaint();
333} 332}
334 333
335 334
336/** 335/**
337 * The method for the configuration dialog. 336 * The method for the configuration dialog.
338 */ 337 */
339void Today::startConfig() { 338void Today::startConfig() {
340 339
341 // disconnect timer to prevent problems while being on config dialog 340 // disconnect timer to prevent problems while being on config dialog
342 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 341 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
343 m_refreshTimer->stop( ); 342 m_refreshTimer->stop( );
344 343
345 TodayConfig conf( this, "dialog", true ); 344 TodayConfig conf( this, "dialog", true );
346 345
347 TodayPlugin plugin; 346 TodayPlugin plugin;
348 QList<TodayConfigWidget> configWidgetList; 347 QList<TodayConfigWidget> configWidgetList;
349 348
350 for ( int i = pluginList.count() - 1; i >= 0; i-- ) { 349 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
351 plugin = pluginList[i]; 350 plugin = pluginList[i];
352 351
353 // load the config widgets in the tabs 352 // load the config widgets in the tabs
354 if ( plugin.guiPart->configWidget( this ) != 0l ) { 353 if ( plugin.guiPart->configWidget( this ) != 0l ) {
355 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); 354 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 );
356 configWidgetList.append( widget ); 355 configWidgetList.append( widget );
357 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() 356 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig()
358 , plugin.guiPart->appName() ); 357 , plugin.guiPart->appName() );
359 } 358 }
360 // set the order/activate tab 359 // set the order/activate tab
361 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), 360 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
362 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); 361 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
363 } 362 }
364 363
365 if ( conf.exec() == QDialog::Accepted ) { 364 if ( conf.exec() == QDialog::Accepted ) {
366 conf.writeConfig(); 365 conf.writeConfig();
367 TodayConfigWidget *confWidget; 366 TodayConfigWidget *confWidget;
368 for ( confWidget = configWidgetList.first(); confWidget != 0; 367 for ( confWidget = configWidgetList.first(); confWidget != 0;
369 confWidget = configWidgetList.next() ) { 368 confWidget = configWidgetList.next() ) {
370 confWidget->writeConfig(); 369 confWidget->writeConfig();
371 } 370 }
372 371
373 // make the plugins to reinitialize ( reread its configs ) 372 // make the plugins to reinitialize ( reread its configs )
374 reinitialize(); 373 reinitialize();
375 draw(); 374 draw();
376 375
377 } else { 376 } else {
378 // since refresh is not called in that case , reconnect the signal 377 // since refresh is not called in that case , reconnect the signal
379 m_refreshTimer->start( 15000 ); // get the config value in here later 378 m_refreshTimer->start( 15000 ); // get the config value in here later
380 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 379 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
381 } 380 }
382} 381}
383 382
384 383
385 384
386void Today::reinitialize() { 385void Today::reinitialize() {
387 386
388 Config cfg( "today" ); 387 Config cfg( "today" );
389 cfg.setGroup( "Plugins" ); 388 cfg.setGroup( "Plugins" );
390 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 389 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
391 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 390 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
392 391
393 /* reinitialize all plugins */ 392 /* reinitialize all plugins */
394 QValueList<TodayPlugin>::Iterator it; 393 QValueList<TodayPlugin>::Iterator it;
395 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 394 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
396 if ( !(*it).excludeRefresh ) { 395 if ( !(*it).excludeRefresh ) {
397 (*it).guiPart->reinitialize(); 396 (*it).guiPart->reinitialize();
398 qDebug( "reinit" ); 397 qDebug( "reinit" );
399 } 398 }
400 399
401 /* check if plugins is still to be shown */ 400 /* check if plugins is still to be shown */
402 if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) { 401 if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) {
403 (*it).active = true; 402 (*it).active = true;
404 } else { 403 } else {
405 (*it).active = false; 404 (*it).active = false;
406 } 405 }
407 406
408 } 407 }
409 408
410 cfg.setGroup( "General" ); 409 cfg.setGroup( "General" );
411 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 410 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
412 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); 411 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
413 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 412 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
414 413
415 // set the date in top label 414 // set the date in top label
416 QDate date = QDate::currentDate(); 415 QDate date = QDate::currentDate();
417 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); 416 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
418 417
419 if ( m_hideBanner ) { 418 if ( m_hideBanner ) {
420 Opiezilla->hide(); 419 Opiezilla->hide();
421 TodayLabel->hide(); 420 TodayLabel->hide();
422 } else { 421 } else {
423 Opiezilla->show(); 422 Opiezilla->show();
424 TodayLabel->show(); 423 TodayLabel->show();
425 } 424 }
426 425
427 delete m_bblayout; 426 delete m_bblayout;
428 m_bblayout = new QVBoxLayout( m_big_box ); 427 m_bblayout = new QVBoxLayout( m_big_box );
429 TodayPlugin tempPlugin; 428 TodayPlugin tempPlugin;
430 QStringList::Iterator stringit; 429 QStringList::Iterator stringit;
431 430
432 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 431 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
433 tempPlugin = ( tempList.find( *stringit ) ).data(); 432 tempPlugin = ( tempList.find( *stringit ) ).data();
434 if ( !( (tempPlugin.name).isEmpty() ) ) { 433 if ( !( (tempPlugin.name).isEmpty() ) ) {
435 m_bblayout->addWidget( tempPlugin.guiBox ); 434 m_bblayout->addWidget( tempPlugin.guiBox );
436 } 435 }
437 } 436 }
438 m_bblayout->addStretch( 2 ); 437 m_bblayout->addStretch( 2 );
439 438
440} 439}
441 440
442/** 441/**
443 * Refresh for the view. Reload all applets 442 * Refresh for the view. Reload all applets
444 * 443 *
445 */ 444 */
446void Today::refresh() { 445void Today::refresh() {
447 446
448 QValueList<TodayPlugin>::Iterator it; 447 QValueList<TodayPlugin>::Iterator it;
449 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 448 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
450 if ( !(*it).excludeRefresh ) { 449 if ( !(*it).excludeRefresh ) {
451 (*it).guiPart->refresh(); 450 (*it).guiPart->refresh();
452 qDebug( "refresh" ); 451 qDebug( "refresh" );
453 } 452 }
454 } 453 }
455 454
456 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); 455 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) );
457 456
458 updateGeometry(); 457 updateGeometry();
459 repaint(); 458 repaint();
460} 459}
461 460
462void Today::startApplication() { 461void Today::startApplication() {
463 QCopEnvelope e( "QPE/System", "execute(QString)" ); 462 QCopEnvelope e( "QPE/System", "execute(QString)" );
464 e << QString( sender()->name() ); 463 e << QString( sender()->name() );
465} 464}
466 465
467/** 466/**
468 * launch addressbook (personal card) 467 * launch addressbook (personal card)
469 */ 468 */
470void Today::editCard() { 469void Today::editCard() {
471 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); 470 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );
472} 471}
473 472
474Today::~Today() { 473Today::~Today() {
475} 474}
476 475
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 0613f2c..b68aad2 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,1042 +1,1036 @@
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 <unistd.h> 29#include <unistd.h>
30 30
31#include <opie2/opimrecurrence.h> 31#include <opie2/opimrecurrence.h>
32#include <opie2/opimnotifymanager.h> 32#include <opie2/opimnotifymanager.h>
33#include <opie2/otodoaccessvcal.h> 33#include <opie2/otodoaccessvcal.h>
34#include <opie2/oapplicationfactory.h> 34#include <opie2/oapplicationfactory.h>
35 35
36#include <qpe/applnk.h> 36#include <qpe/applnk.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/alarmserver.h> 41#include <qpe/alarmserver.h>
42#include <qpe/timestring.h>
43#include <qpe/qpeapplication.h> 42#include <qpe/qpeapplication.h>
44 43
45#include <qmenubar.h> 44#include <qmenubar.h>
46#include <qmessagebox.h> 45#include <qmessagebox.h>
47#include <qtoolbar.h>
48#include <qpopupmenu.h>
49#include <qpushbutton.h> 46#include <qpushbutton.h>
50#include <qwidgetstack.h>
51#include <qaction.h> 47#include <qaction.h>
52#include <qtimer.h> 48#include <qtimer.h>
53#include <qvbox.h>
54#include <qlayout.h> 49#include <qlayout.h>
55#include <qlineedit.h>
56#include <qwhatsthis.h> 50#include <qwhatsthis.h>
57 51
58#include "quickeditimpl.h" 52#include "quickeditimpl.h"
59#include "todotemplatemanager.h" 53#include "todotemplatemanager.h"
60#include "templateeditor.h" 54#include "templateeditor.h"
61#include "tableview.h" 55#include "tableview.h"
62 56
63#include "textviewshow.h" 57#include "textviewshow.h"
64#include "todoeditor.h" 58#include "todoeditor.h"
65#include "mainwindow.h" 59#include "mainwindow.h"
66 60
67OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) 61OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> )
68 62
69using namespace Todo; 63using namespace Todo;
70 64
71MainWindow::MainWindow( QWidget* parent, 65MainWindow::MainWindow( QWidget* parent,
72 const char* name, WFlags ) 66 const char* name, WFlags )
73 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) 67 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp )
74{ 68{
75 if (!name) 69 if (!name)
76 setName("todo window"); 70 setName("todo window");
77 71
78 m_syncing = false; 72 m_syncing = false;
79 m_showing = false; 73 m_showing = false;
80 m_counter = 0; 74 m_counter = 0;
81 m_tempManager = new TemplateManager(); 75 m_tempManager = new TemplateManager();
82 m_tempManager->load(); 76 m_tempManager->load();
83 77
84 initUI(); 78 initUI();
85 initConfig(); 79 initConfig();
86 initViews(); 80 initViews();
87 initActions(); 81 initActions();
88 initEditor(); 82 initEditor();
89 initShow(); 83 initShow();
90 initTemplate(); 84 initTemplate();
91 85
92 populateTemplates(); 86 populateTemplates();
93 raiseCurrentView(); 87 raiseCurrentView();
94 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 88 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
95} 89}
96void MainWindow::initTemplate() { 90void MainWindow::initTemplate() {
97 m_curTempEd = new TemplateEditor( this, templateManager() ); 91 m_curTempEd = new TemplateEditor( this, templateManager() );
98} 92}
99void MainWindow::initActions() { 93void MainWindow::initActions() {
100 94
101 // Data menu 95 // Data menu
102 m_edit->insertItem(QWidget::tr("New from template"), m_template, 96 m_edit->insertItem(QWidget::tr("New from template"), m_template,
103 -1, 0 ); 97 -1, 0 );
104 98
105 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 99 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ),
106 QString::null, 0, this, 0 ); 100 QString::null, 0, this, 0 );
107 connect(a, SIGNAL( activated() ), 101 connect(a, SIGNAL( activated() ),
108 this, SLOT( slotNew() ) ); 102 this, SLOT( slotNew() ) );
109 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 103 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) );
110 a->addTo(m_tool ); 104 a->addTo(m_tool );
111 a->addTo(m_edit ); 105 a->addTo(m_edit );
112 106
113 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), 107 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
114 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
115 connect(a, SIGNAL(activated() ), 109 connect(a, SIGNAL(activated() ),
116 this, SLOT( slotEdit() ) ); 110 this, SLOT( slotEdit() ) );
117 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); 111 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
118 a->addTo( m_tool ); 112 a->addTo( m_tool );
119 a->addTo( m_edit ); 113 a->addTo( m_edit );
120 m_editAction = a; 114 m_editAction = a;
121 115
122 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 );
123 connect(a, SIGNAL( activated() ), 117 connect(a, SIGNAL( activated() ),
124 this, SLOT( slotShowDetails() ) ); 118 this, SLOT( slotShowDetails() ) );
125 a->addTo( m_edit ); 119 a->addTo( m_edit );
126 120
127 m_edit->insertSeparator(); 121 m_edit->insertSeparator();
128 122
129 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), 123 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
130 QString::null, 0, this, 0 ); 124 QString::null, 0, this, 0 );
131 connect(a, SIGNAL(activated() ), 125 connect(a, SIGNAL(activated() ),
132 this, SLOT(slotDelete() ) ); 126 this, SLOT(slotDelete() ) );
133 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); 127 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
134 a->addTo( m_tool ); 128 a->addTo( m_tool );
135 a->addTo( m_edit ); 129 a->addTo( m_edit );
136 m_deleteAction = a; 130 m_deleteAction = a;
137 131
138 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 );
139 connect(a, SIGNAL( activated() ), 133 connect(a, SIGNAL( activated() ),
140 this, SLOT( slotDeleteAll() ) ); 134 this, SLOT( slotDeleteAll() ) );
141 a->addTo(m_edit ); 135 a->addTo(m_edit );
142 m_deleteAllAction = a; 136 m_deleteAllAction = a;
143 137
144 a = new QAction( QString::null, QWidget::tr("Delete completed"), 138 a = new QAction( QString::null, QWidget::tr("Delete completed"),
145 0, this, 0 ); 139 0, this, 0 );
146 connect(a, SIGNAL( activated() ), 140 connect(a, SIGNAL( activated() ),
147 this, SLOT( slotDeleteCompleted() ) ); 141 this, SLOT( slotDeleteCompleted() ) );
148 a->addTo(m_edit ); 142 a->addTo(m_edit );
149 a->setEnabled( TRUE ); 143 a->setEnabled( TRUE );
150 m_deleteCompleteAction = a; 144 m_deleteCompleteAction = a;
151 145
152 m_edit->insertSeparator(); 146 m_edit->insertSeparator();
153 147
154 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); 148 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
155 connect(a, SIGNAL( activated() ), 149 connect(a, SIGNAL( activated() ),
156 this, SLOT( slotDuplicate() ) ); 150 this, SLOT( slotDuplicate() ) );
157 a->addTo(m_edit ); 151 a->addTo(m_edit );
158 m_duplicateAction = a; 152 m_duplicateAction = a;
159 153
160 m_edit->insertSeparator(); 154 m_edit->insertSeparator();
161 155
162 if ( Ir::supported() ) { 156 if ( Ir::supported() ) {
163 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 );
164 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 158 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
165 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." ) );
166 a->addTo( m_edit ); 160 a->addTo( m_edit );
167 a->addTo( m_tool ); 161 a->addTo( m_tool );
168 } 162 }
169 163
170#if 0 164#if 0
171 // Options menu 165 // Options menu
172 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), 166 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ),
173 QString::null, 0, this, 0 ); 167 QString::null, 0, this, 0 );
174 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 168 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
175 a->addTo( m_options ); 169 a->addTo( m_options );
176 m_findAction = a; 170 m_findAction = a;
177 171
178 172
179 m_options->insertSeparator(); 173 m_options->insertSeparator();
180#endif 174#endif
181 175
182 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 176 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
183 0, this, 0, TRUE ); 177 0, this, 0, TRUE );
184 m_completedAction->addTo( m_options ); 178 m_completedAction->addTo( m_options );
185 m_completedAction->setOn( showCompleted() ); 179 m_completedAction->setOn( showCompleted() );
186 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 180 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
187 181
188 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"),
189 0, this, 0, TRUE ); 183 0, this, 0, TRUE );
190 a->addTo( m_options ); 184 a->addTo( m_options );
191 a->setOn( showOverDue() ); 185 a->setOn( showOverDue() );
192 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 186 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
193 187
194 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 188 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
195 0, this, 0, TRUE ); 189 0, this, 0, TRUE );
196 m_showDeadLineAction->addTo( m_options ); 190 m_showDeadLineAction->addTo( m_options );
197 m_showDeadLineAction->setOn( showDeadline() ); 191 m_showDeadLineAction->setOn( showDeadline() );
198 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); 192 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) );
199 193
200 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"),
201 0, this, 0, TRUE ); 195 0, this, 0, TRUE );
202 m_showQuickTaskAction->addTo( m_options ); 196 m_showQuickTaskAction->addTo( m_options );
203 m_showQuickTaskAction->setOn( showQuickTask() ); 197 m_showQuickTaskAction->setOn( showQuickTask() );
204 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 198 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
205 199
206 m_options->insertSeparator(); 200 m_options->insertSeparator();
207 201
208 m_bar->insertItem( QWidget::tr("Data") ,m_edit ); 202 m_bar->insertItem( QWidget::tr("Data") ,m_edit );
209 m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); 203 m_bar->insertItem( QWidget::tr("Category"), m_catMenu );
210 m_bar->insertItem( QWidget::tr("Options"), m_options ); 204 m_bar->insertItem( QWidget::tr("Options"), m_options );
211 205
212 m_curQuick = new QuickEditImpl( this, m_quicktask ); 206 m_curQuick = new QuickEditImpl( this, m_quicktask );
213 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); 207 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE );
214 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 208 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
215 209
216} 210}
217/* m_curCat from Config */ 211/* m_curCat from Config */
218void MainWindow::initConfig() { 212void MainWindow::initConfig() {
219 Config config( "todo" ); 213 Config config( "todo" );
220 config.setGroup( "View" ); 214 config.setGroup( "View" );
221 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 215 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
222 m_curCat = config.readEntry( "Category", QString::null ); 216 m_curCat = config.readEntry( "Category", QString::null );
223 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 217 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
224 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 218 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
225 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 219 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
226} 220}
227void MainWindow::initUI() { 221void MainWindow::initUI() {
228 222
229 m_stack = new OWidgetStack(this, "main stack"); 223 m_stack = new OWidgetStack(this, "main stack");
230 224
231 setCentralWidget( m_stack ); 225 setCentralWidget( m_stack );
232 226
233 setToolBarsMovable( FALSE ); 227 setToolBarsMovable( FALSE );
234 228
235 QToolBar *menubarholder = new QToolBar( this ); 229 QToolBar *menubarholder = new QToolBar( this );
236 menubarholder->setHorizontalStretchable( TRUE ); 230 menubarholder->setHorizontalStretchable( TRUE );
237 m_bar = new QMenuBar( menubarholder ); 231 m_bar = new QMenuBar( menubarholder );
238 232
239 m_tool = new QToolBar( this ); 233 m_tool = new QToolBar( this );
240 234
241 /** QPopupMenu */ 235 /** QPopupMenu */
242 m_edit = new QPopupMenu( this ); 236 m_edit = new QPopupMenu( this );
243 m_options = new QPopupMenu( this ); 237 m_options = new QPopupMenu( this );
244 m_catMenu = new QPopupMenu( this ); 238 m_catMenu = new QPopupMenu( this );
245 m_template = new QPopupMenu( this ); 239 m_template = new QPopupMenu( this );
246 240
247 m_catMenu->setCheckable( TRUE ); 241 m_catMenu->setCheckable( TRUE );
248 m_template->setCheckable( TRUE ); 242 m_template->setCheckable( TRUE );
249 243
250 connect(m_catMenu, SIGNAL(activated(int) ), 244 connect(m_catMenu, SIGNAL(activated(int) ),
251 this, SLOT(setCategory(int) ) ); 245 this, SLOT(setCategory(int) ) );
252 connect(m_template, SIGNAL(activated(int) ), 246 connect(m_template, SIGNAL(activated(int) ),
253 this, SLOT(slotNewFromTemplate(int) ) ); 247 this, SLOT(slotNewFromTemplate(int) ) );
254} 248}
255void MainWindow::initViews() { 249void MainWindow::initViews() {
256 250
257 TableView* tableView = new TableView( this, m_stack ); 251 TableView* tableView = new TableView( this, m_stack );
258 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." ) );
259 m_stack->addWidget( tableView, m_counter++ ); 253 m_stack->addWidget( tableView, m_counter++ );
260 m_views.append( tableView ); 254 m_views.append( tableView );
261 m_curView = tableView; 255 m_curView = tableView;
262 connectBase( tableView ); 256 connectBase( tableView );
263 /* add QString type + QString configname to 257 /* add QString type + QString configname to
264 * the View menu 258 * the View menu
265 * and subdirs for multiple views 259 * and subdirs for multiple views
266 */ 260 */
267} 261}
268void MainWindow::initEditor() { 262void MainWindow::initEditor() {
269 m_curEdit = new Editor(); 263 m_curEdit = new Editor();
270} 264}
271void MainWindow::initShow() { 265void MainWindow::initShow() {
272 m_curShow = new TextViewShow(this, this); 266 m_curShow = new TextViewShow(this, this);
273 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 267 m_stack->addWidget( m_curShow->widget() , m_counter++ );
274} 268}
275MainWindow::~MainWindow() { 269MainWindow::~MainWindow() {
276 delete templateManager(); 270 delete templateManager();
277} 271}
278void MainWindow::connectBase( ViewBase* ) { 272void MainWindow::connectBase( ViewBase* ) {
279 // once templates and signals mix we'll use it again 273 // once templates and signals mix we'll use it again
280} 274}
281QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 275QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
282 QPopupMenu* menu = new QPopupMenu(); 276 QPopupMenu* menu = new QPopupMenu();
283 277
284 m_editAction->addTo( menu ); 278 m_editAction->addTo( menu );
285 m_deleteAction->addTo( menu ); 279 m_deleteAction->addTo( menu );
286 m_duplicateAction->addTo( menu ); 280 m_duplicateAction->addTo( menu );
287 281
288 menu->insertSeparator(); 282 menu->insertSeparator();
289 283
290 /* 284 /*
291 * if this event recurs we allow 285 * if this event recurs we allow
292 * to detach it. 286 * to detach it.
293 * remove all 287 * remove all
294 */ 288 */
295 if ( recur ) { 289 if ( recur ) {
296 ; // FIXME 290 ; // FIXME
297 } 291 }
298 292
299 return menu; 293 return menu;
300} 294}
301QPopupMenu* MainWindow::options() { 295QPopupMenu* MainWindow::options() {
302 qWarning("Options"); 296 qWarning("Options");
303 return m_options; 297 return m_options;
304} 298}
305QPopupMenu* MainWindow::edit() { 299QPopupMenu* MainWindow::edit() {
306 return m_edit; 300 return m_edit;
307} 301}
308QToolBar* MainWindow::toolbar() { 302QToolBar* MainWindow::toolbar() {
309 return m_tool; 303 return m_tool;
310} 304}
311OPimTodoAccess::List MainWindow::list()const { 305OPimTodoAccess::List MainWindow::list()const {
312 return m_todoMgr.list(); 306 return m_todoMgr.list();
313} 307}
314OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 308OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
315 int cat = 0; 309 int cat = 0;
316 if ( m_curCat != QWidget::tr("All Categories") ) 310 if ( m_curCat != QWidget::tr("All Categories") )
317 cat = currentCatId(); 311 cat = currentCatId();
318 if ( m_curCat == QWidget::tr("Unfiled") ) 312 if ( m_curCat == QWidget::tr("Unfiled") )
319 cat = -1; 313 cat = -1;
320 314
321 qWarning(" Category %d %s", cat, m_curCat.latin1() ); 315 qWarning(" Category %d %s", cat, m_curCat.latin1() );
322 316
323 int filter = 1; 317 int filter = 1;
324 318
325 if (!m_completed ) 319 if (!m_completed )
326 filter |= 4; 320 filter |= 4;
327 if (m_overdue) 321 if (m_overdue)
328 filter |= 2; 322 filter |= 2;
329 323
330 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 324 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
331} 325}
332OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 326OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
333 int cat = 0; 327 int cat = 0;
334 if ( m_curCat != QWidget::tr("All Categories") ) 328 if ( m_curCat != QWidget::tr("All Categories") )
335 cat = currentCatId(); 329 cat = currentCatId();
336 330
337 if ( m_curCat == QWidget::tr("Unfiled") ) 331 if ( m_curCat == QWidget::tr("Unfiled") )
338 cat = -1; 332 cat = -1;
339 333
340 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 334 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
341} 335}
342OPimTodo MainWindow::event( int uid ) { 336OPimTodo MainWindow::event( int uid ) {
343 return m_todoMgr.event( uid ); 337 return m_todoMgr.event( uid );
344} 338}
345bool MainWindow::isSyncing()const { 339bool MainWindow::isSyncing()const {
346 return m_syncing; 340 return m_syncing;
347} 341}
348TemplateManager* MainWindow::templateManager() { 342TemplateManager* MainWindow::templateManager() {
349 return m_tempManager; 343 return m_tempManager;
350} 344}
351Editor* MainWindow::currentEditor() { 345Editor* MainWindow::currentEditor() {
352 return m_curEdit; 346 return m_curEdit;
353} 347}
354TodoShow* MainWindow::currentShow() { 348TodoShow* MainWindow::currentShow() {
355 return m_curShow; 349 return m_curShow;
356} 350}
357void MainWindow::slotReload() { 351void MainWindow::slotReload() {
358 m_syncing = FALSE; 352 m_syncing = FALSE;
359 m_todoMgr.reload(); 353 m_todoMgr.reload();
360 currentView()->updateView( ); 354 currentView()->updateView( );
361 raiseCurrentView(); 355 raiseCurrentView();
362} 356}
363void MainWindow::closeEvent( QCloseEvent* e ) { 357void MainWindow::closeEvent( QCloseEvent* e ) {
364 if (m_stack->visibleWidget() == currentShow()->widget() ) { 358 if (m_stack->visibleWidget() == currentShow()->widget() ) {
365 m_showing = false; 359 m_showing = false;
366 raiseCurrentView(); 360 raiseCurrentView();
367 e->ignore(); 361 e->ignore();
368 return; 362 return;
369 } 363 }
370 /* 364 /*
371 * we should have flushed and now we're still saving 365 * we should have flushed and now we're still saving
372 * so there is no need to flush 366 * so there is no need to flush
373 */ 367 */
374 if (m_syncing ) { 368 if (m_syncing ) {
375 e->accept(); 369 e->accept();
376 return; 370 return;
377 } 371 }
378 bool quit = false; 372 bool quit = false;
379 if ( m_todoMgr.saveAll() ){ 373 if ( m_todoMgr.saveAll() ){
380 qWarning("saved"); 374 qWarning("saved");
381 quit = true; 375 quit = true;
382 }else { 376 }else {
383 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 377 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
384 QWidget::tr("Todo was unable\n" 378 QWidget::tr("Todo was unable\n"
385 "to save your changes.\n" 379 "to save your changes.\n"
386 "Free up some space\n" 380 "Free up some space\n"
387 "and try again.\n" 381 "and try again.\n"
388 "\nQuit Anyway?"), 382 "\nQuit Anyway?"),
389 QMessageBox::Yes|QMessageBox::Escape, 383 QMessageBox::Yes|QMessageBox::Escape,
390 QMessageBox::No|QMessageBox::Default) 384 QMessageBox::No|QMessageBox::Default)
391 != QMessageBox::No ) { 385 != QMessageBox::No ) {
392 e->accept(); 386 e->accept();
393 quit = true; 387 quit = true;
394 }else 388 }else
395 e->ignore(); 389 e->ignore();
396 390
397 } 391 }
398 392
399 if (quit ) { 393 if (quit ) {
400 Config config( "todo" ); 394 Config config( "todo" );
401 config.setGroup( "View" ); 395 config.setGroup( "View" );
402 config.writeEntry( "ShowComplete", showCompleted() ); 396 config.writeEntry( "ShowComplete", showCompleted() );
403 config.writeEntry( "Category", currentCategory() ); 397 config.writeEntry( "Category", currentCategory() );
404 config.writeEntry( "ShowDeadLine", showDeadline()); 398 config.writeEntry( "ShowDeadLine", showDeadline());
405 config.writeEntry( "ShowOverDue", showOverDue() ); 399 config.writeEntry( "ShowOverDue", showOverDue() );
406 config.writeEntry( "ShowQuickTask", showQuickTask() ); 400 config.writeEntry( "ShowQuickTask", showQuickTask() );
407 /* save templates */ 401 /* save templates */
408 templateManager()->save(); 402 templateManager()->save();
409 e->accept(); 403 e->accept();
410 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); 404 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) );
411 } 405 }
412} 406}
413void MainWindow::populateTemplates() { 407void MainWindow::populateTemplates() {
414 m_template->clear(); 408 m_template->clear();
415 QStringList list = templateManager()->templates(); 409 QStringList list = templateManager()->templates();
416 QStringList::Iterator it; 410 QStringList::Iterator it;
417 for ( it = list.begin(); it != list.end(); ++it ) { 411 for ( it = list.begin(); it != list.end(); ++it ) {
418 m_template->insertItem( (*it) ); 412 m_template->insertItem( (*it) );
419 } 413 }
420} 414}
421/* 415/*
422 * slotNewFromTemplate 416 * slotNewFromTemplate
423 * We use the edit widget to do 417 * We use the edit widget to do
424 * the config but we setUid(1) 418 * the config but we setUid(1)
425 * to get a new uid 419 * to get a new uid
426 */ 420 */
427/* 421/*
428 * first we get the name of the template 422 * first we get the name of the template
429 * then we will use the TemplateManager 423 * then we will use the TemplateManager
430 */ 424 */
431void MainWindow::slotNewFromTemplate( int id ) { 425void MainWindow::slotNewFromTemplate( int id ) {
432 QString name = m_template->text( id ); 426 QString name = m_template->text( id );
433 427
434 OPimTodo event = templateManager()->templateEvent( name ); 428 OPimTodo event = templateManager()->templateEvent( name );
435 event = currentEditor()->edit(this, 429 event = currentEditor()->edit(this,
436 event ); 430 event );
437 431
438 if ( currentEditor()->accepted() ) { 432 if ( currentEditor()->accepted() ) {
439 /* assign new todo */ 433 /* assign new todo */
440 event.setUid( 1 ); 434 event.setUid( 1 );
441 handleAlarms( OPimTodo(), event ); 435 handleAlarms( OPimTodo(), event );
442 m_todoMgr.add( event ); 436 m_todoMgr.add( event );
443 currentView()->addEvent( event ); 437 currentView()->addEvent( event );
444 438
445 populateCategories(); 439 populateCategories();
446 } 440 }
447 raiseCurrentView(); 441 raiseCurrentView();
448} 442}
449void MainWindow::slotNew() { 443void MainWindow::slotNew() {
450 create(); 444 create();
451} 445}
452void MainWindow::slotDuplicate() { 446void MainWindow::slotDuplicate() {
453 if(m_syncing) { 447 if(m_syncing) {
454 QMessageBox::warning(this, QWidget::tr("Todo"), 448 QMessageBox::warning(this, QWidget::tr("Todo"),
455 QWidget::tr("Data can not be edited, currently syncing")); 449 QWidget::tr("Data can not be edited, currently syncing"));
456 return; 450 return;
457 } 451 }
458 OPimTodo ev = m_todoMgr.event( currentView()->current() ); 452 OPimTodo ev = m_todoMgr.event( currentView()->current() );
459 /* let's generate a new uid */ 453 /* let's generate a new uid */
460 ev.setUid(1); 454 ev.setUid(1);
461 m_todoMgr.add( ev ); 455 m_todoMgr.add( ev );
462 456
463 currentView()->addEvent( ev ); 457 currentView()->addEvent( ev );
464 raiseCurrentView(); 458 raiseCurrentView();
465} 459}
466void MainWindow::slotDelete() { 460void MainWindow::slotDelete() {
467 if (!currentView()->current() ) 461 if (!currentView()->current() )
468 return; 462 return;
469 463
470 if(m_syncing) { 464 if(m_syncing) {
471 QMessageBox::warning(this, QWidget::tr("Todo"), 465 QMessageBox::warning(this, QWidget::tr("Todo"),
472 QWidget::tr("Data can not be edited, currently syncing")); 466 QWidget::tr("Data can not be edited, currently syncing"));
473 return; 467 return;
474 } 468 }
475 QString strName = currentView()->currentRepresentation(); 469 QString strName = currentView()->currentRepresentation();
476 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 470 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
477 return; 471 return;
478 472
479 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); 473 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() );
480 m_todoMgr.remove( currentView()->current() ); 474 m_todoMgr.remove( currentView()->current() );
481 currentView()->removeEvent( currentView()->current() ); 475 currentView()->removeEvent( currentView()->current() );
482 raiseCurrentView(); 476 raiseCurrentView();
483} 477}
484void MainWindow::slotDelete(int uid ) { 478void MainWindow::slotDelete(int uid ) {
485 if( uid == 0 ) return; 479 if( uid == 0 ) return;
486 if(m_syncing) { 480 if(m_syncing) {
487 QMessageBox::warning(this, QWidget::tr("Todo"), 481 QMessageBox::warning(this, QWidget::tr("Todo"),
488 QWidget::tr("Data can not be edited, currently syncing")); 482 QWidget::tr("Data can not be edited, currently syncing"));
489 return; 483 return;
490 } 484 }
491 OPimTodo to = m_todoMgr.event(uid); 485 OPimTodo to = m_todoMgr.event(uid);
492 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) 486 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
493 return; 487 return;
494 488
495 handleAlarms(to, OPimTodo() ); 489 handleAlarms(to, OPimTodo() );
496 m_todoMgr.remove( to.uid() ); 490 m_todoMgr.remove( to.uid() );
497 currentView()->removeEvent( to.uid() ); 491 currentView()->removeEvent( to.uid() );
498 raiseCurrentView(); 492 raiseCurrentView();
499} 493}
500void MainWindow::slotDeleteAll() { 494void MainWindow::slotDeleteAll() {
501 if(m_syncing) { 495 if(m_syncing) {
502 QMessageBox::warning(this, QWidget::tr("Todo"), 496 QMessageBox::warning(this, QWidget::tr("Todo"),
503 QWidget::tr("Data can not be edited, currently syncing")); 497 QWidget::tr("Data can not be edited, currently syncing"));
504 return; 498 return;
505 } 499 }
506 500
507 501
508 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) 502 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) )
509 return; 503 return;
510 504
511 m_todoMgr.removeAll(); 505 m_todoMgr.removeAll();
512 currentView()->clear(); 506 currentView()->clear();
513 507
514 raiseCurrentView(); 508 raiseCurrentView();
515} 509}
516void MainWindow::slotDeleteCompleted() { 510void MainWindow::slotDeleteCompleted() {
517 if(m_syncing) { 511 if(m_syncing) {
518 QMessageBox::warning(this, QWidget::tr("Todo"), 512 QMessageBox::warning(this, QWidget::tr("Todo"),
519 QWidget::tr("Data can not be edited, currently syncing")); 513 QWidget::tr("Data can not be edited, currently syncing"));
520 return; 514 return;
521 } 515 }
522 516
523 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) 517 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) )
524 return; 518 return;
525 519
526 520
527 m_todoMgr.removeCompleted(); 521 m_todoMgr.removeCompleted();
528 currentView()->updateView( ); 522 currentView()->updateView( );
529} 523}
530void MainWindow::slotFind() { 524void MainWindow::slotFind() {
531 525
532} 526}
533void MainWindow::slotEdit() { 527void MainWindow::slotEdit() {
534 slotEdit( currentView()->current() ); 528 slotEdit( currentView()->current() );
535} 529}
536/* 530/*
537 * set the category 531 * set the category
538 */ 532 */
539void MainWindow::setCategory( int c) { 533void MainWindow::setCategory( int c) {
540 if ( c <= 0 ) return; 534 if ( c <= 0 ) return;
541 535
542 536
543 qWarning("Iterating over cats %d", c ); 537 qWarning("Iterating over cats %d", c );
544 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 538 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
545 m_catMenu->setItemChecked(i, c == (int)i ); 539 m_catMenu->setItemChecked(i, c == (int)i );
546 540
547 if (c == 1 ) { 541 if (c == 1 ) {
548 m_curCat = QString::null; 542 m_curCat = QString::null;
549 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); 543 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) );
550 544
551 }else if ( c == (int)m_catMenu->count() - 1 ) { 545 }else if ( c == (int)m_catMenu->count() - 1 ) {
552 m_curCat = QWidget::tr("Unfiled"); 546 m_curCat = QWidget::tr("Unfiled");
553 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); 547 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") );
554 }else { 548 }else {
555 m_curCat = m_todoMgr.categories()[c-2]; 549 m_curCat = m_todoMgr.categories()[c-2];
556 setCaption( QWidget::tr("Todo") + " - " + m_curCat ); 550 setCaption( QWidget::tr("Todo") + " - " + m_curCat );
557 } 551 }
558 m_catMenu->setItemChecked( c, true ); 552 m_catMenu->setItemChecked( c, true );
559 553
560 currentView()->setShowCategory( m_curCat ); 554 currentView()->setShowCategory( m_curCat );
561 raiseCurrentView(); 555 raiseCurrentView();
562} 556}
563void MainWindow::slotShowDeadLine( bool dead) { 557void MainWindow::slotShowDeadLine( bool dead) {
564 m_deadline = dead; 558 m_deadline = dead;
565 currentView()->setShowDeadline( dead ); 559 currentView()->setShowDeadline( dead );
566} 560}
567void MainWindow::slotShowCompleted( bool show) { 561void MainWindow::slotShowCompleted( bool show) {
568 m_completed = show; 562 m_completed = show;
569 currentView()->setShowCompleted( m_completed ); 563 currentView()->setShowCompleted( m_completed );
570} 564}
571void MainWindow::slotShowQuickTask( bool show ) { 565void MainWindow::slotShowQuickTask( bool show ) {
572 m_quicktask = show; 566 m_quicktask = show;
573 if ( m_quicktask ) 567 if ( m_quicktask )
574 m_curQuick->widget()->show(); 568 m_curQuick->widget()->show();
575 else 569 else
576 m_curQuick->widget()->hide(); 570 m_curQuick->widget()->hide();
577} 571}
578bool MainWindow::showOverDue()const { 572bool MainWindow::showOverDue()const {
579 return m_overdue; 573 return m_overdue;
580} 574}
581void MainWindow::setDocument( const QString& fi) { 575void MainWindow::setDocument( const QString& fi) {
582 DocLnk doc(fi); 576 DocLnk doc(fi);
583 if (doc.isValid() ) 577 if (doc.isValid() )
584 receiveFile(doc.file() ); 578 receiveFile(doc.file() );
585 else 579 else
586 receiveFile(fi ); 580 receiveFile(fi );
587} 581}
588 582
589static const char *beamfile = "/tmp/opie-todo.vcs"; 583static const char *beamfile = "/tmp/opie-todo.vcs";
590void MainWindow::slotBeam() { 584void MainWindow::slotBeam() {
591 beam( currentView()->current() ); 585 beam( currentView()->current() );
592} 586}
593void MainWindow::beamDone( Ir* ir) { 587void MainWindow::beamDone( Ir* ir) {
594 delete ir; 588 delete ir;
595 ::unlink( beamfile ); 589 ::unlink( beamfile );
596} 590}
597void MainWindow::receiveFile( const QString& filename ) { 591void MainWindow::receiveFile( const QString& filename ) {
598 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); 592 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename );
599 593
600 OPimTodoAccess acc( cal ); 594 OPimTodoAccess acc( cal );
601 acc.load(); 595 acc.load();
602 OPimTodoAccess::List list = acc.allRecords(); 596 OPimTodoAccess::List list = acc.allRecords();
603 597
604 if (list.count()){ 598 if (list.count()){
605 599
606 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 600 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
607 601
608 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 602 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
609 message, QMessageBox::Ok, 603 message, QMessageBox::Ok,
610 QMessageBox::Cancel ) == QMessageBox::Ok ) { 604 QMessageBox::Cancel ) == QMessageBox::Ok ) {
611 OPimTodoAccess::List::Iterator it; 605 OPimTodoAccess::List::Iterator it;
612 for ( it = list.begin(); it != list.end(); ++it ) 606 for ( it = list.begin(); it != list.end(); ++it )
613 m_todoMgr.add( (*it) ); 607 m_todoMgr.add( (*it) );
614 608
615 currentView()->updateView(); 609 currentView()->updateView();
616 } 610 }
617 } 611 }
618} 612}
619 613
620void MainWindow::slotFlush() { 614void MainWindow::slotFlush() {
621 m_syncing = TRUE; 615 m_syncing = TRUE;
622 m_todoMgr.save(); 616 m_todoMgr.save();
623} 617}
624void MainWindow::slotShowDetails() { 618void MainWindow::slotShowDetails() {
625 slotShow( currentView()->current() ); 619 slotShow( currentView()->current() );
626} 620}
627/* 621/*
628 * populate the Categories 622 * populate the Categories
629 * Menu 623 * Menu
630 */ 624 */
631void MainWindow::populateCategories() { 625void MainWindow::populateCategories() {
632 m_todoMgr.load(); 626 m_todoMgr.load();
633 627
634 m_catMenu->clear(); 628 m_catMenu->clear();
635 int id, rememberId; 629 int id, rememberId;
636 id = 1; 630 id = 1;
637 rememberId = 1; 631 rememberId = 1;
638 632
639 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); 633 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ );
640 m_catMenu->insertSeparator(); 634 m_catMenu->insertSeparator();
641 QStringList categories = m_todoMgr.categories(); 635 QStringList categories = m_todoMgr.categories();
642 categories.append( QWidget::tr( "Unfiled" ) ); 636 categories.append( QWidget::tr( "Unfiled" ) );
643 for ( QStringList::Iterator it = categories.begin(); 637 for ( QStringList::Iterator it = categories.begin();
644 it != categories.end(); ++it ) { 638 it != categories.end(); ++it ) {
645 m_catMenu->insertItem( *it, id ); 639 m_catMenu->insertItem( *it, id );
646 if ( *it == currentCategory() ) 640 if ( *it == currentCategory() )
647 rememberId = id; 641 rememberId = id;
648 ++id; 642 ++id;
649 } 643 }
650 setCategory( rememberId ); 644 setCategory( rememberId );
651} 645}
652bool MainWindow::showCompleted()const { 646bool MainWindow::showCompleted()const {
653 return m_completed; 647 return m_completed;
654} 648}
655bool MainWindow::showDeadline()const { 649bool MainWindow::showDeadline()const {
656 return m_deadline; 650 return m_deadline;
657} 651}
658bool MainWindow::showQuickTask()const { 652bool MainWindow::showQuickTask()const {
659 return m_quicktask; 653 return m_quicktask;
660} 654}
661QString MainWindow::currentCategory()const { 655QString MainWindow::currentCategory()const {
662 return m_curCat; 656 return m_curCat;
663} 657}
664int MainWindow::currentCatId() { 658int MainWindow::currentCatId() {
665 return m_todoMgr.catId( m_curCat ); 659 return m_todoMgr.catId( m_curCat );
666} 660}
667ViewBase* MainWindow::currentView() { 661ViewBase* MainWindow::currentView() {
668 return m_curView; 662 return m_curView;
669} 663}
670void MainWindow::raiseCurrentView() { 664void MainWindow::raiseCurrentView() {
671 // due QPE/Application/todolist show(int) 665 // due QPE/Application/todolist show(int)
672 // we might not have the populateCategories slot called once 666 // we might not have the populateCategories slot called once
673 // we would show the otodo but then imediately switch to the currentView 667 // we would show the otodo but then imediately switch to the currentView
674 // if we're initially showing we shouldn't raise the table 668 // if we're initially showing we shouldn't raise the table
675 // in returnFromView we fix up m_showing 669 // in returnFromView we fix up m_showing
676 if (m_showing ) return; 670 if (m_showing ) return;
677 671
678 m_stack->raiseWidget( m_curView->widget() ); 672 m_stack->raiseWidget( m_curView->widget() );
679} 673}
680void MainWindow::slotShowDue(bool ov) { 674void MainWindow::slotShowDue(bool ov) {
681 m_overdue = ov; 675 m_overdue = ov;
682 currentView()->showOverDue( ov ); 676 currentView()->showOverDue( ov );
683 raiseCurrentView(); 677 raiseCurrentView();
684} 678}
685void MainWindow::slotShow( int uid ) { 679void MainWindow::slotShow( int uid ) {
686 if ( uid == 0 ) return; 680 if ( uid == 0 ) return;
687 qWarning("slotShow"); 681 qWarning("slotShow");
688 currentShow()->slotShow( event( uid ) ); 682 currentShow()->slotShow( event( uid ) );
689 m_stack->raiseWidget( currentShow()->widget() ); 683 m_stack->raiseWidget( currentShow()->widget() );
690} 684}
691void MainWindow::slotShowNext() { 685void MainWindow::slotShowNext() {
692 int l = currentView()->next(); 686 int l = currentView()->next();
693 if (l!=0) 687 if (l!=0)
694 slotShow(l); 688 slotShow(l);
695} 689}
696void MainWindow::slotShowPrev() { 690void MainWindow::slotShowPrev() {
697 int l = currentView()->prev(); 691 int l = currentView()->prev();
698 if (l!=0) 692 if (l!=0)
699 slotShow(l); 693 slotShow(l);
700} 694}
701void MainWindow::slotEdit( int uid ) { 695void MainWindow::slotEdit( int uid ) {
702 if (uid == 0 ) return; 696 if (uid == 0 ) return;
703 if(m_syncing) { 697 if(m_syncing) {
704 QMessageBox::warning(this, QWidget::tr("Todo"), 698 QMessageBox::warning(this, QWidget::tr("Todo"),
705 QWidget::tr("Data can't be edited, currently syncing")); 699 QWidget::tr("Data can't be edited, currently syncing"));
706 return; 700 return;
707 } 701 }
708 702
709 OPimTodo old_todo = m_todoMgr.event( uid ); 703 OPimTodo old_todo = m_todoMgr.event( uid );
710 704
711 OPimTodo todo = currentEditor()->edit(this, old_todo ); 705 OPimTodo todo = currentEditor()->edit(this, old_todo );
712 706
713 /* if completed */ 707 /* if completed */
714 if ( currentEditor()->accepted() ) { 708 if ( currentEditor()->accepted() ) {
715 handleAlarms( old_todo, todo ); 709 handleAlarms( old_todo, todo );
716 m_todoMgr.update( todo.uid(), todo ); 710 m_todoMgr.update( todo.uid(), todo );
717 currentView()->replaceEvent( todo ); 711 currentView()->replaceEvent( todo );
718 /* a Category might have changed */ 712 /* a Category might have changed */
719 populateCategories(); 713 populateCategories();
720 } 714 }
721 715
722 raiseCurrentView(); 716 raiseCurrentView();
723} 717}
724/* 718/*
725void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 719void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
726 m_todoMgr.update( uid, ev ); 720 m_todoMgr.update( uid, ev );
727} 721}
728*/ 722*/
729void MainWindow::updateTodo( const OPimTodo& ev) { 723void MainWindow::updateTodo( const OPimTodo& ev) {
730 m_todoMgr.update( ev.uid() , ev ); 724 m_todoMgr.update( ev.uid() , ev );
731} 725}
732/* The view changed it's configuration 726/* The view changed it's configuration
733 * update the view menu 727 * update the view menu
734 */ 728 */
735void MainWindow::slotUpdate3( QWidget* ) { 729void MainWindow::slotUpdate3( QWidget* ) {
736 730
737} 731}
738void MainWindow::updateList() { 732void MainWindow::updateList() {
739 m_todoMgr.updateList(); 733 m_todoMgr.updateList();
740} 734}
741void MainWindow::setReadAhead( uint count ) { 735void MainWindow::setReadAhead( uint count ) {
742 if (m_todoMgr.todoDB() ) 736 if (m_todoMgr.todoDB() )
743 m_todoMgr.todoDB()->setReadAhead( count ); 737 m_todoMgr.todoDB()->setReadAhead( count );
744} 738}
745void MainWindow::slotQuickEntered() { 739void MainWindow::slotQuickEntered() {
746 qWarning("entered"); 740 qWarning("entered");
747 OPimTodo todo = quickEditor()->todo(); 741 OPimTodo todo = quickEditor()->todo();
748 if (todo.isEmpty() ) 742 if (todo.isEmpty() )
749 return; 743 return;
750 744
751 m_todoMgr.add( todo ); 745 m_todoMgr.add( todo );
752 currentView()->addEvent( todo ); 746 currentView()->addEvent( todo );
753 raiseCurrentView(); 747 raiseCurrentView();
754} 748}
755QuickEditBase* MainWindow::quickEditor() { 749QuickEditBase* MainWindow::quickEditor() {
756 return m_curQuick; 750 return m_curQuick;
757} 751}
758void MainWindow::slotComplete( int uid ) { 752void MainWindow::slotComplete( int uid ) {
759 slotComplete( event(uid) ); 753 slotComplete( event(uid) );
760} 754}
761void MainWindow::slotComplete( const OPimTodo& todo ) { 755void MainWindow::slotComplete( const OPimTodo& todo ) {
762 OPimTodo to = todo; 756 OPimTodo to = todo;
763 to.setCompleted( !to.isCompleted() ); 757 to.setCompleted( !to.isCompleted() );
764 to.setCompletedDate( QDate::currentDate() ); 758 to.setCompletedDate( QDate::currentDate() );
765 759
766 /* 760 /*
767 * if the item does recur 761 * if the item does recur
768 * we need to spin it off 762 * we need to spin it off
769 * and update the items duedate to the next 763 * and update the items duedate to the next
770 * possible recurrance of this item... 764 * possible recurrance of this item...
771 * the spinned off one will loose the 765 * the spinned off one will loose the
772 * recurrence. 766 * recurrence.
773 * We calculate the difference between the old due date and the 767 * We calculate the difference between the old due date and the
774 * new one and add this diff to start, completed and alarm dates 768 * new one and add this diff to start, completed and alarm dates
775 * -zecke 769 * -zecke
776 */ 770 */
777 if ( to.hasRecurrence() && to.isCompleted() ) { 771 if ( to.hasRecurrence() && to.isCompleted() ) {
778 OPimTodo to2( to ); 772 OPimTodo to2( to );
779 773
780 /* the spinned off one won't recur anymore */ 774 /* the spinned off one won't recur anymore */
781 to.setRecurrence( OPimRecurrence() ); 775 to.setRecurrence( OPimRecurrence() );
782 776
783 OPimRecurrence rec = to2.recurrence(); 777 OPimRecurrence rec = to2.recurrence();
784 rec.setStart( to.dueDate() ); 778 rec.setStart( to.dueDate() );
785 to2.setRecurrence( rec ); 779 to2.setRecurrence( rec );
786 /* 780 /*
787 * if there is a next occurence 781 * if there is a next occurence
788 * from the duedate of the last recurrance 782 * from the duedate of the last recurrance
789 */ 783 */
790 QDate date; 784 QDate date;
791 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 785 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
792 int dayDiff = to.dueDate().daysTo( date ); 786 int dayDiff = to.dueDate().daysTo( date );
793 qWarning("day diff is %d", dayDiff ); 787 qWarning("day diff is %d", dayDiff );
794 QDate inval; 788 QDate inval;
795 /* generate a new uid for the old record */ 789 /* generate a new uid for the old record */
796 to.setUid( 1 ); 790 to.setUid( 1 );
797 791
798 /* add the old one cause it has a new UID here cause it was spin off */ 792 /* add the old one cause it has a new UID here cause it was spin off */
799 m_todoMgr.add( to ); 793 m_todoMgr.add( to );
800 794
801 /* 795 /*
802 * update the due date 796 * update the due date
803 * start date 797 * start date
804 * and complete date 798 * and complete date
805 */ 799 */
806 to2.setDueDate( date ); 800 to2.setDueDate( date );
807 rec.setStart( date ); 801 rec.setStart( date );
808 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week 802 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week
809 803
810 /* move start date */ 804 /* move start date */
811 if (to2.hasStartDate() ) 805 if (to2.hasStartDate() )
812 to2.setStartDate( to2.startDate().addDays( dayDiff ) ); 806 to2.setStartDate( to2.startDate().addDays( dayDiff ) );
813 807
814 /* now the alarms */ 808 /* now the alarms */
815 if (to2.hasNotifiers() ) { 809 if (to2.hasNotifiers() ) {
816 OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); 810 OPimNotifyManager::Alarms _als = to2.notifiers().alarms();
817 OPimNotifyManager::Alarms als; 811 OPimNotifyManager::Alarms als;
818 812
819 /* for every alarm move the day */ 813 /* for every alarm move the day */
820 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { 814 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) {
821 OPimAlarm al = (*it); 815 OPimAlarm al = (*it);
822 al.setDateTime( al.dateTime().addDays( dayDiff ) ); 816 al.setDateTime( al.dateTime().addDays( dayDiff ) );
823 als.append( al ); 817 als.append( al );
824 } 818 }
825 to2.notifiers().setAlarms( als ); 819 to2.notifiers().setAlarms( als );
826 handleAlarms( OPimTodo(), todo ); 820 handleAlarms( OPimTodo(), todo );
827 } 821 }
828 to2.setCompletedDate( inval ); 822 to2.setCompletedDate( inval );
829 to2.setCompleted( false ); 823 to2.setCompleted( false );
830 824
831 updateTodo( to2 ); 825 updateTodo( to2 );
832 }else 826 }else
833 updateTodo( to ); 827 updateTodo( to );
834 }else 828 }else
835 updateTodo( to ); 829 updateTodo( to );
836 830
837 currentView()->updateView(); 831 currentView()->updateView();
838 raiseCurrentView(); 832 raiseCurrentView();
839} 833}
840void MainWindow::flush() { 834void MainWindow::flush() {
841 slotFlush(); 835 slotFlush();
842} 836}
843void MainWindow::reload() { 837void MainWindow::reload() {
844 slotReload(); 838 slotReload();
845} 839}
846int MainWindow::create() { 840int MainWindow::create() {
847 int uid = 0; 841 int uid = 0;
848 if(m_syncing) { 842 if(m_syncing) {
849 QMessageBox::warning(this, QWidget::tr("Todo"), 843 QMessageBox::warning(this, QWidget::tr("Todo"),
850 QWidget::tr("Data can not be edited, currently syncing")); 844 QWidget::tr("Data can not be edited, currently syncing"));
851 return uid; 845 return uid;
852 } 846 }
853 m_todoMgr.load(); 847 m_todoMgr.load();
854 848
855 849
856 OPimTodo todo = currentEditor()->newTodo( currentCatId(), 850 OPimTodo todo = currentEditor()->newTodo( currentCatId(),
857 this ); 851 this );
858 852
859 if ( currentEditor()->accepted() ) { 853 if ( currentEditor()->accepted() ) {
860 //todo.assignUid(); 854 //todo.assignUid();
861 uid = todo.uid(); 855 uid = todo.uid();
862 handleAlarms( OPimTodo(), todo ); 856 handleAlarms( OPimTodo(), todo );
863 m_todoMgr.add( todo ); 857 m_todoMgr.add( todo );
864 currentView()->addEvent( todo ); 858 currentView()->addEvent( todo );
865 859
866 860
867 // I'm afraid we must call this every time now, otherwise 861 // I'm afraid we must call this every time now, otherwise
868 // spend expensive time comparing all these strings... 862 // spend expensive time comparing all these strings...
869 // but only call if we changed something -zecke 863 // but only call if we changed something -zecke
870 populateCategories(); 864 populateCategories();
871 } 865 }
872 raiseCurrentView( ); 866 raiseCurrentView( );
873 867
874 return uid; 868 return uid;
875} 869}
876/* delete it silently... */ 870/* delete it silently... */
877bool MainWindow::remove( int uid ) { 871bool MainWindow::remove( int uid ) {
878 if (m_syncing) return false; 872 if (m_syncing) return false;
879 873
880 /* argh need to get the whole OEvent... to disable alarms -zecke */ 874 /* argh need to get the whole OEvent... to disable alarms -zecke */
881 handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); 875 handleAlarms( OPimTodo(), m_todoMgr.event( uid ) );
882 876
883 return m_todoMgr.remove( uid ); 877 return m_todoMgr.remove( uid );
884} 878}
885void MainWindow::beam( int uid) { 879void MainWindow::beam( int uid) {
886 if( uid == 0 ) return; 880 if( uid == 0 ) return;
887 881
888 ::unlink( beamfile ); 882 ::unlink( beamfile );
889 m_todoMgr.load(); 883 m_todoMgr.load();
890 884
891 OPimTodo todo = event( uid ); 885 OPimTodo todo = event( uid );
892 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); 886 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) );
893 OPimTodoAccess acc( cal ); 887 OPimTodoAccess acc( cal );
894 acc.load(); 888 acc.load();
895 acc.add( todo ); 889 acc.add( todo );
896 acc.save(); 890 acc.save();
897 Ir* ir = new Ir(this ); 891 Ir* ir = new Ir(this );
898 connect(ir, SIGNAL(done(Ir*) ), 892 connect(ir, SIGNAL(done(Ir*) ),
899 this, SLOT(beamDone(Ir*) ) ); 893 this, SLOT(beamDone(Ir*) ) );
900 ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); 894 ir->send(beamfile, todo.summary(), "text/x-vCalendar" );
901} 895}
902void MainWindow::show( int uid ) { 896void MainWindow::show( int uid ) {
903 m_todoMgr.load(); // might not be loaded yet 897 m_todoMgr.load(); // might not be loaded yet
904 m_showing = true; 898 m_showing = true;
905 slotShow( uid ); 899 slotShow( uid );
906 raise(); 900 raise();
907 QPEApplication::setKeepRunning(); 901 QPEApplication::setKeepRunning();
908} 902}
909void MainWindow::edit( int uid ) { 903void MainWindow::edit( int uid ) {
910 m_todoMgr.load(); 904 m_todoMgr.load();
911 slotEdit( uid ); 905 slotEdit( uid );
912} 906}
913void MainWindow::add( const OPimRecord& rec) { 907void MainWindow::add( const OPimRecord& rec) {
914 if ( rec.rtti() != OPimTodo::rtti() ) return; 908 if ( rec.rtti() != OPimTodo::rtti() ) return;
915 m_todoMgr.load(); // might not be loaded 909 m_todoMgr.load(); // might not be loaded
916 910
917 const OPimTodo& todo = static_cast<const OPimTodo&>(rec); 911 const OPimTodo& todo = static_cast<const OPimTodo&>(rec);
918 912
919 m_todoMgr.add(todo ); 913 m_todoMgr.add(todo );
920 currentView()->addEvent( todo ); 914 currentView()->addEvent( todo );
921 915
922 916
923 // I'm afraid we must call this every time now, otherwise 917 // I'm afraid we must call this every time now, otherwise
924 // spend expensive time comparing all these strings... 918 // spend expensive time comparing all these strings...
925 // but only call if we changed something -zecke 919 // but only call if we changed something -zecke
926 populateCategories(); 920 populateCategories();
927} 921}
928void MainWindow::slotReturnFromView() { 922void MainWindow::slotReturnFromView() {
929 m_showing = false; 923 m_showing = false;
930 raiseCurrentView(); 924 raiseCurrentView();
931} 925}
932 926
933namespace { 927namespace {
934 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, 928 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls,
935 const OPimNotifyManager::Alarms& newAls ) { 929 const OPimNotifyManager::Alarms& newAls ) {
936 OPimNotifyManager::Alarms nonMatching; 930 OPimNotifyManager::Alarms nonMatching;
937 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); 931 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin();
938 OPimNotifyManager::Alarms::ConstIterator newIt; 932 OPimNotifyManager::Alarms::ConstIterator newIt;
939 for ( ; oldIt != oldAls.end(); ++oldIt ) { 933 for ( ; oldIt != oldAls.end(); ++oldIt ) {
940 bool found = false; 934 bool found = false;
941 QDateTime oldDt = (*oldIt).dateTime(); 935 QDateTime oldDt = (*oldIt).dateTime();
942 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { 936 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) {
943 if ( oldDt == (*newIt).dateTime() ) { 937 if ( oldDt == (*newIt).dateTime() ) {
944 found = true; 938 found = true;
945 break; 939 break;
946 } 940 }
947 } 941 }
948 if (!found) 942 if (!found)
949 nonMatching.append( (*oldIt) ); 943 nonMatching.append( (*oldIt) );
950 } 944 }
951 return nonMatching; 945 return nonMatching;
952 } 946 }
953 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 947 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
954 OPimNotifyManager::Alarms::ConstIterator it; 948 OPimNotifyManager::Alarms::ConstIterator it;
955 for ( it = als.begin(); it != als.end(); ++it ) { 949 for ( it = als.begin(); it != als.end(); ++it ) {
956 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() ); 950 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() );
957 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 951 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
958 } 952 }
959 953
960 } 954 }
961 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 955 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
962 OPimNotifyManager::Alarms::ConstIterator it; 956 OPimNotifyManager::Alarms::ConstIterator it;
963 for ( it = als.begin(); it != als.end(); ++it ) { 957 for ( it = als.begin(); it != als.end(); ++it ) {
964 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); 958 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() );
965 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 959 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
966 } 960 }
967 } 961 }
968} 962}
969 963
970void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { 964void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) {
971 /* 965 /*
972 * if oldTodo is not empty and has notifiers we need to find the deleted ones 966 * if oldTodo is not empty and has notifiers we need to find the deleted ones
973 */ 967 */
974 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { 968 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
975 OPimNotifyManager::Alarms removed; 969 OPimNotifyManager::Alarms removed;
976 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); 970 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
977 if (!newTodo.hasNotifiers() ) 971 if (!newTodo.hasNotifiers() )
978 removed = oldAls; 972 removed = oldAls;
979 else 973 else
980 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); 974 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
981 975
982 removeAlarms( removed, oldTodo.uid() ); 976 removeAlarms( removed, oldTodo.uid() );
983 } 977 }
984 if ( newTodo.hasNotifiers() ) { 978 if ( newTodo.hasNotifiers() ) {
985 OPimNotifyManager::Alarms added; 979 OPimNotifyManager::Alarms added;
986 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) 980 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
987 added = newTodo.notifiers().alarms(); 981 added = newTodo.notifiers().alarms();
988 else 982 else
989 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); 983 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
990 984
991 addAlarms( added, newTodo.uid() ); 985 addAlarms( added, newTodo.uid() );
992 } 986 }
993} 987}
994/* we might have not loaded the db */ 988/* we might have not loaded the db */
995void MainWindow::doAlarm( const QDateTime& dt, int uid ) { 989void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
996 m_todoMgr.load(); 990 m_todoMgr.load();
997 991
998 OPimTodo todo = m_todoMgr.event( uid ); 992 OPimTodo todo = m_todoMgr.event( uid );
999 if (!todo.hasNotifiers() ) return; 993 if (!todo.hasNotifiers() ) return;
1000 994
1001 /* 995 /*
1002 * let's find the right alarm and find out if silent 996 * let's find the right alarm and find out if silent
1003 * then show a richtext widget 997 * then show a richtext widget
1004 */ 998 */
1005 bool loud = false; 999 bool loud = false;
1006 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 1000 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
1007 OPimNotifyManager::Alarms::Iterator it; 1001 OPimNotifyManager::Alarms::Iterator it;
1008 for ( it = als.begin(); it != als.end(); ++it ) { 1002 for ( it = als.begin(); it != als.end(); ++it ) {
1009 if ( (*it).dateTime() == dt ) { 1003 if ( (*it).dateTime() == dt ) {
1010 loud = ( (*it).sound() == OPimAlarm::Loud ); 1004 loud = ( (*it).sound() == OPimAlarm::Loud );
1011 break; 1005 break;
1012 } 1006 }
1013 } 1007 }
1014 if (loud) 1008 if (loud)
1015 startAlarm(); 1009 startAlarm();
1016 1010
1017 QDialog dlg(this, 0, TRUE ); 1011 QDialog dlg(this, 0, TRUE );
1018 QVBoxLayout* lay = new QVBoxLayout( &dlg ); 1012 QVBoxLayout* lay = new QVBoxLayout( &dlg );
1019 QTextView* view = new QTextView( &dlg ); 1013 QTextView* view = new QTextView( &dlg );
1020 lay->addWidget( view ); 1014 lay->addWidget( view );
1021 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); 1015 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg );
1022 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); 1016 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) );
1023 lay->addWidget( btnOk ); 1017 lay->addWidget( btnOk );
1024 1018
1025 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); 1019 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) );
1026 text += todo.toRichText(); 1020 text += todo.toRichText();
1027 view->setText( text ); 1021 view->setText( text );
1028 1022
1029 bool needToStay = QPEApplication::execDialog( &dlg ); 1023 bool needToStay = QPEApplication::execDialog( &dlg );
1030 1024
1031 if (loud) 1025 if (loud)
1032 killAlarm(); 1026 killAlarm();
1033 1027
1034 if (needToStay) { 1028 if (needToStay) {
1035// showMaximized(); 1029// showMaximized();
1036// raise(); 1030// raise();
1037 QPEApplication::setKeepRunning(); 1031 QPEApplication::setKeepRunning();
1038// setActiveWindow(); 1032// setActiveWindow();
1039 } 1033 }
1040 1034
1041} 1035}
1042 1036