summaryrefslogtreecommitdiffabout
path: root/microkde
authorulf69 <ulf69>2004-07-27 00:57:35 (UTC)
committer ulf69 <ulf69>2004-07-27 00:57:35 (UTC)
commit203a3f0cf7bfc16be93d3a9c75d244d5a9956c2c (patch) (unidiff)
tree3d25d89a5a0206fd5abd0820be834949663daacf /microkde
parentb33c195abfc2e83cc3510707f05bf6a4c93912cf (diff)
downloadkdepimpi-203a3f0cf7bfc16be93d3a9c75d244d5a9956c2c.zip
kdepimpi-203a3f0cf7bfc16be93d3a9c75d244d5a9956c2c.tar.gz
kdepimpi-203a3f0cf7bfc16be93d3a9c75d244d5a9956c2c.tar.bz2
added sync-contact as new resourcefamily. Those resources can be choosen
as sync targets.
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/configpage.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index 0f1469d..8782ffd 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -70,220 +70,223 @@ class ConfigViewItem : public QCheckListItem
70 70
71 bool standard() const { return mIsStandard; } 71 bool standard() const { return mIsStandard; }
72 bool readOnly() const { return mResource->readOnly(); } 72 bool readOnly() const { return mResource->readOnly(); }
73 73
74 Resource *resource() { return mResource; } 74 Resource *resource() { return mResource; }
75 75
76 private: 76 private:
77 Resource* mResource; 77 Resource* mResource;
78 78
79 bool mIsStandard; 79 bool mIsStandard;
80}; 80};
81 81
82ConfigPage::ConfigPage( QWidget *parent, const char *name ) 82ConfigPage::ConfigPage( QWidget *parent, const char *name )
83 : QWidget( parent, name ), 83 : QWidget( parent, name ),
84 mCurrentManager( 0 ), 84 mCurrentManager( 0 ),
85 mCurrentConfig( 0 ) 85 mCurrentConfig( 0 )
86{ 86{
87 setCaption( i18n( "Resource Configuration" ) ); 87 setCaption( i18n( "Resource Configuration" ) );
88 88
89 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 89 QVBoxLayout *mainLayout = new QVBoxLayout( this );
90 90
91 QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this ); 91 QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this );
92 groupBox->setColumnLayout(0, Qt::Vertical ); 92 groupBox->setColumnLayout(0, Qt::Vertical );
93 groupBox->layout()->setSpacing( 6 ); 93 groupBox->layout()->setSpacing( 6 );
94 groupBox->layout()->setMargin( 11 ); 94 groupBox->layout()->setMargin( 11 );
95 QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 2, 2 ); 95 QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 2, 2 );
96 96
97//US mFamilyCombo = new KComboBox( false, groupBox ); 97//US mFamilyCombo = new KComboBox( false, groupBox );
98 mFamilyCombo = new KComboBox( groupBox ); 98 mFamilyCombo = new KComboBox( groupBox );
99 groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 ); 99 groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 );
100 100
101 mListView = new KListView( groupBox ); 101 mListView = new KListView( groupBox );
102 mListView->setAllColumnsShowFocus( true ); 102 mListView->setAllColumnsShowFocus( true );
103 mListView->addColumn( i18n( "Name" ) ); 103 mListView->addColumn( i18n( "Name" ) );
104 mListView->addColumn( i18n( "Type" ) ); 104 mListView->addColumn( i18n( "Type" ) );
105 mListView->addColumn( i18n( "Standard" ) ); 105 mListView->addColumn( i18n( "Standard" ) );
106 106
107 groupBoxLayout->addWidget( mListView, 1, 0 ); 107 groupBoxLayout->addWidget( mListView, 1, 0 );
108 108
109 KButtonBox *buttonBox = new KButtonBox( groupBox, Vertical ); 109 KButtonBox *buttonBox = new KButtonBox( groupBox, Vertical );
110 mAddButton = buttonBox->addButton( i18n( "&Add..." ), this, SLOT(slotAdd()) ); 110 mAddButton = buttonBox->addButton( i18n( "&Add..." ), this, SLOT(slotAdd()) );
111 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT(slotRemove()) ); 111 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT(slotRemove()) );
112 mRemoveButton->setEnabled( false ); 112 mRemoveButton->setEnabled( false );
113 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT(slotEdit()) ); 113 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT(slotEdit()) );
114 mEditButton->setEnabled( false ); 114 mEditButton->setEnabled( false );
115 mStandardButton = buttonBox->addButton( i18n( "&Use as Standard" ), this, SLOT(slotStandard()) ); 115 mStandardButton = buttonBox->addButton( i18n( "&Use as Standard" ), this, SLOT(slotStandard()) );
116 mStandardButton->setEnabled( false ); 116 mStandardButton->setEnabled( false );
117 buttonBox->layout(); 117 buttonBox->layout();
118 118
119 groupBoxLayout->addWidget( buttonBox, 1, 1 ); 119 groupBoxLayout->addWidget( buttonBox, 1, 1 );
120 120
121 mainLayout->addWidget( groupBox ); 121 mainLayout->addWidget( groupBox );
122 122
123 connect( mFamilyCombo, SIGNAL( activated( int ) ), 123 connect( mFamilyCombo, SIGNAL( activated( int ) ),
124 SLOT( slotFamilyChanged( int ) ) ); 124 SLOT( slotFamilyChanged( int ) ) );
125 connect( mListView, SIGNAL( selectionChanged() ), 125 connect( mListView, SIGNAL( selectionChanged() ),
126 SLOT( slotSelectionChanged() ) ); 126 SLOT( slotSelectionChanged() ) );
127 connect( mListView, SIGNAL( clicked( QListViewItem * ) ), 127 connect( mListView, SIGNAL( clicked( QListViewItem * ) ),
128 SLOT( slotItemClicked( QListViewItem * ) ) ); 128 SLOT( slotItemClicked( QListViewItem * ) ) );
129 129
130 mLastItem = 0; 130 mLastItem = 0;
131 131
132//US mConfig = new KConfig( "kcmkresourcesrc" ); 132//US mConfig = new KConfig( "kcmkresourcesrc" );
133 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") ); 133 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") );
134 mConfig->setGroup( "General" ); 134 mConfig->setGroup( "General" );
135 135
136 load(); 136 load();
137} 137}
138 138
139ConfigPage::~ConfigPage() 139ConfigPage::~ConfigPage()
140{ 140{
141 QValueList<ResourcePageInfo>::Iterator it; 141 QValueList<ResourcePageInfo>::Iterator it;
142 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) { 142 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) {
143 (*it).mManager->removeListener( this ); 143 (*it).mManager->removeListener( this );
144 delete (*it).mManager; 144 delete (*it).mManager;
145 delete (*it).mConfig; 145 delete (*it).mConfig;
146 } 146 }
147 147
148 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() ); 148 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() );
149 delete mConfig; 149 delete mConfig;
150 mConfig = 0; 150 mConfig = 0;
151} 151}
152 152
153void ConfigPage::load() 153void ConfigPage::load()
154{ 154{
155 kdDebug(5650) << "ConfigPage::load()" << endl; 155 kdDebug(5650) << "ConfigPage::load()" << endl;
156 156
157 mListView->clear(); 157 mListView->clear();
158 158
159//US we remove the dynamic pluginloader, and set the one family we need (contact) manually. 159//US we remove the dynamic pluginloader, and set the one family we need (contact) manually.
160 160
161//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); 161//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" );
162//US KTrader::OfferList::ConstIterator it; 162//US KTrader::OfferList::ConstIterator it;
163//US for ( it = plugins.begin(); it != plugins.end(); ++it ) { 163//US for ( it = plugins.begin(); it != plugins.end(); ++it ) {
164//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); 164//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" );
165//US QString family = tmp.toString(); 165//US QString family = tmp.toString();
166 166 QStringList families;
167 QString family = "contact"; 167 families << "contact" << "sync-contacts";
168 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
169 {
170 QString family = (*it);
168 if ( !family.isEmpty() ) { 171 if ( !family.isEmpty() ) {
169 if ( !mFamilyMap.contains( family ) ) { 172 if ( !mFamilyMap.contains( family ) ) {
170 mCurrentManager = new Manager<Resource>( family ); 173 mCurrentManager = new Manager<Resource>( family );
171 if ( mCurrentManager ) { 174 if ( mCurrentManager ) {
172 mFamilyMap.append( family ); 175 mFamilyMap.append( family );
173 mCurrentManager->addListener( this ); 176 mCurrentManager->addListener( this );
174 177
175 ResourcePageInfo info; 178 ResourcePageInfo info;
176 info.mManager = mCurrentManager; 179 info.mManager = mCurrentManager;
177 QString configDir = KGlobal::dirs()->saveLocation( "config" ); 180 QString configDir = KGlobal::dirs()->saveLocation( "config" );
178 //QString configDir = KStandardDirs::appDir() + "/config"; 181 //QString configDir = KStandardDirs::appDir() + "/config";
179 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { 182 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) {
180 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); 183 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) );
181 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { 184 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) {
182 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); 185 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) );
183 } else { 186 } else {
184 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); 187 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) );
185 info.mConfig = new KConfig( configFile ); 188 info.mConfig = new KConfig( configFile );
186 } 189 }
187 info.mManager->readConfig( info.mConfig ); 190 info.mManager->readConfig( info.mConfig );
188 191
189 mInfoMap.append( info ); 192 mInfoMap.append( info );
190 } 193 }
191 } 194 }
192 } 195 }
193//US } 196 }
194 mCurrentManager = 0; 197 mCurrentManager = 0;
195 198
196 mFamilyCombo->insertStringList( mFamilyMap ); 199 mFamilyCombo->insertStringList( mFamilyMap );
197 200
198 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); 201 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 );
199 mFamilyCombo->setCurrentItem( currentFamily ); 202 mFamilyCombo->setCurrentItem( currentFamily );
200 slotFamilyChanged( currentFamily ); 203 slotFamilyChanged( currentFamily );
201} 204}
202 205
203void ConfigPage::save() 206void ConfigPage::save()
204{ 207{
205 saveResourceSettings(); 208 saveResourceSettings();
206 209
207 QValueList<ResourcePageInfo>::Iterator it; 210 QValueList<ResourcePageInfo>::Iterator it;
208 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) 211 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it )
209 (*it).mManager->writeConfig( (*it).mConfig ); 212 (*it).mManager->writeConfig( (*it).mConfig );
210 213
211 emit changed( false ); 214 emit changed( false );
212} 215}
213 216
214void ConfigPage::defaults() 217void ConfigPage::defaults()
215{ 218{
216} 219}
217 220
218void ConfigPage::slotFamilyChanged( int pos ) 221void ConfigPage::slotFamilyChanged( int pos )
219{ 222{
220 if ( pos < 0 || pos >= (int)mFamilyMap.count() ) 223 if ( pos < 0 || pos >= (int)mFamilyMap.count() )
221 return; 224 return;
222 225
223 saveResourceSettings(); 226 saveResourceSettings();
224 227
225 mFamily = mFamilyMap[ pos ]; 228 mFamily = mFamilyMap[ pos ];
226 229
227//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1()); 230//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1());
228 231
229 mCurrentManager = mInfoMap[ pos ].mManager; 232 mCurrentManager = mInfoMap[ pos ].mManager;
230 mCurrentConfig = mInfoMap[ pos ].mConfig; 233 mCurrentConfig = mInfoMap[ pos ].mConfig;
231 234
232 if ( !mCurrentManager ) 235 if ( !mCurrentManager )
233 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl; 236 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl;
234 237
235 mListView->clear(); 238 mListView->clear();
236 239
237 if ( mCurrentManager->isEmpty() ) { 240 if ( mCurrentManager->isEmpty() ) {
238//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager ); 241//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager );
239 242
240 defaults(); 243 defaults();
241 } 244 }
242 245
243 Resource *standardResource = mCurrentManager->standardResource(); 246 Resource *standardResource = mCurrentManager->standardResource();
244 247
245//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1()); 248//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1());
246 249
247 250
248 Manager<Resource>::Iterator it; 251 Manager<Resource>::Iterator it;
249 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) { 252 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) {
250 ConfigViewItem *item = new ConfigViewItem( mListView, *it ); 253 ConfigViewItem *item = new ConfigViewItem( mListView, *it );
251 if ( *it == standardResource ) 254 if ( *it == standardResource )
252 item->setStandard( true ); 255 item->setStandard( true );
253 } 256 }
254 257
255 if ( mListView->childCount() == 0 ) { 258 if ( mListView->childCount() == 0 ) {
256//US qDebug("ConfigPage::slotFamilyChanged 4.5 "); 259//US qDebug("ConfigPage::slotFamilyChanged 4.5 ");
257 260
258 defaults(); 261 defaults();
259 emit changed( true ); 262 emit changed( true );
260 mCurrentManager->writeConfig( mCurrentConfig ); 263 mCurrentManager->writeConfig( mCurrentConfig );
261 } else { 264 } else {
262//US qDebug("ConfigPage::slotFamilyChanged 4.6 "); 265//US qDebug("ConfigPage::slotFamilyChanged 4.6 ");
263 266
264 if ( !standardResource ) { 267 if ( !standardResource ) {
265 KMessageBox::sorry( this, i18n( "There is no standard resource! Please select one." ) ); 268 KMessageBox::sorry( this, i18n( "There is no standard resource! Please select one." ) );
266 269
267//US qDebug("ConfigPage::slotFamilyChanged 4.7" ); 270//US qDebug("ConfigPage::slotFamilyChanged 4.7" );
268 271
269 } 272 }
270 273
271 emit changed( false ); 274 emit changed( false );
272 } 275 }
273} 276}
274 277
275void ConfigPage::slotAdd() 278void ConfigPage::slotAdd()
276{ 279{
277 if ( !mCurrentManager ) 280 if ( !mCurrentManager )
278 return; 281 return;
279 282
280 QStringList types = mCurrentManager->resourceTypeNames(); 283 QStringList types = mCurrentManager->resourceTypeNames();
281 QStringList descs = mCurrentManager->resourceTypeDescriptions(); 284 QStringList descs = mCurrentManager->resourceTypeDescriptions();
282 bool ok = false; 285 bool ok = false;
283 QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ), 286 QString desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
284 i18n( "Please select type of the new resource:" ), descs, 0, 287 i18n( "Please select type of the new resource:" ), descs, 0,
285 false, &ok, this ); 288 false, &ok, this );
286 if ( !ok ) 289 if ( !ok )
287 return; 290 return;
288 291
289 QString type = types[ descs.findIndex( desc ) ]; 292 QString type = types[ descs.findIndex( desc ) ];