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
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp \
src/db/collectionDB.cpp \
src/pix.cpp \
src/db/db.cpp \
src/db/dbactions.cpp
......@@ -46,7 +45,6 @@ RESOURCES += \
HEADERS += \
src/pix.h \
src/db/collectionDB.h \
src/db/fileloader.h \
src/db/db.h \
src/db/dbactions.h \
......
......@@ -3,7 +3,7 @@
#include <QFontDatabase>
#include <QQmlContext>
#include <QQuickStyle>
#include "src/utils/pix.h"
#include "src/pix.h"
#ifdef Q_OS_ANDROID
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
......
......@@ -2,7 +2,9 @@
DBActions::DBActions(QObject *parent) : DB(parent)
{
qDebug() << "Getting collectionDB info from: " << PIX::CollectionDBPath;
qDebug()<< "Starting DBActions";
}
DBActions::~DBActions()
......@@ -33,7 +35,7 @@ PIX::DB_LIST DBActions::getDBData(const QString &queryTxt)
return mapList;
}
QVariantList DBActions::getDBDataQML(const QString &queryTxt)
QVariantList DBActions::get(const QString &queryTxt)
{
QVariantList mapList;
......@@ -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 @@
class DBActions : public DB
{
Q_OBJECT
public:
DBActions(QObject *parent = nullptr);
explicit DBActions(QObject *parent = nullptr);
~DBActions();
PIX::DB_LIST getDBData(const QString &queryTxt);
QVariantList getDBDataQML(const QString &queryTxt);
bool execQuery(const QString &queryTxt);
void addPic(const PIX::DB &img);
/* utils */
Q_INVOKABLE QVariantList getFolders();
Q_INVOKABLE QVariantList get(const QString &queryTxt);
};
#endif // DBACTIONS_H
......@@ -4,6 +4,13 @@ import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
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"
Kirigami.ApplicationWindow
......@@ -86,7 +93,7 @@ Kirigami.ApplicationWindow
currentView = currentIndex
}
PixsViewer
PixViewer
{
}
......@@ -96,6 +103,11 @@ Kirigami.ApplicationWindow
}
FoldersView
{
id: foldersView
}
AlbumsView
{
......@@ -113,16 +125,8 @@ Kirigami.ApplicationWindow
}
Component
{
id: viewer
PixsViewer
{
}
}
}
Component.onCompleted: foldersView.populate()
}
......@@ -14,9 +14,7 @@ using namespace PIX;
Pix::Pix(QObject *parent) : DBActions(parent)
{
qDebug() << "Getting collectionDB info from: " << PIX::CollectionDBPath;
qDebug() << "Getting settings info from: " << PIX::SettingPath;
qDebug() << "Getting artwork files from: " << PIX::CachePath;
// if(!PIX::fileExists(notifyDir+"/Pix.notifyrc"))
// {
......@@ -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;
connect(this, &Pix::populate, this, &Pix::populateDB);
......@@ -68,10 +60,6 @@ QVariantList Pix::getList(const QStringList &urls)
return mapList;
}
QVariantList Pix::get(const QString &queryTxt)
{
return this->getDBDataQML(queryTxt);
}
bool Pix::run(const QString &query)
{
......@@ -225,3 +213,4 @@ QVariantMap Pix::getParentDir(const QString &path)
}
......@@ -17,46 +17,44 @@ using namespace std;
class FileLoader;
class QFileSystemWatcher;
class Pix : public DBActions
{
Q_OBJECT
Q_OBJECT
public:
explicit Pix(QObject* parent = nullptr);
~Pix();
public:
explicit Pix(QObject* parent = nullptr);
~Pix();
Q_INVOKABLE QVariantList getList(const QStringList &urls);
Q_INVOKABLE QVariantList get(const QString &queryTxt);
Q_INVOKABLE bool run(const QString &query);
Q_INVOKABLE QVariantList getList(const QStringList &urls);
Q_INVOKABLE bool run(const QString &query);
Q_INVOKABLE static QString backgroundColor();
Q_INVOKABLE static QString foregroundColor();
Q_INVOKABLE static QString hightlightColor();
Q_INVOKABLE static QString midColor();
Q_INVOKABLE static QString altColor();
Q_INVOKABLE static QString pixColor();
Q_INVOKABLE static QString backgroundColor();
Q_INVOKABLE static QString foregroundColor();
Q_INVOKABLE static QString hightlightColor();
Q_INVOKABLE static QString midColor();
Q_INVOKABLE static QString altColor();
Q_INVOKABLE static QString pixColor();
Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static int screenGeometry(QString &side);
Q_INVOKABLE static int cursorPos(QString &axis);
Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static int screenGeometry(QString &side);
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 QVariantMap getParentDir(const QString &path);
Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
private:
FileLoader *fileLoader;
private:
FileLoader *fileLoader;
void populateDB(const QString &path);
void populateDB(const QString &path);
signals:
void refreshTables(QVariantMap tables);
void populate(QString path);
signals:
void refreshTables(QVariantMap tables);
void populate(QString path);
};
......
......@@ -2,19 +2,13 @@
<qresource prefix="/">
<file>main.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/AlbumsView.qml</file>
<file>utils/Icon.qml</file>
<file>utils/Icons.js</file>
<file>utils/materialdesignicons-webfont.ttf</file>
<file>widgets/PixsBar.qml</file>
<file>qtquickcontrols2.conf</file>
<file>widgets/PixsViewer.qml</file>
<file>widgets/SettingsView.qml</file>
<file>db/script.sql</file>
<file>widgets/FoldersView.qml</file>
<file>view_models/PixPic.qml</file>
<file>view_models/PixHolder.qml</file>
<file>../assets/face.png</file>
......@@ -23,5 +17,13 @@
<file>view_models/SideBar.qml</file>
<file>view_models/PixButton.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>
</RCC>
......@@ -26,8 +26,6 @@ PixPage
}
]
content: GridView
{
id: grid
......@@ -53,13 +51,6 @@ PixPage
model: ListModel {id: gridModel}
highlight: Rectangle
{
width: picSize
height: picSize
color: "pink"
radius: 5
}
highlightFollowsCurrentItem: true
......
......@@ -18,18 +18,11 @@ Page
property alias content : pageContent.children
property alias holder : holder
signal exit();
clip: true
PixHolder
{
id: holder
visible: grid.count === 0
message: "No pics..."
}
ColumnLayout
{
......@@ -108,12 +101,17 @@ Page
}
Column
{
id: pageContent
Layout.fillHeight: true
Layout.fillWidth: true
}
Column
{
id: pageContent
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.Controls 2.2
import QtQuick.Layouts 1.3
import "../db/Query.js" as Q
import "../view_models"
import "../../../db/Query.js" as Q
import "../../../view_models"
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