diff options
author | Caroline Chao <caroline.chao@digia.com> | 2014-09-12 13:47:38 +0200 |
---|---|---|
committer | Caroline Chao <caroline.chao@digia.com> | 2014-09-15 11:07:57 +0200 |
commit | 661520661707e5db6fa7bdc99aa6921c04554b35 (patch) | |
tree | 8e2410823322bc6be5bfde36ed2eec2b70c58fe2 | |
parent | 7a108aa1716b7e134dcf98cddcc677ebfc481de4 (diff) |
Handle keynotes as breaks and events
Change-Id: Ieb1f51af0a2e1254629ad125083f555f97367780
Reviewed-by: Niels Weber <niels.weber@digia.com>
-rw-r--r-- | qml/components/DayTracksModel.qml | 1 | ||||
-rw-r--r-- | qml/components/TrackHeader.qml | 2 | ||||
-rw-r--r-- | qml/components/TrackSwitcher.qml | 163 | ||||
-rw-r--r-- | src/sortfiltermodel.cpp | 17 | ||||
-rw-r--r-- | src/sortfiltermodel.h | 6 |
5 files changed, 105 insertions, 84 deletions
diff --git a/qml/components/DayTracksModel.qml b/qml/components/DayTracksModel.qml index 37c6c32..8b095ef 100644 --- a/qml/components/DayTracksModel.qml +++ b/qml/components/DayTracksModel.qml @@ -58,6 +58,7 @@ QtObject { filterRole: "track" filterRegExp: new RegExp(dayId) model: ModelsSingleton.eventModel + hide: true Component.onCompleted: { isEmpty = modelTracks.rowCount() === 0 ready = Qt.binding(function() {return modelTracks.rowCount() > 0}) diff --git a/qml/components/TrackHeader.qml b/qml/components/TrackHeader.qml index 3a35689..65b7ec5 100644 --- a/qml/components/TrackHeader.qml +++ b/qml/components/TrackHeader.qml @@ -47,7 +47,7 @@ import TalkSchedule 1.0 ListView { id: trackHeaderListView - height: rowLayout.height + height: parent.height width: Theme.sizes.trackHeaderWidth clip: true diff --git a/qml/components/TrackSwitcher.qml b/qml/components/TrackSwitcher.qml index 53b82e6..a4b4ef1 100644 --- a/qml/components/TrackSwitcher.qml +++ b/qml/components/TrackSwitcher.qml @@ -196,103 +196,102 @@ Item { } } - Item { - id: breakData - property real trackScrolling: 0 - anchors.fill: rowLayout - Item { - id: breakColumn - anchors.top: parent.top - anchors.topMargin: Theme.sizes.dayLabelHeight - anchors.right: parent.right - height: Math.min(parent.height - Theme.sizes.dayLabelHeight, - listView.contentHeight - Theme.margins.ten) - width: parent.width - Theme.sizes.trackHeaderWidth - Repeater { - id: breaks - model: currentDayBreaksModel - Rectangle { - color: Theme.colors.smokewhite - anchors.top: breakColumn.top - x: Functions.countTrackPosition(start) - breakData.trackScrolling - width: Functions.countTrackWidth(start, end) - Theme.margins.ten - anchors.bottom: breakColumn.bottom - Text { - anchors.centerIn: parent - horizontalAlignment: Text.AlignHCenter - font.pointSize: Theme.fonts.seven_pt - text: name + "\n" + Qt.formatTime(start, "h:mm") + " - " + Qt.formatTime(end, "h:mm") - color: Theme.colors.darkgray - } - } - } - } + TrackHeader { + id: trackHeader + z: 3 + anchors.top: daysWitcher.bottom + anchors.topMargin: Theme.sizes.dayLabelHeight + anchors.left: parent.left + width: Theme.sizes.trackHeaderWidth + model: currentDayTracksModel + height: listView.height } - Row { - id: rowLayout - anchors.fill: parent - anchors.topMargin: daysWitcher.height - Column{ - // Add this empty item so track won't overlap with time line - Item { + Flickable { + id: flickable1 + anchors.left: trackHeader.right + anchors.top: daysWitcher.bottom + height: parent.height + width: root.width + clip: true + contentWidth: timeColumn.width + flickableDirection: Flickable.HorizontalFlick + Column { + spacing: 0 + Row { + id: timeColumn + property var timeList: [] height: Theme.sizes.dayLabelHeight - width: Theme.margins.ten + z: 2 + Repeater { + id: timeColumnList + model: timeColumn.timeList + delegate: Rectangle { + color: Theme.colors.white + width: Theme.sizes.timeColumnWidth + height: timeColumn.height + Text { + id: repeaterText; + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + font.pointSize: Theme.fonts.seven_pt + text: Qt.formatTime(timeColumn.timeList[index], "h:mm") + } + } + } } - TrackHeader { - id: trackHeader + ListView { + id: listView + height: root.height - daysWitcher.height - timeColumn.height + width: parent.width + interactive: true + clip: true + boundsBehavior: Flickable.StopAtBounds + delegate: Track {} model: currentDayTracksModel - } - } - - Flickable { - id: flickable1 - height: rowLayout.height - width: root.width - clip: true - contentWidth: timeColumn.width - flickableDirection: Flickable.HorizontalFlick - onContentXChanged: breakData.trackScrolling = flickable1.contentX - Column { - spacing: 0 - Row { - id: timeColumn - property var timeList: [] - height: Theme.sizes.dayLabelHeight + Component.onCompleted: breakColumn.height = listView.contentHeight + Item { + id: breakColumn + z: 2 + anchors.top: parent.top + anchors.bottom: parent.bottom + width: parent.width Repeater { - id: timeColumnList - model: timeColumn.timeList - delegate: Item { - width: Theme.sizes.timeColumnWidth - height: timeColumn.height + id: breaks + model: currentDayBreaksModel + Rectangle { + color: mouseArea.pressed ? Theme.colors.lightgray : Theme.colors.smokewhite + anchors.top: breakColumn.top + x: Functions.countTrackPosition(start) + width: Functions.countTrackWidth(start, end) - Theme.margins.ten + height: Math.min(breakColumn.height, listView.contentHeight - Theme.margins.ten) Text { - id: repeaterText; - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left + width: parent.width + verticalAlignment: Text.AlignVCenter + height: parent.height + horizontalAlignment: Text.AlignHCenter font.pointSize: Theme.fonts.seven_pt - text: Qt.formatTime(timeColumn.timeList[index], "h:mm") + text: name + "\n" + Qt.formatTime(start, "h:mm") + " - " + Qt.formatTime(end, "h:mm") + color: Theme.colors.darkgray + } + MouseArea { + id: mouseArea + anchors.fill: parent + enabled: !!associatedEventId + onClicked: stack.push({"item" : Qt.resolvedUrl("Event.qml"), "properties" : {"eventId" : associatedEventId}}) } } } } - ListView { - id: listView - height: root.height - daysWitcher.height - timeColumn.height - width: parent.width - interactive: true - clip: true - boundsBehavior: Flickable.StopAtBounds - delegate: Track {} - model: currentDayTracksModel - onContentYChanged: { - if (isViewScrolling === false) { - isViewScrolling = true; - trackHeader.contentY = listView.contentY - isViewScrolling = false; - } + onContentYChanged: { + if (isViewScrolling === false) { + isViewScrolling = true; + trackHeader.contentY = listView.contentY + isViewScrolling = false; } } } } + } } diff --git a/src/sortfiltermodel.cpp b/src/sortfiltermodel.cpp index fc8c50d..c8be995 100644 --- a/src/sortfiltermodel.cpp +++ b/src/sortfiltermodel.cpp @@ -44,7 +44,8 @@ SortFilterModel::SortFilterModel(QObject *parent) : QSortFilterProxyModel(parent), - m_maximumCount(0) + m_maximumCount(0), + m_hide(false) { connect(this, SIGNAL(sourceModelChanged()), SIGNAL(modelChanged())); connect(this, SIGNAL(sortRoleChanged()), SLOT(manualSort())); @@ -99,6 +100,14 @@ void SortFilterModel::setMaximumCount(const int &newCount) } } +void SortFilterModel::setHide(const bool newHide) +{ + if (newHide != m_hide) { + m_hide = newHide; + emit hideChanged(); + } +} + QVariant SortFilterModel::get(int row, const QString &role) { return data(index(row, 0), roleNames().key(role.toLatin1())); @@ -144,6 +153,12 @@ bool SortFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source currentDateTime.setMSecsSinceEpoch(currentDateTime.currentMSecsSinceEpoch() + localTimeZoneOffset*1000); return date >= currentDateTime; } else { + if (m_hide && sourceModel()->roleNames().values().contains("hideInSchedule")) { + QModelIndex index = sourceModel()->index(source_row, 0, source_parent); + bool willBeHidden = sourceModel()->data(index, sourceModel()->roleNames().key("hideInSchedule")).toBool(); + if (willBeHidden) + return false; + } return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); } } diff --git a/src/sortfiltermodel.h b/src/sortfiltermodel.h index 4ffd3ba..19db0b2 100644 --- a/src/sortfiltermodel.h +++ b/src/sortfiltermodel.h @@ -50,6 +50,7 @@ class SortFilterModel : public QSortFilterProxyModel 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) + Q_PROPERTY(bool hide READ hide WRITE setHide NOTIFY hideChanged) public: explicit SortFilterModel(QObject *parent = 0); @@ -65,6 +66,9 @@ public: int maximumCount() const; void setMaximumCount(const int &newCount); + bool hide() const { return m_hide; } + void setHide(const bool newHide); + 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); @@ -80,11 +84,13 @@ Q_SIGNALS: void sortRoleChanged(); void filterRoleChanged(); void maximumCountChanged(); + void hideChanged(); private: QString m_sortRole; QString m_filterRole; int m_maximumCount; + bool m_hide; }; #endif // SORTFILTERMODEL_H |