summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-27 00:57:35 (UTC)
committer ulf69 <ulf69>2004-07-27 00:57:35 (UTC)
commit203a3f0cf7bfc16be93d3a9c75d244d5a9956c2c (patch) (unidiff)
tree3d25d89a5a0206fd5abd0820be834949663daacf
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 (more/less context) (show 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
@@ -118,124 +118,127 @@ ConfigPage::ConfigPage( QWidget *parent, const char *name )
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 }