diff options
author | rtk0c <[email protected]> | 2022-07-01 18:12:31 +0000 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-07-01 18:12:31 +0000 |
commit | b992ae0fa4d792002ffae10a9ef893ef4fa42ac4 (patch) | |
tree | b3bfd176df672eefd9a6a627bfeddd03f22cf458 /ui.qt/source | |
parent | fa744c91b0b15d5978e915816e712e388ead7e64 (diff) |
Convert hardcoding files in CMakeLists.txt to file(GLOB)
git-svn-id: file:///home/arch/svn/epistmool/trunk@8 71f44415-077c-4ad7-a976-72ddbf76608f
Diffstat (limited to 'ui.qt/source')
-rw-r--r-- | ui.qt/source/DatabaseClient.cpp | 5 | ||||
-rw-r--r-- | ui.qt/source/DatabaseClient.hpp | 7 | ||||
-rw-r--r-- | ui.qt/source/DatabaseServer.cpp | 5 | ||||
-rw-r--r-- | ui.qt/source/DatabaseServer.hpp | 7 | ||||
-rw-r--r-- | ui.qt/source/Document.cpp | 152 | ||||
-rw-r--r-- | ui.qt/source/Document.hpp | 72 | ||||
-rw-r--r-- | ui.qt/source/Keyword.cpp | 10 | ||||
-rw-r--r-- | ui.qt/source/Keyword.hpp | 26 | ||||
-rw-r--r-- | ui.qt/source/KnowledgeFragment.cpp | 11 | ||||
-rw-r--r-- | ui.qt/source/KnowledgeFragment.hpp | 38 | ||||
-rw-r--r-- | ui.qt/source/fwd.hpp | 13 | ||||
-rw-r--r-- | ui.qt/source/main.cpp | 35 | ||||
-rw-r--r-- | ui.qt/source/qml/Document.qml | 163 | ||||
-rw-r--r-- | ui.qt/source/qml/GoToKnowledge.qml | 4 | ||||
-rw-r--r-- | ui.qt/source/qml/MainWindow.qml | 21 | ||||
-rw-r--r-- | ui.qt/source/qml/Navigator.qml | 36 |
16 files changed, 0 insertions, 605 deletions
diff --git a/ui.qt/source/DatabaseClient.cpp b/ui.qt/source/DatabaseClient.cpp deleted file mode 100644 index 430fe79..0000000 --- a/ui.qt/source/DatabaseClient.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "DatabaseClient.hpp" - -DatabaseClient::DatabaseClient() -{ -} diff --git a/ui.qt/source/DatabaseClient.hpp b/ui.qt/source/DatabaseClient.hpp deleted file mode 100644 index 17c6ed7..0000000 --- a/ui.qt/source/DatabaseClient.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -class DatabaseClient -{ -public: - DatabaseClient(); -}; diff --git a/ui.qt/source/DatabaseServer.cpp b/ui.qt/source/DatabaseServer.cpp deleted file mode 100644 index a850e63..0000000 --- a/ui.qt/source/DatabaseServer.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "DatabaseServer.hpp" - -DatabaseServer::DatabaseServer() -{ -} diff --git a/ui.qt/source/DatabaseServer.hpp b/ui.qt/source/DatabaseServer.hpp deleted file mode 100644 index 0cd5039..0000000 --- a/ui.qt/source/DatabaseServer.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -class DatabaseServer -{ -public: - DatabaseServer(); -}; diff --git a/ui.qt/source/Document.cpp b/ui.qt/source/Document.cpp deleted file mode 100644 index 272ac4c..0000000 --- a/ui.qt/source/Document.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "Document.hpp" - -#include <QBrush> -#include <QColor> -#include <QTextCursor> -#include <QVariant> - -DocumentHandler::DocumentHandler(QObject* parent) - : QObject{ parent } -{ -} - -QQuickTextDocument* DocumentHandler::getDoc() const -{ - return mDoc; -} - -void DocumentHandler::setDoc(QQuickTextDocument* newDoc) -{ - if (mDoc != newDoc) { - auto oldDoc = mDoc; - mDoc = newDoc; - - if (oldDoc) { - disconnect(oldDoc->textDocument(), nullptr, this, nullptr); - } - if (newDoc) { - connect(newDoc->textDocument(), &QTextDocument::modificationChanged, this, [&]() { - // TODO add a timer to wait for 1 second before updating? - mModifyTime = QDateTime::currentDateTime(); - emit modificationChanged(); - }); - } - - emit docChanged(oldDoc); - } -} - -const QDateTime& DocumentHandler::getModifyTime() const -{ - return mModifyTime; -} - -int DocumentHandler::getCursorPos() const -{ - return mCursorPos; -} - -void DocumentHandler::setCursorPos(int newCursorPos) -{ - if (mCursorPos == newCursorPos) { - return; - } - mCursorPos = newCursorPos; - emit cursorPosChanged(); -} - -int DocumentHandler::getSelectionBegin() const -{ - return mSelectionBegin; -} - -void DocumentHandler::setSelectionBegin(int newSelectionBegin) -{ - if (mSelectionBegin == newSelectionBegin) { - return; - } - mSelectionBegin = newSelectionBegin; - emit selectionBeginChanged(); -} - -int DocumentHandler::getSelectionEnd() const -{ - return mSelectionEnd; -} - -void DocumentHandler::setSelectionEnd(int newSelectionEnd) -{ - if (mSelectionEnd == newSelectionEnd) { - return; - } - mSelectionEnd = newSelectionEnd; - emit selectionEndChanged(); -} - -QFont DocumentHandler::getActiveFont() const -{ - auto cursor = makeTextCursor(); - if (cursor.isNull()) { - return mDoc->textDocument()->defaultFont(); - } - auto format = cursor.charFormat(); - return format.font(); -} - -void DocumentHandler::setActiveFont(const QFont& font) -{ - auto cursor = makeTextCursor(); - if (!cursor.isNull() && cursor.charFormat().font() == font) { - return; - } - - QTextCharFormat format; - format.setFont(font); - mergeFormatOnWordOrSelection(format); - - emit activeFontChanged(); -} - -QColor DocumentHandler::getActiveTextColor() const -{ - auto cursor = makeTextCursor(); - if (cursor.isNull()) { - return QColor(Qt::black); - } - QTextCharFormat format = cursor.charFormat(); - return format.foreground().color(); -} - -void DocumentHandler::setActiveTextColor(const QColor& color) -{ - QTextCharFormat format; - format.setForeground(QBrush(color)); - mergeFormatOnWordOrSelection(format); - emit activeTextColorChanged(); -} - -QTextCursor DocumentHandler::makeTextCursor() const -{ - auto doc = mDoc->textDocument(); - if (!doc) { - return QTextCursor(); - } - - QTextCursor cursor(doc); - if (mSelectionBegin != mSelectionEnd) { - cursor.setPosition(mSelectionBegin); - cursor.setPosition(mSelectionEnd, QTextCursor::KeepAnchor); - } else { - cursor.setPosition(mCursorPos); - } - return cursor; -} - -void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat& format) -{ - auto cursor = makeTextCursor(); - if (!cursor.hasSelection()) { - cursor.select(QTextCursor::WordUnderCursor); - } - cursor.mergeCharFormat(format); -} diff --git a/ui.qt/source/Document.hpp b/ui.qt/source/Document.hpp deleted file mode 100644 index 5ef1bba..0000000 --- a/ui.qt/source/Document.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include "fwd.hpp" - -#include <QAbstractItemModel> -#include <QDateTime> -#include <QObject> -#include <QQuickTextDocument> -#include <QTextCharFormat> - -// To be instanciated in QML as the logic backend to some TextArea -class DocumentHandler : public QObject -{ - Q_OBJECT - QML_ELEMENT - - Q_PROPERTY(QQuickTextDocument* document READ getDoc WRITE setDoc NOTIFY docChanged) - Q_PROPERTY(QDateTime modifyTime READ getModifyTime NOTIFY modificationChanged) - - Q_PROPERTY(int cursorPos READ getCursorPos WRITE setCursorPos NOTIFY cursorPosChanged) - Q_PROPERTY(int selectionBegin READ getSelectionBegin WRITE setSelectionBegin NOTIFY selectionBeginChanged) - Q_PROPERTY(int selectionEnd READ getSelectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) - - Q_PROPERTY(QFont activeFont READ getActiveFont WRITE setActiveFont NOTIFY activeFontChanged) - Q_PROPERTY(QColor activeTextColor READ getActiveTextColor WRITE setActiveTextColor NOTIFY activeTextColorChanged) - -private: - QQuickTextDocument* mDoc = nullptr; - QDateTime mModifyTime; - - int mCursorPos; - int mSelectionBegin; - int mSelectionEnd; - -public: - explicit DocumentHandler(QObject* parent = nullptr); - - QQuickTextDocument* getDoc() const; - void setDoc(QQuickTextDocument* newDoc); - - const QDateTime& getModifyTime() const; - - int getCursorPos() const; - void setCursorPos(int newCursorPos); - - int getSelectionBegin() const; - void setSelectionBegin(int newSelectionBegin); - - int getSelectionEnd() const; - void setSelectionEnd(int newSelectionEnd); - - QFont getActiveFont() const; - void setActiveFont(const QFont& font); - - QColor getActiveTextColor() const; - void setActiveTextColor(const QColor& color); - -signals: - void docChanged(QQuickTextDocument* oldDoc); - void modificationChanged(); // Redirected from the currently bound document - - void cursorPosChanged(); - void selectionBeginChanged(); - void selectionEndChanged(); - - void activeFontChanged(); - void activeTextColorChanged(); - -private: - QTextCursor makeTextCursor() const; - void mergeFormatOnWordOrSelection(const QTextCharFormat& format); -}; diff --git a/ui.qt/source/Keyword.cpp b/ui.qt/source/Keyword.cpp deleted file mode 100644 index f6c18be..0000000 --- a/ui.qt/source/Keyword.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Keyword.hpp" - -#include "KnowledgeFragment.hpp" - -Keyword::Keyword(const QString& name) - : mName(name) -{ -} - -Keyword::~Keyword() = default; diff --git a/ui.qt/source/Keyword.hpp b/ui.qt/source/Keyword.hpp deleted file mode 100644 index 481b5bb..0000000 --- a/ui.qt/source/Keyword.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "fwd.hpp" - -#include <QString> -#include <vector> - -class Keyword -{ -private: - QString mName; - std::vector<KnowledgeId> mAssociations; - -public: - Keyword(const QString& name); - ~Keyword(); - - Keyword(const Keyword&) = default; - Keyword& operator=(const Keyword&) = default; - Keyword(Keyword&&) = default; - Keyword& operator=(Keyword&&) = default; -}; - -class KeywordDatabase -{ -}; diff --git a/ui.qt/source/KnowledgeFragment.cpp b/ui.qt/source/KnowledgeFragment.cpp deleted file mode 100644 index 3d08f6e..0000000 --- a/ui.qt/source/KnowledgeFragment.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "KnowledgeFragment.hpp" - -KnowledgeFragment::KnowledgeFragment(KnowledgeId id) - : mId{ id } -{ -} - -KnowledgeId KnowledgeFragment::getId() const -{ - return mId; -} diff --git a/ui.qt/source/KnowledgeFragment.hpp b/ui.qt/source/KnowledgeFragment.hpp deleted file mode 100644 index 9f4912d..0000000 --- a/ui.qt/source/KnowledgeFragment.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "fwd.hpp" - -#include <QDateTime> -#include <cstddef> -#include <vector> - -struct KnowledgeId -{ - size_t id; -}; - -class KnowledgeFragment -{ -private: - QDateTime mCreateTime; - QDateTime mModifyTime; - KnowledgeId mId; - -public: - KnowledgeFragment(KnowledgeId id); - - KnowledgeId getId() const; -}; - -class KnowledgeDatabase -{ -private: - std::vector<KnowledgeFragment> mStorage; - std::vector<size_t> mIndex; // Mapping from KnowledgeId (index) to `storage` index - KnowledgeId mNextId; - -public: - KnowledgeId allocateFragment(); - bool deleteFragment(KnowledgeId id); - KnowledgeFragment* getFragment(KnowledgeId id); -}; diff --git a/ui.qt/source/fwd.hpp b/ui.qt/source/fwd.hpp deleted file mode 100644 index 14e0033..0000000 --- a/ui.qt/source/fwd.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -// Document.hpp -class DocumentHandler; - -// Keyword.hpp -class Keyword; -class KeywordDatabase; - -// Knowledgefragment.cpp -struct KnowledgeId; -class KnowledgeFragment; -class KnowledgeDatabase; diff --git a/ui.qt/source/main.cpp b/ui.qt/source/main.cpp deleted file mode 100644 index 863ee20..0000000 --- a/ui.qt/source/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include <QApplication> -#include <QLocale> -#include <QQmlApplicationEngine> -#include <QTranslator> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QTranslator translator; - const QStringList uiLanguages = QLocale::system().uiLanguages(); - for (const QString& locale : uiLanguages) { - const QString baseName = "EpistmoolUI_" + QLocale(locale).name(); - if (translator.load(":/i18n/" + baseName)) { - app.installTranslator(&translator); - break; - } - } - - QQmlApplicationEngine engine; - const QUrl url(u"qrc:/EpistmoolUI/source/qml/MainWindow.qml"_qs); - QObject::connect( - &engine, - &QQmlApplicationEngine::objectCreated, - &app, - [url](QObject* obj, const QUrl& objUrl) { - if (!obj && url == objUrl) { - QCoreApplication::exit(-1); - } - }, - Qt::QueuedConnection); - engine.load(url); - - return app.exec(); -} diff --git a/ui.qt/source/qml/Document.qml b/ui.qt/source/qml/Document.qml deleted file mode 100644 index a3d4075..0000000 --- a/ui.qt/source/qml/Document.qml +++ /dev/null @@ -1,163 +0,0 @@ -import QtCore -import QtQuick -import QtQuick.Controls -import QtQuick.Dialogs -import Qt.labs.platform as Platform - -import EpistmoolUI - -Item { - Action { - id: boldAction - shortcut: StandardKey.Bold - onTriggered: docHandler.bold = !docHandler.bold - } - - Action { - id: italicAction - shortcut: StandardKey.Italic - onTriggered: docHandler.italic = !docHandler.italic - } - - Action { - id: underlineAction - shortcut: StandardKey.Underline - onTriggered: docHandler.underline = !docHandler.underline - } - - Action { - id: strikeoutAction - shortcut: "Ctrl+Shift+X" - onTriggered: docHandler.strikeout = !docHandler.strikeout - } - - Platform.ColorDialog { - id: colorDialog - currentColor: "black" - } - - Item { - id: toolbar - width: parent.width - height: childrenRect.height - - Row { - id: toolbarLeft - layoutDirection: Qt.LeftToRight - - ToolButton { - id: boldButton - text: "B" - font.bold: true - focusPolicy: Qt.TabFocus - checkable: true - checked: docHandler.bold - action: boldAction - } - ToolButton { - id: italicButton - text: "I" - font.italic: true - focusPolicy: Qt.TabFocus - checkable: true - checked: docHandler.italic - action: italicAction - } - ToolButton { - id: underlineButton - text: "U" - font.underline: true - focusPolicy: Qt.TabFocus - checkable: true - checked: docHandler.underline - action: underlineAction - } - ToolButton { - id: strikeoutButton - text: "S" - font.strikeout: true - focusPolicy: Qt.TabFocus - checkable: true - checked: docHandler.strikeout - action: strikeoutAction - } - ToolButton { - id: textColorButton - text: "\uF1FC" // icon-brush - font.family: "fontello" - focusPolicy: Qt.TabFocus - onClicked: colorDialog.open() - - Rectangle { - width: aFontMetrics.width + 3 - height: 2 - color: docHandler.activeTextColor - parent: textColorButton.contentItem - anchors.horizontalCenter: parent.horizontalCenter - anchors.baseline: parent.baseline - anchors.baselineOffset: 6 - - TextMetrics { - id: aFontMetrics - font: textColorButton.font - text: textColorButton.text - } - } - } - } - - Row { - id: toolbarRight - layoutDirection: Qt.RightToLeft - height: parent.height - anchors.left: toolbarLeft.right - anchors.right: parent.right - - Label { - text: docHandler.modifyTime.toLocaleTimeString() - - ToolTip.visible: ma.containsMouse - ToolTip.text: docHandler.modifyTime.toLocaleString() - - MouseArea { - id: ma - anchors.fill: parent - hoverEnabled: true - } - } - } - } - - DocumentHandler { - id: docHandler - document: textArea.textDocument - - // Binding for current editing state of the TextArea - cursorPos: textArea.cursorPosition - selectionBegin: textArea.selectionStart - selectionEnd: textArea.selectionEnd - - property alias family: docHandler.activeFont.family - property alias bold: docHandler.activeFont.bold - property alias italic: docHandler.activeFont.italic - property alias underline: docHandler.activeFont.underline - property alias strikeout: docHandler.activeFont.strikeout - property alias size: docHandler.activeFont.pointSize - } - - ScrollView { - id: scrollView - width: parent.width - anchors.top: toolbar.bottom - anchors.bottom: parent.bottom - - TextArea { - id: textArea - textFormat: Qt.RichText - wrapMode: TextArea.Wrap - focus: true - selectByMouse: true - persistentSelection: true - } - } -} diff --git a/ui.qt/source/qml/GoToKnowledge.qml b/ui.qt/source/qml/GoToKnowledge.qml deleted file mode 100644 index f97cbcf..0000000 --- a/ui.qt/source/qml/GoToKnowledge.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick - -Item { -} diff --git a/ui.qt/source/qml/MainWindow.qml b/ui.qt/source/qml/MainWindow.qml deleted file mode 100644 index d81fb4f..0000000 --- a/ui.qt/source/qml/MainWindow.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick - -Window { - width: 640 - height: 480 - visible: true - title: qsTr("Hello World") - - Navigator { - id: navigator - width: childrenRect.width - height: parent.height - } - - Document { - id: document - height: parent.height - anchors.left: navigator.right - anchors.right: parent.right - } -} diff --git a/ui.qt/source/qml/Navigator.qml b/ui.qt/source/qml/Navigator.qml deleted file mode 100644 index 40c66e4..0000000 --- a/ui.qt/source/qml/Navigator.qml +++ /dev/null @@ -1,36 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -Item { - ColumnLayout { - spacing: 0 - - Button { - contentItem: Label { - text: qsTr("Settings") - anchors.verticalCenter: parent.verticalCenter - } - - Layout.fillWidth: true - } - - Button { - contentItem: Label { - text: qsTr("Keyword") - anchors.verticalCenter: parent.verticalCenter - } - - Layout.fillWidth: true - } - - Button { - contentItem: Label { - text: qsTr("Knowledge Fragments") - anchors.verticalCenter: parent.verticalCenter - } - - Layout.fillWidth: true - } - } -} |