diff options
author | Viktor Verebelyi <vviktor2@gmail.com> | 2020-10-08 23:29:07 +0100 |
---|---|---|
committer | Viktor Verebelyi <vviktor2@gmail.com> | 2020-10-08 23:29:07 +0100 |
commit | 5bd3209018a4f548260c1f4d58038bb96cf74d90 (patch) | |
tree | c01d0912dd9dfdff0ed5ea37d016a0a32afec785 | |
parent | caf4951b8417158f9ac16614a15383fae2cbb3fd (diff) | |
download | navit-5bd3209018a4f548260c1f4d58038bb96cf74d90.tar.gz |
improvement:qt5_gui:Levy Improve address & POI search
-rw-r--r-- | navit/gui/qt5_qml/gui_qt5_qml.qrc | 1 | ||||
-rw-r--r-- | navit/gui/qt5_qml/navitpoimodel.cpp | 117 | ||||
-rw-r--r-- | navit/gui/qt5_qml/navitpoimodel.h | 26 | ||||
-rw-r--r-- | navit/gui/qt5_qml/navitsearchmodel.cpp | 539 | ||||
-rw-r--r-- | navit/gui/qt5_qml/navitsearchmodel.h | 137 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/DestinationBar.qml | 61 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/MainLayout.qml | 72 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/SearchDrawer.qml | 263 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/SearchDrawerBreadcrumbs.qml | 225 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/SearchDrawerContextMenu.qml | 22 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/SearchDrawerFavouritesList.qml | 2 | ||||
-rw-r--r-- | navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml | 25 |
12 files changed, 1031 insertions, 459 deletions
diff --git a/navit/gui/qt5_qml/gui_qt5_qml.qrc b/navit/gui/qt5_qml/gui_qt5_qml.qrc index 9bbd72b62..2b6637a4c 100644 --- a/navit/gui/qt5_qml/gui_qt5_qml.qrc +++ b/navit/gui/qt5_qml/gui_qt5_qml.qrc @@ -949,5 +949,6 @@ <file>themes/Levy/SearchDrawerRecentsList.qml</file> <file>themes/Levy/SearchDrawerFavouritesList.qml</file> <file>themes/Levy/SearchDrawerContextMenu.qml</file> + <file>themes/Levy/SearchDrawerBreadcrumbs.qml</file> </qresource> </RCC> diff --git a/navit/gui/qt5_qml/navitpoimodel.cpp b/navit/gui/qt5_qml/navitpoimodel.cpp index 14ca4f006..21f4b6219 100644 --- a/navit/gui/qt5_qml/navitpoimodel.cpp +++ b/navit/gui/qt5_qml/navitpoimodel.cpp @@ -1,19 +1,18 @@ #include "navitpoimodel.h" -POISearchWorker::POISearchWorker (NavitInstance * navit) : +POISearchWorker::POISearchWorker (NavitInstance * navit, QString filter, int screenX, int screenY, int distance) : m_navitInstance(navit), - m_running(false), m_mutex(){ + m_filter(filter), + m_screenX(screenX), + m_screenY(screenY), + m_distance(distance){ } + POISearchWorker::~POISearchWorker (){ qDebug() << "Deleting POISearchWorker"; } -void POISearchWorker::setParameters(QString filter, int screenX, int screenY, int distance){ - m_filter = filter; - m_screenX = screenX; - m_screenY = screenY; - m_distance = distance; -} + void POISearchWorker::run() { struct point p; @@ -53,16 +52,13 @@ void POISearchWorker::run() dbg(lvl_debug, "screenX : %d screenY : %d center is at %x, %x", m_screenX, m_screenY, center.x, center.y); h = mapset_open(navit_get_mapset(m_navitInstance->getNavit())); - m_mutex.lock(); - m_running = true; - while ((m = mapset_next(h, 1)) && m_running) { + + while ((m = mapset_next(h, 1))) { selm = map_selection_dup_pro(sel, pro, map_projection(m)); mr = map_rect_new(m, selm); dbg(lvl_debug, "mr=%p", mr); if (mr) { - // QMutexLocker locker(&m_mutex); - - while ((item = map_rect_get_item(mr)) && m_running) { + while ((item = map_rect_get_item(mr))) { if(!m_filter.isEmpty() && m_filter != item_to_name(item->type)){ continue; } @@ -80,6 +76,13 @@ void POISearchWorker::run() if (item_attr_get(item, attr_label, &attr)) { name = map_convert_string(item->map, attr.u.str); + if(item->type==type_poly_building && item_attr_get(item, attr_house_number, &attr) ) { + if(strcmp(name,map_convert_string_tmp(item->map,attr.u.str))==0) { + g_free(name); + continue; + } + } + QString address = NavitHelper::getAddress(m_navitInstance, c,""); QString label = QString("%0, %1").arg(name).arg(address); QVariantMap coords; @@ -97,22 +100,20 @@ void POISearchWorker::run() emit gotSearchResult(poi); } } + if ( QThread::currentThread()->isInterruptionRequested() ) { + break; + } } map_rect_destroy(mr); } map_selection_destroy(selm); + if ( QThread::currentThread()->isInterruptionRequested() ) { + break; + } } map_selection_destroy(sel); mapset_close(h); - m_mutex.unlock(); -} -void POISearchWorker::stop() { - qDebug() << "Stopping worker"; - m_running = false; - m_mutex.lock(); - m_mutex.unlock(); - qDebug() << "Worker stopped"; } NavitPOIModel::NavitPOIModel(QObject *parent) @@ -127,9 +128,6 @@ NavitPOIModel::~NavitPOIModel(){ void NavitPOIModel::setNavit(NavitInstance * navit){ m_navitInstance = navit; - m_poiWorker = new POISearchWorker(m_navitInstance); - m_poiWorker->setAutoDelete(false); - connect(m_poiWorker, &POISearchWorker::gotSearchResult, this, &NavitPOIModel::receiveSearchResult); } QHash<int, QByteArray> NavitPOIModel::roleNames() const{ @@ -220,58 +218,29 @@ QString NavitPOIModel::getAddressString(struct item *item, int prependPostal) { return address.join(" "); } -void NavitPOIModel::search(QString filter, int screenX, int screenY, int distance){ +void NavitPOIModel::stopWorker(bool clearModel){ if(m_poiWorker){ - m_poiWorker->blockSignals(true); - m_poiWorker->stop(); - qDebug() << "clearing pois"; - + m_poiWorker->requestInterruption(); + m_poiWorker->wait(); + m_poiWorker = nullptr; + } + if(clearModel){ beginResetModel(); m_pois.clear(); m_poiTypes.clear(); endResetModel(); - - m_poiWorker->setParameters(filter, screenX, screenY, distance); - - m_poiWorker->blockSignals(false); - QThreadPool::globalInstance()->start(m_poiWorker); } } -//void NavitPOIModel::receiveSearchResult(QVariantMap poi){ -// qDebug() << "\t" << poi.value("name").toString(); - - -// // if(!m_poiTypes.contains(item_to_name(item->type))){ -// // m_poiTypes << item_to_name(item->type); -// // } - -//// QVariantMap tmpPoi(poi); -// int poiDist = poi.value("distM").toInt(); -//// tmpPoi.insert("distance", NavitHelper::formatDist(poiDist)); -// if(m_pois.size() == 0){ -// beginInsertRows(QModelIndex(), 0, 0); -// m_pois.append(poi); -// endInsertRows(); -// } -// for(int i = 0; i < m_pois.length(); i++){ -// int listDist = m_pois.at(i).value("distance").toInt(); -// if(poiDist >= listDist ){ -// continue; -// } -// beginInsertRows(QModelIndex(), i, i); -// m_pois.append(poi); -// endInsertRows(); -// } -//} -void NavitPOIModel::receiveSearchResult(QVariantMap poi){ - modelMutex.lock(); -// qDebug() << "\t" << poi.value("name").toString() << "\t" << poi.value("distance").toInt(); - +void NavitPOIModel::search(QString filter, int screenX, int screenY, int distance){ + stopWorker(true); - // if(!m_poiTypes.contains(item_to_name(item->type))){ - // m_poiTypes << item_to_name(item->type); - // } + m_poiWorker = new POISearchWorker(m_navitInstance, filter, screenX, screenY, distance); + connect(m_poiWorker, &POISearchWorker::gotSearchResult, this, &NavitPOIModel::receiveSearchResult); + m_poiWorker->start(); +} +void NavitPOIModel::receiveSearchResult(QVariantMap poi){ + modelMutex.lock(); int index = 0; int poiDist = poi.value("distance").toInt(); for(; index < m_pois.length(); index++){ @@ -289,36 +258,48 @@ void NavitPOIModel::receiveSearchResult(QVariantMap poi){ void NavitPOIModel::setAsDestination(int index){ if(m_pois.size() > index){ + stopWorker(); NavitHelper::setDestination(m_navitInstance, m_pois[index]["label"].toString(), m_pois[index]["coords"].toMap()["x"].toInt(), m_pois[index]["coords"].toMap()["y"].toInt()); + stopWorker(true); } } void NavitPOIModel::setAsPosition(int index){ if(m_pois.size() > index){ + stopWorker(); NavitHelper::setPosition(m_navitInstance, m_pois[index]["coords"].toMap()["x"].toInt(), m_pois[index]["coords"].toMap()["y"].toInt()); + stopWorker(true); } } void NavitPOIModel::addAsBookmark(int index){ if(m_pois.size() > index){ + stopWorker(); NavitHelper::addBookmark(m_navitInstance, m_pois[index]["label"].toString(), m_pois[index]["coords"].toMap()["x"].toInt(), m_pois[index]["coords"].toMap()["y"].toInt()); + stopWorker(true); } } void NavitPOIModel::addStop(int index, int position){ if(m_pois.size() > index){ + stopWorker(); NavitHelper::addStop(m_navitInstance, position, m_pois[index]["label"].toString(), m_pois[index]["coords"].toMap()["x"].toInt(), m_pois[index]["coords"].toMap()["y"].toInt()); + stopWorker(true); } } + +void NavitPOIModel::reset(){ + stopWorker(true); +} diff --git a/navit/gui/qt5_qml/navitpoimodel.h b/navit/gui/qt5_qml/navitpoimodel.h index e3b527038..c50a002ca 100644 --- a/navit/gui/qt5_qml/navitpoimodel.h +++ b/navit/gui/qt5_qml/navitpoimodel.h @@ -3,6 +3,7 @@ #include <QAbstractItemModel> #include <QDebug> +#include <QThread> #include <QThreadPool> #include <QRunnable> #include <QMutex> @@ -34,21 +35,17 @@ extern "C" { } -class POISearchWorker : public QObject, public QRunnable +class POISearchWorker : public QThread { Q_OBJECT public: - POISearchWorker (NavitInstance * navit); + POISearchWorker (NavitInstance * navit, QString filter, int screenX, int screenY, int distance); ~POISearchWorker (); - void setParameters(QString filter, int screenX, int screenY, int distance); void run() override; - void stop(); signals: void gotSearchResult(QVariantMap poi); private: NavitInstance * m_navitInstance; - bool m_running; - QMutex m_mutex; QString m_filter; int m_screenX; int m_screenY; @@ -81,14 +78,14 @@ public: QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &child) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - Q_INVOKABLE void search(QString filter, int screenX = -1, int screenY = -1, int distance = 15000); - - Q_INVOKABLE void setAsDestination(int index); - Q_INVOKABLE void setAsPosition(int index); - Q_INVOKABLE void addAsBookmark(int index); - Q_INVOKABLE void addStop(int index, int position); +public slots: + void search(QString filter, int screenX = -1, int screenY = -1, int distance = 15000); + void setAsDestination(int index); + void setAsPosition(int index); + void addAsBookmark(int index); + void addStop(int index, int position); void setNavit(NavitInstance * navit); + void reset(); private slots: void receiveSearchResult(QVariantMap poi); private: @@ -96,7 +93,8 @@ private: NavitInstance *m_navitInstance = nullptr; QStringList m_poiTypes; QString getAddressString(struct item *item, int prependPostal); - POISearchWorker *m_poiWorker; + void stopWorker(bool clearModel = false); + POISearchWorker *m_poiWorker = nullptr; QMutex modelMutex; }; diff --git a/navit/gui/qt5_qml/navitsearchmodel.cpp b/navit/gui/qt5_qml/navitsearchmodel.cpp index d62715c51..4035d1b2f 100644 --- a/navit/gui/qt5_qml/navitsearchmodel.cpp +++ b/navit/gui/qt5_qml/navitsearchmodel.cpp @@ -2,8 +2,141 @@ #include "event.h" +SearchWorker::SearchWorker (NavitInstance * navit, search_list *searchResultList, QString searchQuery, enum attr_type search_type) : + m_navitInstance(navit), + m_searchResultList(searchResultList), + m_searchQuery(searchQuery), + m_search_type(search_type){ + +} + +void SearchWorker::run() +{ + if(m_searchQuery == "" && m_search_type != attr_house_number) + return; + + struct search_list_result *res; + + struct attr attr; + QString label; + QString icon; + + QByteArray qry2 = m_searchQuery.toLocal8Bit(); + attr.u.str = static_cast<char *>(malloc(qry2.size() + 1)); + memcpy ( attr.u.str, qry2.data(), qry2.size() + 1 ); + attr.type = static_cast<enum attr_type>(m_search_type); + + search_list_search(m_searchResultList, &attr, 1); + + int i=0; + while((res=search_list_get_result(m_searchResultList))) { + SearchResult result; + QStringList addressString; + Address address; + + if (res->country) { + label = QString(res->country->name); + icon = res->country->flag; + addressString.append(label); + address.country = label; + } + + if (res->town) { + QString district = ""; + label = res->town->common.town_name; + if(res->town->common.district_name){ + district = QString(" (%1)").arg(res->town->common.district_name); + label.append(district); + } + + icon = "icons/bigcity.png"; + + if (res->town->common.postal_mask) + addressString.append(res->town->common.postal_mask); + else if (res->town->common.postal) + addressString.append(res->town->common.postal); + + struct attr state_attr; + if(attr_generic_get_attr(res->town->common.attrs,nullptr,attr_state_name,&state_attr,nullptr)){ + addressString.append(state_attr.u.str); + } + + if(res->town->common.county_name){ + addressString.append(res->town->common.county_name); + + } + struct attr municipality_attr; + if(attr_generic_get_attr(res->town->common.attrs,nullptr,attr_municipality_name,&municipality_attr,nullptr)){ + addressString.append(municipality_attr.u.str); + } + + addressString.append(label); + + address.town = label; + } + + if (res->street) { + label = QString(res->street->name); + icon = "icons/smallcity.png"; + addressString.append(label); + + if (res->street->common.postal_mask) + addressString.append(res->street->common.postal_mask); + else if (res->street->common.postal) + addressString.append(res->street->common.postal); + + address.street = label; + } + + if (res->house_number) { + QString houseNumber = QString(res->house_number->house_number); + icon = "icons/smallcity.png"; + address.house = label; + + QStringList fullAddress; + for(int i=addressString.size();i-->0;) + { + fullAddress << addressString[i]; + } + label = QString("%0 %1").arg(houseNumber,fullAddress.join(", ")); + addressString.clear(); + } + + if(m_search_type != attr_country_all){ + memcpy(&result.coords, res->c, sizeof result.coords); + } + QStringList reverseAddrStr; + while(!addressString.isEmpty()){ + reverseAddrStr << addressString.takeLast(); + } + + result.index = i; + result.label = label; + result.icon = icon; + result.address = address; + result.addressString = reverseAddrStr.join(", "); + result.distance = "0"; + i++; + emit gotSearchResult(result); + + if ( QThread::currentThread()->isInterruptionRequested() ) { + break; + } + } +} + NavitSearchModel::NavitSearchModel(QObject *parent) { + connect(this, &NavitSearchModel::searchQueryChanged, this, &NavitSearchModel::search); + qRegisterMetaType<SearchResult>("SearchResult"); +} +NavitSearchModel::~NavitSearchModel() +{ + qDebug() << "Deleting NavitSearchModel"; + if(m_searchWorker){ + qDebug() << "Deleting m_searchWorker"; + delete m_searchWorker; + } } @@ -22,18 +155,18 @@ QVariant NavitSearchModel::data(const QModelIndex & index, int role) const { if (index.row() < 0 || index.row() >= m_searchResults.count()) return QVariant(); - const QVariantMap *poi = &m_searchResults.at(index.row()); + const SearchResult *poi = &m_searchResults.at(index.row()); if (role == LabelRole) - return poi->value("label"); + return poi->label; else if (role == NameRole) - return poi->value("label"); + return poi->label; else if (role == IconRole) - return poi->value("icon"); + return poi->icon; else if (role == AddressRole) - return poi->value("address"); + return poi->addressString; else if (role == DistanceRole) - return poi->value("distance"); + return poi->distance; return QVariant(); } @@ -69,159 +202,81 @@ void NavitSearchModel::setNavit(NavitInstance * navit){ m_searchResultList=search_list_new(ms); search_list_set_default_country(); - m_search_type = attr_town_or_district_name; + changeSearchType(SearchTown); } -void NavitSearchModel::handleSearchResult(){ - struct search_list_result *res; - - res=search_list_get_result(m_searchResultList); - if (!res) { - idle_end(); - return; - } - - - QVariantMap result; - QString label; - QString icon; - QStringList address; - - if (res->country) { - label = g_strdup(res->country->name); - icon = res->country->flag; - address.append(label); - } - - if (res->town) { - label = g_strdup(res->town->common.town_name); - icon = "icons/bigcity.png"; - address.append(label); - } - - if (res->street) { - label = g_strdup(res->street->name); - icon = "icons/smallcity.png"; - address.append(label); - } - - - qDebug() << label; - - result.insert("label", label); - result.insert("icon", icon); - - result.insert("address", address.join(", ")); - result.insert("distance", 1); - +void NavitSearchModel::receiveSearchResult(SearchResult result){ beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_searchResults.append(result); endInsertRows(); - - qDebug() << result["label"]; - -} -void NavitSearchModel::idle_cb(NavitSearchModel * searchModel){ - searchModel->handleSearchResult(); -} - -void NavitSearchModel::idle_start(){ - m_idle_cb = callback_new_1(callback_cast(idle_cb), this); - m_event_idle = event_add_idle(50,m_idle_cb); - callback_call_0(m_idle_cb); } - -void NavitSearchModel::idle_end(){ - if (m_event_idle != nullptr) { - event_remove_idle(m_event_idle); - m_event_idle=nullptr; - } - if (m_idle_cb != nullptr) { - callback_destroy(m_idle_cb); - m_idle_cb=nullptr; - } -} - -void NavitSearchModel::search2(QString queryText){ - struct search_list_result *res; - - struct attr attr; - QString label; - QString icon; - - - if(!m_search_type){ - m_search_type = attr_country_all; - } - - attr.u.str = queryText.toUtf8().data(); - attr.type = m_search_type; - - search_list_search(m_searchResultList, &attr, 1); - int count = 0; - +void NavitSearchModel::changeSearchType(enum SearchType searchType, bool restoreQuery){ beginResetModel(); m_searchResults.clear(); endResetModel(); - while((res=search_list_get_result(m_searchResultList))) { - - QVariantMap result; - QStringList address; - - if (res->country) { - label = g_strdup(res->country->name); - icon = res->country->flag; - address.append(label); - } - - if (res->town) { - label = g_strdup(res->town->common.town_name); - icon = "icons/bigcity.png"; - address.append(label); - } - - if (res->street) { - label = g_strdup(res->street->name); - icon = "icons/smallcity.png"; - address.append(label); + m_search_type = searchType; + emit searchTypeChanged(); + + if(restoreQuery){ + switch(m_search_type){ + case SearchCountry: + m_searchQuery = m_searchQueryCountry; + m_searchQueryTown = ""; + m_searchQueryStreet = ""; + m_address.address.country = ""; + m_address.address.town = ""; + m_address.address.street = ""; + m_address.address.house = ""; + break; + case SearchTown: + m_searchQuery = m_searchQueryTown; + m_searchQueryStreet = ""; + m_address.address.town = ""; + m_address.address.street = ""; + m_address.address.house = ""; + break; + case SearchStreet: + m_searchQuery = m_searchQueryStreet; + m_address.address.street = ""; + m_address.address.house = ""; + break; + case SearchHouse: + m_address.address.house = ""; + break; } + emit searchQueryChanged(); + emit addressChanged(); + } +} +enum NavitSearchModel::SearchType NavitSearchModel::getSearchType(){ + return m_search_type; +} - result.insert("label", label); - result.insert("icon", icon); - result.insert("address", address.join(", ")); - - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_searchResults.append(result); - endInsertRows(); - - if (count ++ > 50) { - break; - } - qDebug() << icon << label; +void NavitSearchModel::stopSearchWorker(bool clearModel){ + if(m_searchWorker != nullptr){ + m_searchWorker->requestInterruption(); + m_searchWorker->wait(); + m_searchWorker = nullptr; + } + if(clearModel){ + beginResetModel(); + m_searchResults.clear(); + endResetModel(); } } -void NavitSearchModel::search(QString queryText){ - if(queryText == ""){ +void NavitSearchModel::search(){ + stopSearchWorker(true); + if(m_searchQuery == "" && m_search_type != SearchHouse){ return; } - struct attr attr; - - idle_end(); - - beginResetModel(); - m_searchResults.clear(); - endResetModel(); - - attr.u.str = queryText.toLocal8Bit().data(); - attr.type = m_search_type; - qDebug () << "searching : " << queryText.toLocal8Bit().data(); - search_list_search(m_searchResultList, &attr, 1); - idle_start(); + m_searchWorker = new SearchWorker(m_navitInstance, m_searchResultList,m_searchQuery, static_cast<enum attr_type>(m_search_type)); + connect(m_searchWorker, &SearchWorker::gotSearchResult, this, &NavitSearchModel::receiveSearchResult); + m_searchWorker->start(); } void NavitSearchModel::search_list_set_default_country() { @@ -262,71 +317,130 @@ void NavitSearchModel::search_list_set_default_country() { while((res=search_list_get_result(m_searchResultList))); } } - search_list_select(m_searchResultList, attr_country_all, 0, 0); +// search_list_select(m_searchResultList, attr_country_all, 0, 0); + + m_address.address.country = search_attr.u.str; + emit addressChanged(); + + m_search_type = SearchTown; + searchTypeChanged(); } void NavitSearchModel::select(int index){ - qDebug() << "Select : " << index; + enum attr_type type; + type = static_cast<enum attr_type>(m_search_type); - beginResetModel(); - m_searchResults.clear(); - endResetModel(); + search_list_select(m_searchResultList, type, 0, 0); + search_list_select(m_searchResultList, type, index + 1, 1); - search_list_select(m_searchResultList, m_search_type, 0, 0); - search_list_select(m_searchResultList, m_search_type, index, 1); + SearchResult result = m_searchResults.at(index); + + m_address.address = result.address; + m_address.coords = result.coords; + m_address.addressString = result.addressString; + m_address.label = result.label; + + emit addressChanged(); switch(m_search_type){ - case attr_country_all: - m_search_type = attr_town_or_district_name; + case SearchCountry: + changeSearchType(SearchTown, false); + m_searchQueryCountry = m_searchQuery; break; - case attr_town_or_district_name: - m_search_type = attr_street_name; + case SearchTown: + changeSearchType(SearchStreet, false); + m_searchQueryTown = m_searchQuery; break; - case attr_street_name: - m_search_type = attr_house_number; + case SearchStreet: + changeSearchType(SearchHouse, false); + m_searchQueryStreet = m_searchQuery; break; - case attr_house_number: + case SearchHouse: + setAsDestination(index); + reset(); break; } + m_searchQuery = ""; + emit searchQueryChanged(); } void NavitSearchModel::setAsDestination(int index){ - // if(m_recents.size() > index){ - // NavitHelper::setDestination(m_navitInstance, - // m_recents[index]["label"].toString(), - // m_recents[index]["coords"].toMap()["x"].toInt(), - // m_recents[index]["coords"].toMap()["y"].toInt()); - // } + if(m_searchResults.size() > index){ + stopSearchWorker(); + qDebug() << "Setting destination : " << m_searchResults[index].addressString; + NavitHelper::setDestination(m_navitInstance, + m_searchResults[index].addressString, + m_searchResults[index].coords.x, + m_searchResults[index].coords.y); + stopSearchWorker(true); + } } void NavitSearchModel::addStop(int index, int position){ - // if(m_recents.size() > index){ - // NavitHelper::addStop(m_navitInstance, - // position, - // m_recents[index]["label"].toString(), - // m_recents[index]["coords"].toMap()["x"].toInt(), - // m_recents[index]["coords"].toMap()["y"].toInt()); - // } + if(m_searchResults.size() > index){ + stopSearchWorker(); + NavitHelper::addStop(m_navitInstance, + position, + m_searchResults[index].addressString, + m_searchResults[index].coords.x, + m_searchResults[index].coords.y); + stopSearchWorker(true); + } } void NavitSearchModel::setAsPosition(int index){ - // if(m_recents.size() > index){ - // NavitHelper::setPosition(m_navitInstance, - // m_recents[index]["coords"].toMap()["x"].toInt(), - // m_recents[index]["coords"].toMap()["y"].toInt()); - // } + if(m_searchResults.size() > index){ + stopSearchWorker(); + NavitHelper::setPosition(m_navitInstance, + m_searchResults[index].coords.x, + m_searchResults[index].coords.y); + stopSearchWorker(true); + } } void NavitSearchModel::addAsBookmark(int index){ - // if(m_recents.size() > index){ - // NavitHelper::addBookmark(m_navitInstance, - // m_recents[index]["label"].toString(), - // m_recents[index]["coords"].toMap()["x"].toInt(), - // m_recents[index]["coords"].toMap()["y"].toInt()); - // } + if(m_searchResults.size() > index){ + stopSearchWorker(); + NavitHelper::addBookmark(m_navitInstance, + m_searchResults[index].addressString, + m_searchResults[index].coords.x, + m_searchResults[index].coords.y); + stopSearchWorker(true); + } +} +void NavitSearchModel::setAddressAsDestination(){ + stopSearchWorker(); + NavitHelper::setDestination(m_navitInstance, + m_address.addressString, + m_address.coords.x, + m_address.coords.y); + stopSearchWorker(true); +} +void NavitSearchModel::setAddressAsPosition(){ + stopSearchWorker(); + NavitHelper::setPosition(m_navitInstance, + m_address.coords.x, + m_address.coords.y); + stopSearchWorker(true); +} +void NavitSearchModel::addAddressAsBookmark(){ + stopSearchWorker(); + NavitHelper::addBookmark(m_navitInstance, + m_address.addressString, + m_address.coords.x, + m_address.coords.y); + stopSearchWorker(true); +} +void NavitSearchModel::addAddressStop(int position){ + stopSearchWorker(); + NavitHelper::addStop(m_navitInstance, + position, + m_address.addressString, + m_address.coords.x, + m_address.coords.y); + stopSearchWorker(true); } - void NavitSearchModel::remove(int index) { // if(index < m_recents.size()){ // beginRemoveRows(QModelIndex(), index, index); @@ -334,3 +448,72 @@ void NavitSearchModel::remove(int index) { // endInsertRows(); // } } +void NavitSearchModel::viewAddressOnMap(){ + viewOnMap(m_address); +} +void NavitSearchModel::viewResultOnMap(int index){ + SearchResult result = m_searchResults.at(index); + viewOnMap(result); +} + +void NavitSearchModel::viewOnMap(SearchResult pointMap) { + QList<SearchResult> resultToMap; + resultToMap << pointMap; + searchResultsToMap(resultToMap); + + struct pcoord pc; + pc.x = pointMap.coords.x; + pc.y = pointMap.coords.y; + pc.pro = pointMap.coords.pro; + + navit_set_center(m_navitInstance->getNavit(), &pc, 1); +} + +void NavitSearchModel::searchResultsToMap(QList<SearchResult> results){ + GList* list = nullptr; + GList* p = nullptr; + int results_map_population = 0; + struct attr a; + + for (int i = 0; i < results.size(); ++i) { + SearchResult result = results.at(i); + + struct lcoord coords; + coords.c.x=result.coords.x; + coords.c.y=result.coords.y; + coords.label=strdup(result.addressString.toLocal8Bit()); + list = g_list_prepend(list, &coords); + qDebug() << QString("Adding %1 to the map x : %2 y : %3").arg(coords.label).arg(coords.c.x).arg(coords.c.y); + } + + results_map_population = navit_populate_search_results_map(m_navitInstance->getNavit(), list, nullptr); + + if (list) { + for(p=list; p; p=g_list_next(p)) { + if (((struct lcoord *)(p->data))->label) + g_free(((struct lcoord *)(p->data))->label); + } + } + g_list_free(list); + if(!results_map_population) + return; + + a.type=attr_orientation; + a.u.num=0; + navit_set_attr(m_navitInstance->getNavit(),&a); /* Set orientation to North */ +} + +void NavitSearchModel::reset(){ + stopSearchWorker(true); + + m_search_type = SearchTown; + searchTypeChanged(); + + m_searchQuery = ""; + searchQueryChanged(); + + m_address = SearchResult(); + addressChanged(); + + search_list_set_default_country(); +} diff --git a/navit/gui/qt5_qml/navitsearchmodel.h b/navit/gui/qt5_qml/navitsearchmodel.h index 814dc62a9..bc925576e 100644 --- a/navit/gui/qt5_qml/navitsearchmodel.h +++ b/navit/gui/qt5_qml/navitsearchmodel.h @@ -3,6 +3,11 @@ #include <QAbstractItemModel> #include <QDebug> +#include <QThread> +#include <QThreadPool> +#include <QRunnable> +#include <QMutex> + #include "navitinstance.h" #include "navithelper.h" @@ -25,12 +30,55 @@ extern "C" { #include "country.h" #include "track.h" +#include "graphics.h" } +Q_DECLARE_METATYPE(struct item *) + +struct Address{ + QString country; + QString town; + QString street; + QString house; +}; +struct SearchResult{ + int index; + QString distance; + QString addressString; + QString icon; + QString label; + struct pcoord coords; + struct Address address; +}; + +Q_DECLARE_METATYPE(SearchResult) + +class SearchWorker : public QThread +{ + Q_OBJECT +public: + SearchWorker (NavitInstance * navit, struct search_list *searchResultList, QString searchQuery, enum attr_type search_type); + void run() override; +signals: + void gotSearchResult(SearchResult result); +private: + NavitInstance * m_navitInstance; + struct search_list *m_searchResultList; + QString m_searchQuery; + enum attr_type m_search_type; +}; + class NavitSearchModel : public QAbstractItemModel { Q_OBJECT Q_PROPERTY(NavitInstance * navit MEMBER m_navitInstance WRITE setNavit) + Q_PROPERTY(SearchType currentSearchType READ getSearchType WRITE changeSearchType NOTIFY searchTypeChanged) + Q_PROPERTY(QString searchQuery MEMBER m_searchQuery NOTIFY searchQueryChanged) + Q_PROPERTY(QString country READ getCountry NOTIFY addressChanged) + Q_PROPERTY(QString town READ getTown NOTIFY addressChanged) + Q_PROPERTY(QString street READ getStreet NOTIFY addressChanged) + Q_PROPERTY(QString house READ getHouse NOTIFY addressChanged) + public: enum SearchModelRoles { LabelRole = Qt::UserRole + 1, @@ -40,16 +88,16 @@ public: DistanceRole }; - enum SearchField { - SearchCountry, - SearchTown, - SearchStreet, - SearchHouse + enum SearchType { + SearchCountry = attr_country_all, + SearchTown = attr_town_or_district_name,//attr_town_or_district_name or attr_town_postal + SearchStreet = attr_street_name, + SearchHouse = attr_house_number }; - Q_ENUMS(SearchField) - + Q_ENUMS(SearchType) explicit NavitSearchModel(QObject *parent = 0); + ~NavitSearchModel (); int rowCount(const QModelIndex & parent = QModelIndex()) const override; QHash<int, QByteArray> roleNames() const override; QVariant data(const QModelIndex & index, int role) const override; @@ -61,36 +109,71 @@ public: int columnCount(const QModelIndex &parent = QModelIndex()) const override; void setNavit(NavitInstance * navit); - - Q_INVOKABLE void setAsDestination(int index); - Q_INVOKABLE void setAsPosition(int index); - Q_INVOKABLE void addAsBookmark(int index); - Q_INVOKABLE void addStop(int index, int position); - Q_INVOKABLE void remove(int index); - Q_INVOKABLE void select(int index); - Q_INVOKABLE void search(QString queryText); - Q_INVOKABLE void search2(QString queryText); void search_list_set_default_country(); - static void idle_cb(NavitSearchModel * searchModel); - void handleSearchResult(); - +public slots: + void setAsDestination(int index); + void setAsPosition(int index); + void addAsBookmark(int index); + void addStop(int index, int position); + void setAddressAsDestination(); + void setAddressAsPosition(); + void addAddressAsBookmark(); + void addAddressStop(int position); + void viewAddressOnMap(); + void viewResultOnMap(int index); + void remove(int index); + void select(int index); + void search(); + void reset(); +signals: + void searchTypeChanged(); + void searchQueryChanged(); + void addressChanged(); +private slots: + void receiveSearchResult(SearchResult result); private: NavitInstance *m_navitInstance = nullptr; - QList<QVariantMap> m_searchResults; - QString m_country = "United Kingdom"; - struct callback * m_idle_cb; - struct event_idle * m_event_idle; + QList<SearchResult> m_searchResults; + + QString m_country = "United Kingdom"; struct search_list *m_searchResultList; char *m_country_iso2; - enum attr_type m_search_type; - void update(); - void idle_start(); - void idle_end(); + enum SearchType m_search_type; + + QString m_searchQuery; + QString m_searchQueryCountry; + QString m_searchQueryTown; + QString m_searchQueryStreet; + + SearchResult m_address; + + SearchWorker *m_searchWorker = nullptr; + + void update(); + void stopSearchWorker(bool clearModel = false); void setDefaultCountry(); + void changeSearchType(enum SearchType searchType, bool restoreQuery = true); + void searchResultsToMap(QList<SearchResult> results); + enum SearchType getSearchType(); + + void viewOnMap(SearchResult pointMap); + + QString getCountry(){ + return m_address.address.country; + } + QString getTown(){ + return m_address.address.town; + } + QString getStreet(){ + return m_address.address.street; + } + QString getHouse(){ + return m_address.address.house; + } }; #endif // NAVITSEARCHMODEL_H diff --git a/navit/gui/qt5_qml/themes/Levy/DestinationBar.qml b/navit/gui/qt5_qml/themes/Levy/DestinationBar.qml index 66dcdc084..b18915bcf 100644 --- a/navit/gui/qt5_qml/themes/Levy/DestinationBar.qml +++ b/navit/gui/qt5_qml/themes/Levy/DestinationBar.qml @@ -105,6 +105,8 @@ Item { Text { color: "#ffffff" text: qsTr("Cancel") + anchors.leftMargin: parent.width*0.05 + anchors.rightMargin: parent.width*0.05 font.pixelSize: __root.height / 4 anchors.top: parent.top anchors.bottom: parent.bottom @@ -121,56 +123,6 @@ Item { } Item { - id: routDetailsButtonWrapper - Layout.fillHeight: true - Layout.fillWidth: true - - Rectangle { - color: "#232121" - anchors.fill: parent - } - - Rectangle { - width: 1 - color: "#000000" - anchors.leftMargin: 0 - anchors.topMargin: 0 - anchors.bottom: parent.bottom - anchors.top: parent.top - anchors.left: parent.left - } - - - Rectangle { - width: 1 - color: "#000000" - anchors.topMargin: 0 - anchors.bottom: parent.bottom - anchors.top: parent.top - anchors.right: parent.right - } - - - Text { - color: "#ffffff" - text: qsTr("Route Details") - font.pixelSize: __root.height / 4 - verticalAlignment: Text.AlignVCenter - anchors.top: parent.top - anchors.bottom: parent.bottom - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.WordWrap - anchors.left: parent.left - anchors.right: parent.right - } - - MouseArea { - anchors.fill: parent - onClicked: __root.routeDetailsClicked() - } - } - - Item { id: startButtonWrapper Layout.fillHeight: true Layout.fillWidth: true @@ -251,8 +203,13 @@ Item { } + + + + + + /*##^## Designer { - D{i:0;autoSize:true;height:120;width:1200}D{i:61;anchors_width:240}D{i:59;anchors_x:0;anchors_y:0} -D{i:82;anchors_width:240}D{i:80;anchors_y:0} + D{i:0;autoSize:true;height:120;width:1200} } ##^##*/ diff --git a/navit/gui/qt5_qml/themes/Levy/MainLayout.qml b/navit/gui/qt5_qml/themes/Levy/MainLayout.qml index 05a7268cb..a61d8045a 100644 --- a/navit/gui/qt5_qml/themes/Levy/MainLayout.qml +++ b/navit/gui/qt5_qml/themes/Levy/MainLayout.qml @@ -21,7 +21,7 @@ Item { __root.state = "routeOverview" navit1.pitch = 0; navit1.followVehicle = 0; - navit1.zoomToRoute(); +// navit1.zoomToRoute(); navit1.zoomOut(2); } @@ -56,8 +56,6 @@ Item { NavitMap { id: navit1 - // anchors.left: searchDrawer.right - anchors.leftMargin: 0 anchors.top: parent.top anchors.bottom: parent.bottom @@ -215,14 +213,12 @@ Item { anchors.horizontalCenter: parent.horizontalCenter anchors.bottomMargin: parent.height * 0.05 anchors.bottom: parent.bottom - timeLeft: navitRoute.timeLeft distanceLeft: navitRoute.distance arrivalTime: navitRoute.arrivalTime onSearchButtonClicked: { __root.state = "searchDrawerOpen" - searchDrawer.open() } onMenuButtonClicked: { __root.prevState = __root.state @@ -231,6 +227,7 @@ Item { } + DestinationBar { id: destinationBar height: parent.width > parent.height ? parent.height * 0.15 : parent.width * 0.2 @@ -296,7 +293,7 @@ Item { } Rectangle { - id: rectangle + id: overlay color: "#00000000" visible: false anchors.fill: navit1 @@ -304,11 +301,10 @@ Item { MouseArea { id: mouseArea anchors.fill: parent + preventStealing: true onClicked: { - if(__root.state == "menuDrawerOpen"){ - menuDrawer.close() - } - + menuDrawer.close() + searchDrawer.close() __root.state = "" } } @@ -402,6 +398,8 @@ Item { + + states: [ State { name: "mapControlsVisible" @@ -421,7 +419,7 @@ Item { } PropertyChanges { - target: rectangle + target: overlay // color: parent.width > parent.height ? "#00000000" : "#a6000000" // visible: parent.width < parent.height color: "#a6000000" @@ -450,7 +448,7 @@ Item { } PropertyChanges { - target: rectangle + target: overlay color: "#a6000000" visible: true } @@ -471,7 +469,7 @@ Item { // } PropertyChanges { - target: rectangle + target: overlay color: "#00000000" visible: false } @@ -502,7 +500,7 @@ Item { } PropertyChanges { - target: rectangle + target: overlay color: "#a6000000" visible: true } @@ -511,6 +509,43 @@ Item { target: mouseArea4 enabled: false } + }, + State { + name: "routeOverviewPOIs" + PropertyChanges { + target: overlay + color: "#00000000" + visible: true + } + + PropertyChanges { + target: destinationBar + width: parent.width > parent.height ? parent.height : parent.width + visible: true + } + + PropertyChanges { + target: mapNavigationBar + width: 0 + } + + PropertyChanges { + target: mapControls + x: (parent.width * 0.025) + (mapNavigationBar.height / 2) - (width / 2) + state: "routeOverview" + } + + PropertyChanges { + target: destinationDetailsBar + width: parent.width > parent.height ? parent.height : parent.width + visible: true + } + + PropertyChanges { + target: searchDrawer + x: 0 + visible: true + } } ] @@ -525,13 +560,13 @@ Item { value: true } PropertyAction { - target:rectangle + target:overlay property: "visible" value: true } ParallelAnimation{ ColorAnimation { - target:rectangle + target:overlay } NumberAnimation { property: "x"; @@ -666,7 +701,10 @@ Item { /*##^## Designer { - D{i:0;height:720;width:1280}D{i:4;anchors_x:196}D{i:5;anchors_width:200;anchors_x:196} + D{i:0;height:720;width:1280}D{i:24;anchors_height:200;anchors_width:200}D{i:25;anchors_height:200;anchors_width:200} +D{i:26;anchors_height:200;anchors_width:200}D{i:27;anchors_height:200;anchors_width:200} +D{i:23;anchors_height:200;anchors_width:200}D{i:29;anchors_height:200;anchors_width:200} +D{i:28;anchors_height:200;anchors_width:200}D{i:4;anchors_x:196}D{i:5;anchors_width:200;anchors_x:196} D{i:6;anchors_height:100;anchors_width:100}D{i:7;anchors_height:100;anchors_width:100} D{i:8;anchors_y:109}D{i:10;anchors_height:200;anchors_width:200}D{i:11;anchors_height:100;anchors_width:100} D{i:12;anchors_height:100;anchors_width:100;anchors_y:109}D{i:9;anchors_y:109}D{i:13;anchors_y:109} diff --git a/navit/gui/qt5_qml/themes/Levy/SearchDrawer.qml b/navit/gui/qt5_qml/themes/Levy/SearchDrawer.qml index dd60c9410..2e3863985 100644 --- a/navit/gui/qt5_qml/themes/Levy/SearchDrawer.qml +++ b/navit/gui/qt5_qml/themes/Levy/SearchDrawer.qml @@ -14,14 +14,27 @@ Item { signal closeSearch() signal closeDrawer() - function open() { + function close(){ stackView.clear() stackView.push(mainComponent) - state = "" + searchModel.reset() + navitPoiModel.reset() + __root.state = "" } - Component.onCompleted: { - // backend.setSearchContext("town") + onCloseSearch: { + close() + } + + onCloseDrawer: { + close() + } + + function searchPOIs(filter){ + navitPoiModel.search(filter) + + stackView.push(searchResultsComponents,{results:navitPoiModel}) + __root.state = "poiView" } onStateChanged: { @@ -76,13 +89,7 @@ Item { if(action === "others"){ return; } - - console.log(action + " pois clicked"); - - navitPoiModel.search(action) - - stackView.push(searchResultsComponents,{results:navitPoiModel}) - __root.state = "poiView" + __root.searchPOIs(action); } } @@ -168,7 +175,6 @@ Item { id: mouseArea anchors.fill: parent onClicked: { - __root.state = "" __root.closeSearch() } } @@ -199,14 +205,16 @@ Item { anchors.leftMargin: parent.height/4 anchors.left: parent.left background: Item { } + text:searchModel.searchQuery onPressed: { __root.state = "searchOpen" __root.openSearch() stackView.push(searchResultsComponents,{results:searchModel}) } - onTextChanged: { -// backend.updateSearch(text) - searchModel.search2(text) + Binding{ + target: searchModel + property: "searchQuery" + value: search.text } } @@ -248,7 +256,6 @@ Item { id: mouseArea1 anchors.fill: parent onClicked: { - __root.state = "" __root.closeDrawer() } } @@ -303,9 +310,7 @@ Item { id: mouseArea2 anchors.fill: parent onClicked: { - __root.state = "" __root.closeSearch() - console.log("Back button clicked"); } } } @@ -333,118 +338,156 @@ Item { id: mouseArea3 anchors.fill: parent onClicked: { - __root.state = "" __root.closeDrawer() } } } } - - Item { - id: element2 + Item{ + id:addressWrapper width: parent.width visible: false anchors.topMargin: parent.height * 0.2 anchors.top: searchWrapper.bottom anchors.bottom: parent.bottom + SearchDrawerBreadcrumbs { + id: breadcrumbs + anchors.rightMargin: 13 + anchors.right: viewAddress.left + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.top: parent.top + country: searchModel.country + town: searchModel.town + street: searchModel.street + house: searchModel.house + onCountryClicked: { + searchModel.currentSearchType = NavitSearchModel.SearchCountry + } + onTownClicked: { + searchModel.currentSearchType = NavitSearchModel.SearchTown + } + onStreetClicked: { + searchModel.currentSearchType = NavitSearchModel.SearchStreet + } + onHouseClicked: { - Rectangle { - id: leftBlob - width: height - height: parent.height - color: "#ffffff" - radius: height/2 + } } - - Rectangle { - id: rightBlob + Item { + id: viewAddress width: height - height: parent.height - color: "#ffffff" - radius: height/2 - anchors.rightMargin: -width/2 - anchors.right: breadcrumbs.right - } - - RowLayout { - id: breadcrumbs - width: parent.width - parent.height - anchors.leftMargin: leftBlob.width / 2 - anchors.left: leftBlob.left - anchors.bottom: parent.bottom + anchors.rightMargin: width / 2 anchors.top: parent.top - spacing: 0 + anchors.bottom: parent.bottom + anchors.right: addressMenu.left + anchors.leftMargin: 0 + anchors.topMargin: 0 + visible: searchModel.town Rectangle { - id: rectangle1 color: "#ffffff" - visible: true - Layout.fillHeight: true - Layout.fillWidth: true + radius: height/2 + anchors.fill: parent - Text { - id: element3 - text: qsTr("Country") + Image { + width: height + height: parent.height * 0.75 anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 12 + source: "assets/ionicons/md-arrow-forward.svg" + fillMode: Image.PreserveAspectFit + mipmap: true } } - Rectangle { - id: rectangle2 - color: "#ffffff" - visible: true - Layout.fillHeight: true - Layout.fillWidth: true - - Text { - id: element4 - text: qsTr("Town") - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 12 + MouseArea { + anchors.fill: parent + onClicked: { + __root.closeDrawer() + searchModel.setAddressAsDestination(); } } + } + Item { + id: addressMenu + width: height + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.leftMargin: 0 + anchors.topMargin: 0 Rectangle { - id: rectangle4 + id: rectangle1 color: "#ffffff" - visible: false - Layout.fillHeight: true - Layout.fillWidth: true + radius: height/2 + anchors.fill: parent - Text { - id: element5 - text: qsTr("Street") + Image { + id: image + width: height + height: parent.height * 0.75 anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 12 + source: "qrc:/themes/Levy/assets/ionicons/md-more.svg" + fillMode: Image.PreserveAspectFit + mipmap: true } } - Rectangle { - id: rectangle3 - color: "#ffffff" - visible: false - Layout.fillHeight: true - Layout.fillWidth: true - - Text { - id: element6 - text: qsTr("House") - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 12 + MouseArea { + anchors.fill: parent + onClicked: { + if (mouse.button === Qt.LeftButton) + contextMenu.popup() + } + onPressAndHold: { + if (mouse.source === Qt.MouseEventNotSynthesized) + contextMenu.popup() + } + SearchDrawerContextMenu { + id: contextMenu + onItemClicked: { + switch(action){ + case "addBookmark": + searchModel.addAddressAsBookmark() +// __root.closeDrawer() + break; + case "pois": +// navitPoiModel.search(filter) + +// stackView.push(searchResultsComponents,{results:navitPoiModel}) +// __root.state = "poiView" + return; + case "setPosition": + searchModel.setAddressAsPosition() + __root.closeDrawer() + break; + case "addStop": + searchModel.addAddressStop(0) + __root.closeDrawer() + break; + case "setDestination": + searchModel.setAddressAsDestination() + __root.closeDrawer() + break; + case "view": + searchModel.viewAddressOnMap() + __root.closeDrawer() + break; + case "showResults": + searchModel.viewAddressOnMap() + break; + } + __root.closeDrawer() + } } } - } - } } - } } NavitPOIModel { @@ -468,10 +511,12 @@ Item { if(__root.state == "poiView"){ navitPoiModel.setAsDestination(index) } else if(__root.state == "searchOpen"){ - search.clear() searchModel.select(index) } } + onItemRightClicked: { + searchModel.viewResultOnMap(index) + } } } states: [ @@ -514,9 +559,14 @@ Item { } PropertyChanges { - target: element2 + target: addressWrapper visible: true } + + PropertyChanges { + target: addressMenu + } + }, State { name: "poiView" @@ -573,10 +623,31 @@ Item { + + + + + + + + + + + + /*##^## Designer { - D{i:0;autoSize:true;height:720;width:1000}D{i:15;anchors_height:132.24}D{i:40;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0} -D{i:42;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0}D{i:44;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0} -D{i:38;anchors_height:100;anchors_width:100;anchors_x:"-591";anchors_y:"-25"}D{i:2;anchors_height:200;anchors_width:200} -D{i:49;anchors_height:100;anchors_width:100;anchors_x:"-591";anchors_y:"-25"}D{i:50;anchors_height:200;anchors_width:200} + D{i:0;autoSize:true;height:720;width:1000}D{i:55;anchors_height:200;anchors_width:200} +D{i:56;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0}D{i:57;anchors_height:200;anchors_width:200;anchors_x:"-591";anchors_y:"-25"} +D{i:58;anchors_height:200;anchors_width:200;anchors_x:"-591";anchors_y:"-25"}D{i:59;anchors_height:200;anchors_width:200} +D{i:60;anchors_height:200;anchors_width:200}D{i:61;anchors_height:100;anchors_width:100;anchors_x:"-591";anchors_y:"-25"} +D{i:62;anchors_height:200;anchors_width:200}D{i:54;anchors_height:100;anchors_width:100;anchors_x:"-591";anchors_y:"-25"} +D{i:65;anchors_height:100;anchors_width:100;anchors_x:"-591";anchors_y:"-25"}D{i:66;anchors_height:200;anchors_width:200;anchors_x:"-591";anchors_y:"-25"} +D{i:67;anchors_height:200;anchors_width:200}D{i:38;anchors_height:100;anchors_width:100;anchors_x:"-591";anchors_y:"-25"} +D{i:41;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0}D{i:40;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0} +D{i:43;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0}D{i:42;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0} +D{i:39;anchors_height:"-13.224000000000004";anchors_width:100;anchors_x:"-591";anchors_y:"-25"} +D{i:15;anchors_height:132.24}D{i:2;anchors_height:200;anchors_width:200}D{i:49;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0} +D{i:51;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0}D{i:50;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0} +D{i:53;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0}D{i:52;anchors_height:200;anchors_width:200;anchors_x:"-205";anchors_y:0} } ##^##*/ diff --git a/navit/gui/qt5_qml/themes/Levy/SearchDrawerBreadcrumbs.qml b/navit/gui/qt5_qml/themes/Levy/SearchDrawerBreadcrumbs.qml new file mode 100644 index 000000000..607c63974 --- /dev/null +++ b/navit/gui/qt5_qml/themes/Levy/SearchDrawerBreadcrumbs.qml @@ -0,0 +1,225 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 + +Item { + id:__root + + property string country: "Country" + property string town: "Town" + property string street: "" + property string house: "" + + signal countryClicked() + signal townClicked() + signal streetClicked() + signal houseClicked() + clip: true + + Rectangle { + id: leftBlob + width: height + color: "#ffffff" + radius: height/2 + anchors.top: parent.top + anchors.topMargin: 0 + anchors.bottom: parent.bottom + } + + Rectangle { + id: rightBlob + width: height + color: "#ffffff" + radius: height/2 + anchors.top: parent.top + anchors.topMargin: 0 + anchors.bottom: parent.bottom + anchors.bottomMargin: 0 + anchors.rightMargin: -width/2 + anchors.right: breadcrumbs.right + + Rectangle { + width: parent.width/2 + height: parent.height + color: "#ffffff" + } + } + + RowLayout { + id: breadcrumbs + width: parent.width - parent.height + anchors.leftMargin: leftBlob.width / 2 + anchors.left: leftBlob.left + anchors.bottom: parent.bottom + anchors.top: parent.top + spacing: 0 + + Item { + id: countryCrumb + visible: true + Layout.fillHeight: true + Layout.fillWidth: true + Rectangle { + width: height + height: parent.height + color: "#ffffff" + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + transformOrigin: Item.Center + rotation: 45 + } + + Rectangle { + anchors.fill: parent + anchors.rightMargin: height/2 + + Text { + id: element3 + text: __root.country + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 12 + } + MouseArea { + anchors.fill: parent + onClicked: { + __root.countryClicked(); + } + } + } + + } + + Item { + id: townCrumb + visible: (__root.town) + Layout.fillHeight: true + Layout.fillWidth: true + Rectangle { + y: -height + width: height + height: parent.height + color: "#ffffff" + transformOrigin: Item.BottomLeft + rotation: 45 + } + + Rectangle { + width: height + height: parent.height + color: "#ffffff" + transformOrigin: Item.BottomLeft + rotation: 45 + } + + Rectangle { + width: height + height: parent.height + color: "#ffffff" + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + transformOrigin: Item.Center + rotation: 45 + } + + Rectangle { + anchors.fill: parent + color: "#ffffff" + anchors.leftMargin: height/2 + anchors.rightMargin: height/2 + + Text { + id: element4 + text: __root.town + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 12 + } + + MouseArea { + anchors.fill: parent + onClicked: { + __root.townClicked() + } + } + + } + } + + Item { + id: streetCrumb + visible: (__root.street) + Layout.fillHeight: true + Layout.fillWidth: true + Rectangle { + y: -height + width: height + height: parent.height + color: "#ffffff" + transformOrigin: Item.BottomLeft + rotation: 45 + } + + Rectangle { + width: height + height: parent.height + color: "#ffffff" + transformOrigin: Item.BottomLeft + rotation: 45 + } + + Rectangle { + anchors.fill: parent + color: "#ffffff" + anchors.leftMargin: height/2 + + Text { + id: element5 + text: __root.street + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 12 + } + MouseArea { + anchors.fill: parent + onClicked: { + __root.streetClicked(); + } + } + } + + + } + + Item { + id: houseCrumb + visible: false + Layout.fillHeight: true + Layout.fillWidth: true + Rectangle { + anchors.fill: parent + color: "#ffffff" + + Text { + id: element6 + text: qsTr("House") + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 12 + } + } + } + } + + +} + + + + + + +/*##^## Designer { + D{i:0;autoSize:true;height:50;width:640} +} + ##^##*/ diff --git a/navit/gui/qt5_qml/themes/Levy/SearchDrawerContextMenu.qml b/navit/gui/qt5_qml/themes/Levy/SearchDrawerContextMenu.qml index e8497ebb1..8841ecbd8 100644 --- a/navit/gui/qt5_qml/themes/Levy/SearchDrawerContextMenu.qml +++ b/navit/gui/qt5_qml/themes/Levy/SearchDrawerContextMenu.qml @@ -6,16 +6,25 @@ import QtQuick.Layouts 1.3 Menu { id: __root signal itemClicked(var action) - property alias addBookmarkVisible : addBookmark.visible + property alias setDestination : setDestination.visible + property alias addStop : addStop.visible + property alias setPosition : setPosition.visible + property alias addBookmark : addBookmark.visible + property alias pois : pois.visible + property alias view : view.visible + property alias showResults : showResults.visible MenuItem { + id: setDestination text: "Set as destination" onClicked: __root.itemClicked("setDestination") } MenuItem { + id: addStop text: "Add a stop" onClicked: __root.itemClicked("addStop") } MenuItem { + id: setPosition text: "Set as position" onClicked: __root.itemClicked("setPosition") } @@ -26,7 +35,18 @@ Menu { onClicked: __root.itemClicked("addBookmark") } MenuItem { + id: pois text: "POIs" onClicked: __root.itemClicked("pois") } + MenuItem { + id: view + text: "View on Map" + onClicked: __root.itemClicked("view") + } + MenuItem { + id: showResults + text: "Show results on Map" + onClicked: __root.itemClicked("showResults") + } } diff --git a/navit/gui/qt5_qml/themes/Levy/SearchDrawerFavouritesList.qml b/navit/gui/qt5_qml/themes/Levy/SearchDrawerFavouritesList.qml index 2d8c0baf6..8dba5a329 100644 --- a/navit/gui/qt5_qml/themes/Levy/SearchDrawerFavouritesList.qml +++ b/navit/gui/qt5_qml/themes/Levy/SearchDrawerFavouritesList.qml @@ -50,7 +50,7 @@ ListView { } SearchDrawerContextMenu { id: contextMenu - addBookmarkVisible: false + addBookmark: false onItemClicked: { switch(action){ case "addBookmark": diff --git a/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml b/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml index 188a777e3..424c73acb 100644 --- a/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml +++ b/navit/gui/qt5_qml/themes/Levy/SearchDrawerSearchResults.qml @@ -7,6 +7,7 @@ import "icons.js" as Icons Item { id: __root signal itemClicked (var index) + signal itemRightClicked (var index) property alias results : listView.model property int boxRadius : 10 clip: true @@ -26,6 +27,7 @@ Item { anchors.bottomMargin: parent.height * 0.05 anchors.leftMargin: parent.width * 0.05 anchors.rightMargin: parent.width * 0.05 + currentIndex: -1 delegate: Item { id: element height: 80 @@ -78,17 +80,30 @@ Item { MouseArea { id: mouseArea anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { - __root.itemClicked(index) + if(mouse.button === Qt.LeftButton){ + __root.itemClicked(index) + } + if(mouse.button === Qt.RightButton){ + __root.itemRightClicked(index) + } } - - Rectangle { - color: "#33cb0b0b" - anchors.fill: parent + onEntered: { + listView.currentIndex = index + } + onPressed: { + listView.currentIndex = index + } + onReleased: { + listView.currentIndex = -1 } } } + highlight: Rectangle { + color: "lightsteelblue" + } } |