mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:25:20 +00:00
UI: Minor fixes.
This commit is contained in:
parent
1b9ae68574
commit
0f5f60e030
@ -102,11 +102,11 @@ void Test::debugStatTraf(SqliteDb *sqliteDb)
|
||||
|
||||
debugStatTrafStep(sqliteDb, "traffic_app_total",
|
||||
"SELECT app_id, traf_time, in_bytes, out_bytes"
|
||||
" FROM app;", 1);
|
||||
" FROM app;");
|
||||
}
|
||||
|
||||
void Test::debugStatTrafStep(SqliteDb *sqliteDb, const char *name,
|
||||
const char *sql, int timeMult)
|
||||
const char *sql)
|
||||
{
|
||||
SqliteStmt stmt;
|
||||
|
||||
@ -114,7 +114,7 @@ void Test::debugStatTrafStep(SqliteDb *sqliteDb, const char *name,
|
||||
|
||||
qDebug() << '>' << name << '<';
|
||||
while (stmt.step() == SqliteStmt::StepRow) {
|
||||
const qint64 trafTime = stmt.columnInt64(1) * timeMult;
|
||||
const qint64 trafTime = stmt.columnInt64(1) * 3600;
|
||||
|
||||
qDebug() << '>'
|
||||
<< stmt.columnInt64(0)
|
||||
|
@ -17,7 +17,7 @@ private:
|
||||
|
||||
void debugStatTraf(SqliteDb *sqliteDb);
|
||||
void debugStatTrafStep(SqliteDb *sqliteDb, const char *name,
|
||||
const char *sql, int timeMult = 3600);
|
||||
const char *sql);
|
||||
};
|
||||
|
||||
#endif // TEST_H
|
||||
|
@ -75,6 +75,8 @@ void DatabaseManager::logStatTraf(quint16 procCount, const quint8 *procBits,
|
||||
m_lastTrafDay = trafDay;
|
||||
m_lastTrafMonth = trafMonth;
|
||||
|
||||
m_sqliteDb->beginTransaction();
|
||||
|
||||
// Insert Statemets
|
||||
QStmtList insertTrafAppStmts = QStmtList()
|
||||
<< getTrafficStmt(DatabaseSql::sqlInsertTrafficAppHour, trafHour)
|
||||
@ -99,8 +101,6 @@ void DatabaseManager::logStatTraf(quint16 procCount, const quint8 *procBits,
|
||||
<< getTrafficStmt(DatabaseSql::sqlUpdateTrafficDay, trafDay)
|
||||
<< getTrafficStmt(DatabaseSql::sqlUpdateTrafficMonth, trafMonth);
|
||||
|
||||
m_sqliteDb->beginTransaction();
|
||||
|
||||
for (quint16 i = 0; i < procCount; ++i) {
|
||||
const bool active = procBits[i / 8] & (1 << (i & 7));
|
||||
if (!active) {
|
||||
@ -174,6 +174,8 @@ qint64 DatabaseManager::createAppId(const QString &appPath)
|
||||
{
|
||||
qint64 appId = 0;
|
||||
|
||||
m_sqliteDb->beginTransaction();
|
||||
|
||||
SqliteStmt *stmt = getSqliteStmt(DatabaseSql::sqlInsertAppId);
|
||||
const qint64 unixTime = DateUtil::getUnixTime();
|
||||
|
||||
@ -186,6 +188,8 @@ qint64 DatabaseManager::createAppId(const QString &appPath)
|
||||
}
|
||||
stmt->reset();
|
||||
|
||||
m_sqliteDb->commitTransaction();
|
||||
|
||||
return appId;
|
||||
}
|
||||
|
||||
|
@ -60,15 +60,7 @@ QVariant TrafListModel::data(const QModelIndex &index, int role) const
|
||||
const int row = index.row();
|
||||
|
||||
if (!m_rowCache.isValid(row)) {
|
||||
m_rowCache.row = row;
|
||||
m_rowCache.trafTime = getTrafTime(row);
|
||||
|
||||
const char *sqlSelectTraffic = getSqlSelectTraffic(m_type, m_appId);
|
||||
|
||||
m_databaseManager->getTraffic(
|
||||
sqlSelectTraffic, m_rowCache.trafTime,
|
||||
m_rowCache.inBytes, m_rowCache.outBytes,
|
||||
m_appId);
|
||||
updateRowCache(row);
|
||||
}
|
||||
|
||||
switch (role) {
|
||||
@ -97,6 +89,19 @@ void TrafListModel::clear()
|
||||
{
|
||||
}
|
||||
|
||||
void TrafListModel::updateRowCache(int row) const
|
||||
{
|
||||
m_rowCache.row = row;
|
||||
m_rowCache.trafTime = getTrafTime(row);
|
||||
|
||||
const char *sqlSelectTraffic = getSqlSelectTraffic(m_type, m_appId);
|
||||
|
||||
m_databaseManager->getTraffic(
|
||||
sqlSelectTraffic, m_rowCache.trafTime,
|
||||
m_rowCache.inBytes, m_rowCache.outBytes,
|
||||
m_appId);
|
||||
}
|
||||
|
||||
QString TrafListModel::formatTrafTime(qint32 trafTime) const
|
||||
{
|
||||
const qint64 unixTime = DateUtil::toUnixTime(trafTime);
|
||||
|
@ -57,6 +57,8 @@ public slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void updateRowCache(int row) const;
|
||||
|
||||
QString formatTrafTime(qint32 trafTime) const;
|
||||
|
||||
qint32 getTrafTime(int row) const;
|
||||
|
@ -23,7 +23,7 @@ TranslationManager::~TranslationManager()
|
||||
|
||||
TranslationManager *TranslationManager::instance()
|
||||
{
|
||||
static TranslationManager *g_instanceTranslationManager = 0;
|
||||
static TranslationManager *g_instanceTranslationManager = nullptr;
|
||||
|
||||
if (!g_instanceTranslationManager) {
|
||||
g_instanceTranslationManager = new TranslationManager();
|
||||
|
Loading…
Reference in New Issue
Block a user