Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Starting from clean slate for the UI #23

Merged
merged 39 commits into from
Jan 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
acf367a
Starting from clean slate
DylanVanAssche Dec 22, 2017
5765f25
FirstPage Connection selector
DylanVanAssche Dec 22, 2017
35b8e4c
Enforce gitignore for .pro.user files
DylanVanAssche Dec 22, 2017
7f3805c
FirstPage almost finished
DylanVanAssche Dec 23, 2017
14a15cc
Added GPLv3 license header to all files
DylanVanAssche Dec 23, 2017
8e4709a
Reformatted project file
DylanVanAssche Dec 23, 2017
7880bff
SettingsPage
DylanVanAssche Dec 23, 2017
5da190f
StationSelectorPage
DylanVanAssche Dec 25, 2017
cc44d52
Searching partly works, keyboard loses focus somewhere
DylanVanAssche Dec 25, 2017
c9f7576
Fixed small UI bugs
DylanVanAssche Dec 25, 2017
63c09e4
Bumped version already
DylanVanAssche Dec 25, 2017
465f459
Fixed StationSelectorPage focus loss
DylanVanAssche Dec 26, 2017
e90259a
Small UI bug
DylanVanAssche Dec 26, 2017
3d15f45
improved searching and reduced station map zoom
DylanVanAssche Dec 26, 2017
5f9eb69
Fixed liveboard arrival parsing
DylanVanAssche Dec 26, 2017
b243795
Initial LiveboardPage
DylanVanAssche Dec 26, 2017
a31ccba
Improved LiveBoardPage
DylanVanAssche Dec 26, 2017
e27e5b1
Fixed small bugs + improved LiveboardDelegate
DylanVanAssche Dec 27, 2017
2229b03
Fixed small parsing bugs
DylanVanAssche Dec 27, 2017
68a5636
Moved API instant to harbour-berail file to avoid multiple API instances
DylanVanAssche Dec 27, 2017
4d381a4
Unified GlassButton + initial TripPage
DylanVanAssche Dec 27, 2017
c7ba259
RPM build file delete
DylanVanAssche Dec 27, 2017
e580bbf
TripPage first steps
DylanVanAssche Dec 28, 2017
7c38fba
TripPage improvements
DylanVanAssche Dec 28, 2017
976d23d
First steps to display Vias in TripPage
DylanVanAssche Dec 29, 2017
dfbbef4
Show occupancy level and vias in TripPage
DylanVanAssche Dec 31, 2017
076fc5a
Use SVG images for occupancy
DylanVanAssche Dec 31, 2017
1548a8c
Reformatted GlassButton and GlassStationButton
DylanVanAssche Dec 31, 2017
728f506
Recent connections added
DylanVanAssche Jan 1, 2018
8791908
Touchhint Liveboard + fixed Disturbances text trunication
DylanVanAssche Jan 1, 2018
505887f
Fixed sorting for stations
DylanVanAssche Jan 2, 2018
3d2f9b2
Several bugfixes, improved error handling, init network recovery
DylanVanAssche Jan 3, 2018
990fe6c
Bugfixes, splitted Stop into subclasses
DylanVanAssche Jan 3, 2018
7cf987d
Added network recovery using DBus
DylanVanAssche Jan 3, 2018
be59bd7
Alert the user when via is missed
DylanVanAssche Jan 3, 2018
3d6fe2b
Added beta version of the 'walking' parameter
DylanVanAssche Jan 3, 2018
d2f3b18
Vehicle from Liveboard
DylanVanAssche Jan 4, 2018
02f56c9
Fixed several imports in RELEASE mode
DylanVanAssche Jan 4, 2018
a7d4845
Removed .pro.user file
DylanVanAssche Jan 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed StationSelectorPage focus loss
  • Loading branch information
DylanVanAssche committed Dec 26, 2017
commit 465f4593f591d0a4d5dc4e393f832fd89de28b94
28 changes: 17 additions & 11 deletions qml/pages/StationSelectorPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ Page {
API {
id: api
Component.onCompleted: api.getStations()
onStationsChanged: stationListView.model = api.stations
onStationsChanged: {
stationListView.model = api.stations
}
}

// When set as header of the SilicaListView focus is lost almost on every keystroke
StationSelectorHeader {
id: header
anchors { top: parent.top; left: parent.left; right: parent.right }
onSearchStringChanged: {
_searchString = header.searchString
api.stations.searchName = header.searchString
console.debug("Searching for: " + api.stations.searchName)
}
}

SilicaListView {
id: stationListView
anchors.fill: parent
header: StationSelectorHeader {
id: header
onSearchStringChanged: {
_searchString = header.searchString
api.stations.searchName = header.searchString
console.debug("Searching for: " + api.stations.searchName)
}
onFocusChanged: console.debug("Focus stealing")
}
anchors { top: header.bottom; bottom: parent.bottom; left: parent.left; right: parent.right }
clip: true // Only paint within it's borders
delegate: StationSelectorDelegate {
id: delegate
searchString: _searchString
Expand All @@ -54,4 +59,5 @@ Page {
}
}
}

}
74 changes: 18 additions & 56 deletions src/models/stationlistmodelfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,48 @@

StationListModelFilter::StationListModelFilter()
{
this->setDynamicSortFilter(false); // Dynamic filtering should be deactivated while manipulating the model
this->setSortCaseSensitivity(Qt::CaseInsensitive);
this->setFilterRole(StationListModel::NameRole); // Default Qt::DisplayRole
this->setSortRole(StationListModel::NameRole); // Default Qt::DisplayRole
this->setDynamicSortFilter(true);
}

StationListModelFilter::StationListModelFilter(StationListModel *stationListModel)
{
this->setDynamicSortFilter(false); // Dynamic filtering should be deactivated while manipulating the model
this->setSortCaseSensitivity(Qt::CaseInsensitive);
this->setSourceModel(stationListModel);
this->setFilterRole(StationListModel::NameRole); // Default Qt::DisplayRole
this->setSortRole(StationListModel::NameRole); // Default Qt::DisplayRole
this->setDynamicSortFilter(true);
}

StationListModelFilter::StationListModelFilter(StationListModel *stationListModel, StationListModel::Roles sortRole, StationListModel::Roles filterRole)
{
this->setDynamicSortFilter(false); // Dynamic filtering should be deactivated while manipulating the model
this->setSortCaseSensitivity(Qt::CaseInsensitive);
this->setSourceModel(stationListModel);
this->setSortRole(sortRole);
this->setFilterRole(filterRole);
this->setDynamicSortFilter(true);
}

/*StationListModelFilter::StationListModelFilter(StationListModel* stationListModel)
{
this->setSourceModel(stationListModel);
this->stationListFilter()->setFilterRole(StationListModel::NameRole); // Default Qt::DisplayRole
this->stationListFilter()->setSortRole(StationListModel::NameRole); // Default Qt::DisplayRole
}

StationListModelFilter::StationListModelFilter(StationListModel* stationListModel, StationListModel::Roles sortRole, StationListModel::Roles filterRole)
{
this->setSourceModel(stationListModel);
this->setSortRole(sortRole);
this->setFilterRole(filterRole);
}*/

bool StationListModelFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QModelIndex index = this->sourceModel()->index(sourceRow, 0, sourceParent);
if(index.isValid()) {
QString name = index.data(this->filterRole()).toString();
return name.indexOf(this->searchName()) >= 0;
QVariant rowData = index.data(this->filterRole());
if(this->filterRole() == StationListModel::NameRole && rowData.isValid()) {
QString name = rowData.toString();
return name.indexOf(this->searchName()) >= 0;
}
else if(this->filterRole() == StationListModel::LocationRole && rowData.isValid()) {
QGeoCoordinate location = rowData.value<QGeoCoordinate>();
return location.distanceTo(this->searchLocation()) <= this->maxRadiusLocation();
}
}
return false;


/*switch(this->filterRole())
{
case StationListModel::NameRole:
QString name = this->sourceModel()->data(rowIndex).toString();
return name.indexOf(this->searchName()) > 0;
break;

case StationListModel::LocationRole:
float distance = this->sourceModel()->data(rowIndex).convert(QGeoCoordinate).distanceTo(this->searchLocation());
return distance <= this->maxRadiusLocation();
break;
}*/

/*if(this->filterRole() == StationListModel::NameRole) {
QString name = this->sourceModel()->data(rowIndex).toString();
return name.indexOf(this->searchName()) > 0;
}
return true;*/
}

bool StationListModelFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
/*switch(this->sortRole())
{
case StationListModel::NameRole:
return this->sourceModel()->data(left).toString() < this->sourceModel()->data(right).toString();
break;

case StationListModel::LocationRole:
float distanceLeft = this->sourceModel()->data(left).convert(QGeoCoordinate).distanceTo(this->searchLocation());
float distanceRight = this->sourceModel()->data(right).convert(QGeoCoordinate).distanceTo(this->searchLocation());
return distanceLeft < distanceRight;
break;
}*/
if(this->sortRole() == StationListModel::NameRole) {
return this->sourceModel()->data(left).toString() < this->sourceModel()->data(right).toString();
}
return true;
}

double StationListModelFilter::maxRadiusLocation() const
Expand Down
1 change: 0 additions & 1 deletion src/models/stationlistmodelfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class StationListModelFilter : public QSortFilterProxyModel

protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;

signals:
void searchNameChanged();
Expand Down