author | chicken <chicken> | 2004-03-01 17:39:51 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 17:39:51 (UTC) |
commit | bdac663be648746b868757a6fc9e6c443e6f51b1 (patch) (unidiff) | |
tree | 880ee397824e6e99317d8788856bb8cc781b6fe0 | |
parent | 5f6f3f7d9356e24ac5284b7ccc10a75451ea94ee (diff) | |
download | opie-bdac663be648746b868757a6fc9e6c443e6f51b1.zip opie-bdac663be648746b868757a6fc9e6c443e6f51b1.tar.gz opie-bdac663be648746b868757a6fc9e6c443e6f51b1.tar.bz2 |
fix includes
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 | ||
28 | AbLabel::AbLabel( QWidget *parent, const char *name ): | 25 | AbLabel::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 | ||
34 | AbLabel::~AbLabel() | 31 | AbLabel::~AbLabel() |
35 | { | 32 | { |
36 | } | 33 | } |
37 | 34 | ||
38 | void AbLabel::setContacts( const OContactAccess::List& viewList ) | 35 | void 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 | ||
52 | int AbLabel::currentEntry_UID() | 49 | int 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 | ||
62 | OContact AbLabel::currentEntry() | 59 | OContact 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 | ||
71 | bool AbLabel::selectContact( int UID ) | 68 | bool 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 | ||
88 | void AbLabel::sync() | 85 | void 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 | ||
94 | void AbLabel::keyPressEvent( QKeyEvent *e ) | 91 | void 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,420 +1,411 @@ | |||
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 | ||
55 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 46 | AbTableItem::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 | ||
63 | int AbTableItem::alignment() const | 54 | int AbTableItem::alignment() const |
64 | { | 55 | { |
65 | return AlignLeft|AlignVCenter; | 56 | return AlignLeft|AlignVCenter; |
66 | } | 57 | } |
67 | 58 | ||
68 | QString AbTableItem::key() const | 59 | QString 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... |
74 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 65 | void 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 | ||
88 | AbPickItem::AbPickItem( QTable *t ) : | 79 | AbPickItem::AbPickItem( QTable *t ) : |
89 | QTableItem(t, WhenCurrent, "?") | 80 | QTableItem(t, WhenCurrent, "?") |
90 | { | 81 | { |
91 | } | 82 | } |
92 | 83 | ||
93 | QWidget *AbPickItem::createEditor() const | 84 | QWidget *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 | ||
109 | void AbPickItem::setContentFromEditor( QWidget *w ) | 100 | void 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 | ||
125 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 116 | AbTable::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 | ||
146 | AbTable::~AbTable() | 137 | AbTable::~AbTable() |
147 | { | 138 | { |
148 | } | 139 | } |
149 | 140 | ||
150 | void AbTable::init() | 141 | void 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 | ||
163 | void AbTable::setContacts( const OContactAccess::List& viewList ) | 154 | void 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 | ||
189 | void AbTable::setOrderedList( const QValueList<int> ordered ) | 180 | void AbTable::setOrderedList( const QValueList<int> ordered ) |
190 | { | 181 | { |
191 | intFields = ordered; | 182 | intFields = ordered; |
192 | } | 183 | } |
193 | 184 | ||
194 | 185 | ||
195 | bool AbTable::selectContact( int UID ) | 186 | bool 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 |
225 | void AbTable::insertIntoTable( const OContact& cnt, int row ) | 216 | void 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 | ||
250 | void AbTable::columnClicked( int col ) | 241 | void 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 | ||
268 | void AbTable::resort() | 259 | void 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 | ||
284 | OContact AbTable::currentEntry() | 275 | OContact AbTable::currentEntry() |
285 | { | 276 | { |
286 | return m_viewList[currentRow()]; | 277 | return m_viewList[currentRow()]; |
287 | } | 278 | } |
288 | 279 | ||
289 | int AbTable::currentEntry_UID() | 280 | int AbTable::currentEntry_UID() |
290 | { | 281 | { |
291 | return ( currentEntry().uid() ); | 282 | return ( currentEntry().uid() ); |
292 | } | 283 | } |
293 | 284 | ||
294 | void AbTable::clear() | 285 | void 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 |
312 | void AbTable::refresh() | 303 | void 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 | ||
340 | void AbTable::keyPressEvent( QKeyEvent *e ) | 331 | void 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 | ||
368 | void AbTable::moveTo( char c ) | 359 | void 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) |
406 | QString AbTable::findContactName( const OContact &entry ) | 397 | QString 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 | ||
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,442 +1,426 @@ | |||
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 | ||
70 | extern QString addressbookPersonalVCardName(); | 54 | extern QString addressbookPersonalVCardName(); |
71 | 55 | ||
72 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 56 | AddressbookWindow::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 | ||
281 | void AddressbookWindow::slotConfig() | 265 | void 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 | ||
300 | void AddressbookWindow::slotSetFont( int size ) | 284 | void 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 | ||
335 | void AddressbookWindow::importvCard() { | 319 | void 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 | } |
342 | void AddressbookWindow::exportvCard() | 326 | void 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 | ||
367 | void AddressbookWindow::setDocument( const QString &filename ) | 351 | void 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 | ||
433 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 417 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
434 | { | 418 | { |
435 | QMainWindow::resizeEvent( e ); | 419 | QMainWindow::resizeEvent( e ); |
436 | 420 | ||
437 | 421 | ||
438 | } | 422 | } |
439 | 423 | ||
440 | AddressbookWindow::~AddressbookWindow() | 424 | AddressbookWindow::~AddressbookWindow() |
441 | { | 425 | { |
442 | ToolBarDock dock; | 426 | ToolBarDock dock; |
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 | ||
14 | ConfigDlg::ConfigDlg( QWidget *parent, const char *name): | 13 | ConfigDlg::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 | ||
44 | void ConfigDlg::slotItemUp() | 43 | void 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 | ||
58 | void ConfigDlg::slotItemDown() | 57 | void 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 | ||
71 | void ConfigDlg::slotItemAdd() | 70 | void 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 | ||
83 | void ConfigDlg::slotItemRemove() | 82 | void 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 | ||
93 | void ConfigDlg::setConfig( const AbConfig& cnf ) | 92 | void 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 | ||
129 | AbConfig ConfigDlg::getConfig() | 128 | AbConfig 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,431 +1,420 @@ | |||
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 | ||
53 | static inline bool containsAlphaNum( const QString &str ); | 42 | static inline bool containsAlphaNum( const QString &str ); |
54 | static inline bool constainsWhiteSpace( const QString &str ); | 43 | static 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... |
58 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 47 | void 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... |
62 | void parseEmailTo( const QString &strDefaultEmail, | 51 | void 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 | ||
86 | ContactEditor::~ContactEditor() { | 75 | ContactEditor::~ContactEditor() { |
87 | } | 76 | } |
88 | 77 | ||
89 | void ContactEditor::init() { | 78 | void 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" ) ); |
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 | ||
27 | OPIE_EXPORT_APP( OApplicationFactory<AddressbookWindow> ) | 26 | OPIE_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 | ||
8 | char PickerLabel::lastLetter = '\0'; | 6 | char PickerLabel::lastLetter = '\0'; |
9 | 7 | ||
10 | PickerLabel::PickerLabel( QWidget *parent, const char *name ) | 8 | PickerLabel::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 | ||
26 | PickerLabel::~PickerLabel() | 24 | PickerLabel::~PickerLabel() |
27 | { | 25 | { |
28 | 26 | ||
29 | } | 27 | } |
30 | 28 | ||
31 | void PickerLabel::setLetters( char ch1, char ch2, char ch3 ) | 29 | void 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 | ||
62 | void PickerLabel::clearLetter() | 60 | void 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 | ||
79 | void PickerLabel::mousePressEvent( QMouseEvent* e ) | 77 | void 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 | ||
88 | void PickerLabel::mouseReleaseEvent( QMouseEvent* /* e */ ) | 86 | void 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 | ||
151 | void PickerLabel::emitClearSignal() { | 149 | void PickerLabel::emitClearSignal() { |
152 | emit clearAll(); | 150 | emit clearAll(); |
153 | } | 151 | } |
154 | 152 | ||
155 | LetterPicker::LetterPicker( QWidget *parent, const char *name ) | 153 | LetterPicker::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 | ||
218 | LetterPicker::~LetterPicker() | 216 | LetterPicker::~LetterPicker() |
219 | { | 217 | { |
220 | } | 218 | } |
221 | 219 | ||
222 | QSizePolicy LetterPicker::sizePolicy () const | 220 | QSizePolicy LetterPicker::sizePolicy () const |
223 | { | 221 | { |
224 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum); | 222 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum); |
225 | } | 223 | } |
226 | 224 | ||
227 | void LetterPicker::clear() | 225 | void 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 | ||
240 | void LetterPicker::newLetter( char letter ) | 238 | void 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,448 +1,433 @@ | |||
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 | ||
73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 58 | DateBook::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 | ||
215 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 200 | void 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 | ||
239 | DateBook::~DateBook() | 224 | DateBook::~DateBook() |
240 | { | 225 | { |
241 | } | 226 | } |
242 | 227 | ||
243 | void DateBook::slotSettings() | 228 | void 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 | ||
300 | void DateBook::fileNew() | 285 | void DateBook::fileNew() |
301 | { | 286 | { |
302 | slotNewEventFromKey(""); | 287 | slotNewEventFromKey(""); |
303 | } | 288 | } |
304 | 289 | ||
305 | QString DateBook::checkEvent(const Event &e) | 290 | QString 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 | ||
333 | QDate DateBook::currentDate() | 318 | QDate 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 | ||
350 | void DateBook::view(int v, const QDate &d) { | 335 | void 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 | ||
378 | void DateBook::viewDefault(const QDate &d) { | 363 | void DateBook::viewDefault(const QDate &d) { |
379 | view(defaultView,d); | 364 | view(defaultView,d); |
380 | } | 365 | } |
381 | 366 | ||
382 | void DateBook::viewDay() { | 367 | void DateBook::viewDay() { |
383 | view(DAY,currentDate()); | 368 | view(DAY,currentDate()); |
384 | } | 369 | } |
385 | 370 | ||
386 | void DateBook::viewWeek() { | 371 | void DateBook::viewWeek() { |
387 | view(WEEK,currentDate()); | 372 | view(WEEK,currentDate()); |
388 | } | 373 | } |
389 | 374 | ||
390 | void DateBook::viewWeekLst() { | 375 | void DateBook::viewWeekLst() { |
391 | view(WEEKLST,currentDate()); | 376 | view(WEEKLST,currentDate()); |
392 | } | 377 | } |
393 | 378 | ||
394 | void DateBook::viewMonth() { | 379 | void DateBook::viewMonth() { |
395 | view(MONTH,currentDate()); | 380 | view(MONTH,currentDate()); |
396 | } | 381 | } |
397 | 382 | ||
398 | void DateBook::insertEvent( const Event &e ) | 383 | void 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 | ||
409 | void DateBook::duplicateEvent( const Event &e ) | 394 | void 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... |
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 | */ |
32 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) | 22 | DatebookdayAllday::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 | */ |
60 | DatebookdayAllday::~DatebookdayAllday() | 50 | DatebookdayAllday::~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 | ||
65 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) | 55 | DatebookAlldayDisp* 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 | ||
79 | void DatebookdayAllday::removeAllEvents() | 69 | void DatebookdayAllday::removeAllEvents() |
80 | { | 70 | { |
81 | subWidgets.clear(); | 71 | subWidgets.clear(); |
82 | item_count = 0; | 72 | item_count = 0; |
83 | } | 73 | } |
84 | 74 | ||
85 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, | 75 | DatebookAlldayDisp::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("<"),"<"); | 80 | strDesc = strDesc.replace(QRegExp("<"),"<"); |
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 | ||
100 | DatebookAlldayDisp::~DatebookAlldayDisp() | 90 | DatebookAlldayDisp::~DatebookAlldayDisp() |
101 | { | 91 | { |
102 | } | 92 | } |
103 | 93 | ||
104 | void DatebookAlldayDisp::beam_single_event() | 94 | void 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 | ||
157 | void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) | 147 | void 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 | ||
197 | DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) | 187 | DatebookEventDesc::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 | ||
206 | DatebookEventDesc::~DatebookEventDesc() | 196 | DatebookEventDesc::~DatebookEventDesc() |
207 | { | 197 | { |
208 | } | 198 | } |
209 | 199 | ||
210 | void DatebookEventDesc::mousePressEvent(QMouseEvent*) | 200 | void 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 | ||
216 | void DatebookEventDesc::disp_event(const Event&e) | 206 | void 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 | */ |
40 | DateBookDayHeader::DateBookDayHeader( bool useMonday, | 36 | DateBookDayHeader::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 | */ |
61 | DateBookDayHeader::~DateBookDayHeader() | 57 | DateBookDayHeader::~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 | ||
66 | void DateBookDayHeader::setStartOfWeek( bool onMonday ) | 62 | void 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 | ||
73 | void DateBookDayHeader::setupNames() | 69 | void 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 | ||
95 | void DateBookDayHeader::pickDate() | 91 | void 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 | ||
113 | void DateBookDayHeader::gotHide() | 109 | void 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 | */ |
122 | void DateBookDayHeader::goBack() | 118 | void 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 | */ |
130 | void DateBookDayHeader::goForward() | 126 | void 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 | */ |
138 | void DateBookDayHeader::goBackWeek() | 134 | void 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 | */ |
146 | void DateBookDayHeader::goForwardWeek() | 142 | void 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 | */ |
156 | void DateBookDayHeader::setDate( int y, int m, int d ) | 152 | void 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 | */ |
176 | void DateBookDayHeader::setDay( int day ) | 172 | void 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 | ||
29 | DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, | 28 | DateBookSettings::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 | ||
40 | DateBookSettings::~DateBookSettings() | 39 | DateBookSettings::~DateBookSettings() |
41 | { | 40 | { |
42 | } | 41 | } |
43 | 42 | ||
44 | void DateBookSettings::setStartTime( int newStartViewTime ) | 43 | void 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 | ||
62 | int DateBookSettings::startTime() const | 61 | int 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 | ||
75 | void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) | 74 | void 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 | ||
82 | bool DateBookSettings::alarmPreset() const | 81 | bool DateBookSettings::alarmPreset() const |
83 | { | 82 | { |
84 | return chkAlarmPreset->isChecked(); | 83 | return chkAlarmPreset->isChecked(); |
85 | } | 84 | } |
86 | 85 | ||
87 | int DateBookSettings::presetTime() const | 86 | int DateBookSettings::presetTime() const |
88 | { | 87 | { |
89 | return spinPreset->value(); | 88 | return spinPreset->value(); |
90 | } | 89 | } |
91 | 90 | ||
92 | 91 | ||
93 | void DateBookSettings::slot12Hour( int i ) | 92 | void 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 | ||
107 | void DateBookSettings::init() | 106 | void 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 | ||
122 | void DateBookSettings::slotChangeClock( bool whichClock ) | 121 | void 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 | ||
138 | void DateBookSettings::setJumpToCurTime( bool bJump ) | 137 | void DateBookSettings::setJumpToCurTime( bool bJump ) |
139 | { | 138 | { |
140 | chkJumpToCurTime->setChecked( bJump ); | 139 | chkJumpToCurTime->setChecked( bJump ); |
141 | } | 140 | } |
142 | 141 | ||
143 | bool DateBookSettings::jumpToCurTime() const | 142 | bool DateBookSettings::jumpToCurTime() const |
144 | { | 143 | { |
145 | return chkJumpToCurTime->isChecked(); | 144 | return chkJumpToCurTime->isChecked(); |
146 | } | 145 | } |
147 | 146 | ||
148 | void DateBookSettings::setRowStyle( int style ) | 147 | void DateBookSettings::setRowStyle( int style ) |
149 | { | 148 | { |
150 | comboRowStyle->setCurrentItem( style ); | 149 | comboRowStyle->setCurrentItem( style ); |
151 | } | 150 | } |
152 | 151 | ||
153 | int DateBookSettings::rowStyle() const | 152 | int 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 | */ |
35 | DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, const char* name, WFlags fl ) | 31 | DateBookWeekHeader::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 | */ |
50 | DateBookWeekHeader::~DateBookWeekHeader() | 46 | DateBookWeekHeader::~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 | ||
55 | void DateBookWeekHeader::pickDate() | 51 | void 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 | ||
71 | void DateBookWeekHeader::nextMonth() | 67 | void DateBookWeekHeader::nextMonth() |
72 | { | 68 | { |
73 | qWarning("nextMonth() " ); | 69 | qWarning("nextMonth() " ); |
74 | setDate(date.addDays(28)); | 70 | setDate(date.addDays(28)); |
75 | } | 71 | } |
76 | void DateBookWeekHeader::prevMonth() | 72 | void DateBookWeekHeader::prevMonth() |
77 | { | 73 | { |
78 | qWarning("prevMonth() " ); | 74 | qWarning("prevMonth() " ); |
79 | setDate(date.addDays(-28)); | 75 | setDate(date.addDays(-28)); |
80 | } | 76 | } |
81 | void DateBookWeekHeader::nextWeek() | 77 | void DateBookWeekHeader::nextWeek() |
82 | { | 78 | { |
83 | qWarning("nextWeek() " ); | 79 | qWarning("nextWeek() " ); |
84 | setDate(date.addDays(7)); | 80 | setDate(date.addDays(7)); |
85 | } | 81 | } |
86 | void DateBookWeekHeader::prevWeek() | 82 | void DateBookWeekHeader::prevWeek() |
87 | { | 83 | { |
88 | qWarning("prevWeek() "); | 84 | qWarning("prevWeek() "); |
89 | setDate(date.addDays(-7)); | 85 | setDate(date.addDays(-7)); |
90 | } | 86 | } |
91 | 87 | ||
92 | void DateBookWeekHeader::setDate( int y, int m, int d ) | 88 | void 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 | ||
97 | void DateBookWeekHeader::setDate(const QDate &d) { | 93 | void 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 | ||
120 | void DateBookWeekHeader::setStartOfWeek( bool onMonday ) | 116 | void 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,393 +1,392 @@ | |||
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 | ||
15 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); | 14 | bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false); |
16 | 15 | ||
17 | DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl) | 16 | DateBookWeekLstHeader::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 | } |
43 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} | 42 | DateBookWeekLstHeader::~DateBookWeekLstHeader(){} |
44 | 43 | ||
45 | void DateBookWeekLstHeader::setDate(const QDate &d) { | 44 | void 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 | ||
69 | void DateBookWeekLstHeader::pickDate() { | 68 | void 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 | } |
84 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { | 83 | void DateBookWeekLstHeader::setDate(int y, int m, int d) { |
85 | setDate(QDate(y,m,d)); | 84 | setDate(QDate(y,m,d)); |
86 | } | 85 | } |
87 | 86 | ||
88 | void DateBookWeekLstHeader::nextWeek() { | 87 | void DateBookWeekLstHeader::nextWeek() { |
89 | setDate(date.addDays(7)); | 88 | setDate(date.addDays(7)); |
90 | } | 89 | } |
91 | void DateBookWeekLstHeader::prevWeek() { | 90 | void DateBookWeekLstHeader::prevWeek() { |
92 | setDate(date.addDays(-7)); | 91 | setDate(date.addDays(-7)); |
93 | } | 92 | } |
94 | void DateBookWeekLstHeader::nextMonth() | 93 | void DateBookWeekLstHeader::nextMonth() |
95 | { | 94 | { |
96 | setDate(date.addDays(28)); | 95 | setDate(date.addDays(28)); |
97 | } | 96 | } |
98 | void DateBookWeekLstHeader::prevMonth() | 97 | void DateBookWeekLstHeader::prevMonth() |
99 | { | 98 | { |
100 | setDate(date.addDays(-28)); | 99 | setDate(date.addDays(-28)); |
101 | } | 100 | } |
102 | 101 | ||
103 | DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, | 102 | DateBookWeekLstDayHdr::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 | ||
140 | void DateBookWeekLstDayHdr::showDay() { | 139 | void DateBookWeekLstDayHdr::showDay() { |
141 | emit showDate(date.year(), date.month(), date.day()); | 140 | emit showDate(date.year(), date.month(), date.day()); |
142 | } | 141 | } |
143 | 142 | ||
144 | void DateBookWeekLstDayHdr::newEvent() { | 143 | void 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 | } |
152 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 151 | DateBookWeekLstEvent::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 | } |
196 | void DateBookWeekLstEvent::editMe() { | 195 | void DateBookWeekLstEvent::editMe() { |
197 | emit editEvent(event.event()); | 196 | emit editEvent(event.event()); |
198 | } | 197 | } |
199 | 198 | ||
200 | 199 | ||
201 | DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, | 200 | DateBookWeekLstView::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 | } |
255 | DateBookWeekLstView::~DateBookWeekLstView(){} | 254 | DateBookWeekLstView::~DateBookWeekLstView(){} |
256 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} | 255 | void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} |
257 | 256 | ||
258 | DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, | 257 | DateBookWeekLstDblView::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 | ||
283 | DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, | 282 | DateBookWeekLst::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 | } |
311 | DateBookWeekLst::~DateBookWeekLst(){ | 310 | DateBookWeekLst::~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 | ||
317 | void DateBookWeekLst::setDate(const QDate &d) { | 316 | void DateBookWeekLst::setDate(const QDate &d) { |
318 | bdate=d; | 317 | bdate=d; |
319 | header->setDate(d); | 318 | header->setDate(d); |
320 | } | 319 | } |
321 | 320 | ||
322 | void DateBookWeekLst::setDbl(bool on) { | 321 | void DateBookWeekLst::setDbl(bool on) { |
323 | dbl=on; | 322 | dbl=on; |
324 | redraw(); | 323 | redraw(); |
325 | } | 324 | } |
326 | void DateBookWeekLst::redraw() {getEvents();} | 325 | void DateBookWeekLst::redraw() {getEvents();} |
327 | 326 | ||
328 | QDate DateBookWeekLst::date() { | 327 | QDate 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 |
334 | QDate DateBookWeekLst::weekDate() const | 333 | QDate 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 | ||
347 | void DateBookWeekLst::getEvents() { | 346 | void 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 | ||
372 | void DateBookWeekLst::dateChanged(QDate &newdate) { | 371 | void DateBookWeekLst::dateChanged(QDate &newdate) { |
373 | bdate=newdate; | 372 | bdate=newdate; |
374 | getEvents(); | 373 | getEvents(); |
375 | } | 374 | } |
376 | 375 | ||
377 | void DateBookWeekLst::keyPressEvent(QKeyEvent *e) | 376 | void 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(); |
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,425 +1,414 @@ | |||
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 | ||
57 | DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, | 46 | DateEntry::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 | ||
70 | bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) | 59 | bool 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 | ||
100 | static void addOrPick( QComboBox* combo, const QString& t ) | 89 | static 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 | ||
115 | DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, | 104 | DateEntry::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 | ||
144 | void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) | 133 | void 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 | ||
157 | void DateEntry::updateTimeEdit(bool s, bool e) { | 146 | void 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 | ||
194 | void DateEntry::init() | 183 | void 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 | */ |
235 | DateEntry::~DateEntry() | 224 | DateEntry::~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 | ||
245 | void DateEntry::slotEditNote() { | 234 | void 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( ¬eDlg ) ) { | 241 | if ( QPEApplication::execDialog( ¬eDlg ) ) { |
253 | noteStr=noteDlg.note->text(); | 242 | noteStr=noteDlg.note->text(); |
254 | } | 243 | } |
255 | 244 | ||
256 | } | 245 | } |
257 | 246 | ||
258 | void DateEntry::endDateChanged( int y, int m, int d ) | 247 | void 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 | ||
270 | static QTime parseTime( const QString& s, bool ampm ) | 259 | static 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 | */ |
306 | void DateEntry::endTimeChanged( const QString &s ) | 295 | void DateEntry::endTimeChanged( const QString &s ) |
307 | { | 296 | { |
308 | endTimeChanged( parseTime(s,ampm) ); | 297 | endTimeChanged( parseTime(s,ampm) ); |
309 | } | 298 | } |
310 | 299 | ||
311 | void DateEntry::endTimeChanged( const QTime &t ) { | 300 | void 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 | */ |
325 | void DateEntry::startDateChanged( int y, int m, int d ) | 314 | void 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 | */ |
348 | void DateEntry::startTimeEdited( const QString &s ) | 337 | void 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 | ||
356 | void DateEntry::startTimeChanged( const QTime &t ) | 345 | void 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 | } |
362 | void DateEntry::startTimePicked( const QTime &t ) { | 351 | void 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 | */ |
375 | void DateEntry::typeChanged( const QString &s ) | 364 | void 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 | ||
383 | void DateEntry::slotRepeat() | 372 | void 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 | ||
403 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) | 392 | void DateEntry::slotChangeStartOfWeek( bool onMonday ) |
404 | { | 393 | { |
405 | startWeekOnMonday = onMonday; | 394 | startWeekOnMonday = onMonday; |
406 | } | 395 | } |
407 | 396 | ||
408 | Event DateEntry::event() | 397 | Event 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 | ||
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 | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<DateBook> ) | 24 | OPIE_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 | ||
7 | NoteEntry::NoteEntry(const QString &title, const QString ¬eStr, | 5 | NoteEntry::NoteEntry(const QString &title, const QString ¬eStr, |
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,415 +1,411 @@ | |||
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 |
37 | namespace { | 33 | namespace { |
38 | QString strDayTemplate; | 34 | QString strDayTemplate; |
39 | QString strYearTemplate; | 35 | QString strYearTemplate; |
40 | QString strMonthDateTemplate; | 36 | QString strMonthDateTemplate; |
41 | QString strMonthDayTemplate; | 37 | QString strMonthDayTemplate; |
42 | QString strWeekTemplate; | 38 | QString strWeekTemplate; |
43 | QString dayLabel[7]; | 39 | QString 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 | */ |
52 | static void fillStrings() { | 48 | static 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) |
69 | static int week( const QDate &dt ); // what week in the month is dt? | 65 | static int week( const QDate &dt ); // what week in the month is dt? |
70 | 66 | ||
71 | RepeatEntry::RepeatEntry( bool startOnMonday, | 67 | RepeatEntry::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 | ||
88 | RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, | 84 | RepeatEntry::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 | ||
156 | RepeatEntry::~RepeatEntry() | 152 | RepeatEntry::~RepeatEntry() |
157 | { | 153 | { |
158 | } | 154 | } |
159 | 155 | ||
160 | Event::RepeatPattern RepeatEntry::repeatPattern() | 156 | Event::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 | ||
217 | void RepeatEntry::slotSetRType( int rtype ) | 213 | void 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 | ||
243 | void RepeatEntry::setupNone() | 239 | void 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 | ||
258 | void RepeatEntry::setupDaily() | 254 | void 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 | ||
270 | void RepeatEntry::setupWeekly() | 266 | void 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 | ||
324 | void RepeatEntry::setupMonthly() | 320 | void 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 | ||
342 | void RepeatEntry::setupYearly() | 338 | void 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 | ||
358 | void RepeatEntry::init() | 354 | void 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 | ||
388 | void RepeatEntry::slotNoEnd( bool unused ) | 384 | void 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 | ||
400 | void RepeatEntry::endDateChanged( int y, int m, int d ) | 396 | void 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 | ||
409 | void RepeatEntry::setupRepeatLabel( const QString &s ) | 405 | void RepeatEntry::setupRepeatLabel( const QString &s ) |
410 | { | 406 | { |
411 | lblVar1->setText( s ); | 407 | lblVar1->setText( s ); |
412 | } | 408 | } |
413 | 409 | ||
414 | void RepeatEntry::setupRepeatLabel( int x ) | 410 | void RepeatEntry::setupRepeatLabel( int x ) |
415 | { | 411 | { |
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 | ||
22 | AdressSearch::AdressSearch(QListView* parent, QString name): | 20 | AdressSearch::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 | ||
39 | AdressSearch::~AdressSearch() | 37 | AdressSearch::~AdressSearch() |
40 | { | 38 | { |
41 | delete _contacts; | 39 | delete _contacts; |
42 | } | 40 | } |
43 | 41 | ||
44 | void AdressSearch::load() | 42 | void AdressSearch::load() |
45 | { | 43 | { |
46 | _contacts = new OPimContactAccess("osearch"); | 44 | _contacts = new OPimContactAccess("osearch"); |
47 | } | 45 | } |
48 | 46 | ||
49 | int AdressSearch::search() | 47 | int 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 | ||
58 | void AdressSearch::insertItem( void* ) | 56 | void 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 | ||
20 | AppLnkItem::AppLnkItem(OListViewItem* parent, AppLnk *app) | 19 | AppLnkItem::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 | ||
29 | AppLnkItem::~AppLnkItem() | 28 | AppLnkItem::~AppLnkItem() |
30 | { | 29 | { |
31 | } | 30 | } |
32 | 31 | ||
33 | 32 | ||
34 | QString AppLnkItem::toRichText() | 33 | QString 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 | ||
45 | void AppLnkItem::action( int act ) | 44 | void 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 | ||
55 | QIntDict<QString> AppLnkItem::actions() | 54 | QIntDict<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 | ||
22 | AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) | 21 | AppLnkSearch::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 | ||
31 | AppLnkSearch::~AppLnkSearch() | 30 | AppLnkSearch::~AppLnkSearch() |
32 | { | 31 | { |
33 | delete _apps; | 32 | delete _apps; |
34 | } | 33 | } |
35 | 34 | ||
36 | 35 | ||
37 | void AppLnkSearch::load() | 36 | void AppLnkSearch::load() |
38 | { | 37 | { |
39 | _apps = new AppLnkSet(QPEApplication::qpeDir()); | 38 | _apps = new AppLnkSet(QPEApplication::qpeDir()); |
40 | } | 39 | } |
41 | 40 | ||
42 | int AppLnkSearch::search() | 41 | int 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 | ||
59 | void AppLnkSearch::insertItem( void *rec ) | 58 | void 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 | ||
65 | void AppLnkSearch::setSearch(QRegExp re) | 64 | void 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 | ||
21 | ContactItem::ContactItem(OListViewItem* parent, OPimContact *contact) | 20 | ContactItem::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 | ||
29 | void ContactItem::setIcon() | 28 | void 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 | ||
112 | ContactItem::~ContactItem() | 111 | ContactItem::~ContactItem() |
113 | { | 112 | { |
114 | delete _contact; | 113 | delete _contact; |
115 | } | 114 | } |
116 | 115 | ||
117 | 116 | ||
118 | QString ContactItem::toRichText() | 117 | QString ContactItem::toRichText() |
119 | { | 118 | { |
120 | return _contact->toRichText(); | 119 | return _contact->toRichText(); |
121 | } | 120 | } |
122 | 121 | ||
123 | void ContactItem::action( int act ) | 122 | void ContactItem::action( int act ) |
124 | { | 123 | { |
125 | if (act == 0){ | 124 | if (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 | ||
135 | QIntDict<QString> ContactItem::actions() | 134 | QIntDict<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 | ||
30 | DatebookSearch::DatebookSearch(QListView* parent, QString name) | 28 | DatebookSearch::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 | ||
43 | DatebookSearch::~DatebookSearch() | 41 | DatebookSearch::~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 | ||
57 | void DatebookSearch::load() | 55 | void DatebookSearch::load() |
58 | { | 56 | { |
59 | _dates = new ODateBookAccess(); | 57 | _dates = new ODateBookAccess(); |
60 | _dates->load(); | 58 | _dates->load(); |
61 | } | 59 | } |
62 | 60 | ||
63 | int DatebookSearch::search() | 61 | int 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 | ||
71 | void DatebookSearch::insertItem( void *rec ) | 69 | void 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 | ||
86 | QPopupMenu* DatebookSearch::popupMenu() | 84 | QPopupMenu* 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 | ||
22 | DocLnkItem::DocLnkItem(OListViewItem* parent, DocLnk *app) | 21 | DocLnkItem::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 | ||
30 | DocLnkItem::~DocLnkItem() | 29 | DocLnkItem::~DocLnkItem() |
31 | { | 30 | { |
32 | } | 31 | } |
33 | 32 | ||
34 | QString DocLnkItem::toRichText() | 33 | QString 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 | ||
63 | void DocLnkItem::action( int act ) | 62 | void 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 | ||
74 | QIntDict<QString> DocLnkItem::actions() | 73 | QIntDict<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 | ||
32 | DocLnkSearch::DocLnkSearch(QListView* parent, QString name) | 31 | DocLnkSearch::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 | ||
45 | DocLnkSearch::~DocLnkSearch() | 44 | DocLnkSearch::~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 | ||
52 | void DocLnkSearch::load() | 51 | void DocLnkSearch::load() |
53 | { | 52 | { |
54 | _apps = new DocLnkSet(QPEApplication::documentDir()); | 53 | _apps = new DocLnkSet(QPEApplication::documentDir()); |
55 | } | 54 | } |
56 | 55 | ||
57 | bool DocLnkSearch::searchFile( AppLnk *app ) | 56 | bool 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 | ||
81 | void DocLnkSearch::insertItem( void *rec ) | 80 | void 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 | ||
88 | QPopupMenu* DocLnkSearch::popupMenu() | 87 | QPopupMenu* 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 | ||
22 | EventItem::EventItem(OListViewItem* parent, OPimEvent *event) | 20 | EventItem::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 | ||
31 | EventItem::~EventItem() | 29 | EventItem::~EventItem() |
32 | { | 30 | { |
33 | } | 31 | } |
34 | 32 | ||
35 | 33 | ||
36 | QString EventItem::toRichText() | 34 | QString EventItem::toRichText() |
37 | { | 35 | { |
38 | return _event->toRichText(); | 36 | return _event->toRichText(); |
39 | } | 37 | } |
40 | 38 | ||
41 | void EventItem::action( int act ) | 39 | void 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 | ||
52 | QIntDict<QString> EventItem::actions() | 50 | QIntDict<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 | ||
60 | void EventItem::setIcon() | 58 | void 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 | ||
7 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 6 | OPIE_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 | ||
55 | static const char* const image1_data[] = { | 55 | static 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 | ||
76 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 76 | MainWindow::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 | ||
139 | void MainWindow::makeMenu() | 139 | void 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 | ||
209 | MainWindow::~MainWindow() | 209 | MainWindow::~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 | ||
218 | void MainWindow::setCurrent(QListViewItem *item) | 218 | void 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 | ||
256 | void MainWindow::stopTimer(QListViewItem*) | 256 | void MainWindow::stopTimer(QListViewItem*) |
257 | { | 257 | { |
258 | popupTimer->stop(); | 258 | popupTimer->stop(); |
259 | } | 259 | } |
260 | 260 | ||
261 | void MainWindow::showPopup() | 261 | void 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 | ||
269 | void MainWindow::setSearch( const QString &key ) | 269 | void 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 | ||
276 | void MainWindow::searchStringChanged() | 276 | void 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 | ||
294 | void MainWindow::searchAll() | 294 | void 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 | ||
305 | void MainWindow::slotAction( int act ) | 305 | void 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 | ||
314 | void MainWindow::optionChanged(int ) | 314 | void 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 | ||
19 | OListView::OListView(QWidget *parent, const char *name ) | 18 | OListView::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 | ||
32 | OListView::~OListView() | 31 | OListView::~OListView() |
33 | { | 32 | { |
34 | } | 33 | } |
35 | 34 | ||
36 | void OListView::expand(QListViewItem *item) | 35 | void 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 | ||
18 | ResultItem::ResultItem(OListViewItem* parent) | 17 | ResultItem::ResultItem(OListViewItem* parent) |
19 | : OListViewItem(parent) | 18 | : OListViewItem(parent) |
20 | { | 19 | { |
21 | 20 | ||
22 | } | 21 | } |
23 | 22 | ||
24 | 23 | ||
25 | ResultItem::~ResultItem() | 24 | ResultItem::~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 |
23 | static OWait *wait = 0; | 20 | static OWait *wait = 0; |
24 | #endif | 21 | #endif |
25 | 22 | ||
26 | SearchGroup::SearchGroup(QListView* parent, QString name) | 23 | SearchGroup::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 | ||
34 | SearchGroup::~SearchGroup() | 31 | SearchGroup::~SearchGroup() |
35 | { | 32 | { |
36 | } | 33 | } |
37 | 34 | ||
38 | 35 | ||
39 | void SearchGroup::expand() | 36 | void 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 | ||
53 | void SearchGroup::doSearch() | 50 | void 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 | ||
61 | void SearchGroup::setSearch(QRegExp re) | 58 | void 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 | ||
70 | int SearchGroup::realSearch() | 67 | int 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 | ||
22 | TodoItem::TodoItem(OListViewItem* parent, OPimTodo *todo) | 21 | TodoItem::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 | ||
30 | TodoItem::~TodoItem() | 29 | TodoItem::~TodoItem() |
31 | { | 30 | { |
32 | delete _todo; | 31 | delete _todo; |
33 | } | 32 | } |
34 | 33 | ||
35 | QString TodoItem::toRichText() | 34 | QString TodoItem::toRichText() |
36 | { | 35 | { |
37 | return _todo->toRichText(); | 36 | return _todo->toRichText(); |
38 | } | 37 | } |
39 | 38 | ||
40 | void TodoItem::action( int act ) | 39 | void 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 | ||
51 | QIntDict<QString> TodoItem::actions() | 50 | QIntDict<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 | ||
59 | void TodoItem::setIcon() | 58 | void 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 | ||
24 | TodoSearch::TodoSearch(QListView* parent, QString name) | 23 | TodoSearch::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 | ||
39 | TodoSearch::~TodoSearch() | 38 | TodoSearch::~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 | ||
50 | void TodoSearch::load() | 49 | void TodoSearch::load() |
51 | { | 50 | { |
52 | _todos = new OPimTodoAccess(); | 51 | _todos = new OPimTodoAccess(); |
53 | _todos->load(); | 52 | _todos->load(); |
54 | } | 53 | } |
55 | 54 | ||
56 | int TodoSearch::search() | 55 | int 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 | ||
64 | void TodoSearch::insertItem( void *rec ) | 63 | void 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 | ||
73 | QPopupMenu* TodoSearch::popupMenu() | 72 | QPopupMenu* 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,408 +1,407 @@ | |||
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 | ||
32 | struct TodayPlugin { | 31 | struct 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 | ||
44 | static QValueList<TodayPlugin> pluginList; | 43 | static QValueList<TodayPlugin> pluginList; |
45 | 44 | ||
46 | static QMap<QString, TodayPlugin> tempList; | 45 | static QMap<QString, TodayPlugin> tempList; |
47 | 46 | ||
48 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 47 | Today::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 | */ |
89 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 88 | void 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 | ||
98 | void Today::setRefreshTimer( int interval ) { | 97 | void 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 | */ |
113 | void Today::setOwnerField() { | 112 | void 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 | */ |
127 | void Today::setOwnerField( QString &message ) { | 126 | void 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 | */ |
136 | void Today::init() { | 135 | void 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 | */ |
173 | void Today::loadPlugins() { | 172 | void 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 | */ |
303 | void Today::draw() { | 302 | void 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 | */ |
339 | void Today::startConfig() { | 338 | void 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 | ||
386 | void Today::reinitialize() { | 385 | void 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 | } |
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,439 +1,433 @@ | |||
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 | ||
67 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 61 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
68 | 62 | ||
69 | using namespace Todo; | 63 | using namespace Todo; |
70 | 64 | ||
71 | MainWindow::MainWindow( QWidget* parent, | 65 | MainWindow::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 | } |
96 | void MainWindow::initTemplate() { | 90 | void MainWindow::initTemplate() { |
97 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 91 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
98 | } | 92 | } |
99 | void MainWindow::initActions() { | 93 | void 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 */ |
218 | void MainWindow::initConfig() { | 212 | void 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 | } |
227 | void MainWindow::initUI() { | 221 | void 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 | } |
255 | void MainWindow::initViews() { | 249 | void 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 | } |
268 | void MainWindow::initEditor() { | 262 | void MainWindow::initEditor() { |
269 | m_curEdit = new Editor(); | 263 | m_curEdit = new Editor(); |
270 | } | 264 | } |
271 | void MainWindow::initShow() { | 265 | void 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 | } |
275 | MainWindow::~MainWindow() { | 269 | MainWindow::~MainWindow() { |
276 | delete templateManager(); | 270 | delete templateManager(); |
277 | } | 271 | } |
278 | void MainWindow::connectBase( ViewBase* ) { | 272 | void 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 | } |
281 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 275 | QPopupMenu* 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 | } |
301 | QPopupMenu* MainWindow::options() { | 295 | QPopupMenu* MainWindow::options() { |
302 | qWarning("Options"); | 296 | qWarning("Options"); |
303 | return m_options; | 297 | return m_options; |
304 | } | 298 | } |
305 | QPopupMenu* MainWindow::edit() { | 299 | QPopupMenu* MainWindow::edit() { |
306 | return m_edit; | 300 | return m_edit; |
307 | } | 301 | } |
308 | QToolBar* MainWindow::toolbar() { | 302 | QToolBar* MainWindow::toolbar() { |
309 | return m_tool; | 303 | return m_tool; |
310 | } | 304 | } |
311 | OPimTodoAccess::List MainWindow::list()const { | 305 | OPimTodoAccess::List MainWindow::list()const { |
312 | return m_todoMgr.list(); | 306 | return m_todoMgr.list(); |
313 | } | 307 | } |
314 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 308 | OPimTodoAccess::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 | } |
332 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 326 | OPimTodoAccess::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 | } |
342 | OPimTodo MainWindow::event( int uid ) { | 336 | OPimTodo MainWindow::event( int uid ) { |
343 | return m_todoMgr.event( uid ); | 337 | return m_todoMgr.event( uid ); |
344 | } | 338 | } |
345 | bool MainWindow::isSyncing()const { | 339 | bool MainWindow::isSyncing()const { |
346 | return m_syncing; | 340 | return m_syncing; |
347 | } | 341 | } |
348 | TemplateManager* MainWindow::templateManager() { | 342 | TemplateManager* MainWindow::templateManager() { |
349 | return m_tempManager; | 343 | return m_tempManager; |
350 | } | 344 | } |
351 | Editor* MainWindow::currentEditor() { | 345 | Editor* MainWindow::currentEditor() { |
352 | return m_curEdit; | 346 | return m_curEdit; |
353 | } | 347 | } |
354 | TodoShow* MainWindow::currentShow() { | 348 | TodoShow* MainWindow::currentShow() { |
355 | return m_curShow; | 349 | return m_curShow; |
356 | } | 350 | } |
357 | void MainWindow::slotReload() { | 351 | void 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 | } |
363 | void MainWindow::closeEvent( QCloseEvent* e ) { | 357 | void 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 | } |
413 | void MainWindow::populateTemplates() { | 407 | void 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 | */ |
431 | void MainWindow::slotNewFromTemplate( int id ) { | 425 | void 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 */ |