Commit 49a79e0e authored by Martin Straka's avatar Martin Straka

Added first prototype of find databox

parent 349769c7
......@@ -99,6 +99,7 @@ SOURCES += \
src/main.cpp \
src/messages.cpp \
src/models/accountmodel.cpp \
src/models/databoxmodel.cpp \
src/models/filemodel.cpp \
src/models/list_sort_filter_proxy_model.cpp \
src/models/messagemodel.cpp \
......@@ -127,6 +128,7 @@ SOURCES += \
src/worker/task_download_delivery_info.cpp \
src/worker/task_download_message.cpp \
src/worker/task_download_message_list.cpp \
src/worker/task_find_databox.cpp \
src/worker/task_keep_alive.cpp \
src/worker/task_send_sms.cpp
......@@ -147,6 +149,7 @@ HEADERS += \
src/log/log.h \
src/messages.h \
src/models/accountmodel.h \
src/models/databoxmodel.h \
src/models/filemodel.h \
src/models/list_sort_filter_proxy_model.h \
src/models/messagemodel.h \
......@@ -176,6 +179,7 @@ HEADERS += \
src/worker/task_download_delivery_info.h \
src/worker/task_download_message.h \
src/worker/task_download_message_list.h \
src/worker/task_find_databox.h \
src/worker/task_keep_alive.h \
src/worker/task_send_sms.h
......
/*
* Copyright (C) 2014-2017 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.
*/
import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1
ListView {
id: root
/* These signals should be captured to implement message interaction. */
signal dbClicked(string dbID, string dbName, string dbAddress, string dbEffectiveOvm)
delegate: Rectangle {
id: dbItem
height: listItemHeight
width: parent.width
color: datovkaPalette.base
Item {
id: databoxData
anchors.fill: parent
anchors.margins: defaultMargin
GridLayout {
id: grid
columns: 2
rows: 3
rowSpacing: defaultMargin * 0.6
columnSpacing: defaultMargin * 2
anchors.verticalCenter: parent.verticalCenter
Text {
id: r1c1
text: rDbType
font.bold: true
}
Text {
id: r1c2
text: rDbName
color: headerColor
font.bold: true
}
Text {
id: r2c1
text: rDbID
}
Text {
id: r2c2
text: rDbAddress
}
Text {
id: r3c1
font.pointSize: textFontSizeSmall
text: rDbSendOption
}
Text {
id: r3c2
font.pointSize: textFontSizeSmall
text: (rDbIc == "") ? rDbIc : "IČ:" + rDbIc
}
Text {
id: hiddenText
visible: false
font.pointSize: textFontSizeSmall
text: rDbEffectiveOvm
}
}
} // Item
Rectangle {
id: next
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
height: parent.height
width: parent.width * 0.07
color: parent.color
Image {
id: nextImage
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/next.svg"
}
ColorOverlay {
anchors.fill: nextImage
source: nextImage
color: datovkaPalette.windowText
}
} // Rectangle
MouseArea {
anchors.fill: parent
onClicked: {
root.dbClicked(rDbID, rDbName, rDbAddress, rDbEffectiveOvm)
}
}
Rectangle {
anchors.top: parent.bottom
height: 1
width: parent.width
color: datovkaPalette.dark
}
} // Rectangle
ScrollIndicator.vertical: ScrollIndicator {}
} // ListView
......@@ -62,6 +62,7 @@ ApplicationWindow {
property Component pageAboutApp: PageAboutApp {}
property Component pageAccountDetail: PageAccountDetail {}
property Component pageChangePassword: PageChangePassword {}
property Component pageDataboxSearch: PageDataboxSearch {}
property Component pageMenuAccount: PageMenuAccount {}
property Component pageMenuDatovkaSettings: PageMenuDatovkaSettings {}
property Component pageMenuMessage: PageMenuMessage {}
......
/*
* Copyright (C) 2014-2017 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.
*/
import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.models 1.0
/*
* Roles are defined in DataboxListModel::roleNames() and are accessed directly
* via their names.
*/
Item {
id: pageDataboxSearch
/* These properties must be set by caller. */
property var pageView
property var statusBar
property string userName
property string searchType: "GENERAL"
property string searchScope: "ALL"
Component.onCompleted: {
searchPhraseText.forceActiveFocus()
}
DataboxListModel {
id: databoxModel
Component.onCompleted: {
}
}
PageHeader {
id: headerBar
title: qsTr("Find databox")
Item {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
MouseArea {
anchors.fill: parent
onClicked: {
statusBar.visible = false
pageView.pop(StackView.Immediate)
}
}
}
Row {
anchors.verticalCenter: parent.verticalCenter
spacing: defaultMargin
anchors.right: parent.right
anchors.rightMargin: defaultMargin
Image {
id: actionButton
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/account-search.svg"
MouseArea {
anchors.fill: parent
onClicked: {
searchPhraseText.focus = false
searchPanel.doSearchRequest()
}
}
}
}
} // PageHeader
Pane {
id: searchPanel
anchors.top: headerBar.bottom
width: parent.width
function doSearchRequest() {
isds.doIsdsAction("findDatabox", userName)
}
Column {
anchors.right: parent.right
anchors.left: parent.left
spacing: formItemVerticalSpacing
ComboBox {
id: searchScopeComboBox
currentIndex: 0
width: parent.width
height: inputItemHeight
textRole: "label"
font.pointSize: defaultTextFont.font.pointSize
delegate: ItemDelegate {
width: searchScopeComboBox.width
height: inputItemHeight
contentItem: Text {
text: label
color: datovkaPalette.text
font.pointSize: defaultTextFont.font.pointSize
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
highlighted: searchScopeComboBox.highlightedIndex == index
}
model: ListModel {
id: searchScopeComboBoxModel
ListElement { label: qsTr("All databoxes"); value: "ALL" }
ListElement { label: qsTr("OVM"); value: "OVM" }
ListElement { label: qsTr("PO"); value: "PO" }
ListElement { label: qsTr("PFO"); value: "PFO" }
ListElement { label: qsTr("FO"); value: "FO" }
}
onCurrentIndexChanged: searchScope = searchScopeComboBoxModel.get(currentIndex).value
}
ComboBox {
id: searchTypeComboBox
currentIndex: 0
width: parent.width
height: inputItemHeight
textRole: "label"
font.pointSize: defaultTextFont.font.pointSize
delegate: ItemDelegate {
width: searchTypeComboBox.width
height: inputItemHeight
contentItem: Text {
text: label
color: datovkaPalette.text
font.pointSize: defaultTextFont.font.pointSize
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
highlighted: searchTypeComboBox.highlightedIndex == index
}
model: ListModel {
id: searchTypeComboBoxModel
ListElement { label: qsTr("All fields"); value: "GENERAL" }
ListElement { label: qsTr("Address"); value: "ADDRESS" }
ListElement { label: qsTr(""); value: "ICO" }
ListElement { label: qsTr("Databox ID"); value: "DBID" }
}
onCurrentIndexChanged: searchType = searchTypeComboBoxModel.get(currentIndex).value
}
TextField {
id: searchPhraseText
placeholderText: qsTr("Enter phrase")
focus: true
width: parent.width
font.pointSize: defaultTextFont.font.pointSize
height: inputItemHeight
onAccepted: searchPanel.doSearchRequest()
InputLineMenu {
id: searchPhraseTextMenu
inputTextControl: searchPhraseText
isPassword: false
}
onPressAndHold: {
if (settings.useExplicitClipboardOperations()) {
searchPhraseTextMenu.implicitWidth = computeMenuWidth(searchPhraseTextMenu)
searchPhraseTextMenu.open()
}
}
}
}
} // Pane
Text {
id: emptyList
visible: false
color: datovkaPalette.text
anchors.centerIn: parent
width: parent.width
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
text: qsTr("No databox found for given search criteria.")
}
DataboxList {
id: databoxList
anchors.top: searchPanel.bottom
anchors.bottom: parent.bottom
clip: true
spacing: 1
opacity: 1
visible: true
width: parent.width
interactive: true
model: databoxModel
onDbClicked: {
statusBar.visible = false
/* TODO - insert databox to send page in the future */
console.log(dbID + " " + dbName + " " + dbAddress + " " + dbEffectiveOvm)
}
} // DataboxList
Connections {
target: isds
onRunFindDataboxSig: {
emptyList.visible = (isds.findDatabox(userName, databoxModel, searchPhraseText.text, searchType, searchScope) <= 0)
}
}
} // Item
......@@ -75,6 +75,11 @@ Component {
image: "qrc:/ui/account-box.svg"
showNext: true
}
ListElement {
index: 5
name: qsTr("Search databox")
image: "qrc:/ui/account-search.svg"
}
ListElement {
index: 2
name: qsTr("Clean up the file database")
......@@ -175,6 +180,12 @@ Component {
settings.saveAllSettings(accountModel)
pageView.pop(StackView.Immediate)
}
} else if (index == 5) {
pageView.replace(pageDataboxSearch, {
"pageView": pageView,
"statusBar": statusBar,
"userName": userName,
}, StackView.Immediate)
} else {
pageView.pop(StackView.Immediate)
}
......
......@@ -95,6 +95,7 @@
<file>datovka.png</file>
<file>cznic.png</file>
<file>ui/datovka@2x.png</file>
<file>../qml/components/DataboxList.qml</file>
<file>../qml/components/InputLineMenu.qml</file>
<file>../qml/components/MessageList.qml</file>
<file>../qml/components/OverlaidImage.qml</file>
......@@ -109,6 +110,7 @@
<file>../qml/pages/PageAccountDetail.qml</file>
<file>../qml/pages/PageAccountList.qml</file>
<file>../qml/pages/PageChangePassword.qml</file>
<file>../qml/pages/PageDataboxSearch.qml</file>
<file>../qml/pages/PageMenuAccount.qml</file>
<file>../qml/pages/PageMenuDatovkaSettings.qml</file>
<file>../qml/pages/PageMenuMessage.qml</file>
......
......@@ -40,6 +40,7 @@
#include "src/locker.h"
#include "src/net/isds_wrapper.h"
#include "src/models/accountmodel.h"
#include "src/models/databoxmodel.h"
#include "src/models/filemodel.h"
#include "src/models/list_sort_filter_proxy_model.h"
#include "src/models/messagemodel.h"
......@@ -82,6 +83,7 @@ const struct QmlTypeEntry qmlPages[] = {
{ "PageAccountDetail", 1, 0 },
{ "PageAccountList", 1, 0 },
{ "PageChangePassword", 1, 0 },
{ "PageDataboxSearch", 1, 0 },
{ "PageMenuAccount", 1, 0 },
{ "PageMenuDatovkaSettings", 1, 0 },
{ "PageMenuMessage", 1, 0 },
......@@ -104,6 +106,7 @@ const struct QmlTypeEntry qmlPages[] = {
*/
static
const struct QmlTypeEntry qmlComponents[] = {
{ "DataboxList", 1, 0 },
{ "InputLineMenu", 1, 0 },
{ "MessageList", 1, 0 },
{ "OverlaidImage", 1, 0 },
......@@ -285,6 +288,7 @@ int main(int argc, char *argv[])
/* Register types into QML. */
AccountListModel::declareQML();
DataboxListModel::declareQML();
Dialogues::declareQML();
FileListModel::declareQML();
InteractionFilesystem::declareQML();
......
/*
* Copyright (C) 2014-2017 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/models/databoxmodel.h"
DataboxModelEntry::DataboxModelEntry(const DataboxModelEntry &dme)
: m_dbID(dme.m_dbID),
m_dbType(dme.m_dbType),
m_dbName(dme.m_dbName),
m_dbAddress(dme.m_dbAddress),
m_dbIC(dme.m_dbIC),
m_dbEffectiveOVM(dme.m_dbEffectiveOVM),
m_dbSendOptions(dme.m_dbSendOptions)
{
}
DataboxModelEntry::DataboxModelEntry(const QString &dbID, const QString &dbType,
const QString &dbName, const QString &dbAddress, const QString &dbIC,
const QString &dbEffectiveOVM, const QString &dbSendOptions)
: m_dbID(dbID),
m_dbType(dbType),
m_dbName(dbName),
m_dbAddress(dbAddress),
m_dbIC(dbIC),
m_dbEffectiveOVM(dbEffectiveOVM),
m_dbSendOptions(dbSendOptions)
{
}
QString DataboxModelEntry::dbID(void) const
{
return m_dbID;
}
void DataboxModelEntry::setDbID(const QString &dbID)
{
m_dbID = dbID;
}
QString DataboxModelEntry::dbType(void) const
{
return m_dbType;
}
void DataboxModelEntry::setDbType(const QString &dbType)
{
m_dbType = dbType;
}
QString DataboxModelEntry::dbName(void) const
{
return m_dbName;
}
void DataboxModelEntry::setDbName(const QString &dbName)
{
m_dbName = dbName;
}
QString DataboxModelEntry::dbAddress(void) const
{
return m_dbAddress;
}
void DataboxModelEntry::setDbAddress(const QString &dbAddress)
{
m_dbAddress = dbAddress;
}
QString DataboxModelEntry::dbIC(void) const
{
return m_dbIC;
}
void DataboxModelEntry::setDbIC(const QString &dbIC)
{
m_dbIC = dbIC;
}
QString DataboxModelEntry::dbEffectiveOVM(void) const
{
return m_dbEffectiveOVM;
}
void DataboxModelEntry::setDbEffectiveOVM(const QString &dbEffectiveOVM)
{
m_dbEffectiveOVM = dbEffectiveOVM;
}
QString DataboxModelEntry::dbSendOptions(void) const
{
return m_dbSendOptions;
}
void DataboxModelEntry::setDbSendOptions(const QString &dbSendOptions)
{
m_dbSendOptions = dbSendOptions;
}
void DataboxListModel::declareQML(void)
{
qmlRegisterType<DataboxListModel>("cz.nic.mobileDatovka.models", 1, 0, "DataboxListModel");
qRegisterMetaType<DataboxListModel>();
qRegisterMetaType<DataboxListModel::Roles>();
}
DataboxListModel::DataboxListModel(QObject *parent)
: QAbstractListModel(parent)
{
}
DataboxListModel::DataboxListModel(const DataboxListModel &model,
QObject *parent)
: QAbstractListModel(parent),
m_databoxes(model.m_databoxes)
{
}
int DataboxListModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return m_databoxes.size();
}
QHash<int, QByteArray> DataboxListModel::roleNames(void) const
{
static QHash<int, QByteArray> roles;
if (roles.isEmpty()) {
roles[ROLE_DB_ID] = "rDbID";
roles[ROLE_DB_TYPE] = "rDbType";
roles[ROLE_DB_NAME] = "rDbName";
roles[ROLE_DB_ADDRESS] = "rDbAddress";
roles[ROLE_DB_IC] = "rDbIc";
roles[ROLE_DB_EFFECTIVE_OVM] = "rDbEffectiveOvm";
roles[ROLE_DB_SEND_OPTION] = "rDbSendOption";
}
return roles;
}
QVariant DataboxListModel::data(const QModelIndex &index, int role) const
{
if ((index.row() < 0) || (index.row() >= m_databoxes.size())) {
return QVariant();
}
const DataboxModelEntry &databox(m_databoxes.at(index.row()));
switch (role) {
case ROLE_DB_ID:
return databox.dbID();
break;
case ROLE_DB_TYPE:
return databox.dbType();
break;
case ROLE_DB_NAME:
return databox.dbName();
break;
case ROLE_DB_ADDRESS:
return databox.dbAddress();
break;
case ROLE_DB_IC:
return databox.dbIC();
break;
case ROLE_DB_EFFECTIVE_OVM:
return databox.dbEffectiveOVM();
break;
case ROLE_DB_SEND_OPTION:
return databox.dbSendOptions();
break;
default:
/* Do nothing. */
break;
}
return QVariant();
}
void DataboxListModel::setData(const DataboxModelEntry &data, int role)
{
Q_UNUSED(role);
beginResetModel();
m_databoxes.append(data);
endResetModel();
}
Qt::ItemFlags DataboxListModel::flags(const QModelIndex &index) const
{
Q_UNUSED(index);
return 0;
}
QModelIndex DataboxListModel::databoxIndex(const QString &dbID) const
{
for (int row = 0; row < m_databoxes.size(); ++row) {
if (m_databoxes.at(row).dbID() == dbID) {
return index(row, 0, QModelIndex());
}
}
return QModelIndex();
}
void DataboxListModel::clearAll(void)
{
beginResetModel();
m_databoxes.clear();
endResetModel();
}
DataboxListModel *DataboxListModel::fromVariant(const QVariant &modelVariant)
{
if (!modelVariant.canConvert<QObject *>()) {
return Q_NULLPTR;
}
QObject *obj = qvariant_cast<QObject *>(modelVariant);
return qobject_cast<DataboxListModel *>(obj);
}
/*
* Copyright (C) 2014-2017 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.
*/
#ifndef DATABOXMODEL_H
#define DATABOXMODEL_H
#include <QAbstractListModel>
class DataboxModelEntry {
public:
DataboxModelEntry(const DataboxModelEntry &dme);
DataboxModelEntry(const QString &dbID, const QString &dbType,
const QString &dbName, const QString &dbAddress, const QString &dbIC,
const QString &dbEffectiveOVM, const QString &dbSendOptions);
QString dbID(void) const;
void setDbID(const QString &dbID);
QString dbType(void) const;
void setDbType(const QString &dbType);
QString dbName(void) const;
void setDbName(const QString &dbName);
QString dbAddress(void) const;
void setDbAddress(const QString &dbAddress);
QString dbIC(void) const;
void setDbIC(const QString &dbIC);
QString dbEffectiveOVM(void) const;
void setDbEffectiveOVM(const QString &dbEffectiveOVM);
QString dbSendOptions(void) const;
void setDbSendOptions(const QString &dbSendOptions);