dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
importsettings.cpp
Go to the documentation of this file.
1 #include "importsettings.h"
2 #include "ui_importsettings.h"
3 #include <QDir>
4 #include <QSettings>
5 #include <utils/xmlconfig.h>
6 #include <QTimer>
7 
9  : QDialog(parent)
10  , ui(new Ui::importSettings)
11 {
12  ui->setupUi(this);
13  connect(ui->cbConfigs, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDetails(int)));
14  connect(ui->btnLoad, SIGNAL(clicked()), this, SLOT(accept()));
15  QTimer::singleShot(500, this, SLOT(repaint()));
16 }
17 void importSettings::loadFiles(QString path)
18 {
19  QDir myDir(path);
20  QStringList filters;
21  filters << "*.xml";
22  QStringList list = myDir.entryList(filters, QDir::Files);
23  int x = 0;
24  foreach (QString fileStr, list) {
25  fileInfo *info = new fileInfo;
26  QSettings settings(path + QDir::separator() + fileStr, XmlConfig::XmlSettingsFormat);
27  settings.beginGroup("General");
28  info->description = settings.value("Description", "None").toString();
29  info->details = settings.value("Details", "None").toString();
30  settings.endGroup();
31  info->file = path + QDir::separator() + fileStr;
32  configList.insert(x, info);
33  ui->cbConfigs->addItem(info->description, x);
34  ++x;
35  }
36 }
37 
38 void importSettings::updateDetails(int index)
39 {
40  fileInfo *info = configList.value(ui->cbConfigs->itemData(index).toInt());
41  ui->lblDetails->setText(info->details);
42 }
44 {
45  fileInfo *info =
46  configList.value(ui->cbConfigs->itemData(ui->cbConfigs->currentIndex()).toInt());
47  return info->file;
48 }
49 
51 {
52  foreach (fileInfo *info, configList.values()) {
53  delete info;
54  }
55  delete ui;
56 }
importSettings(QWidget *parent=nullptr)
QString choosenConfig()
static const QSettings::Format XmlSettingsFormat
Definition: xmlconfig.h:43
void loadFiles(QString path)
x
Definition: OPPlots.m:100