akregator/src

settings_advanced.cpp
1 #include "akregatorconfig.h"
2 #include "settings_advanced.h"
3 #include "storagefactory.h"
4 #include "storagefactoryregistry.h"
5 
6 #include <tqpushbutton.h>
7 #include <tqstringlist.h>
8 #include <tqwidget.h>
9 
10 #include <kcombobox.h>
11 
12 namespace Akregator {
13 
14 SettingsAdvanced::SettingsAdvanced(TQWidget* parent, const char* name) : SettingsAdvancedBase(parent, name)
15 {
16 
17  TQStringList backends = Backend::StorageFactoryRegistry::self()->list();
18  TQString tname;
19  int i = 0;
20  TQStringList::Iterator end( backends.end() );
21  for (TQStringList::Iterator it = backends.begin(); it != end; ++it)
22  {
23  m_factories[i] = Backend::StorageFactoryRegistry::self()->getFactory(*it);
24  m_keyPos[m_factories[i]->key()] = i;
25  cbBackend->insertItem(m_factories[i]->name());
26  i++;
27  }
28  connect(pbBackendConfigure, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotConfigureStorage()));
29  connect(cbBackend, TQ_SIGNAL(activated(int)), this, TQ_SLOT(slotFactorySelected(int)));
30 }
31 
32 TQString SettingsAdvanced::selectedFactory() const
33 {
34  return m_factories[cbBackend->currentItem()]->key();
35 }
36 
37 void SettingsAdvanced::selectFactory(const TQString& key)
38 {
39  cbBackend->setCurrentItem(m_keyPos[key]);
40  pbBackendConfigure->setEnabled((m_factories[m_keyPos[key]]->isConfigurable()));
41 }
42 
43 void SettingsAdvanced::slotConfigureStorage()
44 {
45  m_factories[cbBackend->currentItem()]->configure();
46 }
47 
48 void SettingsAdvanced::slotFactorySelected(int pos)
49 {
50  pbBackendConfigure->setEnabled(m_factories[pos]->isConfigurable());
51 }
52 
53 } //namespace Akregator
54 #include "settings_advanced.moc"