forked from openkylin/ukui-search
Merge branch 'ukss-dev' into 'ukss-dev'
Add app data iface. See merge request kylin-desktop/ukui-search!268
This commit is contained in:
commit
fb8ee3d908
|
@ -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: 建表
|
||||
}
|
||||
|
||||
|
|
@ -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
|
|
@ -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
|
|
@ -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))
|
||||
{
|
||||
}
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
QT += core xml widgets dbus concurrent
|
||||
QT += core xml widgets dbus concurrent sql
|
||||
VERSION = 1.0.0
|
||||
DEFINES += VERSION='\\"$${VERSION}\\"'
|
||||
|
||||
|
|
Loading…
Reference in New Issue