diff --git a/QtClient/JoplinQtClient/JoplinQtClient.pro b/QtClient/JoplinQtClient/JoplinQtClient.pro index c115d37f0f..9acd0d989f 100755 --- a/QtClient/JoplinQtClient/JoplinQtClient.pro +++ b/QtClient/JoplinQtClient/JoplinQtClient.pro @@ -32,7 +32,6 @@ SOURCES += \ models/foldermodel.cpp \ models/notemodel.cpp \ models/note.cpp \ - models/qmlnote.cpp \ webapi.cpp \ synchronizer.cpp \ settings.cpp \ @@ -71,7 +70,6 @@ HEADERS += \ models/notemodel.h \ models/note.h \ sparsevector.hpp \ - models/qmlnote.h \ webapi.h \ synchronizer.h \ settings.h \ diff --git a/QtClient/JoplinQtClient/application.cpp b/QtClient/JoplinQtClient/application.cpp index bd1a3b643c..4c4debcab2 100755 --- a/QtClient/JoplinQtClient/application.cpp +++ b/QtClient/JoplinQtClient/application.cpp @@ -53,7 +53,7 @@ Application::Application(int &argc, char **argv) : QQmlContext *ctxt = view_.rootContext(); ctxt->setContextProperty("folderListModel", &folderModel_); ctxt->setContextProperty("noteListModel", ¬eModel_); - ctxt->setContextProperty("noteModel", &selectedQmlNote_); + //ctxt->setContextProperty("noteModel", &selectedQmlNote_); ctxt->setContextProperty("settings", qmlSettings); view_.setSource(QUrl("qrc:/app.qml")); diff --git a/QtClient/JoplinQtClient/application.h b/QtClient/JoplinQtClient/application.h index 20ceb865be..6996e8fc4b 100755 --- a/QtClient/JoplinQtClient/application.h +++ b/QtClient/JoplinQtClient/application.h @@ -6,7 +6,6 @@ #include "database.h" #include "models/foldermodel.h" #include "models/notemodel.h" -#include "models/qmlnote.h" #include "webapi.h" #include "synchronizer.h" #include "window.h" @@ -31,7 +30,6 @@ private: NoteModel noteModel_; QString selectedFolderId() const; QString selectedNoteId() const; - QmlNote selectedQmlNote_; WebApi api_; Synchronizer synchronizer_; QTimer synchronizerTimer_; diff --git a/QtClient/JoplinQtClient/baseitemlistcontroller.cpp b/QtClient/JoplinQtClient/baseitemlistcontroller.cpp index e25d01d376..95ff34b687 100755 --- a/QtClient/JoplinQtClient/baseitemlistcontroller.cpp +++ b/QtClient/JoplinQtClient/baseitemlistcontroller.cpp @@ -45,19 +45,23 @@ void BaseItemListController::updateItemCount() { } void BaseItemListController::itemList_rowsRequested(int fromIndex, int toIndex) { + Q_UNUSED(fromIndex); Q_UNUSED(toIndex); qFatal("BaseItemListController::itemList_rowsRequested() must be implemented by child class"); } const BaseModel *BaseItemListController::cacheGet(int index) const { + Q_UNUSED(index); qFatal("BaseItemListController::cacheGet() not implemented"); return NULL; } void BaseItemListController::cacheSet(int index, BaseModel* baseModel) const { + Q_UNUSED(index); Q_UNUSED(baseModel); qFatal("BaseItemListController::cacheSet() not implemented"); } bool BaseItemListController::cacheIsset(int index) const { + Q_UNUSED(index); qFatal("BaseItemListController::cacheIsset() not implemented"); return false; } diff --git a/QtClient/JoplinQtClient/baseitemlistcontroller.h b/QtClient/JoplinQtClient/baseitemlistcontroller.h index 3517582c43..8d5cef9269 100755 --- a/QtClient/JoplinQtClient/baseitemlistcontroller.h +++ b/QtClient/JoplinQtClient/baseitemlistcontroller.h @@ -22,8 +22,8 @@ public: private: - QObject* itemList_; QString parentId_; + QObject* itemList_; QString orderBy_; protected: diff --git a/QtClient/JoplinQtClient/build.sh b/QtClient/JoplinQtClient/build.sh index eeb8037770..1f0267c180 100755 --- a/QtClient/JoplinQtClient/build.sh +++ b/QtClient/JoplinQtClient/build.sh @@ -2,23 +2,23 @@ set -e -mkdir -p /cygdrive/d/Web/www/joplin/QtClient/build-JoplinQtClient-Visual_C_32_bits-Debug -cd /cygdrive/d/Web/www/joplin/QtClient/build-JoplinQtClient-Visual_C_32_bits-Debug -rm -rf debug/ release/ Makefile* -export PATH="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin":$PATH -export PATH=$PATH:"/cygdrive/c/Program Files (x86)/Windows Kits/8.1/bin/x86" -export PATH=$PATH:"/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include" -"/cygdrive/c/Qt/5.7/msvc2015/bin/qmake.exe" D:\\Web\\www\\joplin\\QtClient\\JoplinQtClient\\JoplinQtClient.pro -spec win32-msvc2015 "CONFIG+=debug" "CONFIG+=qml_debug" "JOP_FRONT_END_GUI=1" -"/cygdrive/c/Qt/Tools/QtCreator/bin/jom.exe" qmake_all -"/cygdrive/c/Qt/Tools/QtCreator/bin/jom.exe" -rsync -a /cygdrive/d/Web/www/joplin/QtClient/dependencies/dll-debug/ /cygdrive/d/Web/www/joplin/QtClient/build-JoplinQtClient-Visual_C_32_bits-Debug/debug -cd - +# mkdir -p /cygdrive/d/Web/www/joplin/QtClient/build-JoplinQtClient-Visual_C_32_bits-Debug +# cd /cygdrive/d/Web/www/joplin/QtClient/build-JoplinQtClient-Visual_C_32_bits-Debug +# rm -rf debug/ release/ Makefile* +# export PATH="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin":$PATH +# export PATH=$PATH:"/cygdrive/c/Program Files (x86)/Windows Kits/8.1/bin/x86" +# export PATH=$PATH:"/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include" +# "/cygdrive/c/Qt/5.7/msvc2015/bin/qmake.exe" D:\\Web\\www\\joplin\\QtClient\\JoplinQtClient\\JoplinQtClient.pro -spec win32-msvc2015 "CONFIG+=debug" "CONFIG+=qml_debug" "JOP_FRONT_END_GUI=1" +# "/cygdrive/c/Qt/Tools/QtCreator/bin/jom.exe" qmake_all +# "/cygdrive/c/Qt/Tools/QtCreator/bin/jom.exe" +# rsync -a /cygdrive/d/Web/www/joplin/QtClient/dependencies/dll-debug/ /cygdrive/d/Web/www/joplin/QtClient/build-JoplinQtClient-Visual_C_32_bits-Debug/debug +# cd - -# BUILD_DIR=/home/laurent/src/notes/QtClient/build-JoplinQtClient-Desktop_Qt_5_7_1_GCC_64bit-Debug -# mkdir -p "$BUILD_DIR" -# cd "$BUILD_DIR" -# /opt/Qt/5.7/gcc_64/bin/qmake /home/laurent/src/notes/QtClient/JoplinQtClient/JoplinQtClient.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug JOP_FRONT_END_CLI=1 -# /usr/bin/make qmake_all -# /usr/bin/make \ No newline at end of file +BUILD_DIR=/home/laurent/src/notes/QtClient/build-JoplinQtClient-Desktop_Qt_5_7_1_GCC_64bit-Debug +mkdir -p "$BUILD_DIR" +cd "$BUILD_DIR" +/opt/Qt/5.7/gcc_64/bin/qmake /home/laurent/src/notes/QtClient/JoplinQtClient/JoplinQtClient.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug JOP_FRONT_END_CLI=1 +/usr/bin/make qmake_all +/usr/bin/make \ No newline at end of file diff --git a/QtClient/JoplinQtClient/cliapplication.cpp b/QtClient/JoplinQtClient/cliapplication.cpp index 7560d20efe..88c587fc40 100755 --- a/QtClient/JoplinQtClient/cliapplication.cpp +++ b/QtClient/JoplinQtClient/cliapplication.cpp @@ -146,7 +146,7 @@ int CliApplication::exec() { } qStdout() << QString("Total: %1 items").arg(children.size()) << endl; - for (int i = 0; i < children.size(); i++) { + for (size_t i = 0; i < children.size(); i++) { qStdout() << children[i]->displayTitle() << endl; } } diff --git a/QtClient/JoplinQtClient/folderlistcontroller.cpp b/QtClient/JoplinQtClient/folderlistcontroller.cpp index a5d6706719..9b18a1234e 100755 --- a/QtClient/JoplinQtClient/folderlistcontroller.cpp +++ b/QtClient/JoplinQtClient/folderlistcontroller.cpp @@ -22,7 +22,7 @@ void FolderListController::cacheSet(int index, BaseModel *baseModel) const { } bool FolderListController::cacheIsset(int index) const { - return index > 0 && cache_.size() > index; + return index > 0 && cache_.size() > (size_t)index; } void FolderListController::cacheClear() const { @@ -31,12 +31,13 @@ void FolderListController::cacheClear() const { void FolderListController::itemList_rowsRequested(int fromIndex, int toIndex) { if (!cache_.size()) { - cache_ = Folder::all(parentId(), orderBy()); + qFatal("TODO: replace with root::children()"); + //cache_ = Folder::all(parentId(), orderBy()); } //qDebug() << cache_.size(); - if (fromIndex < 0 || toIndex >= cache_.size() || !cache_.size()) { + if (fromIndex < 0 || (size_t)toIndex >= cache_.size() || !cache_.size()) { qWarning() << "Invalid folder indexes" << fromIndex << toIndex; return; } diff --git a/QtClient/JoplinQtClient/models/abstractlistmodel.cpp b/QtClient/JoplinQtClient/models/abstractlistmodel.cpp index 0b5ae35e2b..6387f975b5 100755 --- a/QtClient/JoplinQtClient/models/abstractlistmodel.cpp +++ b/QtClient/JoplinQtClient/models/abstractlistmodel.cpp @@ -32,6 +32,7 @@ QVariant AbstractListModel::data(const QModelIndex & index, int role) const { } const BaseModel *AbstractListModel::atIndex(int index) const { + Q_UNUSED(index); qFatal("AbstractListModel::atIndex() not implemented"); return NULL; } @@ -72,15 +73,18 @@ int AbstractListModel::baseModelCount() const { } const BaseModel *AbstractListModel::cacheGet(int index) const { + Q_UNUSED(index); qFatal("AbstractListModel::cacheGet() not implemented"); return NULL; } void AbstractListModel::cacheSet(int index, BaseModel* baseModel) const { + Q_UNUSED(index); Q_UNUSED(baseModel); qFatal("AbstractListModel::cacheSet() not implemented"); } bool AbstractListModel::cacheIsset(int index) const { + Q_UNUSED(index); qFatal("AbstractListModel::cacheIsset() not implemented"); return false; } @@ -126,6 +130,7 @@ QString AbstractListModel::indexToId(int index) const { } int AbstractListModel::idToIndex(const QString &id) const { + Q_UNUSED(id); qFatal("AbstractListModel::idToIndex() not implemented"); return -1; } diff --git a/QtClient/JoplinQtClient/models/basemodel.cpp b/QtClient/JoplinQtClient/models/basemodel.cpp index 45c0f9f69a..dddc2c1e4c 100755 --- a/QtClient/JoplinQtClient/models/basemodel.cpp +++ b/QtClient/JoplinQtClient/models/basemodel.cpp @@ -10,7 +10,7 @@ using namespace jop; QMap> BaseModel::tableFields_; QHash BaseModel::cache_; -BaseModel::BaseModel() : table_(jop::UndefinedTable), isNew_(-1) {} +BaseModel::BaseModel() : isNew_(-1), table_(jop::UndefinedTable) {} QStringList BaseModel::changedFields() const { QStringList output; @@ -410,7 +410,7 @@ void BaseModel::setValue(const QString &name, const QJsonValue &value, QMetaType } else if (type == QMetaType::Int) { setValue(name, value.toInt()); } else { - qFatal("Unsupported value type %s %d", name.toStdString(), type); + qFatal("Unsupported value type %s %d", name.toStdString().c_str(), type); } } diff --git a/QtClient/JoplinQtClient/models/folder.cpp b/QtClient/JoplinQtClient/models/folder.cpp index 168709fc12..b8233ebe6d 100755 --- a/QtClient/JoplinQtClient/models/folder.cpp +++ b/QtClient/JoplinQtClient/models/folder.cpp @@ -38,7 +38,7 @@ std::vector> Folder::children(const QString &orderBy, std::vector tables; tables.push_back(jop::FoldersTable); tables.push_back(jop::NotesTable); - for (int tableIndex = 0; tableIndex < tables.size(); tableIndex++) { + for (size_t tableIndex = 0; tableIndex < tables.size(); tableIndex++) { jop::Table table = tables[tableIndex]; QString sql = QString("SELECT %1 FROM %2 WHERE parent_id = :parent_id ORDER BY %3 %4 %5") @@ -143,26 +143,26 @@ int Folder::count(const QString &parentId) { return BaseModel::count(jop::FoldersTable, parentId); } -std::vector> Folder::all(const QString& parentId, const QString &orderBy) { - QSqlQuery q = jop::db().prepare(QString("SELECT %1 FROM %2 WHERE parent_id = :parent_id ORDER BY %3") - .arg(BaseModel::tableFieldNames(jop::FoldersTable).join(",")) - .arg(BaseModel::tableName(jop::FoldersTable)) - .arg(orderBy)); - q.bindValue(":parent_id", parentId); - jop::db().execQuery(q); +// std::vector> Folder::all(const QString& parentId, const QString &orderBy) { +// QSqlQuery q = jop::db().prepare(QString("SELECT %1 FROM %2 WHERE parent_id = :parent_id ORDER BY %3") +// .arg(BaseModel::tableFieldNames(jop::FoldersTable).join(",")) +// .arg(BaseModel::tableName(jop::FoldersTable)) +// .arg(orderBy)); +// q.bindValue(":parent_id", parentId); +// jop::db().execQuery(q); - std::vector> output; +// std::vector> output; - //if (!jop::db().errorCheck(q)) return output; +// //if (!jop::db().errorCheck(q)) return output; - while (q.next()) { - std::unique_ptr folder(new Folder()); - folder->loadSqlQuery(q); - output.push_back(std::move(folder)); - } +// while (q.next()) { +// std::unique_ptr folder(new Folder()); +// folder->loadSqlQuery(q); +// output.push_back(std::move(folder)); +// } - return output; -} +// return output; +// } QString Folder::displayTitle() const { return QString("%1/").arg(value("title").toString()); diff --git a/QtClient/JoplinQtClient/models/folder.h b/QtClient/JoplinQtClient/models/folder.h index 60bcfbbd4e..0b34e56971 100755 --- a/QtClient/JoplinQtClient/models/folder.h +++ b/QtClient/JoplinQtClient/models/folder.h @@ -16,7 +16,7 @@ public: Folder(); static int count(const QString& parentId); - static std::vector> all(const QString& orderBy = "title"); + // static std::vector> all(const QString& parentId = QString(""), const QString &orderBy = QString("title")); static std::vector> pathToFolders(const QString& path, bool returnLast, int& errorCode); static QString pathBaseName(const QString& path); static std::unique_ptr root(); diff --git a/QtClient/JoplinQtClient/models/foldermodel.cpp b/QtClient/JoplinQtClient/models/foldermodel.cpp index e19c4d8b98..d25c97d28a 100755 --- a/QtClient/JoplinQtClient/models/foldermodel.cpp +++ b/QtClient/JoplinQtClient/models/foldermodel.cpp @@ -13,7 +13,7 @@ FolderModel::FolderModel() : AbstractListModel(), orderBy_("title") { const BaseModel *FolderModel::atIndex(int index) const { if (cache_.size()) { - if (index < 0 || index >= cache_.size()) { + if (index < 0 || index >= (int)cache_.size()) { qWarning() << "Invalid folder index:" << index; return NULL; } @@ -23,7 +23,8 @@ const BaseModel *FolderModel::atIndex(int index) const { cacheClear(); - cache_ = Folder::all(orderBy_); + qFatal("TODO: replace with root::children()"); + //cache_ = Folder::all(orderBy_); if (!cache_.size()) { qWarning() << "Invalid folder index:" << index; @@ -79,7 +80,7 @@ void FolderModel::cacheSet(int index, BaseModel* baseModel) const { } bool FolderModel::cacheIsset(int index) const { - return index > 0 && cache_.size() > index; + return index > 0 && (int)cache_.size() > index; } void FolderModel::cacheClear() const { diff --git a/QtClient/JoplinQtClient/models/notemodel.cpp b/QtClient/JoplinQtClient/models/notemodel.cpp index e39c98c706..56a63f9e67 100755 --- a/QtClient/JoplinQtClient/models/notemodel.cpp +++ b/QtClient/JoplinQtClient/models/notemodel.cpp @@ -56,7 +56,7 @@ void NoteModel::setFolderId(const QString &v) { int NoteModel::idToIndex(const QString &id) const { std::vector indexes = cache_.indexes(); - for (int i = 0; i < indexes.size(); i++) { + for (size_t i = 0; i < indexes.size(); i++) { Note* note = cache_.get(indexes[i]); if (note->idString() == id) return indexes[i]; } diff --git a/QtClient/JoplinQtClient/models/qmlnote.cpp b/QtClient/JoplinQtClient/models/qmlnote.cpp deleted file mode 100755 index 52b06febc9..0000000000 --- a/QtClient/JoplinQtClient/models/qmlnote.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "qmlnote.h" - -using namespace jop; - -QmlNote::QmlNote() {} - -QString QmlNote::title() const { - return note_.value("title").toString(); -} - -QString QmlNote::body() const { - return note_.value("body").toString(); -} - -void QmlNote::setNote(const Note ¬e) { -// note_ = note; - emit changed(); -} diff --git a/QtClient/JoplinQtClient/models/qmlnote.h b/QtClient/JoplinQtClient/models/qmlnote.h deleted file mode 100755 index 71ade08c08..0000000000 --- a/QtClient/JoplinQtClient/models/qmlnote.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef QMLNOTE_H -#define QMLNOTE_H - -#include -#include "note.h" - -namespace jop { - -class QmlNote : public QObject { - - Q_OBJECT - -public: - - QmlNote(); - QString title() const; - QString body() const; - void setNote(const Note& note); - -signals: - - void changed(); - -private: - - Note note_; - -}; - -} - -#endif // QMLNOTE_H diff --git a/QtClient/JoplinQtClient/paths.cpp b/QtClient/JoplinQtClient/paths.cpp index 7578222c76..011b7fdc0b 100755 --- a/QtClient/JoplinQtClient/paths.cpp +++ b/QtClient/JoplinQtClient/paths.cpp @@ -11,7 +11,7 @@ QString paths::configDir() { QDir d(configDir_); if (!d.exists()) { bool dirCreated = d.mkpath("."); - if (!dirCreated) qFatal(QString("Cannot create config directory: " + configDir_).toLatin1()); + if (!dirCreated) qFatal("Cannot create config directory: %s", configDir_.toStdString().c_str()); } return configDir_; }