Commit 3e4e30d7 authored by Camilo Higuita's avatar Camilo Higuita

organize code and initial work on folders view #4

parent 7e3dbd9a
...@@ -20,7 +20,6 @@ DEFINES += QT_DEPRECATED_WARNINGS ...@@ -20,7 +20,6 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp \ SOURCES += main.cpp \
src/db/collectionDB.cpp \
src/pix.cpp \ src/pix.cpp \
src/db/db.cpp \ src/db/db.cpp \
src/db/dbactions.cpp src/db/dbactions.cpp
...@@ -46,7 +45,6 @@ RESOURCES += \ ...@@ -46,7 +45,6 @@ RESOURCES += \
HEADERS += \ HEADERS += \
src/pix.h \ src/pix.h \
src/db/collectionDB.h \
src/db/fileloader.h \ src/db/fileloader.h \
src/db/db.h \ src/db/db.h \
src/db/dbactions.h \ src/db/dbactions.h \
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <QFontDatabase> #include <QFontDatabase>
#include <QQmlContext> #include <QQmlContext>
#include <QQuickStyle> #include <QQuickStyle>
#include "src/utils/pix.h" #include "src/pix.h"
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
#include "./3rdparty/kirigami/src/kirigamiplugin.h" #include "./3rdparty/kirigami/src/kirigamiplugin.h"
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
DBActions::DBActions(QObject *parent) : DB(parent) DBActions::DBActions(QObject *parent) : DB(parent)
{ {
qDebug() << "Getting collectionDB info from: " << PIX::CollectionDBPath;
qDebug()<< "Starting DBActions";
} }
DBActions::~DBActions() DBActions::~DBActions()
...@@ -33,7 +35,7 @@ PIX::DB_LIST DBActions::getDBData(const QString &queryTxt) ...@@ -33,7 +35,7 @@ PIX::DB_LIST DBActions::getDBData(const QString &queryTxt)
return mapList; return mapList;
} }
QVariantList DBActions::getDBDataQML(const QString &queryTxt) QVariantList DBActions::get(const QString &queryTxt)
{ {
QVariantList mapList; QVariantList mapList;
...@@ -103,3 +105,20 @@ void DBActions::addPic(const PIX::DB &img) ...@@ -103,3 +105,20 @@ void DBActions::addPic(const PIX::DB &img)
} }
} }
QVariantList DBActions::getFolders()
{
QVariantList res;
auto data = this->getDBData("select * from sources");
for(auto i : data)
{
QVariantMap map;
map.insert(PIX::KEYMAP[PIX::KEY::URL], i[PIX::KEY::URL]);
map.insert("folder", QFileInfo(i[PIX::KEY::URL]).baseName());
res << map;
}
qDebug()<< res;
return res;
}
...@@ -6,17 +6,22 @@ ...@@ -6,17 +6,22 @@
class DBActions : public DB class DBActions : public DB
{ {
Q_OBJECT
public: public:
DBActions(QObject *parent = nullptr); explicit DBActions(QObject *parent = nullptr);
~DBActions(); ~DBActions();
PIX::DB_LIST getDBData(const QString &queryTxt); PIX::DB_LIST getDBData(const QString &queryTxt);
QVariantList getDBDataQML(const QString &queryTxt);
bool execQuery(const QString &queryTxt); bool execQuery(const QString &queryTxt);
void addPic(const PIX::DB &img); void addPic(const PIX::DB &img);
/* utils */
Q_INVOKABLE QVariantList getFolders();
Q_INVOKABLE QVariantList get(const QString &queryTxt);
}; };
#endif // DBACTIONS_H #endif // DBACTIONS_H
...@@ -4,6 +4,13 @@ import QtQuick.Layouts 1.3 ...@@ -4,6 +4,13 @@ import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami import org.kde.kirigami 2.0 as Kirigami
import "widgets" import "widgets"
import "widgets/views/Albums"
import "widgets/views/Folders"
import "widgets/views/Gallery"
import "widgets/views/Settings"
import "widgets/views/Tags"
import "widgets/views/Viewer"
import "view_models" import "view_models"
Kirigami.ApplicationWindow Kirigami.ApplicationWindow
...@@ -86,7 +93,7 @@ Kirigami.ApplicationWindow ...@@ -86,7 +93,7 @@ Kirigami.ApplicationWindow
currentView = currentIndex currentView = currentIndex
} }
PixsViewer PixViewer
{ {
} }
...@@ -96,6 +103,11 @@ Kirigami.ApplicationWindow ...@@ -96,6 +103,11 @@ Kirigami.ApplicationWindow
} }
FoldersView
{
id: foldersView
}
AlbumsView AlbumsView
{ {
...@@ -113,16 +125,8 @@ Kirigami.ApplicationWindow ...@@ -113,16 +125,8 @@ Kirigami.ApplicationWindow
} }
Component
{
id: viewer
PixsViewer
{
}
}
} }
Component.onCompleted: foldersView.populate()
} }
...@@ -14,9 +14,7 @@ using namespace PIX; ...@@ -14,9 +14,7 @@ using namespace PIX;
Pix::Pix(QObject *parent) : DBActions(parent) Pix::Pix(QObject *parent) : DBActions(parent)
{ {
qDebug() << "Getting collectionDB info from: " << PIX::CollectionDBPath;
qDebug() << "Getting settings info from: " << PIX::SettingPath; qDebug() << "Getting settings info from: " << PIX::SettingPath;
qDebug() << "Getting artwork files from: " << PIX::CachePath;
// if(!PIX::fileExists(notifyDir+"/Pix.notifyrc")) // if(!PIX::fileExists(notifyDir+"/Pix.notifyrc"))
// { // {
...@@ -28,12 +26,6 @@ Pix::Pix(QObject *parent) : DBActions(parent) ...@@ -28,12 +26,6 @@ Pix::Pix(QObject *parent) : DBActions(parent)
// } // }
QDir cachePath_dir(PIX::CachePath);
if (!cachePath_dir.exists())
cachePath_dir.mkpath(".");
this->fileLoader = new FileLoader; this->fileLoader = new FileLoader;
connect(this, &Pix::populate, this, &Pix::populateDB); connect(this, &Pix::populate, this, &Pix::populateDB);
...@@ -68,10 +60,6 @@ QVariantList Pix::getList(const QStringList &urls) ...@@ -68,10 +60,6 @@ QVariantList Pix::getList(const QStringList &urls)
return mapList; return mapList;
} }
QVariantList Pix::get(const QString &queryTxt)
{
return this->getDBDataQML(queryTxt);
}
bool Pix::run(const QString &query) bool Pix::run(const QString &query)
{ {
...@@ -225,3 +213,4 @@ QVariantMap Pix::getParentDir(const QString &path) ...@@ -225,3 +213,4 @@ QVariantMap Pix::getParentDir(const QString &path)
} }
...@@ -17,46 +17,44 @@ using namespace std; ...@@ -17,46 +17,44 @@ using namespace std;
class FileLoader; class FileLoader;
class QFileSystemWatcher;
class Pix : public DBActions class Pix : public DBActions
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit Pix(QObject* parent = nullptr); explicit Pix(QObject* parent = nullptr);
~Pix(); ~Pix();
Q_INVOKABLE QVariantList getList(const QStringList &urls); Q_INVOKABLE QVariantList getList(const QStringList &urls);
Q_INVOKABLE QVariantList get(const QString &queryTxt); Q_INVOKABLE bool run(const QString &query);
Q_INVOKABLE bool run(const QString &query);
Q_INVOKABLE static QString backgroundColor(); Q_INVOKABLE static QString backgroundColor();
Q_INVOKABLE static QString foregroundColor(); Q_INVOKABLE static QString foregroundColor();
Q_INVOKABLE static QString hightlightColor(); Q_INVOKABLE static QString hightlightColor();
Q_INVOKABLE static QString midColor(); Q_INVOKABLE static QString midColor();
Q_INVOKABLE static QString altColor(); Q_INVOKABLE static QString altColor();
Q_INVOKABLE static QString pixColor(); Q_INVOKABLE static QString pixColor();
Q_INVOKABLE static bool isMobile(); Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static int screenGeometry(QString &side); Q_INVOKABLE static int screenGeometry(QString &side);
Q_INVOKABLE static int cursorPos(QString &axis); Q_INVOKABLE static int cursorPos(QString &axis);
Q_INVOKABLE static QString homeDir(); Q_INVOKABLE static QString homeDir();
Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl); Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
Q_INVOKABLE static QVariantMap getParentDir(const QString &path); Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
private: private:
FileLoader *fileLoader; FileLoader *fileLoader;
void populateDB(const QString &path); void populateDB(const QString &path);
signals: signals:
void refreshTables(QVariantMap tables); void refreshTables(QVariantMap tables);
void populate(QString path); void populate(QString path);
}; };
......
...@@ -2,19 +2,13 @@ ...@@ -2,19 +2,13 @@
<qresource prefix="/"> <qresource prefix="/">
<file>main.qml</file> <file>main.qml</file>
<file>view_models/PixGrid.qml</file> <file>view_models/PixGrid.qml</file>
<file>widgets/TagsView.qml</file>
<file>widgets/GalleryView.qml</file>
<file>widgets/EditTools.qml</file> <file>widgets/EditTools.qml</file>
<file>widgets/AlbumsView.qml</file>
<file>utils/Icon.qml</file> <file>utils/Icon.qml</file>
<file>utils/Icons.js</file> <file>utils/Icons.js</file>
<file>utils/materialdesignicons-webfont.ttf</file> <file>utils/materialdesignicons-webfont.ttf</file>
<file>widgets/PixsBar.qml</file> <file>widgets/PixsBar.qml</file>
<file>qtquickcontrols2.conf</file> <file>qtquickcontrols2.conf</file>
<file>widgets/PixsViewer.qml</file>
<file>widgets/SettingsView.qml</file>
<file>db/script.sql</file> <file>db/script.sql</file>
<file>widgets/FoldersView.qml</file>
<file>view_models/PixPic.qml</file> <file>view_models/PixPic.qml</file>
<file>view_models/PixHolder.qml</file> <file>view_models/PixHolder.qml</file>
<file>../assets/face.png</file> <file>../assets/face.png</file>
...@@ -23,5 +17,13 @@ ...@@ -23,5 +17,13 @@
<file>view_models/SideBar.qml</file> <file>view_models/SideBar.qml</file>
<file>view_models/PixButton.qml</file> <file>view_models/PixButton.qml</file>
<file>view_models/PixPage.qml</file> <file>view_models/PixPage.qml</file>
<file>widgets/views/Folders/FoldersView.qml</file>
<file>widgets/views/Gallery/GalleryView.qml</file>
<file>widgets/views/Tags/TagsView.qml</file>
<file>widgets/views/Albums/AlbumsView.qml</file>
<file>widgets/views/Viewer/PixViewer.qml</file>
<file>widgets/views/Settings/SettingsView.qml</file>
<file>widgets/views/Folders/FoldersGrid.qml</file>
<file>widgets/views/Folders/FoldersDelegate.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -26,8 +26,6 @@ PixPage ...@@ -26,8 +26,6 @@ PixPage
} }
] ]
content: GridView content: GridView
{ {
id: grid id: grid
...@@ -53,13 +51,6 @@ PixPage ...@@ -53,13 +51,6 @@ PixPage
model: ListModel {id: gridModel} model: ListModel {id: gridModel}
highlight: Rectangle
{
width: picSize
height: picSize
color: "pink"
radius: 5
}
highlightFollowsCurrentItem: true highlightFollowsCurrentItem: true
......
...@@ -18,18 +18,11 @@ Page ...@@ -18,18 +18,11 @@ Page
property alias content : pageContent.children property alias content : pageContent.children
property alias holder : holder
signal exit(); signal exit();
clip: true clip: true
PixHolder
{
id: holder
visible: grid.count === 0
message: "No pics..."
}
ColumnLayout ColumnLayout
{ {
...@@ -108,12 +101,17 @@ Page ...@@ -108,12 +101,17 @@ Page
} }
Column
{ Column
id: pageContent {
Layout.fillHeight: true id: pageContent
Layout.fillWidth: true Layout.margins: contentMargins
} Layout.fillHeight: true
Layout.fillWidth: true
}
} }
......
import QtQuick 2.0
Item {
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import "../../../view_models"
ItemDelegate
{
property int folderSize : 32
height: folderSize*2
width: folderSize*2
PixButton
{
anchors.centerIn: parent
iconSize: folderSize
iconName: "folder"
text: folder
display: AbstractButton.TextUnderIcon
flat: true
height: parent.height
width: parent.width
}
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
GridView
{
id: folderGridRoot
property int gridSize : 64
clip: true
height: parent.height
width: parent.width
cellHeight: folderSize
cellWidth: folderSize
focus: true
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: GridView.SnapToRow
model: ListModel {id: gridModel}
highlightFollowsCurrentItem: true
delegate: FoldersDelegate
{
folderSize : 32
}
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import "../../../view_models"
PixPage
{
content: FoldersGrid
{
id: folderGrid
}
function populate()
{
var folders = pix.getFolders()
if(folders.length > 0)
for(var i in folders)
folderGrid.model.append(folders[i])
}
}
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "../db/Query.js" as Q import "../../../db/Query.js" as Q
import "../view_models" import "../../../view_models"
PixGrid PixGrid
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment