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, te::qt::af::ApplicationController* app)
25 {
26  QScrollArea* scr = new QScrollArea(parent);
27  std::string value = facName.toUtf8().data();
28 
30  wid->setApplicationController(app);
31 
32  QGridLayout* lay = new QGridLayout(scr);
33 
34  scr->setWidget(wid);
35  lay->addWidget(wid);
36 
37  scr->setFrameShape(QFrame::NoFrame);
38 
39  return scr;
40 }
41 
43 QDialog(parent),
44 m_app(nullptr),
45 m_ui(new Ui::SettingsDialogForm)
46 {
47  m_ui->setupUi(this);
48 
49  // Signal/Slots connections
50  connect (m_ui->m_closePushButton, SIGNAL(pressed()), SLOT(close()));
51  connect (m_ui->m_settingsListView, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), SLOT(settingsChanged (QListWidgetItem*, QListWidgetItem*)));
52 
53 
54 }
55 
57 {
60  //ProjectWidgetFactory::finalize();
63 
64  delete m_ui;
65 }
66 
68 {
69  m_app = app;
70 
73  //ProjectWidgetFactory::initialize();
76 
77  QVector<QString> facNames;
78  QVector<QString>::Iterator it;
79 
80  GetFactoriesNames(facNames);
81 
82  for (it = facNames.begin(); it != facNames.end(); ++it)
83  m_ui->m_settingsListView->addItem(*it);
84 
85  m_ui->m_settingsListView->setCurrentRow(0);
86 }
87 
88 void te::qt::af::SettingsDialog::settingsChanged(QListWidgetItem* current,
89  QListWidgetItem* /*previous*/)
90 {
91  QString sett = current->text();
92  int pos = -1;
93 
94  if(m_widPos.find(sett) == m_widPos.end())
95  {
96  QWidget* wid = GetWidget(sett, this, m_app);
97  pos = m_ui->m_widgetStack->addWidget(wid);
98 
99  m_widPos[sett] = pos;
100  }
101  else
102  pos = m_widPos[sett];
103 
104  if(pos == -1)
105  throw;
106 
107  if(pos != m_ui->m_widgetStack->currentIndex())
108  {
109  // Disconnecting old
110  QWidget* w = ((QScrollArea*)m_ui->m_widgetStack->currentWidget())->widget();
111 
112  if(!w->disconnect(SIGNAL(updateApplyButtonState(const bool&)), this, SLOT(updateApplyButtonState(const bool&))))
113  throw;
114 
115  if(!m_ui->m_applyPushButton->disconnect(SIGNAL(clicked()), w, SLOT(onApplyButtonClicked())))
116  throw;
117  }
118 
119  // Connecting new
120  QWidget* w = ((QScrollArea*)m_ui->m_widgetStack->widget(pos))->widget();
121  connect(w, SIGNAL(updateApplyButtonState(const bool&)), SLOT(updateApplyButtonState(const bool&)));
122  w->connect(m_ui->m_applyPushButton, SIGNAL(clicked()), SLOT(onApplyButtonClicked()));
123 
124  // Update dialog
125  m_ui->m_widgetStack->setCurrentIndex(pos);
126  m_ui->m_customGroupBox->setTitle(sett + tr(" settings"));
127 
129 
130  QString lbl = w2->getResumeText(),
131  ns,
132  page;
133 
134  w2->getHelpInformations(ns, page);
135 
136  m_ui->m_helpPushButton->setNameSpace(ns);
137  m_ui->m_helpPushButton->setPageReference(page);
138 
139  m_ui->m_resumeLabel->setText(lbl);
140 
141  m_ui->m_applyPushButton->setEnabled(false);
142 }
143 
145 {
146  m_ui->m_applyPushButton->setEnabled(state);
147 }
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.
void setApplicationController(te::qt::af::ApplicationController *app)
QMap< QString, int > m_widPos
SettingsDialog(QWidget *parent=0)
The base API for TerraLib applications.
static dictionary_type & getDictionary()
It returns a reference to the internal dictionary of concrete factories.
te::qt::af::ApplicationController * m_app
A factory to build the display frame object.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
void updateApplyButtonState(const bool &state)
Ui::SettingsDialogForm * m_ui
A frame for setting Table options.
A factory to build the general config frame object.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator end() const
It returns an iterator to the end of the container.
virtual void setApplicationController(te::qt::af::ApplicationController *app)
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)
QWidget * GetWidget(const QString &facName, QWidget *parent, te::qt::af::ApplicationController *app)
void GetFactoriesNames(QVector< QString > &facNames)
A factory to build the tool bars widget object.
This class represents a dictionary of factories.