forked from organicmaps/organicmaps-tmp
Improve UI a bit.
This commit is contained in:
parent
8f7782963d
commit
6d7196be16
5 changed files with 38 additions and 8 deletions
|
@ -239,29 +239,30 @@ MainWindow::MainWindow(Framework & framework)
|
|||
m_closeTrafficSampleAction = fileMenu->addAction(
|
||||
"Close sample", this, &MainWindow::OnCloseTrafficSample
|
||||
);
|
||||
m_closeTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
|
||||
m_saveTrafficSampleAction = fileMenu->addAction(
|
||||
"Save sample", this, &MainWindow::OnSaveTrafficSample
|
||||
);
|
||||
|
||||
fileMenu->addAction("Start editing", [this] {
|
||||
m_startEditingAction = fileMenu->addAction("Start editing", [this] {
|
||||
m_trafficMode->StartBuildingPath();
|
||||
m_mapWidget->SetTrafficMarkupMode();
|
||||
m_commitPathAction->setEnabled(true /* enabled */);
|
||||
m_cancelPathAction->setEnabled(true /* enabled */);
|
||||
//m_mapWidget->ShowPointsInViewPort();
|
||||
});
|
||||
fileMenu->addAction("Commit path", [this] {
|
||||
m_commitPathAction = fileMenu->addAction("Commit path", [this] {
|
||||
m_trafficMode->CommitPath();
|
||||
m_mapWidget->SetNormalMode();
|
||||
//TODO m_mapWidget->ClearShownPoints();
|
||||
});
|
||||
fileMenu->addAction("Cancel path", [this] {
|
||||
m_cancelPathAction = fileMenu->addAction("Cancel path", [this] {
|
||||
m_trafficMode->RollBackPath();
|
||||
m_mapWidget->SetNormalMode();
|
||||
// TODO m_mapWidget->ClearShownPoints();
|
||||
});
|
||||
|
||||
m_closeTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_saveTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_startEditingAction->setEnabled(false /* enabled */);
|
||||
m_commitPathAction->setEnabled(false /* enabled */);
|
||||
m_cancelPathAction->setEnabled(false /* enabled */);
|
||||
}
|
||||
|
||||
void MainWindow::CreateTrafficPanel(string const & dataFilePath)
|
||||
|
@ -273,6 +274,8 @@ void MainWindow::CreateTrafficPanel(string const & dataFilePath)
|
|||
|
||||
connect(m_mapWidget, &MapWidget::TrafficMarkupClick,
|
||||
m_trafficMode, &TrafficMode::OnClick);
|
||||
connect(m_trafficMode, &TrafficMode::EditingStopped,
|
||||
this, &MainWindow::OnPathEditingStop);
|
||||
|
||||
m_docWidget = new QDockWidget(tr("Routes"), this);
|
||||
addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, m_docWidget);
|
||||
|
@ -315,6 +318,7 @@ void MainWindow::OnOpenTrafficSample()
|
|||
|
||||
m_closeTrafficSampleAction->setEnabled(true /* enabled */);
|
||||
m_saveTrafficSampleAction->setEnabled(true /* enabled */);
|
||||
m_startEditingAction->setEnabled(true /* enabled */);
|
||||
}
|
||||
|
||||
void MainWindow::OnCloseTrafficSample()
|
||||
|
@ -325,6 +329,10 @@ void MainWindow::OnCloseTrafficSample()
|
|||
|
||||
m_saveTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_closeTrafficSampleAction->setEnabled(false /* enabled */);
|
||||
m_startEditingAction->setEnabled(false /* enabled */);
|
||||
m_commitPathAction->setEnabled(false /* enabled */);
|
||||
m_cancelPathAction->setEnabled(false /* enabled */);
|
||||
|
||||
DestroyTrafficPanel();
|
||||
}
|
||||
|
||||
|
@ -342,3 +350,9 @@ void MainWindow::OnSaveTrafficSample()
|
|||
QString("Can't save file: ") + strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OnPathEditingStop()
|
||||
{
|
||||
m_commitPathAction->setEnabled(false /* enabled */);
|
||||
m_cancelPathAction->setEnabled(false /* enabled */);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ private:
|
|||
void OnOpenTrafficSample();
|
||||
void OnCloseTrafficSample();
|
||||
void OnSaveTrafficSample();
|
||||
void OnPathEditingStop();
|
||||
|
||||
Framework & m_framework;
|
||||
|
||||
|
@ -41,6 +42,9 @@ private:
|
|||
|
||||
QAction * m_saveTrafficSampleAction = nullptr;
|
||||
QAction * m_closeTrafficSampleAction = nullptr;
|
||||
QAction * m_startEditingAction = nullptr;
|
||||
QAction * m_commitPathAction = nullptr;
|
||||
QAction * m_cancelPathAction = nullptr;
|
||||
|
||||
MapWidget * m_mapWidget = nullptr;
|
||||
};
|
||||
|
|
|
@ -166,6 +166,7 @@ TrafficMode::TrafficMode(std::string const & dataFileName,
|
|||
// TODO(mgsergio): LOG(LINFO, (xxx, "segments are loaded"));
|
||||
}
|
||||
|
||||
// TODO(mgsergio): Check if a path was commited, or commit it.
|
||||
bool TrafficMode::SaveSampleAs(std::string const & fileName) const
|
||||
{
|
||||
CHECK(!fileName.empty(), ("Can't save to an empty file."));
|
||||
|
@ -311,6 +312,7 @@ void TrafficMode::CommitPath()
|
|||
if (m_goldenPath.empty())
|
||||
{
|
||||
LOG(LDEBUG, ("Golden path is empty :'("));
|
||||
emit EditingStopped();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -345,6 +347,7 @@ void TrafficMode::CommitPath()
|
|||
}
|
||||
|
||||
m_currentSegment->GetGoldenPath() = path;
|
||||
emit EditingStopped();
|
||||
}
|
||||
|
||||
void TrafficMode::RollBackPath()
|
||||
|
@ -362,6 +365,8 @@ void TrafficMode::RollBackPath()
|
|||
m_drawerDelegate->ClearGoldenPath();
|
||||
if (auto const & path = m_currentSegment->GetGoldenPath())
|
||||
m_drawerDelegate->DrawGoldenPath(GetPoints(*path));
|
||||
|
||||
emit EditingStopped();
|
||||
}
|
||||
|
||||
size_t TrafficMode::GetPointsCount() const
|
||||
|
|
|
@ -199,6 +199,9 @@ public slots:
|
|||
HandlePoint(clickPoint, button);
|
||||
}
|
||||
|
||||
signals:
|
||||
void EditingStopped();
|
||||
|
||||
private:
|
||||
void HandlePoint(m2::PointD clickPoint, Qt::MouseButton const button);
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ TrafficPanel::TrafficPanel(QAbstractItemModel * trafficModel, QWidget * parent)
|
|||
auto * layout = new QVBoxLayout();
|
||||
layout->addWidget(m_table);
|
||||
setLayout(layout);
|
||||
|
||||
// Select first segment by default;
|
||||
auto const & index = m_table->model()->index(0, 0);
|
||||
m_table->selectionModel()->select(index, QItemSelectionModel::Select);
|
||||
}
|
||||
|
||||
void TrafficPanel::CreateTable(QAbstractItemModel * trafficModel)
|
||||
|
|
Loading…
Add table
Reference in a new issue