MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / addHistoryEntry

Method addHistoryEntry

Plugins/WebBrowser/History/HistoryDatabase.cpp:64–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64bool CHistoryDatabase::addHistoryEntry(const QString &url)
65{
66 if (url.isEmpty()) return false;
67
68 int nUrlId = 0;
69 // 检查 URL 是否已存在。如果不存在,则增加
70 nUrlId = m_UrlDB.GetId(url);
71 if(0 == nUrlId) {
72 nUrlId = m_UrlDB.AddUrl(url);
73 if(0 == nUrlId)
74 return false;
75 }
76
77 // 插入新记录
78 QSqlQuery query(GetDatabase());
79 query.prepare(
80 "INSERT INTO history (url, visit_time) "
81 "VALUES (:url, :visit_time) "
82 );
83 query.bindValue(":url", nUrlId);
84 QDateTime tm = QDateTime::currentDateTime();
85 query.bindValue(":visit_time", tm);
86
87 bool success = query.exec();
88 if (!success) {
89 QString szErr = "Failed to add history: " + query.lastError().text()
90 + "; Sql: " + query.executedQuery()
91 + "; url: " + url;
92 SetError(szErr);
93 qCritical(log) << GetError();
94 }
95
96 return success;
97}
98
99bool CHistoryDatabase::addHistoryEntry(const QString &url, const QString& title, const QDateTime& time)
100{

Callers 1

SetConnectMethod · 0.80

Calls 3

AddUrlMethod · 0.80
isEmptyMethod · 0.45
GetIdMethod · 0.45

Tested by

no test coverage detected