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