summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-10-16 16:01:48 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-23 15:10:03 +0200
commit84b4281cc26fcc0aa8fa3b2693ee212e7c4e7e7e (patch)
tree77ed7304aae81dfa0a8f2c771b5a90536fc7ae0b
parent6dd607c40b449ea9864f615af5e46f447619d651 (diff)
Add the wind direction for accessibility
Change-Id: I6de63d01c21aabd8e00c750c987300ecf610a758 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com> Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
-rw-r--r--qml/js/utils.js7
-rw-r--r--qml/models/WeatherModel.qml1
-rw-r--r--qml/pages/OneDayZoomItem.qml2
-rw-r--r--src/daymodel.cpp8
-rw-r--r--src/daymodel.h8
5 files changed, 20 insertions, 6 deletions
diff --git a/qml/js/utils.js b/qml/js/utils.js
index 9333062..9426cff 100644
--- a/qml/js/utils.js
+++ b/qml/js/utils.js
@@ -163,7 +163,7 @@ function updateDayModel(dayModel, item)
{
var windIconUrl = getWindSymbolUrl(item.windSpeed, item.windDirectionDeg)
var weatherUrl = extractSymbolUrl(item.symbolcode)
- dayModel.addRow(weatherUrl, item.from, item.to, item.temperature, item.windSpeed, windIconUrl, item.rain, item.period)
+ dayModel.addRow(weatherUrl, item.from, item.to, item.temperature, item.windSpeed, item.windDirectionName, windIconUrl, item.rain, item.period)
}
function getItemDate(item)
@@ -254,6 +254,11 @@ function getWindSpeed(index, dayModel)
return isMetricSystem() ? speed_ms : Math.round(speed_ms * 223.694)/100 // convert to mph
}
+function getWindDirectionName(index, dayModel)
+{
+ return dayModel.getDayDetails(index, "windDirectionName")
+}
+
function getWindUrl(index, dayModel)
{
var url = dayModel.getDayDetails(index, "windUrl")
diff --git a/qml/models/WeatherModel.qml b/qml/models/WeatherModel.qml
index 920c494..131f36e 100644
--- a/qml/models/WeatherModel.qml
+++ b/qml/models/WeatherModel.qml
@@ -101,6 +101,7 @@ Item {
XmlRole { name: "period"; query: "@period/string()" }
XmlRole { name: "symbolcode"; query: "symbol/@var/string()" }
XmlRole { name: "windType"; query: "windSpeed/@name/string()" }
+ XmlRole { name: "windDirectionName"; query: "windDirection/@name/string()" }
XmlRole { name: "windDirectionDeg"; query: "windDirection/@deg/string()" }
XmlRole { name: "windSpeed"; query: "windSpeed/@mps/string()" }
XmlRole { name: "temperature"; query: "temperature/@value/string()" }
diff --git a/qml/pages/OneDayZoomItem.qml b/qml/pages/OneDayZoomItem.qml
index 0a03725..fa8e4ec 100644
--- a/qml/pages/OneDayZoomItem.qml
+++ b/qml/pages/OneDayZoomItem.qml
@@ -176,7 +176,7 @@ GridLayout {
text : qsTr("Wind: ") + Utils.getWindSpeed(root.sliderValue, root.model)
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
pixelSize: 30
- Accessible.name: text + " " + windUnit.text
+ Accessible.name: text + " " + windUnit.text + " " + Utils.getWindDirectionName(root.sliderValue, root.model)
}
TouchLabel {
//: The wind speed unit, meters per second or miles per hour
diff --git a/src/daymodel.cpp b/src/daymodel.cpp
index 3473fa1..82aa022 100644
--- a/src/daymodel.cpp
+++ b/src/daymodel.cpp
@@ -66,6 +66,8 @@ QVariant DayModel::data(const QModelIndex &index, int role) const
return m_data.at(index.row()).windSpeed;
if (role == WindUrlRole)
return m_data.at(index.row()).windUrl;
+ if (role == WindDirectionNameRole)
+ return m_data.at(index.row()).windDirectionName;
if (role == RainRole)
return m_data.at(index.row()).rain;
return QVariant();
@@ -80,6 +82,7 @@ QHash<int, QByteArray> DayModel::roleNames() const
rn[TemperatureRole] = "temperature";
rn[WindSpeedRole] = "windSpeed";
rn[WindUrlRole] = "windUrl";
+ rn[WindDirectionNameRole] = "windDirectionName";
rn[RainRole] = "rain";
return rn;
}
@@ -91,7 +94,7 @@ void DayModel::clear()
m_data.clear();
}
-void DayModel::addRow(QString weatherUrl, QString from, QString to, QString temperature, QString windSpeed, QString windUrl, QString rain) {
+void DayModel::addRow(QString weatherUrl, QString from, QString to, QString temperature, QString windSpeed, QString windDirectionName, QString windUrl, QString rain) {
QStringList m_images;
DayModelStructure temp;
temp.from = from;
@@ -103,6 +106,7 @@ void DayModel::addRow(QString weatherUrl, QString from, QString to, QString temp
temp.temperature = temperature;
temp.windSpeed = windSpeed;
temp.windUrl = windUrl;
+ temp.windDirectionName = windDirectionName;
m_images.append(windUrl);
temp.rain = rain;
m_data.append(temp);
@@ -147,6 +151,8 @@ QString DayModel::getDayDetails(int index, QString prop) const
return temp.temperature;
if (prop == "windSpeed")
return temp.windSpeed;
+ if (prop == "windDirectionName")
+ return temp.windDirectionName;
if (prop == "windUrl")
return temp.windUrl;
if (prop == "rain")
diff --git a/src/daymodel.h b/src/daymodel.h
index 2edeeb3..13291b9 100644
--- a/src/daymodel.h
+++ b/src/daymodel.h
@@ -66,6 +66,7 @@ public:
QString to;
QString temperature;
QString windSpeed;
+ QString windDirectionName;
QString windUrl;
QString rain;
};
@@ -76,8 +77,9 @@ public:
ToRole = Qt::UserRole + 3,
TemperatureRole = Qt::UserRole + 4,
WindSpeedRole = Qt::UserRole + 5,
- WindUrlRole = Qt::UserRole + 6,
- RainRole = Qt::UserRole + 7
+ WindDirectionNameRole = Qt::UserRole + 6,
+ WindUrlRole = Qt::UserRole + 7,
+ RainRole = Qt::UserRole + 8
};
DayModel();
@@ -93,7 +95,7 @@ public:
QVariant data(const QModelIndex &index, int role) const;
QHash<int, QByteArray> roleNames() const;
- Q_INVOKABLE void addRow(QString weatherUrl, QString from, QString to, QString temperature, QString windSpeed, QString windUrl, QString rain);
+ Q_INVOKABLE void addRow(QString weatherUrl, QString from, QString to, QString temperature, QString windSpeed, QString windDirectionName, QString windUrl, QString rain);
Q_INVOKABLE QString getDayDetails(int index, QString prop) const;
Q_INVOKABLE int periodCount() const { return m_data.count(); }