runningwater 2 anni fa
commit
1ec1948f2a

+ 287 - 0
.gitignore

@@ -0,0 +1,287 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+!core/
+*.*#
+*.a
+*.app
+*.autosave
+*.core
+*.debug
+*.embed.manifest
+*.moc
+*.o
+*.obj
+*.orig
+*.prl
+*.qm
+*.rc
+*.rej
+*.res
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*_wrapper.bat
+*_wrapper.sh
+*~
+.#*
+.DS_Store
+.qmake.cache
+.qmake.stash
+.vscode
+Makefile*
+Thumbs.db
+core
+moc_*.cpp
+qrc_*.cpp
+tags
+ui_*.h
+wrapper.bat
+wrapper.sh
+debug_toolchain.cmake
+
+# qtcreator generated files
+*.creator.user*
+*.pro.user*
+*.pyqtc.user*
+*.qbs.user*
+*.qmlproject.user*
+CMakeLists.txt.user*
+/share/qtcreator/examples/
+/share/qtcreator/externaltools/
+/share/qtcreator/fonts/
+/share/qtcreator/generic-highlighter/
+/share/qtcreator/qmldesigner/QtProject/
+/src/app/Info.plist
+/src/plugins/**/*.json
+/src/plugins/coreplugin/ide_version.h
+/src/libs/qt-breakpad/bin
+/.cmake/
+app_version.h
+phony.c
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.ncb
+*.opensdf
+*.pdb
+*.sdf
+*.sln
+*.suo
+*.vcproj
+*.vcxproj
+*vcproj.*.*.user
+*vcxproj.*
+
+# gcov files
+*.gcda
+*.gcno
+*.gcov
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# translation related:
+/share/qtcreator/translations/*_tr.h
+/share/qtcreator/translations/qtcreator_untranslated.ts
+
+# Qml caching files
+*.jsc
+*.qmlc
+
+# Squish generated files
+/tests/system/suite_*/config.xml
+
+# Clang tooling files
+compile_commands.json
+
+# Directories to ignore
+# ---------------------
+
+.moc/
+.obj/
+.pch/
+.rcc/
+.uic/
+.clangd/
+/*-debug/
+/*-release/
+/build*/
+/dist/gdb/*.gz
+/dist/gdb/python/
+/dist/gdb/qtcreator-*/
+/dist/gdb/source/
+/dist/gdb/staging/
+/doc/qbs/
+/doc/html/qtcreator/
+/doc/html/qtcreator-dev/
+/doc/html/qtdesignstudio/
+/doc/qtdesignstudio/doc/html
+/lib/
+/lib64/
+/libexec/
+debug/
+ipch/
+release/
+tmp/
+.cache/clangd/
+# ignore both a directory as well as a symlink
+/share/qtcreator/QtProject
+
+# Binaries
+# --------
+*.dll
+*.exe
+/bin/buildoutputparser
+/bin/clangbackend
+/bin/cpaster
+/bin/cplusplus-ast2png
+/bin/cplusplus-frontend
+/bin/cplusplus-keywordgen
+/bin/cplusplus-mkvisitor
+/bin/cplusplus-update-frontend
+/bin/qbs*
+/bin/qml2puppet
+/bin/qmlpuppet
+/bin/qtcreator
+/bin/qtcreator_crash_handler
+/bin/qtcreator_ctrlc_stub
+/bin/qtcreator_process_stub
+/bin/qtpromaker
+/bin/sdktool
+/share/doc/qtcreator/*.qch
+/share/qtcreator/qbs/
+/src/tools/examplesscanner/examplesscanner
+/src/tools/qml/qmldump/qmldump
+/src/tools/valgrindfake/valgrind-fake
+
+# Tests
+#------
+/tests/auto/aggregation/tst_aggregation
+/tests/auto/algorithm/tst_algorithm
+/tests/auto/changeset/tst_changeset
+/tests/auto/cplusplus/ast/tst_ast
+/tests/auto/cplusplus/c99/tst_c99
+/tests/auto/cplusplus/checksymbols/tst_checksymbols
+/tests/auto/cplusplus/codeformatter/tst_codeformatter
+/tests/auto/cplusplus/codegen/tst_codegen
+/tests/auto/cplusplus/cppselectionchanger/tst_cppselectionchanger
+/tests/auto/cplusplus/cxx11/tst_c99
+/tests/auto/cplusplus/cxx11/tst_cxx11
+/tests/auto/cplusplus/fileiterationorder/tst_fileiterationorder
+/tests/auto/cplusplus/findusages/tst_findusages
+/tests/auto/cplusplus/lexer/tst_lexer
+/tests/auto/cplusplus/lookup/tst_lookup
+/tests/auto/cplusplus/misc/tst_misc
+/tests/auto/cplusplus/preprocessor/tst_preprocessor
+/tests/auto/cplusplus/semantic/tst_semantic
+/tests/auto/cplusplus/simplifytypes/tst_simplifytypes
+/tests/auto/cplusplus/translationunit/tst_translationunit
+/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter
+/tests/auto/debugger/qt_tst_dumpers_*
+/tests/auto/debugger/tst_disassembler
+/tests/auto/debugger/tst_dumpers
+/tests/auto/debugger/tst_gdb
+/tests/auto/debugger/tst_namedemangler
+/tests/auto/debugger/tst_offsets
+/tests/auto/debugger/tst_olddumpers
+/tests/auto/debugger/tst_simplifytypes
+/tests/auto/debugger/tst_version
+/tests/auto/diff/differ/tst_differ
+/tests/auto/environment/tst_environment
+/tests/auto/extensionsystem/pluginmanager/tst_pluginmanager
+/tests/auto/extensionsystem/pluginspec/tst_pluginspec
+/tests/auto/externaltool/tst_externaltool
+/tests/auto/fakevim/tst_fakevim
+/tests/auto/filesearch/tst_filesearch
+/tests/auto/flamegraph/tst_flamegraph
+/tests/auto/generichighlighter/highlighterengine/tst_highlighterengine
+/tests/auto/generichighlighter/specificrules/tst_specificrules
+/tests/auto/ioutils/tst_ioutils
+/tests/auto/json/tst_json
+/tests/auto/mapreduce/tst_mapreduce
+/tests/auto/profilewriter/tst_profilewriter
+/tests/auto/qml/codemodel/check/tst_codemodel_check
+/tests/auto/qml/codemodel/dependencies/tst_dependencies
+/tests/auto/qml/codemodel/importscheck/tst_qml_imports_check
+/tests/auto/qml/persistenttrie/tst_trie_check
+/tests/auto/qml/qmldesigner/bauhaustests/tst_bauhaus
+/tests/auto/qml/qmldesigner/coretests/tst_coretests
+/tests/auto/qml/qmldesigner/coretests/tst_qmldesigner_core
+/tests/auto/qml/qmldesigner/propertyeditortests/tst_propertyeditor
+/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter
+/tests/auto/qml/qmljssimplereader/tst_qmljssimplereader
+/tests/auto/qml/qmlprojectmanager/fileformat/tst_fileformat
+/tests/auto/qml/qrcparser/tst_qrcparser
+/tests/auto/qml/reformatter/tst_reformatter
+/tests/auto/qtcprocess/tst_qtcprocess
+/tests/auto/runextensions/tst_runextensions
+/tests/auto/sdktool/tst_sdktool
+/tests/auto/ssh/tst_ssh
+/tests/auto/timeline/timelineabstractrenderer/tst_timelineabstractrenderer
+/tests/auto/timeline/timelineitemsrenderpass/tst_timelineitemsrenderpass
+/tests/auto/timeline/timelinemodel/tst_timelinemodel
+/tests/auto/timeline/timelinemodelaggregator/tst_timelinemodelaggregator
+/tests/auto/timeline/timelinenotesmodel/tst_timelinenotesmodel
+/tests/auto/timeline/timelinenotesrenderpass/tst_timelinenotesrenderpass
+/tests/auto/timeline/timelineoverviewrenderer/tst_timelineoverviewrenderer
+/tests/auto/timeline/timelinerenderer/tst_timelinerenderer
+/tests/auto/timeline/timelinerenderpass/tst_timelinerenderpass
+/tests/auto/timeline/timelinerenderstate/tst_timelinerenderstate
+/tests/auto/timeline/timelineselectionrenderpass/tst_timelineselectionrenderpass
+/tests/auto/timeline/timelinezoomcontrol/tst_timelinezoomcontrol
+/tests/auto/treeviewfind/tst_treeviewfind
+/tests/auto/utils/ansiescapecodehandler/tst_ansiescapecodehandler
+/tests/auto/utils/fileutils/tst_fileutils
+/tests/auto/utils/stringutils/tst_stringutils
+/tests/auto/utils/templateengine/tst_templateengine
+/tests/auto/utils/treemodel/tst_treemodel
+/tests/auto/valgrind/callgrind/tst_callgrindparsertests
+/tests/auto/valgrind/memcheck/modeldemo
+/tests/auto/valgrind/memcheck/testapps/free1/free1
+/tests/auto/valgrind/memcheck/testapps/free2/free2
+/tests/auto/valgrind/memcheck/testapps/invalidjump/invalidjump
+/tests/auto/valgrind/memcheck/testapps/leak1/leak1
+/tests/auto/valgrind/memcheck/testapps/leak2/leak2
+/tests/auto/valgrind/memcheck/testapps/leak3/leak3
+/tests/auto/valgrind/memcheck/testapps/leak4/leak4
+/tests/auto/valgrind/memcheck/testapps/overlap/overlap
+/tests/auto/valgrind/memcheck/testapps/syscall/syscall
+/tests/auto/valgrind/memcheck/testapps/uninit1/uninit1
+/tests/auto/valgrind/memcheck/testapps/uninit2/uninit2
+/tests/auto/valgrind/memcheck/testapps/uninit3/uninit3
+/tests/auto/valgrind/memcheck/tst_parsertests
+/tests/auto/valgrind/memcheck/tst_testrunner
+/tests/manual/debugger/gui/gui
+/tests/manual/debugger/helper/helper
+/tests/manual/debugger/simple/libsimple_test_plugin.*dylib
+/tests/manual/debugger/simple/simple_test_app
+/tests/manual/fakevim/tst_fakevim
+/tests/manual/pluginview/tst_plugindialog
+/tests/manual/preprocessor/pp
+/tests/manual/process/process
+/tests/manual/proparser/testreader
+/tests/manual/qml-ast2dot/qml-ast2dot
+/tests/manual/shootout/shootout
+/tests/manual/ssh/sftpfsmodel/sftpfsmodel
+/tests/manual/ssh/shell/shell
+/tests/tools/qml-ast2dot/qml-ast2dot
+/tests/unit/echoserver/echo
+/tests/unit/unittest/unittest
+
+# qbs builds
+/*-debug/
+/*-release/

+ 23 - 0
gallery-core/Album.cpp

@@ -0,0 +1,23 @@
+#include "Album.h"
+
+Album::Album(const QString& name) : mId(-1), mName(name) {}
+
+// int Album::id() const
+//{
+
+//}
+
+// void Album::setId(int id)
+//{
+
+//}
+
+// QString Album::name() const
+//{
+
+//}
+
+// void Album::setName(const QString &name)
+//{
+
+//}

+ 15 - 0
gallery-core/AlbumDao.cpp

@@ -0,0 +1,15 @@
+#include "AlbumDao.h"
+
+#include <QSqlDatabase>
+#include <QSqlQuery>
+
+AlbumDao::AlbumDao(QSqlDatabase &database) : mDatabase(database) {}
+
+void AlbumDao::init() const {
+  const QStringList tables = mDatabase.tables();
+  if (!tables.contains("albums")) {
+    QSqlQuery query(mDatabase);
+    query.exec(
+        "CREATE TABLE albums(id INTEGER PRIMARY KEY AUTOINCRMENT, name TEXT)");
+  }
+}

+ 15 - 0
gallery-core/AlbumDao.h

@@ -0,0 +1,15 @@
+#ifndef ALBUMDAO_H
+#define ALBUMDAO_H
+
+class QSqlDatabase;
+
+class AlbumDao {
+ public:
+  AlbumDao(QSqlDatabase& database);
+  void init() const;
+
+ private:
+  QSqlDatabase& mDatabase;
+};
+
+#endif  // ALBUMDAO_H

+ 19 - 0
gallery-core/DatabaseManager.cpp

@@ -0,0 +1,19 @@
+#include "DatabaseManager.h"
+
+#include <QSqlDatabase>
+
+DatabaseManager &DatabaseManager::instance() {
+  static DatabaseManager singleton;
+  return singleton;
+}
+
+DatabaseManager::~DatabaseManager() {
+  mDatabase->close();
+  delete mDatabase;
+}
+
+DatabaseManager::DatabaseManager(const QString &path)
+    : mDatabase(new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE"))) {
+  mDatabase->setDatabaseName(path);
+  mDatabase->open();
+}

+ 23 - 0
gallery-core/DatabaseManager.h

@@ -0,0 +1,23 @@
+#ifndef DATABASEMANAGER_H
+#define DATABASEMANAGER_H
+
+#include <QString>
+
+class QSqlDatabase;
+
+const QString DATABASE_FILE_NAME = "gallery.db";
+
+class DatabaseManager {
+ public:
+  static DatabaseManager& instance();
+  ~DatabaseManager();
+
+ protected:
+  DatabaseManager(const QString& path = DATABASE_FILE_NAME);
+  DatabaseManager& operator=(const DatabaseManager& rhs);
+
+ private:
+  QSqlDatabase* mDatabase;
+};
+
+#endif  // DATABASEMANAGER_H

+ 19 - 0
gallery-core/Picture.cpp

@@ -0,0 +1,19 @@
+#include "Picture.h"
+
+Picture::Picture(const QString &filePath)
+    : Picture(QUrl::fromLocalFile(filePath)) {}
+
+Picture::Picture(const QUrl &fileUrl)
+    : mId(-1), mAlbumId(-1), mFileUrl(fileUrl) {}
+
+// int Picture::id() const {}
+
+// void Picture::setId(int id) {}
+
+// int Picture::albumId() const {}
+
+// void Picture::setAlbumId(int albumId) {}
+
+QUrl Picture::fileUrl() const { return mFileUrl; }
+
+void Picture::setFileUrl(const QUrl &fileUrl) { mFileUrl = fileUrl; }

+ 29 - 0
gallery-core/Picture.h

@@ -0,0 +1,29 @@
+#ifndef PICTURE_H
+#define PICTURE_H
+
+#include <QString>
+#include <QUrl>
+
+#include "gallery-core_global.h"
+
+class GALLERYCORE_EXPORT Picture {
+ public:
+  Picture(const QString& filePath = "");
+  Picture(const QUrl& fileUrl);
+
+  int id() const;
+  void setId(int id);
+
+  int albumId() const;
+  void setAlbumId(int albumId);
+
+  QUrl fileUrl() const;
+  void setFileUrl(const QUrl& fileUrl);
+
+ private:
+  int mId;
+  int mAlbumId;
+  QUrl mFileUrl;
+};
+
+#endif  // PICTURE_H

+ 22 - 0
gallery-core/album.h

@@ -0,0 +1,22 @@
+#ifndef ALBUM_H
+#define ALBUM_H
+
+#include <QString>
+
+#include "gallery-core_global.h"
+
+class GALLERYCORE_EXPORT Album {
+ public:
+  explicit Album(const QString& name = "");
+
+  int id() const;
+  void setId(int id);
+  QString name() const;
+  void setName(const QString& name);
+
+ private:
+  int mId;
+  QString mName;
+};
+
+#endif  // ALBUM_H

+ 30 - 0
gallery-core/gallery-core.pro

@@ -0,0 +1,30 @@
+QT += sql
+QT -= gui
+
+TEMPLATE = lib
+DEFINES += GALLERYCORE_LIBRARY
+
+CONFIG += c++17
+
+# You can make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    AlbumDao.cpp \
+    DatabaseManager.cpp \
+    Picture.cpp \
+    Album.cpp
+
+HEADERS += \
+    AlbumDao.h \
+    DatabaseManager.h \
+    gallery-core_global.h \
+    Picture.h \
+    Album.h
+
+# Default rules for deployment.
+unix {
+    target.path = /usr/lib
+}
+!isEmpty(target.path): INSTALLS += target

+ 12 - 0
gallery-core/gallery-core_global.h

@@ -0,0 +1,12 @@
+#ifndef GALLERYCORE_GLOBAL_H
+#define GALLERYCORE_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(GALLERYCORE_LIBRARY)
+#  define GALLERYCORE_EXPORT Q_DECL_EXPORT
+#else
+#  define GALLERYCORE_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // GALLERYCORE_GLOBAL_H

+ 4 - 0
gallery.pro

@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+    gallery-core