7#include "RoutingProfilesWidget.h"
9#include "ui_RoutingSettingsWidget.h"
11#include "MarbleDebug.h"
13#include "PluginManager.h"
14#include "RoutingManager.h"
15#include "RoutingProfileSettingsDialog.h"
16#include "RoutingProfilesModel.h"
17#include "RoutingRunnerPlugin.h"
18#include <QStandardItemModel>
23class Q_DECL_HIDDEN RoutingProfilesWidget::Private
26 Private(MarbleModel *marbleModel, RoutingProfilesWidget *parent);
35 RoutingProfilesWidget *
const q;
36 const PluginManager *
const m_pluginManager;
37 RoutingProfilesModel *
const m_profilesModel;
38 Ui_RoutingSettingsWidget m_ui;
41RoutingProfilesWidget::Private::Private(MarbleModel *marbleModel, RoutingProfilesWidget *parent)
43 , m_pluginManager(marbleModel->pluginManager())
44 , m_profilesModel(marbleModel->routingManager()->profilesModel())
48RoutingProfilesWidget::RoutingProfilesWidget(MarbleModel *marbleModel)
50 , d(new Private(marbleModel, this))
53 d->m_ui.profilesList->setModel(d->m_profilesModel);
55 connect(d->m_ui.addButton, SIGNAL(clicked(
bool)), SLOT(
add()));
56 connect(d->m_ui.removeButton, SIGNAL(clicked(
bool)), SLOT(
remove()));
58 connect(d->m_ui.moveUpButton, SIGNAL(clicked(
bool)), SLOT(moveUp()));
59 connect(d->m_ui.moveDownButton, SIGNAL(clicked(
bool)), SLOT(moveDown()));
63 connect(d->m_profilesModel, SIGNAL(layoutChanged()), SLOT(updateButtons()));
66RoutingProfilesWidget::~RoutingProfilesWidget()
71void RoutingProfilesWidget::Private::add()
73 m_profilesModel->addProfile(tr(
"New Profile"));
75 int profileIndex = m_profilesModel->rowCount() - 1;
78 RoutingProfileSettingsDialog dialog(m_pluginManager, m_profilesModel, q);
79 dialog.editProfile(profileIndex);
82void RoutingProfilesWidget::Private::remove()
84 if (m_ui.profilesList->selectionModel()->selectedRows().isEmpty()) {
87 m_profilesModel->removeRows(m_ui.profilesList->selectionModel()->selectedRows().first().row(), 1);
90void RoutingProfilesWidget::Private::configure()
92 if (m_ui.profilesList->selectionModel()->selectedRows().isEmpty()) {
96 int profileIndex = m_ui.profilesList->selectionModel()->selectedRows().first().row();
98 RoutingProfileSettingsDialog dialog(m_pluginManager, m_profilesModel, q);
99 dialog.editProfile(profileIndex);
102void RoutingProfilesWidget::Private::moveUp()
104 if (m_ui.profilesList->selectionModel()->selectedRows().isEmpty()) {
107 m_profilesModel->moveUp(m_ui.profilesList->selectionModel()->selectedRows().first().row());
110void RoutingProfilesWidget::Private::moveDown()
112 if (m_ui.profilesList->selectionModel()->selectedRows().isEmpty()) {
115 m_profilesModel->moveDown(m_ui.profilesList->selectionModel()->selectedRows().first().row());
118void RoutingProfilesWidget::Private::updateButtons()
121 if (!m_ui.profilesList->selectionModel()->selectedRows().isEmpty()) {
122 current = m_ui.profilesList->selectionModel()->selectedRows().first();
124 m_ui.configureButton->setEnabled(current.
isValid());
125 m_ui.removeButton->setEnabled(current.
isValid());
126 m_ui.moveUpButton->setEnabled(current.
isValid() && current.
row() > 0);
127 m_ui.moveDownButton->setEnabled(current.
isValid() && current.
row() + 1 < m_profilesModel->rowCount());
132#include "moc_RoutingProfilesWidget.cpp"
This file contains the headers for MarbleModel.
bool remove(const QString &column, const QVariant &value)
Binds a QML item to a specific geodetic location in screen coordinates.
bool isValid() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)