13 #include "ui_RoutingSettingsWidget.h"
16 #include <QStandardItemModel>
29 class RoutingProfilesWidget::Private
42 const PluginManager *
const m_pluginManager;
43 RoutingProfilesModel *
const m_profilesModel;
44 Ui_RoutingSettingsWidget m_ui;
47 RoutingProfilesWidget::Private::Private( MarbleModel *marbleModel, RoutingProfilesWidget *parent ) :
49 m_pluginManager( marbleModel->pluginManager() ),
50 m_profilesModel( marbleModel->routingManager()->profilesModel() )
56 d( new Private( marbleModel, this ) )
58 d->m_ui.setupUi(
this );
59 d->m_ui.profilesList->setModel( d->m_profilesModel );
61 connect( d->m_ui.addButton, SIGNAL(clicked(
bool)), SLOT(add()) );
62 connect( d->m_ui.removeButton, SIGNAL(clicked(
bool)), SLOT(
remove()) );
63 connect( d->m_ui.configureButton, SIGNAL(clicked(
bool)), SLOT(configure()) );
64 connect( d->m_ui.moveUpButton, SIGNAL(clicked(
bool)), SLOT(moveUp()) );
65 connect( d->m_ui.moveDownButton, SIGNAL(clicked(
bool)), SLOT(moveDown()) );
66 connect( d->m_ui.profilesList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(updateButtons()), Qt::QueuedConnection );
67 connect( d->m_ui.profilesList, SIGNAL(doubleClicked(QModelIndex)), SLOT(configure()) );
69 connect( d->m_profilesModel, SIGNAL(layoutChanged()), SLOT(updateButtons()) );
77 void RoutingProfilesWidget::Private::add()
79 m_profilesModel->addProfile( tr(
"New Profile" ) );
81 int profileIndex = m_profilesModel->rowCount() - 1;
82 m_ui.profilesList->selectionModel()->select( m_profilesModel->index( profileIndex, 0 ), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent );
85 dialog.editProfile( profileIndex );
88 void RoutingProfilesWidget::Private::remove()
90 if ( m_ui.profilesList->selectionModel()->selectedRows().isEmpty() ) {
93 m_profilesModel->removeRows( m_ui.profilesList->selectionModel()->selectedRows().first().row(), 1 );
96 void RoutingProfilesWidget::Private::configure()
98 if ( m_ui.profilesList->selectionModel()->selectedRows().isEmpty() ) {
102 int profileIndex = m_ui.profilesList->selectionModel()->selectedRows().first().row();
104 RoutingProfileSettingsDialog dialog( m_pluginManager, m_profilesModel, q );
105 dialog.editProfile( profileIndex );
108 void RoutingProfilesWidget::Private::moveUp()
110 if ( m_ui.profilesList->selectionModel()->selectedRows().isEmpty() ) {
113 m_profilesModel->moveUp( m_ui.profilesList->selectionModel()->selectedRows().first().row() );
116 void RoutingProfilesWidget::Private::moveDown()
118 if ( m_ui.profilesList->selectionModel()->selectedRows().isEmpty() ) {
121 m_profilesModel->moveDown( m_ui.profilesList->selectionModel()->selectedRows().first().row() );
124 void RoutingProfilesWidget::Private::updateButtons()
127 if ( !m_ui.profilesList->selectionModel()->selectedRows().isEmpty() ) {
128 current = m_ui.profilesList->selectionModel()->selectedRows().first();
130 m_ui.configureButton->setEnabled( current.isValid() );
131 m_ui.removeButton->setEnabled( current.isValid() );
132 m_ui.moveUpButton->setEnabled( current.isValid() && current.row() > 0 );
133 m_ui.moveDownButton->setEnabled( current.isValid() && current.row()+1 < m_profilesModel->rowCount() );
138 #include "RoutingProfilesWidget.moc"
This file contains the headers for MarbleModel.
The data model (not based on QAbstractModel) for a MarbleWidget.