Fix the error count of launch times.
Modify the enqueue operation of app queue.
This commit is contained in:
parent
720ac7304c
commit
6408223760
|
@ -709,8 +709,8 @@ bool AppDBManager::handleDBItemUpdate(const QString &desktopfd)
|
|||
"MODIFYED_TIME='%0',"
|
||||
"LOCAL_NAME='%1',"
|
||||
"NAME_EN='%2',"
|
||||
"NAME_ZH='%3'"
|
||||
",PINYIN_NAME='%4',"
|
||||
"NAME_ZH='%3',"
|
||||
"PINYIN_NAME='%4',"
|
||||
"FIRST_LETTER_OF_PINYIN='%5',"
|
||||
"FIRST_LETTER_ALL='%6',"
|
||||
"ICON='%7',"
|
||||
|
@ -753,14 +753,15 @@ bool AppDBManager::handleDBItemUpdate(const QString &desktopfd)
|
|||
return res;
|
||||
}
|
||||
|
||||
bool AppDBManager::handleLaunchTimesUpdate(const QString &desktopfp)
|
||||
bool AppDBManager::handleLaunchTimesUpdate(const QString &desktopfp, int num)
|
||||
{
|
||||
qDebug() << "launch times will add:" << num;
|
||||
bool res(true);
|
||||
QSqlQuery sql(m_database);
|
||||
QString cmd = QString("SELECT LAUNCH_TIMES FROM APPINFO WHERE DESKTOP_FILE_PATH='%1'").arg(desktopfp);
|
||||
if (sql.exec(cmd)) {
|
||||
if (sql.next()) {
|
||||
int launchTimes = sql.value(0).toInt() + 1;
|
||||
int launchTimes = sql.value(0).toInt() + num;
|
||||
cmd = QString("UPDATE appInfo SET MODIFYED_TIME='%0', LAUNCH_TIMES=%1, LAUNCHED=%2 WHERE DESKTOP_FILE_PATH='%3'")
|
||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"))
|
||||
.arg(launchTimes)
|
||||
|
@ -774,7 +775,7 @@ bool AppDBManager::handleLaunchTimesUpdate(const QString &desktopfp)
|
|||
result.desktopPath = desktopfp;
|
||||
result.launchTimes = launchTimes;
|
||||
Q_EMIT this->appDBItemUpdate(result);
|
||||
qDebug() << "app database update " << desktopfp << "launch times success!";
|
||||
qDebug() << "app database update:" << desktopfp << "launch times:" << launchTimes << "success!";
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Failed to exec next!" << cmd;
|
||||
|
@ -929,12 +930,15 @@ void AppDBManager::updateLocaleData(const QString &desktopfp)
|
|||
void AppDBManager::updateLaunchTimes(const QString &desktopfp)
|
||||
{
|
||||
PendingAppInfo item(desktopfp, PendingAppInfo::HandleType::UpdateLaunchTimes);
|
||||
item.setLaunchWillAdd(true);
|
||||
item.setLaunchTimes(1);
|
||||
PendingAppInfoQueue::getAppInfoQueue().enqueue(item);
|
||||
}
|
||||
|
||||
void AppDBManager::updateFavoritesState(const QString &desktopfp, int num)
|
||||
{
|
||||
PendingAppInfo item(desktopfp, PendingAppInfo::HandleType::UpdateFavorites, num);
|
||||
PendingAppInfo item(desktopfp, PendingAppInfo::HandleType::UpdateFavorites);
|
||||
item.setFavorites(num);
|
||||
PendingAppInfoQueue::getAppInfoQueue().enqueue(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
bool handleDBItemDelete(const QString &desktopfd);
|
||||
|
||||
bool handleLocaleDataUpdate(const QString &desktopPath);
|
||||
bool handleLaunchTimesUpdate(const QString &desktopfp);
|
||||
bool handleLaunchTimesUpdate(const QString &desktopfp, int num);
|
||||
bool handleFavoritesStateUpdate(const QString &desktopfp, int num);
|
||||
bool handleTopStateUpdate(const QString &desktopfp, int num);
|
||||
bool handleLockStateUpdate(const QString &desktopfp, int num);
|
||||
|
|
|
@ -19,18 +19,20 @@ void PendingAppInfoQueue::enqueue(const PendingAppInfo &appInfo)
|
|||
if (index == -1) {
|
||||
m_cache << appInfo;
|
||||
} else {
|
||||
//已插入项操作类型为对某字段更新
|
||||
if (m_cache[index].handleType() > PendingAppInfo::HandleType::UpdateAll) {
|
||||
if (appInfo.handleType() > PendingAppInfo::HandleType::UpdateAll) {
|
||||
m_cache[index].merge(appInfo);
|
||||
} else {
|
||||
m_cache[index].setHandleType(appInfo);
|
||||
}
|
||||
} else {
|
||||
//已插入项操作类型为对全部字段进行增删改时,设置为优先级高的操作类型
|
||||
//只要操作类型为delete,直接覆盖
|
||||
if (m_cache[index].handleType() == PendingAppInfo::HandleType::Delete
|
||||
or appInfo.handleType() == PendingAppInfo::HandleType::Delete) {
|
||||
m_cache[index].setHandleType(PendingAppInfo::HandleType::Delete);
|
||||
|
||||
//已插入项操作类型为对所有desktop文件相关数据进行操作
|
||||
} else if (m_cache[index].handleType() < PendingAppInfo::HandleType::UpdateLocaleData
|
||||
and appInfo.handleType() < PendingAppInfo::HandleType::UpdateLocaleData) {
|
||||
//设置为优先级高的操作类型
|
||||
if (m_cache[index].handleType() > appInfo.handleType()) {
|
||||
m_cache[index].setHandleType(appInfo);
|
||||
}
|
||||
} else {
|
||||
m_cache[index].merge(appInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,11 +118,17 @@ void PendingAppInfoQueue::processCache()
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
if (handleTypes & PendingAppInfo::HandleType::Insert) {
|
||||
AppDBManager::getInstance()->handleDBItemInsert(info.path());
|
||||
}
|
||||
if (handleTypes & PendingAppInfo::HandleType::UpdateAll) {
|
||||
AppDBManager::getInstance()->handleDBItemUpdate(info.path());
|
||||
}
|
||||
if (handleTypes & PendingAppInfo::HandleType::UpdateLocaleData) {
|
||||
AppDBManager::getInstance()->handleLocaleDataUpdate(info.path());
|
||||
}
|
||||
if (handleTypes & PendingAppInfo::HandleType::UpdateLaunchTimes) {
|
||||
AppDBManager::getInstance()->handleLaunchTimesUpdate(info.path());
|
||||
AppDBManager::getInstance()->handleLaunchTimesUpdate(info.path(), info.launchTimes());
|
||||
}
|
||||
if (handleTypes & PendingAppInfo::HandleType::UpdateFavorites) {
|
||||
AppDBManager::getInstance()->handleFavoritesStateUpdate(info.path(), info.favoritesState());
|
||||
|
|
|
@ -22,23 +22,30 @@ public:
|
|||
Q_DECLARE_FLAGS(HandleTypes, HandleType)
|
||||
|
||||
PendingAppInfo() = default;
|
||||
PendingAppInfo(QString desktopfp, HandleTypes type, int favorites = -1, int top = -1, int lock = -1)
|
||||
PendingAppInfo(QString desktopfp, HandleTypes type, int favorites = -1, int top = -1, int lock = -1, bool addLaunch = false, int launchTimes = 0)
|
||||
: m_desktopfp(desktopfp),
|
||||
m_handleType(type),
|
||||
m_favoritesState(favorites),
|
||||
m_topState(top),
|
||||
m_lockState(lock) {}
|
||||
m_lockState(lock),
|
||||
m_willAddLaunch(addLaunch),
|
||||
m_launchTimes(launchTimes) {}
|
||||
|
||||
QString path() const {return m_desktopfp;}
|
||||
HandleTypes handleType() const {return m_handleType;}
|
||||
int favoritesState() const {return m_favoritesState;}
|
||||
int topState() const {return m_topState;}
|
||||
int lockState() const {return m_lockState;}
|
||||
int launchTimes() const {return m_launchTimes;}
|
||||
bool willAddLunchTimes() const {return m_willAddLaunch;}
|
||||
|
||||
void setHandleType(const PendingAppInfo & info) {m_handleType = info.handleType();}
|
||||
void setHandleType(HandleTypes type) {m_handleType = type;}
|
||||
void setFavorites(int favoritesState) {m_favoritesState = favoritesState;}
|
||||
void setTop(int top) {m_topState = top;}
|
||||
void setLock(int lock) {m_lockState = lock;}
|
||||
void setLaunchWillAdd(bool willAdd) {m_willAddLaunch = willAdd;}
|
||||
void setLaunchTimes(int times) {m_launchTimes = times;}
|
||||
void merge(const PendingAppInfo &info)
|
||||
{
|
||||
m_handleType |= info.handleType();
|
||||
|
@ -54,6 +61,9 @@ public:
|
|||
if (info.lockState() != -1) {
|
||||
m_lockState = info.lockState();
|
||||
}
|
||||
if (info.willAddLunchTimes()) {
|
||||
m_launchTimes++;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator ==(const PendingAppInfo& rhs) const {
|
||||
|
@ -65,6 +75,8 @@ private:
|
|||
int m_favoritesState;
|
||||
int m_topState;
|
||||
int m_lockState;
|
||||
bool m_willAddLaunch;
|
||||
int m_launchTimes;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue