Commit 97687eb6 authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

Enabled upload hierarchy sorting.

parent fb332cad
......@@ -137,6 +137,7 @@ SOURCES += \
src/qml_interaction/message_info.cpp \
src/qml_interaction/string_manipulation.cpp \
src/records_management/models/upload_hierarchy_list_model.cpp \
src/records_management/models/upload_hierarchy_qml_proxy_model.cpp \
src/records_management.cpp \
src/settings.cpp \
src/setwrapper.cpp \
......@@ -219,6 +220,7 @@ HEADERS += \
src/qml_interaction/message_info.h \
src/qml_interaction/string_manipulation.h \
src/records_management/models/upload_hierarchy_list_model.h \
src/records_management/models/upload_hierarchy_qml_proxy_model.h \
src/records_management.h \
src/settings.h \
src/setwrapper.h \
......
......@@ -44,6 +44,8 @@ Component {
property var uploadIds: []
Component.onCompleted: {
uploadHierarchyProxyModel.setSourceModel(uploadHierarchyListModel)
uploadHierarchyProxyModel.sort()
}
Component.onDestruction: {
......@@ -53,12 +55,19 @@ Component {
UploadHierarchyListModel {
id: uploadHierarchyListModel
onModelReset: {
uploadHierarchyProxyModel.sort()
locationLabel.text = uploadHierarchyListModel.navigatedRootName(true, "/")
}
Component.onCompleted: {
}
}
UploadHierarchyQmlProxyModel {
id: uploadHierarchyProxyModel
Component.onCompleted: {
}
}
PageHeader {
id: headerBar
title: qsTr("Upload message %1").arg(msgId)
......@@ -134,7 +143,7 @@ Component {
anchors.bottom: bottomText.top
/* TODO */
width: parent.width
model: uploadHierarchyListModel
model: uploadHierarchyProxyModel
delegate: Rectangle {
id: uploadItem
......@@ -154,7 +163,8 @@ Component {
MouseArea {
function handleClick() {
uploadHierarchyListModel.navigateSub(index);
uploadHierarchyListModel.navigateSub(
uploadHierarchyProxyModel.mapToSource(index));
}
anchors.fill: parent
......
......@@ -55,6 +55,7 @@
#include "src/qml_interaction/message_envelope.h"
#include "src/qml_interaction/string_manipulation.h"
#include "src/records_management/models/upload_hierarchy_list_model.h"
#include "src/records_management/models/upload_hierarchy_qml_proxy_model.h"
#include "src/records_management.h"
#include "src/settings.h"
#include "src/setwrapper.h"
......@@ -340,6 +341,7 @@ int main(int argc, char *argv[])
MsgEnvelope::declareQML();
MsgInfo::declareQML();
UploadHierarchyListModel::declareQML();
UploadHierarchyQmlProxyModel::declareQML();
InteractionZfoFile interactionZfoFile;
......
......@@ -156,6 +156,9 @@ QVariant UploadHierarchyListModel::data(const QModelIndex &index,
}
switch (role) {
case Qt::DisplayRole:
return entry->name();
break;
case ROLE_NAME:
return entry->name();
break;
......
/*
* Copyright (C) 2014-2018 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#include <QQmlEngine> /* qmlRegisterType */
#include "src/records_management/models/upload_hierarchy_qml_proxy_model.h"
void UploadHierarchyQmlProxyModel::declareQML(void)
{
qmlRegisterType<UploadHierarchyQmlProxyModel>("cz.nic.mobileDatovka.models", 1, 0, "UploadHierarchyQmlProxyModel");
qRegisterMetaType<UploadHierarchyQmlProxyModel>();
}
UploadHierarchyQmlProxyModel::UploadHierarchyQmlProxyModel(QObject *parent)
: UploadHierarchyProxyModel(parent)
{
}
UploadHierarchyQmlProxyModel::UploadHierarchyQmlProxyModel(
const UploadHierarchyQmlProxyModel &model, QObject *parent)
: UploadHierarchyProxyModel(parent)
{
Q_UNUSED(model);
}
void UploadHierarchyQmlProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
UploadHierarchyProxyModel::setSourceModel(sourceModel);
}
int UploadHierarchyQmlProxyModel::mapToSource(int proxyRow) const
{
const QModelIndex proxyIndex(index(proxyRow, 0, QModelIndex()));
return UploadHierarchyProxyModel::mapToSource(proxyIndex).row();
}
void UploadHierarchyQmlProxyModel::sort(void)
{
UploadHierarchyProxyModel::sort(0, Qt::AscendingOrder);
}
/*
* Copyright (C) 2014-2018 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
#pragma once
#include "src/datovka_shared/records_management/models/upload_hierarchy_proxy_model.h"
/*!
* @brief Enables filtering from QML according to metadata.
*/
class UploadHierarchyQmlProxyModel : public UploadHierarchyProxyModel {
Q_OBJECT
public:
/* Don't forget to declare various properties to the QML system. */
static
void declareQML(void);
/*!
* @brief Constructor.
*
* @param[in] parent Parent object.
*/
explicit UploadHierarchyQmlProxyModel(QObject *parent = Q_NULLPTR);
/*!
* @brief Copy constructor.
*
* @note Needed for QVariant conversion.
* @note This is a dummy function. Calling this constructor causes an
* assertion failure.
*
* @param[in] model Model to be copied.
* @param[in] parent Pointer to parent object.
*/
explicit UploadHierarchyQmlProxyModel(
const UploadHierarchyQmlProxyModel &model,
QObject *parent = Q_NULLPTR);
/*!
* @brief Set source model.
*
* @param[in] sourceModel Source model to be used.
*/
Q_INVOKABLE virtual
void setSourceModel(QAbstractItemModel *sourceModel) Q_DECL_OVERRIDE;
Q_INVOKABLE
int mapToSource(int proxyRow) const;
/*!
* @brief Sorts the model content.
*/
Q_INVOKABLE
void sort(void);
};
/* QML passes its arguments via QVariant. */
Q_DECLARE_METATYPE(UploadHierarchyQmlProxyModel)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment