author | zautrix <zautrix> | 2004-10-10 23:26:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-10 23:26:49 (UTC) |
commit | ea40295e233db219dc2431960e18fb4398ddb75c (patch) (unidiff) | |
tree | 1d654ae51d7f65f4375787105951a8f4f9fc359e | |
parent | 640874bb21ea348edb33a54690ad225e0efdd1e4 (diff) | |
download | kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.zip kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.tar.gz kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.tar.bz2 |
added better searching in kapi
-rw-r--r-- | kaddressbook/incsearchwidget.cpp | 8 | ||||
-rw-r--r-- | kaddressbook/incsearchwidget.h | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 3 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 2 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 11 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 20 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 17 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 18 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.h | 2 | ||||
-rw-r--r-- | microkde/klineedit.h | 29 |
13 files changed, 108 insertions, 10 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp index 3533427..78eaf65 100644 --- a/kaddressbook/incsearchwidget.cpp +++ b/kaddressbook/incsearchwidget.cpp | |||
@@ -1,161 +1,167 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | 28 | ||
29 | #include <kdialog.h> | 29 | #include <kdialog.h> |
30 | #include <klineedit.h> | 30 | #include <klineedit.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kglobal.h> | 33 | #include <kglobal.h> |
34 | #include "kabprefs.h" | 34 | #include "kabprefs.h" |
35 | 35 | ||
36 | #include "incsearchwidget.h" | 36 | #include "incsearchwidget.h" |
37 | 37 | ||
38 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) | 38 | IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) |
39 | : QWidget( parent, name ) | 39 | : QWidget( parent, name ) |
40 | { | 40 | { |
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | //US setCaption( i18n( "Incremental Search" ) ); | 42 | //US setCaption( i18n( "Incremental Search" ) ); |
43 | #endif //KAB_EMBEDDED | 43 | #endif //KAB_EMBEDDED |
44 | 44 | ||
45 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); | 45 | QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); |
46 | 46 | ||
47 | #ifdef DESKTOP_VERSION | 47 | #ifdef DESKTOP_VERSION |
48 | QLabel *label = new QLabel( i18n( "Search:" ), this ); | 48 | QLabel *label = new QLabel( i18n( "Search:" ), this ); |
49 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); | 49 | label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); |
50 | layout->addWidget( label ); | 50 | layout->addWidget( label ); |
51 | #endif //KAB_EMBEDDED | 51 | #endif //KAB_EMBEDDED |
52 | 52 | ||
53 | mSearchText = new KLineEdit( this ); | 53 | mSearchText = new KLineEdit( this ); |
54 | layout->addWidget( mSearchText ); | 54 | layout->addWidget( mSearchText ); |
55 | // #ifdef KAB_EMBEDDED | 55 | // #ifdef KAB_EMBEDDED |
56 | // if (KGlobal::getOrientation() == KGlobal::Portrait) | 56 | // if (KGlobal::getOrientation() == KGlobal::Portrait) |
57 | // mSearchText->setMaximumWidth(30); | 57 | // mSearchText->setMaximumWidth(30); |
58 | // #endif //KAB_EMBEDDED | 58 | // #endif //KAB_EMBEDDED |
59 | 59 | ||
60 | 60 | ||
61 | mFieldCombo = new QComboBox( false, this ); | 61 | mFieldCombo = new QComboBox( false, this ); |
62 | layout->addWidget( mFieldCombo ); | 62 | layout->addWidget( mFieldCombo ); |
63 | mFieldCombo->setMaximumHeight( 34 ); | 63 | mFieldCombo->setMaximumHeight( 34 ); |
64 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); | 64 | QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); |
65 | 65 | ||
66 | // #ifndef KAB_EMBEDDED | 66 | // #ifndef KAB_EMBEDDED |
67 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); | 67 | // resize( QSize(420, 50).expandedTo( sizeHint() ) ); |
68 | // #else //KAB_EMBEDDED | 68 | // #else //KAB_EMBEDDED |
69 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); | 69 | // resize( QSize(30, 10).expandedTo( sizeHint() ) ); |
70 | // #endif //KAB_EMBEDDED | 70 | // #endif //KAB_EMBEDDED |
71 | 71 | ||
72 | 72 | ||
73 | // for performance reasons, we do a search on the pda only after return is pressed | 73 | // for performance reasons, we do a search on the pda only after return is pressed |
74 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), | 74 | connect( mSearchText, SIGNAL( textChanged( const QString& ) ), |
75 | SLOT( announceDoSearch2() ) ); | 75 | SLOT( announceDoSearch2() ) ); |
76 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 76 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
77 | SLOT( announceDoSearch2() ) ); | 77 | SLOT( announceDoSearch2() ) ); |
78 | 78 | ||
79 | connect( mSearchText, SIGNAL( returnPressed() ), | 79 | connect( mSearchText, SIGNAL( returnPressed() ), |
80 | SLOT( announceDoSearch() ) ); | 80 | SLOT( announceDoSearch() ) ); |
81 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), | 81 | connect( mFieldCombo, SIGNAL( activated( const QString& ) ), |
82 | SLOT( announceFieldChanged() ) ); | 82 | SLOT( announceFieldChanged() ) ); |
83 | 83 | ||
84 | |||
85 | |||
86 | connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); | ||
87 | connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); | ||
88 | |||
89 | |||
84 | setFocusProxy( mSearchText ); | 90 | setFocusProxy( mSearchText ); |
85 | } | 91 | } |
86 | 92 | ||
87 | IncSearchWidget::~IncSearchWidget() | 93 | IncSearchWidget::~IncSearchWidget() |
88 | { | 94 | { |
89 | 95 | ||
90 | } | 96 | } |
91 | void IncSearchWidget::announceDoSearch2() | 97 | void IncSearchWidget::announceDoSearch2() |
92 | { | 98 | { |
93 | if ( KABPrefs::instance()->mSearchWithReturn ) | 99 | if ( KABPrefs::instance()->mSearchWithReturn ) |
94 | return; | 100 | return; |
95 | emit doSearch( mSearchText->text() ); | 101 | emit doSearch( mSearchText->text() ); |
96 | //qDebug("emit dosreach "); | 102 | //qDebug("emit dosreach "); |
97 | } | 103 | } |
98 | 104 | ||
99 | void IncSearchWidget::announceDoSearch() | 105 | void IncSearchWidget::announceDoSearch() |
100 | { | 106 | { |
101 | 107 | ||
102 | emit doSearch( mSearchText->text() ); | 108 | emit doSearch( mSearchText->text() ); |
103 | // qDebug("emit dosreach "); | 109 | // qDebug("emit dosreach "); |
104 | } | 110 | } |
105 | 111 | ||
106 | void IncSearchWidget::announceFieldChanged() | 112 | void IncSearchWidget::announceFieldChanged() |
107 | { | 113 | { |
108 | emit fieldChanged(); | 114 | emit fieldChanged(); |
109 | } | 115 | } |
110 | 116 | ||
111 | void IncSearchWidget::setFields( const KABC::Field::List &list ) | 117 | void IncSearchWidget::setFields( const KABC::Field::List &list ) |
112 | { | 118 | { |
113 | 119 | ||
114 | mFieldCombo->clear(); | 120 | mFieldCombo->clear(); |
115 | mFieldCombo->insertItem( i18n( "All Fields" ) ); | 121 | mFieldCombo->insertItem( i18n( "All Fields" ) ); |
116 | QFontMetrics fm ( mFieldCombo->font() ); | 122 | QFontMetrics fm ( mFieldCombo->font() ); |
117 | int wid = fm.width(i18n( "All Fields" ) ); | 123 | int wid = fm.width(i18n( "All Fields" ) ); |
118 | int max = wid; | 124 | int max = wid; |
119 | 125 | ||
120 | KABC::Field::List::ConstIterator it; | 126 | KABC::Field::List::ConstIterator it; |
121 | for ( it = list.begin(); it != list.end(); ++it ) { | 127 | for ( it = list.begin(); it != list.end(); ++it ) { |
122 | mFieldCombo->insertItem( (*it)->label() ); | 128 | mFieldCombo->insertItem( (*it)->label() ); |
123 | // wid = fm.width((*it)->label() ); | 129 | // wid = fm.width((*it)->label() ); |
124 | //if ( wid > max ) | 130 | //if ( wid > max ) |
125 | // max = wid; | 131 | // max = wid; |
126 | } | 132 | } |
127 | 133 | ||
128 | mFieldList = list; | 134 | mFieldList = list; |
129 | 135 | ||
130 | announceDoSearch(); | 136 | announceDoSearch(); |
131 | announceFieldChanged(); | 137 | announceFieldChanged(); |
132 | mFieldCombo->setMaximumWidth( wid+60 ); | 138 | mFieldCombo->setMaximumWidth( wid+60 ); |
133 | } | 139 | } |
134 | 140 | ||
135 | KABC::Field::List IncSearchWidget::fields() const | 141 | KABC::Field::List IncSearchWidget::fields() const |
136 | { | 142 | { |
137 | return mFieldList; | 143 | return mFieldList; |
138 | } | 144 | } |
139 | 145 | ||
140 | KABC::Field *IncSearchWidget::currentField()const | 146 | KABC::Field *IncSearchWidget::currentField()const |
141 | { | 147 | { |
142 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) | 148 | if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) |
143 | return 0; // for error or 'use all fields' | 149 | return 0; // for error or 'use all fields' |
144 | else | 150 | else |
145 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; | 151 | return mFieldList[ mFieldCombo->currentItem() - 1 ]; |
146 | } | 152 | } |
147 | 153 | ||
148 | void IncSearchWidget::setCurrentItem( int pos ) | 154 | void IncSearchWidget::setCurrentItem( int pos ) |
149 | { | 155 | { |
150 | mFieldCombo->setCurrentItem( pos ); | 156 | mFieldCombo->setCurrentItem( pos ); |
151 | announceFieldChanged(); | 157 | announceFieldChanged(); |
152 | } | 158 | } |
153 | 159 | ||
154 | int IncSearchWidget::currentItem() const | 160 | int IncSearchWidget::currentItem() const |
155 | { | 161 | { |
156 | 162 | ||
157 | return mFieldCombo->currentItem(); | 163 | return mFieldCombo->currentItem(); |
158 | } | 164 | } |
159 | #ifndef KAB_EMBEDDED | 165 | #ifndef KAB_EMBEDDED |
160 | #include "incsearchwidget.moc" | 166 | #include "incsearchwidget.moc" |
161 | #endif //KAB_EMBEDDED | 167 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/incsearchwidget.h b/kaddressbook/incsearchwidget.h index 5c95438..1546a51 100644 --- a/kaddressbook/incsearchwidget.h +++ b/kaddressbook/incsearchwidget.h | |||
@@ -1,74 +1,76 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef INCSEARCHWIDGET_H | 24 | #ifndef INCSEARCHWIDGET_H |
25 | #define INCSEARCHWIDGET_H | 25 | #define INCSEARCHWIDGET_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | 28 | ||
29 | #include <kabc/field.h> | 29 | #include <kabc/field.h> |
30 | 30 | ||
31 | class QComboBox; | 31 | class QComboBox; |
32 | class KLineEdit; | 32 | class KLineEdit; |
33 | 33 | ||
34 | class IncSearchWidget : public QWidget | 34 | class IncSearchWidget : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | IncSearchWidget( QWidget *parent, const char *name = 0 ); | 39 | IncSearchWidget( QWidget *parent, const char *name = 0 ); |
40 | ~IncSearchWidget(); | 40 | ~IncSearchWidget(); |
41 | 41 | ||
42 | void setFields( const KABC::Field::List &list ); | 42 | void setFields( const KABC::Field::List &list ); |
43 | KABC::Field::List fields() const; | 43 | KABC::Field::List fields() const; |
44 | 44 | ||
45 | KABC::Field *currentField() const; | 45 | KABC::Field *currentField() const; |
46 | 46 | ||
47 | void setCurrentItem( int pos ); | 47 | void setCurrentItem( int pos ); |
48 | int currentItem() const; | 48 | int currentItem() const; |
49 | 49 | ||
50 | signals: | 50 | signals: |
51 | void scrollUP(); | ||
52 | void scrollDOWN(); | ||
51 | /** | 53 | /** |
52 | This signal is emmited whenever the text in the input | 54 | This signal is emmited whenever the text in the input |
53 | widget is changed. You can get the sorting field by | 55 | widget is changed. You can get the sorting field by |
54 | @ref currentField. | 56 | @ref currentField. |
55 | */ | 57 | */ |
56 | void doSearch( const QString& text ); | 58 | void doSearch( const QString& text ); |
57 | 59 | ||
58 | /** | 60 | /** |
59 | This signal is emmited whenever the search field changes. | 61 | This signal is emmited whenever the search field changes. |
60 | */ | 62 | */ |
61 | void fieldChanged(); | 63 | void fieldChanged(); |
62 | 64 | ||
63 | private slots: | 65 | private slots: |
64 | void announceDoSearch(); | 66 | void announceDoSearch(); |
65 | void announceDoSearch2(); | 67 | void announceDoSearch2(); |
66 | void announceFieldChanged(); | 68 | void announceFieldChanged(); |
67 | 69 | ||
68 | private: | 70 | private: |
69 | QComboBox* mFieldCombo; | 71 | QComboBox* mFieldCombo; |
70 | KLineEdit* mSearchText; | 72 | KLineEdit* mSearchText; |
71 | KABC::Field::List mFieldList; | 73 | KABC::Field::List mFieldList; |
72 | }; | 74 | }; |
73 | 75 | ||
74 | #endif | 76 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index cd261f6..f2d4cd6 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1292,769 +1292,770 @@ void KABCore::setDetailsVisible( bool visible ) | |||
1292 | mViewManager->hide(); | 1292 | mViewManager->hide(); |
1293 | mDetails->show(); | 1293 | mDetails->show(); |
1294 | } | 1294 | } |
1295 | else { | 1295 | else { |
1296 | mViewManager->show(); | 1296 | mViewManager->show(); |
1297 | mDetails->hide(); | 1297 | mDetails->hide(); |
1298 | } | 1298 | } |
1299 | setJumpButtonBarVisible( !visible ); | 1299 | setJumpButtonBarVisible( !visible ); |
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | void KABCore::extensionChanged( int id ) | 1304 | void KABCore::extensionChanged( int id ) |
1305 | { | 1305 | { |
1306 | //change the details view only for non desktop systems | 1306 | //change the details view only for non desktop systems |
1307 | #ifndef DESKTOP_VERSION | 1307 | #ifndef DESKTOP_VERSION |
1308 | 1308 | ||
1309 | if (id == 0) | 1309 | if (id == 0) |
1310 | { | 1310 | { |
1311 | //the user disabled the extension. | 1311 | //the user disabled the extension. |
1312 | 1312 | ||
1313 | if (mMultipleViewsAtOnce) | 1313 | if (mMultipleViewsAtOnce) |
1314 | { // enable detailsview again | 1314 | { // enable detailsview again |
1315 | setDetailsVisible( true ); | 1315 | setDetailsVisible( true ); |
1316 | mActionDetails->setChecked( true ); | 1316 | mActionDetails->setChecked( true ); |
1317 | } | 1317 | } |
1318 | else | 1318 | else |
1319 | { //go back to the listview | 1319 | { //go back to the listview |
1320 | setDetailsVisible( false ); | 1320 | setDetailsVisible( false ); |
1321 | mActionDetails->setChecked( false ); | 1321 | mActionDetails->setChecked( false ); |
1322 | mActionDetails->setEnabled(true); | 1322 | mActionDetails->setEnabled(true); |
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | else | 1326 | else |
1327 | { | 1327 | { |
1328 | //the user enabled the extension. | 1328 | //the user enabled the extension. |
1329 | setDetailsVisible( false ); | 1329 | setDetailsVisible( false ); |
1330 | mActionDetails->setChecked( false ); | 1330 | mActionDetails->setChecked( false ); |
1331 | 1331 | ||
1332 | if (!mMultipleViewsAtOnce) | 1332 | if (!mMultipleViewsAtOnce) |
1333 | { | 1333 | { |
1334 | mActionDetails->setEnabled(false); | 1334 | mActionDetails->setEnabled(false); |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | mExtensionManager->setSelectionChanged(); | 1337 | mExtensionManager->setSelectionChanged(); |
1338 | 1338 | ||
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | #endif// DESKTOP_VERSION | 1341 | #endif// DESKTOP_VERSION |
1342 | 1342 | ||
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | 1345 | ||
1346 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1346 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1347 | { | 1347 | { |
1348 | 1348 | ||
1349 | if ( list.count() != 0 ) { | 1349 | if ( list.count() != 0 ) { |
1350 | KABC::Addressee::List::ConstIterator it; | 1350 | KABC::Addressee::List::ConstIterator it; |
1351 | for ( it = list.begin(); it != list.end(); ++it ) | 1351 | for ( it = list.begin(); it != list.end(); ++it ) |
1352 | mAddressBook->insertAddressee( *it ); | 1352 | mAddressBook->insertAddressee( *it ); |
1353 | if ( list.count() > 1 ) | 1353 | if ( list.count() > 1 ) |
1354 | setModified(); | 1354 | setModified(); |
1355 | else | 1355 | else |
1356 | setModifiedWOrefresh(); | 1356 | setModifiedWOrefresh(); |
1357 | } | 1357 | } |
1358 | if ( list.count() == 0 ) | 1358 | if ( list.count() == 0 ) |
1359 | mViewManager->refreshView(); | 1359 | mViewManager->refreshView(); |
1360 | else | 1360 | else |
1361 | mViewManager->refreshView( list[ 0 ].uid() ); | 1361 | mViewManager->refreshView( list[ 0 ].uid() ); |
1362 | 1362 | ||
1363 | 1363 | ||
1364 | 1364 | ||
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | QString KABCore::getNameByPhone( const QString &phone ) | 1367 | QString KABCore::getNameByPhone( const QString &phone ) |
1368 | { | 1368 | { |
1369 | #ifndef KAB_EMBEDDED | 1369 | #ifndef KAB_EMBEDDED |
1370 | QRegExp r( "[/*/-/ ]" ); | 1370 | QRegExp r( "[/*/-/ ]" ); |
1371 | QString localPhone( phone ); | 1371 | QString localPhone( phone ); |
1372 | 1372 | ||
1373 | bool found = false; | 1373 | bool found = false; |
1374 | QString ownerName = ""; | 1374 | QString ownerName = ""; |
1375 | KABC::AddressBook::Iterator iter; | 1375 | KABC::AddressBook::Iterator iter; |
1376 | KABC::PhoneNumber::List::Iterator phoneIter; | 1376 | KABC::PhoneNumber::List::Iterator phoneIter; |
1377 | KABC::PhoneNumber::List phoneList; | 1377 | KABC::PhoneNumber::List phoneList; |
1378 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1378 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1379 | phoneList = (*iter).phoneNumbers(); | 1379 | phoneList = (*iter).phoneNumbers(); |
1380 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1380 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1381 | ++phoneIter) { | 1381 | ++phoneIter) { |
1382 | // Get rid of separator chars so just the numbers are compared. | 1382 | // Get rid of separator chars so just the numbers are compared. |
1383 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1383 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1384 | ownerName = (*iter).formattedName(); | 1384 | ownerName = (*iter).formattedName(); |
1385 | found = true; | 1385 | found = true; |
1386 | } | 1386 | } |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | return ownerName; | 1390 | return ownerName; |
1391 | #else //KAB_EMBEDDED | 1391 | #else //KAB_EMBEDDED |
1392 | qDebug("KABCore::getNameByPhone finsih method"); | 1392 | qDebug("KABCore::getNameByPhone finsih method"); |
1393 | return ""; | 1393 | return ""; |
1394 | #endif //KAB_EMBEDDED | 1394 | #endif //KAB_EMBEDDED |
1395 | 1395 | ||
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | void KABCore::openConfigDialog() | 1398 | void KABCore::openConfigDialog() |
1399 | { | 1399 | { |
1400 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1400 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1401 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1401 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1402 | ConfigureDialog->addModule(kabcfg ); | 1402 | ConfigureDialog->addModule(kabcfg ); |
1403 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1403 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1404 | ConfigureDialog->addModule(kdelibcfg ); | 1404 | ConfigureDialog->addModule(kdelibcfg ); |
1405 | 1405 | ||
1406 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1406 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1407 | this, SLOT( configurationChanged() ) ); | 1407 | this, SLOT( configurationChanged() ) ); |
1408 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1408 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1409 | this, SLOT( configurationChanged() ) ); | 1409 | this, SLOT( configurationChanged() ) ); |
1410 | saveSettings(); | 1410 | saveSettings(); |
1411 | #ifndef DESKTOP_VERSION | 1411 | #ifndef DESKTOP_VERSION |
1412 | ConfigureDialog->showMaximized(); | 1412 | ConfigureDialog->showMaximized(); |
1413 | #endif | 1413 | #endif |
1414 | if ( ConfigureDialog->exec() ) | 1414 | if ( ConfigureDialog->exec() ) |
1415 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1415 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1416 | delete ConfigureDialog; | 1416 | delete ConfigureDialog; |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void KABCore::openLDAPDialog() | 1419 | void KABCore::openLDAPDialog() |
1420 | { | 1420 | { |
1421 | #ifndef KAB_EMBEDDED | 1421 | #ifndef KAB_EMBEDDED |
1422 | if ( !mLdapSearchDialog ) { | 1422 | if ( !mLdapSearchDialog ) { |
1423 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1423 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1424 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1424 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1425 | SLOT( refreshView() ) ); | 1425 | SLOT( refreshView() ) ); |
1426 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1426 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1427 | SLOT( setModified() ) ); | 1427 | SLOT( setModified() ) ); |
1428 | } else | 1428 | } else |
1429 | mLdapSearchDialog->restoreSettings(); | 1429 | mLdapSearchDialog->restoreSettings(); |
1430 | 1430 | ||
1431 | if ( mLdapSearchDialog->isOK() ) | 1431 | if ( mLdapSearchDialog->isOK() ) |
1432 | mLdapSearchDialog->exec(); | 1432 | mLdapSearchDialog->exec(); |
1433 | #else //KAB_EMBEDDED | 1433 | #else //KAB_EMBEDDED |
1434 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1434 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1435 | #endif //KAB_EMBEDDED | 1435 | #endif //KAB_EMBEDDED |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | void KABCore::print() | 1438 | void KABCore::print() |
1439 | { | 1439 | { |
1440 | #ifndef KAB_EMBEDDED | 1440 | #ifndef KAB_EMBEDDED |
1441 | KPrinter printer; | 1441 | KPrinter printer; |
1442 | if ( !printer.setup( this ) ) | 1442 | if ( !printer.setup( this ) ) |
1443 | return; | 1443 | return; |
1444 | 1444 | ||
1445 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1445 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1446 | mViewManager->selectedUids(), this ); | 1446 | mViewManager->selectedUids(), this ); |
1447 | 1447 | ||
1448 | wizard.exec(); | 1448 | wizard.exec(); |
1449 | #else //KAB_EMBEDDED | 1449 | #else //KAB_EMBEDDED |
1450 | qDebug("KABCore::print() finsih method"); | 1450 | qDebug("KABCore::print() finsih method"); |
1451 | #endif //KAB_EMBEDDED | 1451 | #endif //KAB_EMBEDDED |
1452 | 1452 | ||
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | 1455 | ||
1456 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1456 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1457 | { | 1457 | { |
1458 | if ( mGUIClient ) | 1458 | if ( mGUIClient ) |
1459 | mGUIClient->insertChildClient( client ); | 1459 | mGUIClient->insertChildClient( client ); |
1460 | else | 1460 | else |
1461 | KMessageBox::error( this, "no KXMLGUICLient"); | 1461 | KMessageBox::error( this, "no KXMLGUICLient"); |
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | 1464 | ||
1465 | void KABCore::configurationChanged() | 1465 | void KABCore::configurationChanged() |
1466 | { | 1466 | { |
1467 | mExtensionManager->reconfigure(); | 1467 | mExtensionManager->reconfigure(); |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | void KABCore::addressBookChanged() | 1470 | void KABCore::addressBookChanged() |
1471 | { | 1471 | { |
1472 | /*US | 1472 | /*US |
1473 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1473 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1474 | while ( it.current() ) { | 1474 | while ( it.current() ) { |
1475 | if ( it.current()->dirty() ) { | 1475 | if ( it.current()->dirty() ) { |
1476 | QString text = i18n( "Data has been changed externally. Unsaved " | 1476 | QString text = i18n( "Data has been changed externally. Unsaved " |
1477 | "changes will be lost." ); | 1477 | "changes will be lost." ); |
1478 | KMessageBox::information( this, text ); | 1478 | KMessageBox::information( this, text ); |
1479 | } | 1479 | } |
1480 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1480 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1481 | ++it; | 1481 | ++it; |
1482 | } | 1482 | } |
1483 | */ | 1483 | */ |
1484 | if (mEditorDialog) | 1484 | if (mEditorDialog) |
1485 | { | 1485 | { |
1486 | if (mEditorDialog->dirty()) | 1486 | if (mEditorDialog->dirty()) |
1487 | { | 1487 | { |
1488 | QString text = i18n( "Data has been changed externally. Unsaved " | 1488 | QString text = i18n( "Data has been changed externally. Unsaved " |
1489 | "changes will be lost." ); | 1489 | "changes will be lost." ); |
1490 | KMessageBox::information( this, text ); | 1490 | KMessageBox::information( this, text ); |
1491 | } | 1491 | } |
1492 | QString currentuid = mEditorDialog->addressee().uid(); | 1492 | QString currentuid = mEditorDialog->addressee().uid(); |
1493 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1493 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1494 | } | 1494 | } |
1495 | mViewManager->refreshView(); | 1495 | mViewManager->refreshView(); |
1496 | // mDetails->refreshView(); | 1496 | // mDetails->refreshView(); |
1497 | 1497 | ||
1498 | 1498 | ||
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1501 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1502 | const char *name ) | 1502 | const char *name ) |
1503 | { | 1503 | { |
1504 | 1504 | ||
1505 | if ( mEditorDialog == 0 ) { | 1505 | if ( mEditorDialog == 0 ) { |
1506 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1506 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1507 | name ? name : "editorDialog" ); | 1507 | name ? name : "editorDialog" ); |
1508 | 1508 | ||
1509 | 1509 | ||
1510 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1510 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1511 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1511 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1512 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1512 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1513 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1513 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1514 | } | 1514 | } |
1515 | 1515 | ||
1516 | return mEditorDialog; | 1516 | return mEditorDialog; |
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1519 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1520 | { | 1520 | { |
1521 | //mEditorDict.remove( uid ); | 1521 | //mEditorDict.remove( uid ); |
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | void KABCore::initGUI() | 1524 | void KABCore::initGUI() |
1525 | { | 1525 | { |
1526 | #ifndef KAB_EMBEDDED | 1526 | #ifndef KAB_EMBEDDED |
1527 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1527 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1528 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1528 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1529 | 1529 | ||
1530 | mExtensionBarSplitter = new QSplitter( this ); | 1530 | mExtensionBarSplitter = new QSplitter( this ); |
1531 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1531 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1532 | 1532 | ||
1533 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1533 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1534 | 1534 | ||
1535 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1535 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1536 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1536 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1537 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1537 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1538 | SLOT( incrementalSearch( const QString& ) ) ); | 1538 | SLOT( incrementalSearch( const QString& ) ) ); |
1539 | 1539 | ||
1540 | mViewManager = new ViewManager( this, viewSpace ); | 1540 | mViewManager = new ViewManager( this, viewSpace ); |
1541 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1541 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1542 | 1542 | ||
1543 | mDetails = new ViewContainer( mDetailsSplitter ); | 1543 | mDetails = new ViewContainer( mDetailsSplitter ); |
1544 | 1544 | ||
1545 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1545 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1546 | 1546 | ||
1547 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1547 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1548 | 1548 | ||
1549 | topLayout->addWidget( mExtensionBarSplitter ); | 1549 | topLayout->addWidget( mExtensionBarSplitter ); |
1550 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1550 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1551 | topLayout->addWidget( mJumpButtonBar ); | 1551 | topLayout->addWidget( mJumpButtonBar ); |
1552 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1552 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1553 | 1553 | ||
1554 | mXXPortManager = new XXPortManager( this, this ); | 1554 | mXXPortManager = new XXPortManager( this, this ); |
1555 | 1555 | ||
1556 | #else //KAB_EMBEDDED | 1556 | #else //KAB_EMBEDDED |
1557 | //US initialize viewMenu before settingup viewmanager. | 1557 | //US initialize viewMenu before settingup viewmanager. |
1558 | // Viewmanager needs this menu to plugin submenues. | 1558 | // Viewmanager needs this menu to plugin submenues. |
1559 | viewMenu = new QPopupMenu( this ); | 1559 | viewMenu = new QPopupMenu( this ); |
1560 | settingsMenu = new QPopupMenu( this ); | 1560 | settingsMenu = new QPopupMenu( this ); |
1561 | //filterMenu = new QPopupMenu( this ); | 1561 | //filterMenu = new QPopupMenu( this ); |
1562 | ImportMenu = new QPopupMenu( this ); | 1562 | ImportMenu = new QPopupMenu( this ); |
1563 | ExportMenu = new QPopupMenu( this ); | 1563 | ExportMenu = new QPopupMenu( this ); |
1564 | syncMenu = new QPopupMenu( this ); | 1564 | syncMenu = new QPopupMenu( this ); |
1565 | changeMenu= new QPopupMenu( this ); | 1565 | changeMenu= new QPopupMenu( this ); |
1566 | 1566 | ||
1567 | //US since we have no splitter for the embedded system, setup | 1567 | //US since we have no splitter for the embedded system, setup |
1568 | // a layout with two frames. One left and one right. | 1568 | // a layout with two frames. One left and one right. |
1569 | 1569 | ||
1570 | QBoxLayout *topLayout; | 1570 | QBoxLayout *topLayout; |
1571 | 1571 | ||
1572 | // = new QHBoxLayout( this ); | 1572 | // = new QHBoxLayout( this ); |
1573 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1573 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1574 | 1574 | ||
1575 | // QWidget *mainBox = new QWidget( this ); | 1575 | // QWidget *mainBox = new QWidget( this ); |
1576 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1576 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1577 | 1577 | ||
1578 | #ifdef DESKTOP_VERSION | 1578 | #ifdef DESKTOP_VERSION |
1579 | topLayout = new QHBoxLayout( this ); | 1579 | topLayout = new QHBoxLayout( this ); |
1580 | 1580 | ||
1581 | 1581 | ||
1582 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1582 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1583 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1583 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1584 | 1584 | ||
1585 | topLayout->addWidget(mMiniSplitter ); | 1585 | topLayout->addWidget(mMiniSplitter ); |
1586 | 1586 | ||
1587 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1587 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1588 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1588 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1589 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1589 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1590 | mDetails = new ViewContainer( mMiniSplitter ); | 1590 | mDetails = new ViewContainer( mMiniSplitter ); |
1591 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1591 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1592 | #else | 1592 | #else |
1593 | if ( QApplication::desktop()->width() > 480 ) { | 1593 | if ( QApplication::desktop()->width() > 480 ) { |
1594 | topLayout = new QHBoxLayout( this ); | 1594 | topLayout = new QHBoxLayout( this ); |
1595 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1595 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1596 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1596 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1597 | } else { | 1597 | } else { |
1598 | 1598 | ||
1599 | topLayout = new QHBoxLayout( this ); | 1599 | topLayout = new QHBoxLayout( this ); |
1600 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1600 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1601 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1601 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1602 | } | 1602 | } |
1603 | 1603 | ||
1604 | topLayout->addWidget(mMiniSplitter ); | 1604 | topLayout->addWidget(mMiniSplitter ); |
1605 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1605 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1606 | mDetails = new ViewContainer( mMiniSplitter ); | 1606 | mDetails = new ViewContainer( mMiniSplitter ); |
1607 | 1607 | ||
1608 | 1608 | ||
1609 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1609 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1610 | #endif | 1610 | #endif |
1611 | //eh->hide(); | 1611 | //eh->hide(); |
1612 | // topLayout->addWidget(mExtensionManager ); | 1612 | // topLayout->addWidget(mExtensionManager ); |
1613 | 1613 | ||
1614 | 1614 | ||
1615 | /*US | 1615 | /*US |
1616 | #ifndef KAB_NOSPLITTER | 1616 | #ifndef KAB_NOSPLITTER |
1617 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1617 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1618 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1618 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1619 | topLayout->setSpacing( 10 ); | 1619 | topLayout->setSpacing( 10 ); |
1620 | 1620 | ||
1621 | mDetailsSplitter = new QSplitter( this ); | 1621 | mDetailsSplitter = new QSplitter( this ); |
1622 | 1622 | ||
1623 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1623 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1624 | 1624 | ||
1625 | mViewManager = new ViewManager( this, viewSpace ); | 1625 | mViewManager = new ViewManager( this, viewSpace ); |
1626 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1626 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1627 | 1627 | ||
1628 | mDetails = new ViewContainer( mDetailsSplitter ); | 1628 | mDetails = new ViewContainer( mDetailsSplitter ); |
1629 | 1629 | ||
1630 | topLayout->addWidget( mDetailsSplitter ); | 1630 | topLayout->addWidget( mDetailsSplitter ); |
1631 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1631 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1632 | #else //KAB_NOSPLITTER | 1632 | #else //KAB_NOSPLITTER |
1633 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1633 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1634 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1634 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1635 | topLayout->setSpacing( 10 ); | 1635 | topLayout->setSpacing( 10 ); |
1636 | 1636 | ||
1637 | // mDetailsSplitter = new QSplitter( this ); | 1637 | // mDetailsSplitter = new QSplitter( this ); |
1638 | 1638 | ||
1639 | QVBox *viewSpace = new QVBox( this ); | 1639 | QVBox *viewSpace = new QVBox( this ); |
1640 | 1640 | ||
1641 | mViewManager = new ViewManager( this, viewSpace ); | 1641 | mViewManager = new ViewManager( this, viewSpace ); |
1642 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1642 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1643 | 1643 | ||
1644 | mDetails = new ViewContainer( this ); | 1644 | mDetails = new ViewContainer( this ); |
1645 | 1645 | ||
1646 | topLayout->addWidget( viewSpace ); | 1646 | topLayout->addWidget( viewSpace ); |
1647 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1647 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1648 | topLayout->addWidget( mDetails ); | 1648 | topLayout->addWidget( mDetails ); |
1649 | #endif //KAB_NOSPLITTER | 1649 | #endif //KAB_NOSPLITTER |
1650 | */ | 1650 | */ |
1651 | 1651 | ||
1652 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1652 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1653 | syncManager->setBlockSave(false); | 1653 | syncManager->setBlockSave(false); |
1654 | 1654 | ||
1655 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1655 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1656 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1656 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1657 | syncManager->setDefaultFileName( sentSyncFile()); | 1657 | syncManager->setDefaultFileName( sentSyncFile()); |
1658 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1658 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1659 | 1659 | ||
1660 | #endif //KAB_EMBEDDED | 1660 | #endif //KAB_EMBEDDED |
1661 | initActions(); | 1661 | initActions(); |
1662 | 1662 | ||
1663 | #ifdef KAB_EMBEDDED | 1663 | #ifdef KAB_EMBEDDED |
1664 | addActionsManually(); | 1664 | addActionsManually(); |
1665 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1665 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1666 | mXXPortManager = new XXPortManager( this, this ); | 1666 | mXXPortManager = new XXPortManager( this, this ); |
1667 | 1667 | ||
1668 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1668 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1669 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1669 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1670 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1670 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1671 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1671 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1672 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1672 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1673 | // mIncSearchWidget->hide(); | 1673 | // mIncSearchWidget->hide(); |
1674 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1674 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1675 | SLOT( incrementalSearch( const QString& ) ) ); | 1675 | SLOT( incrementalSearch( const QString& ) ) ); |
1676 | 1676 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | |
1677 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | ||
1677 | 1678 | ||
1678 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1679 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1679 | 1680 | ||
1680 | topLayout->addWidget( mJumpButtonBar ); | 1681 | topLayout->addWidget( mJumpButtonBar ); |
1681 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1682 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1682 | 1683 | ||
1683 | // mMainWindow->getIconToolBar()->raise(); | 1684 | // mMainWindow->getIconToolBar()->raise(); |
1684 | 1685 | ||
1685 | #endif //KAB_EMBEDDED | 1686 | #endif //KAB_EMBEDDED |
1686 | 1687 | ||
1687 | } | 1688 | } |
1688 | void KABCore::initActions() | 1689 | void KABCore::initActions() |
1689 | { | 1690 | { |
1690 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1691 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1691 | 1692 | ||
1692 | #ifndef KAB_EMBEDDED | 1693 | #ifndef KAB_EMBEDDED |
1693 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1694 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1694 | SLOT( clipboardDataChanged() ) ); | 1695 | SLOT( clipboardDataChanged() ) ); |
1695 | #endif //KAB_EMBEDDED | 1696 | #endif //KAB_EMBEDDED |
1696 | 1697 | ||
1697 | // file menu | 1698 | // file menu |
1698 | if ( mIsPart ) { | 1699 | if ( mIsPart ) { |
1699 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1700 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1700 | SLOT( sendMail() ), actionCollection(), | 1701 | SLOT( sendMail() ), actionCollection(), |
1701 | "kaddressbook_mail" ); | 1702 | "kaddressbook_mail" ); |
1702 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1703 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1703 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1704 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1704 | 1705 | ||
1705 | } else { | 1706 | } else { |
1706 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1707 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1707 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1708 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1708 | } | 1709 | } |
1709 | 1710 | ||
1710 | 1711 | ||
1711 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1712 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1712 | SLOT( save() ), actionCollection(), "file_sync" ); | 1713 | SLOT( save() ), actionCollection(), "file_sync" ); |
1713 | 1714 | ||
1714 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1715 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1715 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1716 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1716 | 1717 | ||
1717 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1718 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1718 | this, SLOT( mailVCard() ), | 1719 | this, SLOT( mailVCard() ), |
1719 | actionCollection(), "file_mail_vcard"); | 1720 | actionCollection(), "file_mail_vcard"); |
1720 | 1721 | ||
1721 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1722 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1722 | SLOT( export2phone() ), actionCollection(), | 1723 | SLOT( export2phone() ), actionCollection(), |
1723 | "kaddressbook_ex2phone" ); | 1724 | "kaddressbook_ex2phone" ); |
1724 | 1725 | ||
1725 | mActionBeamVCard = 0; | 1726 | mActionBeamVCard = 0; |
1726 | mActionBeam = 0; | 1727 | mActionBeam = 0; |
1727 | 1728 | ||
1728 | #ifndef DESKTOP_VERSION | 1729 | #ifndef DESKTOP_VERSION |
1729 | if ( Ir::supported() ) { | 1730 | if ( Ir::supported() ) { |
1730 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1731 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1731 | SLOT( beamVCard() ), actionCollection(), | 1732 | SLOT( beamVCard() ), actionCollection(), |
1732 | "kaddressbook_beam_vcard" ); | 1733 | "kaddressbook_beam_vcard" ); |
1733 | 1734 | ||
1734 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1735 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1735 | SLOT( beamMySelf() ), actionCollection(), | 1736 | SLOT( beamMySelf() ), actionCollection(), |
1736 | "kaddressbook_beam_myself" ); | 1737 | "kaddressbook_beam_myself" ); |
1737 | } | 1738 | } |
1738 | #endif | 1739 | #endif |
1739 | 1740 | ||
1740 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1741 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1741 | this, SLOT( editContact2() ), | 1742 | this, SLOT( editContact2() ), |
1742 | actionCollection(), "file_properties" ); | 1743 | actionCollection(), "file_properties" ); |
1743 | 1744 | ||
1744 | #ifdef KAB_EMBEDDED | 1745 | #ifdef KAB_EMBEDDED |
1745 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1746 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1746 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1747 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1747 | mMainWindow, SLOT( exit() ), | 1748 | mMainWindow, SLOT( exit() ), |
1748 | actionCollection(), "quit" ); | 1749 | actionCollection(), "quit" ); |
1749 | #endif //KAB_EMBEDDED | 1750 | #endif //KAB_EMBEDDED |
1750 | 1751 | ||
1751 | // edit menu | 1752 | // edit menu |
1752 | if ( mIsPart ) { | 1753 | if ( mIsPart ) { |
1753 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1754 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1754 | SLOT( copyContacts() ), actionCollection(), | 1755 | SLOT( copyContacts() ), actionCollection(), |
1755 | "kaddressbook_copy" ); | 1756 | "kaddressbook_copy" ); |
1756 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1757 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1757 | SLOT( cutContacts() ), actionCollection(), | 1758 | SLOT( cutContacts() ), actionCollection(), |
1758 | "kaddressbook_cut" ); | 1759 | "kaddressbook_cut" ); |
1759 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1760 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1760 | SLOT( pasteContacts() ), actionCollection(), | 1761 | SLOT( pasteContacts() ), actionCollection(), |
1761 | "kaddressbook_paste" ); | 1762 | "kaddressbook_paste" ); |
1762 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1763 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1763 | SLOT( selectAllContacts() ), actionCollection(), | 1764 | SLOT( selectAllContacts() ), actionCollection(), |
1764 | "kaddressbook_select_all" ); | 1765 | "kaddressbook_select_all" ); |
1765 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1766 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1766 | SLOT( undo() ), actionCollection(), | 1767 | SLOT( undo() ), actionCollection(), |
1767 | "kaddressbook_undo" ); | 1768 | "kaddressbook_undo" ); |
1768 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1769 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1769 | this, SLOT( redo() ), actionCollection(), | 1770 | this, SLOT( redo() ), actionCollection(), |
1770 | "kaddressbook_redo" ); | 1771 | "kaddressbook_redo" ); |
1771 | } else { | 1772 | } else { |
1772 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1773 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1773 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1774 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1774 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1775 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1775 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1776 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1776 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1777 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1777 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1778 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1778 | } | 1779 | } |
1779 | 1780 | ||
1780 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1781 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1781 | Key_Delete, this, SLOT( deleteContacts() ), | 1782 | Key_Delete, this, SLOT( deleteContacts() ), |
1782 | actionCollection(), "edit_delete" ); | 1783 | actionCollection(), "edit_delete" ); |
1783 | 1784 | ||
1784 | mActionUndo->setEnabled( false ); | 1785 | mActionUndo->setEnabled( false ); |
1785 | mActionRedo->setEnabled( false ); | 1786 | mActionRedo->setEnabled( false ); |
1786 | 1787 | ||
1787 | // settings menu | 1788 | // settings menu |
1788 | #ifdef KAB_EMBEDDED | 1789 | #ifdef KAB_EMBEDDED |
1789 | //US special menuentry to configure the addressbook resources. On KDE | 1790 | //US special menuentry to configure the addressbook resources. On KDE |
1790 | // you do that through the control center !!! | 1791 | // you do that through the control center !!! |
1791 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1792 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1792 | SLOT( configureResources() ), actionCollection(), | 1793 | SLOT( configureResources() ), actionCollection(), |
1793 | "kaddressbook_configure_resources" ); | 1794 | "kaddressbook_configure_resources" ); |
1794 | #endif //KAB_EMBEDDED | 1795 | #endif //KAB_EMBEDDED |
1795 | 1796 | ||
1796 | if ( mIsPart ) { | 1797 | if ( mIsPart ) { |
1797 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1798 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1798 | SLOT( openConfigDialog() ), actionCollection(), | 1799 | SLOT( openConfigDialog() ), actionCollection(), |
1799 | "kaddressbook_configure" ); | 1800 | "kaddressbook_configure" ); |
1800 | 1801 | ||
1801 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1802 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1802 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1803 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1803 | "kaddressbook_configure_shortcuts" ); | 1804 | "kaddressbook_configure_shortcuts" ); |
1804 | #ifdef KAB_EMBEDDED | 1805 | #ifdef KAB_EMBEDDED |
1805 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1806 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1806 | mActionConfigureToolbars->setEnabled( false ); | 1807 | mActionConfigureToolbars->setEnabled( false ); |
1807 | #endif //KAB_EMBEDDED | 1808 | #endif //KAB_EMBEDDED |
1808 | 1809 | ||
1809 | } else { | 1810 | } else { |
1810 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1811 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1811 | 1812 | ||
1812 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1813 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1813 | } | 1814 | } |
1814 | 1815 | ||
1815 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1816 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1816 | actionCollection(), "options_show_jump_bar" ); | 1817 | actionCollection(), "options_show_jump_bar" ); |
1817 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1818 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1818 | 1819 | ||
1819 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1820 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1820 | actionCollection(), "options_show_details" ); | 1821 | actionCollection(), "options_show_details" ); |
1821 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1822 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1822 | 1823 | ||
1823 | // misc | 1824 | // misc |
1824 | // only enable LDAP lookup if we can handle the protocol | 1825 | // only enable LDAP lookup if we can handle the protocol |
1825 | #ifndef KAB_EMBEDDED | 1826 | #ifndef KAB_EMBEDDED |
1826 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1827 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1827 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1828 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1828 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1829 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1829 | "ldap_lookup" ); | 1830 | "ldap_lookup" ); |
1830 | } | 1831 | } |
1831 | #else //KAB_EMBEDDED | 1832 | #else //KAB_EMBEDDED |
1832 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1833 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1833 | #endif //KAB_EMBEDDED | 1834 | #endif //KAB_EMBEDDED |
1834 | 1835 | ||
1835 | 1836 | ||
1836 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1837 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1837 | SLOT( setWhoAmI() ), actionCollection(), | 1838 | SLOT( setWhoAmI() ), actionCollection(), |
1838 | "set_personal" ); | 1839 | "set_personal" ); |
1839 | 1840 | ||
1840 | 1841 | ||
1841 | 1842 | ||
1842 | 1843 | ||
1843 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1844 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1844 | SLOT( setCategories() ), actionCollection(), | 1845 | SLOT( setCategories() ), actionCollection(), |
1845 | "edit_set_categories" ); | 1846 | "edit_set_categories" ); |
1846 | 1847 | ||
1847 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1848 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1848 | SLOT( removeVoice() ), actionCollection(), | 1849 | SLOT( removeVoice() ), actionCollection(), |
1849 | "remove_voice" ); | 1850 | "remove_voice" ); |
1850 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1851 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1851 | SLOT( importFromOL() ), actionCollection(), | 1852 | SLOT( importFromOL() ), actionCollection(), |
1852 | "import_OL" ); | 1853 | "import_OL" ); |
1853 | #ifdef KAB_EMBEDDED | 1854 | #ifdef KAB_EMBEDDED |
1854 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1855 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1855 | this, SLOT( showLicence() ), actionCollection(), | 1856 | this, SLOT( showLicence() ), actionCollection(), |
1856 | "licence_about_data" ); | 1857 | "licence_about_data" ); |
1857 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1858 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1858 | this, SLOT( faq() ), actionCollection(), | 1859 | this, SLOT( faq() ), actionCollection(), |
1859 | "faq_about_data" ); | 1860 | "faq_about_data" ); |
1860 | 1861 | ||
1861 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1862 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1862 | this, SLOT( createAboutData() ), actionCollection(), | 1863 | this, SLOT( createAboutData() ), actionCollection(), |
1863 | "kaddressbook_about_data" ); | 1864 | "kaddressbook_about_data" ); |
1864 | #endif //KAB_EMBEDDED | 1865 | #endif //KAB_EMBEDDED |
1865 | 1866 | ||
1866 | clipboardDataChanged(); | 1867 | clipboardDataChanged(); |
1867 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1868 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1868 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1869 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1869 | } | 1870 | } |
1870 | 1871 | ||
1871 | //US we need this function, to plug all actions into the correct menues. | 1872 | //US we need this function, to plug all actions into the correct menues. |
1872 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1873 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1873 | void KABCore::addActionsManually() | 1874 | void KABCore::addActionsManually() |
1874 | { | 1875 | { |
1875 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1876 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1876 | 1877 | ||
1877 | #ifdef KAB_EMBEDDED | 1878 | #ifdef KAB_EMBEDDED |
1878 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1879 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1879 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1880 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1880 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1881 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1881 | 1882 | ||
1882 | KToolBar* tb = mMainWindow->toolBar(); | 1883 | KToolBar* tb = mMainWindow->toolBar(); |
1883 | 1884 | ||
1884 | #ifdef DESKTOP_VERSION | 1885 | #ifdef DESKTOP_VERSION |
1885 | QMenuBar* mb = mMainWindow->menuBar(); | 1886 | QMenuBar* mb = mMainWindow->menuBar(); |
1886 | 1887 | ||
1887 | //US setup menubar. | 1888 | //US setup menubar. |
1888 | //Disable the following block if you do not want to have a menubar. | 1889 | //Disable the following block if you do not want to have a menubar. |
1889 | mb->insertItem( "&File", fileMenu ); | 1890 | mb->insertItem( "&File", fileMenu ); |
1890 | mb->insertItem( "&Edit", editMenu ); | 1891 | mb->insertItem( "&Edit", editMenu ); |
1891 | mb->insertItem( "&View", viewMenu ); | 1892 | mb->insertItem( "&View", viewMenu ); |
1892 | mb->insertItem( "&Settings", settingsMenu ); | 1893 | mb->insertItem( "&Settings", settingsMenu ); |
1893 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1894 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1894 | mb->insertItem( "&Change selected", changeMenu ); | 1895 | mb->insertItem( "&Change selected", changeMenu ); |
1895 | mb->insertItem( "&Help", helpMenu ); | 1896 | mb->insertItem( "&Help", helpMenu ); |
1896 | mIncSearchWidget = new IncSearchWidget( tb ); | 1897 | mIncSearchWidget = new IncSearchWidget( tb ); |
1897 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1898 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1898 | 1899 | ||
1899 | #else | 1900 | #else |
1900 | //US setup toolbar | 1901 | //US setup toolbar |
1901 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1902 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1902 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1903 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1903 | menuBarTB->insertItem( "ME", popupBarTB); | 1904 | menuBarTB->insertItem( "ME", popupBarTB); |
1904 | tb->insertWidget(-1, 0, menuBarTB); | 1905 | tb->insertWidget(-1, 0, menuBarTB); |
1905 | mIncSearchWidget = new IncSearchWidget( tb ); | 1906 | mIncSearchWidget = new IncSearchWidget( tb ); |
1906 | 1907 | ||
1907 | tb->enableMoving(false); | 1908 | tb->enableMoving(false); |
1908 | popupBarTB->insertItem( "&File", fileMenu ); | 1909 | popupBarTB->insertItem( "&File", fileMenu ); |
1909 | popupBarTB->insertItem( "&Edit", editMenu ); | 1910 | popupBarTB->insertItem( "&Edit", editMenu ); |
1910 | popupBarTB->insertItem( "&View", viewMenu ); | 1911 | popupBarTB->insertItem( "&View", viewMenu ); |
1911 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1912 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1912 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1913 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1913 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1914 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1914 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1915 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1915 | popupBarTB->insertItem( "&Help", helpMenu ); | 1916 | popupBarTB->insertItem( "&Help", helpMenu ); |
1916 | if (QApplication::desktop()->width() > 320 ) { | 1917 | if (QApplication::desktop()->width() > 320 ) { |
1917 | // mViewManager->getFilterAction()->plug ( tb); | 1918 | // mViewManager->getFilterAction()->plug ( tb); |
1918 | } | 1919 | } |
1919 | #endif | 1920 | #endif |
1920 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1921 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1921 | 1922 | ||
1922 | 1923 | ||
1923 | 1924 | ||
1924 | //US Now connect the actions with the menue entries. | 1925 | //US Now connect the actions with the menue entries. |
1925 | mActionPrint->plug( fileMenu ); | 1926 | mActionPrint->plug( fileMenu ); |
1926 | mActionMail->plug( fileMenu ); | 1927 | mActionMail->plug( fileMenu ); |
1927 | fileMenu->insertSeparator(); | 1928 | fileMenu->insertSeparator(); |
1928 | 1929 | ||
1929 | mActionNewContact->plug( fileMenu ); | 1930 | mActionNewContact->plug( fileMenu ); |
1930 | mActionNewContact->plug( tb ); | 1931 | mActionNewContact->plug( tb ); |
1931 | 1932 | ||
1932 | mActionEditAddressee->plug( fileMenu ); | 1933 | mActionEditAddressee->plug( fileMenu ); |
1933 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1934 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1934 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1935 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1935 | mActionEditAddressee->plug( tb ); | 1936 | mActionEditAddressee->plug( tb ); |
1936 | 1937 | ||
1937 | fileMenu->insertSeparator(); | 1938 | fileMenu->insertSeparator(); |
1938 | mActionSave->plug( fileMenu ); | 1939 | mActionSave->plug( fileMenu ); |
1939 | fileMenu->insertItem( "&Import", ImportMenu ); | 1940 | fileMenu->insertItem( "&Import", ImportMenu ); |
1940 | fileMenu->insertItem( "&Export", ExportMenu ); | 1941 | fileMenu->insertItem( "&Export", ExportMenu ); |
1941 | fileMenu->insertSeparator(); | 1942 | fileMenu->insertSeparator(); |
1942 | mActionMailVCard->plug( fileMenu ); | 1943 | mActionMailVCard->plug( fileMenu ); |
1943 | #ifndef DESKTOP_VERSION | 1944 | #ifndef DESKTOP_VERSION |
1944 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1945 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1945 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1946 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1946 | #endif | 1947 | #endif |
1947 | fileMenu->insertSeparator(); | 1948 | fileMenu->insertSeparator(); |
1948 | mActionQuit->plug( fileMenu ); | 1949 | mActionQuit->plug( fileMenu ); |
1949 | #ifdef _WIN32_ | 1950 | #ifdef _WIN32_ |
1950 | mActionImportOL->plug( ImportMenu ); | 1951 | mActionImportOL->plug( ImportMenu ); |
1951 | #endif | 1952 | #endif |
1952 | // edit menu | 1953 | // edit menu |
1953 | mActionUndo->plug( editMenu ); | 1954 | mActionUndo->plug( editMenu ); |
1954 | mActionRedo->plug( editMenu ); | 1955 | mActionRedo->plug( editMenu ); |
1955 | editMenu->insertSeparator(); | 1956 | editMenu->insertSeparator(); |
1956 | mActionCut->plug( editMenu ); | 1957 | mActionCut->plug( editMenu ); |
1957 | mActionCopy->plug( editMenu ); | 1958 | mActionCopy->plug( editMenu ); |
1958 | mActionPaste->plug( editMenu ); | 1959 | mActionPaste->plug( editMenu ); |
1959 | mActionDelete->plug( editMenu ); | 1960 | mActionDelete->plug( editMenu ); |
1960 | editMenu->insertSeparator(); | 1961 | editMenu->insertSeparator(); |
1961 | mActionSelectAll->plug( editMenu ); | 1962 | mActionSelectAll->plug( editMenu ); |
1962 | 1963 | ||
1963 | mActionRemoveVoice->plug( changeMenu ); | 1964 | mActionRemoveVoice->plug( changeMenu ); |
1964 | // settings menu | 1965 | // settings menu |
1965 | //US special menuentry to configure the addressbook resources. On KDE | 1966 | //US special menuentry to configure the addressbook resources. On KDE |
1966 | // you do that through the control center !!! | 1967 | // you do that through the control center !!! |
1967 | mActionConfigResources->plug( settingsMenu ); | 1968 | mActionConfigResources->plug( settingsMenu ); |
1968 | settingsMenu->insertSeparator(); | 1969 | settingsMenu->insertSeparator(); |
1969 | 1970 | ||
1970 | mActionConfigKAddressbook->plug( settingsMenu ); | 1971 | mActionConfigKAddressbook->plug( settingsMenu ); |
1971 | 1972 | ||
1972 | if ( mIsPart ) { | 1973 | if ( mIsPart ) { |
1973 | mActionConfigShortcuts->plug( settingsMenu ); | 1974 | mActionConfigShortcuts->plug( settingsMenu ); |
1974 | mActionConfigureToolbars->plug( settingsMenu ); | 1975 | mActionConfigureToolbars->plug( settingsMenu ); |
1975 | 1976 | ||
1976 | } else { | 1977 | } else { |
1977 | mActionKeyBindings->plug( settingsMenu ); | 1978 | mActionKeyBindings->plug( settingsMenu ); |
1978 | } | 1979 | } |
1979 | 1980 | ||
1980 | settingsMenu->insertSeparator(); | 1981 | settingsMenu->insertSeparator(); |
1981 | 1982 | ||
1982 | mActionJumpBar->plug( settingsMenu ); | 1983 | mActionJumpBar->plug( settingsMenu ); |
1983 | mActionDetails->plug( settingsMenu ); | 1984 | mActionDetails->plug( settingsMenu ); |
1984 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1985 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1985 | mActionDetails->plug( tb ); | 1986 | mActionDetails->plug( tb ); |
1986 | settingsMenu->insertSeparator(); | 1987 | settingsMenu->insertSeparator(); |
1987 | 1988 | ||
1988 | mActionWhoAmI->plug( settingsMenu ); | 1989 | mActionWhoAmI->plug( settingsMenu ); |
1989 | mActionCategories->plug( settingsMenu ); | 1990 | mActionCategories->plug( settingsMenu ); |
1990 | 1991 | ||
1991 | mActionLicence->plug( helpMenu ); | 1992 | mActionLicence->plug( helpMenu ); |
1992 | mActionFaq->plug( helpMenu ); | 1993 | mActionFaq->plug( helpMenu ); |
1993 | mActionAboutKAddressbook->plug( helpMenu ); | 1994 | mActionAboutKAddressbook->plug( helpMenu ); |
1994 | 1995 | ||
1995 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1996 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1996 | 1997 | ||
1997 | mActionSave->plug( tb ); | 1998 | mActionSave->plug( tb ); |
1998 | mViewManager->getFilterAction()->plug ( tb); | 1999 | mViewManager->getFilterAction()->plug ( tb); |
1999 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2000 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2000 | mActionUndo->plug( tb ); | 2001 | mActionUndo->plug( tb ); |
2001 | mActionDelete->plug( tb ); | 2002 | mActionDelete->plug( tb ); |
2002 | mActionRedo->plug( tb ); | 2003 | mActionRedo->plug( tb ); |
2003 | } | 2004 | } |
2004 | } | 2005 | } |
2005 | //mActionQuit->plug ( tb ); | 2006 | //mActionQuit->plug ( tb ); |
2006 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2007 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2007 | 2008 | ||
2008 | //US link the searchwidget first to this. | 2009 | //US link the searchwidget first to this. |
2009 | // The real linkage to the toolbar happens later. | 2010 | // The real linkage to the toolbar happens later. |
2010 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2011 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2011 | //US tb->insertItem( mIncSearchWidget ); | 2012 | //US tb->insertItem( mIncSearchWidget ); |
2012 | /*US | 2013 | /*US |
2013 | mIncSearchWidget = new IncSearchWidget( tb ); | 2014 | mIncSearchWidget = new IncSearchWidget( tb ); |
2014 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2015 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2015 | SLOT( incrementalSearch( const QString& ) ) ); | 2016 | SLOT( incrementalSearch( const QString& ) ) ); |
2016 | 2017 | ||
2017 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2018 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2018 | 2019 | ||
2019 | //US topLayout->addWidget( mJumpButtonBar ); | 2020 | //US topLayout->addWidget( mJumpButtonBar ); |
2020 | this->layout()->add( mJumpButtonBar ); | 2021 | this->layout()->add( mJumpButtonBar ); |
2021 | */ | 2022 | */ |
2022 | 2023 | ||
2023 | #endif //KAB_EMBEDDED | 2024 | #endif //KAB_EMBEDDED |
2024 | 2025 | ||
2025 | mActionExport2phone->plug( ExportMenu ); | 2026 | mActionExport2phone->plug( ExportMenu ); |
2026 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2027 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2027 | syncManager->fillSyncMenu(); | 2028 | syncManager->fillSyncMenu(); |
2028 | 2029 | ||
2029 | } | 2030 | } |
2030 | void KABCore::showLicence() | 2031 | void KABCore::showLicence() |
2031 | { | 2032 | { |
2032 | KApplication::showLicence(); | 2033 | KApplication::showLicence(); |
2033 | } | 2034 | } |
2034 | void KABCore::removeVoice() | 2035 | void KABCore::removeVoice() |
2035 | { | 2036 | { |
2036 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2037 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2037 | return; | 2038 | return; |
2038 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2039 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2039 | KABC::Addressee::List::Iterator it; | 2040 | KABC::Addressee::List::Iterator it; |
2040 | for ( it = list.begin(); it != list.end(); ++it ) { | 2041 | for ( it = list.begin(); it != list.end(); ++it ) { |
2041 | 2042 | ||
2042 | if ( (*it).removeVoice() ) | 2043 | if ( (*it).removeVoice() ) |
2043 | contactModified((*it) ); | 2044 | contactModified((*it) ); |
2044 | } | 2045 | } |
2045 | } | 2046 | } |
2046 | 2047 | ||
2047 | 2048 | ||
2048 | 2049 | ||
2049 | void KABCore::clipboardDataChanged() | 2050 | void KABCore::clipboardDataChanged() |
2050 | { | 2051 | { |
2051 | 2052 | ||
2052 | if ( mReadWrite ) | 2053 | if ( mReadWrite ) |
2053 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2054 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2054 | 2055 | ||
2055 | } | 2056 | } |
2056 | 2057 | ||
2057 | void KABCore::updateActionMenu() | 2058 | void KABCore::updateActionMenu() |
2058 | { | 2059 | { |
2059 | UndoStack *undo = UndoStack::instance(); | 2060 | UndoStack *undo = UndoStack::instance(); |
2060 | RedoStack *redo = RedoStack::instance(); | 2061 | RedoStack *redo = RedoStack::instance(); |
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 17106e8..c134e96 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h | |||
@@ -1,296 +1,298 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KADDRESSBOOKVIEW_H | 24 | #ifndef KADDRESSBOOKVIEW_H |
25 | #define KADDRESSBOOKVIEW_H | 25 | #define KADDRESSBOOKVIEW_H |
26 | 26 | ||
27 | #ifndef KAB_EMBEDDED | 27 | #ifndef KAB_EMBEDDED |
28 | #include <klibloader.h> | 28 | #include <klibloader.h> |
29 | #endif //KAB_EMBEDDED | 29 | #endif //KAB_EMBEDDED |
30 | 30 | ||
31 | class KConfig; | 31 | class KConfig; |
32 | class QDropEvent; | 32 | class QDropEvent; |
33 | 33 | ||
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <kabc/field.h> | 35 | #include <kabc/field.h> |
36 | #include <qwidget.h> | 36 | #include <qwidget.h> |
37 | 37 | ||
38 | #include "viewconfigurewidget.h" | 38 | #include "viewconfigurewidget.h" |
39 | #include "filter.h" | 39 | #include "filter.h" |
40 | 40 | ||
41 | namespace KABC { class AddressBook; } | 41 | namespace KABC { class AddressBook; } |
42 | 42 | ||
43 | /** | 43 | /** |
44 | Base class for all views in kaddressbook. This class implements | 44 | Base class for all views in kaddressbook. This class implements |
45 | all the common methods needed to provide a view to the user. | 45 | all the common methods needed to provide a view to the user. |
46 | 46 | ||
47 | To implement a specific view (table, card, etc), just inherit from | 47 | To implement a specific view (table, card, etc), just inherit from |
48 | this class and implement all the pure virtuals. | 48 | this class and implement all the pure virtuals. |
49 | 49 | ||
50 | @author Mike Pilone <mpilone@slac.com> | 50 | @author Mike Pilone <mpilone@slac.com> |
51 | */ | 51 | */ |
52 | class KAddressBookView : public QWidget | 52 | class KAddressBookView : public QWidget |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | 55 | ||
56 | public: | 56 | public: |
57 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; | 57 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; |
58 | 58 | ||
59 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); | 59 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); |
60 | virtual ~KAddressBookView(); | 60 | virtual ~KAddressBookView(); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | Must be overloaded in subclasses. Should return a list of | 63 | Must be overloaded in subclasses. Should return a list of |
64 | all the uids of selected contacts. | 64 | all the uids of selected contacts. |
65 | */ | 65 | */ |
66 | virtual QStringList selectedUids() = 0; | 66 | virtual QStringList selectedUids() = 0; |
67 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; | 67 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; |
68 | virtual void scrollUP() = 0; | ||
69 | virtual void scrollDOWN() = 0; | ||
68 | 70 | ||
69 | /** | 71 | /** |
70 | Called whenever this view should read the config. This can be used | 72 | Called whenever this view should read the config. This can be used |
71 | as a sign that the config has changed, therefore the view should | 73 | as a sign that the config has changed, therefore the view should |
72 | assume the worst and rebuild itself if necessary. For example, | 74 | assume the worst and rebuild itself if necessary. For example, |
73 | in a table view this method may be called when the user adds or | 75 | in a table view this method may be called when the user adds or |
74 | removes columns from the view. | 76 | removes columns from the view. |
75 | 77 | ||
76 | If overloaded in the subclass, do not forget to call super class's | 78 | If overloaded in the subclass, do not forget to call super class's |
77 | method. | 79 | method. |
78 | 80 | ||
79 | @param config The KConfig object to read from. The group will already | 81 | @param config The KConfig object to read from. The group will already |
80 | be set, so do not change the group. | 82 | be set, so do not change the group. |
81 | */ | 83 | */ |
82 | virtual void readConfig( KConfig *config ); | 84 | virtual void readConfig( KConfig *config ); |
83 | 85 | ||
84 | /** | 86 | /** |
85 | Called whenever this view should write the config. The view should not | 87 | Called whenever this view should write the config. The view should not |
86 | write out information handled by the application, such as which fields | 88 | write out information handled by the application, such as which fields |
87 | are visible. The view should only write out information specific | 89 | are visible. The view should only write out information specific |
88 | to itself (i.e.: All information in the ViewConfigWidget) | 90 | to itself (i.e.: All information in the ViewConfigWidget) |
89 | 91 | ||
90 | If overloaded in the subclass, do not forget to call the super class's | 92 | If overloaded in the subclass, do not forget to call the super class's |
91 | method. | 93 | method. |
92 | 94 | ||
93 | @param config The KConfig object to read from. The group will already | 95 | @param config The KConfig object to read from. The group will already |
94 | be set, so do not change the group. | 96 | be set, so do not change the group. |
95 | */ | 97 | */ |
96 | virtual void writeConfig( KConfig *config ); | 98 | virtual void writeConfig( KConfig *config ); |
97 | 99 | ||
98 | /** | 100 | /** |
99 | Returns a QString with all the selected email addresses concatenated | 101 | Returns a QString with all the selected email addresses concatenated |
100 | together with a ',' seperator. | 102 | together with a ',' seperator. |
101 | */ | 103 | */ |
102 | virtual QString selectedEmails(); | 104 | virtual QString selectedEmails(); |
103 | 105 | ||
104 | /** | 106 | /** |
105 | Return the type of the view: Icon, Table, etc. Please make sure that | 107 | Return the type of the view: Icon, Table, etc. Please make sure that |
106 | this is the same value that ViewWrapper::type() will return for your | 108 | this is the same value that ViewWrapper::type() will return for your |
107 | view. | 109 | view. |
108 | */ | 110 | */ |
109 | virtual QString type() const = 0; | 111 | virtual QString type() const = 0; |
110 | 112 | ||
111 | /** | 113 | /** |
112 | Returns a list of the fields that should be displayed. The list | 114 | Returns a list of the fields that should be displayed. The list |
113 | is composed of the fields proper names (ie: Home Address), so | 115 | is composed of the fields proper names (ie: Home Address), so |
114 | the view may need to translate them in order to get the | 116 | the view may need to translate them in order to get the |
115 | value from the addressee. | 117 | value from the addressee. |
116 | 118 | ||
117 | This list is generated from the config file, so it is advisable to call | 119 | This list is generated from the config file, so it is advisable to call |
118 | this method whenever a readConfig() is called in order to get the newest | 120 | this method whenever a readConfig() is called in order to get the newest |
119 | list of fields. | 121 | list of fields. |
120 | */ | 122 | */ |
121 | KABC::Field::List fields() const; | 123 | KABC::Field::List fields() const; |
122 | 124 | ||
123 | /** | 125 | /** |
124 | Sets the active filter. This filter will be used for filtering | 126 | Sets the active filter. This filter will be used for filtering |
125 | the list of addressees to display. The view will <b>not</b> | 127 | the list of addressees to display. The view will <b>not</b> |
126 | automatically refresh itself, so in most cases you will want to call | 128 | automatically refresh itself, so in most cases you will want to call |
127 | KAddressBookView::refresh() after this method. | 129 | KAddressBookView::refresh() after this method. |
128 | */ | 130 | */ |
129 | void setFilter( const Filter& ); | 131 | void setFilter( const Filter& ); |
130 | 132 | ||
131 | /** | 133 | /** |
132 | @return The default filter type selection. If the selection | 134 | @return The default filter type selection. If the selection |
133 | is SpecificFilter, the name of the filter can be retrieved with | 135 | is SpecificFilter, the name of the filter can be retrieved with |
134 | defaultFilterName() | 136 | defaultFilterName() |
135 | */ | 137 | */ |
136 | DefaultFilterType defaultFilterType() const; | 138 | DefaultFilterType defaultFilterType() const; |
137 | 139 | ||
138 | /** | 140 | /** |
139 | @return The name of the default filter. This string is | 141 | @return The name of the default filter. This string is |
140 | only valid if defaultFilterType() is returning SpecificFilter. | 142 | only valid if defaultFilterType() is returning SpecificFilter. |
141 | */ | 143 | */ |
142 | const QString &defaultFilterName() const; | 144 | const QString &defaultFilterName() const; |
143 | 145 | ||
144 | /** | 146 | /** |
145 | @return The address book. | 147 | @return The address book. |
146 | */ | 148 | */ |
147 | KABC::AddressBook *addressBook() const; | 149 | KABC::AddressBook *addressBook() const; |
148 | 150 | ||
149 | public slots: | 151 | public slots: |
150 | /** | 152 | /** |
151 | Must be overloaded in subclasses to refresh the view. | 153 | Must be overloaded in subclasses to refresh the view. |
152 | Refreshing includes updating the view to ensure that only items | 154 | Refreshing includes updating the view to ensure that only items |
153 | in the document are visible. If <i>uid</i> is valid, only the | 155 | in the document are visible. If <i>uid</i> is valid, only the |
154 | addressee with uid needs to be refreshed. This is an optimization | 156 | addressee with uid needs to be refreshed. This is an optimization |
155 | only. | 157 | only. |
156 | */ | 158 | */ |
157 | virtual void refresh( QString uid = QString::null ) = 0; | 159 | virtual void refresh( QString uid = QString::null ) = 0; |
158 | 160 | ||
159 | /** | 161 | /** |
160 | This method must be overloaded in subclasses. Select (highlight) | 162 | This method must be overloaded in subclasses. Select (highlight) |
161 | the addressee matching <i>uid</i>. If uid | 163 | the addressee matching <i>uid</i>. If uid |
162 | is equal to QString::null, then all addressees should be selected. | 164 | is equal to QString::null, then all addressees should be selected. |
163 | */ | 165 | */ |
164 | #ifndef KAB_EMBEDDED | 166 | #ifndef KAB_EMBEDDED |
165 | //MOC_SKIP_BEGIN | 167 | //MOC_SKIP_BEGIN |
166 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; | 168 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; |
167 | //MOC_SKIP_END | 169 | //MOC_SKIP_END |
168 | #else //KAB_EMBEDDED | 170 | #else //KAB_EMBEDDED |
169 | //US my moc can not handle the default parameters. Is this a problem ??? | 171 | //US my moc can not handle the default parameters. Is this a problem ??? |
170 | virtual void setSelected( QString uid, bool selected) = 0; | 172 | virtual void setSelected( QString uid, bool selected) = 0; |
171 | #endif //KAB_EMBEDDED | 173 | #endif //KAB_EMBEDDED |
172 | 174 | ||
173 | signals: | 175 | signals: |
174 | /** | 176 | /** |
175 | This signal should be emitted by a subclass whenever an addressee | 177 | This signal should be emitted by a subclass whenever an addressee |
176 | is modified. | 178 | is modified. |
177 | */ | 179 | */ |
178 | void modified(); | 180 | void modified(); |
179 | 181 | ||
180 | /** | 182 | /** |
181 | This signal should be emitted by a subclass whenever an addressee | 183 | This signal should be emitted by a subclass whenever an addressee |
182 | is selected. Selected means that the addressee was given the focus. | 184 | is selected. Selected means that the addressee was given the focus. |
183 | Some widgets may call this 'highlighted'. The view is responsible for | 185 | Some widgets may call this 'highlighted'. The view is responsible for |
184 | emitting this signal multiple times if multiple items are selected, | 186 | emitting this signal multiple times if multiple items are selected, |
185 | with the last item selected being the last emit. | 187 | with the last item selected being the last emit. |
186 | 188 | ||
187 | @param uid The uid of the selected addressee. | 189 | @param uid The uid of the selected addressee. |
188 | 190 | ||
189 | @see KListView | 191 | @see KListView |
190 | */ | 192 | */ |
191 | void selected( const QString &uid ); | 193 | void selected( const QString &uid ); |
192 | void deleteRequest(); | 194 | void deleteRequest(); |
193 | /** | 195 | /** |
194 | This signal should be emitted by a subclass whenever an addressee | 196 | This signal should be emitted by a subclass whenever an addressee |
195 | is executed. This is defined by the KDE system wide config, but it | 197 | is executed. This is defined by the KDE system wide config, but it |
196 | either means single or doubleclicked. | 198 | either means single or doubleclicked. |
197 | 199 | ||
198 | @param ui The uid of the selected addressee | 200 | @param ui The uid of the selected addressee |
199 | 201 | ||
200 | @see KListView | 202 | @see KListView |
201 | */ | 203 | */ |
202 | void executed( const QString &uid ); | 204 | void executed( const QString &uid ); |
203 | 205 | ||
204 | /** | 206 | /** |
205 | This signal is emitted whenever a user attempts to start a drag | 207 | This signal is emitted whenever a user attempts to start a drag |
206 | in the view. The slot connected to this signal would usually want | 208 | in the view. The slot connected to this signal would usually want |
207 | to create a QDragObject. | 209 | to create a QDragObject. |
208 | */ | 210 | */ |
209 | void startDrag(); | 211 | void startDrag(); |
210 | 212 | ||
211 | /** | 213 | /** |
212 | This signal is emitted whenever the user drops something on the | 214 | This signal is emitted whenever the user drops something on the |
213 | view. The individual view should handle checking if the item is | 215 | view. The individual view should handle checking if the item is |
214 | droppable (ie: if it is a vcard). | 216 | droppable (ie: if it is a vcard). |
215 | */ | 217 | */ |
216 | void dropped( QDropEvent* ); | 218 | void dropped( QDropEvent* ); |
217 | 219 | ||
218 | protected: | 220 | protected: |
219 | /** | 221 | /** |
220 | Returns a list of the addressees that should be displayed. This method | 222 | Returns a list of the addressees that should be displayed. This method |
221 | should always be used by the subclass to get a list of addressees. This | 223 | should always be used by the subclass to get a list of addressees. This |
222 | method internally takes many factors into account, including the current | 224 | method internally takes many factors into account, including the current |
223 | filter. | 225 | filter. |
224 | */ | 226 | */ |
225 | KABC::Addressee::List addressees(); | 227 | KABC::Addressee::List addressees(); |
226 | 228 | ||
227 | /** | 229 | /** |
228 | This method returns the widget that should be used as the parent for | 230 | This method returns the widget that should be used as the parent for |
229 | all view components. By using this widget as the parent and not | 231 | all view components. By using this widget as the parent and not |
230 | 'this', the view subclass has the option of placing other widgets | 232 | 'this', the view subclass has the option of placing other widgets |
231 | around the view (ie: search fields, etc). Do not delete this widget! | 233 | around the view (ie: search fields, etc). Do not delete this widget! |
232 | */ | 234 | */ |
233 | QWidget *viewWidget(); | 235 | QWidget *viewWidget(); |
234 | 236 | ||
235 | private: | 237 | private: |
236 | void initGUI(); | 238 | void initGUI(); |
237 | 239 | ||
238 | DefaultFilterType mDefaultFilterType; | 240 | DefaultFilterType mDefaultFilterType; |
239 | Filter mFilter; | 241 | Filter mFilter; |
240 | QString mDefaultFilterName; | 242 | QString mDefaultFilterName; |
241 | KABC::AddressBook *mAddressBook; | 243 | KABC::AddressBook *mAddressBook; |
242 | KABC::Field::List mFieldList; | 244 | KABC::Field::List mFieldList; |
243 | 245 | ||
244 | QWidget *mViewWidget; | 246 | QWidget *mViewWidget; |
245 | }; | 247 | }; |
246 | 248 | ||
247 | #ifndef KAB_EMBEDDED | 249 | #ifndef KAB_EMBEDDED |
248 | //MOC_SKIP_BEGIN | 250 | //MOC_SKIP_BEGIN |
249 | class ViewFactory : public KLibFactory | 251 | class ViewFactory : public KLibFactory |
250 | //MOC_SKIP_END | 252 | //MOC_SKIP_END |
251 | #else //KAB_EMBEDDED | 253 | #else //KAB_EMBEDDED |
252 | class ViewFactory | 254 | class ViewFactory |
253 | #endif //KAB_EMBEDDED | 255 | #endif //KAB_EMBEDDED |
254 | { | 256 | { |
255 | 257 | ||
256 | public: | 258 | public: |
257 | virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, | 259 | virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, |
258 | const char *name = 0 ) = 0; | 260 | const char *name = 0 ) = 0; |
259 | 261 | ||
260 | /** | 262 | /** |
261 | @return The type of the view. This is normally a small one word | 263 | @return The type of the view. This is normally a small one word |
262 | string (ie: Table, Icon, Tree, etc). | 264 | string (ie: Table, Icon, Tree, etc). |
263 | */ | 265 | */ |
264 | virtual QString type() const = 0; | 266 | virtual QString type() const = 0; |
265 | 267 | ||
266 | /** | 268 | /** |
267 | @return The description of the view. This should be a 3 to | 269 | @return The description of the view. This should be a 3 to |
268 | 4 line string (don't actually use return characters in the string) | 270 | 4 line string (don't actually use return characters in the string) |
269 | describing the features offered by the view. | 271 | describing the features offered by the view. |
270 | */ | 272 | */ |
271 | virtual QString description() const = 0; | 273 | virtual QString description() const = 0; |
272 | 274 | ||
273 | /** | 275 | /** |
274 | Creates a config dialog for the view type. The default | 276 | Creates a config dialog for the view type. The default |
275 | implementation will return a ViewConfigDialog. This default | 277 | implementation will return a ViewConfigDialog. This default |
276 | dialog will allow the user to set the visible fields only. If | 278 | dialog will allow the user to set the visible fields only. If |
277 | you need more config options (as most views will), this method | 279 | you need more config options (as most views will), this method |
278 | can be overloaded to return your sublcass of ViewConfigDialog. | 280 | can be overloaded to return your sublcass of ViewConfigDialog. |
279 | If this method is over loaded the base classes method should | 281 | If this method is over loaded the base classes method should |
280 | <B>not</B> be called. | 282 | <B>not</B> be called. |
281 | */ | 283 | */ |
282 | virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, | 284 | virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, |
283 | QWidget *parent, | 285 | QWidget *parent, |
284 | const char *name = 0 ); | 286 | const char *name = 0 ); |
285 | 287 | ||
286 | protected: | 288 | protected: |
287 | virtual QObject* createObject( QObject*, const char*, const char*, | 289 | virtual QObject* createObject( QObject*, const char*, const char*, |
288 | const QStringList & ) | 290 | const QStringList & ) |
289 | { | 291 | { |
290 | return 0; | 292 | return 0; |
291 | } | 293 | } |
292 | 294 | ||
293 | }; | 295 | }; |
294 | 296 | ||
295 | 297 | ||
296 | #endif | 298 | #endif |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index c6baeac..f4fb08b 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -1,472 +1,481 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | 64 | ||
65 | #include <kabc/addressbook.h> | 65 | #include <kabc/addressbook.h> |
66 | #include "filtereditdialog.h" | 66 | #include "filtereditdialog.h" |
67 | #include "addviewdialog.h" | 67 | #include "addviewdialog.h" |
68 | #include "kabcore.h" | 68 | #include "kabcore.h" |
69 | #include "kabprefs.h" | 69 | #include "kabprefs.h" |
70 | #include "viewmanager.h" | 70 | #include "viewmanager.h" |
71 | 71 | ||
72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
74 | { | 74 | { |
75 | initGUI(); | 75 | initGUI(); |
76 | initActions(); | 76 | initActions(); |
77 | 77 | ||
78 | mViewDict.setAutoDelete( true ); | 78 | mViewDict.setAutoDelete( true ); |
79 | 79 | ||
80 | createViewFactories(); | 80 | createViewFactories(); |
81 | } | 81 | } |
82 | 82 | ||
83 | ViewManager::~ViewManager() | 83 | ViewManager::~ViewManager() |
84 | { | 84 | { |
85 | unloadViews(); | 85 | unloadViews(); |
86 | mViewFactoryDict.clear(); | 86 | mViewFactoryDict.clear(); |
87 | } | 87 | } |
88 | 88 | void ViewManager::scrollUP() | |
89 | { | ||
90 | if ( mActiveView ) | ||
91 | mActiveView->scrollUP(); | ||
92 | } | ||
93 | void ViewManager::scrollDOWN() | ||
94 | { | ||
95 | if ( mActiveView ) | ||
96 | mActiveView->scrollDOWN(); | ||
97 | } | ||
89 | void ViewManager::restoreSettings() | 98 | void ViewManager::restoreSettings() |
90 | { | 99 | { |
91 | mViewNameList = KABPrefs::instance()->mViewNames; | 100 | mViewNameList = KABPrefs::instance()->mViewNames; |
92 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 101 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
93 | 102 | ||
94 | mActionSelectView->setItems( mViewNameList ); | 103 | mActionSelectView->setItems( mViewNameList ); |
95 | 104 | ||
96 | // Filter | 105 | // Filter |
97 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
98 | mActionSelectFilter->setItems( filterNames() ); | 107 | mActionSelectFilter->setItems( filterNames() ); |
99 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
100 | 109 | ||
101 | // Tell the views to reread their config, since they may have | 110 | // Tell the views to reread their config, since they may have |
102 | // been modified by global settings | 111 | // been modified by global settings |
103 | QString _oldgroup = mCore->config()->group(); | 112 | QString _oldgroup = mCore->config()->group(); |
104 | 113 | ||
105 | QDictIterator<KAddressBookView> it( mViewDict ); | 114 | QDictIterator<KAddressBookView> it( mViewDict ); |
106 | for ( it.toFirst(); it.current(); ++it ) { | 115 | for ( it.toFirst(); it.current(); ++it ) { |
107 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
108 | it.current()->readConfig( mCore->config() ); | 117 | it.current()->readConfig( mCore->config() ); |
109 | } | 118 | } |
110 | setActiveView( activeViewName ); | 119 | setActiveView( activeViewName ); |
111 | 120 | ||
112 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
113 | } | 122 | } |
114 | 123 | ||
115 | void ViewManager::saveSettings() | 124 | void ViewManager::saveSettings() |
116 | { | 125 | { |
117 | QString _oldgroup = mCore->config()->group(); | 126 | QString _oldgroup = mCore->config()->group(); |
118 | 127 | ||
119 | QDictIterator<KAddressBookView> it( mViewDict ); | 128 | QDictIterator<KAddressBookView> it( mViewDict ); |
120 | for ( it.toFirst(); it.current(); ++it ) { | 129 | for ( it.toFirst(); it.current(); ++it ) { |
121 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
122 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
123 | (*it)->writeConfig( mCore->config() ); | 132 | (*it)->writeConfig( mCore->config() ); |
124 | #else | 133 | #else |
125 | (*it).writeConfig( mCore->config() ); | 134 | (*it).writeConfig( mCore->config() ); |
126 | #endif | 135 | #endif |
127 | } | 136 | } |
128 | 137 | ||
129 | Filter::save( mCore->config(), "Filter", mFilterList ); | 138 | Filter::save( mCore->config(), "Filter", mFilterList ); |
130 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
131 | 140 | ||
132 | // write the view name list | 141 | // write the view name list |
133 | KABPrefs::instance()->mViewNames = mViewNameList; | 142 | KABPrefs::instance()->mViewNames = mViewNameList; |
134 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
135 | 144 | ||
136 | } | 145 | } |
137 | 146 | ||
138 | QStringList ViewManager::selectedUids() const | 147 | QStringList ViewManager::selectedUids() const |
139 | { | 148 | { |
140 | if ( mActiveView ) | 149 | if ( mActiveView ) |
141 | return mActiveView->selectedUids(); | 150 | return mActiveView->selectedUids(); |
142 | else | 151 | else |
143 | return QStringList(); | 152 | return QStringList(); |
144 | } | 153 | } |
145 | 154 | ||
146 | QStringList ViewManager::selectedEmails() const | 155 | QStringList ViewManager::selectedEmails() const |
147 | { | 156 | { |
148 | if ( mActiveView ) | 157 | if ( mActiveView ) |
149 | return mActiveView->selectedEmails(); | 158 | return mActiveView->selectedEmails(); |
150 | else | 159 | else |
151 | return QStringList(); | 160 | return QStringList(); |
152 | } | 161 | } |
153 | 162 | ||
154 | KABC::Addressee::List ViewManager::selectedAddressees() const | 163 | KABC::Addressee::List ViewManager::selectedAddressees() const |
155 | { | 164 | { |
156 | KABC::Addressee::List list; | 165 | KABC::Addressee::List list; |
157 | if ( mActiveView ) { | 166 | if ( mActiveView ) { |
158 | QStringList uids = mActiveView->selectedUids(); | 167 | QStringList uids = mActiveView->selectedUids(); |
159 | QStringList::Iterator it; | 168 | QStringList::Iterator it; |
160 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 169 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
161 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
162 | if ( !addr.isEmpty() ) | 171 | if ( !addr.isEmpty() ) |
163 | list.append( addr ); | 172 | list.append( addr ); |
164 | } | 173 | } |
165 | } | 174 | } |
166 | 175 | ||
167 | return list; | 176 | return list; |
168 | } | 177 | } |
169 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 178 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
170 | void ViewManager::setSelected() | 179 | void ViewManager::setSelected() |
171 | { | 180 | { |
172 | setSelected( QString::null, true ); | 181 | setSelected( QString::null, true ); |
173 | } | 182 | } |
174 | 183 | ||
175 | void ViewManager::setSelected( const QString &uid, bool selected ) | 184 | void ViewManager::setSelected( const QString &uid, bool selected ) |
176 | { | 185 | { |
177 | if ( mActiveView ) | 186 | if ( mActiveView ) |
178 | mActiveView->setSelected( uid, selected ); | 187 | mActiveView->setSelected( uid, selected ); |
179 | } | 188 | } |
180 | 189 | ||
181 | void ViewManager::setListSelected(QStringList list) | 190 | void ViewManager::setListSelected(QStringList list) |
182 | { | 191 | { |
183 | int i, count = list.count(); | 192 | int i, count = list.count(); |
184 | for ( i = 0; i < count;++i ) | 193 | for ( i = 0; i < count;++i ) |
185 | setSelected( list[i], true ); | 194 | setSelected( list[i], true ); |
186 | 195 | ||
187 | } | 196 | } |
188 | void ViewManager::unloadViews() | 197 | void ViewManager::unloadViews() |
189 | { | 198 | { |
190 | mViewDict.clear(); | 199 | mViewDict.clear(); |
191 | mActiveView = 0; | 200 | mActiveView = 0; |
192 | } | 201 | } |
193 | 202 | ||
194 | void ViewManager::setActiveView( const QString &name ) | 203 | void ViewManager::setActiveView( const QString &name ) |
195 | { | 204 | { |
196 | KAddressBookView *view = 0; | 205 | KAddressBookView *view = 0; |
197 | 206 | ||
198 | // Check that this isn't the same as the current active view | 207 | // Check that this isn't the same as the current active view |
199 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 208 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
200 | return; | 209 | return; |
201 | 210 | ||
202 | // At this point we know the view that should be active is not | 211 | // At this point we know the view that should be active is not |
203 | // currently active. We will try to find the new on in the list. If | 212 | // currently active. We will try to find the new on in the list. If |
204 | // we can't find it, it means it hasn't been instantiated, so we will | 213 | // we can't find it, it means it hasn't been instantiated, so we will |
205 | // create it on demand. | 214 | // create it on demand. |
206 | 215 | ||
207 | view = mViewDict.find( name ); | 216 | view = mViewDict.find( name ); |
208 | 217 | ||
209 | // Check if we found the view. If we didn't, then we need to create it | 218 | // Check if we found the view. If we didn't, then we need to create it |
210 | if ( view == 0 ) { | 219 | if ( view == 0 ) { |
211 | KConfig *config = mCore->config(); | 220 | KConfig *config = mCore->config(); |
212 | 221 | ||
213 | KConfigGroupSaver saver( config, name ); | 222 | KConfigGroupSaver saver( config, name ); |
214 | 223 | ||
215 | QString type = config->readEntry( "Type", "Table" ); | 224 | QString type = config->readEntry( "Type", "Table" ); |
216 | 225 | ||
217 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
218 | 227 | ||
219 | ViewFactory *factory = mViewFactoryDict.find( type ); | 228 | ViewFactory *factory = mViewFactoryDict.find( type ); |
220 | if ( factory ) | 229 | if ( factory ) |
221 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
222 | 231 | ||
223 | if ( view ) { | 232 | if ( view ) { |
224 | view->setCaption( name ); | 233 | view->setCaption( name ); |
225 | mViewDict.insert( name, view ); | 234 | mViewDict.insert( name, view ); |
226 | //US my version needs an int as second parameter to addWidget | 235 | //US my version needs an int as second parameter to addWidget |
227 | mViewWidgetStack->addWidget( view, -1 ); | 236 | mViewWidgetStack->addWidget( view, -1 ); |
228 | view->readConfig( config ); | 237 | view->readConfig( config ); |
229 | 238 | ||
230 | // The manager just relays the signals | 239 | // The manager just relays the signals |
231 | connect( view, SIGNAL( selected( const QString& ) ), | 240 | connect( view, SIGNAL( selected( const QString& ) ), |
232 | SIGNAL( selected( const QString & ) ) ); | 241 | SIGNAL( selected( const QString & ) ) ); |
233 | connect( view, SIGNAL( executed( const QString& ) ), | 242 | connect( view, SIGNAL( executed( const QString& ) ), |
234 | SIGNAL( executed( const QString& ) ) ); | 243 | SIGNAL( executed( const QString& ) ) ); |
235 | 244 | ||
236 | connect( view, SIGNAL( deleteRequest( ) ), | 245 | connect( view, SIGNAL( deleteRequest( ) ), |
237 | SIGNAL( deleteRequest( ) ) ); | 246 | SIGNAL( deleteRequest( ) ) ); |
238 | 247 | ||
239 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 248 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
240 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 249 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
241 | SLOT( dropped( QDropEvent* ) ) ); | 250 | SLOT( dropped( QDropEvent* ) ) ); |
242 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 251 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
243 | } | 252 | } |
244 | } | 253 | } |
245 | 254 | ||
246 | // If we found or created the view, raise it and refresh it | 255 | // If we found or created the view, raise it and refresh it |
247 | if ( view ) { | 256 | if ( view ) { |
248 | mActiveView = view; | 257 | mActiveView = view; |
249 | mViewWidgetStack->raiseWidget( view ); | 258 | mViewWidgetStack->raiseWidget( view ); |
250 | // Set the proper filter in the view. By setting the combo | 259 | // Set the proper filter in the view. By setting the combo |
251 | // box, the activated slot will be called, which will push | 260 | // box, the activated slot will be called, which will push |
252 | // the filter to the view and refresh it. | 261 | // the filter to the view and refresh it. |
253 | 262 | ||
254 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 263 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
255 | 264 | ||
256 | mActionSelectFilter->setCurrentItem( 0 ); | 265 | mActionSelectFilter->setCurrentItem( 0 ); |
257 | setActiveFilter( 0 ); | 266 | setActiveFilter( 0 ); |
258 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 267 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
259 | setActiveFilter( mActionSelectFilter->currentItem() ); | 268 | setActiveFilter( mActionSelectFilter->currentItem() ); |
260 | } else { | 269 | } else { |
261 | uint pos = filterPosition( view->defaultFilterName() ); | 270 | uint pos = filterPosition( view->defaultFilterName() ); |
262 | mActionSelectFilter->setCurrentItem( pos ); | 271 | mActionSelectFilter->setCurrentItem( pos ); |
263 | setActiveFilter( pos ); | 272 | setActiveFilter( pos ); |
264 | } | 273 | } |
265 | //US qDebug("ViewManager::setActiveView 6" ); | 274 | //US qDebug("ViewManager::setActiveView 6" ); |
266 | 275 | ||
267 | // Update the inc search widget to show the fields in the new active | 276 | // Update the inc search widget to show the fields in the new active |
268 | // view. | 277 | // view. |
269 | mCore->setSearchFields( mActiveView->fields() ); | 278 | mCore->setSearchFields( mActiveView->fields() ); |
270 | 279 | ||
271 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
272 | //US mActiveView->refresh(); | 281 | //US mActiveView->refresh(); |
273 | 282 | ||
274 | } | 283 | } |
275 | else | 284 | else |
276 | { | 285 | { |
277 | qDebug("ViewManager::setActiveView: unable to find view" ); | 286 | qDebug("ViewManager::setActiveView: unable to find view" ); |
278 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
279 | } | 288 | } |
280 | } | 289 | } |
281 | 290 | ||
282 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 291 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
283 | void ViewManager::refreshView() | 292 | void ViewManager::refreshView() |
284 | { | 293 | { |
285 | refreshView( QString::null ); | 294 | refreshView( QString::null ); |
286 | } | 295 | } |
287 | 296 | ||
288 | void ViewManager::refreshView( const QString &uid ) | 297 | void ViewManager::refreshView( const QString &uid ) |
289 | { | 298 | { |
290 | if ( mActiveView ) | 299 | if ( mActiveView ) |
291 | mActiveView->refresh( uid ); | 300 | mActiveView->refresh( uid ); |
292 | } | 301 | } |
293 | 302 | ||
294 | void ViewManager::editView() | 303 | void ViewManager::editView() |
295 | { | 304 | { |
296 | if ( !mActiveView ) | 305 | if ( !mActiveView ) |
297 | return; | 306 | return; |
298 | 307 | ||
299 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 308 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
300 | ViewConfigureWidget *wdg = 0; | 309 | ViewConfigureWidget *wdg = 0; |
301 | ViewConfigureDialog* dlg = 0; | 310 | ViewConfigureDialog* dlg = 0; |
302 | if ( factory ) { | 311 | if ( factory ) { |
303 | // Save the filters so the dialog has the latest set | 312 | // Save the filters so the dialog has the latest set |
304 | Filter::save( mCore->config(), "Filter", mFilterList ); | 313 | Filter::save( mCore->config(), "Filter", mFilterList ); |
305 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 314 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
306 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 315 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
307 | } else { | 316 | } else { |
308 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 317 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
309 | return; | 318 | return; |
310 | } | 319 | } |
311 | if ( wdg ) { | 320 | if ( wdg ) { |
312 | dlg->setWidget( wdg ); | 321 | dlg->setWidget( wdg ); |
313 | 322 | ||
314 | #ifndef DESKTOP_VERSION | 323 | #ifndef DESKTOP_VERSION |
315 | //dlg.setMaximumSize( 640, 480 ); | 324 | //dlg.setMaximumSize( 640, 480 ); |
316 | //dlg->setGeometry( 40,40, 400, 300); | 325 | //dlg->setGeometry( 40,40, 400, 300); |
317 | dlg->showMaximized(); | 326 | dlg->showMaximized(); |
318 | #endif | 327 | #endif |
319 | 328 | ||
320 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 329 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
321 | 330 | ||
322 | dlg->restoreSettings( mCore->config() ); | 331 | dlg->restoreSettings( mCore->config() ); |
323 | 332 | ||
324 | if ( dlg->exec() ) { | 333 | if ( dlg->exec() ) { |
325 | dlg->saveSettings( mCore->config() ); | 334 | dlg->saveSettings( mCore->config() ); |
326 | mActiveView->readConfig( mCore->config() ); | 335 | mActiveView->readConfig( mCore->config() ); |
327 | 336 | ||
328 | // Set the proper filter in the view. By setting the combo | 337 | // Set the proper filter in the view. By setting the combo |
329 | // box, the activated slot will be called, which will push | 338 | // box, the activated slot will be called, which will push |
330 | // the filter to the view and refresh it. | 339 | // the filter to the view and refresh it. |
331 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 340 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
332 | mActionSelectFilter->setCurrentItem( 0 ); | 341 | mActionSelectFilter->setCurrentItem( 0 ); |
333 | setActiveFilter( 0 ); | 342 | setActiveFilter( 0 ); |
334 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 343 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
335 | setActiveFilter( mActionSelectFilter->currentItem() ); | 344 | setActiveFilter( mActionSelectFilter->currentItem() ); |
336 | } else { | 345 | } else { |
337 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 346 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
338 | mActionSelectFilter->setCurrentItem( pos ); | 347 | mActionSelectFilter->setCurrentItem( pos ); |
339 | setActiveFilter( pos ); | 348 | setActiveFilter( pos ); |
340 | } | 349 | } |
341 | mCore->setSearchFields( mActiveView->fields() ); | 350 | mCore->setSearchFields( mActiveView->fields() ); |
342 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 351 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
343 | //US mActiveView->refresh(); | 352 | //US mActiveView->refresh(); |
344 | 353 | ||
345 | 354 | ||
346 | //US this is a bugfix, that we get notified if we change a views configuration | 355 | //US this is a bugfix, that we get notified if we change a views configuration |
347 | emit modified(); | 356 | emit modified(); |
348 | 357 | ||
349 | } | 358 | } |
350 | 359 | ||
351 | } | 360 | } |
352 | delete dlg; | 361 | delete dlg; |
353 | } | 362 | } |
354 | 363 | ||
355 | void ViewManager::deleteView() | 364 | void ViewManager::deleteView() |
356 | { | 365 | { |
357 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 366 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
358 | .arg( mActiveView->caption() ); | 367 | .arg( mActiveView->caption() ); |
359 | QString caption = i18n( "Confirm Delete" ); | 368 | QString caption = i18n( "Confirm Delete" ); |
360 | 369 | ||
361 | 370 | ||
362 | if (QMessageBox::information( this, caption, | 371 | if (QMessageBox::information( this, caption, |
363 | text, | 372 | text, |
364 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 373 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
365 | { | 374 | { |
366 | mViewNameList.remove( mActiveView->caption() ); | 375 | mViewNameList.remove( mActiveView->caption() ); |
367 | 376 | ||
368 | // remove the view from the config file | 377 | // remove the view from the config file |
369 | KConfig *config = mCore->config(); | 378 | KConfig *config = mCore->config(); |
370 | config->deleteGroup( mActiveView->caption() ); | 379 | config->deleteGroup( mActiveView->caption() ); |
371 | 380 | ||
372 | mViewDict.remove( mActiveView->caption() ); | 381 | mViewDict.remove( mActiveView->caption() ); |
373 | mActiveView = 0; | 382 | mActiveView = 0; |
374 | 383 | ||
375 | // we are in an invalid state now, but that should be fixed after | 384 | // we are in an invalid state now, but that should be fixed after |
376 | // we emit the signal | 385 | // we emit the signal |
377 | mActionSelectView->setItems( mViewNameList ); | 386 | mActionSelectView->setItems( mViewNameList ); |
378 | if ( mViewNameList.count() > 0 ) { | 387 | if ( mViewNameList.count() > 0 ) { |
379 | mActionSelectView->setCurrentItem( 0 ); | 388 | mActionSelectView->setCurrentItem( 0 ); |
380 | setActiveView( mViewNameList[ 0 ] ); | 389 | setActiveView( mViewNameList[ 0 ] ); |
381 | } | 390 | } |
382 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 391 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
383 | } | 392 | } |
384 | } | 393 | } |
385 | 394 | ||
386 | void ViewManager::addView() | 395 | void ViewManager::addView() |
387 | { | 396 | { |
388 | AddViewDialog dialog( &mViewFactoryDict, this ); | 397 | AddViewDialog dialog( &mViewFactoryDict, this ); |
389 | 398 | ||
390 | if ( dialog.exec() ) { | 399 | if ( dialog.exec() ) { |
391 | QString newName = dialog.viewName(); | 400 | QString newName = dialog.viewName(); |
392 | QString type = dialog.viewType(); | 401 | QString type = dialog.viewType(); |
393 | 402 | ||
394 | // Check for name conflicts | 403 | // Check for name conflicts |
395 | bool firstConflict = true; | 404 | bool firstConflict = true; |
396 | int numTries = 1; | 405 | int numTries = 1; |
397 | while ( mViewNameList.contains( newName ) > 0 ) { | 406 | while ( mViewNameList.contains( newName ) > 0 ) { |
398 | if ( !firstConflict ) { | 407 | if ( !firstConflict ) { |
399 | newName = newName.left( newName.length() - 4 ); | 408 | newName = newName.left( newName.length() - 4 ); |
400 | firstConflict = false; | 409 | firstConflict = false; |
401 | } | 410 | } |
402 | 411 | ||
403 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 412 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
404 | numTries++; | 413 | numTries++; |
405 | } | 414 | } |
406 | 415 | ||
407 | // Add the new one to the list | 416 | // Add the new one to the list |
408 | mViewNameList.append( newName ); | 417 | mViewNameList.append( newName ); |
409 | 418 | ||
410 | // write the view to the config file, | 419 | // write the view to the config file, |
411 | KConfig *config = mCore->config(); | 420 | KConfig *config = mCore->config(); |
412 | 421 | ||
413 | config->deleteGroup( newName ); | 422 | config->deleteGroup( newName ); |
414 | 423 | ||
415 | KConfigGroupSaver saver( config, newName ); | 424 | KConfigGroupSaver saver( config, newName ); |
416 | 425 | ||
417 | config->writeEntry( "Type", type ); | 426 | config->writeEntry( "Type", type ); |
418 | 427 | ||
419 | // try to set the active view | 428 | // try to set the active view |
420 | mActionSelectView->setItems( mViewNameList ); | 429 | mActionSelectView->setItems( mViewNameList ); |
421 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 430 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
422 | setActiveView( newName ); | 431 | setActiveView( newName ); |
423 | 432 | ||
424 | editView(); | 433 | editView(); |
425 | 434 | ||
426 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 435 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
427 | } | 436 | } |
428 | } | 437 | } |
429 | 438 | ||
430 | void ViewManager::createViewFactories() | 439 | void ViewManager::createViewFactories() |
431 | { | 440 | { |
432 | #ifndef KAB_EMBEDDED | 441 | #ifndef KAB_EMBEDDED |
433 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 442 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
434 | KTrader::OfferList::ConstIterator it; | 443 | KTrader::OfferList::ConstIterator it; |
435 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 444 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
436 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 445 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
437 | continue; | 446 | continue; |
438 | 447 | ||
439 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 448 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
440 | 449 | ||
441 | if ( !factory ) { | 450 | if ( !factory ) { |
442 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 451 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
443 | continue; | 452 | continue; |
444 | } | 453 | } |
445 | 454 | ||
446 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 455 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
447 | 456 | ||
448 | if ( !viewFactory ) { | 457 | if ( !viewFactory ) { |
449 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 458 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
450 | continue; | 459 | continue; |
451 | } | 460 | } |
452 | 461 | ||
453 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 462 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
454 | } | 463 | } |
455 | 464 | ||
456 | #else //KAB_EMBEDDED | 465 | #else //KAB_EMBEDDED |
457 | ViewFactory* viewFactory = new IconViewFactory(); | 466 | ViewFactory* viewFactory = new IconViewFactory(); |
458 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 467 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
459 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 468 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
460 | 469 | ||
461 | viewFactory = new TableViewFactory(); | 470 | viewFactory = new TableViewFactory(); |
462 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 471 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
463 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 472 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
464 | 473 | ||
465 | viewFactory = new CardViewFactory(); | 474 | viewFactory = new CardViewFactory(); |
466 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 475 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
467 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 476 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
468 | 477 | ||
469 | #endif //KAB_EMBEDDED | 478 | #endif //KAB_EMBEDDED |
470 | 479 | ||
471 | } | 480 | } |
472 | 481 | ||
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 6def6b6..585f4e9 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -1,154 +1,156 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef VIEWMANAGER_H | 24 | #ifndef VIEWMANAGER_H |
25 | #define VIEWMANAGER_H | 25 | #define VIEWMANAGER_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <kaddressbookview.h> | 29 | #include <kaddressbookview.h> |
30 | #include <qdict.h> | 30 | #include <qdict.h> |
31 | 31 | ||
32 | class KAction; | 32 | class KAction; |
33 | class KSelectAction; | 33 | class KSelectAction; |
34 | 34 | ||
35 | class KABCore; | 35 | class KABCore; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class QDropEvent; | 37 | class QDropEvent; |
38 | 38 | ||
39 | namespace KABC { class AddressBook; } | 39 | namespace KABC { class AddressBook; } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | The view manager manages the views and everything related to them. The | 42 | The view manager manages the views and everything related to them. The |
43 | manager will load the views at startup and display a view when told to | 43 | manager will load the views at startup and display a view when told to |
44 | make one active. | 44 | make one active. |
45 | 45 | ||
46 | The view manager will also create and manage all dialogs directly related to | 46 | The view manager will also create and manage all dialogs directly related to |
47 | views (ie: AddView, ConfigureView, DeleteView, etc). | 47 | views (ie: AddView, ConfigureView, DeleteView, etc). |
48 | */ | 48 | */ |
49 | class ViewManager : public QWidget | 49 | class ViewManager : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); | 53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); |
54 | ~ViewManager(); | 54 | ~ViewManager(); |
55 | 55 | ||
56 | void restoreSettings(); | 56 | void restoreSettings(); |
57 | void saveSettings(); | 57 | void saveSettings(); |
58 | void doSearch( const QString& s ,KABC::Field *field ); | 58 | void doSearch( const QString& s ,KABC::Field *field ); |
59 | 59 | ||
60 | void unloadViews(); | 60 | void unloadViews(); |
61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } | 61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } |
62 | 62 | ||
63 | QStringList selectedUids() const; | 63 | QStringList selectedUids() const; |
64 | QStringList selectedEmails() const; | 64 | QStringList selectedEmails() const; |
65 | KABC::Addressee::List selectedAddressees() const; | 65 | KABC::Addressee::List selectedAddressees() const; |
66 | void setListSelected(QStringList); | 66 | void setListSelected(QStringList); |
67 | 67 | ||
68 | public slots: | 68 | public slots: |
69 | void scrollUP(); | ||
70 | void scrollDOWN(); | ||
69 | 71 | ||
70 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); | 72 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); |
71 | void setSelected( const QString &uid, bool); | 73 | void setSelected( const QString &uid, bool); |
72 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 74 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
73 | void setSelected(); | 75 | void setSelected(); |
74 | 76 | ||
75 | 77 | ||
76 | 78 | ||
77 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 79 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
78 | void refreshView(); | 80 | void refreshView(); |
79 | void refreshView( const QString &uid); | 81 | void refreshView( const QString &uid); |
80 | 82 | ||
81 | void editView(); | 83 | void editView(); |
82 | void deleteView(); | 84 | void deleteView(); |
83 | void addView(); | 85 | void addView(); |
84 | 86 | ||
85 | protected slots: | 87 | protected slots: |
86 | /** | 88 | /** |
87 | Called whenever the user drops something in the active view. | 89 | Called whenever the user drops something in the active view. |
88 | This method will try to decode what was dropped, and if it was | 90 | This method will try to decode what was dropped, and if it was |
89 | a valid addressee, add it to the addressbook. | 91 | a valid addressee, add it to the addressbook. |
90 | */ | 92 | */ |
91 | void dropped( QDropEvent* ); | 93 | void dropped( QDropEvent* ); |
92 | 94 | ||
93 | /** | 95 | /** |
94 | Called whenever the user attempts to start a drag in the view. | 96 | Called whenever the user attempts to start a drag in the view. |
95 | This method will convert all the selected addressees into text (vcard) | 97 | This method will convert all the selected addressees into text (vcard) |
96 | and create a drag object. | 98 | and create a drag object. |
97 | */ | 99 | */ |
98 | void startDrag(); | 100 | void startDrag(); |
99 | 101 | ||
100 | signals: | 102 | signals: |
101 | /** | 103 | /** |
102 | Emitted whenever the user selects an entry in the view. | 104 | Emitted whenever the user selects an entry in the view. |
103 | */ | 105 | */ |
104 | void selected( const QString &uid ); | 106 | void selected( const QString &uid ); |
105 | void deleteRequest( ); | 107 | void deleteRequest( ); |
106 | 108 | ||
107 | /** | 109 | /** |
108 | Emitted whenever the user activates an entry in the view. | 110 | Emitted whenever the user activates an entry in the view. |
109 | */ | 111 | */ |
110 | void executed( const QString &uid ); | 112 | void executed( const QString &uid ); |
111 | 113 | ||
112 | /** | 114 | /** |
113 | Emitted whenever the address book is modified in some way. | 115 | Emitted whenever the address book is modified in some way. |
114 | */ | 116 | */ |
115 | void modified(); | 117 | void modified(); |
116 | 118 | ||
117 | /** | 119 | /** |
118 | Emitted whenever a url is dragged on a view. | 120 | Emitted whenever a url is dragged on a view. |
119 | */ | 121 | */ |
120 | void urlDropped( const KURL& ); | 122 | void urlDropped( const KURL& ); |
121 | 123 | ||
122 | private slots: | 124 | private slots: |
123 | void setActiveView( const QString &name ); | 125 | void setActiveView( const QString &name ); |
124 | void setActiveFilter( int index ); | 126 | void setActiveFilter( int index ); |
125 | void configureFilters(); | 127 | void configureFilters(); |
126 | 128 | ||
127 | private: | 129 | private: |
128 | void createViewFactories(); | 130 | void createViewFactories(); |
129 | QStringList filterNames() const; | 131 | QStringList filterNames() const; |
130 | int filterPosition( const QString &name ) const; | 132 | int filterPosition( const QString &name ) const; |
131 | QStringList viewNames() const; | 133 | QStringList viewNames() const; |
132 | int viewPosition( const QString &name ) const; | 134 | int viewPosition( const QString &name ) const; |
133 | void initActions(); | 135 | void initActions(); |
134 | void initGUI(); | 136 | void initGUI(); |
135 | 137 | ||
136 | KABCore *mCore; | 138 | KABCore *mCore; |
137 | 139 | ||
138 | Filter mCurrentFilter; | 140 | Filter mCurrentFilter; |
139 | Filter::List mFilterList; | 141 | Filter::List mFilterList; |
140 | 142 | ||
141 | QDict<KAddressBookView> mViewDict; | 143 | QDict<KAddressBookView> mViewDict; |
142 | QDict<ViewFactory> mViewFactoryDict; | 144 | QDict<ViewFactory> mViewFactoryDict; |
143 | QStringList mViewNameList; | 145 | QStringList mViewNameList; |
144 | 146 | ||
145 | QWidgetStack *mViewWidgetStack; | 147 | QWidgetStack *mViewWidgetStack; |
146 | KAddressBookView *mActiveView; | 148 | KAddressBookView *mActiveView; |
147 | 149 | ||
148 | KAction *mActionDeleteView; | 150 | KAction *mActionDeleteView; |
149 | KSelectAction *mActionSelectFilter; | 151 | KSelectAction *mActionSelectFilter; |
150 | KSelectAction *mActionSelectView; | 152 | KSelectAction *mActionSelectView; |
151 | 153 | ||
152 | }; | 154 | }; |
153 | 155 | ||
154 | #endif | 156 | #endif |
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 4babf67..a7bf6c9 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -1,448 +1,464 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qdragobject.h> | 24 | #include <qdragobject.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <qapplication.h> | ||
30 | 31 | ||
31 | #include <kabc/addressbook.h> | 32 | #include <kabc/addressbook.h> |
32 | #include <kabc/addressee.h> | 33 | #include <kabc/addressee.h> |
33 | #include <kconfig.h> | 34 | #include <kconfig.h> |
34 | #include <kdebug.h> | 35 | #include <kdebug.h> |
35 | #include <klocale.h> | 36 | #include <klocale.h> |
36 | 37 | ||
37 | #include "kabprefs.h" | 38 | #include "kabprefs.h" |
38 | #include "viewmanager.h" | 39 | #include "viewmanager.h" |
39 | 40 | ||
40 | #include "kaddressbookcardview.h" | 41 | #include "kaddressbookcardview.h" |
41 | 42 | ||
42 | #ifndef KAB_EMBEDDED | 43 | #ifndef KAB_EMBEDDED |
43 | extern "C" { | 44 | extern "C" { |
44 | void *init_libkaddrbk_cardview() | 45 | void *init_libkaddrbk_cardview() |
45 | { | 46 | { |
46 | return ( new CardViewFactory ); | 47 | return ( new CardViewFactory ); |
47 | } | 48 | } |
48 | } | 49 | } |
49 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
50 | 51 | ||
51 | //////////////////////////////// | 52 | //////////////////////////////// |
52 | // AddresseeCardViewItem (internal class) | 53 | // AddresseeCardViewItem (internal class) |
53 | class AddresseeCardViewItem : public CardViewItem | 54 | class AddresseeCardViewItem : public CardViewItem |
54 | { | 55 | { |
55 | public: | 56 | public: |
56 | AddresseeCardViewItem(const KABC::Field::List &fields, | 57 | AddresseeCardViewItem(const KABC::Field::List &fields, |
57 | bool showEmptyFields, | 58 | bool showEmptyFields, |
58 | KABC::AddressBook *doc, const KABC::Addressee &a, | 59 | KABC::AddressBook *doc, const KABC::Addressee &a, |
59 | CardView *parent) | 60 | CardView *parent) |
60 | : CardViewItem(parent, a.formattedName()), | 61 | : CardViewItem(parent, a.formattedName()), |
61 | mFields( fields ), mShowEmptyFields(showEmptyFields), | 62 | mFields( fields ), mShowEmptyFields(showEmptyFields), |
62 | mDocument(doc), mAddressee(a) | 63 | mDocument(doc), mAddressee(a) |
63 | { | 64 | { |
64 | if ( mFields.isEmpty() ) { | 65 | if ( mFields.isEmpty() ) { |
65 | mFields = KABC::Field::defaultFields(); | 66 | mFields = KABC::Field::defaultFields(); |
66 | } | 67 | } |
67 | refresh(); | 68 | refresh(); |
68 | } | 69 | } |
69 | 70 | ||
70 | const KABC::Addressee &addressee() const { return mAddressee; } | 71 | const KABC::Addressee &addressee() const { return mAddressee; } |
71 | 72 | ||
72 | void refresh() | 73 | void refresh() |
73 | { | 74 | { |
74 | // Update our addressee, since it may have changed elsewhere | 75 | // Update our addressee, since it may have changed elsewhere |
75 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 76 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
76 | 77 | ||
77 | if (!mAddressee.isEmpty()) | 78 | if (!mAddressee.isEmpty()) |
78 | { | 79 | { |
79 | clearFields(); | 80 | clearFields(); |
80 | 81 | ||
81 | // Try all the selected fields until we find one with text. | 82 | // Try all the selected fields until we find one with text. |
82 | // This will limit the number of unlabeled icons in the view | 83 | // This will limit the number of unlabeled icons in the view |
83 | KABC::Field::List::Iterator iter; | 84 | KABC::Field::List::Iterator iter; |
84 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) | 85 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) |
85 | { | 86 | { |
86 | // insert empty fields or not? not doing so saves a bit of memory and CPU | 87 | // insert empty fields or not? not doing so saves a bit of memory and CPU |
87 | // (during geometry calculations), but prevents having equally | 88 | // (during geometry calculations), but prevents having equally |
88 | // wide label columns in all cards, unless CardViewItem/CardView search | 89 | // wide label columns in all cards, unless CardViewItem/CardView search |
89 | // globally for the widest label. (anders) | 90 | // globally for the widest label. (anders) |
90 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) | 91 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) |
91 | insertField((*iter)->label(), (*iter)->value( mAddressee )); | 92 | insertField((*iter)->label(), (*iter)->value( mAddressee )); |
92 | } | 93 | } |
93 | 94 | ||
94 | // We might want to make this the first field. hmm... -mpilone | 95 | // We might want to make this the first field. hmm... -mpilone |
95 | setCaption( mAddressee.realName() ); | 96 | setCaption( mAddressee.realName() ); |
96 | } | 97 | } |
97 | } | 98 | } |
98 | 99 | ||
99 | private: | 100 | private: |
100 | KABC::Field::List mFields; | 101 | KABC::Field::List mFields; |
101 | bool mShowEmptyFields; | 102 | bool mShowEmptyFields; |
102 | KABC::AddressBook *mDocument; | 103 | KABC::AddressBook *mDocument; |
103 | KABC::Addressee mAddressee; | 104 | KABC::Addressee mAddressee; |
104 | }; | 105 | }; |
105 | 106 | ||
106 | /////////////////////////////// | 107 | /////////////////////////////// |
107 | // AddresseeCardView | 108 | // AddresseeCardView |
108 | 109 | ||
109 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 110 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
110 | : CardView(parent, name) | 111 | : CardView(parent, name) |
111 | { | 112 | { |
112 | setAcceptDrops(true); | 113 | setAcceptDrops(true); |
113 | } | 114 | } |
114 | 115 | ||
115 | AddresseeCardView::~AddresseeCardView() | 116 | AddresseeCardView::~AddresseeCardView() |
116 | { | 117 | { |
117 | } | 118 | } |
118 | 119 | ||
119 | 120 | ||
120 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 121 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
121 | { | 122 | { |
122 | #ifndef KAB_EMBEDDED | 123 | #ifndef KAB_EMBEDDED |
123 | if (QTextDrag::canDecode(e)) | 124 | if (QTextDrag::canDecode(e)) |
124 | e->accept(); | 125 | e->accept(); |
125 | #else //KAB_EMBEDDED | 126 | #else //KAB_EMBEDDED |
126 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 127 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
127 | #endif //KAB_EMBEDDED | 128 | #endif //KAB_EMBEDDED |
128 | } | 129 | } |
129 | 130 | ||
130 | void AddresseeCardView::dropEvent(QDropEvent *e) | 131 | void AddresseeCardView::dropEvent(QDropEvent *e) |
131 | { | 132 | { |
132 | emit addresseeDropped(e); | 133 | emit addresseeDropped(e); |
133 | } | 134 | } |
134 | 135 | ||
135 | void AddresseeCardView::startDrag() | 136 | void AddresseeCardView::startDrag() |
136 | { | 137 | { |
137 | emit startAddresseeDrag(); | 138 | emit startAddresseeDrag(); |
138 | } | 139 | } |
139 | 140 | ||
140 | 141 | ||
141 | /////////////////////////////// | 142 | /////////////////////////////// |
142 | // KAddressBookCardView | 143 | // KAddressBookCardView |
143 | 144 | ||
144 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 145 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
145 | QWidget *parent, const char *name ) | 146 | QWidget *parent, const char *name ) |
146 | : KAddressBookView( ab, parent, name ) | 147 | : KAddressBookView( ab, parent, name ) |
147 | { | 148 | { |
148 | mShowEmptyFields = false; | 149 | mShowEmptyFields = false; |
149 | 150 | ||
150 | // Init the GUI | 151 | // Init the GUI |
151 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 152 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
152 | 153 | ||
153 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 154 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
154 | mCardView->setSelectionMode(CardView::Extended); | 155 | mCardView->setSelectionMode(CardView::Extended); |
155 | layout->addWidget(mCardView); | 156 | layout->addWidget(mCardView); |
156 | 157 | ||
157 | // Connect up the signals | 158 | // Connect up the signals |
158 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 159 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
159 | this, SLOT(addresseeExecuted(CardViewItem *))); | 160 | this, SLOT(addresseeExecuted(CardViewItem *))); |
160 | connect(mCardView, SIGNAL(selectionChanged()), | 161 | connect(mCardView, SIGNAL(selectionChanged()), |
161 | this, SLOT(addresseeSelected())); | 162 | this, SLOT(addresseeSelected())); |
162 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 163 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
163 | this, SIGNAL(dropped(QDropEvent*))); | 164 | this, SIGNAL(dropped(QDropEvent*))); |
164 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 165 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
165 | this, SIGNAL(startDrag())); | 166 | this, SIGNAL(startDrag())); |
166 | } | 167 | } |
167 | 168 | ||
168 | KAddressBookCardView::~KAddressBookCardView() | 169 | KAddressBookCardView::~KAddressBookCardView() |
169 | { | 170 | { |
170 | } | 171 | } |
171 | 172 | ||
173 | void KAddressBookCardView::scrollUP() | ||
174 | { | ||
175 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | ||
176 | QApplication::postEvent( mCardView, ev ); | ||
177 | |||
178 | } | ||
179 | void KAddressBookCardView::scrollDOWN() | ||
180 | { | ||
181 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | ||
182 | QApplication::postEvent( mCardView, ev ); | ||
183 | } | ||
172 | void KAddressBookCardView::readConfig(KConfig *config) | 184 | void KAddressBookCardView::readConfig(KConfig *config) |
173 | { | 185 | { |
174 | KAddressBookView::readConfig(config); | 186 | KAddressBookView::readConfig(config); |
175 | 187 | ||
176 | // costum colors? | 188 | // costum colors? |
177 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 189 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
178 | { | 190 | { |
179 | QPalette p( mCardView->palette() ); | 191 | QPalette p( mCardView->palette() ); |
180 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 192 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
181 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 193 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
182 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 194 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
183 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 195 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
184 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 196 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
185 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 197 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
186 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 198 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
187 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 199 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
188 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 200 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
189 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 201 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
190 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 202 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
191 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 203 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
192 | mCardView->viewport()->setPalette( p ); | 204 | mCardView->viewport()->setPalette( p ); |
193 | } | 205 | } |
194 | else | 206 | else |
195 | { | 207 | { |
196 | // needed if turned off during a session. | 208 | // needed if turned off during a session. |
197 | mCardView->viewport()->setPalette( mCardView->palette() ); | 209 | mCardView->viewport()->setPalette( mCardView->palette() ); |
198 | } | 210 | } |
199 | 211 | ||
200 | //custom fonts? | 212 | //custom fonts? |
201 | QFont f( font() ); | 213 | QFont f( font() ); |
202 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 214 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
203 | { | 215 | { |
204 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 216 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
205 | f.setBold( true ); | 217 | f.setBold( true ); |
206 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 218 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
207 | } | 219 | } |
208 | else | 220 | else |
209 | { | 221 | { |
210 | mCardView->setFont( f ); | 222 | mCardView->setFont( f ); |
211 | f.setBold( true ); | 223 | f.setBold( true ); |
212 | mCardView->setHeaderFont( f ); | 224 | mCardView->setHeaderFont( f ); |
213 | } | 225 | } |
214 | 226 | ||
215 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 227 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
216 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 228 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
217 | true)); | 229 | true)); |
218 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 230 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
219 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 231 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
220 | 232 | ||
221 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 233 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
222 | 234 | ||
223 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 235 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
224 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 236 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
225 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 237 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
226 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 238 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
227 | 239 | ||
228 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 240 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
229 | this, SLOT(addresseeExecuted(CardViewItem *))); | 241 | this, SLOT(addresseeExecuted(CardViewItem *))); |
230 | 242 | ||
231 | if (KABPrefs::instance()->mHonorSingleClick) | 243 | if (KABPrefs::instance()->mHonorSingleClick) |
232 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 244 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
233 | this, SLOT(addresseeExecuted(CardViewItem *))); | 245 | this, SLOT(addresseeExecuted(CardViewItem *))); |
234 | else | 246 | else |
235 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 247 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
236 | this, SLOT(addresseeExecuted(CardViewItem *))); | 248 | this, SLOT(addresseeExecuted(CardViewItem *))); |
237 | 249 | ||
238 | } | 250 | } |
239 | 251 | ||
240 | void KAddressBookCardView::writeConfig( KConfig *config ) | 252 | void KAddressBookCardView::writeConfig( KConfig *config ) |
241 | { | 253 | { |
242 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 254 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
243 | KAddressBookView::writeConfig( config ); | 255 | KAddressBookView::writeConfig( config ); |
244 | } | 256 | } |
245 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | 257 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) |
246 | { | 258 | { |
247 | mCardView->clear(); | 259 | mCardView->clear(); |
248 | if ( s.isEmpty() || s == "*" ) { | 260 | if ( s.isEmpty() || s == "*" ) { |
249 | refresh(); | 261 | refresh(); |
250 | return; | 262 | return; |
251 | } | 263 | } |
252 | QString pattern = s.lower()+"*"; | 264 | QString pattern = s.lower()+"*"; |
253 | QRegExp re; | 265 | QRegExp re; |
254 | re.setWildcard(true); // most people understand these better. | 266 | re.setWildcard(true); // most people understand these better. |
255 | re.setCaseSensitive(false); | 267 | re.setCaseSensitive(false); |
256 | re.setPattern( pattern ); | 268 | re.setPattern( pattern ); |
257 | if (!re.isValid()) | 269 | if (!re.isValid()) |
258 | return; | 270 | return; |
259 | mCardView->viewport()->setUpdatesEnabled( false ); | 271 | mCardView->viewport()->setUpdatesEnabled( false ); |
260 | KABC::Addressee::List addresseeList = addressees(); | 272 | KABC::Addressee::List addresseeList = addressees(); |
261 | KABC::Addressee::List::Iterator it; | 273 | KABC::Addressee::List::Iterator it; |
262 | if ( field ) { | 274 | if ( field ) { |
263 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 275 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
264 | #if QT_VERSION >= 300 | 276 | #if QT_VERSION >= 300 |
265 | if (re.search(field->value( *it ).lower()) != -1) | 277 | if (re.search(field->value( *it ).lower()) != -1) |
266 | #else | 278 | #else |
267 | if (re.match(field->value( *it ).lower()) != -1) | 279 | if (re.match(field->value( *it ).lower()) != -1) |
268 | #endif | 280 | #endif |
269 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 281 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
270 | addressBook(), *it, mCardView); | 282 | addressBook(), *it, mCardView); |
271 | 283 | ||
272 | } | 284 | } |
273 | } else { | 285 | } else { |
274 | KABC::Field::List fieldList = fields(); | 286 | KABC::Field::List fieldList = fields(); |
275 | KABC::Field::List::ConstIterator fieldIt; | 287 | KABC::Field::List::ConstIterator fieldIt; |
276 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 288 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
277 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 289 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
278 | #if QT_VERSION >= 300 | 290 | #if QT_VERSION >= 300 |
279 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 291 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
280 | #else | 292 | #else |
281 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 293 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
282 | #endif | 294 | #endif |
283 | { | 295 | { |
284 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | 296 | new AddresseeCardViewItem(fields(), mShowEmptyFields, |
285 | addressBook(), *it, mCardView); | 297 | addressBook(), *it, mCardView); |
286 | continue; | 298 | continue; |
287 | } | 299 | } |
288 | } | 300 | } |
289 | } | 301 | } |
290 | } | 302 | } |
291 | mCardView->viewport()->setUpdatesEnabled( true ); | 303 | mCardView->viewport()->setUpdatesEnabled( true ); |
292 | mCardView->viewport()->update(); | 304 | mCardView->viewport()->update(); |
293 | // by default nothing is selected | 305 | if ( mCardView->firstItem() ) { |
294 | emit selected(QString::null); | 306 | mCardView->setCurrentItem ( mCardView->firstItem() ); |
307 | mCardView->setSelected ( mCardView->firstItem() , true ); | ||
308 | } | ||
309 | else | ||
310 | emit selected(QString::null); | ||
295 | } | 311 | } |
296 | QStringList KAddressBookCardView::selectedUids() | 312 | QStringList KAddressBookCardView::selectedUids() |
297 | { | 313 | { |
298 | QStringList uidList; | 314 | QStringList uidList; |
299 | CardViewItem *item; | 315 | CardViewItem *item; |
300 | AddresseeCardViewItem *aItem; | 316 | AddresseeCardViewItem *aItem; |
301 | 317 | ||
302 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 318 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
303 | { | 319 | { |
304 | if (item->isSelected()) | 320 | if (item->isSelected()) |
305 | { | 321 | { |
306 | #ifndef KAB_EMBEDDED | 322 | #ifndef KAB_EMBEDDED |
307 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 323 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
308 | #else //KAB_EMBEDDED | 324 | #else //KAB_EMBEDDED |
309 | aItem = (AddresseeCardViewItem*)(item); | 325 | aItem = (AddresseeCardViewItem*)(item); |
310 | #endif //KAB_EMBEDDED | 326 | #endif //KAB_EMBEDDED |
311 | if (aItem) | 327 | if (aItem) |
312 | uidList << aItem->addressee().uid(); | 328 | uidList << aItem->addressee().uid(); |
313 | } | 329 | } |
314 | } | 330 | } |
315 | 331 | ||
316 | return uidList; | 332 | return uidList; |
317 | } | 333 | } |
318 | 334 | ||
319 | void KAddressBookCardView::refresh(QString uid) | 335 | void KAddressBookCardView::refresh(QString uid) |
320 | { | 336 | { |
321 | CardViewItem *item; | 337 | CardViewItem *item; |
322 | AddresseeCardViewItem *aItem; | 338 | AddresseeCardViewItem *aItem; |
323 | 339 | ||
324 | if (uid.isNull()) | 340 | if (uid.isNull()) |
325 | { | 341 | { |
326 | // Rebuild the view | 342 | // Rebuild the view |
327 | mCardView->viewport()->setUpdatesEnabled( false ); | 343 | mCardView->viewport()->setUpdatesEnabled( false ); |
328 | mCardView->clear(); | 344 | mCardView->clear(); |
329 | 345 | ||
330 | KABC::Addressee::List addresseeList = addressees(); | 346 | KABC::Addressee::List addresseeList = addressees(); |
331 | KABC::Addressee::List::Iterator iter; | 347 | KABC::Addressee::List::Iterator iter; |
332 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 348 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
333 | { | 349 | { |
334 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | 350 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) |
335 | continue; | 351 | continue; |
336 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 352 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
337 | addressBook(), *iter, mCardView); | 353 | addressBook(), *iter, mCardView); |
338 | } | 354 | } |
339 | mCardView->viewport()->setUpdatesEnabled( true ); | 355 | mCardView->viewport()->setUpdatesEnabled( true ); |
340 | mCardView->viewport()->update(); | 356 | mCardView->viewport()->update(); |
341 | 357 | ||
342 | // by default nothing is selected | 358 | // by default nothing is selected |
343 | emit selected(QString::null); | 359 | emit selected(QString::null); |
344 | } | 360 | } |
345 | else | 361 | else |
346 | { | 362 | { |
347 | // Try to find the one to refresh | 363 | // Try to find the one to refresh |
348 | bool found = false; | 364 | bool found = false; |
349 | for (item = mCardView->firstItem(); item && !found; | 365 | for (item = mCardView->firstItem(); item && !found; |
350 | item = item->nextItem()) | 366 | item = item->nextItem()) |
351 | { | 367 | { |
352 | #ifndef KAB_EMBEDDED | 368 | #ifndef KAB_EMBEDDED |
353 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 369 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
354 | #else //KAB_EMBEDDED | 370 | #else //KAB_EMBEDDED |
355 | aItem = (AddresseeCardViewItem*)(item); | 371 | aItem = (AddresseeCardViewItem*)(item); |
356 | #endif //KAB_EMBEDDED | 372 | #endif //KAB_EMBEDDED |
357 | 373 | ||
358 | if ((aItem) && (aItem->addressee().uid() == uid)) | 374 | if ((aItem) && (aItem->addressee().uid() == uid)) |
359 | { | 375 | { |
360 | aItem->refresh(); | 376 | aItem->refresh(); |
361 | found = true; | 377 | found = true; |
362 | } | 378 | } |
363 | } | 379 | } |
364 | } | 380 | } |
365 | } | 381 | } |
366 | 382 | ||
367 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 383 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
368 | { | 384 | { |
369 | CardViewItem *item; | 385 | CardViewItem *item; |
370 | AddresseeCardViewItem *aItem; | 386 | AddresseeCardViewItem *aItem; |
371 | 387 | ||
372 | if (uid.isNull()) | 388 | if (uid.isNull()) |
373 | { | 389 | { |
374 | mCardView->selectAll(selected); | 390 | mCardView->selectAll(selected); |
375 | } | 391 | } |
376 | else | 392 | else |
377 | { | 393 | { |
378 | bool found = false; | 394 | bool found = false; |
379 | for (item = mCardView->firstItem(); item && !found; | 395 | for (item = mCardView->firstItem(); item && !found; |
380 | item = item->nextItem()) | 396 | item = item->nextItem()) |
381 | { | 397 | { |
382 | #ifndef KAB_EMBEDDED | 398 | #ifndef KAB_EMBEDDED |
383 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 399 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
384 | #else //KAB_EMBEDDED | 400 | #else //KAB_EMBEDDED |
385 | aItem = (AddresseeCardViewItem*)(item); | 401 | aItem = (AddresseeCardViewItem*)(item); |
386 | #endif //KAB_EMBEDDED | 402 | #endif //KAB_EMBEDDED |
387 | 403 | ||
388 | if ((aItem) && (aItem->addressee().uid() == uid)) | 404 | if ((aItem) && (aItem->addressee().uid() == uid)) |
389 | { | 405 | { |
390 | mCardView->setSelected(aItem, selected); | 406 | mCardView->setSelected(aItem, selected); |
391 | mCardView->ensureItemVisible(item); | 407 | mCardView->ensureItemVisible(item); |
392 | found = true; | 408 | found = true; |
393 | } | 409 | } |
394 | } | 410 | } |
395 | } | 411 | } |
396 | } | 412 | } |
397 | 413 | ||
398 | //US added an additional method without parameter | 414 | //US added an additional method without parameter |
399 | void KAddressBookCardView::setSelected() | 415 | void KAddressBookCardView::setSelected() |
400 | { | 416 | { |
401 | setSelected(QString::null, true); | 417 | setSelected(QString::null, true); |
402 | } | 418 | } |
403 | 419 | ||
404 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 420 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
405 | { | 421 | { |
406 | #ifndef KAB_EMBEDDED | 422 | #ifndef KAB_EMBEDDED |
407 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 423 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
408 | #else //KAB_EMBEDDED | 424 | #else //KAB_EMBEDDED |
409 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 425 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
410 | #endif //KAB_EMBEDDED | 426 | #endif //KAB_EMBEDDED |
411 | if (aItem) | 427 | if (aItem) |
412 | { | 428 | { |
413 | //kdDebug()<<"... even has a valid item:)"<<endl; | 429 | //kdDebug()<<"... even has a valid item:)"<<endl; |
414 | emit executed(aItem->addressee().uid()); | 430 | emit executed(aItem->addressee().uid()); |
415 | } | 431 | } |
416 | } | 432 | } |
417 | 433 | ||
418 | void KAddressBookCardView::addresseeSelected() | 434 | void KAddressBookCardView::addresseeSelected() |
419 | { | 435 | { |
420 | CardViewItem *item; | 436 | CardViewItem *item; |
421 | AddresseeCardViewItem *aItem; | 437 | AddresseeCardViewItem *aItem; |
422 | 438 | ||
423 | bool found = false; | 439 | bool found = false; |
424 | for (item = mCardView->firstItem(); item && !found; | 440 | for (item = mCardView->firstItem(); item && !found; |
425 | item = item->nextItem()) | 441 | item = item->nextItem()) |
426 | { | 442 | { |
427 | if (item->isSelected()) | 443 | if (item->isSelected()) |
428 | { | 444 | { |
429 | #ifndef KAB_EMBEDDED | 445 | #ifndef KAB_EMBEDDED |
430 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 446 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
431 | #else //KAB_EMBEDDED | 447 | #else //KAB_EMBEDDED |
432 | aItem = (AddresseeCardViewItem*)(item); | 448 | aItem = (AddresseeCardViewItem*)(item); |
433 | #endif //KAB_EMBEDDED | 449 | #endif //KAB_EMBEDDED |
434 | if ( aItem ) | 450 | if ( aItem ) |
435 | { | 451 | { |
436 | emit selected(aItem->addressee().uid()); | 452 | emit selected(aItem->addressee().uid()); |
437 | found = true; | 453 | found = true; |
438 | } | 454 | } |
439 | } | 455 | } |
440 | } | 456 | } |
441 | 457 | ||
442 | if (!found) | 458 | if (!found) |
443 | emit selected(QString::null); | 459 | emit selected(QString::null); |
444 | 460 | ||
445 | } | 461 | } |
446 | #ifndef KAB_EMBEDDED | 462 | #ifndef KAB_EMBEDDED |
447 | #include "kaddressbookcardview.moc" | 463 | #include "kaddressbookcardview.moc" |
448 | #endif //KAB_EMBEDDED | 464 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index b8efb01..45a9781 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h | |||
@@ -1,117 +1,119 @@ | |||
1 | #ifndef KADDRESSBOOKCARDVIEW_H | 1 | #ifndef KADDRESSBOOKCARDVIEW_H |
2 | #define KADDRESSBOOKCARDVIEW_H | 2 | #define KADDRESSBOOKCARDVIEW_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | This file is part of KAddressBook. | 5 | This file is part of KAddressBook. |
6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #ifndef KAB_EMBEDDED | 28 | #ifndef KAB_EMBEDDED |
29 | #include <kiconview.h> | 29 | #include <kiconview.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #endif //KAB_EMBEDDED | 32 | #endif //KAB_EMBEDDED |
33 | 33 | ||
34 | #include "cardview.h" | 34 | #include "cardview.h" |
35 | #include "kaddressbookview.h" | 35 | #include "kaddressbookview.h" |
36 | #include "configurecardviewdialog.h" | 36 | #include "configurecardviewdialog.h" |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragEntryEvent; | 39 | class QDragEntryEvent; |
40 | class QDropEvent; | 40 | class QDropEvent; |
41 | class KConfig; | 41 | class KConfig; |
42 | class AddresseeCardView; | 42 | class AddresseeCardView; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | This view uses the CardView class to create a card view. At some | 45 | This view uses the CardView class to create a card view. At some |
46 | point in the future I think this will be the default view of | 46 | point in the future I think this will be the default view of |
47 | KAddressBook. | 47 | KAddressBook. |
48 | */ | 48 | */ |
49 | class KAddressBookCardView : public KAddressBookView | 49 | class KAddressBookCardView : public KAddressBookView |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | 52 | ||
53 | public: | 53 | public: |
54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, | 54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, |
55 | const char *name = 0 ); | 55 | const char *name = 0 ); |
56 | virtual ~KAddressBookCardView(); | 56 | virtual ~KAddressBookCardView(); |
57 | void doSearch( const QString& s,KABC::Field *field ); | 57 | void doSearch( const QString& s,KABC::Field *field ); |
58 | virtual QStringList selectedUids(); | 58 | virtual QStringList selectedUids(); |
59 | virtual QString type() const { return "Card"; } | 59 | virtual QString type() const { return "Card"; } |
60 | 60 | ||
61 | virtual void readConfig(KConfig *config); | 61 | virtual void readConfig(KConfig *config); |
62 | virtual void writeConfig(KConfig *); | 62 | virtual void writeConfig(KConfig *); |
63 | virtual void scrollUP(); | ||
64 | virtual void scrollDOWN(); | ||
63 | 65 | ||
64 | public slots: | 66 | public slots: |
65 | void refresh(QString uid = QString::null); | 67 | void refresh(QString uid = QString::null); |
66 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); | 68 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); |
67 | //US added an additional method without parameter | 69 | //US added an additional method without parameter |
68 | void setSelected(); | 70 | void setSelected(); |
69 | 71 | ||
70 | protected slots: | 72 | protected slots: |
71 | void addresseeExecuted(CardViewItem *item); | 73 | void addresseeExecuted(CardViewItem *item); |
72 | void addresseeSelected(); | 74 | void addresseeSelected(); |
73 | 75 | ||
74 | private: | 76 | private: |
75 | AddresseeCardView *mCardView; | 77 | AddresseeCardView *mCardView; |
76 | bool mShowEmptyFields; | 78 | bool mShowEmptyFields; |
77 | }; | 79 | }; |
78 | 80 | ||
79 | class AddresseeCardView : public CardView | 81 | class AddresseeCardView : public CardView |
80 | { | 82 | { |
81 | Q_OBJECT | 83 | Q_OBJECT |
82 | public: | 84 | public: |
83 | AddresseeCardView(QWidget *parent, const char *name = 0); | 85 | AddresseeCardView(QWidget *parent, const char *name = 0); |
84 | ~AddresseeCardView(); | 86 | ~AddresseeCardView(); |
85 | 87 | ||
86 | signals: | 88 | signals: |
87 | void startAddresseeDrag(); | 89 | void startAddresseeDrag(); |
88 | void addresseeDropped(QDropEvent *); | 90 | void addresseeDropped(QDropEvent *); |
89 | 91 | ||
90 | protected: | 92 | protected: |
91 | virtual void dragEnterEvent(QDragEnterEvent *); | 93 | virtual void dragEnterEvent(QDragEnterEvent *); |
92 | virtual void dropEvent(QDropEvent *); | 94 | virtual void dropEvent(QDropEvent *); |
93 | virtual void startDrag(); | 95 | virtual void startDrag(); |
94 | }; | 96 | }; |
95 | 97 | ||
96 | 98 | ||
97 | class CardViewFactory : public ViewFactory | 99 | class CardViewFactory : public ViewFactory |
98 | { | 100 | { |
99 | public: | 101 | public: |
100 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 102 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
101 | { | 103 | { |
102 | return new KAddressBookCardView( ab, parent, name ); | 104 | return new KAddressBookCardView( ab, parent, name ); |
103 | } | 105 | } |
104 | 106 | ||
105 | QString type() const { return "Card"; } | 107 | QString type() const { return "Card"; } |
106 | 108 | ||
107 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } | 109 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } |
108 | 110 | ||
109 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, | 111 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, |
110 | const char *name = 0 ) | 112 | const char *name = 0 ) |
111 | { | 113 | { |
112 | return new ConfigureCardViewWidget( ab, parent, name ); | 114 | return new ConfigureCardViewWidget( ab, parent, name ); |
113 | } | 115 | } |
114 | }; | 116 | }; |
115 | 117 | ||
116 | 118 | ||
117 | #endif | 119 | #endif |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index fdc0db9..f4c68b8 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -1,429 +1,446 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | 27 | ||
28 | #include <kabc/addressee.h> | 28 | #include <kabc/addressee.h> |
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #else //KAB_EMBEDDED | 35 | #else //KAB_EMBEDDED |
36 | #endif //KAB_EMBEDDED | 36 | #endif //KAB_EMBEDDED |
37 | 37 | ||
38 | #include <kabc/addressbook.h> | 38 | #include <kabc/addressbook.h> |
39 | #include "kabprefs.h" | 39 | #include "kabprefs.h" |
40 | #include "viewmanager.h" | 40 | #include "viewmanager.h" |
41 | #include "kaddressbookiconview.h" | 41 | #include "kaddressbookiconview.h" |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qapplication.h> | ||
44 | #include <kglobal.h> | 45 | #include <kglobal.h> |
45 | /*US transfered to the headerfile | 46 | /*US transfered to the headerfile |
46 | class IconViewFactory : public ViewFactory | 47 | class IconViewFactory : public ViewFactory |
47 | { | 48 | { |
48 | public: | 49 | public: |
49 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 50 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
50 | { | 51 | { |
51 | return new KAddressBookIconView( ab, parent, name ); | 52 | return new KAddressBookIconView( ab, parent, name ); |
52 | } | 53 | } |
53 | 54 | ||
54 | QString type() const { return "Icon"; } | 55 | QString type() const { return "Icon"; } |
55 | 56 | ||
56 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 57 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
57 | }; | 58 | }; |
58 | 59 | ||
59 | */ | 60 | */ |
60 | 61 | ||
61 | extern "C" { | 62 | extern "C" { |
62 | void *init_libkaddrbk_iconview() | 63 | void *init_libkaddrbk_iconview() |
63 | { | 64 | { |
64 | return ( new IconViewFactory ); | 65 | return ( new IconViewFactory ); |
65 | } | 66 | } |
66 | } | 67 | } |
67 | 68 | ||
68 | //////////////////////////////// | 69 | //////////////////////////////// |
69 | // AddresseeIconView (internal class) | 70 | // AddresseeIconView (internal class) |
70 | #ifndef KAB_EMBEDDED | 71 | #ifndef KAB_EMBEDDED |
71 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 72 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
72 | : KIconView(parent, name) | 73 | : KIconView(parent, name) |
73 | #else //KAB_EMBEDDED | 74 | #else //KAB_EMBEDDED |
74 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 75 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
75 | : QIconView(parent, name) | 76 | : QIconView(parent, name) |
76 | #endif //KAB_EMBEDDED | 77 | #endif //KAB_EMBEDDED |
77 | 78 | ||
78 | { | 79 | { |
79 | setSelectionMode( QIconView::Extended ); | 80 | setSelectionMode( QIconView::Extended ); |
80 | setResizeMode( QIconView::Adjust ); | 81 | setResizeMode( QIconView::Adjust ); |
81 | setWordWrapIconText( true ); | 82 | setWordWrapIconText( true ); |
82 | setGridX( 100 ); | 83 | setGridX( 100 ); |
83 | setItemsMovable(false); | 84 | setItemsMovable(false); |
84 | setSorting(true, true); | 85 | setSorting(true, true); |
85 | 86 | ||
86 | 87 | ||
87 | //US ??? setMode( KIconView::Select ); | 88 | //US ??? setMode( KIconView::Select ); |
88 | 89 | ||
89 | #ifndef KAB_EMBEDDED | 90 | #ifndef KAB_EMBEDDED |
90 | 91 | ||
91 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 92 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), |
92 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 93 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); |
93 | #endif //KAB_EMBEDDED | 94 | #endif //KAB_EMBEDDED |
94 | } | 95 | } |
95 | 96 | ||
96 | AddresseeIconView::~AddresseeIconView() | 97 | AddresseeIconView::~AddresseeIconView() |
97 | { | 98 | { |
98 | } | 99 | } |
99 | 100 | ||
100 | 101 | ||
101 | void AddresseeIconView::itemDropped(QDropEvent *e, | 102 | void AddresseeIconView::itemDropped(QDropEvent *e, |
102 | const QValueList<QIconDragItem> &) | 103 | const QValueList<QIconDragItem> &) |
103 | { | 104 | { |
104 | emit addresseeDropped(e); | 105 | emit addresseeDropped(e); |
105 | } | 106 | } |
106 | 107 | ||
107 | QDragObject *AddresseeIconView::dragObject() | 108 | QDragObject *AddresseeIconView::dragObject() |
108 | { | 109 | { |
109 | emit startAddresseeDrag(); | 110 | emit startAddresseeDrag(); |
110 | 111 | ||
111 | // We never want IconView to start the drag | 112 | // We never want IconView to start the drag |
112 | return 0; | 113 | return 0; |
113 | } | 114 | } |
114 | //////////////////////////////// | 115 | //////////////////////////////// |
115 | // AddresseeIconViewItem (internal class) | 116 | // AddresseeIconViewItem (internal class) |
116 | #ifndef KAB_EMBEDDED | 117 | #ifndef KAB_EMBEDDED |
117 | class AddresseeIconViewItem : public KIconViewItem | 118 | class AddresseeIconViewItem : public KIconViewItem |
118 | #else //KAB_EMBEDDED | 119 | #else //KAB_EMBEDDED |
119 | class AddresseeIconViewItem : public QIconViewItem | 120 | class AddresseeIconViewItem : public QIconViewItem |
120 | #endif //KAB_EMBEDDED | 121 | #endif //KAB_EMBEDDED |
121 | { | 122 | { |
122 | public: | 123 | public: |
123 | #ifndef KAB_EMBEDDED | 124 | #ifndef KAB_EMBEDDED |
124 | AddresseeIconViewItem(const KABC::Field::List &fields, | 125 | AddresseeIconViewItem(const KABC::Field::List &fields, |
125 | KABC::AddressBook *doc, const KABC::Addressee &a, | 126 | KABC::AddressBook *doc, const KABC::Addressee &a, |
126 | QIconView *parent) | 127 | QIconView *parent) |
127 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 128 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
128 | #else //KAB_EMBEDDED | 129 | #else //KAB_EMBEDDED |
129 | AddresseeIconViewItem(const KABC::Field::List &fields, | 130 | AddresseeIconViewItem(const KABC::Field::List &fields, |
130 | KABC::AddressBook *doc, const KABC::Addressee &a, | 131 | KABC::AddressBook *doc, const KABC::Addressee &a, |
131 | QIconView *parent) | 132 | QIconView *parent) |
132 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 133 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
133 | #endif //KAB_EMBEDDED | 134 | #endif //KAB_EMBEDDED |
134 | { | 135 | { |
135 | if ( mFields.isEmpty() ) { | 136 | if ( mFields.isEmpty() ) { |
136 | mFields = KABC::Field::defaultFields(); | 137 | mFields = KABC::Field::defaultFields(); |
137 | } | 138 | } |
138 | refresh(); | 139 | refresh(); |
139 | } | 140 | } |
140 | 141 | ||
141 | const KABC::Addressee &addressee() const { return mAddressee; } | 142 | const KABC::Addressee &addressee() const { return mAddressee; } |
142 | 143 | ||
143 | void refresh() | 144 | void refresh() |
144 | { | 145 | { |
145 | // Update our addressee, since it may have changed elsewhere | 146 | // Update our addressee, since it may have changed elsewhere |
146 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 147 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
147 | 148 | ||
148 | if (!mAddressee.isEmpty()) | 149 | if (!mAddressee.isEmpty()) |
149 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); | 150 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); |
150 | 151 | ||
151 | QPixmap icon; | 152 | QPixmap icon; |
152 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); | 153 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); |
153 | KABC::Picture pic = mAddressee.photo(); | 154 | KABC::Picture pic = mAddressee.photo(); |
154 | if ( pic.data().isNull() ) | 155 | if ( pic.data().isNull() ) |
155 | pic = mAddressee.logo(); | 156 | pic = mAddressee.logo(); |
156 | 157 | ||
157 | if ( pic.isIntern() && !pic.data().isNull() ) { | 158 | if ( pic.isIntern() && !pic.data().isNull() ) { |
158 | QImage img = pic.data(); | 159 | QImage img = pic.data(); |
159 | #ifndef KAB_EMBEDDED | 160 | #ifndef KAB_EMBEDDED |
160 | if ( img.width() > img.height() ) | 161 | if ( img.width() > img.height() ) |
161 | icon = img.scaleWidth( 32 ); | 162 | icon = img.scaleWidth( 32 ); |
162 | else | 163 | else |
163 | icon = img.scaleHeight( 32 ); | 164 | icon = img.scaleHeight( 32 ); |
164 | #else //KAB_EMBEDDED | 165 | #else //KAB_EMBEDDED |
165 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); | 166 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); |
166 | icon.convertFromImage(img.smoothScale(32, 32)); | 167 | icon.convertFromImage(img.smoothScale(32, 32)); |
167 | #endif //KAB_EMBEDDED | 168 | #endif //KAB_EMBEDDED |
168 | 169 | ||
169 | } else | 170 | } else |
170 | icon = defaultIcon; | 171 | icon = defaultIcon; |
171 | 172 | ||
172 | setPixmap( icon ); | 173 | setPixmap( icon ); |
173 | } | 174 | } |
174 | 175 | ||
175 | private: | 176 | private: |
176 | KABC::Field::List mFields; | 177 | KABC::Field::List mFields; |
177 | KABC::AddressBook *mDocument; | 178 | KABC::AddressBook *mDocument; |
178 | KABC::Addressee mAddressee; | 179 | KABC::Addressee mAddressee; |
179 | }; | 180 | }; |
180 | 181 | ||
181 | /////////////////////////////// | 182 | /////////////////////////////// |
182 | // KAddressBookView | 183 | // KAddressBookView |
183 | 184 | ||
184 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 185 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
185 | QWidget *parent, const char *name) | 186 | QWidget *parent, const char *name) |
186 | : KAddressBookView( ab, parent, name ) | 187 | : KAddressBookView( ab, parent, name ) |
187 | { | 188 | { |
188 | // Init the GUI | 189 | // Init the GUI |
189 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 190 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
190 | 191 | ||
191 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 192 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
192 | layout->addWidget(mIconView); | 193 | layout->addWidget(mIconView); |
193 | 194 | ||
194 | // Connect up the signals | 195 | // Connect up the signals |
195 | 196 | ||
196 | //US method executed is part of KIconView | 197 | //US method executed is part of KIconView |
197 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 198 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
198 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 199 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
199 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 200 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
200 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 201 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
201 | 202 | ||
202 | connect(mIconView, SIGNAL(selectionChanged()), | 203 | connect(mIconView, SIGNAL(selectionChanged()), |
203 | this, SLOT(addresseeSelected())); | 204 | this, SLOT(addresseeSelected())); |
204 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 205 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
205 | this, SIGNAL(dropped(QDropEvent*))); | 206 | this, SIGNAL(dropped(QDropEvent*))); |
206 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 207 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
207 | this, SIGNAL(startDrag())); | 208 | this, SIGNAL(startDrag())); |
208 | } | 209 | } |
209 | 210 | ||
210 | KAddressBookIconView::~KAddressBookIconView() | 211 | KAddressBookIconView::~KAddressBookIconView() |
211 | { | 212 | { |
212 | } | 213 | } |
213 | 214 | ||
215 | void KAddressBookIconView::scrollUP() | ||
216 | { | ||
217 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | ||
218 | QApplication::postEvent( mIconView, ev ); | ||
219 | } | ||
220 | void KAddressBookIconView::scrollDOWN() | ||
221 | { | ||
222 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | ||
223 | QApplication::postEvent( mIconView, ev ); | ||
224 | } | ||
214 | void KAddressBookIconView::readConfig(KConfig *config) | 225 | void KAddressBookIconView::readConfig(KConfig *config) |
215 | { | 226 | { |
216 | KAddressBookView::readConfig(config); | 227 | KAddressBookView::readConfig(config); |
217 | 228 | ||
218 | //US method executed is part of KIconView | 229 | //US method executed is part of KIconView |
219 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 230 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
220 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 231 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
221 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 232 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
222 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 233 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
223 | 234 | ||
224 | //US method executed is part of KIconView. Use selectionChanged instead | 235 | //US method executed is part of KIconView. Use selectionChanged instead |
225 | /*US | 236 | /*US |
226 | if (KABPrefs::instance()->mHonorSingleClick) | 237 | if (KABPrefs::instance()->mHonorSingleClick) |
227 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 238 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
228 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 239 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
229 | else | 240 | else |
230 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 241 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
231 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 242 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
232 | */ | 243 | */ |
233 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 244 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
234 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 245 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
235 | 246 | ||
236 | } | 247 | } |
237 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | 248 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) |
238 | { | 249 | { |
239 | mIconView->clear(); | 250 | mIconView->clear(); |
240 | mIconList.clear(); | 251 | mIconList.clear(); |
241 | if ( s.isEmpty() || s == "*" ) { | 252 | if ( s.isEmpty() || s == "*" ) { |
242 | refresh(); | 253 | refresh(); |
243 | return; | 254 | return; |
244 | } | 255 | } |
245 | QString pattern = s.lower()+"*"; | 256 | QString pattern = s.lower()+"*"; |
246 | QRegExp re; | 257 | QRegExp re; |
247 | re.setWildcard(true); // most people understand these better. | 258 | re.setWildcard(true); // most people understand these better. |
248 | re.setCaseSensitive(false); | 259 | re.setCaseSensitive(false); |
249 | re.setPattern( pattern ); | 260 | re.setPattern( pattern ); |
250 | if (!re.isValid()) | 261 | if (!re.isValid()) |
251 | return; | 262 | return; |
252 | KABC::Addressee::List addresseeList = addressees(); | 263 | KABC::Addressee::List addresseeList = addressees(); |
253 | KABC::Addressee::List::Iterator it; | 264 | KABC::Addressee::List::Iterator it; |
254 | if ( field ) { | 265 | if ( field ) { |
255 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 266 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
256 | #if QT_VERSION >= 300 | 267 | #if QT_VERSION >= 300 |
257 | if (re.search(field->value( *it ).lower()) != -1) | 268 | if (re.search(field->value( *it ).lower()) != -1) |
258 | #else | 269 | #else |
259 | if (re.match(field->value( *it ).lower()) != -1) | 270 | if (re.match(field->value( *it ).lower()) != -1) |
260 | #endif | 271 | #endif |
261 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 272 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
262 | 273 | ||
263 | 274 | ||
264 | } | 275 | } |
265 | } else { | 276 | } else { |
266 | KABC::Field::List fieldList = fields(); | 277 | KABC::Field::List fieldList = fields(); |
267 | KABC::Field::List::ConstIterator fieldIt; | 278 | KABC::Field::List::ConstIterator fieldIt; |
268 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 279 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
269 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 280 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
270 | #if QT_VERSION >= 300 | 281 | #if QT_VERSION >= 300 |
271 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 282 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
272 | #else | 283 | #else |
273 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 284 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
274 | #endif | 285 | #endif |
275 | { | 286 | { |
276 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | 287 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); |
277 | continue; | 288 | continue; |
278 | } | 289 | } |
279 | } | 290 | } |
280 | } | 291 | } |
281 | } | 292 | } |
282 | mIconView->arrangeItemsInGrid( true ); | 293 | mIconView->arrangeItemsInGrid( true ); |
294 | if ( mIconView->firstItem() ) { | ||
295 | mIconView->setCurrentItem ( mIconView->firstItem() ); | ||
296 | mIconView->setSelected ( mIconView->firstItem() , true ); | ||
297 | } | ||
298 | else | ||
299 | emit selected(QString::null); | ||
283 | } | 300 | } |
284 | QStringList KAddressBookIconView::selectedUids() | 301 | QStringList KAddressBookIconView::selectedUids() |
285 | { | 302 | { |
286 | QStringList uidList; | 303 | QStringList uidList; |
287 | QIconViewItem *item; | 304 | QIconViewItem *item; |
288 | AddresseeIconViewItem *aItem; | 305 | AddresseeIconViewItem *aItem; |
289 | 306 | ||
290 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 307 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
291 | { | 308 | { |
292 | if (item->isSelected()) | 309 | if (item->isSelected()) |
293 | { | 310 | { |
294 | #ifndef KAB_EMBEDDED | 311 | #ifndef KAB_EMBEDDED |
295 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 312 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
296 | #else //KAB_EMBEDDED | 313 | #else //KAB_EMBEDDED |
297 | aItem = (AddresseeIconViewItem*)(item); | 314 | aItem = (AddresseeIconViewItem*)(item); |
298 | #endif //KAB_EMBEDDED | 315 | #endif //KAB_EMBEDDED |
299 | if (aItem) | 316 | if (aItem) |
300 | uidList << aItem->addressee().uid(); | 317 | uidList << aItem->addressee().uid(); |
301 | } | 318 | } |
302 | } | 319 | } |
303 | 320 | ||
304 | return uidList; | 321 | return uidList; |
305 | } | 322 | } |
306 | 323 | ||
307 | void KAddressBookIconView::refresh(QString uid) | 324 | void KAddressBookIconView::refresh(QString uid) |
308 | { | 325 | { |
309 | QIconViewItem *item; | 326 | QIconViewItem *item; |
310 | AddresseeIconViewItem *aItem; | 327 | AddresseeIconViewItem *aItem; |
311 | 328 | ||
312 | if ( uid.isNull() ) { | 329 | if ( uid.isNull() ) { |
313 | // Rebuild the view | 330 | // Rebuild the view |
314 | mIconView->clear(); | 331 | mIconView->clear(); |
315 | mIconList.clear(); | 332 | mIconList.clear(); |
316 | 333 | ||
317 | KABC::Addressee::List addresseeList = addressees(); | 334 | KABC::Addressee::List addresseeList = addressees(); |
318 | KABC::Addressee::List::Iterator iter; | 335 | KABC::Addressee::List::Iterator iter; |
319 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { | 336 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) { |
320 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) | 337 | if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") ) |
321 | continue; | 338 | continue; |
322 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | 339 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); |
323 | } | 340 | } |
324 | 341 | ||
325 | mIconView->arrangeItemsInGrid( true ); | 342 | mIconView->arrangeItemsInGrid( true ); |
326 | 343 | ||
327 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) | 344 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) |
328 | { | 345 | { |
329 | #ifndef KAB_EMBEDDED | 346 | #ifndef KAB_EMBEDDED |
330 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); | 347 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); |
331 | #else //KAB_EMBEDDED | 348 | #else //KAB_EMBEDDED |
332 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); | 349 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); |
333 | #endif //KAB_EMBEDDED | 350 | #endif //KAB_EMBEDDED |
334 | mIconList.append( aivi ); | 351 | mIconList.append( aivi ); |
335 | } | 352 | } |
336 | 353 | ||
337 | } else { | 354 | } else { |
338 | // Try to find the one to refresh | 355 | // Try to find the one to refresh |
339 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { | 356 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { |
340 | #ifndef KAB_EMBEDDED | 357 | #ifndef KAB_EMBEDDED |
341 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 358 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
342 | #else //KAB_EMBEDDED | 359 | #else //KAB_EMBEDDED |
343 | aItem = (AddresseeIconViewItem*)(item); | 360 | aItem = (AddresseeIconViewItem*)(item); |
344 | #endif //KAB_EMBEDDED | 361 | #endif //KAB_EMBEDDED |
345 | if ((aItem) && (aItem->addressee().uid() == uid)) { | 362 | if ((aItem) && (aItem->addressee().uid() == uid)) { |
346 | aItem->refresh(); | 363 | aItem->refresh(); |
347 | mIconView->arrangeItemsInGrid( true ); | 364 | mIconView->arrangeItemsInGrid( true ); |
348 | return; | 365 | return; |
349 | } | 366 | } |
350 | } | 367 | } |
351 | refresh( QString::null ); | 368 | refresh( QString::null ); |
352 | } | 369 | } |
353 | } | 370 | } |
354 | 371 | ||
355 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 372 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
356 | { | 373 | { |
357 | QIconViewItem *item; | 374 | QIconViewItem *item; |
358 | AddresseeIconViewItem *aItem; | 375 | AddresseeIconViewItem *aItem; |
359 | 376 | ||
360 | if (uid.isNull()) | 377 | if (uid.isNull()) |
361 | { | 378 | { |
362 | mIconView->selectAll(selected); | 379 | mIconView->selectAll(selected); |
363 | } | 380 | } |
364 | else | 381 | else |
365 | { | 382 | { |
366 | bool found = false; | 383 | bool found = false; |
367 | for (item = mIconView->firstItem(); item && !found; | 384 | for (item = mIconView->firstItem(); item && !found; |
368 | item = item->nextItem()) | 385 | item = item->nextItem()) |
369 | { | 386 | { |
370 | #ifndef KAB_EMBEDDED | 387 | #ifndef KAB_EMBEDDED |
371 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 388 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
372 | #else //KAB_EMBEDDED | 389 | #else //KAB_EMBEDDED |
373 | aItem = (AddresseeIconViewItem*)(item); | 390 | aItem = (AddresseeIconViewItem*)(item); |
374 | #endif //KAB_EMBEDDED | 391 | #endif //KAB_EMBEDDED |
375 | 392 | ||
376 | if ((aItem) && (aItem->addressee().uid() == uid)) | 393 | if ((aItem) && (aItem->addressee().uid() == uid)) |
377 | { | 394 | { |
378 | mIconView->setSelected(aItem, selected); | 395 | mIconView->setSelected(aItem, selected); |
379 | mIconView->ensureItemVisible( aItem ); | 396 | mIconView->ensureItemVisible( aItem ); |
380 | found = true; | 397 | found = true; |
381 | } | 398 | } |
382 | } | 399 | } |
383 | } | 400 | } |
384 | } | 401 | } |
385 | 402 | ||
386 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 403 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) |
387 | { | 404 | { |
388 | #ifndef KAB_EMBEDDED | 405 | #ifndef KAB_EMBEDDED |
389 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 406 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
390 | #else //KAB_EMBEDDED | 407 | #else //KAB_EMBEDDED |
391 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 408 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
392 | #endif //KAB_EMBEDDED | 409 | #endif //KAB_EMBEDDED |
393 | 410 | ||
394 | if (aItem) { | 411 | if (aItem) { |
395 | emit executed(aItem->addressee().uid()); | 412 | emit executed(aItem->addressee().uid()); |
396 | } | 413 | } |
397 | } | 414 | } |
398 | 415 | ||
399 | void KAddressBookIconView::addresseeSelected() | 416 | void KAddressBookIconView::addresseeSelected() |
400 | { | 417 | { |
401 | QIconViewItem *item; | 418 | QIconViewItem *item; |
402 | AddresseeIconViewItem *aItem; | 419 | AddresseeIconViewItem *aItem; |
403 | 420 | ||
404 | bool found = false; | 421 | bool found = false; |
405 | for (item = mIconView->firstItem(); item && !found; | 422 | for (item = mIconView->firstItem(); item && !found; |
406 | item = item->nextItem()) | 423 | item = item->nextItem()) |
407 | { | 424 | { |
408 | if (item->isSelected()) | 425 | if (item->isSelected()) |
409 | { | 426 | { |
410 | #ifndef KAB_EMBEDDED | 427 | #ifndef KAB_EMBEDDED |
411 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 428 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
412 | #else //KAB_EMBEDDED | 429 | #else //KAB_EMBEDDED |
413 | aItem = (AddresseeIconViewItem*)(item); | 430 | aItem = (AddresseeIconViewItem*)(item); |
414 | #endif //KAB_EMBEDDED | 431 | #endif //KAB_EMBEDDED |
415 | if (aItem) | 432 | if (aItem) |
416 | { | 433 | { |
417 | emit selected(aItem->addressee().uid()); | 434 | emit selected(aItem->addressee().uid()); |
418 | found = true; | 435 | found = true; |
419 | } | 436 | } |
420 | } | 437 | } |
421 | } | 438 | } |
422 | 439 | ||
423 | if (!found) | 440 | if (!found) |
424 | emit selected(QString::null); | 441 | emit selected(QString::null); |
425 | } | 442 | } |
426 | 443 | ||
427 | #ifndef KAB_EMBEDDED | 444 | #ifndef KAB_EMBEDDED |
428 | #include "kaddressbookiconview.moc" | 445 | #include "kaddressbookiconview.moc" |
429 | #endif //KAB_EMBEDDED | 446 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h index 963ee7c..acfcd71 100644 --- a/kaddressbook/views/kaddressbookiconview.h +++ b/kaddressbook/views/kaddressbookiconview.h | |||
@@ -1,131 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KADDRESSBOOKICONVIEW_H | 24 | #ifndef KADDRESSBOOKICONVIEW_H |
25 | #define KADDRESSBOOKICONVIEW_H | 25 | #define KADDRESSBOOKICONVIEW_H |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #ifndef KAB_EMBEDDED | 28 | #ifndef KAB_EMBEDDED |
29 | #include <kiconview.h> | 29 | #include <kiconview.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <qiconview.h> | 31 | #include <qiconview.h> |
32 | #include <qptrlist.h> | 32 | #include <qptrlist.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #endif //KAB_EMBEDDED | 34 | #endif //KAB_EMBEDDED |
35 | #include "kaddressbookview.h" | 35 | #include "kaddressbookview.h" |
36 | 36 | ||
37 | class QIconViewItem; | 37 | class QIconViewItem; |
38 | class KConfig; | 38 | class KConfig; |
39 | class AddresseeIconView; | 39 | class AddresseeIconView; |
40 | class AddresseeIconViewItem; | 40 | class AddresseeIconViewItem; |
41 | class QIconDragItem; | 41 | class QIconDragItem; |
42 | class KAddressBookIconView; | 42 | class KAddressBookIconView; |
43 | 43 | ||
44 | namespace KABC { class AddressBook; } | 44 | namespace KABC { class AddressBook; } |
45 | 45 | ||
46 | /** This is an example kaddressbook view that is implemented using | 46 | /** This is an example kaddressbook view that is implemented using |
47 | * KIconView. This view is not the most useful view, but it displays | 47 | * KIconView. This view is not the most useful view, but it displays |
48 | * how simple implementing a new view can be. | 48 | * how simple implementing a new view can be. |
49 | */ | 49 | */ |
50 | class KAddressBookIconView : public KAddressBookView | 50 | class KAddressBookIconView : public KAddressBookView |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, | 55 | KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name = 0 ); | 56 | const char *name = 0 ); |
57 | virtual ~KAddressBookIconView(); | 57 | virtual ~KAddressBookIconView(); |
58 | 58 | ||
59 | virtual QStringList selectedUids(); | 59 | virtual QStringList selectedUids(); |
60 | virtual QString type() const { return "Icon"; } | 60 | virtual QString type() const { return "Icon"; } |
61 | void doSearch( const QString& s ,KABC::Field *field ); | 61 | void doSearch( const QString& s ,KABC::Field *field ); |
62 | 62 | ||
63 | virtual void readConfig(KConfig *config); | 63 | virtual void readConfig(KConfig *config); |
64 | virtual void scrollUP(); | ||
65 | virtual void scrollDOWN(); | ||
64 | 66 | ||
65 | public slots: | 67 | public slots: |
66 | void refresh(QString uid = QString::null); | 68 | void refresh(QString uid = QString::null); |
67 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
68 | //MOC_SKIP_BEGIN | 70 | //MOC_SKIP_BEGIN |
69 | void setSelected(QString uid = QString::null, bool selected = true); | 71 | void setSelected(QString uid = QString::null, bool selected = true); |
70 | //MOC_SKIP_END | 72 | //MOC_SKIP_END |
71 | #else //KAB_EMBEDDED | 73 | #else //KAB_EMBEDDED |
72 | //US my MOC do not like default parameters ??? | 74 | //US my MOC do not like default parameters ??? |
73 | void setSelected(QString uid, bool selected); | 75 | void setSelected(QString uid, bool selected); |
74 | #endif //KAB_EMBEDDED | 76 | #endif //KAB_EMBEDDED |
75 | 77 | ||
76 | protected slots: | 78 | protected slots: |
77 | void addresseeExecuted(QIconViewItem *item); | 79 | void addresseeExecuted(QIconViewItem *item); |
78 | void addresseeSelected(); | 80 | void addresseeSelected(); |
79 | 81 | ||
80 | private: | 82 | private: |
81 | AddresseeIconView *mIconView; | 83 | AddresseeIconView *mIconView; |
82 | QPtrList<AddresseeIconViewItem> mIconList; | 84 | QPtrList<AddresseeIconViewItem> mIconList; |
83 | }; | 85 | }; |
84 | 86 | ||
85 | 87 | ||
86 | #ifndef KAB_EMBEDDED | 88 | #ifndef KAB_EMBEDDED |
87 | //MOC_SKIP_BEGIN | 89 | //MOC_SKIP_BEGIN |
88 | class AddresseeIconView : public KIconView | 90 | class AddresseeIconView : public KIconView |
89 | //MOC_SKIP_END | 91 | //MOC_SKIP_END |
90 | #else //KAB_EMBEDDED | 92 | #else //KAB_EMBEDDED |
91 | class AddresseeIconView : public QIconView | 93 | class AddresseeIconView : public QIconView |
92 | #endif //KAB_EMBEDDED | 94 | #endif //KAB_EMBEDDED |
93 | { | 95 | { |
94 | Q_OBJECT | 96 | Q_OBJECT |
95 | 97 | ||
96 | public: | 98 | public: |
97 | AddresseeIconView(QWidget *parent, const char *name); | 99 | AddresseeIconView(QWidget *parent, const char *name); |
98 | ~AddresseeIconView(); | 100 | ~AddresseeIconView(); |
99 | 101 | ||
100 | signals: | 102 | signals: |
101 | void addresseeDropped(QDropEvent *); | 103 | void addresseeDropped(QDropEvent *); |
102 | void startAddresseeDrag(); | 104 | void startAddresseeDrag(); |
103 | 105 | ||
104 | protected: | 106 | protected: |
105 | virtual QDragObject *dragObject(); | 107 | virtual QDragObject *dragObject(); |
106 | 108 | ||
107 | protected slots: | 109 | protected slots: |
108 | void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); | 110 | void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); |
109 | }; | 111 | }; |
110 | 112 | ||
111 | class IconViewFactory : public ViewFactory | 113 | class IconViewFactory : public ViewFactory |
112 | { | 114 | { |
113 | public: | 115 | public: |
114 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 116 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
115 | { | 117 | { |
116 | return new KAddressBookIconView( ab, parent, name ); | 118 | return new KAddressBookIconView( ab, parent, name ); |
117 | } | 119 | } |
118 | 120 | ||
119 | QString type() const { return "Icon"; } | 121 | QString type() const { return "Icon"; } |
120 | 122 | ||
121 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 123 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
122 | }; | 124 | }; |
123 | /* | 125 | /* |
124 | extern "C" { | 126 | extern "C" { |
125 | void *init_libkaddrbk_iconview() | 127 | void *init_libkaddrbk_iconview() |
126 | { | 128 | { |
127 | return ( new IconViewFactory ); | 129 | return ( new IconViewFactory ); |
128 | } | 130 | } |
129 | } | 131 | } |
130 | */ | 132 | */ |
131 | #endif | 133 | #endif |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index fbfddba..2412170 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,445 +1,459 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | 37 | ||
38 | #include "kaddressbooktableview.h" | 38 | #include "kaddressbooktableview.h" |
39 | 39 | ||
40 | 40 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
42 | QWidget *parent, const char *name ) | 42 | QWidget *parent, const char *name ) |
43 | : KAddressBookView( ab, parent, name ) | 43 | : KAddressBookView( ab, parent, name ) |
44 | { | 44 | { |
45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
46 | 46 | ||
47 | // The list view will be created when the config is read. | 47 | // The list view will be created when the config is read. |
48 | mListView = 0; | 48 | mListView = 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 51 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | void KAddressBookTableView::scrollUP() | |
55 | { | ||
56 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | ||
57 | QApplication::postEvent( mListView, ev ); | ||
58 | } | ||
59 | void KAddressBookTableView::scrollDOWN() | ||
60 | { | ||
61 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | ||
62 | QApplication::postEvent( mListView, ev ); | ||
63 | } | ||
55 | void KAddressBookTableView::reconstructListView() | 64 | void KAddressBookTableView::reconstructListView() |
56 | { | 65 | { |
57 | if (mListView) | 66 | if (mListView) |
58 | { | 67 | { |
59 | disconnect(mListView, SIGNAL(selectionChanged()), | 68 | disconnect(mListView, SIGNAL(selectionChanged()), |
60 | this, SLOT(addresseeSelected())); | 69 | this, SLOT(addresseeSelected())); |
61 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 70 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
62 | this, SLOT(addresseeExecuted(QListViewItem*))); | 71 | this, SLOT(addresseeExecuted(QListViewItem*))); |
63 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 72 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
64 | this, SLOT(addresseeExecuted(QListViewItem*))); | 73 | this, SLOT(addresseeExecuted(QListViewItem*))); |
65 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 74 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
66 | SIGNAL(startDrag())); | 75 | SIGNAL(startDrag())); |
67 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 76 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
68 | this, SLOT(addresseeExecuted(QListViewItem*))); | 77 | this, SLOT(addresseeExecuted(QListViewItem*))); |
69 | 78 | ||
70 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 79 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
71 | SIGNAL(dropped(QDropEvent*))); | 80 | SIGNAL(dropped(QDropEvent*))); |
72 | delete mListView; | 81 | delete mListView; |
73 | } | 82 | } |
74 | 83 | ||
75 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 84 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
76 | 85 | ||
77 | // Add the columns | 86 | // Add the columns |
78 | KABC::Field::List fieldList = fields(); | 87 | KABC::Field::List fieldList = fields(); |
79 | KABC::Field::List::ConstIterator it; | 88 | KABC::Field::List::ConstIterator it; |
80 | 89 | ||
81 | int c = 0; | 90 | int c = 0; |
82 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 91 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
83 | mListView->addColumn( (*it)->label() ); | 92 | mListView->addColumn( (*it)->label() ); |
84 | mListView->setColumnWidthMode(c++, QListView::Manual); | 93 | mListView->setColumnWidthMode(c++, QListView::Manual); |
85 | //US | 94 | //US |
86 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 95 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
87 | } | 96 | } |
88 | 97 | ||
89 | connect(mListView, SIGNAL(selectionChanged()), | 98 | connect(mListView, SIGNAL(selectionChanged()), |
90 | this, SLOT(addresseeSelected())); | 99 | this, SLOT(addresseeSelected())); |
91 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 100 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
92 | SIGNAL(startDrag())); | 101 | SIGNAL(startDrag())); |
93 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 102 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
94 | SIGNAL(dropped(QDropEvent*))); | 103 | SIGNAL(dropped(QDropEvent*))); |
95 | 104 | ||
96 | if (KABPrefs::instance()->mHonorSingleClick) | 105 | if (KABPrefs::instance()->mHonorSingleClick) |
97 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 106 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
98 | this, SLOT(addresseeExecuted(QListViewItem*))); | 107 | this, SLOT(addresseeExecuted(QListViewItem*))); |
99 | else | 108 | else |
100 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 109 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
101 | this, SLOT(addresseeExecuted(QListViewItem*))); | 110 | this, SLOT(addresseeExecuted(QListViewItem*))); |
102 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 111 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
103 | this, SLOT(addresseeExecuted(QListViewItem*))); | 112 | this, SLOT(addresseeExecuted(QListViewItem*))); |
104 | connect(mListView, SIGNAL(signalDelete()), | 113 | connect(mListView, SIGNAL(signalDelete()), |
105 | this, SLOT(addresseeDeleted())); | 114 | this, SLOT(addresseeDeleted())); |
106 | 115 | ||
107 | //US performceimprovement. Refresh is done from the outside | 116 | //US performceimprovement. Refresh is done from the outside |
108 | //US refresh(); | 117 | //US refresh(); |
109 | 118 | ||
110 | mListView->setSorting( 0, true ); | 119 | mListView->setSorting( 0, true ); |
111 | mainLayout->addWidget( mListView ); | 120 | mainLayout->addWidget( mListView ); |
112 | mainLayout->activate(); | 121 | mainLayout->activate(); |
113 | mListView->show(); | 122 | mListView->show(); |
114 | } | 123 | } |
115 | 124 | ||
116 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | 125 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) |
117 | { | 126 | { |
118 | mListView->clear(); | 127 | mListView->clear(); |
119 | if ( s.isEmpty() || s == "*" ) { | 128 | if ( s.isEmpty() || s == "*" ) { |
120 | refresh(); | 129 | refresh(); |
121 | return; | 130 | return; |
122 | } | 131 | } |
123 | QString pattern = s.lower()+"*"; | 132 | QString pattern = s.lower()+"*"; |
124 | QRegExp re; | 133 | QRegExp re; |
125 | re.setWildcard(true); // most people understand these better. | 134 | re.setWildcard(true); // most people understand these better. |
126 | re.setCaseSensitive(false); | 135 | re.setCaseSensitive(false); |
127 | re.setPattern( pattern ); | 136 | re.setPattern( pattern ); |
128 | if (!re.isValid()) | 137 | if (!re.isValid()) |
129 | return; | 138 | return; |
130 | KABC::Addressee::List addresseeList = addressees(); | 139 | KABC::Addressee::List addresseeList = addressees(); |
131 | KABC::Addressee::List::Iterator it; | 140 | KABC::Addressee::List::Iterator it; |
132 | if ( field ) { | 141 | if ( field ) { |
133 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 142 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
134 | #if QT_VERSION >= 300 | 143 | #if QT_VERSION >= 300 |
135 | if (re.search(field->value( *it ).lower()) != -1) | 144 | if (re.search(field->value( *it ).lower()) != -1) |
136 | #else | 145 | #else |
137 | if (re.match(field->value( *it ).lower()) != -1) | 146 | if (re.match(field->value( *it ).lower()) != -1) |
138 | #endif | 147 | #endif |
139 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 148 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
140 | 149 | ||
141 | } | 150 | } |
142 | } else { | 151 | } else { |
143 | KABC::Field::List fieldList = fields(); | 152 | KABC::Field::List fieldList = fields(); |
144 | KABC::Field::List::ConstIterator fieldIt; | 153 | KABC::Field::List::ConstIterator fieldIt; |
145 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 154 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
146 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 155 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
147 | #if QT_VERSION >= 300 | 156 | #if QT_VERSION >= 300 |
148 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 157 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
149 | #else | 158 | #else |
150 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 159 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
151 | #endif | 160 | #endif |
152 | { | 161 | { |
153 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 162 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
154 | break; | 163 | break; |
155 | } | 164 | } |
156 | } | 165 | } |
157 | } | 166 | } |
158 | } | 167 | } |
159 | // Sometimes the background pixmap gets messed up when we add lots | 168 | // Sometimes the background pixmap gets messed up when we add lots |
160 | // of items. | 169 | // of items. |
161 | mListView->repaint(); | 170 | mListView->repaint(); |
162 | emit selected(QString::null); | 171 | if ( mListView->firstChild() ) { |
172 | mListView->setCurrentItem ( mListView->firstChild() ); | ||
173 | mListView->setSelected ( mListView->firstChild(), true ); | ||
174 | } | ||
175 | else | ||
176 | emit selected(QString::null); | ||
163 | 177 | ||
164 | } | 178 | } |
165 | void KAddressBookTableView::writeConfig(KConfig *config) | 179 | void KAddressBookTableView::writeConfig(KConfig *config) |
166 | { | 180 | { |
167 | KAddressBookView::writeConfig(config); | 181 | KAddressBookView::writeConfig(config); |
168 | 182 | ||
169 | mListView->saveLayout(config, config->group()); | 183 | mListView->saveLayout(config, config->group()); |
170 | } | 184 | } |
171 | 185 | ||
172 | void KAddressBookTableView::readConfig(KConfig *config) | 186 | void KAddressBookTableView::readConfig(KConfig *config) |
173 | { | 187 | { |
174 | KAddressBookView::readConfig( config ); | 188 | KAddressBookView::readConfig( config ); |
175 | // The config could have changed the fields, so we need to reconstruct | 189 | // The config could have changed the fields, so we need to reconstruct |
176 | // the listview. | 190 | // the listview. |
177 | reconstructListView(); | 191 | reconstructListView(); |
178 | 192 | ||
179 | // costum colors? | 193 | // costum colors? |
180 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 194 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
181 | { | 195 | { |
182 | QPalette p( mListView->palette() ); | 196 | QPalette p( mListView->palette() ); |
183 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 197 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
184 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 198 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
185 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 199 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
186 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 200 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
187 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 201 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
188 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 202 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
189 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 203 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
190 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 204 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
191 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 205 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
192 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 206 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
193 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 207 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
194 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 208 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
195 | #ifndef KAB_EMBEDDED | 209 | #ifndef KAB_EMBEDDED |
196 | c = KGlobalSettings::alternateBackgroundColor(); | 210 | c = KGlobalSettings::alternateBackgroundColor(); |
197 | #else //KAB_EMBEDDED | 211 | #else //KAB_EMBEDDED |
198 | c = QColor(240, 240, 240); | 212 | c = QColor(240, 240, 240); |
199 | #endif //KAB_EMBEDDED | 213 | #endif //KAB_EMBEDDED |
200 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 214 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
201 | mListView->setAlternateColor(c); | 215 | mListView->setAlternateColor(c); |
202 | 216 | ||
203 | 217 | ||
204 | //US mListView->viewport()->setPalette( p ); | 218 | //US mListView->viewport()->setPalette( p ); |
205 | mListView->setPalette( p ); | 219 | mListView->setPalette( p ); |
206 | } | 220 | } |
207 | else | 221 | else |
208 | { | 222 | { |
209 | // needed if turned off during a session. | 223 | // needed if turned off during a session. |
210 | //US mListView->viewport()->setPalette( mListView->palette() ); | 224 | //US mListView->viewport()->setPalette( mListView->palette() ); |
211 | mListView->setPalette( mListView->palette() ); | 225 | mListView->setPalette( mListView->palette() ); |
212 | } | 226 | } |
213 | 227 | ||
214 | //custom fonts? | 228 | //custom fonts? |
215 | QFont f( font() ); | 229 | QFont f( font() ); |
216 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 230 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
217 | { | 231 | { |
218 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 232 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
219 | f.setBold( true ); | 233 | f.setBold( true ); |
220 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 234 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
221 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 235 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
222 | } | 236 | } |
223 | else | 237 | else |
224 | { | 238 | { |
225 | mListView->setFont( f ); | 239 | mListView->setFont( f ); |
226 | f.setBold( true ); | 240 | f.setBold( true ); |
227 | //US mListView->setHeaderFont( f ); | 241 | //US mListView->setHeaderFont( f ); |
228 | mListView->header()->setFont( f ); | 242 | mListView->header()->setFont( f ); |
229 | } | 243 | } |
230 | 244 | ||
231 | 245 | ||
232 | 246 | ||
233 | 247 | ||
234 | 248 | ||
235 | // Set the list view options | 249 | // Set the list view options |
236 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 250 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
237 | true)); | 251 | true)); |
238 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 252 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
239 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 253 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
240 | 254 | ||
241 | if (config->readBoolEntry("Background", false)) | 255 | if (config->readBoolEntry("Background", false)) |
242 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 256 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
243 | 257 | ||
244 | // Restore the layout of the listview | 258 | // Restore the layout of the listview |
245 | mListView->restoreLayout(config, config->group()); | 259 | mListView->restoreLayout(config, config->group()); |
246 | } | 260 | } |
247 | 261 | ||
248 | void KAddressBookTableView::refresh(QString uid) | 262 | void KAddressBookTableView::refresh(QString uid) |
249 | { | 263 | { |
250 | // For now just repopulate. In reality this method should | 264 | // For now just repopulate. In reality this method should |
251 | // check the value of uid, and if valid iterate through | 265 | // check the value of uid, and if valid iterate through |
252 | // the listview to find the entry, then tell it to refresh. | 266 | // the listview to find the entry, then tell it to refresh. |
253 | 267 | ||
254 | if (uid.isNull()) { | 268 | if (uid.isNull()) { |
255 | // Clear the list view | 269 | // Clear the list view |
256 | QString currentUID, nextUID; | 270 | QString currentUID, nextUID; |
257 | #ifndef KAB_EMBEDDED | 271 | #ifndef KAB_EMBEDDED |
258 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 272 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
259 | #else //KAB_EMBEDDED | 273 | #else //KAB_EMBEDDED |
260 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 274 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
261 | #endif //KAB_EMBEDDED | 275 | #endif //KAB_EMBEDDED |
262 | 276 | ||
263 | if ( currentItem ) { | 277 | if ( currentItem ) { |
264 | #ifndef KAB_EMBEDDED | 278 | #ifndef KAB_EMBEDDED |
265 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 279 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
266 | #else //KAB_EMBEDDED | 280 | #else //KAB_EMBEDDED |
267 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 281 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
268 | #endif //KAB_EMBEDDED | 282 | #endif //KAB_EMBEDDED |
269 | if ( nextItem ) | 283 | if ( nextItem ) |
270 | nextUID = nextItem->addressee().uid(); | 284 | nextUID = nextItem->addressee().uid(); |
271 | currentUID = currentItem->addressee().uid(); | 285 | currentUID = currentItem->addressee().uid(); |
272 | } | 286 | } |
273 | 287 | ||
274 | mListView->clear(); | 288 | mListView->clear(); |
275 | 289 | ||
276 | currentItem = 0; | 290 | currentItem = 0; |
277 | KABC::Addressee::List addresseeList = addressees(); | 291 | KABC::Addressee::List addresseeList = addressees(); |
278 | KABC::Addressee::List::Iterator it; | 292 | KABC::Addressee::List::Iterator it; |
279 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 293 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
280 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 294 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
281 | continue; | 295 | continue; |
282 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 296 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
283 | if ( (*it).uid() == currentUID ) | 297 | if ( (*it).uid() == currentUID ) |
284 | currentItem = item; | 298 | currentItem = item; |
285 | else if ( (*it).uid() == nextUID && !currentItem ) | 299 | else if ( (*it).uid() == nextUID && !currentItem ) |
286 | currentItem = item; | 300 | currentItem = item; |
287 | } | 301 | } |
288 | 302 | ||
289 | // Sometimes the background pixmap gets messed up when we add lots | 303 | // Sometimes the background pixmap gets messed up when we add lots |
290 | // of items. | 304 | // of items. |
291 | mListView->repaint(); | 305 | mListView->repaint(); |
292 | 306 | ||
293 | if ( currentItem ) { | 307 | if ( currentItem ) { |
294 | mListView->setCurrentItem( currentItem ); | 308 | mListView->setCurrentItem( currentItem ); |
295 | mListView->ensureItemVisible( currentItem ); | 309 | mListView->ensureItemVisible( currentItem ); |
296 | } | 310 | } |
297 | } else { | 311 | } else { |
298 | // Only need to update on entry. Iterate through and try to find it | 312 | // Only need to update on entry. Iterate through and try to find it |
299 | ContactListViewItem *ceItem; | 313 | ContactListViewItem *ceItem; |
300 | QListViewItemIterator it( mListView ); | 314 | QListViewItemIterator it( mListView ); |
301 | while ( it.current() ) { | 315 | while ( it.current() ) { |
302 | #ifndef KAB_EMBEDDED | 316 | #ifndef KAB_EMBEDDED |
303 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 317 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
304 | #else //KAB_EMBEDDED | 318 | #else //KAB_EMBEDDED |
305 | ceItem = (ContactListViewItem*)( it.current() ); | 319 | ceItem = (ContactListViewItem*)( it.current() ); |
306 | #endif //KAB_EMBEDDED | 320 | #endif //KAB_EMBEDDED |
307 | 321 | ||
308 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 322 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
309 | ceItem->refresh(); | 323 | ceItem->refresh(); |
310 | return; | 324 | return; |
311 | } | 325 | } |
312 | ++it; | 326 | ++it; |
313 | } | 327 | } |
314 | 328 | ||
315 | refresh( QString::null ); | 329 | refresh( QString::null ); |
316 | } | 330 | } |
317 | } | 331 | } |
318 | 332 | ||
319 | QStringList KAddressBookTableView::selectedUids() | 333 | QStringList KAddressBookTableView::selectedUids() |
320 | { | 334 | { |
321 | QStringList uidList; | 335 | QStringList uidList; |
322 | QListViewItem *item; | 336 | QListViewItem *item; |
323 | ContactListViewItem *ceItem; | 337 | ContactListViewItem *ceItem; |
324 | 338 | ||
325 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 339 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
326 | { | 340 | { |
327 | if (mListView->isSelected( item )) | 341 | if (mListView->isSelected( item )) |
328 | { | 342 | { |
329 | #ifndef KAB_EMBEDDED | 343 | #ifndef KAB_EMBEDDED |
330 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 344 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
331 | #else //KAB_EMBEDDED | 345 | #else //KAB_EMBEDDED |
332 | ceItem = (ContactListViewItem*)(item); | 346 | ceItem = (ContactListViewItem*)(item); |
333 | #endif //KAB_EMBEDDED | 347 | #endif //KAB_EMBEDDED |
334 | 348 | ||
335 | if (ceItem != 0L) | 349 | if (ceItem != 0L) |
336 | uidList << ceItem->addressee().uid(); | 350 | uidList << ceItem->addressee().uid(); |
337 | } | 351 | } |
338 | } | 352 | } |
339 | if ( uidList.count() == 0 ) | 353 | if ( uidList.count() == 0 ) |
340 | if ( mListView->currentItem() ) { | 354 | if ( mListView->currentItem() ) { |
341 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 355 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
342 | uidList << ceItem->addressee().uid(); | 356 | uidList << ceItem->addressee().uid(); |
343 | } | 357 | } |
344 | 358 | ||
345 | return uidList; | 359 | return uidList; |
346 | } | 360 | } |
347 | 361 | ||
348 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 362 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
349 | { | 363 | { |
350 | QListViewItem *item; | 364 | QListViewItem *item; |
351 | ContactListViewItem *ceItem; | 365 | ContactListViewItem *ceItem; |
352 | 366 | ||
353 | if (uid.isNull()) | 367 | if (uid.isNull()) |
354 | { | 368 | { |
355 | mListView->selectAll(selected); | 369 | mListView->selectAll(selected); |
356 | } | 370 | } |
357 | else | 371 | else |
358 | { | 372 | { |
359 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 373 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
360 | { | 374 | { |
361 | #ifndef KAB_EMBEDDED | 375 | #ifndef KAB_EMBEDDED |
362 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 376 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
363 | #else //KAB_EMBEDDED | 377 | #else //KAB_EMBEDDED |
364 | ceItem = (ContactListViewItem*)(item); | 378 | ceItem = (ContactListViewItem*)(item); |
365 | #endif //KAB_EMBEDDED | 379 | #endif //KAB_EMBEDDED |
366 | 380 | ||
367 | 381 | ||
368 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 382 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
369 | { | 383 | { |
370 | mListView->setSelected(item, selected); | 384 | mListView->setSelected(item, selected); |
371 | 385 | ||
372 | if (selected) | 386 | if (selected) |
373 | mListView->ensureItemVisible(item); | 387 | mListView->ensureItemVisible(item); |
374 | } | 388 | } |
375 | } | 389 | } |
376 | } | 390 | } |
377 | } | 391 | } |
378 | 392 | ||
379 | void KAddressBookTableView::addresseeSelected() | 393 | void KAddressBookTableView::addresseeSelected() |
380 | { | 394 | { |
381 | // We need to try to find the first selected item. This might not be the | 395 | // We need to try to find the first selected item. This might not be the |
382 | // last selected item, but when QListView is in multiselection mode, | 396 | // last selected item, but when QListView is in multiselection mode, |
383 | // there is no way to figure out which one was | 397 | // there is no way to figure out which one was |
384 | // selected last. | 398 | // selected last. |
385 | QListViewItem *item; | 399 | QListViewItem *item; |
386 | bool found =false; | 400 | bool found =false; |
387 | for (item = mListView->firstChild(); item && !found; | 401 | for (item = mListView->firstChild(); item && !found; |
388 | item = item->nextSibling()) | 402 | item = item->nextSibling()) |
389 | { | 403 | { |
390 | if (item->isSelected()) | 404 | if (item->isSelected()) |
391 | { | 405 | { |
392 | found = true; | 406 | found = true; |
393 | #ifndef KAB_EMBEDDED | 407 | #ifndef KAB_EMBEDDED |
394 | ContactListViewItem *ceItem | 408 | ContactListViewItem *ceItem |
395 | = dynamic_cast<ContactListViewItem*>(item); | 409 | = dynamic_cast<ContactListViewItem*>(item); |
396 | #else //KAB_EMBEDDED | 410 | #else //KAB_EMBEDDED |
397 | ContactListViewItem *ceItem | 411 | ContactListViewItem *ceItem |
398 | = (ContactListViewItem*)(item); | 412 | = (ContactListViewItem*)(item); |
399 | #endif //KAB_EMBEDDED | 413 | #endif //KAB_EMBEDDED |
400 | 414 | ||
401 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 415 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
402 | } | 416 | } |
403 | } | 417 | } |
404 | 418 | ||
405 | if (!found) | 419 | if (!found) |
406 | emit selected(QString::null); | 420 | emit selected(QString::null); |
407 | } | 421 | } |
408 | 422 | ||
409 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 423 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
410 | { | 424 | { |
411 | if (item) | 425 | if (item) |
412 | { | 426 | { |
413 | #ifndef KAB_EMBEDDED | 427 | #ifndef KAB_EMBEDDED |
414 | ContactListViewItem *ceItem | 428 | ContactListViewItem *ceItem |
415 | = dynamic_cast<ContactListViewItem*>(item); | 429 | = dynamic_cast<ContactListViewItem*>(item); |
416 | #else //KAB_EMBEDDED | 430 | #else //KAB_EMBEDDED |
417 | ContactListViewItem *ceItem | 431 | ContactListViewItem *ceItem |
418 | = (ContactListViewItem*)(item); | 432 | = (ContactListViewItem*)(item); |
419 | #endif //KAB_EMBEDDED | 433 | #endif //KAB_EMBEDDED |
420 | 434 | ||
421 | if (ceItem) | 435 | if (ceItem) |
422 | { | 436 | { |
423 | emit executed(ceItem->addressee().uid()); | 437 | emit executed(ceItem->addressee().uid()); |
424 | } | 438 | } |
425 | } | 439 | } |
426 | else | 440 | else |
427 | { | 441 | { |
428 | emit executed(QString::null); | 442 | emit executed(QString::null); |
429 | } | 443 | } |
430 | } | 444 | } |
431 | 445 | ||
432 | void KAddressBookTableView::addresseeDeleted() | 446 | void KAddressBookTableView::addresseeDeleted() |
433 | { | 447 | { |
434 | 448 | ||
435 | emit deleteRequest(); | 449 | emit deleteRequest(); |
436 | 450 | ||
437 | } | 451 | } |
438 | 452 | ||
439 | 453 | ||
440 | 454 | ||
441 | 455 | ||
442 | 456 | ||
443 | #ifndef KAB_EMBEDDED | 457 | #ifndef KAB_EMBEDDED |
444 | #include "kaddressbooktableview.moc" | 458 | #include "kaddressbooktableview.moc" |
445 | #endif //KAB_EMBEDDED | 459 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h index ecfe7a1..865f8d5 100644 --- a/kaddressbook/views/kaddressbooktableview.h +++ b/kaddressbook/views/kaddressbooktableview.h | |||
@@ -1,115 +1,117 @@ | |||
1 | #ifndef KADDRESSBOOKTABLEVIEW_H | 1 | #ifndef KADDRESSBOOKTABLEVIEW_H |
2 | #define KADDRESSBOOKTABLEVIEW_H | 2 | #define KADDRESSBOOKTABLEVIEW_H |
3 | 3 | ||
4 | 4 | ||
5 | #ifndef KAB_EMBEDDED | 5 | #ifndef KAB_EMBEDDED |
6 | 6 | ||
7 | 7 | ||
8 | #ifdef HAVE_CONFIG_H | 8 | #ifdef HAVE_CONFIG_H |
9 | #include <config.h> | 9 | #include <config.h> |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #include <qwidget.h> | 12 | #include <qwidget.h> |
13 | #include <qlistview.h> | 13 | #include <qlistview.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qdialog.h> | 15 | #include <qdialog.h> |
16 | #include <qtabdialog.h> | 16 | #include <qtabdialog.h> |
17 | #include <qstringlist.h> | 17 | #include <qstringlist.h> |
18 | #include <qvaluelist.h> | 18 | #include <qvaluelist.h> |
19 | 19 | ||
20 | #include "undo.h" | 20 | #include "undo.h" |
21 | 21 | ||
22 | #else //KAB_EMBEDDED | 22 | #else //KAB_EMBEDDED |
23 | #include "views/configuretableviewdialog.h" | 23 | #include "views/configuretableviewdialog.h" |
24 | #endif //KAB_EMBEDDED | 24 | #endif //KAB_EMBEDDED |
25 | 25 | ||
26 | #include "klocale.h" | 26 | #include "klocale.h" |
27 | #include "kaddressbookview.h" | 27 | #include "kaddressbookview.h" |
28 | 28 | ||
29 | class QListViewItem; | 29 | class QListViewItem; |
30 | class QListBox; | 30 | class QListBox; |
31 | class QVBoxLayout; | 31 | class QVBoxLayout; |
32 | class KConfig; | 32 | class KConfig; |
33 | 33 | ||
34 | class ContactListViewItem; | 34 | class ContactListViewItem; |
35 | class ContactListView; | 35 | class ContactListView; |
36 | 36 | ||
37 | 37 | ||
38 | namespace KABC { class AddressBook; } | 38 | namespace KABC { class AddressBook; } |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * This class is the table view for kaddressbook. This view is a KListView | 41 | * This class is the table view for kaddressbook. This view is a KListView |
42 | * with multiple columns for the selected fields. | 42 | * with multiple columns for the selected fields. |
43 | * | 43 | * |
44 | * @short Table View | 44 | * @short Table View |
45 | * @author Don Sanders <dsanders@kde.org> | 45 | * @author Don Sanders <dsanders@kde.org> |
46 | * @version 0.1 | 46 | * @version 0.1 |
47 | */ | 47 | */ |
48 | class KAddressBookTableView : public KAddressBookView | 48 | class KAddressBookTableView : public KAddressBookView |
49 | { | 49 | { |
50 | friend class ContactListView; | 50 | friend class ContactListView; |
51 | 51 | ||
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, | 55 | KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name = 0 ); | 56 | const char *name = 0 ); |
57 | virtual ~KAddressBookTableView(); | 57 | virtual ~KAddressBookTableView(); |
58 | 58 | ||
59 | virtual void refresh(QString uid = QString::null); | 59 | virtual void refresh(QString uid = QString::null); |
60 | virtual QStringList selectedUids(); | 60 | virtual QStringList selectedUids(); |
61 | virtual void setSelected(QString uid = QString::null, bool selected = false); | 61 | virtual void setSelected(QString uid = QString::null, bool selected = false); |
62 | virtual void readConfig(KConfig *config); | 62 | virtual void readConfig(KConfig *config); |
63 | virtual void writeConfig(KConfig *config); | 63 | virtual void writeConfig(KConfig *config); |
64 | virtual QString type() const { return "Table"; } | 64 | virtual QString type() const { return "Table"; } |
65 | void doSearch( const QString& s ,KABC::Field *field ); | 65 | void doSearch( const QString& s ,KABC::Field *field ); |
66 | virtual void scrollUP(); | ||
67 | virtual void scrollDOWN(); | ||
66 | 68 | ||
67 | public slots: | 69 | public slots: |
68 | virtual void reconstructListView(); | 70 | virtual void reconstructListView(); |
69 | 71 | ||
70 | protected slots: | 72 | protected slots: |
71 | /** Called whenever the user selects an addressee in the list view. | 73 | /** Called whenever the user selects an addressee in the list view. |
72 | */ | 74 | */ |
73 | void addresseeSelected(); | 75 | void addresseeSelected(); |
74 | void addresseeDeleted(); | 76 | void addresseeDeleted(); |
75 | 77 | ||
76 | /** Called whenever the user executes an addressee. In terms of the | 78 | /** Called whenever the user executes an addressee. In terms of the |
77 | * list view, this is probably a double click | 79 | * list view, this is probably a double click |
78 | */ | 80 | */ |
79 | void addresseeExecuted(QListViewItem*); | 81 | void addresseeExecuted(QListViewItem*); |
80 | 82 | ||
81 | private: | 83 | private: |
82 | QVBoxLayout *mainLayout; | 84 | QVBoxLayout *mainLayout; |
83 | ContactListView *mListView; | 85 | ContactListView *mListView; |
84 | }; | 86 | }; |
85 | 87 | ||
86 | 88 | ||
87 | class TableViewFactory : public ViewFactory | 89 | class TableViewFactory : public ViewFactory |
88 | { | 90 | { |
89 | public: | 91 | public: |
90 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 92 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
91 | { | 93 | { |
92 | return new KAddressBookTableView( ab, parent, name ); | 94 | return new KAddressBookTableView( ab, parent, name ); |
93 | } | 95 | } |
94 | 96 | ||
95 | QString type() const { return "Table"; } | 97 | QString type() const { return "Table"; } |
96 | 98 | ||
97 | QString description() const { return i18n( "A listing of contacts in a table. Each cell of " | 99 | QString description() const { return i18n( "A listing of contacts in a table. Each cell of " |
98 | "the table holds a field of the contact." ); } | 100 | "the table holds a field of the contact." ); } |
99 | 101 | ||
100 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, | 102 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, |
101 | const char *name = 0 ) | 103 | const char *name = 0 ) |
102 | { | 104 | { |
103 | return new ConfigureTableViewWidget( ab, parent, name ); | 105 | return new ConfigureTableViewWidget( ab, parent, name ); |
104 | } | 106 | } |
105 | }; | 107 | }; |
106 | /*US | 108 | /*US |
107 | extern "C" { | 109 | extern "C" { |
108 | void *init_libkaddrbk_tableview() | 110 | void *init_libkaddrbk_tableview() |
109 | { | 111 | { |
110 | return ( new TableViewFactory ); | 112 | return ( new TableViewFactory ); |
111 | } | 113 | } |
112 | } | 114 | } |
113 | */ | 115 | */ |
114 | 116 | ||
115 | #endif | 117 | #endif |
diff --git a/microkde/klineedit.h b/microkde/klineedit.h index 65e2f59..70c72d1 100644 --- a/microkde/klineedit.h +++ b/microkde/klineedit.h | |||
@@ -1,24 +1,47 @@ | |||
1 | #ifndef MINIKDE_KLINEEDIT_H | 1 | #ifndef MINIKDE_KLINEEDIT_H |
2 | #define MINIKDE_KLINEEDIT_H | 2 | #define MINIKDE_KLINEEDIT_H |
3 | 3 | ||
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | 5 | ||
6 | #ifndef DESKTOP_VERSION | 6 | #ifndef DESKTOP_VERSION |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | 10 | ||
11 | class KLineEdit : public QLineEdit | 11 | class KLineEdit : public QLineEdit |
12 | { | 12 | { |
13 | |||
14 | Q_OBJECT | ||
15 | |||
13 | public: | 16 | public: |
14 | KLineEdit( QWidget *parent=0, const char *name=0 ) : | 17 | KLineEdit( QWidget *parent=0, const char *name=0 ) : |
15 | QLineEdit( parent, name ) { | 18 | QLineEdit( parent, name ) |
19 | { | ||
16 | #ifndef DESKTOP_VERSION | 20 | #ifndef DESKTOP_VERSION |
17 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 21 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
18 | #endif | 22 | #endif |
19 | } | 23 | } |
20 | 24 | void keyPressEvent ( QKeyEvent * e) | |
25 | { | ||
26 | switch ( e->key() ) { | ||
27 | case Qt::Key_Down: | ||
28 | emit scrollDOWN(); | ||
29 | e->accept(); | ||
30 | break; | ||
31 | case Qt::Key_Up: | ||
32 | emit scrollUP(); | ||
33 | e->accept(); | ||
34 | break; | ||
35 | default: | ||
36 | QLineEdit::keyPressEvent ( e ); | ||
37 | break; | ||
38 | } | ||
39 | |||
40 | } | ||
21 | void setTrapReturnKey( bool ) {} | 41 | void setTrapReturnKey( bool ) {} |
42 | signals: | ||
43 | void scrollUP(); | ||
44 | void scrollDOWN(); | ||
22 | }; | 45 | }; |
23 | 46 | ||
24 | #endif | 47 | #endif |