Commit 26f83e20 authored by Karel Slaný's avatar Karel Slaný

Added code for converting rich text into plain text.

parent fdcd9487
...@@ -125,6 +125,7 @@ SOURCES += \ ...@@ -125,6 +125,7 @@ SOURCES += \
src/qml_interaction/interaction_zfo_file.cpp \ src/qml_interaction/interaction_zfo_file.cpp \
src/qml_interaction/message_envelope.cpp \ src/qml_interaction/message_envelope.cpp \
src/qml_interaction/message_info.cpp \ src/qml_interaction/message_info.cpp \
src/qml_interaction/string_manipulation.cpp \
src/settings.cpp \ src/settings.cpp \
src/setwrapper.cpp \ src/setwrapper.cpp \
src/sqlite/account_db.cpp \ src/sqlite/account_db.cpp \
...@@ -188,6 +189,7 @@ HEADERS += \ ...@@ -188,6 +189,7 @@ HEADERS += \
src/qml_interaction/interaction_zfo_file.h \ src/qml_interaction/interaction_zfo_file.h \
src/qml_interaction/message_envelope.h \ src/qml_interaction/message_envelope.h \
src/qml_interaction/message_info.h \ src/qml_interaction/message_info.h \
src/qml_interaction/string_manipulation.h \
src/settings.h \ src/settings.h \
src/setwrapper.h \ src/setwrapper.h \
src/sqlite/account_db.h \ src/sqlite/account_db.h \
......
...@@ -26,7 +26,8 @@ import QtQuick 2.7 ...@@ -26,7 +26,8 @@ import QtQuick 2.7
/* /*
* Accessible text component. * Accessible text component.
* *
* This component exposes the its text to the accessibility interface. * This component exposes its text to the accessibility interface. Rich text
* is converted onto plain text.
* If accessibleName is specified then its content is used instead of the text * If accessibleName is specified then its content is used instead of the text
* property value. * property value.
*/ */
...@@ -37,5 +38,5 @@ Text { ...@@ -37,5 +38,5 @@ Text {
property string accessibleName: "" property string accessibleName: ""
Accessible.role: Accessible.StaticText Accessible.role: Accessible.StaticText
Accessible.name: (root.accessibleName !== "") ? root.accessibleName : root.text Accessible.name: (root.accessibleName !== "") ? root.accessibleName : ((root.textFormat !== TextEdit.RichText) ? root.text : strManipulation.removeRich(root.text))
} }
...@@ -46,7 +46,7 @@ Text { ...@@ -46,7 +46,7 @@ Text {
anchors.fill: parent anchors.fill: parent
Accessible.role: Accessible.Button Accessible.role: Accessible.Button
Accessible.name: (root.accessibleName !== "") ? root.accessibleName : root.text Accessible.name: (root.accessibleName !== "") ? root.accessibleName : ((root.textFormat !== TextEdit.RichText) ? root.text : strManipulation.removeRich(root.text))
Accessible.onPressAction: { Accessible.onPressAction: {
handleClick() handleClick()
} }
......
...@@ -98,7 +98,7 @@ Component { ...@@ -98,7 +98,7 @@ Component {
ScrollIndicator.vertical: ScrollIndicator {} ScrollIndicator.vertical: ScrollIndicator {}
} }
Text { AccessibleText {
id: emptyList id: emptyList
visible: true visible: true
color: datovkaPalette.text color: datovkaPalette.text
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "src/qml_interaction/interaction_filesystem.h" #include "src/qml_interaction/interaction_filesystem.h"
#include "src/qml_interaction/interaction_zfo_file.h" #include "src/qml_interaction/interaction_zfo_file.h"
#include "src/qml_interaction/message_envelope.h" #include "src/qml_interaction/message_envelope.h"
#include "src/qml_interaction/string_manipulation.h"
#include "src/settings.h" #include "src/settings.h"
#include "src/setwrapper.h" #include "src/setwrapper.h"
#include "src/sqlite/db_tables.h" #include "src/sqlite/db_tables.h"
...@@ -277,6 +278,7 @@ int main(int argc, char *argv[]) ...@@ -277,6 +278,7 @@ int main(int argc, char *argv[])
Files files; Files files;
IsdsWrapper isds; IsdsWrapper isds;
GlobalSettingsQmlWrapper settings; GlobalSettingsQmlWrapper settings;
StringManipulation strManipulation;
Zfo zfo; Zfo zfo;
/* Connect slot for isds cxt delete when account was deleted or updated */ /* Connect slot for isds cxt delete when account was deleted or updated */
...@@ -336,6 +338,7 @@ int main(int argc, char *argv[]) ...@@ -336,6 +338,7 @@ int main(int argc, char *argv[])
ctx->setContextProperty("accounts", &accounts); ctx->setContextProperty("accounts", &accounts);
ctx->setContextProperty("files", &files); ctx->setContextProperty("files", &files);
ctx->setContextProperty("settings", &settings); ctx->setContextProperty("settings", &settings);
ctx->setContextProperty("strManipulation", &strManipulation);
ctx->setContextProperty("locker", &locker); ctx->setContextProperty("locker", &locker);
ctx->setContextProperty("interactionZfoFile", &interactionZfoFile); ctx->setContextProperty("interactionZfoFile", &interactionZfoFile);
ctx->setContextProperty("dlgEmitter", QmlDlgHelper::dlgEmitter); ctx->setContextProperty("dlgEmitter", QmlDlgHelper::dlgEmitter);
......
/*
* 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 <QXmlStreamReader>
#include "src/qml_interaction/string_manipulation.h"
QString StringManipulation::removeRich(const QString &inStr)
{
QString plainStr;
QXmlStreamReader xml(inStr);
while (!xml.atEnd()) {
if (xml.readNext() == QXmlStreamReader::Characters) {
plainStr += xml.text();
}
}
return plainStr;
}
/*
* 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.
*/
#ifndef _STRING_MANIPULATION_H_
#define _STRING_MANIPULATION_H_
#include <QObject>
#include <QString>
/*!
* @brief Convenience class for string manipulation.
*/
class StringManipulation : public QObject {
Q_OBJECT
public:
/*!
* @brief Converts rich text to plain text.
*
* @param[in] inStr String that may contain rich text tags.
* @return Plain text.
*/
Q_INVOKABLE static
QString removeRich(const QString &inStr);
};
#endif /* _STRING_MANIPULATION_H_ */
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