diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index e2d5bf7..ea36732 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/data/qml/LocationCityPicker.qml b/data/qml/LocationCityPicker.qml index 355dc49..e493006 100644 --- a/data/qml/LocationCityPicker.qml +++ b/data/qml/LocationCityPicker.qml @@ -18,6 +18,7 @@ */ import QtQuick 2.2 +import QtQuick.Controls 1.4 StelDialog { id: root @@ -27,9 +28,23 @@ StelDialog { property string country property string city + TextField{ + id: citySearchField + anchors.left: parent.left + width: root.country ? root.width / 2 : root.width + onTextChanged: { + if (text.length > 0 ) { + root.applyFilter(text); + } else { + root.reload(); + } + } + } + ListView { id: countriesList anchors.left: parent.left + anchors.top: citySearchField.bottom width: root.country ? root.width / 2 : root.width Behavior on width { NumberAnimation { easing.type: Easing.InOutQuad } @@ -41,20 +56,22 @@ StelDialog { selected: root.country === modelData onClicked: root.country = modelData } - model: stellarium.getCountryNames() - clip: true + model: stellarium.getCountryNames() + clip: true } ListView { + id: citiesList + anchors.top: citySearchField.bottom anchors.left: countriesList.right anchors.right: parent.right - height: root.height + height: root.height delegate: StelListItem { withArrow: false text: qsTr(modelData) selected: root.city === modelData onClicked: root.city = modelData } - model: stellarium.getCityNames(root.country) + model: stellarium.getCityNames(root.country, "") clip: true } @@ -63,4 +80,23 @@ StelDialog { stellarium.location = "%1, %2".arg(city).arg(country) close(); } + + function reload() { + var cList = stellarium.getCountryNames(); + var temp = []; + for (var i = 0; i < cList.length; i++){ + temp.push(cList[i]) + } + countriesList.model = temp; + } + function applyFilter(cName){ + var cList = stellarium.getCountryNames(); + var temp = []; + for (var i = 0; i < cList.length; i++) + { + if (cList[i].includes(cName)) + temp.push(cList[i]) + } + countriesList.model = temp; + } } diff --git a/src/StelQuickStelItem.cpp b/src/StelQuickStelItem.cpp index abeb5aa..07a8741 100644 --- a/src/StelQuickStelItem.cpp +++ b/src/StelQuickStelItem.cpp @@ -397,20 +397,46 @@ QStringList StelQuickStelItem::getCountryNames() const return ret; } -QStringList StelQuickStelItem::getCityNames(const QString& country) const +QStringList StelQuickStelItem::getCityNames(const QString& country, const QString& search) const { QStringList ret; if (country.isEmpty()) return ret; QList allLocations = StelApp::getInstance().getLocationMgr().getAll(); foreach(const StelLocation& loc, allLocations) { - if (loc.country == country) - ret << loc.name; + if (loc.country == country) + { + if (search.isEmpty()) + { + ret << loc.name; + } + else + { + if (loc.name.contains(search)) + ret << loc.name; + } + } } ret.sort(); return ret; } +bool StelQuickStelItem::testCityNames(const QString& country, const QString& search) const +{ + if (country.isEmpty()) return false; + if (search.isEmpty()) return true; + QList allLocations = StelApp::getInstance().getLocationMgr().getAll(); + foreach(const StelLocation& loc, allLocations) + { + if (loc.country == country) + { + if (loc.name.contains(search)) + return true; + } + } + return false; +} + QString StelQuickStelItem::getLocation() const { StelCore* core = StelApp::getInstance().getCore(); diff --git a/src/StelQuickStelItem.hpp b/src/StelQuickStelItem.hpp index b37f595..234564f 100644 --- a/src/StelQuickStelItem.hpp +++ b/src/StelQuickStelItem.hpp @@ -94,7 +94,8 @@ class StelQuickStelItem : public QQuickItem QString getCurrentSkyCultureHtmlDescription() const; QString getCurrentSkyCultureBaseUrl() const; Q_INVOKABLE QStringList getCountryNames() const; - Q_INVOKABLE QStringList getCityNames(const QString& country) const; + Q_INVOKABLE QStringList getCityNames(const QString& country, const QString& search) const; + Q_INVOKABLE bool testCityNames(const QString& country, const QString& search) const; QString getLocation() const; void setLocation(const QString locationId); double getLatitude() const; diff --git a/stellarium.pro b/stellarium.pro index 83db035..c9b627a 100644 --- a/stellarium.pro +++ b/stellarium.pro @@ -1,7 +1,7 @@ TARGET = stellarium VERSION = 0.12.3 -MOBILE_VERSION = 1.24.2 +MOBILE_VERSION = 1.24.3 INCLUDEPATH += \ . src/ src/core src/core/modules src/core/external \ src/core/external/glues_stel/source src/core/external/kfilter \