Merge branch 'ukss-dev' into 'ukss-dev'

Add app data iface.

See merge request kylin-desktop/ukui-search!268
This commit is contained in:
纪笑旭 2022-03-02 03:33:19 +00:00
commit fb8ee3d908
8 changed files with 142 additions and 4 deletions

View File

@ -0,0 +1,40 @@
#include "app-db-manager.h"
#include <QDir>
#include <QSqlError>
#include <QSqlQuery>
#include <QDebug>
#include <QApplication>
using namespace UkuiSearch;
#define APP_DATABASE_PATH QDir::homePath()+"/.config/org.ukui/ukui-search/appdata/"+"app-info.db"
#define CONNECTION_NAME QLatin1String("ukss-appdb-connection")
static AppDBManager *global_instance = nullptr;
AppDBManager *AppDBManager::getInstance()
{
if (!global_instance) {
global_instance = new AppDBManager();
}
return global_instance;
}
AppDBManager::AppDBManager(QObject *parent) : QObject(parent), m_database(QSqlDatabase::addDatabase("QSQLITE",CONNECTION_NAME))
{
}
AppDBManager::~AppDBManager()
{
}
void AppDBManager::initDateBaseConnection()
{
if(!m_database->isValid()) {
qWarning() << m_database->lastError();
QApplication::quit();
}
m_database->setDatabaseName(APP_DATABASE_PATH);
if(!m_database->open()) {
qWarning() << m_database->lastError();
QApplication::quit();
}
//todo: 建表
}

View File

@ -0,0 +1,27 @@
#ifndef APPDBMANAGER_H
#define APPDBMANAGER_H
#include <QObject>
#include <QSqlDatabase>
namespace UkuiSearch {
/**
* @brief The AppDBManager class
* 1.desktop文件目录
* 2.
*/
class AppDBManager : public QObject
{
Q_OBJECT
public:
static AppDBManager *getInstance();
void initDateBaseConnection();
private:
explicit AppDBManager(QObject *parent = nullptr);
~AppDBManager();
QSqlDatabase *m_database = nullptr;
};
}
#endif // APPDBMANAGER_H

View File

@ -0,0 +1,21 @@
#ifndef APPINFOTABLEPRIVATE_H
#define APPINFOTABLEPRIVATE_H
#include <QObject>
#include <app-info-table.h>
namespace UkuiSearch {
class AppInfoTablePrivate : public QObject
{
Q_OBJECT
public:
explicit AppInfoTablePrivate(AppInfoTable *parent = nullptr);
AppInfoTablePrivate(AppInfoTablePrivate &) = delete;
AppInfoTablePrivate &operator =(const AppInfoTablePrivate &) = delete;
private:
AppInfoTable *q;
};
}
#endif // APPINFOTABLEPRIVATE_H

View File

@ -0,0 +1,10 @@
#include "app-info-table.h"
#include "app-info-table-private.h"
using namespace UkuiSearch;
AppInfoTablePrivate::AppInfoTablePrivate(AppInfoTable *parent) : QObject(parent), q(parent)
{
}
AppInfoTable::AppInfoTable(QObject *parent) : QObject(parent), d(new AppInfoTablePrivate(this))
{
}

View File

@ -0,0 +1,35 @@
#ifndef APPINFOTABLE_H
#define APPINFOTABLE_H
#include <QObject>
namespace UkuiSearch {
class AppInfoTablePrivate;
/**
* @brief The AppInfoTable class
* TODO:
* 1.
* 2.
* 3.
* 4.
* 5.
* 6.
* 7.
* 8.
* 9.
*
*/
class AppInfoTable : public QObject
{
Q_OBJECT
public:
explicit AppInfoTable(QObject *parent = nullptr);
AppInfoTable(AppInfoTable &) = delete;
AppInfoTable &operator =(const AppInfoTable &) = delete;
private:
AppInfoTablePrivate *d;
};
}
#endif // APPINFOTABLE_H

View File

@ -1,6 +1,11 @@
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/app-db-manager.h \
$$PWD/app-info-table-private.h \
$$PWD/app-info-table.h
SOURCES += \
SOURCES += \ \
$$PWD/app-db-manager.cpp \
$$PWD/app-info-table.cpp

View File

@ -40,14 +40,14 @@
#include <QFontMetrics>
#include <QLabel>
#include <quazip/quazipfile.h>
#include <quazip5/quazipfile.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <quazip/quazip.h>
#include <quazip5/quazip.h>
#include <uchardet/uchardet.h>
//#include <poppler-qt5.h>
#include <poppler/qt5/poppler-qt5.h>

View File

@ -1,4 +1,4 @@
QT += core xml widgets dbus concurrent
QT += core xml widgets dbus concurrent sql
VERSION = 1.0.0
DEFINES += VERSION='\\"$${VERSION}\\"'