All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SettingsDialog.cpp
Go to the documentation of this file.
1 #include <ui_SettingsDialogForm.h>
2 
4 #include "SettingsDialog.h"
5 #include "DisplayWidgetFactory.h"
6 #include "ProjectWidgetFactory.h"
7 #include "TableWidgetFactory.h"
9 
10 // Qt
11 #include <QtGui/QScrollArea>
12 
13 void GetFactoriesNames (QVector<QString>& facNames)
14 {
15  std::vector<std::string> vec;
18 
19  for(it = d.begin(); it != d.end(); ++it)
20  facNames.append(it->first.c_str());
21 }
22 
23 QWidget* GetWidget(const QString& facName, QWidget* parent)
24 {
25  QScrollArea* scr = new QScrollArea(parent);
26  std::string value = facName.toStdString();
27 
28  QWidget* wid = te::qt::af::SettingsWidgetsFactory::make(value, scr);
29 
30  QGridLayout* lay = new QGridLayout(scr);
31 
32  scr->setWidget(wid);
33  lay->addWidget(wid);
34 
35  scr->setFrameShape(QFrame::NoFrame);
36 
37  return scr;
38 }
39 
41 QDialog(parent),
42 m_ui(new Ui::SettingsDialogForm)
43 {
44  m_ui->setupUi(this);
45 
50 
51  QVector<QString> facNames;
52  QVector<QString>::Iterator it;
53 
54  GetFactoriesNames(facNames);
55 
56  for(it = facNames.begin(); it != facNames.end(); ++it)
57  m_ui->m_settingsListView->addItem(*it);
58 
59  // Signal/Slots connections
60  connect (m_ui->m_closePushButton, SIGNAL(pressed()), SLOT(close()));
61  connect (m_ui->m_settingsListView, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), SLOT(settingsChanged (QListWidgetItem*, QListWidgetItem*)));
62 
63  m_ui->m_settingsListView->setCurrentRow(0);
64 }
65 
67 {
72 
73  delete m_ui;
74 }
75 
76 void te::qt::af::SettingsDialog::settingsChanged (QListWidgetItem* current, QListWidgetItem* previous)
77 {
78  QString sett = current->text();
79  int pos = -1;
80 
81  if(m_widPos.find(sett) == m_widPos.end())
82  {
83  QWidget* wid = GetWidget(sett, this);
84  pos = m_ui->m_widgetStack->addWidget(wid);
85 
86  m_widPos[sett] = pos;
87  }
88  else
89  pos = m_widPos[sett];
90 
91  if(pos == -1)
92  throw;
93 
94  if(pos != m_ui->m_widgetStack->currentIndex())
95  {
96  // Disconnecting old
97  QWidget* w = ((QScrollArea*)m_ui->m_widgetStack->currentWidget())->widget();
98 
99  if(!w->disconnect(SIGNAL(updateApplyButtonState(const bool&)), this, SLOT(updateApplyButtonState(const bool&))))
100  throw;
101 
102  if(!m_ui->m_applyPushButton->disconnect(SIGNAL(clicked()), w, SLOT(onApplyButtonClicked())))
103  throw;
104  }
105 
106  // Connecting new
107  QWidget* w = ((QScrollArea*)m_ui->m_widgetStack->widget(pos))->widget();
108  connect(w, SIGNAL(updateApplyButtonState(const bool&)), SLOT(updateApplyButtonState(const bool&)));
109  w->connect(m_ui->m_applyPushButton, SIGNAL(clicked()), SLOT(onApplyButtonClicked()));
110 
111  // Update dialog
112  m_ui->m_widgetStack->setCurrentIndex(pos);
113  m_ui->m_customGroupBox->setTitle(sett + tr(" settings"));
114 
116 
117  QString lbl = w2->getResumeText(),
118  ns,
119  page;
120 
121  w2->getHelpInformations(ns, page);
122 
123  m_ui->m_helpPushButton->setNameSpace(ns);
124  m_ui->m_helpPushButton->setPageReference(page);
125 
126  m_ui->m_resumeLabel->setText(lbl);
127 
128  m_ui->m_applyPushButton->setEnabled(false);
129 }
130 
132 {
133  m_ui->m_applyPushButton->setEnabled(state);
134 }
QWidget * GetWidget(const QString &facName, QWidget *parent)
A factory to build the Table frame object.
void settingsChanged(QListWidgetItem *current, QListWidgetItem *previous)
void updateApplyButtonState(const bool &state)
This class represents a dictionary of factories.
virtual void getHelpInformations(QString &ns, QString &helpFile)=0
Ui::SettingsDialogForm * m_ui
A factory to build the project frame object.
void GetFactoriesNames(QVector< QString > &facNames)
SettingsDialog(QWidget *parent=0)
static dictionary_type & getDictionary()
It returns a reference to the internal dictionary of concrete factories.
A factory to build the tool bars widget object.
A factory to build the display frame object.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
static AbstractSettingWidget * make(const std::string &cwType, QWidget *parent=0)
A for customization of the application components.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator end() const
It returns an iterator to the end of the container.
An abstraction for setting widgets.
A frame for setting Table options.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator begin() const
It returns an iterator to the first stored factory.