1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-17 11:26:26 +02:00
joplin/QtClient/JoplinQtClient/application.cpp

39 lines
1.1 KiB
C++
Raw Normal View History

2016-12-11 16:09:39 +00:00
#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();
}