mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Access view from c+
This commit is contained in:
parent
e357dfb072
commit
dc4b1580b0
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,3 +18,4 @@
|
||||
database.sqlite
|
||||
QtClient/build-*-Debug/
|
||||
*.pro.user
|
||||
notes.sqlite
|
@ -5,7 +5,7 @@ Item {
|
||||
id: root
|
||||
property alias model: listView.model
|
||||
property alias currentIndex: listView.currentIndex
|
||||
signal currentItemChanged()
|
||||
property alias currentItem: listView.currentItem
|
||||
|
||||
Rectangle {
|
||||
color: "#eeeeff"
|
||||
@ -37,8 +37,5 @@ Item {
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
|
||||
focus: true
|
||||
onCurrentItemChanged: {
|
||||
root.currentItemChanged()
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,11 @@ SOURCES += \
|
||||
database.cpp \
|
||||
uuid.cpp \
|
||||
services/folderservice.cpp \
|
||||
models/foldermodel.cpp
|
||||
models/foldermodel.cpp \
|
||||
models/notemodel.cpp \
|
||||
models/note.cpp \
|
||||
services/noteservice.cpp \
|
||||
application.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
@ -28,7 +32,11 @@ HEADERS += \
|
||||
database.h \
|
||||
uuid.h \
|
||||
services/folderservice.h \
|
||||
models/foldermodel.h
|
||||
models/foldermodel.h \
|
||||
models/notemodel.h \
|
||||
models/note.h \
|
||||
services/noteservice.h \
|
||||
application.h
|
||||
|
||||
DISTFILES +=
|
||||
|
||||
|
44
QtClient/JoplinQtClient/NoteList.qml
Executable file
44
QtClient/JoplinQtClient/NoteList.qml
Executable file
@ -0,0 +1,44 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property alias model: listView.model
|
||||
property alias currentIndex: listView.currentIndex
|
||||
signal currentItemChanged()
|
||||
|
||||
Rectangle {
|
||||
color: "#ffeeee"
|
||||
border.color: "#00ff00"
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
Component {
|
||||
id: noteDelegate
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 25
|
||||
Text {
|
||||
text: display
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
listView.currentIndex = index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
anchors.fill: parent
|
||||
delegate: noteDelegate
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
|
||||
focus: true
|
||||
onCurrentItemChanged: {
|
||||
root.currentItemChanged()
|
||||
}
|
||||
}
|
||||
}
|
38
QtClient/JoplinQtClient/application.cpp
Executable file
38
QtClient/JoplinQtClient/application.cpp
Executable file
@ -0,0 +1,38 @@
|
||||
#include "application.h"
|
||||
|
||||
#include "models/folder.h"
|
||||
#include "database.h"
|
||||
#include "models/foldermodel.h"
|
||||
#include "services/folderservice.h"
|
||||
|
||||
using namespace jop;
|
||||
|
||||
Application::Application(int &argc, char **argv) : QGuiApplication(argc, argv) {
|
||||
db_ = Database("D:/Web/www/joplin/notes.sqlite");
|
||||
folderService_ = FolderService(db_);
|
||||
folderModel_.setService(folderService_);
|
||||
|
||||
view_.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
QQmlContext *ctxt = view_.rootContext();
|
||||
ctxt->setContextProperty("folderListModel", &folderModel_);
|
||||
|
||||
view_.setSource(QUrl("qrc:/main.qml"));
|
||||
|
||||
QObject* rootObject = (QObject*)view_.rootObject();
|
||||
|
||||
connect(rootObject, SIGNAL(currentFolderChanged()), this, SLOT(view_currentFolderChanged()));
|
||||
|
||||
view_.show();
|
||||
}
|
||||
|
||||
QString Application::selectedFolderId() const {
|
||||
QObject* rootObject = (QObject*)view_.rootObject();
|
||||
|
||||
int index = rootObject->property("currentFolderIndex").toInt();
|
||||
QModelIndex modelIndex = folderModel_.index(index);
|
||||
return folderModel_.data(modelIndex, FolderModel::IdRole).toString();
|
||||
}
|
||||
|
||||
void Application::view_currentFolderChanged() {
|
||||
qDebug() << selectedFolderId();
|
||||
}
|
36
QtClient/JoplinQtClient/application.h
Executable file
36
QtClient/JoplinQtClient/application.h
Executable file
@ -0,0 +1,36 @@
|
||||
#ifndef APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
#include <stable.h>
|
||||
|
||||
#include "database.h"
|
||||
#include "services/folderservice.h"
|
||||
#include "models/foldermodel.h"
|
||||
|
||||
namespace jop {
|
||||
|
||||
class Application : public QGuiApplication {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
Application(int &argc, char **argv);
|
||||
|
||||
private:
|
||||
|
||||
QQuickView view_;
|
||||
Database db_;
|
||||
FolderService folderService_;
|
||||
FolderModel folderModel_;
|
||||
QString selectedFolderId() const;
|
||||
|
||||
public slots:
|
||||
|
||||
void view_currentFolderChanged();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // APPLICATION_H
|
@ -5,7 +5,7 @@ using namespace jop;
|
||||
Database::Database(const QString &path) {
|
||||
version_ = -1;
|
||||
|
||||
QFile::remove(path);
|
||||
//QFile::remove(path);
|
||||
|
||||
db_ = QSqlDatabase::addDatabase("QSQLITE");
|
||||
db_.setDatabaseName(path);
|
||||
@ -16,7 +16,7 @@ Database::Database(const QString &path) {
|
||||
qDebug() << "Database: connection ok";
|
||||
}
|
||||
|
||||
upgrade();
|
||||
//upgrade();
|
||||
}
|
||||
|
||||
Database::Database() {}
|
||||
@ -80,11 +80,11 @@ void Database::upgrade() {
|
||||
|
||||
db_.exec("CREATE TABLE folders (id TEXT PRIMARY KEY, title TEXT, created_time INT)");
|
||||
|
||||
for (int i = 1; i < 100; i++) {
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
QString title = QString::number(i);
|
||||
db_.exec(QString("INSERT INTO folders (id, title, created_time) VALUES (\"%1\", \"%2\", 1481235571)").arg(uuid.toString(), title.repeated(10)));
|
||||
}
|
||||
// for (int i = 1; i < 100; i++) {
|
||||
// QUuid uuid = QUuid::createUuid();
|
||||
// QString title = QString::number(i);
|
||||
// db_.exec(QString("INSERT INTO folders (id, title, created_time) VALUES (\"%1\", \"%2\", 1481235571)").arg(uuid.toString(), title.repeated(10)));
|
||||
// }
|
||||
|
||||
//db_.exec("INSERT INTO folders (id, title, created_time) VALUES (\"ed735d55415bee976b771989be8f7005\", \"bbbb\", 1481235571)");
|
||||
//db_.exec("INSERT INTO folders (id, title, created_time) VALUES (\"5d41402abc4b2a76b9719d911017c592\", \"cccc\", 1481235571)");
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stable.h>
|
||||
|
||||
#include "application.h"
|
||||
#include "models/folder.h"
|
||||
#include "database.h"
|
||||
#include "models/foldermodel.h"
|
||||
@ -9,73 +10,6 @@ using namespace jop;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
Database db("D:/Web/www/joplin/database.sqlite");
|
||||
|
||||
// FolderService s(db);
|
||||
// qDebug() << s.count();
|
||||
|
||||
// Folder f = s.byId("35dbdd6e633566c4160e699a86601ab8");
|
||||
// qDebug() << f.id() << f.title() << f.createdTime();
|
||||
|
||||
// QSqlQuery q = db.query("SELECT * FROM folders WHERE id = :id");
|
||||
// q.bindValue(":id", "35dbdd6e633566c4160e699a86601ab8");
|
||||
// q.exec();
|
||||
// q.next();
|
||||
|
||||
//qDebug() << q.isValid();
|
||||
|
||||
// Folder f;
|
||||
// f.fromSqlQuery(q);
|
||||
|
||||
// qDebug() << f.title() << f.id() << f.createdTime();
|
||||
|
||||
|
||||
//QSqlQuery q = query("SELECT * FROM folders WHERE id = :id");
|
||||
//q.bindValue(":id", "a");
|
||||
//q.exec();
|
||||
|
||||
|
||||
FolderService folderService(db);
|
||||
FolderModel model(folderService);
|
||||
|
||||
//Folder* f = new Folder(); f->setTitle("oneXXX"); model.addFolder(f);
|
||||
//f = new Folder(); f->setTitle("two"); model.addFolder(f);
|
||||
//f = new Folder(); f->setTitle("three"); model.addFolder(f);
|
||||
|
||||
// QQuickView view;
|
||||
// view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
// QQmlContext *ctxt = view.rootContext();
|
||||
// ctxt->setContextProperty("myModel", &model);
|
||||
|
||||
|
||||
|
||||
// QSqlDatabase m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
// m_db.setDatabaseName("D:/Web/www/joplin/QtClient/JoplinQtClient/test.sqlite3");
|
||||
|
||||
// if (!m_db.open())
|
||||
// {
|
||||
// qDebug() << "Error: connection with database fail";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// qDebug() << "Database: connection ok";
|
||||
// }
|
||||
|
||||
//QQmlApplicationEngine engine;
|
||||
//engine.load(QUrl(QLatin1String("qrc:/main.qml")));
|
||||
|
||||
QQuickView view;
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
QQmlContext *ctxt = view.rootContext();
|
||||
ctxt->setContextProperty("folderTreeViewModel", &model);
|
||||
|
||||
view.setSource(QUrl("qrc:/main.qml"));
|
||||
|
||||
|
||||
view.show();
|
||||
|
||||
|
||||
Application app(argc, argv);
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -4,17 +4,20 @@ import QtQuick.Controls 1.4
|
||||
import QtQuick.Layouts 1.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
width: 800
|
||||
height: 600
|
||||
signal currentFolderChanged()
|
||||
property alias currentFolderIndex: folderList.currentIndex
|
||||
|
||||
RowLayout {
|
||||
id: layout
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
FolderListView {
|
||||
id: folderTreeView
|
||||
model: folderTreeViewModel
|
||||
FolderList {
|
||||
id: folderList
|
||||
model: folderListModel
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.minimumWidth: 50
|
||||
@ -23,105 +26,19 @@ Item {
|
||||
Layout.minimumHeight: 150
|
||||
|
||||
onCurrentItemChanged: {
|
||||
console.info(folderTreeView.currentIndex)
|
||||
root.currentFolderChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// Rectangle {
|
||||
// color: 'teal'
|
||||
// Layout.fillWidth: true
|
||||
// Layout.minimumWidth: 50
|
||||
// Layout.preferredWidth: 100
|
||||
// Layout.maximumWidth: 300
|
||||
// Layout.minimumHeight: 150
|
||||
// Text {
|
||||
// anchors.centerIn: parent
|
||||
// text: parent.width + 'x' + parent.height
|
||||
// }
|
||||
// }
|
||||
Rectangle {
|
||||
color: 'plum'
|
||||
NoteList {
|
||||
id: noteList
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.minimumWidth: 100
|
||||
Layout.preferredWidth: 200
|
||||
Layout.preferredHeight: 100
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: parent.width + 'x' + parent.height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// visible: true
|
||||
// width: 640
|
||||
// height: 480
|
||||
// //title: qsTr("Hello World")
|
||||
|
||||
// RowLayout {
|
||||
|
||||
// anchors.fill: parent
|
||||
|
||||
// FolderTreeView {
|
||||
// id: folderTreeView
|
||||
// model: folderTreeViewModel
|
||||
// width: 200
|
||||
// //height: 500
|
||||
// //currentIndex: folderTreeViewCurrentIndex
|
||||
// anchors.fill: parent
|
||||
// onCurrentItemChanged: {
|
||||
// console.info(folderTreeView.currentIndex)
|
||||
// //folderTreeViewCurrentIndex = folderTreeView.currentIndex
|
||||
// }
|
||||
// }
|
||||
|
||||
// Rectangle {
|
||||
// color: 'plum'
|
||||
// Text {
|
||||
// anchors.centerIn: parent
|
||||
// text: parent.width + 'x' + parent.height
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//import QtQuick 2.7
|
||||
//import QtQuick.Controls 2.0
|
||||
//import QtQuick.Controls 1.4
|
||||
//import QtQuick.Layouts 1.0
|
||||
|
||||
//ApplicationWindow {
|
||||
// visible: true
|
||||
// width: 640
|
||||
// height: 480
|
||||
// title: qsTr("Hello World")
|
||||
|
||||
// SwipeView {
|
||||
// id: swipeView
|
||||
// anchors.fill: parent
|
||||
// currentIndex: tabBar.currentIndex
|
||||
|
||||
// Page1 {
|
||||
// }
|
||||
|
||||
// Page {
|
||||
// Label {
|
||||
// text: qsTr("Second page")
|
||||
// anchors.centerIn: parent
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// footer: TabBar {
|
||||
// id: tabBar
|
||||
// currentIndex: swipeView.currentIndex
|
||||
// TabButton {
|
||||
// text: qsTr("First")
|
||||
// }
|
||||
// TabButton {
|
||||
// text: qsTr("Second")
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
using namespace jop;
|
||||
|
||||
//FolderModel::FolderModel() : QAbstractListModel() {}
|
||||
FolderModel::FolderModel() : QAbstractListModel() {}
|
||||
|
||||
FolderModel::FolderModel(FolderService &folderService) : QAbstractListModel() {
|
||||
void FolderModel::setService(FolderService &folderService) {
|
||||
folderService_ = folderService;
|
||||
}
|
||||
|
||||
@ -33,13 +33,18 @@ QVariant FolderModel::data(const QModelIndex & index, int role) const {
|
||||
return QVariant(folder.title());
|
||||
}
|
||||
|
||||
if (role == IdRole) {
|
||||
return QVariant(folder.id());
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> FolderModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
|
||||
roles[TitleRole] = "title";
|
||||
roles[UuidRole] = "uuid";
|
||||
roles[IdRole] = "uuid";
|
||||
roles[RawRole] = "raw";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,14 @@ class FolderModel : public QAbstractListModel {
|
||||
public:
|
||||
|
||||
enum FolderRoles {
|
||||
UuidRole = Qt::UserRole + 1,
|
||||
TitleRole
|
||||
IdRole = Qt::UserRole + 1,
|
||||
TitleRole,
|
||||
RawRole
|
||||
};
|
||||
|
||||
//FolderModel();
|
||||
FolderModel(FolderService& folderService);
|
||||
FolderModel();
|
||||
|
||||
void setService(FolderService& folderService);
|
||||
|
||||
void addFolder(Folder* folder);
|
||||
|
||||
|
@ -12,12 +12,12 @@ void Item::fromSqlQuery(const QSqlQuery &q) {
|
||||
int i_title = q.record().indexOf("title");
|
||||
int i_created_time = q.record().indexOf("created_time");
|
||||
|
||||
id_ = jop::uuid::fromString(q.value(i_id).toString());
|
||||
id_ = q.value(i_id).toString();
|
||||
title_ = q.value(i_title).toString();
|
||||
createdTime_ = q.value(i_created_time).toInt();
|
||||
}
|
||||
|
||||
QUuid Item::id() const {
|
||||
QString Item::id() const {
|
||||
return id_;
|
||||
}
|
||||
|
||||
@ -29,13 +29,8 @@ int Item::createdTime() const {
|
||||
return createdTime_;
|
||||
}
|
||||
|
||||
void Item::setId(const QUuid &v) {
|
||||
id_ = v;
|
||||
}
|
||||
|
||||
void Item::setId(const QString& v) {
|
||||
QUuid u = uuid::fromString(v);
|
||||
setId(u);
|
||||
id_ = v;
|
||||
}
|
||||
|
||||
void Item::setTitle(const QString &v) {
|
||||
|
@ -11,12 +11,11 @@ public:
|
||||
|
||||
Item();
|
||||
|
||||
QUuid id() const;
|
||||
QString id() const;
|
||||
QString title() const;
|
||||
int createdTime() const;
|
||||
bool isPartial() const;
|
||||
|
||||
void setId(const QUuid& v);
|
||||
void setId(const QString& v);
|
||||
void setTitle(const QString& v);
|
||||
void setCreatedTime(int v);
|
||||
@ -26,7 +25,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
QUuid id_;
|
||||
QString id_;
|
||||
QString title_;
|
||||
int createdTime_;
|
||||
bool isPartial_;
|
||||
|
8
QtClient/JoplinQtClient/models/note.cpp
Executable file
8
QtClient/JoplinQtClient/models/note.cpp
Executable file
@ -0,0 +1,8 @@
|
||||
#include "note.h"
|
||||
|
||||
using namespace jop;
|
||||
|
||||
Note::Note()
|
||||
{
|
||||
|
||||
}
|
23
QtClient/JoplinQtClient/models/note.h
Executable file
23
QtClient/JoplinQtClient/models/note.h
Executable file
@ -0,0 +1,23 @@
|
||||
#ifndef NOTE_H
|
||||
#define NOTE_H
|
||||
|
||||
#include <stable.h>
|
||||
#include "models/item.h"
|
||||
|
||||
namespace jop {
|
||||
|
||||
class Note : public Item {
|
||||
|
||||
public:
|
||||
|
||||
Note();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NOTE_H
|
25
QtClient/JoplinQtClient/models/notemodel.cpp
Executable file
25
QtClient/JoplinQtClient/models/notemodel.cpp
Executable file
@ -0,0 +1,25 @@
|
||||
#include "notemodel.h"
|
||||
|
||||
jop::NoteModel::NoteModel(NoteService ¬eService)
|
||||
{
|
||||
noteService_ = noteService;
|
||||
}
|
||||
|
||||
int jop::NoteModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariant jop::NoteModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> jop::NoteModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
|
||||
// roles[TitleRole] = "title";
|
||||
// roles[UuidRole] = "uuid";
|
||||
return roles;
|
||||
|
||||
}
|
33
QtClient/JoplinQtClient/models/notemodel.h
Executable file
33
QtClient/JoplinQtClient/models/notemodel.h
Executable file
@ -0,0 +1,33 @@
|
||||
#ifndef NOTEMODEL_H
|
||||
#define NOTEMODEL_H
|
||||
|
||||
#include <stable.h>
|
||||
|
||||
#include "services/noteservice.h"
|
||||
|
||||
namespace jop {
|
||||
|
||||
class NoteModel : public QAbstractListModel {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
NoteModel(NoteService ¬eService);
|
||||
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||
|
||||
protected:
|
||||
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
private:
|
||||
|
||||
QList<Note> notes_;
|
||||
NoteService noteService_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NOTEMODEL_H
|
@ -1,9 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>Page1.qml</file>
|
||||
<file>Page1Form.ui.qml</file>
|
||||
<file>FolderListView.qml</file>
|
||||
<file>TestUnQuatre.qml</file>
|
||||
<file>FolderList.qml</file>
|
||||
<file>NoteList.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
26
QtClient/JoplinQtClient/services/noteservice.cpp
Executable file
26
QtClient/JoplinQtClient/services/noteservice.cpp
Executable file
@ -0,0 +1,26 @@
|
||||
#include "noteservice.h"
|
||||
|
||||
using namespace jop;
|
||||
|
||||
NoteService::NoteService() {}
|
||||
|
||||
NoteService::NoteService(jop::Database &database) {
|
||||
database_ = database;
|
||||
}
|
||||
|
||||
int NoteService::count(int parentFolderId) const {
|
||||
QSqlQuery q = database_.query("SELECT count(*) as row_count FROM notes WHERE parent_id = :parent_id");
|
||||
q.bindValue(":parent_id", parentFolderId);
|
||||
q.exec();
|
||||
q.next();
|
||||
return q.value(0).toInt();
|
||||
}
|
||||
|
||||
Note NoteService::byId(const QString &id) const {
|
||||
Note n;
|
||||
return n;
|
||||
}
|
||||
|
||||
const QList<Note> NoteService::overviewList(const QString &orderBy, int from, int to) const {
|
||||
return QList<Note>();
|
||||
}
|
29
QtClient/JoplinQtClient/services/noteservice.h
Executable file
29
QtClient/JoplinQtClient/services/noteservice.h
Executable file
@ -0,0 +1,29 @@
|
||||
#ifndef NOTESERVICE_H
|
||||
#define NOTESERVICE_H
|
||||
|
||||
#include <stable.h>
|
||||
#include "database.h"
|
||||
#include "models/note.h"
|
||||
|
||||
namespace jop {
|
||||
|
||||
class NoteService {
|
||||
|
||||
public:
|
||||
|
||||
NoteService();
|
||||
NoteService(Database& database);
|
||||
int count(int parentFolderId) const;
|
||||
Note byId(const QString& id) const;
|
||||
const QList<Note> overviewList(const QString& orderBy, int from, int to) const;
|
||||
|
||||
private:
|
||||
|
||||
Database database_;
|
||||
mutable QList<Note> cache_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NOTESERVICE_H
|
@ -4,19 +4,21 @@
|
||||
#if defined __cplusplus
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QGuiApplication>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlRecord>
|
||||
#include <QUuid>
|
||||
#include <vector>
|
||||
//#include <QUuid>
|
||||
//#include <vector>
|
||||
#include <QList>
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QSqlDatabase>
|
||||
#include <QQuickView>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlProperty>
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
@ -4,19 +4,19 @@
|
||||
namespace jop {
|
||||
namespace uuid {
|
||||
|
||||
QUuid fromString(const QString& s) {
|
||||
// {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
|
||||
QString mod = s;
|
||||
mod.insert(8, '-');
|
||||
mod.insert(13, '-');
|
||||
mod.insert(18, '-');
|
||||
mod.insert(23, '-');
|
||||
mod = "{" + mod + "}";
|
||||
//QUuid fromString(const QString& s) {
|
||||
// // {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
|
||||
// QString mod = s;
|
||||
// mod.insert(8, '-');
|
||||
// mod.insert(13, '-');
|
||||
// mod.insert(18, '-');
|
||||
// mod.insert(23, '-');
|
||||
// mod = "{" + mod + "}";
|
||||
|
||||
qDebug() << mod;
|
||||
// //qDebug() << mod;
|
||||
|
||||
return QUuid(mod);
|
||||
}
|
||||
// return QUuid(mod);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
namespace jop {
|
||||
namespace uuid {
|
||||
|
||||
QUuid fromString(const QString& s);
|
||||
//QUuid fromString(const QString& s);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user