diff options
author | Caroline Chao <caroline.chao@digia.com> | 2014-09-11 09:36:36 +0200 |
---|---|---|
committer | Caroline Chao <caroline.chao@digia.com> | 2014-09-11 13:38:26 +0200 |
commit | 92d8c407b6411ae019723dec3499a4e380b860f1 (patch) | |
tree | 347015d572e3b7259dfcd6d61d0a66510e72bf51 | |
parent | e337e05e1cc865ff954389fa84d0b422be7be1fe (diff) |
Adjust homescreen layout
Change-Id: I3433c9ec3bba31606de90c5a2ee45a72266b2c50
Reviewed-by: Niels Weber <niels.weber@digia.com>
-rw-r--r-- | qml/components/HomeScreen.qml | 81 | ||||
-rw-r--r-- | src/sortfiltermodel.cpp | 21 | ||||
-rw-r--r-- | src/sortfiltermodel.h | 6 | ||||
-rw-r--r-- | src/theme.cpp | 8 |
4 files changed, 84 insertions, 32 deletions
diff --git a/qml/components/HomeScreen.qml b/qml/components/HomeScreen.qml index 4058302..86c6cc5 100644 --- a/qml/components/HomeScreen.qml +++ b/qml/components/HomeScreen.qml @@ -100,12 +100,28 @@ Rectangle { visible: ModelsSingleton.conferenceId !== "" Item { // upcoming + id: upcomingItem width: homeScreenWindow.width height: homeScreenWindow.height / 3 + property string visibleDate: "" + property string formatDate: "ddd d.MM" + + SortFilterModel { + id: sortModelNextEvents + sortRole: "start" + filterRole: "fromNow" + maximumCount: 7 + model: ModelsSingleton.eventModel + Component.onCompleted: { + if (sortModelNextEvents.rowCount() > 0) + upcomingItem.visibleDate = Qt.formatDate(sortModelNextEvents.get(0, "start"), upcomingItem.formatDate) + } + } + Text { id: labelUpcoming - text: Theme.text.upcoming.arg(ModelsSingleton.conferenceTitle) + text: Theme.text.upcoming.arg(ModelsSingleton.conferenceTitle).arg(upcomingItem.visibleDate) width: parent.width height: Theme.sizes.homeTitleHeight z: 1 @@ -126,51 +142,64 @@ Rectangle { anchors.right: parent.right anchors.left: parent.left anchors.margins: Theme.margins.ten + model: sortModelNextEvents clip: true - model: SortFilterModel { - id: sortModel - sortRole: "start" - filterRole: "fromNow" - model: ModelsSingleton.eventModel + onVisibleChanged: { + if (visible) { + sortModelNextEvents.filter() + upcomingItem.visibleDate = Qt.formatDate(sortModelNextEvents.get(0, "start"), upcomingItem.formatDate) + } } - onVisibleChanged: sortModel.filter() - spacing: Theme.margins.five + spacing: Theme.margins.ten delegate: RowLayout { + id: upcomingEventDelegate width: parent.width - height: Theme.sizes.upcomingEventHeight + visible: Qt.formatDate(start, upcomingItem.formatDate) === upcomingItem.visibleDate + height: visible ? Theme.sizes.upcomingEventHeight : 0 Rectangle { color: tracks.backgroundColor Layout.fillHeight: true Layout.preferredWidth: Theme.sizes.upcomingEventTimeWidth - Text { anchors.fill: parent anchors.leftMargin: Theme.margins.five - text: Qt.formatDate(start, "ddd") + " " + Qt.formatTime(start, "h:mm") + text: tracks.name + font.capitalization: Font.AllUppercase + color: Theme.colors.white verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignLeft - font.pointSize: Theme.fonts.seven_pt + font.pointSize: Theme.fonts.six_pt } } Rectangle { Layout.fillHeight: true Layout.fillWidth: true color: mouseArea.pressed ? Theme.colors.smokewhite : Theme.colors.white - - Text { + MouseArea { + id: mouseArea anchors.fill: parent - anchors.leftMargin: Theme.margins.five - text: "<b>" + topic + "</b><br />by " + performer + " in " + location - verticalAlignment: Text.AlignVCenter - elide: Text.ElideRight - wrapMode: Text.Wrap - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: stack.push({ - "item" : Qt.resolvedUrl("Event.qml"), - "properties" : {"eventId" : id} - }) + onClicked: stack.push({ + "item" : Qt.resolvedUrl("Event.qml"), + "properties" : {"eventId" : id} + }) + } + ColumnLayout { + anchors.fill: parent + anchors.leftMargin: Theme.margins.twenty + Text { + Layout.fillWidth: true + text: topic + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + font.pointSize: Theme.fonts.seven_pt + } + Text { + Layout.fillWidth: true + text: Qt.formatTime(start, Qt.locale().timeFormat(Locale.ShortFormat)) + Theme.text.room_space.arg(location) + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + font.pointSize: Theme.fonts.seven_pt + color: Theme.colors.gray } } } diff --git a/src/sortfiltermodel.cpp b/src/sortfiltermodel.cpp index 7789f03..fc8c50d 100644 --- a/src/sortfiltermodel.cpp +++ b/src/sortfiltermodel.cpp @@ -43,7 +43,8 @@ #include <QtCore/QDebug> SortFilterModel::SortFilterModel(QObject *parent) - : QSortFilterProxyModel(parent) + : QSortFilterProxyModel(parent), + m_maximumCount(0) { connect(this, SIGNAL(sourceModelChanged()), SIGNAL(modelChanged())); connect(this, SIGNAL(sortRoleChanged()), SLOT(manualSort())); @@ -85,6 +86,19 @@ void SortFilterModel::setFilterRole(const QString &role) Q_EMIT filterRoleChanged(); } +int SortFilterModel::maximumCount() const +{ + return m_maximumCount; +} + +void SortFilterModel::setMaximumCount(const int &newCount) +{ + if (newCount != m_maximumCount) { + m_maximumCount = newCount; + emit maximumCountChanged(); + } +} + QVariant SortFilterModel::get(int row, const QString &role) { return data(index(row, 0), roleNames().key(role.toLatin1())); @@ -103,7 +117,10 @@ QVariant SortFilterModel::indexOf(const QString &role, QVariant value) int SortFilterModel::rowCount(const QModelIndex &parent) const { - return QSortFilterProxyModel::rowCount(parent); + int tempRowCount = QSortFilterProxyModel::rowCount(parent); + if (maximumCount() > 0) + tempRowCount = qMin(maximumCount(), tempRowCount); + return tempRowCount; } void SortFilterModel::manualSort() diff --git a/src/sortfiltermodel.h b/src/sortfiltermodel.h index 99e98e2..4ffd3ba 100644 --- a/src/sortfiltermodel.h +++ b/src/sortfiltermodel.h @@ -49,6 +49,7 @@ class SortFilterModel : public QSortFilterProxyModel Q_PROPERTY(QObject *model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QString sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged) Q_PROPERTY(QString filterRole READ filterRole WRITE setFilterRole NOTIFY filterRoleChanged) + Q_PROPERTY(int maximumCount READ maximumCount WRITE setMaximumCount NOTIFY maximumCountChanged) public: explicit SortFilterModel(QObject *parent = 0); @@ -61,6 +62,9 @@ public: QString filterRole() const; void setFilterRole(const QString &role); + int maximumCount() const; + void setMaximumCount(const int &newCount); + Q_INVOKABLE QVariant get(int row, const QString &role); Q_INVOKABLE void set(int row, const QVariant &data, const QString &role); Q_INVOKABLE QVariant indexOf(const QString &role, QVariant value); @@ -75,10 +79,12 @@ Q_SIGNALS: void modelChanged(); void sortRoleChanged(); void filterRoleChanged(); + void maximumCountChanged(); private: QString m_sortRole; QString m_filterRole; + int m_maximumCount; }; #endif // SORTFILTERMODEL_H diff --git a/src/theme.cpp b/src/theme.cpp index 2c1440e..0245e17 100644 --- a/src/theme.cpp +++ b/src/theme.cpp @@ -76,13 +76,13 @@ Theme::Theme(QObject *parent) m_text->insert(QLatin1String("talks"), tr("Presentations")); m_text->insert(QLatin1String("favorites"), tr("Favorites")); m_text->insert(QLatin1String("feedback"), tr("Send Feedback")); - m_text->insert(QLatin1String("upcoming"), tr("Upcoming: %1")); + m_text->insert(QLatin1String("upcoming"), tr("Upcoming: %1 %2")); m_text->insert(QLatin1String("news"), tr("News")); m_text->insert(QLatin1String("info"), tr("Useful Information")); m_text->insert(QLatin1String("writeYourCommentHere"), tr("Write your comments here")); m_text->insert(QLatin1String("by"), tr("by %1")); m_text->insert(QLatin1String("room"), tr("Room %1")); - + m_text->insert(QLatin1String("room_space"), tr(" - Room %1")); m_colors = new QQmlPropertyMap(this); m_colors->insert(QLatin1String("white"), QVariant("#ffffff")); @@ -111,9 +111,9 @@ Theme::Theme(QObject *parent) m_sizes->insert(QLatin1String("menuHeight"), QVariant(applyRatio(62))); m_sizes->insert(QLatin1String("menuWidth"), QVariant(applyRatio(78))); m_sizes->insert(QLatin1String("dayLabelHeight"), QVariant(applyRatio(70))); - m_sizes->insert(QLatin1String("upcomingEventHeight"), QVariant(applyRatio(75))); + m_sizes->insert(QLatin1String("upcomingEventHeight"), QVariant(applyRatio(90))); m_sizes->insert(QLatin1String("homeTitleHeight"), QVariant(applyRatio(50))); - m_sizes->insert(QLatin1String("upcomingEventTimeWidth"), QVariant(applyRatio(180))); + m_sizes->insert(QLatin1String("upcomingEventTimeWidth"), QVariant(applyRatio(200))); m_sizes->insert(QLatin1String("trackFieldHeight"), QVariant(applyRatio(50))); m_sizes->insert(QLatin1String("buttonHeight"), QVariant(applyRatio(78))); m_sizes->insert(QLatin1String("buttonWidth"), QVariant(applyRatio(300))); |