6#include "RoutingProfileSettingsDialog.h"
8#include <QStandardItemModel>
10#include "MarbleDebug.h"
11#include "MarbleGlobal.h"
12#include "PluginManager.h"
13#include "RoutingProfilesModel.h"
15#include "ui_RoutingProfileSettingsDialog.h"
20RoutingProfileSettingsDialog::RoutingProfileSettingsDialog(
const PluginManager *pluginManager, RoutingProfilesModel *profilesModel,
QWidget *parent)
22 , m_profilesModel(profilesModel)
24 , m_dialogLayout(nullptr)
26 m_ui =
new Ui_RoutingProfileSettingsDialog();
28 bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
30 setMinimumHeight(480);
31 m_ui->services->setMinimumWidth(280);
32 m_ui->buttonBox->hide();
36 for (RoutingRunnerPlugin *plugin : allPlugins) {
38 RoutingRunnerPlugin::ConfigWidget *configWidget = plugin->configWidget();
40 m_configWidgets.insert(plugin, configWidget);
41 m_ui->settingsStack->addWidget(configWidget);
46 m_ui->services->setModel(m_servicesModel);
56RoutingProfileSettingsDialog::~RoutingProfileSettingsDialog()
58 qDeleteAll(m_configWidgets);
62void RoutingProfileSettingsDialog::updateConfigWidget()
64 QModelIndex current = m_ui->services->selectionModel()->currentIndex();
67 m_ui->settingsStack->setEnabled(
false);
71 RoutingRunnerPlugin *plugin = m_plugins.at(current.
row());
72 QWidget *configWidget = m_configWidgets[plugin];
74 bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
75 m_ui->settingsStack->setCurrentWidget(smallScreen ? m_ui->configurePage : configWidget);
76 m_ui->descriptionLabel->setText(plugin->description());
77 m_ui->statusLabel->setText(plugin->statusMessage());
81 m_ui->settingsStack->setEnabled(
false);
82 m_ui->noConfigDescriptionLabel->setText(plugin->description());
83 m_ui->noConfigStatusLabel->setText(plugin->statusMessage());
84 m_ui->settingsStack->setCurrentWidget(m_ui->noConfigAvailablePage);
88void RoutingProfileSettingsDialog::editProfile(
int profileIndex)
91 m_ui->name->setText(profiles.
at(profileIndex).name());
93 m_servicesModel->
clear();
94 for (RoutingRunnerPlugin *plugin : m_plugins) {
97 if (profiles[profileIndex].pluginSettings().contains(plugin->nameId())) {
100 mDebug() << settings;
101 if (m_configWidgets[plugin]) {
102 m_configWidgets[plugin]->loadSettings(settings);
105 m_servicesModel->invisibleRootItem()->appendRow(item);
107 m_ui->settingsStack->setCurrentWidget(m_ui->selectServicePage);
108 m_ui->settingsStack->setEnabled(
false);
110 bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
116 m_profilesModel->setProfileName(profileIndex, m_ui->name->text());
119 for (
int i = 0; i < m_servicesModel->invisibleRootItem()->rowCount(); ++i) {
123 if (m_configWidgets[m_plugins[i]]) {
124 settings = m_configWidgets[m_plugins[i]]->settings();
126 mDebug() << i << m_plugins[i]->nameId() << settings;
127 pluginSettings.
insert(m_plugins[i]->nameId(), settings);
129 pluginSettings.
remove(m_plugins[i]->nameId());
132 m_profilesModel->setProfilePluginSettings(profileIndex, pluginSettings);
135void RoutingProfileSettingsDialog::openConfigDialog()
137 QModelIndex current = m_ui->services->selectionModel()->currentIndex();
139 RoutingRunnerPlugin *plugin = m_plugins.at(current.
row());
145 m_dialogLayout->addWidget(m_configWidgets[plugin]);
147 m_dialog->setLayout(m_dialogLayout);
148 m_dialog->setMinimumHeight(480);
150 m_dialogLayout->insertWidget(0, m_configWidgets[plugin]);
153 m_configWidgets[plugin]->show();
154 m_dialog->setWindowTitle(plugin->guiString());
156 m_configWidgets[plugin]->hide();
157 m_dialogLayout->removeWidget(m_configWidgets[plugin]);
163#include "moc_RoutingProfileSettingsDialog.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
iterator insert(const Key &key, const T &value)
bool remove(const Key &key)
const_reference at(qsizetype i) const const
bool isValid() const const
Qt::CheckState checkState() const const
QStandardItem * child(int row, int column) const const
void setCheckState(Qt::CheckState state)
void setCheckable(bool checkable)
void setEnabled(bool enabled)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)