-rw-r--r-- | kaddressbook/xxport/csvimportdialog.cpp | 4 | ||||
-rw-r--r-- | microkde/kresources/configpage.cpp | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/kaddressbook/xxport/csvimportdialog.cpp b/kaddressbook/xxport/csvimportdialog.cpp index 1093f9c..cc55a24 100644 --- a/kaddressbook/xxport/csvimportdialog.cpp +++ b/kaddressbook/xxport/csvimportdialog.cpp | |||
@@ -1,225 +1,229 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> |
4 | based on the code of KSpread's CSV Import Dialog | 4 | based on the code of KSpread's CSV Import Dialog |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #include <qbuttongroup.h> | 30 | #include <qbuttongroup.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #ifdef DESKTOP_VERSION | ||
33 | #include <qinputdialog.h> | 34 | #include <qinputdialog.h> |
35 | #else | ||
36 | #include <qtcompat/qinputdialog.h> | ||
37 | #endif | ||
34 | #include <qlabel.h> | 38 | #include <qlabel.h> |
35 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
36 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
37 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
38 | #include <qtable.h> | 42 | #include <qtable.h> |
39 | #include <qlayout.h> | 43 | #include <qlayout.h> |
40 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
41 | #include <qfile.h> | 45 | #include <qfile.h> |
42 | 46 | ||
43 | #include <kapplication.h> | 47 | #include <kapplication.h> |
44 | #include <kdebug.h> | 48 | #include <kdebug.h> |
45 | #include <kdialogbase.h> | 49 | #include <kdialogbase.h> |
46 | #include <kfiledialog.h> | 50 | #include <kfiledialog.h> |
47 | #include <klineedit.h> | 51 | #include <klineedit.h> |
48 | #include <klocale.h> | 52 | #include <klocale.h> |
49 | #include <kglobal.h> | 53 | #include <kglobal.h> |
50 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> |
51 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
52 | #include <kurlrequester.h> | 56 | #include <kurlrequester.h> |
53 | 57 | ||
54 | #ifdef DESKTOP_VERSION | 58 | #ifdef DESKTOP_VERSION |
55 | #include "qtable.h" | 59 | #include "qtable.h" |
56 | #else | 60 | #else |
57 | #include "qcombotableitem.h" | 61 | #include "qcombotableitem.h" |
58 | #endif | 62 | #endif |
59 | #include "csvimportdialog.h" | 63 | #include "csvimportdialog.h" |
60 | 64 | ||
61 | CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, | 65 | CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, |
62 | const char * name ) | 66 | const char * name ) |
63 | : KDialogBase( Plain, i18n ( "CSV Import Dialog" ), Ok | Cancel | User1 | | 67 | : KDialogBase( Plain, i18n ( "CSV Import Dialog" ), Ok | Cancel | User1 | |
64 | User2, Ok, parent, name, true, true ), | 68 | User2, Ok, parent, name, true, true ), |
65 | mAdjustRows( false ), | 69 | mAdjustRows( false ), |
66 | mStartLine( 0 ), | 70 | mStartLine( 0 ), |
67 | mTextQuote( '"' ), | 71 | mTextQuote( '"' ), |
68 | mDelimiter( "," ), | 72 | mDelimiter( "," ), |
69 | mAddressBook( ab ) | 73 | mAddressBook( ab ) |
70 | { | 74 | { |
71 | initGUI(); | 75 | initGUI(); |
72 | 76 | ||
73 | mTypeMap.insert( i18n( "Undefined" ), Undefined ); | 77 | mTypeMap.insert( i18n( "Undefined" ), Undefined ); |
74 | mTypeMap.insert( KABC::Addressee::formattedNameLabel(), FormattedName ); | 78 | mTypeMap.insert( KABC::Addressee::formattedNameLabel(), FormattedName ); |
75 | mTypeMap.insert( KABC::Addressee::familyNameLabel(), FamilyName ); | 79 | mTypeMap.insert( KABC::Addressee::familyNameLabel(), FamilyName ); |
76 | mTypeMap.insert( KABC::Addressee::givenNameLabel(), GivenName ); | 80 | mTypeMap.insert( KABC::Addressee::givenNameLabel(), GivenName ); |
77 | mTypeMap.insert( KABC::Addressee::additionalNameLabel(), AdditionalName ); | 81 | mTypeMap.insert( KABC::Addressee::additionalNameLabel(), AdditionalName ); |
78 | mTypeMap.insert( KABC::Addressee::prefixLabel(), Prefix ); | 82 | mTypeMap.insert( KABC::Addressee::prefixLabel(), Prefix ); |
79 | mTypeMap.insert( KABC::Addressee::suffixLabel(), Suffix ); | 83 | mTypeMap.insert( KABC::Addressee::suffixLabel(), Suffix ); |
80 | mTypeMap.insert( KABC::Addressee::nickNameLabel(), NickName ); | 84 | mTypeMap.insert( KABC::Addressee::nickNameLabel(), NickName ); |
81 | mTypeMap.insert( KABC::Addressee::birthdayLabel(), Birthday ); | 85 | mTypeMap.insert( KABC::Addressee::birthdayLabel(), Birthday ); |
82 | 86 | ||
83 | mTypeMap.insert( KABC::Addressee::homeAddressStreetLabel(), HomeAddressStreet ); | 87 | mTypeMap.insert( KABC::Addressee::homeAddressStreetLabel(), HomeAddressStreet ); |
84 | mTypeMap.insert( KABC::Addressee::homeAddressLocalityLabel(), | 88 | mTypeMap.insert( KABC::Addressee::homeAddressLocalityLabel(), |
85 | HomeAddressLocality ); | 89 | HomeAddressLocality ); |
86 | mTypeMap.insert( KABC::Addressee::homeAddressRegionLabel(), HomeAddressRegion ); | 90 | mTypeMap.insert( KABC::Addressee::homeAddressRegionLabel(), HomeAddressRegion ); |
87 | mTypeMap.insert( KABC::Addressee::homeAddressPostalCodeLabel(), | 91 | mTypeMap.insert( KABC::Addressee::homeAddressPostalCodeLabel(), |
88 | HomeAddressPostalCode ); | 92 | HomeAddressPostalCode ); |
89 | mTypeMap.insert( KABC::Addressee::homeAddressCountryLabel(), | 93 | mTypeMap.insert( KABC::Addressee::homeAddressCountryLabel(), |
90 | HomeAddressCountry ); | 94 | HomeAddressCountry ); |
91 | mTypeMap.insert( KABC::Addressee::homeAddressLabelLabel(), HomeAddressLabel ); | 95 | mTypeMap.insert( KABC::Addressee::homeAddressLabelLabel(), HomeAddressLabel ); |
92 | 96 | ||
93 | mTypeMap.insert( KABC::Addressee::businessAddressStreetLabel(), | 97 | mTypeMap.insert( KABC::Addressee::businessAddressStreetLabel(), |
94 | BusinessAddressStreet ); | 98 | BusinessAddressStreet ); |
95 | mTypeMap.insert( KABC::Addressee::businessAddressLocalityLabel(), | 99 | mTypeMap.insert( KABC::Addressee::businessAddressLocalityLabel(), |
96 | BusinessAddressLocality ); | 100 | BusinessAddressLocality ); |
97 | mTypeMap.insert( KABC::Addressee::businessAddressRegionLabel(), | 101 | mTypeMap.insert( KABC::Addressee::businessAddressRegionLabel(), |
98 | BusinessAddressRegion ); | 102 | BusinessAddressRegion ); |
99 | mTypeMap.insert( KABC::Addressee::businessAddressPostalCodeLabel(), | 103 | mTypeMap.insert( KABC::Addressee::businessAddressPostalCodeLabel(), |
100 | BusinessAddressPostalCode ); | 104 | BusinessAddressPostalCode ); |
101 | mTypeMap.insert( KABC::Addressee::businessAddressCountryLabel(), | 105 | mTypeMap.insert( KABC::Addressee::businessAddressCountryLabel(), |
102 | BusinessAddressCountry ); | 106 | BusinessAddressCountry ); |
103 | mTypeMap.insert( KABC::Addressee::businessAddressLabelLabel(), | 107 | mTypeMap.insert( KABC::Addressee::businessAddressLabelLabel(), |
104 | BusinessAddressLabel ); | 108 | BusinessAddressLabel ); |
105 | 109 | ||
106 | mTypeMap.insert( KABC::Addressee::homePhoneLabel(), HomePhone ); | 110 | mTypeMap.insert( KABC::Addressee::homePhoneLabel(), HomePhone ); |
107 | mTypeMap.insert( KABC::Addressee::businessPhoneLabel(), BusinessPhone ); | 111 | mTypeMap.insert( KABC::Addressee::businessPhoneLabel(), BusinessPhone ); |
108 | mTypeMap.insert( KABC::Addressee::mobilePhoneLabel(), MobilePhone ); | 112 | mTypeMap.insert( KABC::Addressee::mobilePhoneLabel(), MobilePhone ); |
109 | mTypeMap.insert( KABC::Addressee::homeFaxLabel(), HomeFax ); | 113 | mTypeMap.insert( KABC::Addressee::homeFaxLabel(), HomeFax ); |
110 | mTypeMap.insert( KABC::Addressee::businessFaxLabel(), BusinessFax ); | 114 | mTypeMap.insert( KABC::Addressee::businessFaxLabel(), BusinessFax ); |
111 | mTypeMap.insert( KABC::Addressee::carPhoneLabel(), CarPhone ); | 115 | mTypeMap.insert( KABC::Addressee::carPhoneLabel(), CarPhone ); |
112 | mTypeMap.insert( KABC::Addressee::isdnLabel(), Isdn ); | 116 | mTypeMap.insert( KABC::Addressee::isdnLabel(), Isdn ); |
113 | mTypeMap.insert( KABC::Addressee::pagerLabel(), Pager ); | 117 | mTypeMap.insert( KABC::Addressee::pagerLabel(), Pager ); |
114 | mTypeMap.insert( KABC::Addressee::emailLabel(), Email ); | 118 | mTypeMap.insert( KABC::Addressee::emailLabel(), Email ); |
115 | mTypeMap.insert( KABC::Addressee::mailerLabel(), Mailer ); | 119 | mTypeMap.insert( KABC::Addressee::mailerLabel(), Mailer ); |
116 | mTypeMap.insert( KABC::Addressee::titleLabel(), Title ); | 120 | mTypeMap.insert( KABC::Addressee::titleLabel(), Title ); |
117 | mTypeMap.insert( KABC::Addressee::roleLabel(), Role ); | 121 | mTypeMap.insert( KABC::Addressee::roleLabel(), Role ); |
118 | mTypeMap.insert( KABC::Addressee::organizationLabel(), Organization ); | 122 | mTypeMap.insert( KABC::Addressee::organizationLabel(), Organization ); |
119 | mTypeMap.insert( KABC::Addressee::noteLabel(), Note ); | 123 | mTypeMap.insert( KABC::Addressee::noteLabel(), Note ); |
120 | mTypeMap.insert( KABC::Addressee::urlLabel(), URL ); | 124 | mTypeMap.insert( KABC::Addressee::urlLabel(), URL ); |
121 | 125 | ||
122 | mCustomCounter = mTypeMap.count(); | 126 | mCustomCounter = mTypeMap.count(); |
123 | int count = mCustomCounter; | 127 | int count = mCustomCounter; |
124 | 128 | ||
125 | KABC::Field::List fields = mAddressBook->fields( KABC::Field::CustomCategory ); | 129 | KABC::Field::List fields = mAddressBook->fields( KABC::Field::CustomCategory ); |
126 | KABC::Field::List::Iterator it; | 130 | KABC::Field::List::Iterator it; |
127 | for ( it = fields.begin(); it != fields.end(); ++it, ++count ) | 131 | for ( it = fields.begin(); it != fields.end(); ++it, ++count ) |
128 | mTypeMap.insert( (*it)->label(), count ); | 132 | mTypeMap.insert( (*it)->label(), count ); |
129 | 133 | ||
130 | connect( mDelimiterBox, SIGNAL( clicked( int ) ), | 134 | connect( mDelimiterBox, SIGNAL( clicked( int ) ), |
131 | this, SLOT( delimiterClicked( int ) ) ); | 135 | this, SLOT( delimiterClicked( int ) ) ); |
132 | connect( mDelimiterEdit, SIGNAL( returnPressed() ), | 136 | connect( mDelimiterEdit, SIGNAL( returnPressed() ), |
133 | this, SLOT( returnPressed() ) ); | 137 | this, SLOT( returnPressed() ) ); |
134 | connect( mDelimiterEdit, SIGNAL( textChanged ( const QString& ) ), | 138 | connect( mDelimiterEdit, SIGNAL( textChanged ( const QString& ) ), |
135 | this, SLOT( textChanged ( const QString& ) ) ); | 139 | this, SLOT( textChanged ( const QString& ) ) ); |
136 | connect( mComboLine, SIGNAL( activated( const QString& ) ), | 140 | connect( mComboLine, SIGNAL( activated( const QString& ) ), |
137 | this, SLOT( lineSelected( const QString& ) ) ); | 141 | this, SLOT( lineSelected( const QString& ) ) ); |
138 | connect( mComboQuote, SIGNAL( activated( const QString& ) ), | 142 | connect( mComboQuote, SIGNAL( activated( const QString& ) ), |
139 | this, SLOT( textquoteSelected( const QString& ) ) ); | 143 | this, SLOT( textquoteSelected( const QString& ) ) ); |
140 | connect( mIgnoreDuplicates, SIGNAL( stateChanged( int ) ), | 144 | connect( mIgnoreDuplicates, SIGNAL( stateChanged( int ) ), |
141 | this, SLOT( ignoreDuplicatesChanged( int ) ) ); | 145 | this, SLOT( ignoreDuplicatesChanged( int ) ) ); |
142 | 146 | ||
143 | connect( mUrlRequester, SIGNAL( returnPressed( const QString& ) ), | 147 | connect( mUrlRequester, SIGNAL( returnPressed( const QString& ) ), |
144 | this, SLOT( setFile( const QString& ) ) ); | 148 | this, SLOT( setFile( const QString& ) ) ); |
145 | connect( mUrlRequester, SIGNAL( urlSelected( const QString& ) ), | 149 | connect( mUrlRequester, SIGNAL( urlSelected( const QString& ) ), |
146 | this, SLOT( setFile( const QString& ) ) ); | 150 | this, SLOT( setFile( const QString& ) ) ); |
147 | connect( mUrlRequester->lineEdit(), SIGNAL( textChanged ( const QString& ) ), | 151 | connect( mUrlRequester->lineEdit(), SIGNAL( textChanged ( const QString& ) ), |
148 | this, SLOT( urlChanged( const QString& ) ) ); | 152 | this, SLOT( urlChanged( const QString& ) ) ); |
149 | 153 | ||
150 | connect( this, SIGNAL( user1Clicked() ), | 154 | connect( this, SIGNAL( user1Clicked() ), |
151 | this, SLOT( applyTemplate() ) ); | 155 | this, SLOT( applyTemplate() ) ); |
152 | 156 | ||
153 | connect( this, SIGNAL( user2Clicked() ), | 157 | connect( this, SIGNAL( user2Clicked() ), |
154 | this, SLOT( saveTemplate() ) ); | 158 | this, SLOT( saveTemplate() ) ); |
155 | 159 | ||
156 | // if ( QApplication::desktop()->width() < 321 ) | 160 | // if ( QApplication::desktop()->width() < 321 ) |
157 | QIconSet icon = SmallIcon("filesave"); | 161 | QIconSet icon = SmallIcon("filesave"); |
158 | 162 | ||
159 | findButton( User2 )->setIconSet (icon ) ; | 163 | findButton( User2 )->setIconSet (icon ) ; |
160 | icon = SmallIcon("fileopen"); | 164 | icon = SmallIcon("fileopen"); |
161 | findButton( User1 )->setIconSet (icon ) ; | 165 | findButton( User1 )->setIconSet (icon ) ; |
162 | int wid = findButton( User2 )->sizeHint().height(); | 166 | int wid = findButton( User2 )->sizeHint().height(); |
163 | findButton( User2 )->setMaximumWidth( wid+4 ); | 167 | findButton( User2 )->setMaximumWidth( wid+4 ); |
164 | findButton( User1 )->setMaximumWidth( wid+4 ); | 168 | findButton( User1 )->setMaximumWidth( wid+4 ); |
165 | } | 169 | } |
166 | 170 | ||
167 | CSVImportDialog::~CSVImportDialog() | 171 | CSVImportDialog::~CSVImportDialog() |
168 | { | 172 | { |
169 | } | 173 | } |
170 | 174 | ||
171 | KABC::AddresseeList CSVImportDialog::contacts() const | 175 | KABC::AddresseeList CSVImportDialog::contacts() const |
172 | { | 176 | { |
173 | KABC::AddresseeList contacts; | 177 | KABC::AddresseeList contacts; |
174 | 178 | ||
175 | for ( int row = 1; row < mTable->numRows(); ++row ) { | 179 | for ( int row = 1; row < mTable->numRows(); ++row ) { |
176 | KABC::Addressee a; | 180 | KABC::Addressee a; |
177 | bool emptyRow = true; | 181 | bool emptyRow = true; |
178 | KABC::Address addrHome( KABC::Address::Home ); | 182 | KABC::Address addrHome( KABC::Address::Home ); |
179 | KABC::Address addrWork( KABC::Address::Work ); | 183 | KABC::Address addrWork( KABC::Address::Work ); |
180 | for ( int col = 0; col < mTable->numCols(); ++col ) { | 184 | for ( int col = 0; col < mTable->numCols(); ++col ) { |
181 | 185 | ||
182 | QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, col ) ); | 186 | QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, col ) ); |
183 | 187 | ||
184 | if ( !item ) { | 188 | if ( !item ) { |
185 | qDebug( "ERROR: item cast failed" ); | 189 | qDebug( "ERROR: item cast failed" ); |
186 | continue; | 190 | continue; |
187 | } | 191 | } |
188 | 192 | ||
189 | QString value = mTable->text( row, col ); | 193 | QString value = mTable->text( row, col ); |
190 | if ( !value.isEmpty() ) | 194 | if ( !value.isEmpty() ) |
191 | emptyRow = false; | 195 | emptyRow = false; |
192 | 196 | ||
193 | switch ( posToType( item->currentItem() ) ) | 197 | switch ( posToType( item->currentItem() ) ) |
194 | { | 198 | { |
195 | case Undefined: | 199 | case Undefined: |
196 | continue; | 200 | continue; |
197 | break; | 201 | break; |
198 | case FormattedName: | 202 | case FormattedName: |
199 | a.setFormattedName( value ); | 203 | a.setFormattedName( value ); |
200 | break; | 204 | break; |
201 | case GivenName: | 205 | case GivenName: |
202 | a.setGivenName( value ); | 206 | a.setGivenName( value ); |
203 | break; | 207 | break; |
204 | case FamilyName: | 208 | case FamilyName: |
205 | a.setFamilyName( value ); | 209 | a.setFamilyName( value ); |
206 | break; | 210 | break; |
207 | case AdditionalName: | 211 | case AdditionalName: |
208 | a.setAdditionalName( value ); | 212 | a.setAdditionalName( value ); |
209 | break; | 213 | break; |
210 | case Prefix: | 214 | case Prefix: |
211 | a.setPrefix( value ); | 215 | a.setPrefix( value ); |
212 | break; | 216 | break; |
213 | case Suffix: | 217 | case Suffix: |
214 | a.setSuffix( value ); | 218 | a.setSuffix( value ); |
215 | break; | 219 | break; |
216 | case NickName: | 220 | case NickName: |
217 | a.setNickName( value ); | 221 | a.setNickName( value ); |
218 | break; | 222 | break; |
219 | case Birthday: | 223 | case Birthday: |
220 | //US | 224 | //US |
221 | //the generated code had the following format: a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); | 225 | //the generated code had the following format: a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); |
222 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? | 226 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? |
223 | { | 227 | { |
224 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate | 228 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate |
225 | a.setBirthday(dt); | 229 | a.setBirthday(dt); |
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp index 011e47e..fc7a42e 100644 --- a/microkde/kresources/configpage.cpp +++ b/microkde/kresources/configpage.cpp | |||
@@ -1,227 +1,231 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkresources. | 2 | This file is part of libkresources. |
3 | 3 | ||
4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | 5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either | 10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. | 11 | version 2 of the License, or (at your option) any later version. |
12 | 12 | ||
13 | This library is distributed in the hope that it will be useful, | 13 | This library 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 GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
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 | #include <qgroupbox.h> | 31 | #include <qgroupbox.h> |
32 | |||
33 | #ifdef DESKTOP_VERSION | ||
32 | #include <qinputdialog.h> | 34 | #include <qinputdialog.h> |
35 | #else | ||
36 | #include <qtcompat/qinputdialog.h> | ||
37 | #endif | ||
33 | #include <qlabel.h> | 38 | #include <qlabel.h> |
34 | #include <qlayout.h> | 39 | #include <qlayout.h> |
35 | |||
36 | #include <kapplication.h> | 40 | #include <kapplication.h> |
37 | #include <kcombobox.h> | 41 | #include <kcombobox.h> |
38 | #include <kdebug.h> | 42 | #include <kdebug.h> |
39 | #include <klocale.h> | 43 | #include <klocale.h> |
40 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
41 | #include <ksimpleconfig.h> | 45 | #include <ksimpleconfig.h> |
42 | #include <kstandarddirs.h> | 46 | #include <kstandarddirs.h> |
43 | #include <kurlrequester.h> | 47 | #include <kurlrequester.h> |
44 | #include <klistview.h> | 48 | #include <klistview.h> |
45 | #include <kbuttonbox.h> | 49 | #include <kbuttonbox.h> |
46 | //US #include <ktrader.h> | 50 | //US #include <ktrader.h> |
47 | 51 | ||
48 | #include "resource.h" | 52 | #include "resource.h" |
49 | #include "configdialog.h" | 53 | #include "configdialog.h" |
50 | 54 | ||
51 | #include "configpage.h" | 55 | #include "configpage.h" |
52 | 56 | ||
53 | //US | 57 | //US |
54 | #include <qpushbutton.h> | 58 | #include <qpushbutton.h> |
55 | #include <qfile.h> | 59 | #include <qfile.h> |
56 | #include <kglobal.h> | 60 | #include <kglobal.h> |
57 | 61 | ||
58 | using namespace KRES; | 62 | using namespace KRES; |
59 | 63 | ||
60 | class ConfigViewItem : public QCheckListItem | 64 | class ConfigViewItem : public QCheckListItem |
61 | { | 65 | { |
62 | public: | 66 | public: |
63 | ConfigViewItem( QListView *parent, Resource* resource ) : | 67 | ConfigViewItem( QListView *parent, Resource* resource ) : |
64 | QCheckListItem( parent, resource->resourceName(), CheckBox ), | 68 | QCheckListItem( parent, resource->resourceName(), CheckBox ), |
65 | mResource( resource ), | 69 | mResource( resource ), |
66 | mIsStandard( false ) | 70 | mIsStandard( false ) |
67 | { | 71 | { |
68 | setText( 1, mResource->type() ); | 72 | setText( 1, mResource->type() ); |
69 | setOn( mResource->isActive() ); | 73 | setOn( mResource->isActive() ); |
70 | } | 74 | } |
71 | 75 | ||
72 | void setStandard( bool value ) | 76 | void setStandard( bool value ) |
73 | { | 77 | { |
74 | setText( 2, ( value ? i18n( "Yes" ) : QString::null ) ); | 78 | setText( 2, ( value ? i18n( "Yes" ) : QString::null ) ); |
75 | mIsStandard = value; | 79 | mIsStandard = value; |
76 | } | 80 | } |
77 | 81 | ||
78 | bool standard() const { return mIsStandard; } | 82 | bool standard() const { return mIsStandard; } |
79 | bool readOnly() const { return mResource->readOnly(); } | 83 | bool readOnly() const { return mResource->readOnly(); } |
80 | 84 | ||
81 | Resource *resource() { return mResource; } | 85 | Resource *resource() { return mResource; } |
82 | 86 | ||
83 | private: | 87 | private: |
84 | Resource* mResource; | 88 | Resource* mResource; |
85 | 89 | ||
86 | bool mIsStandard; | 90 | bool mIsStandard; |
87 | }; | 91 | }; |
88 | 92 | ||
89 | ConfigPage::ConfigPage( QWidget *parent, const char *name ) | 93 | ConfigPage::ConfigPage( QWidget *parent, const char *name ) |
90 | : QWidget( parent, name ), | 94 | : QWidget( parent, name ), |
91 | mCurrentManager( 0 ), | 95 | mCurrentManager( 0 ), |
92 | mCurrentConfig( 0 ) | 96 | mCurrentConfig( 0 ) |
93 | { | 97 | { |
94 | setCaption( i18n( "Resource Configuration" ) ); | 98 | setCaption( i18n( "Resource Configuration" ) ); |
95 | 99 | ||
96 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 100 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
97 | 101 | ||
98 | QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this ); | 102 | QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this ); |
99 | groupBox->setColumnLayout(0, Qt::Vertical ); | 103 | groupBox->setColumnLayout(0, Qt::Vertical ); |
100 | groupBox->layout()->setSpacing( 3 ); | 104 | groupBox->layout()->setSpacing( 3 ); |
101 | groupBox->layout()->setMargin( 5 ); | 105 | groupBox->layout()->setMargin( 5 ); |
102 | QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 4, 2 ); | 106 | QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 4, 2 ); |
103 | 107 | ||
104 | //US mFamilyCombo = new KComboBox( false, groupBox ); | 108 | //US mFamilyCombo = new KComboBox( false, groupBox ); |
105 | mFamilyCombo = new KComboBox( groupBox ); | 109 | mFamilyCombo = new KComboBox( groupBox ); |
106 | groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 ); | 110 | groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 ); |
107 | 111 | ||
108 | mListView = new KListView( groupBox ); | 112 | mListView = new KListView( groupBox ); |
109 | mListView->setAllColumnsShowFocus( true ); | 113 | mListView->setAllColumnsShowFocus( true ); |
110 | mListView->addColumn( i18n( "Name" ) ); | 114 | mListView->addColumn( i18n( "Name" ) ); |
111 | mListView->addColumn( i18n( "Type" ) ); | 115 | mListView->addColumn( i18n( "Type" ) ); |
112 | mListView->addColumn( i18n( "Standard" ) ); | 116 | mListView->addColumn( i18n( "Standard" ) ); |
113 | 117 | ||
114 | //US groupBoxLayout->addWidget( mListView, 1, 0 ); | 118 | //US groupBoxLayout->addWidget( mListView, 1, 0 ); |
115 | groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 ); | 119 | groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 ); |
116 | 120 | ||
117 | 121 | ||
118 | mAddButton = new QPushButton( i18n( "&Add..." ), groupBox ); | 122 | mAddButton = new QPushButton( i18n( "&Add..." ), groupBox ); |
119 | groupBoxLayout->addWidget( mAddButton, 2, 0 ); | 123 | groupBoxLayout->addWidget( mAddButton, 2, 0 ); |
120 | mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox ); | 124 | mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox ); |
121 | groupBoxLayout->addWidget( mRemoveButton, 2, 1 ); | 125 | groupBoxLayout->addWidget( mRemoveButton, 2, 1 ); |
122 | mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox ); | 126 | mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox ); |
123 | groupBoxLayout->addWidget( mEditButton, 3, 0 ); | 127 | groupBoxLayout->addWidget( mEditButton, 3, 0 ); |
124 | mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox ); | 128 | mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox ); |
125 | groupBoxLayout->addWidget( mStandardButton, 3, 1 ); | 129 | groupBoxLayout->addWidget( mStandardButton, 3, 1 ); |
126 | 130 | ||
127 | mRemoveButton->setEnabled( false ); | 131 | mRemoveButton->setEnabled( false ); |
128 | mEditButton->setEnabled( false ); | 132 | mEditButton->setEnabled( false ); |
129 | mStandardButton->setEnabled( false ); | 133 | mStandardButton->setEnabled( false ); |
130 | 134 | ||
131 | 135 | ||
132 | connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) ); | 136 | connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) ); |
133 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) ); | 137 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) ); |
134 | connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) ); | 138 | connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) ); |
135 | connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) ); | 139 | connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) ); |
136 | 140 | ||
137 | 141 | ||
138 | mainLayout->addWidget( groupBox ); | 142 | mainLayout->addWidget( groupBox ); |
139 | 143 | ||
140 | connect( mFamilyCombo, SIGNAL( activated( int ) ), | 144 | connect( mFamilyCombo, SIGNAL( activated( int ) ), |
141 | SLOT( slotFamilyChanged( int ) ) ); | 145 | SLOT( slotFamilyChanged( int ) ) ); |
142 | connect( mListView, SIGNAL( selectionChanged() ), | 146 | connect( mListView, SIGNAL( selectionChanged() ), |
143 | SLOT( slotSelectionChanged() ) ); | 147 | SLOT( slotSelectionChanged() ) ); |
144 | connect( mListView, SIGNAL( clicked( QListViewItem * ) ), | 148 | connect( mListView, SIGNAL( clicked( QListViewItem * ) ), |
145 | SLOT( slotItemClicked( QListViewItem * ) ) ); | 149 | SLOT( slotItemClicked( QListViewItem * ) ) ); |
146 | 150 | ||
147 | mLastItem = 0; | 151 | mLastItem = 0; |
148 | 152 | ||
149 | //US mConfig = new KConfig( "kcmkresourcesrc" ); | 153 | //US mConfig = new KConfig( "kcmkresourcesrc" ); |
150 | mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") ); | 154 | mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") ); |
151 | mConfig->setGroup( "General" ); | 155 | mConfig->setGroup( "General" ); |
152 | 156 | ||
153 | load(); | 157 | load(); |
154 | } | 158 | } |
155 | 159 | ||
156 | ConfigPage::~ConfigPage() | 160 | ConfigPage::~ConfigPage() |
157 | { | 161 | { |
158 | QValueList<ResourcePageInfo>::Iterator it; | 162 | QValueList<ResourcePageInfo>::Iterator it; |
159 | for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) { | 163 | for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) { |
160 | (*it).mManager->removeListener( this ); | 164 | (*it).mManager->removeListener( this ); |
161 | delete (*it).mManager; | 165 | delete (*it).mManager; |
162 | delete (*it).mConfig; | 166 | delete (*it).mConfig; |
163 | } | 167 | } |
164 | 168 | ||
165 | mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() ); | 169 | mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() ); |
166 | delete mConfig; | 170 | delete mConfig; |
167 | mConfig = 0; | 171 | mConfig = 0; |
168 | } | 172 | } |
169 | 173 | ||
170 | void ConfigPage::load() | 174 | void ConfigPage::load() |
171 | { | 175 | { |
172 | kdDebug(5650) << "ConfigPage::load()" << endl; | 176 | kdDebug(5650) << "ConfigPage::load()" << endl; |
173 | 177 | ||
174 | mListView->clear(); | 178 | mListView->clear(); |
175 | 179 | ||
176 | //US we remove the dynamic pluginloader, and set the one family we need (contact) manually. | 180 | //US we remove the dynamic pluginloader, and set the one family we need (contact) manually. |
177 | 181 | ||
178 | //US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); | 182 | //US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); |
179 | //US KTrader::OfferList::ConstIterator it; | 183 | //US KTrader::OfferList::ConstIterator it; |
180 | //US for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 184 | //US for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
181 | //US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); | 185 | //US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); |
182 | //US QString family = tmp.toString(); | 186 | //US QString family = tmp.toString(); |
183 | QStringList families; | 187 | QStringList families; |
184 | families << "contact"; | 188 | families << "contact"; |
185 | 189 | ||
186 | 190 | ||
187 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) | 191 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) |
188 | { | 192 | { |
189 | QString family = (*it); | 193 | QString family = (*it); |
190 | if ( !family.isEmpty() ) { | 194 | if ( !family.isEmpty() ) { |
191 | if ( !mFamilyMap.contains( family ) ) { | 195 | if ( !mFamilyMap.contains( family ) ) { |
192 | mCurrentManager = new Manager<Resource>( family ); | 196 | mCurrentManager = new Manager<Resource>( family ); |
193 | if ( mCurrentManager ) { | 197 | if ( mCurrentManager ) { |
194 | mFamilyMap.append( family ); | 198 | mFamilyMap.append( family ); |
195 | mCurrentManager->addListener( this ); | 199 | mCurrentManager->addListener( this ); |
196 | 200 | ||
197 | ResourcePageInfo info; | 201 | ResourcePageInfo info; |
198 | info.mManager = mCurrentManager; | 202 | info.mManager = mCurrentManager; |
199 | QString configDir = KGlobal::dirs()->saveLocation( "config" ); | 203 | QString configDir = KGlobal::dirs()->saveLocation( "config" ); |
200 | //QString configDir = KStandardDirs::appDir() + "/config"; | 204 | //QString configDir = KStandardDirs::appDir() + "/config"; |
201 | if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { | 205 | if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { |
202 | info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); | 206 | info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); |
203 | } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { | 207 | } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { |
204 | info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); | 208 | info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); |
205 | } else { | 209 | } else { |
206 | QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); | 210 | QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); |
207 | info.mConfig = new KConfig( configFile ); | 211 | info.mConfig = new KConfig( configFile ); |
208 | } | 212 | } |
209 | info.mManager->readConfig( info.mConfig ); | 213 | info.mManager->readConfig( info.mConfig ); |
210 | 214 | ||
211 | mInfoMap.append( info ); | 215 | mInfoMap.append( info ); |
212 | } | 216 | } |
213 | } | 217 | } |
214 | } | 218 | } |
215 | } | 219 | } |
216 | mCurrentManager = 0; | 220 | mCurrentManager = 0; |
217 | 221 | ||
218 | mFamilyCombo->insertStringList( mFamilyMap ); | 222 | mFamilyCombo->insertStringList( mFamilyMap ); |
219 | 223 | ||
220 | int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); | 224 | int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); |
221 | mFamilyCombo->setCurrentItem( currentFamily ); | 225 | mFamilyCombo->setCurrentItem( currentFamily ); |
222 | slotFamilyChanged( currentFamily ); | 226 | slotFamilyChanged( currentFamily ); |
223 | } | 227 | } |
224 | 228 | ||
225 | void ConfigPage::save() | 229 | void ConfigPage::save() |
226 | { | 230 | { |
227 | saveResourceSettings(); | 231 | saveResourceSettings(); |