mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
AboutDialog::AboutDialog(QWidget * parent)
|
||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint |
|
||||
Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint)
|
||||
: QDialog(parent,
|
||||
Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
QIcon icon(":/ui/logo.png");
|
||||
setWindowIcon(icon);
|
||||
@@ -33,7 +33,7 @@ AboutDialog::AboutDialog(QWidget * parent)
|
||||
versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
versionBox->addWidget(versionLabel);
|
||||
// TODO: insert maps data version.
|
||||
//versionBox->addWidget(new QLabel(QString("Data: ") + DESIGNER_DATA_VERSION));
|
||||
// versionBox->addWidget(new QLabel(QString("Data: ") + DESIGNER_DATA_VERSION));
|
||||
|
||||
QHBoxLayout * hBox = new QHBoxLayout();
|
||||
hBox->addWidget(labelIcon);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
class AboutDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutDialog(QWidget * parent);
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
|
||||
namespace qt
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
@@ -128,8 +127,8 @@ void BookmarkDialog::OnCloseClick()
|
||||
|
||||
void BookmarkDialog::OnImportClick()
|
||||
{
|
||||
auto const files = QFileDialog::getOpenFileNames(this /* parent */, tr("Open KML, KMZ, GPX..."),
|
||||
QString() /* dir */, "KML, KMZ, GPX files (*.kml *.KML *.kmz *.KMZ, *.gpx *.GPX)");
|
||||
auto const files = QFileDialog::getOpenFileNames(this /* parent */, tr("Open KML, KMZ, GPX..."), QString() /* dir */,
|
||||
"KML, KMZ, GPX files (*.kml *.KML *.kmz *.KMZ, *.gpx *.GPX)");
|
||||
|
||||
for (auto const & name : files)
|
||||
{
|
||||
@@ -165,13 +164,13 @@ void BookmarkDialog::OnExportClick()
|
||||
return;
|
||||
}
|
||||
|
||||
auto const name = QFileDialog::getSaveFileName(this /* parent */, tr("Export KMZ..."),
|
||||
QString() /* dir */, "KMZ files (*.kmz)");
|
||||
auto const name =
|
||||
QFileDialog::getSaveFileName(this /* parent */, tr("Export KMZ..."), QString() /* dir */, "KMZ files (*.kmz)");
|
||||
if (name.isEmpty())
|
||||
return;
|
||||
|
||||
m_framework.GetBookmarkManager().PrepareFileForSharing({categoryIt->second},
|
||||
[this, name](BookmarkManager::SharingResult const & result)
|
||||
[this, name](BookmarkManager::SharingResult const & result)
|
||||
{
|
||||
if (result.m_code == BookmarkManager::SharingResult::Code::Success)
|
||||
{
|
||||
@@ -280,8 +279,7 @@ void BookmarkDialog::FillTree()
|
||||
if (name.empty())
|
||||
{
|
||||
name = measurement_utils::FormatLatLon(mercator::YToLat(bookmark->GetPivot().y),
|
||||
mercator::XToLon(bookmark->GetPivot().x),
|
||||
true /* withComma */);
|
||||
mercator::XToLon(bookmark->GetPivot().x), true /* withComma */);
|
||||
}
|
||||
auto bookmarkItem = CreateTreeItem(name + " (Bookmark)", categoryItem);
|
||||
m_bookmarks[bookmarkItem] = bookmarkId;
|
||||
|
||||
@@ -63,25 +63,15 @@ bool CopyFile(QString const & oldFile, QString const & newFile)
|
||||
void CopyFromResources(QString const & name, QString const & output)
|
||||
{
|
||||
QString const resourceDir = GetPlatform().ResourcesDir().c_str();
|
||||
if (!CopyFile(JoinPathQt({resourceDir, name}),
|
||||
JoinPathQt({output, name})))
|
||||
{
|
||||
throw std::runtime_error(std::string("Cannot copy file ") +
|
||||
name.toStdString() +
|
||||
" to " + output.toStdString());
|
||||
}
|
||||
if (!CopyFile(JoinPathQt({resourceDir, name}), JoinPathQt({output, name})))
|
||||
throw std::runtime_error(std::string("Cannot copy file ") + name.toStdString() + " to " + output.toStdString());
|
||||
}
|
||||
|
||||
void CopyToResources(QString const & name, QString const & input, QString const & newName)
|
||||
{
|
||||
QString const resourceDir = GetPlatform().ResourcesDir().c_str();
|
||||
if (!CopyFile(JoinPathQt({input, name}),
|
||||
JoinPathQt({resourceDir, newName.isEmpty() ? name : newName})))
|
||||
{
|
||||
throw std::runtime_error(std::string("Cannot copy file ") +
|
||||
name.toStdString() +
|
||||
" from " + input.toStdString());
|
||||
}
|
||||
if (!CopyFile(JoinPathQt({input, name}), JoinPathQt({resourceDir, newName.isEmpty() ? name : newName})))
|
||||
throw std::runtime_error(std::string("Cannot copy file ") + name.toStdString() + " from " + input.toStdString());
|
||||
}
|
||||
|
||||
QString JoinPathQt(std::initializer_list<QString> folders)
|
||||
@@ -102,8 +92,7 @@ QString JoinPathQt(std::initializer_list<QString> folders)
|
||||
return QDir::cleanPath(result);
|
||||
}
|
||||
|
||||
QString GetExternalPath(QString const & name, QString const & primaryPath,
|
||||
QString const & secondaryPath)
|
||||
QString GetExternalPath(QString const & name, QString const & primaryPath, QString const & secondaryPath)
|
||||
{
|
||||
QString const resourceDir = GetPlatform().ResourcesDir().c_str();
|
||||
QString path = JoinPathQt({resourceDir, primaryPath, name});
|
||||
|
||||
@@ -29,12 +29,17 @@ void BuildDrawingRulesImpl(QString const & mapcssFile, QString const & outputDir
|
||||
env.insert("PROTOBUF_EGG_PATH", GetProtobufEggPath());
|
||||
|
||||
// Run the script
|
||||
(void)ExecProcess("python", {
|
||||
GetExternalPath("libkomwm.py", "kothic/src", "../tools/kothic/src"),
|
||||
"-s", mapcssFile,
|
||||
"-o", outputTemplate,
|
||||
"-x", "True",
|
||||
}, &env);
|
||||
(void)ExecProcess("python",
|
||||
{
|
||||
GetExternalPath("libkomwm.py", "kothic/src", "../tools/kothic/src"),
|
||||
"-s",
|
||||
mapcssFile,
|
||||
"-o",
|
||||
outputTemplate,
|
||||
"-x",
|
||||
"True",
|
||||
},
|
||||
&env);
|
||||
|
||||
// Ensure that generated file is not empty.
|
||||
if (QFile(outputFile).size() == 0)
|
||||
|
||||
@@ -20,11 +20,8 @@ QString RunBuildingPhonePack(QString const & stylesDir, QString const & targetDi
|
||||
|
||||
if (!QDir(targetDir).exists())
|
||||
throw runtime_error("target directory does not exist" + targetDir.toStdString());
|
||||
|
||||
return ExecProcess("python", {
|
||||
GetExternalPath("generate_styles_override.py", "", "../tools/python"),
|
||||
stylesDir,
|
||||
targetDir
|
||||
});
|
||||
|
||||
return ExecProcess("python",
|
||||
{GetExternalPath("generate_styles_override.py", "", "../tools/python"), stylesDir, targetDir});
|
||||
}
|
||||
} // namespace build_style
|
||||
|
||||
@@ -31,30 +31,33 @@ enum SkinType
|
||||
SkinCount
|
||||
};
|
||||
|
||||
using SkinInfo = std::tuple<const char*, int, bool>;
|
||||
SkinInfo const g_skinInfo[SkinCount] =
|
||||
{
|
||||
std::make_tuple("mdpi", 18, false),
|
||||
std::make_tuple("hdpi", 27, false),
|
||||
std::make_tuple("xhdpi", 36, false),
|
||||
std::make_tuple("6plus", 43, false),
|
||||
std::make_tuple("xxhdpi", 54, false),
|
||||
std::make_tuple("xxxhdpi", 64, false),
|
||||
using SkinInfo = std::tuple<char const *, int, bool>;
|
||||
SkinInfo const g_skinInfo[SkinCount] = {
|
||||
std::make_tuple("mdpi", 18, false), std::make_tuple("hdpi", 27, false), std::make_tuple("xhdpi", 36, false),
|
||||
std::make_tuple("6plus", 43, false), std::make_tuple("xxhdpi", 54, false), std::make_tuple("xxxhdpi", 64, false),
|
||||
};
|
||||
|
||||
std::array<SkinType, SkinCount> const g_skinTypes =
|
||||
{{
|
||||
SkinMDPI,
|
||||
SkinHDPI,
|
||||
SkinXHDPI,
|
||||
Skin6Plus,
|
||||
SkinXXHDPI,
|
||||
SkinXXXHDPI,
|
||||
std::array<SkinType, SkinCount> const g_skinTypes = {{
|
||||
SkinMDPI,
|
||||
SkinHDPI,
|
||||
SkinXHDPI,
|
||||
Skin6Plus,
|
||||
SkinXXHDPI,
|
||||
SkinXXXHDPI,
|
||||
}};
|
||||
|
||||
inline const char * SkinSuffix(SkinType s) { return std::get<0>(g_skinInfo[s]); }
|
||||
inline int SkinSize(SkinType s) { return std::get<1>(g_skinInfo[s]); }
|
||||
inline bool SkinCoorrectColor(SkinType s) { return std::get<2>(g_skinInfo[s]); }
|
||||
inline char const * SkinSuffix(SkinType s)
|
||||
{
|
||||
return std::get<0>(g_skinInfo[s]);
|
||||
}
|
||||
inline int SkinSize(SkinType s)
|
||||
{
|
||||
return std::get<1>(g_skinInfo[s]);
|
||||
}
|
||||
inline bool SkinCoorrectColor(SkinType s)
|
||||
{
|
||||
return std::get<2>(g_skinInfo[s]);
|
||||
}
|
||||
|
||||
QString GetSkinGeneratorPath()
|
||||
{
|
||||
@@ -124,8 +127,8 @@ std::unordered_map<std::string, int> GetSkinSizes(QString const & file)
|
||||
return skinSizes;
|
||||
}
|
||||
|
||||
void BuildSkinImpl(QString const & styleDir, QString const & suffix,
|
||||
int size, bool colorCorrection, QString const & outputDir)
|
||||
void BuildSkinImpl(QString const & styleDir, QString const & suffix, int size, bool colorCorrection,
|
||||
QString const & outputDir)
|
||||
{
|
||||
QString const symbolsDir = JoinPathQt({styleDir, "symbols"});
|
||||
|
||||
@@ -152,13 +155,18 @@ void BuildSkinImpl(QString const & styleDir, QString const & suffix,
|
||||
QString const strSize = QString::number(size);
|
||||
// Run the script.
|
||||
(void)ExecProcess(GetSkinGeneratorPath(), {
|
||||
"--symbolWidth", strSize,
|
||||
"--symbolHeight", strSize,
|
||||
"--symbolsDir", symbolsDir,
|
||||
"--skinName", JoinPathQt({outputDir, "basic"}),
|
||||
"--skinSuffix=",
|
||||
"--colorCorrection", (colorCorrection ? "true" : "false"),
|
||||
});
|
||||
"--symbolWidth",
|
||||
strSize,
|
||||
"--symbolHeight",
|
||||
strSize,
|
||||
"--symbolsDir",
|
||||
symbolsDir,
|
||||
"--skinName",
|
||||
JoinPathQt({outputDir, "basic"}),
|
||||
"--skinSuffix=",
|
||||
"--colorCorrection",
|
||||
(colorCorrection ? "true" : "false"),
|
||||
});
|
||||
|
||||
// Check if files were created.
|
||||
if (QFile(JoinPathQt({outputDir, "symbols.png"})).size() == 0 ||
|
||||
@@ -178,7 +186,7 @@ void BuildSkins(QString const & styleDir, QString const & outputDir)
|
||||
{
|
||||
QString const suffix = SkinSuffix(s);
|
||||
QString const outputSkinDir = JoinPathQt({outputDir, "symbols", suffix, "design"});
|
||||
int const size = resolution2size.at(suffix.toStdString()); // SkinSize(s);
|
||||
int const size = resolution2size.at(suffix.toStdString()); // SkinSize(s);
|
||||
bool const colorCorrection = SkinCoorrectColor(s);
|
||||
|
||||
BuildSkinImpl(styleDir, suffix, size, colorCorrection, outputSkinDir);
|
||||
@@ -198,10 +206,8 @@ void ApplySkins(QString const & outputDir)
|
||||
if (!QFileInfo::exists(resourceSkinDir) && !QDir().mkdir(resourceSkinDir))
|
||||
throw std::runtime_error("Cannot create resource skin directory: " + resourceSkinDir.toStdString());
|
||||
|
||||
if (!CopyFile(JoinPathQt({outputSkinDir, "symbols.png"}),
|
||||
JoinPathQt({resourceSkinDir, "symbols.png"})) ||
|
||||
!CopyFile(JoinPathQt({outputSkinDir, "symbols.sdf"}),
|
||||
JoinPathQt({resourceSkinDir, "symbols.sdf"})))
|
||||
if (!CopyFile(JoinPathQt({outputSkinDir, "symbols.png"}), JoinPathQt({resourceSkinDir, "symbols.png"})) ||
|
||||
!CopyFile(JoinPathQt({outputSkinDir, "symbols.sdf"}), JoinPathQt({resourceSkinDir, "symbols.sdf"})))
|
||||
{
|
||||
throw std::runtime_error("Cannot copy skins files");
|
||||
}
|
||||
|
||||
@@ -27,11 +27,13 @@ QString GetStyleStatistics(QString const & mapcssMappingFile, QString const & dr
|
||||
env.insert("PROTOBUF_EGG_PATH", GetProtobufEggPath());
|
||||
|
||||
// Run the script.
|
||||
return ExecProcess("python", {
|
||||
GetExternalPath("drules_info.py", "kothic/src", "../tools/python/stylesheet"),
|
||||
mapcssMappingFile,
|
||||
drulesFile,
|
||||
}, &env);
|
||||
return ExecProcess("python",
|
||||
{
|
||||
GetExternalPath("drules_info.py", "kothic/src", "../tools/python/stylesheet"),
|
||||
mapcssMappingFile,
|
||||
drulesFile,
|
||||
},
|
||||
&env);
|
||||
}
|
||||
|
||||
QString GetCurrentStyleStatistics()
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <future>
|
||||
#include <string>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -54,7 +54,7 @@ void BuildAndApply(QString const & mapcssFile)
|
||||
{
|
||||
auto future = std::async(std::launch::async, BuildSkins, styleDir, outputDir);
|
||||
BuildDrawingRules(mapcssFile, outputDir);
|
||||
future.get(); // may rethrow exception from the BuildSkin
|
||||
future.get(); // may rethrow exception from the BuildSkin
|
||||
|
||||
ApplyDrawingRules(outputDir);
|
||||
ApplySkins(outputDir);
|
||||
@@ -108,13 +108,13 @@ void RunRecalculationGeometryScript(QString const & mapcssFile)
|
||||
CopyFromResources("types.txt", geometryToolResourceDir);
|
||||
|
||||
(void)ExecProcess("python", {
|
||||
GetRecalculateGeometryScriptPath(),
|
||||
resourceDir,
|
||||
writableDir,
|
||||
generatorToolPath,
|
||||
appPath,
|
||||
mapcssFile,
|
||||
});
|
||||
GetRecalculateGeometryScriptPath(),
|
||||
resourceDir,
|
||||
writableDir,
|
||||
generatorToolPath,
|
||||
appPath,
|
||||
mapcssFile,
|
||||
});
|
||||
}
|
||||
|
||||
bool NeedRecalculate = false;
|
||||
|
||||
@@ -11,12 +11,12 @@ std::pair<bool, QString> RunCurrentStyleTests()
|
||||
QString const program = GetExternalPath("style_tests", "style_tests.app/Contents/MacOS", "");
|
||||
QString const resourcesDir = QString::fromStdString(GetPlatform().ResourcesDir());
|
||||
QString const output = ExecProcess(program, {
|
||||
"--user_resource_path=" + resourcesDir,
|
||||
"--data_path=" + resourcesDir,
|
||||
});
|
||||
"--user_resource_path=" + resourcesDir,
|
||||
"--data_path=" + resourcesDir,
|
||||
});
|
||||
|
||||
// Unfortunately test process returns 0 even if some test failed,
|
||||
// therefore phrase 'All tests passed.' is looked to be sure that everything is OK.
|
||||
return std::make_pair(output.contains("All tests passed."), output);
|
||||
}
|
||||
} // namespace build_style
|
||||
} // namespace build_style
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include <QtWidgets/QListWidget>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
CreateFeatureDialog::CreateFeatureDialog(QWidget * parent, osm::NewFeatureCategories & cats)
|
||||
: QDialog(parent)
|
||||
CreateFeatureDialog::CreateFeatureDialog(QWidget * parent, osm::NewFeatureCategories & cats) : QDialog(parent)
|
||||
{
|
||||
cats.AddLanguage("en");
|
||||
cats.AddLanguage(languages::GetCurrentNorm());
|
||||
|
||||
@@ -11,6 +11,7 @@ class NewFeatureCategories;
|
||||
class CreateFeatureDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CreateFeatureDialog(QWidget * parent, osm::NewFeatureCategories & cats);
|
||||
/// Valid only if dialog has finished with Accepted code.
|
||||
|
||||
@@ -51,13 +51,12 @@ using namespace qt::common;
|
||||
namespace
|
||||
{
|
||||
std::vector<dp::Color> colorList = {
|
||||
dp::Color(255, 0, 0, 255), dp::Color(0, 255, 0, 255), dp::Color(0, 0, 255, 255),
|
||||
dp::Color(255, 255, 0, 255), dp::Color(0, 255, 255, 255), dp::Color(255, 0, 255, 255),
|
||||
dp::Color(100, 0, 0, 255), dp::Color(0, 100, 0, 255), dp::Color(0, 0, 100, 255),
|
||||
dp::Color(100, 100, 0, 255), dp::Color(0, 100, 100, 255), dp::Color(100, 0, 100, 255)};
|
||||
dp::Color(255, 0, 0, 255), dp::Color(0, 255, 0, 255), dp::Color(0, 0, 255, 255), dp::Color(255, 255, 0, 255),
|
||||
dp::Color(0, 255, 255, 255), dp::Color(255, 0, 255, 255), dp::Color(100, 0, 0, 255), dp::Color(0, 100, 0, 255),
|
||||
dp::Color(0, 0, 100, 255), dp::Color(100, 100, 0, 255), dp::Color(0, 100, 100, 255), dp::Color(100, 0, 100, 255)};
|
||||
|
||||
void DrawMwmBorder(df::DrapeApi & drapeApi, std::string const & mwmName,
|
||||
std::vector<m2::RegionD> const & regions, bool withVertices)
|
||||
void DrawMwmBorder(df::DrapeApi & drapeApi, std::string const & mwmName, std::vector<m2::RegionD> const & regions,
|
||||
bool withVertices)
|
||||
{
|
||||
for (size_t i = 0; i < regions.size(); ++i)
|
||||
{
|
||||
@@ -84,62 +83,60 @@ df::TouchEvent::ETouchType qtTouchEventTypeToDfTouchEventType(QEvent::Type qEven
|
||||
{
|
||||
switch (qEventType)
|
||||
{
|
||||
case QEvent::TouchBegin: return df::TouchEvent::TOUCH_DOWN;
|
||||
case QEvent::TouchEnd: return df::TouchEvent::TOUCH_UP;
|
||||
case QEvent::TouchUpdate: return df::TouchEvent::TOUCH_MOVE;
|
||||
case QEvent::TouchCancel: return df::TouchEvent::TOUCH_CANCEL;
|
||||
default: return df::TouchEvent::TOUCH_NONE;
|
||||
case QEvent::TouchBegin: return df::TouchEvent::TOUCH_DOWN;
|
||||
case QEvent::TouchEnd: return df::TouchEvent::TOUCH_UP;
|
||||
case QEvent::TouchUpdate: return df::TouchEvent::TOUCH_MOVE;
|
||||
case QEvent::TouchCancel: return df::TouchEvent::TOUCH_CANCEL;
|
||||
default: return df::TouchEvent::TOUCH_NONE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
DrawWidget::DrawWidget(Framework & framework, std::unique_ptr<ScreenshotParams> && screenshotParams,
|
||||
QWidget * parent)
|
||||
DrawWidget::DrawWidget(Framework & framework, std::unique_ptr<ScreenshotParams> && screenshotParams, QWidget * parent)
|
||||
: TBase(framework, screenshotParams != nullptr, parent)
|
||||
, m_rubberBand(nullptr)
|
||||
, m_emulatingLocation(false)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
m_framework.SetPlacePageListeners([this]() { ShowPlacePage(); },
|
||||
{} /* onClose */, {} /* onUpdate */, {} /*onSwitchFullScreen */);
|
||||
m_framework.SetPlacePageListeners([this]() { ShowPlacePage(); }, {} /* onClose */, {} /* onUpdate */,
|
||||
{} /*onSwitchFullScreen */);
|
||||
|
||||
auto & routingManager = m_framework.GetRoutingManager();
|
||||
|
||||
routingManager.SetRouteBuildingListener(
|
||||
[&routingManager, this](routing::RouterResultCode, storage::CountriesSet const &)
|
||||
{
|
||||
auto & drapeApi = m_framework.GetDrapeApi();
|
||||
|
||||
m_turnsVisualizer.ClearTurns(drapeApi);
|
||||
|
||||
if (RoutingSettings::TurnsEnabled())
|
||||
m_turnsVisualizer.Visualize(routingManager, drapeApi);
|
||||
|
||||
auto const routerType = routingManager.GetLastUsedRouter();
|
||||
if (routerType == routing::RouterType::Pedestrian || routerType == routing::RouterType::Bicycle)
|
||||
{
|
||||
RoutingManager::DistanceAltitude da;
|
||||
if (!routingManager.GetRouteAltitudesAndDistancesM(da))
|
||||
return;
|
||||
|
||||
for (int iter = 0; iter < 2; ++iter)
|
||||
{
|
||||
auto & drapeApi = m_framework.GetDrapeApi();
|
||||
LOG(LINFO, ("Altitudes", iter == 0 ? "before" : "after", "simplify:"));
|
||||
LOG_SHORT(LDEBUG, (da));
|
||||
|
||||
m_turnsVisualizer.ClearTurns(drapeApi);
|
||||
uint32_t totalAscent, totalDescent;
|
||||
da.CalculateAscentDescent(totalAscent, totalDescent);
|
||||
LOG_SHORT(LINFO, ("Ascent:", totalAscent, "Descent:", totalDescent));
|
||||
|
||||
if (RoutingSettings::TurnsEnabled())
|
||||
m_turnsVisualizer.Visualize(routingManager, drapeApi);
|
||||
da.Simplify();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
auto const routerType = routingManager.GetLastUsedRouter();
|
||||
if (routerType == routing::RouterType::Pedestrian || routerType == routing::RouterType::Bicycle)
|
||||
{
|
||||
RoutingManager::DistanceAltitude da;
|
||||
if (!routingManager.GetRouteAltitudesAndDistancesM(da))
|
||||
return;
|
||||
|
||||
for (int iter = 0; iter < 2; ++iter)
|
||||
{
|
||||
LOG(LINFO, ("Altitudes", iter == 0 ? "before" : "after", "simplify:"));
|
||||
LOG_SHORT(LDEBUG, (da));
|
||||
|
||||
uint32_t totalAscent, totalDescent;
|
||||
da.CalculateAscentDescent(totalAscent, totalDescent);
|
||||
LOG_SHORT(LINFO, ("Ascent:", totalAscent, "Descent:", totalDescent));
|
||||
|
||||
da.Simplify();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
routingManager.SetRouteRecommendationListener(
|
||||
[this](RoutingManager::Recommendation r) { OnRouteRecommendation(r); });
|
||||
routingManager.SetRouteRecommendationListener([this](RoutingManager::Recommendation r) { OnRouteRecommendation(r); });
|
||||
|
||||
if (screenshotParams != nullptr)
|
||||
{
|
||||
@@ -209,7 +206,7 @@ void DrawWidget::initializeGL()
|
||||
bool DrawWidget::event(QEvent * event)
|
||||
{
|
||||
#if !defined(OMIM_OS_LINUX)
|
||||
return QOpenGLWidget::event(event);
|
||||
return QOpenGLWidget::event(event);
|
||||
#else
|
||||
// TouchScreen
|
||||
if (auto dfTouchEventType = qtTouchEventTypeToDfTouchEventType(event->type());
|
||||
@@ -231,9 +228,9 @@ bool DrawWidget::event(QEvent * event)
|
||||
touch.m_id = i;
|
||||
touch.m_location = m2::PointD(L2D(it->position().x()), L2D(it->position().y()));
|
||||
if (i == 0)
|
||||
dfTouchEvent.SetFirstTouch(touch);
|
||||
dfTouchEvent.SetFirstTouch(touch);
|
||||
else
|
||||
dfTouchEvent.SetSecondTouch(touch);
|
||||
dfTouchEvent.SetSecondTouch(touch);
|
||||
}
|
||||
m_framework.TouchEvent(dfTouchEvent);
|
||||
return true;
|
||||
@@ -242,7 +239,7 @@ bool DrawWidget::event(QEvent * event)
|
||||
else if (event->type() == QEvent::NativeGesture)
|
||||
{
|
||||
event->accept();
|
||||
auto qNativeGestureEvent = dynamic_cast<QNativeGestureEvent*>(event);
|
||||
auto qNativeGestureEvent = dynamic_cast<QNativeGestureEvent *>(event);
|
||||
if (qNativeGestureEvent->gestureType() == Qt::ZoomNativeGesture)
|
||||
{
|
||||
QPointF const pos = qNativeGestureEvent->position();
|
||||
@@ -314,8 +311,8 @@ void DrawWidget::mouseMoveEvent(QMouseEvent * e)
|
||||
m_rubberBand->setGeometry(QRect(m_rubberBandOrigin, e->pos()).normalized());
|
||||
}
|
||||
|
||||
void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices,
|
||||
bool fromPackedPolygon, bool boundingBox)
|
||||
void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices, bool fromPackedPolygon,
|
||||
bool boundingBox)
|
||||
{
|
||||
auto const getRegions = [&](std::string const & mwmName)
|
||||
{
|
||||
@@ -360,8 +357,8 @@ void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVer
|
||||
for (auto const & region : regions)
|
||||
{
|
||||
auto const r = region.GetRect();
|
||||
boxes.emplace_back(std::vector<m2::PointD>({r.LeftBottom(), r.LeftTop(), r.RightTop(),
|
||||
r.RightBottom(), r.LeftBottom()}));
|
||||
boxes.emplace_back(
|
||||
std::vector<m2::PointD>({r.LeftBottom(), r.LeftTop(), r.RightTop(), r.RightBottom(), r.LeftBottom()}));
|
||||
}
|
||||
|
||||
regions = std::move(boxes);
|
||||
@@ -378,14 +375,9 @@ void DrawWidget::mouseReleaseEvent(QMouseEvent * e)
|
||||
|
||||
QOpenGLWidget::mouseReleaseEvent(e);
|
||||
if (IsLeftButton(e) && !IsAltModifier(e))
|
||||
{
|
||||
m_framework.TouchEvent(GetDfTouchEventFromQMouseEvent(e, df::TouchEvent::TOUCH_UP));
|
||||
}
|
||||
else if (m_selectionMode && IsRightButton(e) &&
|
||||
m_rubberBand != nullptr && m_rubberBand->isVisible())
|
||||
{
|
||||
else if (m_selectionMode && IsRightButton(e) && m_rubberBand != nullptr && m_rubberBand->isVisible())
|
||||
ProcessSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWidget::ProcessSelectionMode()
|
||||
@@ -398,54 +390,39 @@ void DrawWidget::ProcessSelectionMode()
|
||||
|
||||
switch (*m_selectionMode)
|
||||
{
|
||||
case SelectionMode::Features:
|
||||
m_framework.VisualizeRoadsInRect(rect);
|
||||
break;
|
||||
case SelectionMode::Features: m_framework.VisualizeRoadsInRect(rect); break;
|
||||
|
||||
case SelectionMode::CityBoundaries:
|
||||
m_framework.VisualizeCityBoundariesInRect(rect);
|
||||
break;
|
||||
case SelectionMode::CityBoundaries: m_framework.VisualizeCityBoundariesInRect(rect); break;
|
||||
|
||||
case SelectionMode::CityRoads:
|
||||
m_framework.VisualizeCityRoadsInRect(rect);
|
||||
break;
|
||||
case SelectionMode::CityRoads: m_framework.VisualizeCityRoadsInRect(rect); break;
|
||||
|
||||
case SelectionMode::CrossMwmSegments:
|
||||
m_framework.VisualizeCrossMwmTransitionsInRect(rect);
|
||||
break;
|
||||
case SelectionMode::CrossMwmSegments: m_framework.VisualizeCrossMwmTransitionsInRect(rect); break;
|
||||
|
||||
case SelectionMode::MwmsBordersByPolyFiles:
|
||||
VisualizeMwmsBordersInRect(rect, false /* withVertices */, false /* fromPackedPolygon */,
|
||||
false /* boundingBox */);
|
||||
VisualizeMwmsBordersInRect(rect, false /* withVertices */, false /* fromPackedPolygon */, false /* boundingBox */);
|
||||
break;
|
||||
|
||||
case SelectionMode::MwmsBordersWithVerticesByPolyFiles:
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, false /* fromPackedPolygon */,
|
||||
false /* boundingBox */);
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, false /* fromPackedPolygon */, false /* boundingBox */);
|
||||
break;
|
||||
|
||||
case SelectionMode::MwmsBordersByPackedPolygon:
|
||||
VisualizeMwmsBordersInRect(rect, false /* withVertices */, true /* fromPackedPolygon */,
|
||||
false /* boundingBox */);
|
||||
VisualizeMwmsBordersInRect(rect, false /* withVertices */, true /* fromPackedPolygon */, false /* boundingBox */);
|
||||
break;
|
||||
|
||||
case SelectionMode::MwmsBordersWithVerticesByPackedPolygon:
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, true /* fromPackedPolygon */,
|
||||
false /* boundingBox */);
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, true /* fromPackedPolygon */, false /* boundingBox */);
|
||||
break;
|
||||
|
||||
case SelectionMode::BoundingBoxByPolyFiles:
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, false /* fromPackedPolygon */,
|
||||
true /* boundingBox */);
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, false /* fromPackedPolygon */, true /* boundingBox */);
|
||||
break;
|
||||
|
||||
case SelectionMode::BoundingBoxByPackedPolygon:
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, true /* fromPackedPolygon */,
|
||||
true /* boundingBox */);
|
||||
VisualizeMwmsBordersInRect(rect, true /* withVertices */, true /* fromPackedPolygon */, true /* boundingBox */);
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE();
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
m_rubberBand->hide();
|
||||
@@ -456,8 +433,7 @@ void DrawWidget::keyPressEvent(QKeyEvent * e)
|
||||
if (m_screenshotMode)
|
||||
return;
|
||||
|
||||
if (IsLeftButton(QGuiApplication::mouseButtons()) &&
|
||||
e->key() == Qt::Key_Control)
|
||||
if (IsLeftButton(QGuiApplication::mouseButtons()) && e->key() == Qt::Key_Control)
|
||||
{
|
||||
df::TouchEvent event;
|
||||
event.SetTouchType(df::TouchEvent::TOUCH_DOWN);
|
||||
@@ -476,8 +452,7 @@ void DrawWidget::keyReleaseEvent(QKeyEvent * e)
|
||||
if (m_screenshotMode)
|
||||
return;
|
||||
|
||||
if (IsLeftButton(QGuiApplication::mouseButtons()) &&
|
||||
e->key() == Qt::Key_Control)
|
||||
if (IsLeftButton(QGuiApplication::mouseButtons()) && e->key() == Qt::Key_Control)
|
||||
{
|
||||
df::TouchEvent event;
|
||||
event.SetTouchType(df::TouchEvent::TOUCH_UP);
|
||||
@@ -500,8 +475,7 @@ std::string DrawWidget::GetDistance(search::Result const & res) const
|
||||
{
|
||||
auto const ll = mercator::ToLatLon(*position);
|
||||
double dummy;
|
||||
(void)m_framework.GetDistanceAndAzimut(res.GetFeatureCenter(), ll.m_lat, ll.m_lon, -1.0, dist,
|
||||
dummy);
|
||||
(void)m_framework.GetDistanceAndAzimut(res.GetFeatureCenter(), ll.m_lat, ll.m_lon, -1.0, dist, dummy);
|
||||
}
|
||||
return dist.ToString();
|
||||
}
|
||||
@@ -560,21 +534,19 @@ void DrawWidget::SubmitFakeLocationPoint(m2::PointD const & pt)
|
||||
routingManager.GetRouteFollowingInfo(loc);
|
||||
if (routingManager.GetCurrentRouterType() == routing::RouterType::Pedestrian)
|
||||
{
|
||||
LOG(LDEBUG, ("Distance:", loc.m_distToTarget, "Time:", loc.m_time,
|
||||
DebugPrint(loc.m_pedestrianTurn),
|
||||
"in", loc.m_distToTurn.ToString(),
|
||||
loc.m_nextStreetName.empty() ? "" : "to " + loc.m_nextStreetName ));
|
||||
LOG(LDEBUG, ("Distance:", loc.m_distToTarget, "Time:", loc.m_time, DebugPrint(loc.m_pedestrianTurn), "in",
|
||||
loc.m_distToTurn.ToString(), loc.m_nextStreetName.empty() ? "" : "to " + loc.m_nextStreetName));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string speed;
|
||||
if (loc.m_speedLimitMps > 0)
|
||||
speed = "SpeedLimit: " + measurement_utils::FormatSpeedNumeric(loc.m_speedLimitMps, measurement_utils::Units::Metric);
|
||||
speed = "SpeedLimit: " +
|
||||
measurement_utils::FormatSpeedNumeric(loc.m_speedLimitMps, measurement_utils::Units::Metric);
|
||||
|
||||
LOG(LDEBUG, ("Distance:", loc.m_distToTarget, "Time:", loc.m_time, speed,
|
||||
GetTurnString(loc.m_turn), (loc.m_exitNum != 0 ? ":" + std::to_string(loc.m_exitNum) : ""),
|
||||
"in", loc.m_distToTurn.ToString(),
|
||||
loc.m_nextStreetName.empty() ? "" : "to " + loc.m_nextStreetName ));
|
||||
LOG(LDEBUG, ("Distance:", loc.m_distToTarget, "Time:", loc.m_time, speed, GetTurnString(loc.m_turn),
|
||||
(loc.m_exitNum != 0 ? ":" + std::to_string(loc.m_exitNum) : ""), "in", loc.m_distToTurn.ToString(),
|
||||
loc.m_nextStreetName.empty() ? "" : "to " + loc.m_nextStreetName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -608,7 +580,7 @@ void DrawWidget::SubmitRoutingPoint(m2::PointD const & pt, bool pointIsMercator)
|
||||
point.m_isMyPosition = false;
|
||||
if (!isIntermediate)
|
||||
point.m_position = GetCoordsFromSettingsIfExists(false /* start */, pt, pointIsMercator);
|
||||
else
|
||||
else
|
||||
point.m_position = pointIsMercator ? pt : P2G(pt);
|
||||
|
||||
routingManager.AddRoutePoint(std::move(point));
|
||||
@@ -791,7 +763,7 @@ m2::PointD DrawWidget::P2G(m2::PointD const & pt) const
|
||||
return m_framework.P3dtoG(pt);
|
||||
}
|
||||
|
||||
m2::PointD DrawWidget::GetCoordsFromSettingsIfExists(bool start, m2::PointD const & pt, bool pointIsMercator) const
|
||||
m2::PointD DrawWidget::GetCoordsFromSettingsIfExists(bool start, m2::PointD const & pt, bool pointIsMercator) const
|
||||
{
|
||||
if (auto optional = RoutingSettings::GetCoords(start))
|
||||
return mercator::FromLatLon(*optional);
|
||||
|
||||
@@ -42,8 +42,7 @@ public Q_SLOTS:
|
||||
void ChoosePositionModeDisable();
|
||||
|
||||
public:
|
||||
DrawWidget(Framework & framework, std::unique_ptr<ScreenshotParams> && screenshotParams,
|
||||
QWidget * parent);
|
||||
DrawWidget(Framework & framework, std::unique_ptr<ScreenshotParams> && screenshotParams, QWidget * parent);
|
||||
~DrawWidget() override;
|
||||
|
||||
std::string GetDistance(search::Result const & res) const;
|
||||
@@ -97,8 +96,7 @@ private:
|
||||
void SubmitBookmark(m2::PointD const & pt);
|
||||
void ShowPlacePage();
|
||||
|
||||
void VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices,
|
||||
bool fromPackedPolygon, bool boundingBox);
|
||||
void VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices, bool fromPackedPolygon, bool boundingBox);
|
||||
|
||||
m2::PointD P2G(m2::PointD const & pt) const;
|
||||
m2::PointD GetCoordsFromSettingsIfExists(bool start, m2::PointD const & pt, bool pointIsMercator) const;
|
||||
|
||||
@@ -22,8 +22,7 @@ constexpr char const * kHouseNumberObjectName = "addr:housenumber";
|
||||
constexpr char const * kPostcodeObjectName = "addr:postcode";
|
||||
constexpr char const * kInternetObjectName = "internet_access";
|
||||
|
||||
EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo)
|
||||
: QDialog(parent), m_feature(emo)
|
||||
EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo) : QDialog(parent), m_feature(emo)
|
||||
{
|
||||
QGridLayout * grid = new QGridLayout();
|
||||
int row = 0;
|
||||
@@ -33,8 +32,8 @@ EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo)
|
||||
ms::LatLon const ll = emo.GetLatLon();
|
||||
grid->addWidget(new QLabel("Latitude/Longitude:"), row, 0);
|
||||
QHBoxLayout * coords = new QHBoxLayout();
|
||||
coords->addWidget(new QLabel(QString::fromStdString(strings::to_string_dac(ll.m_lat, 7) + " " +
|
||||
strings::to_string_dac(ll.m_lon, 7))));
|
||||
coords->addWidget(new QLabel(
|
||||
QString::fromStdString(strings::to_string_dac(ll.m_lat, 7) + " " + strings::to_string_dac(ll.m_lon, 7))));
|
||||
grid->addLayout(coords, row++, 1);
|
||||
}
|
||||
|
||||
@@ -111,30 +110,23 @@ EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo)
|
||||
switch (prop)
|
||||
{
|
||||
case PropID::FMD_INTERNET:
|
||||
{
|
||||
grid->addWidget(new QLabel(kInternetObjectName), row, 0);
|
||||
QComboBox * cmb = new QComboBox();
|
||||
std::string const values[] = {DebugPrint(feature::Internet::Unknown),
|
||||
DebugPrint(feature::Internet::Wlan),
|
||||
DebugPrint(feature::Internet::Wired),
|
||||
DebugPrint(feature::Internet::Terminal),
|
||||
DebugPrint(feature::Internet::Yes),
|
||||
DebugPrint(feature::Internet::No)};
|
||||
for (auto const & v : values)
|
||||
cmb->addItem(v.c_str());
|
||||
cmb->setCurrentText(DebugPrint(emo.GetInternet()).c_str());
|
||||
cmb->setObjectName(kInternetObjectName);
|
||||
grid->addWidget(cmb, row++, 1);
|
||||
}
|
||||
{
|
||||
grid->addWidget(new QLabel(kInternetObjectName), row, 0);
|
||||
QComboBox * cmb = new QComboBox();
|
||||
std::string const values[] = {DebugPrint(feature::Internet::Unknown), DebugPrint(feature::Internet::Wlan),
|
||||
DebugPrint(feature::Internet::Wired), DebugPrint(feature::Internet::Terminal),
|
||||
DebugPrint(feature::Internet::Yes), DebugPrint(feature::Internet::No)};
|
||||
for (auto const & v : values)
|
||||
cmb->addItem(v.c_str());
|
||||
cmb->setCurrentText(DebugPrint(emo.GetInternet()).c_str());
|
||||
cmb->setObjectName(kInternetObjectName);
|
||||
grid->addWidget(cmb, row++, 1);
|
||||
}
|
||||
continue;
|
||||
case PropID::FMD_CUISINE:
|
||||
v = strings::JoinStrings(emo.GetLocalizedCuisines(), ", ");
|
||||
break;
|
||||
case PropID::FMD_CUISINE: v = strings::JoinStrings(emo.GetLocalizedCuisines(), ", "); break;
|
||||
case PropID::FMD_POSTCODE: // already set above
|
||||
continue;
|
||||
default:
|
||||
v = emo.GetMetadata(prop);
|
||||
break;
|
||||
default: v = emo.GetMetadata(prop); break;
|
||||
}
|
||||
|
||||
QString const fieldName = QString::fromStdString(DebugPrint(prop));
|
||||
@@ -146,8 +138,7 @@ EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo)
|
||||
|
||||
// Dialog buttons.
|
||||
{
|
||||
QDialogButtonBox * buttonBox =
|
||||
new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save);
|
||||
QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &EditorDialog::OnSave);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
// Delete button should send custom int return value from dialog.
|
||||
@@ -170,8 +161,8 @@ void EditorDialog::OnSave()
|
||||
if (m_feature.IsNameEditable())
|
||||
{
|
||||
StringUtf8Multilang names;
|
||||
for (int8_t langCode = StringUtf8Multilang::kDefaultCode;
|
||||
langCode < StringUtf8Multilang::kMaxSupportedLanguages; ++langCode)
|
||||
for (int8_t langCode = StringUtf8Multilang::kDefaultCode; langCode < StringUtf8Multilang::kMaxSupportedLanguages;
|
||||
++langCode)
|
||||
{
|
||||
std::string_view const lang = StringUtf8Multilang::GetLangByCode(langCode);
|
||||
QLineEdit * le = findChild<QLineEdit *>(QString::fromUtf8(lang.data(), lang.size()));
|
||||
@@ -215,7 +206,7 @@ void EditorDialog::OnSave()
|
||||
m_feature.SetInternet(feature::InternetFromString(cmb->currentText().toStdString()));
|
||||
continue;
|
||||
}
|
||||
if (prop == PropID::FMD_POSTCODE) // already set above
|
||||
if (prop == PropID::FMD_POSTCODE) // already set above
|
||||
continue;
|
||||
|
||||
QLineEdit * editor = findChild<QLineEdit *>(QString::fromStdString(DebugPrint(prop)));
|
||||
@@ -225,9 +216,7 @@ void EditorDialog::OnSave()
|
||||
std::string v = editor->text().toStdString();
|
||||
switch (prop)
|
||||
{
|
||||
case PropID::FMD_CUISINE:
|
||||
m_feature.SetCuisines(strings::Tokenize(v, ";"));
|
||||
break;
|
||||
case PropID::FMD_CUISINE: m_feature.SetCuisines(strings::Tokenize(v, ";")); break;
|
||||
default:
|
||||
if (osm::EditableMapObject::IsValidMetadata(prop, v))
|
||||
m_feature.SetMetadata(prop, std::move(v));
|
||||
|
||||
@@ -10,6 +10,7 @@ class EditableMapObject;
|
||||
class EditorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EditorDialog(QWidget * parent, osm::EditableMapObject & emo);
|
||||
private slots:
|
||||
|
||||
@@ -3,63 +3,61 @@
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtWidgets/QTextBrowser>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QTextBrowser>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
namespace qt
|
||||
{
|
||||
InfoDialog::InfoDialog(QString const & title, QString const & text, QWidget * parent,
|
||||
QStringList const & buttons)
|
||||
InfoDialog::InfoDialog(QString const & title, QString const & text, QWidget * parent, QStringList const & buttons)
|
||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
|
||||
{
|
||||
QIcon icon(":/ui/logo.png");
|
||||
setWindowIcon(icon);
|
||||
setWindowTitle(title);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
|
||||
QVBoxLayout * vBox = new QVBoxLayout();
|
||||
QTextBrowser * browser = new QTextBrowser();
|
||||
browser->setReadOnly(true);
|
||||
browser->setOpenLinks(true);
|
||||
browser->setOpenExternalLinks(true);
|
||||
browser->setText(text);
|
||||
vBox->addWidget(browser);
|
||||
|
||||
// this horizontal layout is for buttons
|
||||
QHBoxLayout * hBox = new QHBoxLayout();
|
||||
hBox->addSpacing(static_cast<int>(browser->width() / 4 * (3.5 - buttons.size())));
|
||||
for (int i = 0; i < buttons.size(); ++i)
|
||||
{
|
||||
QIcon icon(":/ui/logo.png");
|
||||
setWindowIcon(icon);
|
||||
setWindowTitle(title);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
|
||||
QVBoxLayout * vBox = new QVBoxLayout();
|
||||
QTextBrowser * browser = new QTextBrowser();
|
||||
browser->setReadOnly(true);
|
||||
browser->setOpenLinks(true);
|
||||
browser->setOpenExternalLinks(true);
|
||||
browser->setText(text);
|
||||
vBox->addWidget(browser);
|
||||
|
||||
// this horizontal layout is for buttons
|
||||
QHBoxLayout * hBox = new QHBoxLayout();
|
||||
hBox->addSpacing(static_cast<int>(browser->width() / 4 * (3.5 - buttons.size())));
|
||||
for (int i = 0; i < buttons.size(); ++i)
|
||||
QPushButton * button = new QPushButton(buttons[i], this);
|
||||
switch (i)
|
||||
{
|
||||
QPushButton * button = new QPushButton(buttons[i], this);
|
||||
switch (i)
|
||||
{
|
||||
case 0: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick1); break;
|
||||
case 1: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick2); break;
|
||||
case 2: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick3); break;
|
||||
default:
|
||||
ASSERT(false, ("Only 3 buttons are currently supported in info dialog"));
|
||||
}
|
||||
hBox->addWidget(button);
|
||||
case 0: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick1); break;
|
||||
case 1: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick2); break;
|
||||
case 2: connect(button, &QAbstractButton::clicked, this, &InfoDialog::OnButtonClick3); break;
|
||||
default: ASSERT(false, ("Only 3 buttons are currently supported in info dialog"));
|
||||
}
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
setLayout(vBox);
|
||||
hBox->addWidget(button);
|
||||
}
|
||||
|
||||
void InfoDialog::OnButtonClick1()
|
||||
{
|
||||
done(1);
|
||||
}
|
||||
void InfoDialog::OnButtonClick2()
|
||||
{
|
||||
done(2);
|
||||
}
|
||||
void InfoDialog::OnButtonClick3()
|
||||
{
|
||||
done(3);
|
||||
}
|
||||
vBox->addLayout(hBox);
|
||||
setLayout(vBox);
|
||||
}
|
||||
|
||||
void InfoDialog::OnButtonClick1()
|
||||
{
|
||||
done(1);
|
||||
}
|
||||
void InfoDialog::OnButtonClick2()
|
||||
{
|
||||
done(2);
|
||||
}
|
||||
void InfoDialog::OnButtonClick3()
|
||||
{
|
||||
done(3);
|
||||
}
|
||||
} // namespace qt
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
|
||||
namespace qt
|
||||
{
|
||||
/// Simple information dialog with scrollable html content
|
||||
/// @note exec() returns 0 if dialog was closed or [1..buttons_count] for any button pressed
|
||||
class InfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
/// Simple information dialog with scrollable html content
|
||||
/// @note exec() returns 0 if dialog was closed or [1..buttons_count] for any button pressed
|
||||
class InfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InfoDialog(QString const & title, QString const & text,
|
||||
QWidget * parent, QStringList const & buttons = QStringList());
|
||||
public Q_SLOTS:
|
||||
void OnButtonClick1();
|
||||
void OnButtonClick2();
|
||||
void OnButtonClick3();
|
||||
};
|
||||
}
|
||||
public:
|
||||
explicit InfoDialog(QString const & title, QString const & text, QWidget * parent,
|
||||
QStringList const & buttons = QStringList());
|
||||
public Q_SLOTS:
|
||||
void OnButtonClick1();
|
||||
void OnButtonClick2();
|
||||
void OnButtonClick3();
|
||||
};
|
||||
} // namespace qt
|
||||
|
||||
80
qt/main.cpp
80
qt/main.cpp
@@ -17,23 +17,26 @@
|
||||
#include "build_style/build_style.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
|
||||
DEFINE_string(data_path, "", "Path to data directory.");
|
||||
DEFINE_string(log_abort_level, base::ToString(base::GetDefaultLogAbortLevel()), "Log messages severity that causes termination.");
|
||||
DEFINE_string(log_abort_level, base::ToString(base::GetDefaultLogAbortLevel()),
|
||||
"Log messages severity that causes termination.");
|
||||
DEFINE_string(resources_path, "", "Path to resources directory.");
|
||||
DEFINE_string(kml_path, "", "Activates screenshot mode. Path to a kml file or a directory with kml files to take screenshots.");
|
||||
DEFINE_string(points, "", "Activates screenshot mode. Points on the map and zoom level "
|
||||
DEFINE_string(kml_path, "",
|
||||
"Activates screenshot mode. Path to a kml file or a directory with kml files to take screenshots.");
|
||||
DEFINE_string(points, "",
|
||||
"Activates screenshot mode. Points on the map and zoom level "
|
||||
"[1..18] in format \"lat,lon,zoom[;lat,lon,zoom]\" or path to a file with points in "
|
||||
"the same format. Each point and zoom define a place on the map to take screenshot.");
|
||||
DEFINE_string(rects, "", "Activates screenshot mode. Rects on the map in format"
|
||||
DEFINE_string(rects, "",
|
||||
"Activates screenshot mode. Rects on the map in format"
|
||||
"\"lat_leftBottom,lon_leftBottom,lat_rightTop,lon_rightTop"
|
||||
"[;lat_leftBottom,lon_leftBottom,lat_rightTop,lon_rightTop]\" or path to a file with "
|
||||
"rects in the same format. Each rect defines a place on the map to take screenshot.");
|
||||
@@ -41,7 +44,9 @@ DEFINE_string(dst_path, "", "Path to a directory to save screenshots.");
|
||||
DEFINE_string(lang, "", "Device language.");
|
||||
DEFINE_int32(width, 0, "Screenshot width.");
|
||||
DEFINE_int32(height, 0, "Screenshot height.");
|
||||
DEFINE_double(dpi_scale, 0.0, "Screenshot dpi scale (mdpi = 1.0, hdpi = 1.5, xhdpiScale = 2.0, 6plus = 2.4, xxhdpi = 3.0, xxxhdpi = 3.5).");
|
||||
DEFINE_double(
|
||||
dpi_scale, 0.0,
|
||||
"Screenshot dpi scale (mdpi = 1.0, hdpi = 1.5, xhdpiScale = 2.0, 6plus = 2.4, xxhdpi = 3.0, xxxhdpi = 3.5).");
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -49,7 +54,7 @@ bool ValidateLogAbortLevel(char const * flagname, std::string const & value)
|
||||
{
|
||||
if (auto level = base::FromString(value); !level)
|
||||
{
|
||||
std::cerr << "Invalid value for --" << flagname << ": "<< value << ", must be one of: ";
|
||||
std::cerr << "Invalid value for --" << flagname << ": " << value << ", must be one of: ";
|
||||
auto const & names = base::GetLogLevelNames();
|
||||
for (size_t i = 0; i < names.size(); ++i)
|
||||
{
|
||||
@@ -74,29 +79,27 @@ public:
|
||||
// useful when using memory and resource leak utilites
|
||||
// google::protobuf::ShutdownProtobufLibrary();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#if defined(OMIM_OS_WINDOWS) //&& defined(PROFILER_COMMON)
|
||||
class InitializeFinalize : public FinalizeBase
|
||||
#if defined(OMIM_OS_WINDOWS) //&& defined(PROFILER_COMMON)
|
||||
class InitializeFinalize : public FinalizeBase
|
||||
{
|
||||
FILE * m_errFile;
|
||||
base::ScopedLogLevelChanger const m_debugLog;
|
||||
|
||||
public:
|
||||
InitializeFinalize() : m_debugLog(LDEBUG)
|
||||
{
|
||||
FILE * m_errFile;
|
||||
base::ScopedLogLevelChanger const m_debugLog;
|
||||
public:
|
||||
InitializeFinalize() : m_debugLog(LDEBUG)
|
||||
{
|
||||
// App runs without error console under win32.
|
||||
m_errFile = ::freopen(".\\mapsme.log", "w", stderr);
|
||||
// App runs without error console under win32.
|
||||
m_errFile = ::freopen(".\\mapsme.log", "w", stderr);
|
||||
|
||||
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF);
|
||||
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
}
|
||||
~InitializeFinalize()
|
||||
{
|
||||
::fclose(m_errFile);
|
||||
}
|
||||
};
|
||||
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF);
|
||||
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
}
|
||||
~InitializeFinalize() { ::fclose(m_errFile); }
|
||||
};
|
||||
#else
|
||||
typedef FinalizeBase InitializeFinalize;
|
||||
typedef FinalizeBase InitializeFinalize;
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
@@ -111,7 +114,7 @@ int main(int argc, char * argv[])
|
||||
Platform & platform = GetPlatform();
|
||||
|
||||
LOG(LINFO, ("CoMaps", platform.Version(), "built with QT:", QT_VERSION_STR, "runtime QT:", qVersion(),
|
||||
"detected CPU cores:", platform.CpuCores()));
|
||||
"detected CPU cores:", platform.CpuCores()));
|
||||
|
||||
gflags::SetUsageMessage("Desktop application.");
|
||||
gflags::SetVersionString(platform.Version());
|
||||
@@ -136,14 +139,12 @@ int main(int argc, char * argv[])
|
||||
app.setDesktopFileName("app.comaps.comaps");
|
||||
platform.SetupMeasurementSystem();
|
||||
|
||||
|
||||
#ifdef BUILD_DESIGNER
|
||||
QApplication::setApplicationName("CoMaps Designer");
|
||||
QApplication::setApplicationName("CoMaps Designer");
|
||||
#else
|
||||
QApplication::setApplicationName("CoMaps");
|
||||
QApplication::setApplicationName("CoMaps");
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
static bool constexpr developerMode = true;
|
||||
#else
|
||||
@@ -169,7 +170,7 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
|
||||
int returnCode = -1;
|
||||
if (eulaAccepted) // User has accepted EULA
|
||||
if (eulaAccepted) // User has accepted EULA
|
||||
{
|
||||
std::unique_ptr<qt::ScreenshotParams> screenshotParams;
|
||||
|
||||
@@ -211,7 +212,7 @@ int main(int argc, char * argv[])
|
||||
#ifdef BUILD_DESIGNER
|
||||
QString mapcssFilePath;
|
||||
if (argc >= 2 && platform.IsFileExistsByFullPath(argv[1]))
|
||||
mapcssFilePath = argv[1];
|
||||
mapcssFilePath = argv[1];
|
||||
if (0 == mapcssFilePath.length())
|
||||
mapcssFilePath = QFileDialog::getOpenFileName(nullptr, "Open style.mapcss file", "~/", "MapCSS Files (*.mapcss)");
|
||||
if (mapcssFilePath.isEmpty())
|
||||
@@ -232,14 +233,15 @@ int main(int argc, char * argv[])
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
#endif // BUILD_DESIGNER
|
||||
#endif // BUILD_DESIGNER
|
||||
|
||||
Framework framework(frameworkParams);
|
||||
qt::MainWindow w(framework, std::move(screenshotParams), QApplication::primaryScreen()->geometry()
|
||||
#ifdef BUILD_DESIGNER
|
||||
, mapcssFilePath
|
||||
#endif // BUILD_DESIGNER
|
||||
);
|
||||
,
|
||||
mapcssFilePath
|
||||
#endif // BUILD_DESIGNER
|
||||
);
|
||||
w.show();
|
||||
returnCode = QApplication::exec();
|
||||
}
|
||||
@@ -261,7 +263,7 @@ int main(int argc, char * argv[])
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
#endif // BUILD_DESIGNER
|
||||
#endif // BUILD_DESIGNER
|
||||
|
||||
LOG_SHORT(LINFO, ("Finished with code", returnCode));
|
||||
return returnCode;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "qt/mainwindow.hpp"
|
||||
#include "qt/about.hpp"
|
||||
#include "qt/bookmark_dialog.hpp"
|
||||
#include "qt/draw_widget.hpp"
|
||||
#include "qt/mainwindow.hpp"
|
||||
#include "qt/mwms_borders_selection.hpp"
|
||||
#include "qt/osm_auth_dialog.hpp"
|
||||
#include "qt/popup_menu_holder.hpp"
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "qt/screenshoter.hpp"
|
||||
#include "qt/search_panel.hpp"
|
||||
|
||||
#include "platform/settings.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#ifdef BUILD_DESIGNER
|
||||
#include "build_style/build_common.h"
|
||||
#include "build_style/build_phone_pack.h"
|
||||
#include "build_style/build_style.h"
|
||||
#include "build_style/build_statistics.h"
|
||||
#include "build_style/build_style.h"
|
||||
#include "build_style/run_tests.h"
|
||||
|
||||
#include "drape_frontend/debug_rect_renderer.hpp"
|
||||
#endif // BUILD_DESIGNER
|
||||
#endif // BUILD_DESIGNER
|
||||
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtWidgets/QDockWidget>
|
||||
@@ -46,14 +46,14 @@
|
||||
#include <QtWidgets/QToolBar>
|
||||
|
||||
#ifdef OMIM_OS_WINDOWS
|
||||
#define IDM_ABOUT_DIALOG 1001
|
||||
#define IDM_PREFERENCES_DIALOG 1002
|
||||
#define IDM_ABOUT_DIALOG 1001
|
||||
#define IDM_PREFERENCES_DIALOG 1002
|
||||
#endif
|
||||
|
||||
#ifndef NO_DOWNLOADER
|
||||
#include "qt/update_dialog.hpp"
|
||||
#include "qt/info_dialog.hpp"
|
||||
#endif // NO_DOWNLOADER
|
||||
#include "qt/update_dialog.hpp"
|
||||
#endif // NO_DOWNLOADER
|
||||
|
||||
namespace qt
|
||||
{
|
||||
@@ -70,7 +70,7 @@ void FormatMapSize(uint64_t sizeInBytes, std::string & units, size_t & sizeToDow
|
||||
}
|
||||
else if (sizeInBytes > kbInBytes)
|
||||
{
|
||||
sizeToDownload = (sizeInBytes + kbInBytes -1) / kbInBytes;
|
||||
sizeToDownload = (sizeInBytes + kbInBytes - 1) / kbInBytes;
|
||||
units = "KB";
|
||||
}
|
||||
else
|
||||
@@ -80,7 +80,8 @@ void FormatMapSize(uint64_t sizeInBytes, std::string & units, size_t & sizeToDow
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> T * CreateBlackControl(QString const & name)
|
||||
template <class T>
|
||||
T * CreateBlackControl(QString const & name)
|
||||
{
|
||||
T * p = new T(name);
|
||||
p->setStyleSheet("color: black;");
|
||||
@@ -92,11 +93,11 @@ template <class T> T * CreateBlackControl(QString const & name)
|
||||
// Defined in osm_auth_dialog.cpp.
|
||||
extern char const * kOauthTokenSetting;
|
||||
|
||||
MainWindow::MainWindow(Framework & framework,
|
||||
std::unique_ptr<ScreenshotParams> && screenshotParams,
|
||||
MainWindow::MainWindow(Framework & framework, std::unique_ptr<ScreenshotParams> && screenshotParams,
|
||||
QRect const & screenGeometry
|
||||
#ifdef BUILD_DESIGNER
|
||||
, QString const & mapcssFilePath
|
||||
,
|
||||
QString const & mapcssFilePath
|
||||
#endif
|
||||
)
|
||||
: m_locationService(CreateDesktopLocationService(*this))
|
||||
@@ -200,8 +201,7 @@ MainWindow::MainWindow(Framework & framework,
|
||||
|
||||
if (!text.empty())
|
||||
{
|
||||
InfoDialog welcomeDlg(QString("Welcome to ") + caption, text.c_str(),
|
||||
this, QStringList(tr("Download Maps")));
|
||||
InfoDialog welcomeDlg(QString("Welcome to ") + caption, text.c_str(), this, QStringList(tr("Download Maps")));
|
||||
if (welcomeDlg.exec() == QDialog::Rejected)
|
||||
bShowUpdateDialog = false;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ MainWindow::MainWindow(Framework & framework,
|
||||
if (bShowUpdateDialog)
|
||||
ShowUpdateDialog();
|
||||
}
|
||||
#endif // NO_DOWNLOADER
|
||||
#endif // NO_DOWNLOADER
|
||||
|
||||
m_pDrawWidget->UpdateAfterSettingsChanged();
|
||||
|
||||
@@ -262,11 +262,9 @@ void MainWindow::CreateNavigationBar()
|
||||
m_pDrawWidget->BindHotkeys(*this);
|
||||
|
||||
// Add navigation hot keys.
|
||||
qt::common::Hotkey const hotkeys[] = {
|
||||
{ Qt::Key_A, SLOT(ShowAll()) },
|
||||
// Use CMD+n (New Item hotkey) to activate Create Feature mode.
|
||||
{ Qt::Key_Escape, SLOT(ChoosePositionModeDisable()) }
|
||||
};
|
||||
qt::common::Hotkey const hotkeys[] = {{Qt::Key_A, SLOT(ShowAll())},
|
||||
// Use CMD+n (New Item hotkey) to activate Create Feature mode.
|
||||
{Qt::Key_Escape, SLOT(ChoosePositionModeDisable())}};
|
||||
|
||||
for (auto const & hotkey : hotkeys)
|
||||
{
|
||||
@@ -304,8 +302,9 @@ void MainWindow::CreateNavigationBar()
|
||||
|
||||
pToolBar->addSeparator();
|
||||
|
||||
pToolBar->addAction(QIcon(":/navig64/bookmark.png"), tr("Show bookmarks and tracks; use ALT + RMB to add a bookmark"),
|
||||
this, SLOT(OnBookmarksAction()));
|
||||
pToolBar->addAction(QIcon(":/navig64/bookmark.png"),
|
||||
tr("Show bookmarks and tracks; use ALT + RMB to add a bookmark"), this,
|
||||
SLOT(OnBookmarksAction()));
|
||||
pToolBar->addSeparator();
|
||||
|
||||
#ifndef BUILD_DESIGNER
|
||||
@@ -324,15 +323,17 @@ void MainWindow::CreateNavigationBar()
|
||||
pToolBar->addWidget(toolBtn);
|
||||
m_routing->setCurrent(m_pDrawWidget->GetRoutePointAddMode());
|
||||
|
||||
QAction * act = pToolBar->addAction(QIcon(":/navig64/routing.png"), tr("Follow route"), this, SLOT(OnFollowRoute()));
|
||||
QAction * act =
|
||||
pToolBar->addAction(QIcon(":/navig64/routing.png"), tr("Follow route"), this, SLOT(OnFollowRoute()));
|
||||
act->setToolTip(tr("Build route and use ALT + LMB to emulate current position"));
|
||||
pToolBar->addAction(QIcon(":/navig64/clear-route.png"), tr("Clear route"), this, SLOT(OnClearRoute()));
|
||||
pToolBar->addAction(QIcon(":/navig64/settings-routing.png"), tr("Routing settings"), this, SLOT(OnRoutingSettings()));
|
||||
pToolBar->addAction(QIcon(":/navig64/settings-routing.png"), tr("Routing settings"), this,
|
||||
SLOT(OnRoutingSettings()));
|
||||
|
||||
pToolBar->addSeparator();
|
||||
|
||||
m_pCreateFeatureAction = pToolBar->addAction(QIcon(":/navig64/select.png"), tr("Create Feature"),
|
||||
this, SLOT(OnCreateFeatureClicked()));
|
||||
m_pCreateFeatureAction =
|
||||
pToolBar->addAction(QIcon(":/navig64/select.png"), tr("Create Feature"), this, SLOT(OnCreateFeatureClicked()));
|
||||
m_pCreateFeatureAction->setCheckable(true);
|
||||
m_pCreateFeatureAction->setToolTip(tr("Push to select position, next push to create Feature"));
|
||||
m_pCreateFeatureAction->setShortcut(QKeySequence::New);
|
||||
@@ -350,8 +351,8 @@ void MainWindow::CreateNavigationBar()
|
||||
std::bind(&MainWindow::OnSwitchSelectionMode, this, SelectionMode::CityRoads), true);
|
||||
m_selection->addAction(QIcon(":/navig64/test.png"), tr("Cross MWM segments selection mode"),
|
||||
std::bind(&MainWindow::OnSwitchSelectionMode, this, SelectionMode::CrossMwmSegments), true);
|
||||
m_selection->addAction(QIcon(":/navig64/borders_selection.png"), tr("MWMs borders selection mode"),
|
||||
this, SLOT(OnSwitchMwmsBordersSelectionMode()), true);
|
||||
m_selection->addAction(QIcon(":/navig64/borders_selection.png"), tr("MWMs borders selection mode"), this,
|
||||
SLOT(OnSwitchMwmsBordersSelectionMode()), true);
|
||||
|
||||
toolBtn = m_selection->create();
|
||||
toolBtn->setToolTip(tr("Select mode and use RMB to define selection box"));
|
||||
@@ -361,11 +362,11 @@ void MainWindow::CreateNavigationBar()
|
||||
|
||||
pToolBar->addSeparator();
|
||||
|
||||
#endif // NOT BUILD_DESIGNER
|
||||
#endif // NOT BUILD_DESIGNER
|
||||
|
||||
// Add search button with "checked" behavior.
|
||||
m_pSearchAction = pToolBar->addAction(QIcon(":/navig64/search.png"), tr("Offline Search"),
|
||||
this, SLOT(OnSearchButtonClicked()));
|
||||
m_pSearchAction =
|
||||
pToolBar->addAction(QIcon(":/navig64/search.png"), tr("Offline Search"), this, SLOT(OnSearchButtonClicked()));
|
||||
m_pSearchAction->setCheckable(true);
|
||||
m_pSearchAction->setShortcut(QKeySequence::Find);
|
||||
|
||||
@@ -378,62 +379,50 @@ void MainWindow::CreateNavigationBar()
|
||||
|
||||
// add my position button with "checked" behavior
|
||||
|
||||
m_pMyPositionAction = pToolBar->addAction(QIcon(":/navig64/location.png"), tr("My Position"), this, SLOT(OnMyPosition()));
|
||||
m_pMyPositionAction =
|
||||
pToolBar->addAction(QIcon(":/navig64/location.png"), tr("My Position"), this, SLOT(OnMyPosition()));
|
||||
m_pMyPositionAction->setCheckable(true);
|
||||
|
||||
#ifdef BUILD_DESIGNER
|
||||
// Add "Build style" button
|
||||
if (!m_mapcssFilePath.isEmpty())
|
||||
{
|
||||
m_pBuildStyleAction = pToolBar->addAction(QIcon(":/navig64/run.png"),
|
||||
tr("Build style"),
|
||||
this,
|
||||
SLOT(OnBuildStyle()));
|
||||
m_pBuildStyleAction =
|
||||
pToolBar->addAction(QIcon(":/navig64/run.png"), tr("Build style"), this, SLOT(OnBuildStyle()));
|
||||
m_pBuildStyleAction->setCheckable(false);
|
||||
m_pBuildStyleAction->setToolTip(tr("Build style"));
|
||||
|
||||
m_pRecalculateGeomIndex = pToolBar->addAction(QIcon(":/navig64/geom.png"),
|
||||
tr("Recalculate geometry index"),
|
||||
this,
|
||||
m_pRecalculateGeomIndex = pToolBar->addAction(QIcon(":/navig64/geom.png"), tr("Recalculate geometry index"), this,
|
||||
SLOT(OnRecalculateGeomIndex()));
|
||||
m_pRecalculateGeomIndex->setCheckable(false);
|
||||
m_pRecalculateGeomIndex->setToolTip(tr("Recalculate geometry index"));
|
||||
}
|
||||
|
||||
// Add "Debug style" button
|
||||
m_pDrawDebugRectAction = pToolBar->addAction(QIcon(":/navig64/bug.png"),
|
||||
tr("Debug style"),
|
||||
this,
|
||||
SLOT(OnDebugStyle()));
|
||||
m_pDrawDebugRectAction =
|
||||
pToolBar->addAction(QIcon(":/navig64/bug.png"), tr("Debug style"), this, SLOT(OnDebugStyle()));
|
||||
m_pDrawDebugRectAction->setCheckable(true);
|
||||
m_pDrawDebugRectAction->setChecked(false);
|
||||
m_pDrawDebugRectAction->setToolTip(tr("Debug style"));
|
||||
m_pDrawWidget->GetFramework().EnableDebugRectRendering(false);
|
||||
|
||||
// Add "Get statistics" button
|
||||
m_pGetStatisticsAction = pToolBar->addAction(QIcon(":/navig64/chart.png"),
|
||||
tr("Get statistics"),
|
||||
this,
|
||||
SLOT(OnGetStatistics()));
|
||||
m_pGetStatisticsAction =
|
||||
pToolBar->addAction(QIcon(":/navig64/chart.png"), tr("Get statistics"), this, SLOT(OnGetStatistics()));
|
||||
m_pGetStatisticsAction->setCheckable(false);
|
||||
m_pGetStatisticsAction->setToolTip(tr("Get statistics"));
|
||||
|
||||
// Add "Run tests" button
|
||||
m_pRunTestsAction = pToolBar->addAction(QIcon(":/navig64/test.png"),
|
||||
tr("Run tests"),
|
||||
this,
|
||||
SLOT(OnRunTests()));
|
||||
m_pRunTestsAction = pToolBar->addAction(QIcon(":/navig64/test.png"), tr("Run tests"), this, SLOT(OnRunTests()));
|
||||
m_pRunTestsAction->setCheckable(false);
|
||||
m_pRunTestsAction->setToolTip(tr("Run tests"));
|
||||
|
||||
// Add "Build phone package" button
|
||||
m_pBuildPhonePackAction = pToolBar->addAction(QIcon(":/navig64/phonepack.png"),
|
||||
tr("Build phone package"),
|
||||
this,
|
||||
m_pBuildPhonePackAction = pToolBar->addAction(QIcon(":/navig64/phonepack.png"), tr("Build phone package"), this,
|
||||
SLOT(OnBuildPhonePackage()));
|
||||
m_pBuildPhonePackAction->setCheckable(false);
|
||||
m_pBuildPhonePackAction->setToolTip(tr("Build phone package"));
|
||||
#endif // BUILD_DESIGNER
|
||||
#endif // BUILD_DESIGNER
|
||||
}
|
||||
|
||||
pToolBar->addSeparator();
|
||||
@@ -442,7 +431,7 @@ void MainWindow::CreateNavigationBar()
|
||||
#ifndef NO_DOWNLOADER
|
||||
pToolBar->addSeparator();
|
||||
pToolBar->addAction(QIcon(":/navig64/download.png"), tr("Download Maps"), this, SLOT(ShowUpdateDialog()));
|
||||
#endif // NO_DOWNLOADER
|
||||
#endif // NO_DOWNLOADER
|
||||
|
||||
if (m_screenshotMode)
|
||||
pToolBar->setVisible(false);
|
||||
@@ -525,18 +514,17 @@ void MainWindow::CreateCountryStatusControls()
|
||||
GetFramework().SetCurrentCountryChangedListener(OnCountryChanged);
|
||||
|
||||
GetFramework().GetStorage().Subscribe(
|
||||
[this, onChanged = std::move(OnCountryChanged)](storage::CountryId const & countryId)
|
||||
{
|
||||
// Storage also calls notifications for parents, but we are interested in leafs only.
|
||||
if (GetFramework().GetStorage().IsLeaf(countryId))
|
||||
onChanged(countryId);
|
||||
},
|
||||
[this](storage::CountryId const & countryId, downloader::Progress const & progress)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "Downloading (" << countryId << ") " << progress.m_bytesDownloaded * 100 / progress.m_bytesTotal << "%";
|
||||
m_downloadingStatusLabel->setText(str.str().c_str());
|
||||
});
|
||||
[this, onChanged = std::move(OnCountryChanged)](storage::CountryId const & countryId)
|
||||
{
|
||||
// Storage also calls notifications for parents, but we are interested in leafs only.
|
||||
if (GetFramework().GetStorage().IsLeaf(countryId))
|
||||
onChanged(countryId);
|
||||
}, [this](storage::CountryId const & countryId, downloader::Progress const & progress)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "Downloading (" << countryId << ") " << progress.m_bytesDownloaded * 100 / progress.m_bytesTotal << "%";
|
||||
m_downloadingStatusLabel->setText(str.str().c_str());
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::OnAbout()
|
||||
@@ -549,20 +537,18 @@ void MainWindow::OnLocationError(location::TLocationError errorCode)
|
||||
{
|
||||
switch (errorCode)
|
||||
{
|
||||
case location::EDenied: [[fallthrough]];
|
||||
case location::EDenied: [[fallthrough]];
|
||||
case location::ETimeout: [[fallthrough]];
|
||||
case location::EUnknown:
|
||||
{
|
||||
if (m_pDrawWidget && m_pMyPositionAction)
|
||||
m_pMyPositionAction->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(false, ("Not handled location notification:", errorCode));
|
||||
{
|
||||
if (m_pDrawWidget && m_pMyPositionAction)
|
||||
m_pMyPositionAction->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
|
||||
default: ASSERT(false, ("Not handled location notification:", errorCode)); break;
|
||||
}
|
||||
|
||||
if (m_pDrawWidget != nullptr)
|
||||
m_pDrawWidget->GetFramework().OnLocationError(errorCode);
|
||||
}
|
||||
@@ -656,9 +642,7 @@ void MainWindow::OnUploadEditsMenuItem()
|
||||
void MainWindow::OnBeforeEngineCreation()
|
||||
{
|
||||
m_pDrawWidget->GetFramework().SetMyPositionModeListener([this](location::EMyPositionMode mode, bool /*routingActive*/)
|
||||
{
|
||||
LocationStateModeChanged(mode);
|
||||
});
|
||||
{ LocationStateModeChanged(mode); });
|
||||
}
|
||||
|
||||
void MainWindow::OnPreferences()
|
||||
@@ -814,7 +798,7 @@ void MainWindow::OnBuildPhonePackage()
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
#endif // BUILD_DESIGNER
|
||||
#endif // BUILD_DESIGNER
|
||||
|
||||
#ifndef NO_DOWNLOADER
|
||||
void MainWindow::ShowUpdateDialog()
|
||||
@@ -824,7 +808,7 @@ void MainWindow::ShowUpdateDialog()
|
||||
m_pDrawWidget->update();
|
||||
}
|
||||
|
||||
#endif // NO_DOWNLOADER
|
||||
#endif // NO_DOWNLOADER
|
||||
|
||||
void MainWindow::CreateSearchBarAndPanel()
|
||||
{
|
||||
@@ -834,8 +818,8 @@ void MainWindow::CreateSearchBarAndPanel()
|
||||
m_Docks[0]->setWidget(panel);
|
||||
}
|
||||
|
||||
void MainWindow::CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString const & name,
|
||||
QKeySequence const & hotkey, char const * slot)
|
||||
void MainWindow::CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString const & name, QKeySequence const & hotkey,
|
||||
char const * slot)
|
||||
{
|
||||
ASSERT_LESS(i, m_Docks.size(), ());
|
||||
m_Docks[i] = new QDockWidget(name, this);
|
||||
|
||||
@@ -12,15 +12,18 @@
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class Framework;
|
||||
class QDockWidget;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
|
||||
namespace search { class Result; }
|
||||
namespace search
|
||||
{
|
||||
class Result;
|
||||
}
|
||||
|
||||
namespace qt
|
||||
{
|
||||
@@ -28,7 +31,9 @@ class DrawWidget;
|
||||
class PopupMenuHolder;
|
||||
struct ScreenshotParams;
|
||||
|
||||
class MainWindow : public QMainWindow, location::LocationObserver
|
||||
class MainWindow
|
||||
: public QMainWindow
|
||||
, location::LocationObserver
|
||||
{
|
||||
DrawWidget * m_pDrawWidget = nullptr;
|
||||
// TODO(mgsergio): Make indexing more informative.
|
||||
@@ -52,7 +57,7 @@ class MainWindow : public QMainWindow, location::LocationObserver
|
||||
{
|
||||
/// @todo Uncomment when we will integrate a traffic provider.
|
||||
// TRAFFIC = 0,
|
||||
TRANSIT = 0, // Metro scheme
|
||||
TRANSIT = 0, // Metro scheme
|
||||
ISOLINES,
|
||||
OUTDOORS,
|
||||
};
|
||||
@@ -68,17 +73,17 @@ class MainWindow : public QMainWindow, location::LocationObserver
|
||||
QAction * m_pGetStatisticsAction = nullptr;
|
||||
QAction * m_pRunTestsAction = nullptr;
|
||||
QAction * m_pBuildPhonePackAction = nullptr;
|
||||
#endif // BUILD_DESIGNER
|
||||
#endif // BUILD_DESIGNER
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(Framework & framework, std::unique_ptr<ScreenshotParams> && screenshotParams,
|
||||
QRect const & screenGeometry
|
||||
MainWindow(Framework & framework, std::unique_ptr<ScreenshotParams> && screenshotParams, QRect const & screenGeometry
|
||||
#ifdef BUILD_DESIGNER
|
||||
, QString const & mapcssFilePath = QString()
|
||||
,
|
||||
QString const & mapcssFilePath = QString()
|
||||
#endif
|
||||
);
|
||||
);
|
||||
|
||||
protected:
|
||||
Framework & GetFramework() const;
|
||||
@@ -87,8 +92,8 @@ protected:
|
||||
void OnLocationUpdated(location::GpsInfo const & info) override;
|
||||
void LocationStateModeChanged(location::EMyPositionMode mode);
|
||||
|
||||
void CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString const & name,
|
||||
QKeySequence const & hotkey, char const * slot);
|
||||
void CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString const & name, QKeySequence const & hotkey,
|
||||
char const * slot);
|
||||
void CreateNavigationBar();
|
||||
void CreateSearchBarAndPanel();
|
||||
void CreateCountryStatusControls();
|
||||
@@ -105,7 +110,7 @@ protected:
|
||||
protected Q_SLOTS:
|
||||
#ifndef NO_DOWNLOADER
|
||||
void ShowUpdateDialog();
|
||||
#endif // NO_DOWNLOADER
|
||||
#endif // NO_DOWNLOADER
|
||||
|
||||
void OnPreferences();
|
||||
void OnAbout();
|
||||
@@ -142,6 +147,6 @@ protected Q_SLOTS:
|
||||
void OnGetStatistics();
|
||||
void OnRunTests();
|
||||
void OnBuildPhonePackage();
|
||||
#endif // BUILD_DESIGNER
|
||||
#endif // BUILD_DESIGNER
|
||||
};
|
||||
} // namespace qt
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
|
||||
#include <QtWidgets/QDialogButtonBox>
|
||||
#include <QtWidgets/QRadioButton>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QSplitter>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
namespace qt
|
||||
{
|
||||
MwmsBordersSelection::MwmsBordersSelection(QWidget * parent)
|
||||
: QDialog(parent)
|
||||
MwmsBordersSelection::MwmsBordersSelection(QWidget * parent) : QDialog(parent)
|
||||
{
|
||||
setWindowTitle("Mwms borders selection settings");
|
||||
|
||||
@@ -26,8 +25,7 @@ QGroupBox * MwmsBordersSelection::CreateButtonBoxGroup()
|
||||
{
|
||||
auto * groupBox = new QGroupBox();
|
||||
|
||||
auto * buttonBox =
|
||||
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
|
||||
auto * buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
|
||||
|
||||
auto * vbox = new QVBoxLayout;
|
||||
|
||||
|
||||
@@ -128,4 +128,4 @@ void OsmAuthDialog::OnAction()
|
||||
SwitchToLogin(this);
|
||||
}
|
||||
}
|
||||
} // namespace qt
|
||||
} // namespace qt
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace qt
|
||||
class OsmAuthDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OsmAuthDialog(QWidget * parent);
|
||||
|
||||
@@ -15,4 +16,4 @@ private slots:
|
||||
void OnAction();
|
||||
};
|
||||
|
||||
} // namespace qt
|
||||
} // namespace qt
|
||||
|
||||
@@ -11,46 +11,32 @@ void addCommonButtons(QDialog * this_, QDialogButtonBox * dbb, bool shouldShowEd
|
||||
QPushButton * fromButton = new QPushButton("Route From");
|
||||
fromButton->setIcon(QIcon(":/navig64/point-start.png"));
|
||||
fromButton->setAutoDefault(false);
|
||||
this_->connect(fromButton, &QAbstractButton::clicked, this_, [this_]
|
||||
{
|
||||
this_->done(RouteFrom);
|
||||
});
|
||||
this_->connect(fromButton, &QAbstractButton::clicked, this_, [this_] { this_->done(RouteFrom); });
|
||||
dbb->addButton(fromButton, QDialogButtonBox::ActionRole);
|
||||
|
||||
QPushButton * addStopButton = new QPushButton("Add Stop");
|
||||
addStopButton->setIcon(QIcon(":/navig64/point-intermediate.png"));
|
||||
addStopButton->setAutoDefault(false);
|
||||
this_->connect(addStopButton, &QAbstractButton::clicked, this_, [this_]
|
||||
{
|
||||
this_->done(AddStop);
|
||||
});
|
||||
this_->connect(addStopButton, &QAbstractButton::clicked, this_, [this_] { this_->done(AddStop); });
|
||||
dbb->addButton(addStopButton, QDialogButtonBox::ActionRole);
|
||||
|
||||
QPushButton * routeToButton = new QPushButton("Route To");
|
||||
routeToButton->setIcon(QIcon(":/navig64/point-finish.png"));
|
||||
routeToButton->setAutoDefault(false);
|
||||
this_->connect(routeToButton, &QAbstractButton::clicked, this_, [this_]
|
||||
{
|
||||
this_->done(RouteTo);
|
||||
});
|
||||
this_->connect(routeToButton, &QAbstractButton::clicked, this_, [this_] { this_->done(RouteTo); });
|
||||
dbb->addButton(routeToButton, QDialogButtonBox::ActionRole);
|
||||
|
||||
QPushButton * closeButton = new QPushButton("Close");
|
||||
closeButton->setDefault(true);
|
||||
this_->connect(closeButton, &QAbstractButton::clicked, this_, [this_]
|
||||
{
|
||||
this_->done(place_page_dialog::Close);
|
||||
});
|
||||
this_->connect(closeButton, &QAbstractButton::clicked, this_, [this_] { this_->done(place_page_dialog::Close); });
|
||||
dbb->addButton(closeButton, QDialogButtonBox::RejectRole);
|
||||
|
||||
if (shouldShowEditPlace)
|
||||
{
|
||||
QPushButton * editButton = new QPushButton("Edit Place");
|
||||
this_->connect(editButton, &QAbstractButton::clicked, this_, [this_]
|
||||
{
|
||||
this_->done(place_page_dialog::EditPlace);
|
||||
});
|
||||
this_->connect(editButton, &QAbstractButton::clicked, this_,
|
||||
[this_] { this_->done(place_page_dialog::EditPlace); });
|
||||
dbb->addButton(editButton, QDialogButtonBox::AcceptRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace place_page_dialog
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
namespace place_page_dialog
|
||||
{
|
||||
enum PressedButton : int {
|
||||
enum PressedButton : int
|
||||
{
|
||||
Close = QDialog::Rejected,
|
||||
RouteFrom,
|
||||
AddStop,
|
||||
@@ -14,4 +15,4 @@ enum PressedButton : int {
|
||||
};
|
||||
|
||||
void addCommonButtons(QDialog * this_, QDialogButtonBox * dbb, bool shouldShowEditPlace);
|
||||
}
|
||||
} // namespace place_page_dialog
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "qt/place_page_dialog_common.hpp"
|
||||
#include "qt/place_page_dialog_developer.hpp"
|
||||
#include "qt/place_page_dialog_common.hpp"
|
||||
|
||||
#include "qt/qt_common/text_dialog.hpp"
|
||||
|
||||
@@ -117,11 +117,8 @@ PlacePageDialogDeveloper::PlacePageDialogDeveloper(QWidget * parent, place_page:
|
||||
case PropID::FMD_CONTACT_BLUESKY:
|
||||
case PropID::FMD_WIKIPEDIA:
|
||||
case PropID::FMD_WIKIMEDIA_COMMONS:
|
||||
case PropID::FMD_PANORAMAX:
|
||||
isLink = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case PropID::FMD_PANORAMAX: isLink = true; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
addEntry(DebugPrint(id), value, isLink);
|
||||
|
||||
@@ -12,6 +12,7 @@ class Info;
|
||||
class PlacePageDialogDeveloper : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlacePageDialogDeveloper(QWidget * parent, place_page::Info const & info,
|
||||
search::ReverseGeocoder::Address const & address);
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include "qt/place_page_dialog_common.hpp"
|
||||
#include "qt/place_page_dialog_user.hpp"
|
||||
#include "qt/place_page_dialog_common.hpp"
|
||||
|
||||
#include "qt/qt_common/text_dialog.hpp"
|
||||
|
||||
#include "map/place_page_info.hpp"
|
||||
#include "indexer/validate_and_format_contacts.hpp"
|
||||
#include "map/place_page_info.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
#include <QtWidgets/QDialog>
|
||||
#include <QtWidgets/QDialogButtonBox>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QDialog>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -22,7 +22,7 @@ namespace
|
||||
static int constexpr kMaxLengthOfPlacePageDescription = 500;
|
||||
static int constexpr kMinWidthOfShortDescription = 390;
|
||||
|
||||
std::string getShortDescription(const std::string & description)
|
||||
std::string getShortDescription(std::string const & description)
|
||||
{
|
||||
std::string_view view(description);
|
||||
|
||||
@@ -38,12 +38,11 @@ std::string getShortDescription(const std::string & description)
|
||||
return std::string(view);
|
||||
}
|
||||
|
||||
std::string_view stripSchemeFromURI(std::string_view uri) {
|
||||
std::string_view stripSchemeFromURI(std::string_view uri)
|
||||
{
|
||||
for (std::string_view prefix : {"https://", "http://"})
|
||||
{
|
||||
if (uri.starts_with(prefix))
|
||||
return uri.substr(prefix.size());
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
} // namespace
|
||||
@@ -121,19 +120,19 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
if (info.IsBookmark())
|
||||
addEntry("Bookmark", "Yes");
|
||||
|
||||
|
||||
// Wikipedia fragment
|
||||
if (auto const & wikipedia = info.GetMetadata(feature::Metadata::EType::FMD_WIKIPEDIA); !wikipedia.empty())
|
||||
{
|
||||
QLabel * name = new QLabel("Wikipedia");
|
||||
name->setOpenExternalLinks(true);
|
||||
name->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
name->setText(QString::fromStdString("<a href=\"" + feature::Metadata::ToWikiURL(std::string(wikipedia)) + "\">Wikipedia</a>"));
|
||||
name->setText(QString::fromStdString("<a href=\"" + feature::Metadata::ToWikiURL(std::string(wikipedia)) +
|
||||
"\">Wikipedia</a>"));
|
||||
data->addWidget(name, row++, 0);
|
||||
}
|
||||
|
||||
// Description
|
||||
if (const auto & description = info.GetWikiDescription(); !description.empty())
|
||||
if (auto const & description = info.GetWikiDescription(); !description.empty())
|
||||
{
|
||||
auto descriptionShort = getShortDescription(description);
|
||||
|
||||
@@ -146,7 +145,8 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
wikiButton->setAutoDefault(false);
|
||||
connect(wikiButton, &QAbstractButton::clicked, this, [this, description, title]()
|
||||
{
|
||||
auto textDialog = TextDialog(this, QString::fromStdString(description), QString::fromStdString("Wikipedia: " + title));
|
||||
auto textDialog =
|
||||
TextDialog(this, QString::fromStdString(description), QString::fromStdString("Wikipedia: " + title));
|
||||
textDialog.exec();
|
||||
});
|
||||
|
||||
@@ -169,7 +169,8 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
{
|
||||
data->addWidget(new QLabel("Phone"), row, 0);
|
||||
|
||||
QLabel * value = new QLabel(QString::fromStdString("<a href='tel:" + std::string(phoneNumber) + "'>" + std::string(phoneNumber) + "</a>"));
|
||||
QLabel * value = new QLabel(QString::fromStdString("<a href='tel:" + std::string(phoneNumber) + "'>" +
|
||||
std::string(phoneNumber) + "</a>"));
|
||||
value->setOpenExternalLinks(true);
|
||||
|
||||
data->addWidget(value, row++, 1);
|
||||
@@ -191,7 +192,8 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
{
|
||||
data->addWidget(new QLabel("Email"), row, 0);
|
||||
|
||||
QLabel * value = new QLabel(QString::fromStdString("<a href='mailto:" + std::string(email) + "'>" + std::string(email) + "</a>"));
|
||||
QLabel * value = new QLabel(
|
||||
QString::fromStdString("<a href='mailto:" + std::string(email) + "'>" + std::string(email) + "</a>"));
|
||||
value->setOpenExternalLinks(true);
|
||||
|
||||
data->addWidget(value, row++, 1);
|
||||
@@ -199,13 +201,14 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
|
||||
// Social networks
|
||||
{
|
||||
auto addSocialNetworkWidget = [data, &info, &row](const std::string label, const feature::Metadata::EType eType)
|
||||
auto addSocialNetworkWidget = [data, &info, &row](std::string const label, feature::Metadata::EType const eType)
|
||||
{
|
||||
if (auto item = info.GetMetadata(eType); !item.empty())
|
||||
{
|
||||
data->addWidget(new QLabel(QString::fromStdString(label)), row, 0);
|
||||
|
||||
QLabel * value = new QLabel(QString::fromStdString("<a href='" + osm::socialContactToURL(eType, std::string(item)) + "'>" + std::string(item) + "</a>"));
|
||||
QLabel * value = new QLabel(QString::fromStdString(
|
||||
"<a href='" + osm::socialContactToURL(eType, std::string(item)) + "'>" + std::string(item) + "</a>"));
|
||||
value->setOpenExternalLinks(true);
|
||||
value->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
|
||||
@@ -222,11 +225,14 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
addSocialNetworkWidget("Bluesky", feature::Metadata::EType::FMD_CONTACT_BLUESKY);
|
||||
}
|
||||
|
||||
if (auto wikimedia_commons = info.GetMetadata(feature::Metadata::EType::FMD_WIKIMEDIA_COMMONS); !wikimedia_commons.empty())
|
||||
if (auto wikimedia_commons = info.GetMetadata(feature::Metadata::EType::FMD_WIKIMEDIA_COMMONS);
|
||||
!wikimedia_commons.empty())
|
||||
{
|
||||
data->addWidget(new QLabel("Wikimedia Commons"), row, 0);
|
||||
|
||||
QLabel * value = new QLabel(QString::fromStdString("<a href='" + feature::Metadata::ToWikimediaCommonsURL(std::string(wikimedia_commons)) + "'>Wikimedia Commons</a>"));
|
||||
QLabel * value = new QLabel(QString::fromStdString(
|
||||
"<a href='" + feature::Metadata::ToWikimediaCommonsURL(std::string(wikimedia_commons)) +
|
||||
"'>Wikimedia Commons</a>"));
|
||||
value->setOpenExternalLinks(true);
|
||||
value->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
|
||||
@@ -237,7 +243,8 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
{
|
||||
data->addWidget(new QLabel("Panoramax Picture"), row, 0);
|
||||
|
||||
QLabel * value = new QLabel(QString::fromStdString("<a href='https://api.panoramax.xyz/?pic=" + std::string(panoramax) + "'>Panoramax Image</a>"));
|
||||
QLabel * value = new QLabel(QString::fromStdString(
|
||||
"<a href='https://api.panoramax.xyz/?pic=" + std::string(panoramax) + "'>Panoramax Image</a>"));
|
||||
value->setOpenExternalLinks(true);
|
||||
value->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
|
||||
@@ -265,7 +272,7 @@ PlacePageDialogUser::PlacePageDialogUser(QWidget * parent, place_page::Info cons
|
||||
layout->addLayout(data);
|
||||
}
|
||||
|
||||
layout->addStretch();
|
||||
layout->addStretch();
|
||||
|
||||
{
|
||||
QHLine * line = new QHLine();
|
||||
|
||||
@@ -12,6 +12,7 @@ class Info;
|
||||
class PlacePageDialogUser : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlacePageDialogUser(QWidget * parent, place_page::Info const & info,
|
||||
search::ReverseGeocoder::Address const & address);
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
namespace qt
|
||||
{
|
||||
|
||||
PopupMenuHolder::PopupMenuHolder(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
PopupMenuHolder::PopupMenuHolder(QObject * parent) : QObject(parent) {}
|
||||
|
||||
QAction * PopupMenuHolder::addActionImpl(QIcon const & icon, QString const & text, bool checkable)
|
||||
{
|
||||
@@ -57,4 +54,4 @@ bool PopupMenuHolder::isChecked(size_t idx)
|
||||
return m_actions[idx]->isChecked();
|
||||
}
|
||||
|
||||
} // namespace qt
|
||||
} // namespace qt
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <QtGui/QAction>
|
||||
#include <QtWidgets/QToolButton>
|
||||
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace qt
|
||||
{
|
||||
@@ -15,15 +15,15 @@ class PopupMenuHolder : public QObject
|
||||
|
||||
QToolButton * m_toolButton;
|
||||
|
||||
std::vector<QAction*> m_actions;
|
||||
std::vector<QAction *> m_actions;
|
||||
|
||||
QAction * addActionImpl(QIcon const & icon, QString const & text, bool checkable);
|
||||
|
||||
public:
|
||||
explicit PopupMenuHolder(QObject * parent = nullptr);
|
||||
|
||||
QAction * addAction(QIcon const & icon, QString const & text,
|
||||
QObject const * receiver, char const * member, bool checkable)
|
||||
QAction * addAction(QIcon const & icon, QString const & text, QObject const * receiver, char const * member,
|
||||
bool checkable)
|
||||
{
|
||||
QAction * p = addActionImpl(icon, text, checkable);
|
||||
connect(p, SIGNAL(triggered()), receiver, member);
|
||||
@@ -42,13 +42,19 @@ public:
|
||||
void setMainIcon(QIcon const & icon);
|
||||
|
||||
void setCurrent(size_t idx);
|
||||
template <class T> typename std::enable_if<std::is_enum<T>::value, void>::type
|
||||
setCurrent(T idx) { setCurrent(static_cast<size_t>(idx)); }
|
||||
template <class T>
|
||||
typename std::enable_if<std::is_enum<T>::value, void>::type setCurrent(T idx)
|
||||
{
|
||||
setCurrent(static_cast<size_t>(idx));
|
||||
}
|
||||
|
||||
void setChecked(size_t idx, bool checked);
|
||||
|
||||
bool isChecked(size_t idx);
|
||||
template <class T> typename std::enable_if<std::is_enum<T>::value, bool>::type
|
||||
isChecked(T idx) { return isChecked(static_cast<size_t>(idx)); }
|
||||
template <class T>
|
||||
typename std::enable_if<std::is_enum<T>::value, bool>::type isChecked(T idx)
|
||||
{
|
||||
return isChecked(static_cast<size_t>(idx));
|
||||
}
|
||||
};
|
||||
} // namespace qt
|
||||
} // namespace qt
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "qt/preferences_dialog.hpp"
|
||||
|
||||
#include "indexer/map_style.hpp"
|
||||
#include "coding/string_utf8_multilang.hpp"
|
||||
#include "indexer/map_style.hpp"
|
||||
#include "map/framework.hpp"
|
||||
|
||||
#include "platform/measurement_utils.hpp"
|
||||
@@ -9,17 +9,17 @@
|
||||
#include "platform/settings.hpp"
|
||||
#include "platform/style_utils.hpp"
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
#include <QLocale>
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtWidgets/QGroupBox>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QGroupBox>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QRadioButton>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
using namespace measurement_utils;
|
||||
|
||||
@@ -29,179 +29,174 @@ std::string const kEnabledAutoRegenGeomIndex = "EnabledAutoRegenGeomIndex";
|
||||
|
||||
namespace qt
|
||||
{
|
||||
PreferencesDialog::PreferencesDialog(QWidget * parent, Framework & framework)
|
||||
PreferencesDialog::PreferencesDialog(QWidget * parent, Framework & framework)
|
||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
|
||||
{
|
||||
QIcon icon(":/ui/logo.png");
|
||||
setWindowIcon(icon);
|
||||
setWindowTitle(tr("Preferences"));
|
||||
|
||||
QButtonGroup * unitsGroup = new QButtonGroup(this);
|
||||
QGroupBox * unitsRadioBox = new QGroupBox("System of measurement");
|
||||
{
|
||||
QIcon icon(":/ui/logo.png");
|
||||
setWindowIcon(icon);
|
||||
setWindowTitle(tr("Preferences"));
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
|
||||
QButtonGroup * unitsGroup = new QButtonGroup(this);
|
||||
QGroupBox * unitsRadioBox = new QGroupBox("System of measurement");
|
||||
QRadioButton * radioButton = new QRadioButton("Metric");
|
||||
layout->addWidget(radioButton);
|
||||
unitsGroup->addButton(radioButton, static_cast<int>(Units::Metric));
|
||||
|
||||
radioButton = new QRadioButton("Imperial (foot)");
|
||||
layout->addWidget(radioButton);
|
||||
unitsGroup->addButton(radioButton, static_cast<int>(Units::Imperial));
|
||||
|
||||
unitsRadioBox->setLayout(layout);
|
||||
|
||||
Units u;
|
||||
if (!settings::Get(settings::kMeasurementUnits, u))
|
||||
{
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
// Set default measurement from system locale
|
||||
if (QLocale::system().measurementSystem() == QLocale::MetricSystem)
|
||||
u = Units::Metric;
|
||||
else
|
||||
u = Units::Imperial;
|
||||
}
|
||||
unitsGroup->button(static_cast<int>(u))->setChecked(true);
|
||||
|
||||
QRadioButton * radioButton = new QRadioButton("Metric");
|
||||
layout->addWidget(radioButton);
|
||||
unitsGroup->addButton(radioButton, static_cast<int>(Units::Metric));
|
||||
|
||||
radioButton = new QRadioButton("Imperial (foot)");
|
||||
layout->addWidget(radioButton);
|
||||
unitsGroup->addButton(radioButton, static_cast<int>(Units::Imperial));
|
||||
|
||||
unitsRadioBox->setLayout(layout);
|
||||
|
||||
Units u;
|
||||
if (!settings::Get(settings::kMeasurementUnits, u))
|
||||
// Temporary to pass the address of overloaded function.
|
||||
void (QButtonGroup::*buttonClicked)(int) = &QButtonGroup::idClicked;
|
||||
connect(unitsGroup, buttonClicked, [&framework](int i)
|
||||
{
|
||||
Units u = Units::Metric;
|
||||
switch (i)
|
||||
{
|
||||
// Set default measurement from system locale
|
||||
if (QLocale::system().measurementSystem() == QLocale::MetricSystem)
|
||||
u = Units::Metric;
|
||||
else
|
||||
u = Units::Imperial;
|
||||
case 0: u = Units::Metric; break;
|
||||
case 1: u = Units::Imperial; break;
|
||||
}
|
||||
unitsGroup->button(static_cast<int>(u))->setChecked(true);
|
||||
|
||||
// Temporary to pass the address of overloaded function.
|
||||
void (QButtonGroup::* buttonClicked)(int) = &QButtonGroup::idClicked;
|
||||
connect(unitsGroup, buttonClicked, [&framework](int i)
|
||||
{
|
||||
Units u = Units::Metric;
|
||||
switch (i)
|
||||
{
|
||||
case 0: u = Units::Metric; break;
|
||||
case 1: u = Units::Imperial; break;
|
||||
}
|
||||
|
||||
settings::Set(settings::kMeasurementUnits, u);
|
||||
framework.SetupMeasurementSystem();
|
||||
});
|
||||
}
|
||||
|
||||
QCheckBox * largeFontCheckBox = new QCheckBox("Use larger font on the map");
|
||||
{
|
||||
largeFontCheckBox->setChecked(framework.LoadLargeFontsSize());
|
||||
connect(largeFontCheckBox, &QCheckBox::stateChanged, [&framework](int i)
|
||||
{
|
||||
framework.SetLargeFontsSize(static_cast<bool>(i));
|
||||
});
|
||||
}
|
||||
|
||||
QCheckBox * transliterationCheckBox = new QCheckBox("Transliterate to Latin");
|
||||
{
|
||||
transliterationCheckBox->setChecked(framework.LoadTransliteration());
|
||||
connect(transliterationCheckBox, &QCheckBox::stateChanged, [&framework](int i)
|
||||
{
|
||||
bool const enable = i > 0;
|
||||
framework.SaveTransliteration(enable);
|
||||
framework.AllowTransliteration(enable);
|
||||
});
|
||||
}
|
||||
|
||||
QCheckBox * developerModeCheckBox = new QCheckBox("Developer Mode");
|
||||
{
|
||||
bool developerMode;
|
||||
if (settings::Get(settings::kDeveloperMode, developerMode) && developerMode)
|
||||
developerModeCheckBox->setChecked(developerMode);
|
||||
connect(developerModeCheckBox, &QCheckBox::stateChanged, [](int i)
|
||||
{
|
||||
settings::Set(settings::kDeveloperMode, static_cast<bool>(i));
|
||||
});
|
||||
}
|
||||
|
||||
QLabel * mapLanguageLabel = new QLabel("Map Language");
|
||||
QComboBox * mapLanguageComboBox = new QComboBox();
|
||||
{
|
||||
// The property maxVisibleItems is ignored for non-editable comboboxes in styles that
|
||||
// return true for `QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
|
||||
// So we ensure that it returns false here.
|
||||
mapLanguageComboBox->setStyleSheet("QComboBox { combobox-popup: 0; }");
|
||||
mapLanguageComboBox->setMaxVisibleItems(10);
|
||||
StringUtf8Multilang::Languages const & supportedLanguages = StringUtf8Multilang::GetSupportedLanguages(/* includeServiceLangs */ false);
|
||||
QStringList languagesList = QStringList();
|
||||
for (auto const & language : supportedLanguages)
|
||||
languagesList << QString::fromStdString(std::string(language.m_name));
|
||||
|
||||
mapLanguageComboBox->addItems(languagesList);
|
||||
std::string const & mapLanguageCode = framework.GetMapLanguageCode();
|
||||
int8_t languageIndex = StringUtf8Multilang::GetLangIndex(mapLanguageCode);
|
||||
if (languageIndex == StringUtf8Multilang::kUnsupportedLanguageCode)
|
||||
languageIndex = StringUtf8Multilang::kDefaultCode;
|
||||
|
||||
mapLanguageComboBox->setCurrentText(QString::fromStdString(std::string(StringUtf8Multilang::GetLangNameByCode(languageIndex))));
|
||||
connect(mapLanguageComboBox, &QComboBox::activated, [&framework, &supportedLanguages](int index)
|
||||
{
|
||||
auto const & mapLanguageCode = std::string(supportedLanguages[index].m_code);
|
||||
framework.SetMapLanguageCode(mapLanguageCode);
|
||||
});
|
||||
}
|
||||
|
||||
QButtonGroup * nightModeGroup = new QButtonGroup(this);
|
||||
QGroupBox * nightModeRadioBox = new QGroupBox("Night Mode");
|
||||
{
|
||||
using namespace style_utils;
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
|
||||
QRadioButton * radioButton = new QRadioButton("Off");
|
||||
layout->addWidget(radioButton);
|
||||
nightModeGroup->addButton(radioButton, static_cast<int>(NightMode::Off));
|
||||
|
||||
radioButton = new QRadioButton("On");
|
||||
layout->addWidget(radioButton);
|
||||
nightModeGroup->addButton(radioButton, static_cast<int>(NightMode::On));
|
||||
|
||||
nightModeRadioBox->setLayout(layout);
|
||||
|
||||
int const btn = MapStyleIsDark(framework.GetMapStyle()) ? 1 : 0;
|
||||
nightModeGroup->button(btn)->setChecked(true);
|
||||
|
||||
void (QButtonGroup::* buttonClicked)(int) = &QButtonGroup::idClicked;
|
||||
connect(nightModeGroup, buttonClicked, [&framework](int i)
|
||||
{
|
||||
auto const currStyle = framework.GetMapStyle();
|
||||
framework.SetMapStyle((i == 0) ? GetLightMapStyleVariant(currStyle) :
|
||||
GetDarkMapStyleVariant(currStyle));
|
||||
});
|
||||
}
|
||||
|
||||
#ifdef BUILD_DESIGNER
|
||||
QCheckBox * indexRegenCheckBox = new QCheckBox("Enable auto regeneration of geometry index");
|
||||
{
|
||||
bool enabled = false;
|
||||
if (!settings::Get(kEnabledAutoRegenGeomIndex, enabled))
|
||||
settings::Set(kEnabledAutoRegenGeomIndex, false);
|
||||
indexRegenCheckBox->setChecked(enabled);
|
||||
connect(indexRegenCheckBox, &QCheckBox::stateChanged, [](int i)
|
||||
{
|
||||
settings::Set(kEnabledAutoRegenGeomIndex, static_cast<bool>(i))
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
QHBoxLayout * bottomLayout = new QHBoxLayout();
|
||||
{
|
||||
QPushButton * closeButton = new QPushButton(tr("Close"));
|
||||
closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
closeButton->setDefault(true);
|
||||
connect(closeButton, &QAbstractButton::clicked, [this](){ done(0); });
|
||||
|
||||
bottomLayout->addStretch(1);
|
||||
bottomLayout->setSpacing(0);
|
||||
bottomLayout->addWidget(closeButton);
|
||||
}
|
||||
|
||||
QVBoxLayout * finalLayout = new QVBoxLayout();
|
||||
finalLayout->addWidget(unitsRadioBox);
|
||||
finalLayout->addWidget(largeFontCheckBox);
|
||||
finalLayout->addWidget(transliterationCheckBox);
|
||||
finalLayout->addWidget(developerModeCheckBox);
|
||||
finalLayout->addWidget(mapLanguageLabel);
|
||||
finalLayout->addWidget(mapLanguageComboBox);
|
||||
finalLayout->addWidget(nightModeRadioBox);
|
||||
#ifdef BUILD_DESIGNER
|
||||
finalLayout->addWidget(indexRegenCheckBox);
|
||||
#endif
|
||||
finalLayout->addLayout(bottomLayout);
|
||||
setLayout(finalLayout);
|
||||
settings::Set(settings::kMeasurementUnits, u);
|
||||
framework.SetupMeasurementSystem();
|
||||
});
|
||||
}
|
||||
|
||||
QCheckBox * largeFontCheckBox = new QCheckBox("Use larger font on the map");
|
||||
{
|
||||
largeFontCheckBox->setChecked(framework.LoadLargeFontsSize());
|
||||
connect(largeFontCheckBox, &QCheckBox::stateChanged,
|
||||
[&framework](int i) { framework.SetLargeFontsSize(static_cast<bool>(i)); });
|
||||
}
|
||||
|
||||
QCheckBox * transliterationCheckBox = new QCheckBox("Transliterate to Latin");
|
||||
{
|
||||
transliterationCheckBox->setChecked(framework.LoadTransliteration());
|
||||
connect(transliterationCheckBox, &QCheckBox::stateChanged, [&framework](int i)
|
||||
{
|
||||
bool const enable = i > 0;
|
||||
framework.SaveTransliteration(enable);
|
||||
framework.AllowTransliteration(enable);
|
||||
});
|
||||
}
|
||||
|
||||
QCheckBox * developerModeCheckBox = new QCheckBox("Developer Mode");
|
||||
{
|
||||
bool developerMode;
|
||||
if (settings::Get(settings::kDeveloperMode, developerMode) && developerMode)
|
||||
developerModeCheckBox->setChecked(developerMode);
|
||||
connect(developerModeCheckBox, &QCheckBox::stateChanged,
|
||||
[](int i) { settings::Set(settings::kDeveloperMode, static_cast<bool>(i)); });
|
||||
}
|
||||
|
||||
QLabel * mapLanguageLabel = new QLabel("Map Language");
|
||||
QComboBox * mapLanguageComboBox = new QComboBox();
|
||||
{
|
||||
// The property maxVisibleItems is ignored for non-editable comboboxes in styles that
|
||||
// return true for `QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
|
||||
// So we ensure that it returns false here.
|
||||
mapLanguageComboBox->setStyleSheet("QComboBox { combobox-popup: 0; }");
|
||||
mapLanguageComboBox->setMaxVisibleItems(10);
|
||||
StringUtf8Multilang::Languages const & supportedLanguages =
|
||||
StringUtf8Multilang::GetSupportedLanguages(/* includeServiceLangs */ false);
|
||||
QStringList languagesList = QStringList();
|
||||
for (auto const & language : supportedLanguages)
|
||||
languagesList << QString::fromStdString(std::string(language.m_name));
|
||||
|
||||
mapLanguageComboBox->addItems(languagesList);
|
||||
std::string const & mapLanguageCode = framework.GetMapLanguageCode();
|
||||
int8_t languageIndex = StringUtf8Multilang::GetLangIndex(mapLanguageCode);
|
||||
if (languageIndex == StringUtf8Multilang::kUnsupportedLanguageCode)
|
||||
languageIndex = StringUtf8Multilang::kDefaultCode;
|
||||
|
||||
mapLanguageComboBox->setCurrentText(
|
||||
QString::fromStdString(std::string(StringUtf8Multilang::GetLangNameByCode(languageIndex))));
|
||||
connect(mapLanguageComboBox, &QComboBox::activated, [&framework, &supportedLanguages](int index)
|
||||
{
|
||||
auto const & mapLanguageCode = std::string(supportedLanguages[index].m_code);
|
||||
framework.SetMapLanguageCode(mapLanguageCode);
|
||||
});
|
||||
}
|
||||
|
||||
QButtonGroup * nightModeGroup = new QButtonGroup(this);
|
||||
QGroupBox * nightModeRadioBox = new QGroupBox("Night Mode");
|
||||
{
|
||||
using namespace style_utils;
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
|
||||
QRadioButton * radioButton = new QRadioButton("Off");
|
||||
layout->addWidget(radioButton);
|
||||
nightModeGroup->addButton(radioButton, static_cast<int>(NightMode::Off));
|
||||
|
||||
radioButton = new QRadioButton("On");
|
||||
layout->addWidget(radioButton);
|
||||
nightModeGroup->addButton(radioButton, static_cast<int>(NightMode::On));
|
||||
|
||||
nightModeRadioBox->setLayout(layout);
|
||||
|
||||
int const btn = MapStyleIsDark(framework.GetMapStyle()) ? 1 : 0;
|
||||
nightModeGroup->button(btn)->setChecked(true);
|
||||
|
||||
void (QButtonGroup::*buttonClicked)(int) = &QButtonGroup::idClicked;
|
||||
connect(nightModeGroup, buttonClicked, [&framework](int i)
|
||||
{
|
||||
auto const currStyle = framework.GetMapStyle();
|
||||
framework.SetMapStyle((i == 0) ? GetLightMapStyleVariant(currStyle) : GetDarkMapStyleVariant(currStyle));
|
||||
});
|
||||
}
|
||||
|
||||
#ifdef BUILD_DESIGNER
|
||||
QCheckBox * indexRegenCheckBox = new QCheckBox("Enable auto regeneration of geometry index");
|
||||
{
|
||||
bool enabled = false;
|
||||
if (!settings::Get(kEnabledAutoRegenGeomIndex, enabled))
|
||||
settings::Set(kEnabledAutoRegenGeomIndex, false);
|
||||
indexRegenCheckBox->setChecked(enabled);
|
||||
connect(indexRegenCheckBox, &QCheckBox::stateChanged,
|
||||
[](int i) { settings::Set(kEnabledAutoRegenGeomIndex, static_cast<bool>(i)) });
|
||||
}
|
||||
#endif
|
||||
|
||||
QHBoxLayout * bottomLayout = new QHBoxLayout();
|
||||
{
|
||||
QPushButton * closeButton = new QPushButton(tr("Close"));
|
||||
closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
closeButton->setDefault(true);
|
||||
connect(closeButton, &QAbstractButton::clicked, [this]() { done(0); });
|
||||
|
||||
bottomLayout->addStretch(1);
|
||||
bottomLayout->setSpacing(0);
|
||||
bottomLayout->addWidget(closeButton);
|
||||
}
|
||||
|
||||
QVBoxLayout * finalLayout = new QVBoxLayout();
|
||||
finalLayout->addWidget(unitsRadioBox);
|
||||
finalLayout->addWidget(largeFontCheckBox);
|
||||
finalLayout->addWidget(transliterationCheckBox);
|
||||
finalLayout->addWidget(developerModeCheckBox);
|
||||
finalLayout->addWidget(mapLanguageLabel);
|
||||
finalLayout->addWidget(mapLanguageComboBox);
|
||||
finalLayout->addWidget(nightModeRadioBox);
|
||||
#ifdef BUILD_DESIGNER
|
||||
finalLayout->addWidget(indexRegenCheckBox);
|
||||
#endif
|
||||
finalLayout->addLayout(bottomLayout);
|
||||
setLayout(finalLayout);
|
||||
}
|
||||
} // namespace qt
|
||||
|
||||
@@ -8,16 +8,16 @@ class Framework;
|
||||
|
||||
namespace qt
|
||||
{
|
||||
class PreferencesDialog : public QDialog
|
||||
{
|
||||
typedef QDialog base_t;
|
||||
class PreferencesDialog : public QDialog
|
||||
{
|
||||
typedef QDialog base_t;
|
||||
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PreferencesDialog(QWidget * parent, Framework & framework);
|
||||
};
|
||||
} // namespace qt
|
||||
public:
|
||||
PreferencesDialog(QWidget * parent, Framework & framework);
|
||||
};
|
||||
} // namespace qt
|
||||
|
||||
#ifdef BUILD_DESIGNER
|
||||
extern std::string const kEnabledAutoRegenGeomIndex;
|
||||
|
||||
@@ -10,25 +10,40 @@
|
||||
namespace qt::common
|
||||
{
|
||||
|
||||
bool IsLeftButton(Qt::MouseButtons buttons) { return buttons & Qt::LeftButton; }
|
||||
bool IsLeftButton(Qt::MouseButtons buttons)
|
||||
{
|
||||
return buttons & Qt::LeftButton;
|
||||
}
|
||||
|
||||
bool IsLeftButton(QMouseEvent const * const e)
|
||||
{
|
||||
return IsLeftButton(e->button()) || IsLeftButton(e->buttons());
|
||||
}
|
||||
|
||||
bool IsRightButton(Qt::MouseButtons buttons) { return buttons & Qt::RightButton; }
|
||||
bool IsRightButton(Qt::MouseButtons buttons)
|
||||
{
|
||||
return buttons & Qt::RightButton;
|
||||
}
|
||||
|
||||
bool IsRightButton(QMouseEvent const * const e)
|
||||
{
|
||||
return IsRightButton(e->button()) || IsRightButton(e->buttons());
|
||||
}
|
||||
|
||||
bool IsCommandModifier(QMouseEvent const * const e) { return e->modifiers() & Qt::ControlModifier; }
|
||||
bool IsCommandModifier(QMouseEvent const * const e)
|
||||
{
|
||||
return e->modifiers() & Qt::ControlModifier;
|
||||
}
|
||||
|
||||
bool IsShiftModifier(QMouseEvent const * const e) { return e->modifiers() & Qt::ShiftModifier; }
|
||||
bool IsShiftModifier(QMouseEvent const * const e)
|
||||
{
|
||||
return e->modifiers() & Qt::ShiftModifier;
|
||||
}
|
||||
|
||||
bool IsAltModifier(QMouseEvent const * const e) { return e->modifiers() & Qt::AltModifier; }
|
||||
bool IsAltModifier(QMouseEvent const * const e)
|
||||
{
|
||||
return e->modifiers() & Qt::AltModifier;
|
||||
}
|
||||
|
||||
location::GpsInfo MakeGpsInfo(m2::PointD const & point)
|
||||
{
|
||||
@@ -78,4 +93,4 @@ void SetDefaultSurfaceFormat(QString const & platformName)
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
}
|
||||
|
||||
} // namespace qt::common
|
||||
} // namespace qt::common
|
||||
|
||||
@@ -28,4 +28,4 @@ struct Hotkey
|
||||
location::GpsInfo MakeGpsInfo(m2::PointD const & point);
|
||||
|
||||
void SetDefaultSurfaceFormat(QString const & platformName);
|
||||
} // namespace qt::common
|
||||
} // namespace qt::common
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QTouchEvent>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QOpenGLFunctions>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtWidgets/QMenu>
|
||||
|
||||
// Fraction of the viewport for a move event
|
||||
@@ -33,7 +33,7 @@ static constexpr float kViewportFractionSmoothMove = 0.1;
|
||||
|
||||
namespace qt::common
|
||||
{
|
||||
//#define ENABLE_AA_SWITCH
|
||||
// #define ENABLE_AA_SWITCH
|
||||
|
||||
MapWidget::MapWidget(Framework & framework, bool isScreenshotMode, QWidget * parent)
|
||||
: QOpenGLWidget(parent)
|
||||
@@ -116,8 +116,7 @@ void MapWidget::CreateEngine()
|
||||
|
||||
m_skin.reset(new gui::Skin(gui::ResolveGuiSkinFile("default"), m_ratio));
|
||||
m_skin->Resize(p.m_surfaceWidth, p.m_surfaceHeight);
|
||||
m_skin->ForEach(
|
||||
[&p](gui::EWidget widget, gui::Position const & pos) { p.m_widgetsInitInfo[widget] = pos; });
|
||||
m_skin->ForEach([&p](gui::EWidget widget, gui::Position const & pos) { p.m_widgetsInitInfo[widget] = pos; });
|
||||
|
||||
p.m_widgetsInitInfo[gui::WIDGET_SCALE_FPS_LABEL] = gui::Position(dp::LeftTop);
|
||||
|
||||
@@ -125,29 +124,65 @@ void MapWidget::CreateEngine()
|
||||
m_framework.SetViewportListener(std::bind(&MapWidget::OnViewportChanged, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
void MapWidget::ScalePlus() { m_framework.Scale(Framework::SCALE_MAG, true); }
|
||||
void MapWidget::ScalePlus()
|
||||
{
|
||||
m_framework.Scale(Framework::SCALE_MAG, true);
|
||||
}
|
||||
|
||||
void MapWidget::ScaleMinus() { m_framework.Scale(Framework::SCALE_MIN, true); }
|
||||
void MapWidget::ScaleMinus()
|
||||
{
|
||||
m_framework.Scale(Framework::SCALE_MIN, true);
|
||||
}
|
||||
|
||||
void MapWidget::ScalePlusLight() { m_framework.Scale(Framework::SCALE_MAG_LIGHT, true); }
|
||||
void MapWidget::ScalePlusLight()
|
||||
{
|
||||
m_framework.Scale(Framework::SCALE_MAG_LIGHT, true);
|
||||
}
|
||||
|
||||
void MapWidget::ScaleMinusLight() { m_framework.Scale(Framework::SCALE_MIN_LIGHT, true); }
|
||||
void MapWidget::ScaleMinusLight()
|
||||
{
|
||||
m_framework.Scale(Framework::SCALE_MIN_LIGHT, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveRight() { m_framework.Move(-kViewportFractionRoughMove, 0, true); }
|
||||
void MapWidget::MoveRight()
|
||||
{
|
||||
m_framework.Move(-kViewportFractionRoughMove, 0, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveRightSmooth() { m_framework.Move(-kViewportFractionSmoothMove, 0, true); }
|
||||
void MapWidget::MoveRightSmooth()
|
||||
{
|
||||
m_framework.Move(-kViewportFractionSmoothMove, 0, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveLeft() { m_framework.Move(kViewportFractionRoughMove, 0, true); }
|
||||
void MapWidget::MoveLeft()
|
||||
{
|
||||
m_framework.Move(kViewportFractionRoughMove, 0, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveLeftSmooth() { m_framework.Move(kViewportFractionSmoothMove, 0, true); }
|
||||
void MapWidget::MoveLeftSmooth()
|
||||
{
|
||||
m_framework.Move(kViewportFractionSmoothMove, 0, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveUp() { m_framework.Move(0, -kViewportFractionRoughMove, true); }
|
||||
void MapWidget::MoveUp()
|
||||
{
|
||||
m_framework.Move(0, -kViewportFractionRoughMove, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveUpSmooth() { m_framework.Move(0, -kViewportFractionSmoothMove, true); }
|
||||
void MapWidget::MoveUpSmooth()
|
||||
{
|
||||
m_framework.Move(0, -kViewportFractionSmoothMove, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveDown() { m_framework.Move(0, kViewportFractionRoughMove, true); }
|
||||
void MapWidget::MoveDown()
|
||||
{
|
||||
m_framework.Move(0, kViewportFractionRoughMove, true);
|
||||
}
|
||||
|
||||
void MapWidget::MoveDownSmooth() { m_framework.Move(0, kViewportFractionSmoothMove, true); }
|
||||
void MapWidget::MoveDownSmooth()
|
||||
{
|
||||
m_framework.Move(0, kViewportFractionSmoothMove, true);
|
||||
}
|
||||
|
||||
void MapWidget::AntialiasingOn()
|
||||
{
|
||||
@@ -176,9 +211,15 @@ void MapWidget::ScaleChanged(int action)
|
||||
m_framework.Scale(factor, false);
|
||||
}
|
||||
|
||||
void MapWidget::SliderPressed() { m_sliderState = SliderState::Pressed; }
|
||||
void MapWidget::SliderPressed()
|
||||
{
|
||||
m_sliderState = SliderState::Pressed;
|
||||
}
|
||||
|
||||
void MapWidget::SliderReleased() { m_sliderState = SliderState::Released; }
|
||||
void MapWidget::SliderReleased()
|
||||
{
|
||||
m_sliderState = SliderState::Released;
|
||||
}
|
||||
|
||||
m2::PointD MapWidget::GetDevicePoint(QMouseEvent * e) const
|
||||
{
|
||||
@@ -233,11 +274,11 @@ void MapWidget::Build()
|
||||
std::string_view vertexSrc;
|
||||
std::string_view fragmentSrc;
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
vertexSrc = ":common/shaders/gles_300.vsh.glsl";
|
||||
fragmentSrc = ":common/shaders/gles_300.fsh.glsl";
|
||||
vertexSrc = ":common/shaders/gles_300.vsh.glsl";
|
||||
fragmentSrc = ":common/shaders/gles_300.fsh.glsl";
|
||||
#else
|
||||
vertexSrc = ":common/shaders/gl_150.vsh.glsl";
|
||||
fragmentSrc = ":common/shaders/gl_150.fsh.glsl";
|
||||
vertexSrc = ":common/shaders/gl_150.vsh.glsl";
|
||||
fragmentSrc = ":common/shaders/gl_150.fsh.glsl";
|
||||
#endif
|
||||
|
||||
m_program = std::make_unique<QOpenGLShaderProgram>(this);
|
||||
@@ -254,12 +295,10 @@ void MapWidget::Build()
|
||||
m_vbo->create();
|
||||
m_vbo->bind();
|
||||
|
||||
QVector4D vertices[4] = {QVector4D(-1.0, 1.0, 0.0, 1.0),
|
||||
QVector4D(1.0, 1.0, 1.0, 1.0),
|
||||
QVector4D(-1.0, -1.0, 0.0, 0.0),
|
||||
QVector4D(1.0, -1.0, 1.0, 0.0)};
|
||||
m_vbo->allocate(static_cast<void*>(vertices), sizeof(vertices));
|
||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||
QVector4D vertices[4] = {QVector4D(-1.0, 1.0, 0.0, 1.0), QVector4D(1.0, 1.0, 1.0, 1.0),
|
||||
QVector4D(-1.0, -1.0, 0.0, 0.0), QVector4D(1.0, -1.0, 1.0, 0.0)};
|
||||
m_vbo->allocate(static_cast<void *>(vertices), sizeof(vertices));
|
||||
QOpenGLFunctions * f = QOpenGLContext::currentContext()->functions();
|
||||
// 0-index of the buffer is linked to "a_position" attribute in vertex shader.
|
||||
// Introduced in https://github.com/organicmaps/organicmaps/pull/9814
|
||||
f->glEnableVertexAttribArray(0);
|
||||
@@ -278,7 +317,7 @@ search::ReverseGeocoder::Address GetFeatureAddressInfo(Framework const & framewo
|
||||
coder.GetExactAddress(ft, address);
|
||||
return address;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
void MapWidget::ShowInfoPopup(QMouseEvent * e, m2::PointD const & pt)
|
||||
{
|
||||
@@ -343,16 +382,12 @@ void MapWidget::initializeGL()
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
{
|
||||
QOpenGLFunctions * funcs = context()->functions();
|
||||
LOG(LINFO, ("Vendor:", funcs->glGetString(GL_VENDOR),
|
||||
"\nRenderer:", funcs->glGetString(GL_RENDERER),
|
||||
"\nVersion:", funcs->glGetString(GL_VERSION),
|
||||
"\nShading language version:\n",funcs->glGetString(GL_SHADING_LANGUAGE_VERSION),
|
||||
"\nExtensions:", funcs->glGetString(GL_EXTENSIONS)));
|
||||
LOG(LINFO, ("Vendor:", funcs->glGetString(GL_VENDOR), "\nRenderer:", funcs->glGetString(GL_RENDERER),
|
||||
"\nVersion:", funcs->glGetString(GL_VERSION), "\nShading language version:\n",
|
||||
funcs->glGetString(GL_SHADING_LANGUAGE_VERSION), "\nExtensions:", funcs->glGetString(GL_EXTENSIONS)));
|
||||
|
||||
if (!context()->isOpenGLES())
|
||||
{
|
||||
LOG(LCRITICAL, ("Context is not LibGLES! This shouldn't have happened."));
|
||||
}
|
||||
|
||||
auto fmt = context()->format();
|
||||
if (context()->format().version() < qMakePair(3, 0))
|
||||
@@ -407,7 +442,6 @@ void MapWidget::paintGL()
|
||||
|
||||
m_program->release();
|
||||
m_vao->release();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,8 +456,7 @@ void MapWidget::resizeGL(int width, int height)
|
||||
m_skin->Resize(w, h);
|
||||
|
||||
gui::TWidgetsLayoutInfo layout;
|
||||
m_skin->ForEach(
|
||||
[&layout](gui::EWidget w, gui::Position const & pos) { layout[w] = pos.m_pixelPivot; });
|
||||
m_skin->ForEach([&layout](gui::EWidget w, gui::Position const & pos) { layout[w] = pos.m_pixelPivot; });
|
||||
|
||||
m_framework.SetWidgetLayout(std::move(layout));
|
||||
}
|
||||
@@ -486,4 +519,4 @@ void MapWidget::wheelEvent(QWheelEvent * e)
|
||||
/// @todo Here you can tune the speed of zooming.
|
||||
m_framework.Scale(exp(factor), m2::PointD(L2D(pos.x()), L2D(pos.y())), false);
|
||||
}
|
||||
} // namespace qt::common
|
||||
} // namespace qt::common
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
void BindHotkeys(QWidget & parent);
|
||||
void BindSlider(ScaleSlider & slider);
|
||||
void CreateEngine();
|
||||
void grabGestures(const QList<Qt::GestureType> &gestures);
|
||||
void grabGestures(QList<Qt::GestureType> const & gestures);
|
||||
|
||||
signals:
|
||||
void OnContextMenuRequested(QPoint const & p);
|
||||
@@ -54,7 +54,6 @@ public slots:
|
||||
void MoveDown();
|
||||
void MoveDownSmooth();
|
||||
|
||||
|
||||
void ScaleChanged(int action);
|
||||
void SliderPressed();
|
||||
void SliderReleased();
|
||||
@@ -89,7 +88,6 @@ protected:
|
||||
void paintGL() override;
|
||||
void resizeGL(int width, int height) override;
|
||||
|
||||
|
||||
void mouseDoubleClickEvent(QMouseEvent * e) override;
|
||||
void mousePressEvent(QMouseEvent * e) override;
|
||||
void mouseMoveEvent(QMouseEvent * e) override;
|
||||
@@ -112,4 +110,4 @@ protected:
|
||||
std::unique_ptr<QOpenGLBuffer> m_vbo;
|
||||
};
|
||||
|
||||
} // namespace qt::common
|
||||
} // namespace qt::common
|
||||
|
||||
@@ -6,47 +6,42 @@ namespace common
|
||||
{
|
||||
ProxyStyle::ProxyStyle(QStyle * p) : QStyle(), style(p) {}
|
||||
|
||||
void ProxyStyle::drawComplexControl(ComplexControl control, QStyleOptionComplex const * option,
|
||||
QPainter * painter, QWidget const * widget) const
|
||||
void ProxyStyle::drawComplexControl(ComplexControl control, QStyleOptionComplex const * option, QPainter * painter,
|
||||
QWidget const * widget) const
|
||||
{
|
||||
style->drawComplexControl(control, option, painter, widget);
|
||||
}
|
||||
|
||||
void ProxyStyle::drawControl(ControlElement element, QStyleOption const * option,
|
||||
QPainter * painter, QWidget const * widget) const
|
||||
void ProxyStyle::drawControl(ControlElement element, QStyleOption const * option, QPainter * painter,
|
||||
QWidget const * widget) const
|
||||
{
|
||||
style->drawControl(element, option, painter, widget);
|
||||
}
|
||||
|
||||
void ProxyStyle::drawItemPixmap(QPainter * painter, QRect const & rect, int alignment,
|
||||
QPixmap const & pixmap) const
|
||||
void ProxyStyle::drawItemPixmap(QPainter * painter, QRect const & rect, int alignment, QPixmap const & pixmap) const
|
||||
{
|
||||
style->drawItemPixmap(painter, rect, alignment, pixmap);
|
||||
}
|
||||
|
||||
void ProxyStyle::drawItemText(QPainter * painter, QRect const & rect, int alignment,
|
||||
QPalette const & pal, bool enabled, QString const & text,
|
||||
QPalette::ColorRole textRole) const
|
||||
void ProxyStyle::drawItemText(QPainter * painter, QRect const & rect, int alignment, QPalette const & pal, bool enabled,
|
||||
QString const & text, QPalette::ColorRole textRole) const
|
||||
{
|
||||
style->drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
|
||||
}
|
||||
|
||||
void ProxyStyle::drawPrimitive(PrimitiveElement elem, QStyleOption const * option,
|
||||
QPainter * painter, QWidget const * widget) const
|
||||
void ProxyStyle::drawPrimitive(PrimitiveElement elem, QStyleOption const * option, QPainter * painter,
|
||||
QWidget const * widget) const
|
||||
{
|
||||
style->drawPrimitive(elem, option, painter, widget);
|
||||
}
|
||||
|
||||
QPixmap ProxyStyle::generatedIconPixmap(QIcon::Mode iconMode, QPixmap const & pixmap,
|
||||
QStyleOption const * option) const
|
||||
QPixmap ProxyStyle::generatedIconPixmap(QIcon::Mode iconMode, QPixmap const & pixmap, QStyleOption const * option) const
|
||||
{
|
||||
return style->generatedIconPixmap(iconMode, pixmap, option);
|
||||
}
|
||||
|
||||
QStyle::SubControl ProxyStyle::hitTestComplexControl(ComplexControl control,
|
||||
QStyleOptionComplex const * option,
|
||||
QPoint const & pos,
|
||||
QWidget const * widget) const
|
||||
QStyle::SubControl ProxyStyle::hitTestComplexControl(ComplexControl control, QStyleOptionComplex const * option,
|
||||
QPoint const & pos, QWidget const * widget) const
|
||||
{
|
||||
return style->hitTestComplexControl(control, option, pos, widget);
|
||||
}
|
||||
@@ -56,37 +51,47 @@ QRect ProxyStyle::itemPixmapRect(QRect const & rect, int alignment, QPixmap cons
|
||||
return style->itemPixmapRect(rect, alignment, pixmap);
|
||||
}
|
||||
|
||||
QRect ProxyStyle::itemTextRect(QFontMetrics const & metrics, QRect const & rect, int alignment,
|
||||
bool enabled, QString const & text) const
|
||||
QRect ProxyStyle::itemTextRect(QFontMetrics const & metrics, QRect const & rect, int alignment, bool enabled,
|
||||
QString const & text) const
|
||||
{
|
||||
return style->itemTextRect(metrics, rect, alignment, enabled, text);
|
||||
}
|
||||
|
||||
int ProxyStyle::pixelMetric(PixelMetric metric, QStyleOption const * option,
|
||||
QWidget const * widget) const
|
||||
int ProxyStyle::pixelMetric(PixelMetric metric, QStyleOption const * option, QWidget const * widget) const
|
||||
{
|
||||
return style->pixelMetric(metric, option, widget);
|
||||
}
|
||||
|
||||
void ProxyStyle::polish(QWidget * widget) { style->polish(widget); }
|
||||
void ProxyStyle::polish(QWidget * widget)
|
||||
{
|
||||
style->polish(widget);
|
||||
}
|
||||
|
||||
void ProxyStyle::polish(QApplication * app) { style->polish(app); }
|
||||
void ProxyStyle::polish(QApplication * app)
|
||||
{
|
||||
style->polish(app);
|
||||
}
|
||||
|
||||
void ProxyStyle::polish(QPalette & pal) { style->polish(pal); }
|
||||
void ProxyStyle::polish(QPalette & pal)
|
||||
{
|
||||
style->polish(pal);
|
||||
}
|
||||
|
||||
QSize ProxyStyle::sizeFromContents(ContentsType type, QStyleOption const * option,
|
||||
QSize const & contentsSize, QWidget const * widget) const
|
||||
QSize ProxyStyle::sizeFromContents(ContentsType type, QStyleOption const * option, QSize const & contentsSize,
|
||||
QWidget const * widget) const
|
||||
{
|
||||
return style->sizeFromContents(type, option, contentsSize, widget);
|
||||
}
|
||||
|
||||
QIcon ProxyStyle::standardIcon(StandardPixmap standardIcon, QStyleOption const * option,
|
||||
QWidget const * widget) const
|
||||
QIcon ProxyStyle::standardIcon(StandardPixmap standardIcon, QStyleOption const * option, QWidget const * widget) const
|
||||
{
|
||||
return style->standardIcon(standardIcon, option, widget);
|
||||
}
|
||||
|
||||
QPalette ProxyStyle::standardPalette() const { return style->standardPalette(); }
|
||||
QPalette ProxyStyle::standardPalette() const
|
||||
{
|
||||
return style->standardPalette();
|
||||
}
|
||||
|
||||
QPixmap ProxyStyle::standardPixmap(StandardPixmap standardPixmap, QStyleOption const * option,
|
||||
QWidget const * widget) const
|
||||
@@ -100,25 +105,29 @@ int ProxyStyle::styleHint(StyleHint hint, QStyleOption const * option, QWidget c
|
||||
return style->styleHint(hint, option, widget, returnData);
|
||||
}
|
||||
|
||||
QRect ProxyStyle::subControlRect(ComplexControl control, QStyleOptionComplex const * option,
|
||||
SubControl subControl, QWidget const * widget) const
|
||||
QRect ProxyStyle::subControlRect(ComplexControl control, QStyleOptionComplex const * option, SubControl subControl,
|
||||
QWidget const * widget) const
|
||||
{
|
||||
return style->subControlRect(control, option, subControl, widget);
|
||||
}
|
||||
|
||||
QRect ProxyStyle::subElementRect(SubElement element, QStyleOption const * option,
|
||||
QWidget const * widget) const
|
||||
QRect ProxyStyle::subElementRect(SubElement element, QStyleOption const * option, QWidget const * widget) const
|
||||
{
|
||||
return style->subElementRect(element, option, widget);
|
||||
}
|
||||
|
||||
void ProxyStyle::unpolish(QWidget * widget) { style->unpolish(widget); }
|
||||
void ProxyStyle::unpolish(QWidget * widget)
|
||||
{
|
||||
style->unpolish(widget);
|
||||
}
|
||||
|
||||
void ProxyStyle::unpolish(QApplication * app) { style->unpolish(app); }
|
||||
void ProxyStyle::unpolish(QApplication * app)
|
||||
{
|
||||
style->unpolish(app);
|
||||
}
|
||||
|
||||
int ProxyStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
|
||||
Qt::Orientation orientation, QStyleOption const * option,
|
||||
QWidget const * widget) const
|
||||
Qt::Orientation orientation, QStyleOption const * option, QWidget const * widget) const
|
||||
{
|
||||
return style->layoutSpacing(control1, control2, orientation, option, widget);
|
||||
}
|
||||
|
||||
@@ -12,26 +12,22 @@ public:
|
||||
explicit ProxyStyle(QStyle * p);
|
||||
|
||||
// QStyle overrides:
|
||||
void drawComplexControl(ComplexControl control, QStyleOptionComplex const * option,
|
||||
QPainter * painter, QWidget const * widget = 0) const override;
|
||||
void drawComplexControl(ComplexControl control, QStyleOptionComplex const * option, QPainter * painter,
|
||||
QWidget const * widget = 0) const override;
|
||||
void drawControl(ControlElement element, QStyleOption const * option, QPainter * painter,
|
||||
QWidget const * widget = 0) const override;
|
||||
void drawItemPixmap(QPainter * painter, QRect const & rect, int alignment,
|
||||
QPixmap const & pixmap) const override;
|
||||
void drawItemText(QPainter * painter, QRect const & rect, int alignment, QPalette const & pal,
|
||||
bool enabled, QString const & text,
|
||||
QPalette::ColorRole textRole = QPalette::NoRole) const override;
|
||||
void drawItemPixmap(QPainter * painter, QRect const & rect, int alignment, QPixmap const & pixmap) const override;
|
||||
void drawItemText(QPainter * painter, QRect const & rect, int alignment, QPalette const & pal, bool enabled,
|
||||
QString const & text, QPalette::ColorRole textRole = QPalette::NoRole) const override;
|
||||
void drawPrimitive(PrimitiveElement elem, QStyleOption const * option, QPainter * painter,
|
||||
QWidget const * widget = 0) const override;
|
||||
QPixmap generatedIconPixmap(QIcon::Mode iconMode, QPixmap const & pixmap,
|
||||
QStyleOption const * option) const override;
|
||||
SubControl hitTestComplexControl(ComplexControl control, QStyleOptionComplex const * option,
|
||||
QPoint const & pos, QWidget const * widget = 0) const override;
|
||||
QPixmap generatedIconPixmap(QIcon::Mode iconMode, QPixmap const & pixmap, QStyleOption const * option) const override;
|
||||
SubControl hitTestComplexControl(ComplexControl control, QStyleOptionComplex const * option, QPoint const & pos,
|
||||
QWidget const * widget = 0) const override;
|
||||
QRect itemPixmapRect(QRect const & rect, int alignment, QPixmap const & pixmap) const override;
|
||||
QRect itemTextRect(QFontMetrics const & metrics, QRect const & rect, int alignment, bool enabled,
|
||||
QString const & text) const override;
|
||||
int pixelMetric(PixelMetric metric, QStyleOption const * option = 0,
|
||||
QWidget const * widget = 0) const override;
|
||||
int pixelMetric(PixelMetric metric, QStyleOption const * option = 0, QWidget const * widget = 0) const override;
|
||||
void polish(QWidget * widget) override;
|
||||
void polish(QApplication * app) override;
|
||||
void polish(QPalette & pal) override;
|
||||
@@ -44,15 +40,13 @@ public:
|
||||
QWidget const * widget = 0) const override;
|
||||
int styleHint(StyleHint hint, QStyleOption const * option = 0, QWidget const * widget = 0,
|
||||
QStyleHintReturn * returnData = 0) const override;
|
||||
QRect subControlRect(ComplexControl control, QStyleOptionComplex const * option,
|
||||
SubControl subControl, QWidget const * widget = 0) const override;
|
||||
QRect subElementRect(SubElement element, QStyleOption const * option,
|
||||
QRect subControlRect(ComplexControl control, QStyleOptionComplex const * option, SubControl subControl,
|
||||
QWidget const * widget = 0) const override;
|
||||
QRect subElementRect(SubElement element, QStyleOption const * option, QWidget const * widget = 0) const override;
|
||||
void unpolish(QWidget * widget) override;
|
||||
void unpolish(QApplication * app) override;
|
||||
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
|
||||
Qt::Orientation orientation, QStyleOption const * option = 0,
|
||||
QWidget const * widget = 0) const override;
|
||||
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation,
|
||||
QStyleOption const * option = 0, QWidget const * widget = 0) const override;
|
||||
|
||||
private:
|
||||
QStyle * style;
|
||||
|
||||
@@ -67,22 +67,18 @@ void QtRenderOGLContext::Resize(int w, int h)
|
||||
|
||||
if (nw <= m_width && nh <= m_height && m_backFrame != nullptr)
|
||||
{
|
||||
m_frameRect =
|
||||
QRectF(0.0, 0.0, w / static_cast<float>(m_width), h / static_cast<float>(m_height));
|
||||
m_frameRect = QRectF(0.0, 0.0, w / static_cast<float>(m_width), h / static_cast<float>(m_height));
|
||||
return;
|
||||
}
|
||||
|
||||
m_width = nw;
|
||||
m_height = nh;
|
||||
m_frameRect =
|
||||
QRectF(0.0, 0.0, w / static_cast<float>(m_width), h / static_cast<float>(m_height));
|
||||
m_frameRect = QRectF(0.0, 0.0, w / static_cast<float>(m_width), h / static_cast<float>(m_height));
|
||||
|
||||
m_backFrame = std::make_unique<QOpenGLFramebufferObject>(QSize(m_width, m_height),
|
||||
QOpenGLFramebufferObject::Depth);
|
||||
m_frontFrame = std::make_unique<QOpenGLFramebufferObject>(QSize(m_width, m_height),
|
||||
QOpenGLFramebufferObject::Depth);
|
||||
m_acquiredFrame = std::make_unique<QOpenGLFramebufferObject>(QSize(m_width, m_height),
|
||||
QOpenGLFramebufferObject::Depth);
|
||||
m_backFrame = std::make_unique<QOpenGLFramebufferObject>(QSize(m_width, m_height), QOpenGLFramebufferObject::Depth);
|
||||
m_frontFrame = std::make_unique<QOpenGLFramebufferObject>(QSize(m_width, m_height), QOpenGLFramebufferObject::Depth);
|
||||
m_acquiredFrame =
|
||||
std::make_unique<QOpenGLFramebufferObject>(QSize(m_width, m_height), QOpenGLFramebufferObject::Depth);
|
||||
}
|
||||
|
||||
bool QtRenderOGLContext::AcquireFrame()
|
||||
@@ -118,7 +114,8 @@ GLuint QtRenderOGLContext::GetTextureHandle() const
|
||||
}
|
||||
|
||||
QtUploadOGLContext::QtUploadOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface)
|
||||
: m_surface(surface), m_ctx(std::make_unique<QOpenGLContext>())
|
||||
: m_surface(surface)
|
||||
, m_ctx(std::make_unique<QOpenGLContext>())
|
||||
{
|
||||
m_ctx->setFormat(rootContext->format());
|
||||
m_ctx->setShareContext(rootContext);
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
std::mutex m_frameMutex;
|
||||
};
|
||||
|
||||
class QtUploadOGLContext: public dp::OGLContext
|
||||
class QtUploadOGLContext : public dp::OGLContext
|
||||
{
|
||||
public:
|
||||
QtUploadOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface);
|
||||
|
||||
@@ -23,7 +23,7 @@ class MyProxyStyle : public ProxyStyle
|
||||
public:
|
||||
explicit MyProxyStyle(QStyle * parent) : ProxyStyle(parent) {}
|
||||
|
||||
int styleHint(StyleHint hint, const QStyleOption * option, const QWidget * widget,
|
||||
int styleHint(StyleHint hint, QStyleOption const * option, QWidget const * widget,
|
||||
QStyleHintReturn * returnData) const override
|
||||
{
|
||||
if (hint == SH_Slider_AbsoluteSetButtons)
|
||||
@@ -33,8 +33,7 @@ public:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
ScaleSlider::ScaleSlider(Qt::Orientation orient, QWidget * parent)
|
||||
: QSlider(orient, parent), m_factor(20)
|
||||
ScaleSlider::ScaleSlider(Qt::Orientation orient, QWidget * parent) : QSlider(orient, parent), m_factor(20)
|
||||
{
|
||||
setStyle(new MyProxyStyle(style()));
|
||||
SetRange(2, scales::GetUpperScale());
|
||||
@@ -72,6 +71,9 @@ void ScaleSlider::SetPosWithBlockedSignals(double pos)
|
||||
blockSignals(blocked);
|
||||
}
|
||||
|
||||
void ScaleSlider::SetRange(int low, int up) { setRange(low * m_factor, up * m_factor); }
|
||||
void ScaleSlider::SetRange(int low, int up)
|
||||
{
|
||||
setRange(low * m_factor, up * m_factor);
|
||||
}
|
||||
} // namespace common
|
||||
} // namespace qt
|
||||
|
||||
@@ -30,7 +30,8 @@ Spinner::Spinner()
|
||||
setPixmap(m_pixmaps.front());
|
||||
|
||||
m_timer = new QTimer(this /* parent */);
|
||||
connect(m_timer, &QTimer::timeout, [this]() {
|
||||
connect(m_timer, &QTimer::timeout, [this]()
|
||||
{
|
||||
m_progress = (m_progress + 1) % m_pixmaps.size();
|
||||
setPixmap(m_pixmaps[m_progress]);
|
||||
});
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#include "qt/qt_common/text_dialog.hpp"
|
||||
|
||||
#include <QtWidgets/QDialogButtonBox>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QTextEdit>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
|
||||
TextDialog::TextDialog(QWidget * parent, QString const & htmlOrText, QString const & title)
|
||||
: QDialog(parent)
|
||||
TextDialog::TextDialog(QWidget * parent, QString const & htmlOrText, QString const & title) : QDialog(parent)
|
||||
{
|
||||
auto * textEdit = new QTextEdit(this);
|
||||
textEdit->setReadOnly(true);
|
||||
@@ -33,4 +31,7 @@ TextDialog::TextDialog(QWidget * parent, QString const & htmlOrText, QString con
|
||||
resize(parent->size());
|
||||
}
|
||||
|
||||
void TextDialog::OnClose() { reject(); }
|
||||
void TextDialog::OnClose()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
class TextDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TextDialog(QWidget * parent, QString const & htmlOrText, QString const & title = "");
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtWidgets/QFormLayout>
|
||||
#include <QtWidgets/QDialogButtonBox>
|
||||
#include <QtWidgets/QFormLayout>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
||||
namespace qt
|
||||
@@ -96,9 +96,7 @@ void RoutingSettings::LoadSession(Framework & framework)
|
||||
}
|
||||
}
|
||||
|
||||
RoutingSettings::RoutingSettings(QWidget * parent, Framework & framework)
|
||||
: QDialog(parent)
|
||||
, m_framework(framework)
|
||||
RoutingSettings::RoutingSettings(QWidget * parent, Framework & framework) : QDialog(parent), m_framework(framework)
|
||||
{
|
||||
setWindowTitle("Routing settings");
|
||||
QVBoxLayout * layout = new QVBoxLayout(this);
|
||||
|
||||
@@ -17,8 +17,7 @@ void RoutingTurnsVisualizer::Visualize(RoutingManager & routingManager, df::Drap
|
||||
std::vector<m2::PointD> const fakePoly = {turnPoint, turnPoint};
|
||||
static dp::Color const orangeColor = dp::Color(242, 138, 2, 255);
|
||||
|
||||
drape.AddLine(
|
||||
id, df::DrapeApiLineData(fakePoly, orangeColor).Width(7.0f).ShowPoints(true).ShowId());
|
||||
drape.AddLine(id, df::DrapeApiLineData(fakePoly, orangeColor).Width(7.0f).ShowPoints(true).ShowId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +32,8 @@ void RoutingTurnsVisualizer::ClearTurns(df::DrapeApi & drape)
|
||||
std::string RoutingTurnsVisualizer::GetId(routing::turns::TurnItem const & turn)
|
||||
{
|
||||
std::string const maneuver = turn.m_pedestrianTurn == routing::turns::PedestrianDirection::None
|
||||
? DebugPrint(turn.m_turn)
|
||||
: DebugPrint(turn.m_pedestrianTurn);
|
||||
? DebugPrint(turn.m_turn)
|
||||
: DebugPrint(turn.m_pedestrianTurn);
|
||||
|
||||
std::string const index = std::to_string(turn.m_index);
|
||||
|
||||
|
||||
18
qt/ruler.cpp
18
qt/ruler.cpp
@@ -7,7 +7,10 @@
|
||||
|
||||
namespace qt
|
||||
{
|
||||
bool Ruler::IsActive() { return m_isActive; }
|
||||
bool Ruler::IsActive()
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
void Ruler::SetActive(bool status)
|
||||
{
|
||||
@@ -37,13 +40,18 @@ void Ruler::DrawLine(df::DrapeApi & drapeApi)
|
||||
|
||||
drapeApi.RemoveLine(m_id);
|
||||
SetId();
|
||||
drapeApi.AddLine(
|
||||
m_id, df::DrapeApiLineData(m_polyline, lightGreyColor).Width(7.0f).ShowPoints(true).ShowId());
|
||||
drapeApi.AddLine(m_id, df::DrapeApiLineData(m_polyline, lightGreyColor).Width(7.0f).ShowPoints(true).ShowId());
|
||||
}
|
||||
|
||||
void Ruler::EraseLine(df::DrapeApi & drapeApi) { drapeApi.RemoveLine(m_id); }
|
||||
void Ruler::EraseLine(df::DrapeApi & drapeApi)
|
||||
{
|
||||
drapeApi.RemoveLine(m_id);
|
||||
}
|
||||
|
||||
bool Ruler::IsValidPolyline() { return m_polyline.size() > 1; }
|
||||
bool Ruler::IsValidPolyline()
|
||||
{
|
||||
return m_polyline.size() > 1;
|
||||
}
|
||||
|
||||
void Ruler::SetDistance()
|
||||
{
|
||||
|
||||
@@ -37,10 +37,9 @@ bool ParsePoint(std::string_view s, char const * delim, m2::PointD & pt, uint8_t
|
||||
double lat;
|
||||
double lon;
|
||||
uint8_t zoomLevel;
|
||||
if (strings::to_double(*iter, lat) && mercator::ValidLat(lat) && ++iter &&
|
||||
strings::to_double(*iter, lon) && mercator::ValidLon(lon) && ++iter &&
|
||||
strings::to_uint(*iter, zoomLevel) &&
|
||||
zoomLevel >= 1 && zoomLevel <= scales::GetUpperStyleScale())
|
||||
if (strings::to_double(*iter, lat) && mercator::ValidLat(lat) && ++iter && strings::to_double(*iter, lon) &&
|
||||
mercator::ValidLon(lon) && ++iter && strings::to_uint(*iter, zoomLevel) && zoomLevel >= 1 &&
|
||||
zoomLevel <= scales::GetUpperStyleScale())
|
||||
{
|
||||
pt = mercator::FromLatLon(lat, lon);
|
||||
zoom = zoomLevel;
|
||||
@@ -65,8 +64,8 @@ bool ParseRect(std::string_view s, char const * delim, m2::RectD & rect)
|
||||
strings::to_double(*iter, latRigthTop) && mercator::ValidLat(latRigthTop) && ++iter &&
|
||||
strings::to_double(*iter, lonRigthTop) && mercator::ValidLon(lonRigthTop))
|
||||
{
|
||||
rect = m2::RectD(mercator::FromLatLon(latLeftBottom, lonLeftBottom),
|
||||
mercator::FromLatLon(latRigthTop, lonRigthTop));
|
||||
rect =
|
||||
m2::RectD(mercator::FromLatLon(latLeftBottom, lonLeftBottom), mercator::FromLatLon(latRigthTop, lonRigthTop));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -114,15 +113,13 @@ bool ParseRectsStr(std::string const & rectsStr, std::list<m2::RectD> & rects)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Screenshoter::Screenshoter(ScreenshotParams const & screenshotParams, Framework & framework,
|
||||
QOpenGLWidget * widget)
|
||||
Screenshoter::Screenshoter(ScreenshotParams const & screenshotParams, Framework & framework, QOpenGLWidget * widget)
|
||||
: m_screenshotParams(screenshotParams)
|
||||
, m_framework(framework)
|
||||
, m_widget(widget)
|
||||
{
|
||||
m_framework.GetStorage().Subscribe(
|
||||
std::bind(&Screenshoter::OnCountryChanged, this, std::placeholders::_1),
|
||||
[](storage::CountryId const &, downloader::Progress const &) {});
|
||||
m_framework.GetStorage().Subscribe(std::bind(&Screenshoter::OnCountryChanged, this, std::placeholders::_1),
|
||||
[](storage::CountryId const &, downloader::Progress const &) {});
|
||||
}
|
||||
|
||||
void Screenshoter::Start()
|
||||
@@ -137,9 +134,8 @@ void Screenshoter::Start()
|
||||
"\n mode:",
|
||||
m_screenshotParams.m_mode, "\n kml_path:", m_screenshotParams.m_kmlPath,
|
||||
"\n points:", m_screenshotParams.m_points, "\n rects:", m_screenshotParams.m_rects,
|
||||
"\n dst_path:", m_screenshotParams.m_dstPath,
|
||||
"\n width:", m_screenshotParams.m_width, "\n height:", m_screenshotParams.m_height,
|
||||
"\n dpi_scale:", m_screenshotParams.m_dpiScale));
|
||||
"\n dst_path:", m_screenshotParams.m_dstPath, "\n width:", m_screenshotParams.m_width,
|
||||
"\n height:", m_screenshotParams.m_height, "\n dpi_scale:", m_screenshotParams.m_dpiScale));
|
||||
|
||||
if (!Platform::MkDirChecked(m_screenshotParams.m_dstPath))
|
||||
{
|
||||
@@ -224,8 +220,7 @@ void Screenshoter::ProcessNextRect()
|
||||
|
||||
std::string const postfix = "_" + languages::GetCurrentNorm();
|
||||
std::stringstream ss;
|
||||
ss << "rect_" << std::setfill('0') << std::setw(4) << m_itemsCount - m_rectsToProcess.size()
|
||||
<< postfix;
|
||||
ss << "rect_" << std::setfill('0') << std::setw(4) << m_itemsCount - m_rectsToProcess.size() << postfix;
|
||||
|
||||
m_nextScreenshotName = ss.str();
|
||||
|
||||
@@ -235,8 +230,7 @@ void Screenshoter::ProcessNextRect()
|
||||
CHECK(rect.IsValid(), ());
|
||||
|
||||
ChangeState(State::WaitPosition);
|
||||
m_framework.ShowRect(rect, -1 /* maxScale */, false /* animation */,
|
||||
false /* useVisibleViewport */);
|
||||
m_framework.ShowRect(rect, -1 /* maxScale */, false /* animation */, false /* useVisibleViewport */);
|
||||
WaitPosition();
|
||||
}
|
||||
|
||||
@@ -250,8 +244,7 @@ void Screenshoter::ProcessNextPoint()
|
||||
|
||||
std::string const postfix = "_" + languages::GetCurrentNorm();
|
||||
std::stringstream ss;
|
||||
ss << "point_" << std::setfill('0') << std::setw(4) << m_itemsCount - m_pointsToProcess.size()
|
||||
<< postfix;
|
||||
ss << "point_" << std::setfill('0') << std::setw(4) << m_itemsCount - m_pointsToProcess.size() << postfix;
|
||||
|
||||
m_nextScreenshotName = ss.str();
|
||||
|
||||
@@ -305,7 +298,7 @@ void Screenshoter::OnCountryChanged(storage::CountryId countryId)
|
||||
{
|
||||
ChangeState(State::WaitGraphics);
|
||||
auto const kDelay = std::chrono::seconds(3);
|
||||
GetPlatform().RunDelayedTask(Platform::Thread::File, kDelay, [this]{ WaitGraphics(); });
|
||||
GetPlatform().RunDelayedTask(Platform::Thread::File, kDelay, [this] { WaitGraphics(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,16 +321,14 @@ void Screenshoter::OnGraphicsReady()
|
||||
|
||||
void Screenshoter::WaitPosition()
|
||||
{
|
||||
m_framework.NotifyGraphicsReady(
|
||||
[this]() { GetPlatform().RunTask(Platform::Thread::Gui, [this] { OnPositionReady(); }); },
|
||||
false /* needInvalidate */);
|
||||
m_framework.NotifyGraphicsReady([this]()
|
||||
{ GetPlatform().RunTask(Platform::Thread::Gui, [this] { OnPositionReady(); }); }, false /* needInvalidate */);
|
||||
}
|
||||
|
||||
void Screenshoter::WaitGraphics()
|
||||
{
|
||||
m_framework.NotifyGraphicsReady(
|
||||
[this]() { GetPlatform().RunTask(Platform::Thread::Gui, [this] { OnGraphicsReady(); }); },
|
||||
true /* needInvalidate */);
|
||||
m_framework.NotifyGraphicsReady([this]()
|
||||
{ GetPlatform().RunTask(Platform::Thread::Gui, [this] { OnGraphicsReady(); }); }, true /* needInvalidate */);
|
||||
}
|
||||
|
||||
void Screenshoter::SaveScreenshot()
|
||||
@@ -355,9 +346,9 @@ void Screenshoter::SaveScreenshot()
|
||||
ASSERT_EQUAL(framebuffer.width() % screenshotSize.width(), 0, ());
|
||||
ASSERT_EQUAL(framebuffer.height() % screenshotSize.height(), 0, ());
|
||||
QImage screenshot = framebuffer.scaled(screenshotSize);
|
||||
if (!screenshot.save(QString::fromStdString(base::JoinPath(m_screenshotParams.m_dstPath,
|
||||
m_nextScreenshotName + ".png")),
|
||||
"PNG", 100))
|
||||
if (!screenshot.save(
|
||||
QString::fromStdString(base::JoinPath(m_screenshotParams.m_dstPath, m_nextScreenshotName + ".png")), "PNG",
|
||||
100))
|
||||
{
|
||||
ChangeState(State::FileError);
|
||||
return;
|
||||
@@ -373,8 +364,8 @@ void Screenshoter::ChangeState(State newState, std::string const & msg)
|
||||
if (m_screenshotParams.m_statusChangedFn)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "[" << m_itemsCount - GetItemsToProcessCount() << "/" << m_itemsCount
|
||||
<< "] file: " << m_nextScreenshotName << " state: " << DebugPrint(newState);
|
||||
ss << "[" << m_itemsCount - GetItemsToProcessCount() << "/" << m_itemsCount << "] file: " << m_nextScreenshotName
|
||||
<< " state: " << DebugPrint(newState);
|
||||
if (!msg.empty())
|
||||
ss << " msg: " << msg;
|
||||
LOG(LINFO, (ss.str()));
|
||||
|
||||
@@ -43,8 +43,7 @@ struct ScreenshotParams
|
||||
class Screenshoter
|
||||
{
|
||||
public:
|
||||
Screenshoter(ScreenshotParams const & screenshotParams, Framework & framework,
|
||||
QOpenGLWidget * widget);
|
||||
Screenshoter(ScreenshotParams const & screenshotParams, Framework & framework, QOpenGLWidget * widget);
|
||||
|
||||
void Start();
|
||||
|
||||
|
||||
@@ -157,16 +157,12 @@ void SearchPanel::OnEverywhereSearchResults(uint64_t timestamp, search::Results
|
||||
switch (res.GetResultType())
|
||||
{
|
||||
case search::Result::Type::SuggestFromFeature:
|
||||
case search::Result::Type::PureSuggest:
|
||||
showDistance = false;
|
||||
break;
|
||||
case search::Result::Type::PureSuggest: showDistance = false; break;
|
||||
case search::Result::Type::Feature:
|
||||
case search::Result::Type::Postcode:
|
||||
m_pTable->setItem(rowCount, 0, CreateItem(res.GetLocalizedFeatureType()));
|
||||
break;
|
||||
case search::Result::Type::LatLon:
|
||||
m_pTable->setItem(rowCount, 0, CreateItem("LatLon"));
|
||||
break;
|
||||
case search::Result::Type::LatLon: m_pTable->setItem(rowCount, 0, CreateItem("LatLon")); break;
|
||||
}
|
||||
|
||||
if (showDistance)
|
||||
@@ -213,7 +209,7 @@ std::string SearchPanel::GetCurrentInputLocale()
|
||||
{
|
||||
/// @DebugNote
|
||||
// Hardcode search input language.
|
||||
//return "de";
|
||||
// return "de";
|
||||
|
||||
QString loc = QGuiApplication::inputMethod()->locale().name();
|
||||
loc.replace('_', '-');
|
||||
@@ -227,7 +223,7 @@ void SearchPanel::OnSearchTextChanged(QString const & str)
|
||||
{
|
||||
// Pass input query as-is without any normalization.
|
||||
// Otherwise № -> No, and it's unexpectable for the search index.
|
||||
//QString const normalized = str.normalized(QString::NormalizationForm_KC);
|
||||
// QString const normalized = str.normalized(QString::NormalizationForm_KC);
|
||||
std::string const normalized = str.toStdString();
|
||||
|
||||
if (Try3dModeCmd(normalized))
|
||||
@@ -252,42 +248,37 @@ void SearchPanel::OnSearchTextChanged(QString const & str)
|
||||
using namespace search;
|
||||
if (m_mode == Mode::Everywhere)
|
||||
{
|
||||
EverywhereSearchParams params
|
||||
{
|
||||
normalized, GetCurrentInputLocale(), {} /* timeout */, isCategory,
|
||||
// m_onResults
|
||||
[this, timestamp](Results results, std::vector<ProductInfo> /* productInfo */)
|
||||
{
|
||||
OnEverywhereSearchResults(timestamp, std::move(results));
|
||||
}
|
||||
};
|
||||
EverywhereSearchParams params{normalized,
|
||||
GetCurrentInputLocale(),
|
||||
{} /* timeout */,
|
||||
isCategory,
|
||||
// m_onResults
|
||||
[this, timestamp](Results results, std::vector<ProductInfo> /* productInfo */)
|
||||
{ OnEverywhereSearchResults(timestamp, std::move(results)); }};
|
||||
|
||||
if (GetFramework().GetSearchAPI().SearchEverywhere(std::move(params)))
|
||||
StartBusyIndicator();
|
||||
}
|
||||
else if (m_mode == Mode::Viewport)
|
||||
{
|
||||
ViewportSearchParams params
|
||||
ViewportSearchParams params{normalized,
|
||||
GetCurrentInputLocale(),
|
||||
{} /* timeout */,
|
||||
isCategory,
|
||||
// m_onStarted
|
||||
[this]() { StartBusyIndicator(); },
|
||||
// m_onCompleted
|
||||
[this](search::Results results)
|
||||
{
|
||||
normalized, GetCurrentInputLocale(), {} /* timeout */, isCategory,
|
||||
// m_onStarted
|
||||
[this]()
|
||||
{
|
||||
StartBusyIndicator();
|
||||
},
|
||||
// m_onCompleted
|
||||
[this](search::Results results)
|
||||
{
|
||||
// |m_pTable| is not updated here because the OnResults callback is recreated within
|
||||
// SearchAPI when the viewport is changed. Thus a single call to SearchInViewport may
|
||||
// initiate an arbitrary amount of actual search requests with different viewports, and
|
||||
// clearing the table would require additional care (or, most likely, we would need a better
|
||||
// API). This is similar to the Android and iOS clients where we do not show the list of
|
||||
// results in the viewport search mode.
|
||||
GetFramework().FillSearchResultsMarks(true /* clear */, results);
|
||||
StopBusyIndicator();
|
||||
}
|
||||
};
|
||||
// |m_pTable| is not updated here because the OnResults callback is recreated within
|
||||
// SearchAPI when the viewport is changed. Thus a single call to SearchInViewport may
|
||||
// initiate an arbitrary amount of actual search requests with different viewports, and
|
||||
// clearing the table would require additional care (or, most likely, we would need a better
|
||||
// API). This is similar to the Android and iOS clients where we do not show the list of
|
||||
// results in the viewport search mode.
|
||||
GetFramework().FillSearchResultsMarks(true /* clear */, results);
|
||||
StopBusyIndicator();
|
||||
}};
|
||||
|
||||
GetFramework().GetSearchAPI().SearchInViewport(std::move(params));
|
||||
}
|
||||
@@ -299,10 +290,8 @@ void SearchPanel::OnSearchModeChanged(int mode)
|
||||
switch (newMode)
|
||||
{
|
||||
case search::Mode::Everywhere:
|
||||
case search::Mode::Viewport:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
case search::Mode::Viewport: break;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
if (m_mode == newMode)
|
||||
|
||||
@@ -23,4 +23,4 @@ enum class SelectionMode
|
||||
// Should be the last
|
||||
Cancelled,
|
||||
};
|
||||
} // namespace qt
|
||||
} // namespace qt
|
||||
|
||||
@@ -37,13 +37,13 @@ enum
|
||||
KNumberOfColumns
|
||||
};
|
||||
|
||||
#define COLOR_NOTDOWNLOADED Qt::black
|
||||
#define COLOR_ONDISK Qt::darkGreen
|
||||
#define COLOR_INPROGRESS Qt::blue
|
||||
#define COLOR_DOWNLOADFAILED Qt::red
|
||||
#define COLOR_INQUEUE Qt::gray
|
||||
#define COLOR_OUTOFDATE Qt::magenta
|
||||
#define COLOR_MIXED Qt::yellow
|
||||
#define COLOR_NOTDOWNLOADED Qt::black
|
||||
#define COLOR_ONDISK Qt::darkGreen
|
||||
#define COLOR_INPROGRESS Qt::blue
|
||||
#define COLOR_DOWNLOADFAILED Qt::red
|
||||
#define COLOR_INQUEUE Qt::gray
|
||||
#define COLOR_OUTOFDATE Qt::magenta
|
||||
#define COLOR_MIXED Qt::yellow
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -62,474 +62,456 @@ bool DeleteNotUploadedEditsConfirmation()
|
||||
|
||||
namespace qt
|
||||
{
|
||||
UpdateDialog::UpdateDialog(QWidget * parent, Framework & framework)
|
||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
m_framework(framework),
|
||||
m_observerSlotId(0)
|
||||
UpdateDialog::UpdateDialog(QWidget * parent, Framework & framework)
|
||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
|
||||
, m_framework(framework)
|
||||
, m_observerSlotId(0)
|
||||
{
|
||||
setWindowModality(Qt::WindowModal);
|
||||
|
||||
QPushButton * closeButton = new QPushButton(QObject::tr("Close"), this);
|
||||
closeButton->setDefault(true);
|
||||
connect(closeButton, &QAbstractButton::clicked, this, &UpdateDialog::OnCloseClick);
|
||||
|
||||
m_tree = new QTreeWidget(this);
|
||||
m_tree->setColumnCount(KNumberOfColumns);
|
||||
QStringList columnLabels;
|
||||
columnLabels << tr("Country") << tr("Status") << tr("Size") << tr("Matched by") << tr("Rank");
|
||||
m_tree->setHeaderLabels(columnLabels);
|
||||
|
||||
m_tree->setColumnHidden(KColumnIndexPositionInRanking, true);
|
||||
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexCountry, QHeaderView::ResizeToContents);
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexStatus, QHeaderView::ResizeToContents);
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexMatchedBy, QHeaderView::ResizeToContents);
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexPositionInRanking, QHeaderView::ResizeToContents);
|
||||
|
||||
connect(m_tree, &QTreeWidget::itemClicked, this, &UpdateDialog::OnItemClick);
|
||||
|
||||
QHBoxLayout * horizontalLayout = new QHBoxLayout();
|
||||
horizontalLayout->addStretch();
|
||||
horizontalLayout->addWidget(closeButton);
|
||||
|
||||
QLabel * localeLabel = new QLabel(tr("locale:"));
|
||||
QLineEdit * localeEdit = new QLineEdit(this);
|
||||
localeEdit->setText(m_locale.c_str());
|
||||
connect(localeEdit, &QLineEdit::textChanged, this, &UpdateDialog::OnLocaleTextChanged);
|
||||
|
||||
QLabel * queryLabel = new QLabel(tr("search query:"));
|
||||
QLineEdit * queryEdit = new QLineEdit(this);
|
||||
connect(queryEdit, &QLineEdit::textChanged, this, &UpdateDialog::OnQueryTextChanged);
|
||||
|
||||
QGridLayout * inputLayout = new QGridLayout();
|
||||
// widget, row, column
|
||||
inputLayout->addWidget(localeLabel, 0, 0);
|
||||
inputLayout->addWidget(localeEdit, 0, 1);
|
||||
inputLayout->addWidget(queryLabel, 1, 0);
|
||||
inputLayout->addWidget(queryEdit, 1, 1);
|
||||
|
||||
QVBoxLayout * verticalLayout = new QVBoxLayout();
|
||||
verticalLayout->addLayout(inputLayout);
|
||||
verticalLayout->addWidget(m_tree);
|
||||
verticalLayout->addLayout(horizontalLayout);
|
||||
setLayout(verticalLayout);
|
||||
|
||||
setWindowTitle(tr("Geographical Regions"));
|
||||
resize(900, 600);
|
||||
|
||||
// We want to receive all download progress and result events.
|
||||
using namespace std::placeholders;
|
||||
m_observerSlotId = GetStorage().Subscribe(bind(&UpdateDialog::OnCountryChanged, this, _1),
|
||||
bind(&UpdateDialog::OnCountryDownloadProgress, this, _1, _2));
|
||||
}
|
||||
|
||||
UpdateDialog::~UpdateDialog()
|
||||
{
|
||||
// Tell download manager that we're gone.
|
||||
GetStorage().Unsubscribe(m_observerSlotId);
|
||||
}
|
||||
|
||||
/// when user clicks on any map row in the table
|
||||
void UpdateDialog::OnItemClick(QTreeWidgetItem * item, int column)
|
||||
{
|
||||
CountryId const countryId = GetCountryIdByTreeItem(item);
|
||||
|
||||
Storage & st = GetStorage();
|
||||
|
||||
NodeAttrs attrs;
|
||||
st.GetNodeAttrs(countryId, attrs);
|
||||
|
||||
CountriesVec children;
|
||||
st.GetChildren(countryId, children);
|
||||
|
||||
// For group process only click on the column #.
|
||||
if (!children.empty() && column != 1)
|
||||
return;
|
||||
|
||||
switch (attrs.m_status)
|
||||
{
|
||||
setWindowModality(Qt::WindowModal);
|
||||
case NodeStatus::OnDiskOutOfDate:
|
||||
{
|
||||
// Map is already downloaded, so ask user about deleting.
|
||||
QMessageBox ask(this);
|
||||
ask.setIcon(QMessageBox::Question);
|
||||
ask.setText(tr("Do you want to update or delete %1?").arg(countryId.c_str()));
|
||||
QPushButton * const btnUpdate = ask.addButton(tr("Update"), QMessageBox::ActionRole);
|
||||
QPushButton * const btnDelete = ask.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
QPushButton * const btnCancel = ask.addButton(tr("Cancel"), QMessageBox::NoRole);
|
||||
UNUSED_VALUE(btnCancel);
|
||||
|
||||
QPushButton * closeButton = new QPushButton(QObject::tr("Close"), this);
|
||||
closeButton->setDefault(true);
|
||||
connect(closeButton, &QAbstractButton::clicked, this, &UpdateDialog::OnCloseClick);
|
||||
ask.exec();
|
||||
|
||||
m_tree = new QTreeWidget(this);
|
||||
m_tree->setColumnCount(KNumberOfColumns);
|
||||
QStringList columnLabels;
|
||||
columnLabels << tr("Country") << tr("Status") << tr("Size") << tr("Matched by") << tr("Rank");
|
||||
m_tree->setHeaderLabels(columnLabels);
|
||||
QAbstractButton * const res = ask.clickedButton();
|
||||
|
||||
m_tree->setColumnHidden(KColumnIndexPositionInRanking, true);
|
||||
if (res == btnUpdate)
|
||||
st.UpdateNode(countryId);
|
||||
else if (res == btnDelete)
|
||||
{
|
||||
if (!m_framework.HasUnsavedEdits(countryId) || DeleteNotUploadedEditsConfirmation())
|
||||
st.DeleteNode(countryId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexCountry, QHeaderView::ResizeToContents);
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexStatus, QHeaderView::ResizeToContents);
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexMatchedBy, QHeaderView::ResizeToContents);
|
||||
m_tree->header()->setSectionResizeMode(KColumnIndexPositionInRanking,
|
||||
QHeaderView::ResizeToContents);
|
||||
case NodeStatus::OnDisk:
|
||||
{
|
||||
// Map is already downloaded, so ask user about deleting.
|
||||
QMessageBox ask(this);
|
||||
ask.setIcon(QMessageBox::Question);
|
||||
ask.setText(tr("Do you want to delete %1?").arg(countryId.c_str()));
|
||||
QPushButton * const btnDelete = ask.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
QPushButton * const btnCancel = ask.addButton(tr("Cancel"), QMessageBox::NoRole);
|
||||
UNUSED_VALUE(btnCancel);
|
||||
|
||||
connect(m_tree, &QTreeWidget::itemClicked, this, &UpdateDialog::OnItemClick);
|
||||
ask.exec();
|
||||
|
||||
QHBoxLayout * horizontalLayout = new QHBoxLayout();
|
||||
horizontalLayout->addStretch();
|
||||
horizontalLayout->addWidget(closeButton);
|
||||
QAbstractButton * const res = ask.clickedButton();
|
||||
|
||||
QLabel * localeLabel = new QLabel(tr("locale:"));
|
||||
QLineEdit * localeEdit = new QLineEdit(this);
|
||||
localeEdit->setText(m_locale.c_str());
|
||||
connect(localeEdit, &QLineEdit::textChanged, this, &UpdateDialog::OnLocaleTextChanged);
|
||||
if (res == btnDelete)
|
||||
{
|
||||
if (!m_framework.HasUnsavedEdits(countryId) || DeleteNotUploadedEditsConfirmation())
|
||||
st.DeleteNode(countryId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
QLabel * queryLabel = new QLabel(tr("search query:"));
|
||||
QLineEdit * queryEdit = new QLineEdit(this);
|
||||
connect(queryEdit, &QLineEdit::textChanged, this, &UpdateDialog::OnQueryTextChanged);
|
||||
case NodeStatus::NotDownloaded:
|
||||
case NodeStatus::Error:
|
||||
case NodeStatus::Partly: st.DownloadNode(countryId); break;
|
||||
|
||||
QGridLayout * inputLayout = new QGridLayout();
|
||||
// widget, row, column
|
||||
inputLayout->addWidget(localeLabel, 0, 0);
|
||||
inputLayout->addWidget(localeEdit, 0, 1);
|
||||
inputLayout->addWidget(queryLabel, 1, 0);
|
||||
inputLayout->addWidget(queryEdit, 1, 1);
|
||||
case NodeStatus::InQueue:
|
||||
case NodeStatus::Downloading: st.DeleteNode(countryId); break;
|
||||
|
||||
QVBoxLayout * verticalLayout = new QVBoxLayout();
|
||||
verticalLayout->addLayout(inputLayout);
|
||||
verticalLayout->addWidget(m_tree);
|
||||
verticalLayout->addLayout(horizontalLayout);
|
||||
setLayout(verticalLayout);
|
||||
case NodeStatus::Applying:
|
||||
// Do nothing.
|
||||
break;
|
||||
|
||||
setWindowTitle(tr("Geographical Regions"));
|
||||
resize(900, 600);
|
||||
default: ASSERT(false, ("We shouldn't be here")); break;
|
||||
}
|
||||
}
|
||||
|
||||
// We want to receive all download progress and result events.
|
||||
using namespace std::placeholders;
|
||||
m_observerSlotId = GetStorage().Subscribe(bind(&UpdateDialog::OnCountryChanged, this, _1),
|
||||
bind(&UpdateDialog::OnCountryDownloadProgress, this, _1, _2));
|
||||
void UpdateDialog::OnCloseClick()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
void UpdateDialog::OnLocaleTextChanged(QString const & text)
|
||||
{
|
||||
m_locale.assign(text.toStdString());
|
||||
strings::Trim(m_locale);
|
||||
|
||||
RefillTree();
|
||||
}
|
||||
|
||||
void UpdateDialog::OnQueryTextChanged(QString const & text)
|
||||
{
|
||||
m_query.assign(text.toStdString());
|
||||
|
||||
RefillTree();
|
||||
}
|
||||
|
||||
void UpdateDialog::RefillTree()
|
||||
{
|
||||
++m_fillTreeTimestamp;
|
||||
|
||||
string trimmed = m_query;
|
||||
strings::Trim(trimmed);
|
||||
|
||||
if (trimmed.empty())
|
||||
FillTree({} /* filter */, m_fillTreeTimestamp);
|
||||
else
|
||||
StartSearchInDownloader();
|
||||
}
|
||||
|
||||
void UpdateDialog::StartSearchInDownloader()
|
||||
{
|
||||
CHECK(!m_query.empty(), ());
|
||||
|
||||
auto const timestamp = m_fillTreeTimestamp;
|
||||
|
||||
DownloaderSearchParams params{m_query, m_locale,
|
||||
// m_onResults
|
||||
[this, timestamp](DownloaderSearchResults const & results)
|
||||
{
|
||||
Filter filter;
|
||||
for (size_t i = 0; i < results.m_results.size(); ++i)
|
||||
{
|
||||
auto const & res = results.m_results[i];
|
||||
auto const added = filter.emplace(res.m_countryId, make_pair(i + 1, res.m_matchedName));
|
||||
if (!added.second)
|
||||
LOG(LWARNING, ("Duplicate CountryId in results for query:", results.m_query));
|
||||
}
|
||||
|
||||
FillTree(filter, timestamp);
|
||||
}};
|
||||
|
||||
m_framework.GetSearchAPI().SearchInDownloader(std::move(params));
|
||||
}
|
||||
|
||||
void UpdateDialog::FillTree(optional<Filter> const & filter, uint64_t timestamp)
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
|
||||
if (m_fillTreeTimestamp != timestamp)
|
||||
return;
|
||||
|
||||
m_tree->setSortingEnabled(false);
|
||||
m_tree->clear();
|
||||
m_treeItemByCountryId.clear();
|
||||
|
||||
auto const rootId = m_framework.GetStorage().GetRootId();
|
||||
FillTreeImpl(nullptr /* parent */, rootId, filter);
|
||||
|
||||
// Expand the root.
|
||||
ASSERT_EQUAL(m_tree->topLevelItemCount(), 1, ());
|
||||
m_tree->topLevelItem(0)->setExpanded(true);
|
||||
|
||||
m_tree->sortItems(KColumnIndexPositionInRanking, Qt::AscendingOrder);
|
||||
m_tree->setSortingEnabled(true);
|
||||
}
|
||||
|
||||
void UpdateDialog::FillTreeImpl(QTreeWidgetItem * parent, CountryId const & countryId, optional<Filter> const & filter)
|
||||
{
|
||||
CountriesVec children;
|
||||
GetStorage().GetChildren(countryId, children);
|
||||
|
||||
size_t posInRanking = kInvalidPos;
|
||||
string matchedBy;
|
||||
if (filter)
|
||||
{
|
||||
auto const it = filter->find(countryId);
|
||||
if (it != filter->end())
|
||||
{
|
||||
posInRanking = it->second.first;
|
||||
matchedBy = it->second.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
posInRanking = kIrrelevantPos;
|
||||
}
|
||||
|
||||
UpdateDialog::~UpdateDialog()
|
||||
if (children.empty())
|
||||
{
|
||||
// Tell download manager that we're gone.
|
||||
GetStorage().Unsubscribe(m_observerSlotId);
|
||||
}
|
||||
|
||||
/// when user clicks on any map row in the table
|
||||
void UpdateDialog::OnItemClick(QTreeWidgetItem * item, int column)
|
||||
{
|
||||
CountryId const countryId = GetCountryIdByTreeItem(item);
|
||||
|
||||
Storage & st = GetStorage();
|
||||
|
||||
NodeAttrs attrs;
|
||||
st.GetNodeAttrs(countryId, attrs);
|
||||
|
||||
CountriesVec children;
|
||||
st.GetChildren(countryId, children);
|
||||
|
||||
// For group process only click on the column #.
|
||||
if (!children.empty() && column != 1)
|
||||
if (filter && posInRanking == kInvalidPos)
|
||||
return;
|
||||
|
||||
switch (attrs.m_status)
|
||||
{
|
||||
case NodeStatus::OnDiskOutOfDate:
|
||||
{
|
||||
// Map is already downloaded, so ask user about deleting.
|
||||
QMessageBox ask(this);
|
||||
ask.setIcon(QMessageBox::Question);
|
||||
ask.setText(tr("Do you want to update or delete %1?").arg(countryId.c_str()));
|
||||
QPushButton * const btnUpdate = ask.addButton(tr("Update"), QMessageBox::ActionRole);
|
||||
QPushButton * const btnDelete = ask.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
QPushButton * const btnCancel = ask.addButton(tr("Cancel"), QMessageBox::NoRole);
|
||||
UNUSED_VALUE(btnCancel);
|
||||
|
||||
ask.exec();
|
||||
|
||||
QAbstractButton * const res = ask.clickedButton();
|
||||
|
||||
if (res == btnUpdate)
|
||||
st.UpdateNode(countryId);
|
||||
else if (res == btnDelete)
|
||||
{
|
||||
if (!m_framework.HasUnsavedEdits(countryId) || DeleteNotUploadedEditsConfirmation())
|
||||
st.DeleteNode(countryId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NodeStatus::OnDisk:
|
||||
{
|
||||
// Map is already downloaded, so ask user about deleting.
|
||||
QMessageBox ask(this);
|
||||
ask.setIcon(QMessageBox::Question);
|
||||
ask.setText(tr("Do you want to delete %1?").arg(countryId.c_str()));
|
||||
QPushButton * const btnDelete = ask.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
QPushButton * const btnCancel = ask.addButton(tr("Cancel"), QMessageBox::NoRole);
|
||||
UNUSED_VALUE(btnCancel);
|
||||
|
||||
ask.exec();
|
||||
|
||||
QAbstractButton * const res = ask.clickedButton();
|
||||
|
||||
if (res == btnDelete)
|
||||
{
|
||||
if (!m_framework.HasUnsavedEdits(countryId) || DeleteNotUploadedEditsConfirmation())
|
||||
st.DeleteNode(countryId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NodeStatus::NotDownloaded:
|
||||
case NodeStatus::Error:
|
||||
case NodeStatus::Partly:
|
||||
st.DownloadNode(countryId);
|
||||
break;
|
||||
|
||||
case NodeStatus::InQueue:
|
||||
case NodeStatus::Downloading:
|
||||
st.DeleteNode(countryId);
|
||||
break;
|
||||
|
||||
case NodeStatus::Applying:
|
||||
// Do nothing.
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(false, ("We shouldn't be here"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDialog::OnCloseClick()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
void UpdateDialog::OnLocaleTextChanged(QString const & text)
|
||||
{
|
||||
m_locale.assign(text.toStdString());
|
||||
strings::Trim(m_locale);
|
||||
|
||||
RefillTree();
|
||||
}
|
||||
|
||||
void UpdateDialog::OnQueryTextChanged(QString const & text)
|
||||
{
|
||||
m_query.assign(text.toStdString());
|
||||
|
||||
RefillTree();
|
||||
}
|
||||
|
||||
void UpdateDialog::RefillTree()
|
||||
{
|
||||
++m_fillTreeTimestamp;
|
||||
|
||||
string trimmed = m_query;
|
||||
strings::Trim(trimmed);
|
||||
|
||||
if (trimmed.empty())
|
||||
FillTree({} /* filter */, m_fillTreeTimestamp);
|
||||
else
|
||||
StartSearchInDownloader();
|
||||
}
|
||||
|
||||
void UpdateDialog::StartSearchInDownloader()
|
||||
{
|
||||
CHECK(!m_query.empty(), ());
|
||||
|
||||
auto const timestamp = m_fillTreeTimestamp;
|
||||
|
||||
DownloaderSearchParams params{
|
||||
m_query, m_locale,
|
||||
// m_onResults
|
||||
[this, timestamp](DownloaderSearchResults const & results)
|
||||
{
|
||||
Filter filter;
|
||||
for (size_t i = 0; i < results.m_results.size(); ++i)
|
||||
{
|
||||
auto const & res = results.m_results[i];
|
||||
auto const added = filter.emplace(res.m_countryId, make_pair(i + 1, res.m_matchedName));
|
||||
if (!added.second)
|
||||
LOG(LWARNING, ("Duplicate CountryId in results for query:", results.m_query));
|
||||
}
|
||||
|
||||
FillTree(filter, timestamp);
|
||||
}
|
||||
};
|
||||
|
||||
m_framework.GetSearchAPI().SearchInDownloader(std::move(params));
|
||||
}
|
||||
|
||||
void UpdateDialog::FillTree(optional<Filter> const & filter, uint64_t timestamp)
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
|
||||
if (m_fillTreeTimestamp != timestamp)
|
||||
return;
|
||||
|
||||
m_tree->setSortingEnabled(false);
|
||||
m_tree->clear();
|
||||
m_treeItemByCountryId.clear();
|
||||
|
||||
auto const rootId = m_framework.GetStorage().GetRootId();
|
||||
FillTreeImpl(nullptr /* parent */, rootId, filter);
|
||||
|
||||
// Expand the root.
|
||||
ASSERT_EQUAL(m_tree->topLevelItemCount(), 1, ());
|
||||
m_tree->topLevelItem(0)->setExpanded(true);
|
||||
|
||||
m_tree->sortItems(KColumnIndexPositionInRanking, Qt::AscendingOrder);
|
||||
m_tree->setSortingEnabled(true);
|
||||
}
|
||||
|
||||
void UpdateDialog::FillTreeImpl(QTreeWidgetItem * parent, CountryId const & countryId,
|
||||
optional<Filter> const & filter)
|
||||
{
|
||||
CountriesVec children;
|
||||
GetStorage().GetChildren(countryId, children);
|
||||
|
||||
size_t posInRanking = kInvalidPos;
|
||||
string matchedBy;
|
||||
if (filter)
|
||||
{
|
||||
auto const it = filter->find(countryId);
|
||||
if (it != filter->end())
|
||||
{
|
||||
posInRanking = it->second.first;
|
||||
matchedBy = it->second.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
posInRanking = kIrrelevantPos;
|
||||
}
|
||||
|
||||
if (children.empty())
|
||||
{
|
||||
if (filter && posInRanking == kInvalidPos)
|
||||
return;
|
||||
|
||||
QTreeWidgetItem * item = CreateTreeItem(countryId, posInRanking, matchedBy, parent);
|
||||
UpdateRowWithCountryInfo(item, countryId);
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem * item = CreateTreeItem(countryId, posInRanking, matchedBy, parent);
|
||||
UpdateRowWithCountryInfo(item, countryId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (filter && posInRanking != kInvalidPos)
|
||||
{
|
||||
// Filter matches to the group name, do not filter the group.
|
||||
for (auto const & child : children)
|
||||
FillTreeImpl(item, child, {} /* filter */);
|
||||
QTreeWidgetItem * item = CreateTreeItem(countryId, posInRanking, matchedBy, parent);
|
||||
UpdateRowWithCountryInfo(item, countryId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter does not match to the group, but children can.
|
||||
if (filter && posInRanking != kInvalidPos)
|
||||
{
|
||||
// Filter matches to the group name, do not filter the group.
|
||||
for (auto const & child : children)
|
||||
FillTreeImpl(item, child, filter);
|
||||
FillTreeImpl(item, child, {} /* filter */);
|
||||
|
||||
// Drop the item if it has no children.
|
||||
if (filter && item->childCount() == 0 && parent != nullptr)
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter does not match to the group, but children can.
|
||||
for (auto const & child : children)
|
||||
FillTreeImpl(item, child, filter);
|
||||
|
||||
// Drop the item if it has no children.
|
||||
if (filter && item->childCount() == 0 && parent != nullptr)
|
||||
{
|
||||
parent->removeChild(item);
|
||||
item = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/// Changes row's text color
|
||||
void SetRowColor(QTreeWidgetItem & item, QColor const & color)
|
||||
{
|
||||
for (int column = 0; column < item.columnCount(); ++column)
|
||||
item.setForeground(column, color);
|
||||
}
|
||||
|
||||
void UpdateDialog::UpdateRowWithCountryInfo(CountryId const & countryId)
|
||||
{
|
||||
auto const items = GetTreeItemsByCountryId(countryId);
|
||||
for (auto const item : items)
|
||||
UpdateRowWithCountryInfo(item, countryId);
|
||||
}
|
||||
|
||||
void UpdateDialog::UpdateRowWithCountryInfo(QTreeWidgetItem * item, CountryId const & countryId)
|
||||
{
|
||||
Storage const & st = GetStorage();
|
||||
|
||||
QColor rowColor;
|
||||
QString statusString;
|
||||
LocalAndRemoteSize size(0, 0);
|
||||
|
||||
CountriesVec children;
|
||||
st.GetChildren(countryId, children);
|
||||
|
||||
NodeAttrs attrs;
|
||||
st.GetNodeAttrs(countryId, attrs);
|
||||
|
||||
size.first = attrs.m_downloadingProgress.m_bytesDownloaded;
|
||||
size.second = attrs.m_mwmSize;
|
||||
|
||||
switch (attrs.m_status)
|
||||
{
|
||||
case NodeStatus::NotDownloaded:
|
||||
ASSERT(size.second > 0, (countryId));
|
||||
statusString = tr("Click to download");
|
||||
rowColor = COLOR_NOTDOWNLOADED;
|
||||
break;
|
||||
|
||||
case NodeStatus::OnDisk:
|
||||
case NodeStatus::Partly:
|
||||
statusString = tr("Installed (click to delete)");
|
||||
rowColor = COLOR_ONDISK;
|
||||
break;
|
||||
|
||||
case NodeStatus::OnDiskOutOfDate:
|
||||
statusString = tr("Out of date (click to update or delete)");
|
||||
rowColor = COLOR_OUTOFDATE;
|
||||
break;
|
||||
|
||||
case NodeStatus::Error:
|
||||
statusString = tr("Download has failed");
|
||||
rowColor = COLOR_DOWNLOADFAILED;
|
||||
break;
|
||||
|
||||
case NodeStatus::Downloading:
|
||||
statusString = tr("Downloading ...");
|
||||
rowColor = COLOR_INPROGRESS;
|
||||
break;
|
||||
|
||||
case NodeStatus::Applying:
|
||||
statusString = tr("Applying ...");
|
||||
rowColor = COLOR_INPROGRESS;
|
||||
break;
|
||||
|
||||
case NodeStatus::InQueue:
|
||||
statusString = tr("Marked for download");
|
||||
rowColor = COLOR_INQUEUE;
|
||||
break;
|
||||
|
||||
default: ASSERT(false, ("We shouldn't be here")); break;
|
||||
}
|
||||
|
||||
if (!statusString.isEmpty())
|
||||
item->setText(KColumnIndexStatus, statusString);
|
||||
|
||||
if (size.second > 0)
|
||||
{
|
||||
int const halfMb = 512 * 1024;
|
||||
int const Mb = 1024 * 1024;
|
||||
|
||||
if (size.second > Mb)
|
||||
{
|
||||
parent->removeChild(item);
|
||||
item = nullptr;
|
||||
item->setText(KColumnIndexSize,
|
||||
QString("%1/%2 MB").arg(uint((size.first + halfMb) / Mb)).arg(uint((size.second + halfMb) / Mb)));
|
||||
}
|
||||
}
|
||||
|
||||
/// Changes row's text color
|
||||
void SetRowColor(QTreeWidgetItem & item, QColor const & color)
|
||||
{
|
||||
for (int column = 0; column < item.columnCount(); ++column)
|
||||
item.setForeground(column, color);
|
||||
}
|
||||
|
||||
void UpdateDialog::UpdateRowWithCountryInfo(CountryId const & countryId)
|
||||
{
|
||||
auto const items = GetTreeItemsByCountryId(countryId);
|
||||
for (auto const item : items)
|
||||
UpdateRowWithCountryInfo(item, countryId);
|
||||
}
|
||||
|
||||
void UpdateDialog::UpdateRowWithCountryInfo(QTreeWidgetItem * item, CountryId const & countryId)
|
||||
{
|
||||
Storage const & st = GetStorage();
|
||||
|
||||
QColor rowColor;
|
||||
QString statusString;
|
||||
LocalAndRemoteSize size(0, 0);
|
||||
|
||||
CountriesVec children;
|
||||
st.GetChildren(countryId, children);
|
||||
|
||||
NodeAttrs attrs;
|
||||
st.GetNodeAttrs(countryId, attrs);
|
||||
|
||||
size.first = attrs.m_downloadingProgress.m_bytesDownloaded;
|
||||
size.second = attrs.m_mwmSize;
|
||||
|
||||
switch (attrs.m_status)
|
||||
else
|
||||
{
|
||||
case NodeStatus::NotDownloaded:
|
||||
ASSERT(size.second > 0, (countryId));
|
||||
statusString = tr("Click to download");
|
||||
rowColor = COLOR_NOTDOWNLOADED;
|
||||
break;
|
||||
|
||||
case NodeStatus::OnDisk:
|
||||
case NodeStatus::Partly:
|
||||
statusString = tr("Installed (click to delete)");
|
||||
rowColor = COLOR_ONDISK;
|
||||
break;
|
||||
|
||||
case NodeStatus::OnDiskOutOfDate:
|
||||
statusString = tr("Out of date (click to update or delete)");
|
||||
rowColor = COLOR_OUTOFDATE;
|
||||
break;
|
||||
|
||||
case NodeStatus::Error:
|
||||
statusString = tr("Download has failed");
|
||||
rowColor = COLOR_DOWNLOADFAILED;
|
||||
break;
|
||||
|
||||
case NodeStatus::Downloading:
|
||||
statusString = tr("Downloading ...");
|
||||
rowColor = COLOR_INPROGRESS;
|
||||
break;
|
||||
|
||||
case NodeStatus::Applying:
|
||||
statusString = tr("Applying ...");
|
||||
rowColor = COLOR_INPROGRESS;
|
||||
break;
|
||||
|
||||
case NodeStatus::InQueue:
|
||||
statusString = tr("Marked for download");
|
||||
rowColor = COLOR_INQUEUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(false, ("We shouldn't be here"));
|
||||
break;
|
||||
item->setText(KColumnIndexSize,
|
||||
QString("%1/%2 kB").arg(uint((size.first + 1023) / 1024)).arg(uint((size.second + 1023) / 1024)));
|
||||
}
|
||||
|
||||
if (!statusString.isEmpty())
|
||||
item->setText(KColumnIndexStatus, statusString);
|
||||
|
||||
if (size.second > 0)
|
||||
{
|
||||
int const halfMb = 512 * 1024;
|
||||
int const Mb = 1024 * 1024;
|
||||
|
||||
if (size.second > Mb)
|
||||
{
|
||||
item->setText(KColumnIndexSize, QString("%1/%2 MB").arg(
|
||||
uint((size.first + halfMb) / Mb)).arg(uint((size.second + halfMb) / Mb)));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(KColumnIndexSize, QString("%1/%2 kB").arg(
|
||||
uint((size.first + 1023) / 1024)).arg(uint((size.second + 1023) / 1024)));
|
||||
}
|
||||
|
||||
item->setData(KColumnIndexSize, Qt::UserRole, QVariant(static_cast<qint64>(size.second)));
|
||||
}
|
||||
|
||||
// Commented out because it looks terrible on black backgrounds.
|
||||
// if (!statusString.isEmpty())
|
||||
// SetRowColor(*item, rowColor);
|
||||
item->setData(KColumnIndexSize, Qt::UserRole, QVariant(static_cast<qint64>(size.second)));
|
||||
}
|
||||
|
||||
QString UpdateDialog::GetNodeName(CountryId const & countryId)
|
||||
{
|
||||
// QString const text = QString::fromUtf8(GetStorage().CountryName(countryId).c_str()); // ???
|
||||
NodeAttrs attrs;
|
||||
GetStorage().GetNodeAttrs(countryId, attrs);
|
||||
return attrs.m_nodeLocalName.c_str();
|
||||
}
|
||||
// Commented out because it looks terrible on black backgrounds.
|
||||
// if (!statusString.isEmpty())
|
||||
// SetRowColor(*item, rowColor);
|
||||
}
|
||||
|
||||
QTreeWidgetItem * UpdateDialog::CreateTreeItem(CountryId const & countryId, size_t posInRanking,
|
||||
string matchedBy, QTreeWidgetItem * parent)
|
||||
{
|
||||
QString const text = GetNodeName(countryId);
|
||||
QTreeWidgetItem * item = new QTreeWidgetItem(parent, QStringList(text));
|
||||
item->setData(KColumnIndexCountry, Qt::UserRole, QVariant(countryId.c_str()));
|
||||
QString UpdateDialog::GetNodeName(CountryId const & countryId)
|
||||
{
|
||||
// QString const text = QString::fromUtf8(GetStorage().CountryName(countryId).c_str()); // ???
|
||||
NodeAttrs attrs;
|
||||
GetStorage().GetNodeAttrs(countryId, attrs);
|
||||
return attrs.m_nodeLocalName.c_str();
|
||||
}
|
||||
|
||||
auto const pos = QVariant(static_cast<qint64>(posInRanking));
|
||||
item->setData(KColumnIndexPositionInRanking, Qt::DisplayRole, pos);
|
||||
QTreeWidgetItem * UpdateDialog::CreateTreeItem(CountryId const & countryId, size_t posInRanking, string matchedBy,
|
||||
QTreeWidgetItem * parent)
|
||||
{
|
||||
QString const text = GetNodeName(countryId);
|
||||
QTreeWidgetItem * item = new QTreeWidgetItem(parent, QStringList(text));
|
||||
item->setData(KColumnIndexCountry, Qt::UserRole, QVariant(countryId.c_str()));
|
||||
|
||||
auto const matched = QVariant(matchedBy.c_str());
|
||||
item->setData(KColumnIndexMatchedBy, Qt::DisplayRole, matched);
|
||||
auto const pos = QVariant(static_cast<qint64>(posInRanking));
|
||||
item->setData(KColumnIndexPositionInRanking, Qt::DisplayRole, pos);
|
||||
|
||||
if (parent == nullptr)
|
||||
m_tree->addTopLevelItem(item);
|
||||
auto const matched = QVariant(matchedBy.c_str());
|
||||
item->setData(KColumnIndexMatchedBy, Qt::DisplayRole, matched);
|
||||
|
||||
m_treeItemByCountryId.insert(make_pair(countryId, item));
|
||||
if (parent == nullptr)
|
||||
m_tree->addTopLevelItem(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
m_treeItemByCountryId.insert(make_pair(countryId, item));
|
||||
|
||||
vector<QTreeWidgetItem *> UpdateDialog::GetTreeItemsByCountryId(CountryId const & countryId)
|
||||
{
|
||||
vector<QTreeWidgetItem *> res;
|
||||
auto const p = m_treeItemByCountryId.equal_range(countryId);
|
||||
for (auto i = p.first; i != p.second; ++i)
|
||||
res.emplace_back(i->second);
|
||||
return res;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
CountryId UpdateDialog::GetCountryIdByTreeItem(QTreeWidgetItem * item)
|
||||
{
|
||||
return item->data(KColumnIndexCountry, Qt::UserRole).toString().toStdString();
|
||||
}
|
||||
vector<QTreeWidgetItem *> UpdateDialog::GetTreeItemsByCountryId(CountryId const & countryId)
|
||||
{
|
||||
vector<QTreeWidgetItem *> res;
|
||||
auto const p = m_treeItemByCountryId.equal_range(countryId);
|
||||
for (auto i = p.first; i != p.second; ++i)
|
||||
res.emplace_back(i->second);
|
||||
return res;
|
||||
}
|
||||
|
||||
void UpdateDialog::OnCountryChanged(CountryId const & countryId)
|
||||
{
|
||||
UpdateRowWithCountryInfo(countryId);
|
||||
CountryId UpdateDialog::GetCountryIdByTreeItem(QTreeWidgetItem * item)
|
||||
{
|
||||
return item->data(KColumnIndexCountry, Qt::UserRole).toString().toStdString();
|
||||
}
|
||||
|
||||
// Now core does not support callbacks about parent country change, therefore emulate it.
|
||||
auto const items = GetTreeItemsByCountryId(countryId);
|
||||
for (auto const item : items)
|
||||
{
|
||||
for (auto p = item->parent(); p != nullptr; p = p->parent())
|
||||
UpdateRowWithCountryInfo(GetCountryIdByTreeItem(p));
|
||||
}
|
||||
}
|
||||
void UpdateDialog::OnCountryChanged(CountryId const & countryId)
|
||||
{
|
||||
UpdateRowWithCountryInfo(countryId);
|
||||
|
||||
void UpdateDialog::OnCountryDownloadProgress(CountryId const & countryId,
|
||||
downloader::Progress const & progress)
|
||||
{
|
||||
auto const items = GetTreeItemsByCountryId(countryId);
|
||||
for (auto const item : items)
|
||||
{
|
||||
item->setText(KColumnIndexSize, QString("%1%").arg(progress.m_bytesDownloaded * 100 /
|
||||
progress.m_bytesTotal));
|
||||
}
|
||||
}
|
||||
// Now core does not support callbacks about parent country change, therefore emulate it.
|
||||
auto const items = GetTreeItemsByCountryId(countryId);
|
||||
for (auto const item : items)
|
||||
for (auto p = item->parent(); p != nullptr; p = p->parent())
|
||||
UpdateRowWithCountryInfo(GetCountryIdByTreeItem(p));
|
||||
}
|
||||
|
||||
void UpdateDialog::ShowModal()
|
||||
{
|
||||
// If called for the first time.
|
||||
if (!m_tree->topLevelItemCount())
|
||||
FillTree({} /* filter */, m_fillTreeTimestamp);
|
||||
void UpdateDialog::OnCountryDownloadProgress(CountryId const & countryId, downloader::Progress const & progress)
|
||||
{
|
||||
auto const items = GetTreeItemsByCountryId(countryId);
|
||||
for (auto const item : items)
|
||||
item->setText(KColumnIndexSize, QString("%1%").arg(progress.m_bytesDownloaded * 100 / progress.m_bytesTotal));
|
||||
}
|
||||
|
||||
exec();
|
||||
}
|
||||
void UpdateDialog::ShowModal()
|
||||
{
|
||||
// If called for the first time.
|
||||
if (!m_tree->topLevelItemCount())
|
||||
FillTree({} /* filter */, m_fillTreeTimestamp);
|
||||
|
||||
exec();
|
||||
}
|
||||
} // namespace qt
|
||||
|
||||
@@ -25,64 +25,63 @@ class Framework;
|
||||
|
||||
namespace qt
|
||||
{
|
||||
class UpdateDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
class UpdateDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UpdateDialog(QWidget * parent, Framework & framework);
|
||||
virtual ~UpdateDialog();
|
||||
public:
|
||||
explicit UpdateDialog(QWidget * parent, Framework & framework);
|
||||
virtual ~UpdateDialog();
|
||||
|
||||
/// @name Called from downloader to notify GUI
|
||||
//@{
|
||||
void OnCountryChanged(storage::CountryId const & countryId);
|
||||
void OnCountryDownloadProgress(storage::CountryId const & countryId,
|
||||
downloader::Progress const & progress);
|
||||
//@}
|
||||
/// @name Called from downloader to notify GUI
|
||||
//@{
|
||||
void OnCountryChanged(storage::CountryId const & countryId);
|
||||
void OnCountryDownloadProgress(storage::CountryId const & countryId, downloader::Progress const & progress);
|
||||
//@}
|
||||
|
||||
void ShowModal();
|
||||
void ShowModal();
|
||||
|
||||
private slots:
|
||||
void OnItemClick(QTreeWidgetItem * item, int column);
|
||||
void OnCloseClick();
|
||||
void OnLocaleTextChanged(QString const & text);
|
||||
void OnQueryTextChanged(QString const & text);
|
||||
private slots:
|
||||
void OnItemClick(QTreeWidgetItem * item, int column);
|
||||
void OnCloseClick();
|
||||
void OnLocaleTextChanged(QString const & text);
|
||||
void OnQueryTextChanged(QString const & text);
|
||||
|
||||
private:
|
||||
// CountryId to its ranking position and matched string (assuming no duplicates).
|
||||
using Filter = std::unordered_map<storage::CountryId, std::pair<size_t, std::string>>;
|
||||
private:
|
||||
// CountryId to its ranking position and matched string (assuming no duplicates).
|
||||
using Filter = std::unordered_map<storage::CountryId, std::pair<size_t, std::string>>;
|
||||
|
||||
void RefillTree();
|
||||
void StartSearchInDownloader();
|
||||
void RefillTree();
|
||||
void StartSearchInDownloader();
|
||||
|
||||
// Adds only those countries present in |filter|.
|
||||
// Calls whose timestamp is not the latest are discarded.
|
||||
void FillTree(std::optional<Filter> const & filter, uint64_t timestamp);
|
||||
void FillTreeImpl(QTreeWidgetItem * parent, storage::CountryId const & countryId,
|
||||
std::optional<Filter> const & filter);
|
||||
// Adds only those countries present in |filter|.
|
||||
// Calls whose timestamp is not the latest are discarded.
|
||||
void FillTree(std::optional<Filter> const & filter, uint64_t timestamp);
|
||||
void FillTreeImpl(QTreeWidgetItem * parent, storage::CountryId const & countryId,
|
||||
std::optional<Filter> const & filter);
|
||||
|
||||
void UpdateRowWithCountryInfo(storage::CountryId const & countryId);
|
||||
void UpdateRowWithCountryInfo(QTreeWidgetItem * item, storage::CountryId const & countryId);
|
||||
QString GetNodeName(storage::CountryId const & countryId);
|
||||
void UpdateRowWithCountryInfo(storage::CountryId const & countryId);
|
||||
void UpdateRowWithCountryInfo(QTreeWidgetItem * item, storage::CountryId const & countryId);
|
||||
QString GetNodeName(storage::CountryId const & countryId);
|
||||
|
||||
QTreeWidgetItem * CreateTreeItem(storage::CountryId const & countryId, size_t posInRanking,
|
||||
std::string matchedBy, QTreeWidgetItem * parent);
|
||||
std::vector<QTreeWidgetItem *> GetTreeItemsByCountryId(storage::CountryId const & countryId);
|
||||
storage::CountryId GetCountryIdByTreeItem(QTreeWidgetItem *);
|
||||
QTreeWidgetItem * CreateTreeItem(storage::CountryId const & countryId, size_t posInRanking, std::string matchedBy,
|
||||
QTreeWidgetItem * parent);
|
||||
std::vector<QTreeWidgetItem *> GetTreeItemsByCountryId(storage::CountryId const & countryId);
|
||||
storage::CountryId GetCountryIdByTreeItem(QTreeWidgetItem *);
|
||||
|
||||
inline storage::Storage & GetStorage() const { return m_framework.GetStorage(); }
|
||||
inline storage::Storage & GetStorage() const { return m_framework.GetStorage(); }
|
||||
|
||||
QTreeWidget * m_tree;
|
||||
Framework & m_framework;
|
||||
int m_observerSlotId;
|
||||
QTreeWidget * m_tree;
|
||||
Framework & m_framework;
|
||||
int m_observerSlotId;
|
||||
|
||||
// Params of the queries to the search engine.
|
||||
std::string m_query;
|
||||
std::string m_locale = "en";
|
||||
uint64_t m_fillTreeTimestamp = 0;
|
||||
// Params of the queries to the search engine.
|
||||
std::string m_query;
|
||||
std::string m_locale = "en";
|
||||
uint64_t m_fillTreeTimestamp = 0;
|
||||
|
||||
std::unordered_multimap<storage::CountryId, QTreeWidgetItem *> m_treeItemByCountryId;
|
||||
std::unordered_multimap<storage::CountryId, QTreeWidgetItem *> m_treeItemByCountryId;
|
||||
|
||||
DECLARE_THREAD_CHECKER(m_threadChecker);
|
||||
};
|
||||
DECLARE_THREAD_CHECKER(m_threadChecker);
|
||||
};
|
||||
} // namespace qt
|
||||
|
||||
Reference in New Issue
Block a user