UI: Rename AppUtil to AppInfoUtil.

This commit is contained in:
Nodir Temirkhodjaev 2021-04-24 17:39:47 +03:00
parent 3a3795fc29
commit 086f7e004f
11 changed files with 43 additions and 39 deletions

View File

@ -102,8 +102,8 @@ SOURCES += \
util/app/appinfocache.cpp \
util/app/appinfojob.cpp \
util/app/appinfomanager.cpp \
util/app/appinfoutil.cpp \
util/app/appinfoworker.cpp \
util/app/apputil.cpp \
util/conf/addressrange.cpp \
util/conf/confutil.cpp \
util/dateutil.cpp \
@ -236,8 +236,8 @@ HEADERS += \
util/app/appinfocache.h \
util/app/appinfojob.h \
util/app/appinfomanager.h \
util/app/appinfoutil.h \
util/app/appinfoworker.h \
util/app/apputil.h \
util/conf/addressrange.h \
util/conf/confappswalker.h \
util/conf/confutil.h \

View File

@ -11,7 +11,7 @@
#include "../conf/firewallconf.h"
#include "../log/logentryblocked.h"
#include "../util/app/appinfocache.h"
#include "../util/app/apputil.h"
#include "../util/app/appinfoutil.h"
#include "../util/fileutil.h"
#include "../util/iconcache.h"
#include "../util/guiutil.h"
@ -374,7 +374,7 @@ void AppListModel::purgeApps()
const auto appPath = appRow.appPath;
if (!FileUtil::fileExists(appPath)) {
AppInfo appInfo;
if (!AppUtil::getInfo(appPath, appInfo)) {
if (!AppInfoUtil::getInfo(appPath, appInfo)) {
deleteApp(appRow.appId, appPath, row);
}
}

View File

@ -1,7 +1,7 @@
#include "appinfo.h"
#include "../fileutil.h"
#include "apputil.h"
#include "appinfoutil.h"
bool AppInfo::isFileModified(const QString &appPath) const
{

View File

@ -78,7 +78,7 @@ AppInfo AppInfoCache::appInfo(const QString &appPath)
return *appInfo;
}
void AppInfoCache::handleFinishedLookup(const QString &appPath, const AppInfo info)
void AppInfoCache::handleFinishedLookup(const QString &appPath, const AppInfo &info)
{
AppInfo *appInfo = m_cache.object(appPath);
if (!appInfo)

View File

@ -30,7 +30,7 @@ signals:
void cacheChanged();
private slots:
void handleFinishedLookup(const QString &appPath, const AppInfo info);
void handleFinishedLookup(const QString &appPath, const AppInfo &info);
private:
void emitCacheChanged();

View File

@ -7,8 +7,8 @@
#include <sqlite/sqlitestmt.h>
#include "appinfojob.h"
#include "appinfoutil.h"
#include "appinfoworker.h"
#include "apputil.h"
Q_DECLARE_LOGGING_CATEGORY(CLOG_APPINFO_MANAGER)
Q_LOGGING_CATEGORY(CLOG_APPINFO_MANAGER, "appInfo")
@ -97,7 +97,7 @@ void AppInfoManager::lookupAppInfo(const QString &appPath)
void AppInfoManager::handleWorkerResult(WorkerJob *workerJob)
{
if (!aborted()) {
auto job = static_cast<AppInfoJob *>(workerJob);
const auto job = static_cast<AppInfoJob *>(workerJob);
emit lookupFinished(job->appPath(), job->appInfo);
}
@ -107,12 +107,12 @@ void AppInfoManager::handleWorkerResult(WorkerJob *workerJob)
bool AppInfoManager::loadInfoFromFs(const QString &appPath, AppInfo &appInfo)
{
return AppUtil::getInfo(appPath, appInfo);
return AppInfoUtil::getInfo(appPath, appInfo);
}
QImage AppInfoManager::loadIconFromFs(const QString &appPath)
{
return AppUtil::getIcon(appPath);
return AppInfoUtil::getIcon(appPath);
}
bool AppInfoManager::loadInfoFromDb(const QString &appPath, AppInfo &appInfo)

View File

@ -35,7 +35,7 @@ public:
void deleteOldApps(int limitCount = 0);
signals:
void lookupFinished(const QString &appPath, const AppInfo appInfo);
void lookupFinished(const QString &appPath, const AppInfo &appInfo);
public slots:
void lookupAppInfo(const QString &appPath);

View File

@ -1,4 +1,4 @@
#include "apputil.h"
#include "appinfoutil.h"
#include <QDir>
#include <QPixmap>
@ -121,7 +121,9 @@ bool extractVersionInfo(const QString &appPath, AppInfo &appInfo)
}
bool AppUtil::getInfo(const QString &appPath, AppInfo &appInfo)
namespace AppInfoUtil {
bool getInfo(const QString &appPath, AppInfo &appInfo)
{
if (appPath.isEmpty())
return false;
@ -142,7 +144,7 @@ bool AppUtil::getInfo(const QString &appPath, AppInfo &appInfo)
return true;
}
QImage AppUtil::getIcon(const QString &appPath)
QImage getIcon(const QString &appPath)
{
if (appPath.isEmpty())
return {};
@ -155,12 +157,14 @@ QImage AppUtil::getIcon(const QString &appPath)
return extractShellIcon(appPath).toImage();
}
void AppUtil::initThread()
void initThread()
{
CoInitialize(nullptr);
}
void AppUtil::doneThread()
void doneThread()
{
CoUninitialize();
}
}

View File

@ -0,0 +1,19 @@
#ifndef APPINFOUTIL_H
#define APPINFOUTIL_H
#include <QImage>
#include <QObject>
class AppInfo;
namespace AppInfoUtil {
bool getInfo(const QString &appPath, AppInfo &appInfo);
QImage getIcon(const QString &appPath);
void initThread();
void doneThread();
}
#endif // APPINFOUTIL_H

View File

@ -5,7 +5,7 @@
#include "appinfo.h"
#include "appinfomanager.h"
#include "appinfojob.h"
#include "apputil.h"
#include "appinfoutil.h"
AppInfoWorker::AppInfoWorker(AppInfoManager *manager) : WorkerObject(manager) { }
@ -16,11 +16,11 @@ AppInfoManager *AppInfoWorker::manager() const
void AppInfoWorker::run()
{
AppUtil::initThread();
AppInfoUtil::initThread();
WorkerObject::run();
AppUtil::doneThread();
AppInfoUtil::doneThread();
}
void AppInfoWorker::doJob(WorkerJob *workerJob)

View File

@ -1,19 +0,0 @@
#ifndef APPUTIL_H
#define APPUTIL_H
#include <QImage>
#include <QObject>
class AppInfo;
class AppUtil
{
public:
static bool getInfo(const QString &appPath, AppInfo &appInfo);
static QImage getIcon(const QString &appPath);
static void initThread();
static void doneThread();
};
#endif // APPUTIL_H