Skip to content

Commit 501e2ec

Browse files
committed
Database: modify DatabaseTree
1 parent 1f420d8 commit 501e2ec

4 files changed

Lines changed: 247 additions & 280 deletions

File tree

App/Client/Favorite/FavoriteDatabase.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,30 +207,37 @@ int CFavoriteDatabase::AddFavorite(const QString &szFile,
207207
success = query.exec();
208208
if (!success) {
209209
QString szErr = "Failed to insert favorite table: " + query.lastError().text();
210+
SetError(szErr);
210211
qCritical(log) << szErr;
211212
throw std::runtime_error(szErr.toStdString());
212213
}
213214

214215
key = query.lastInsertId().toInt();
215216
if(0 >= key) {
216217
QString szErr = "Failed to insert favorite table";
218+
SetError(szErr);
219+
qCritical(log) << szErr;
217220
throw std::runtime_error(szErr.toStdString());
218221
}
219222
}
220223

221224
// 在 tree 表中增加
222-
TreeItem item;
225+
TreeItem item(TreeItem::Leaf);
223226
item.SetKey(key);
224227
item.SetParentId(parentId);
225228
int id = Add(item);
226229
if (0 >= id) {
227230
QString szErr = "Failed to insert favorite folder table";
231+
SetError(szErr);
232+
qCritical(log) << szErr;
228233
throw std::runtime_error(szErr.toStdString());
229234
}
230235

231236
// 提交事务
232237
if (!db.commit()) {
233238
QString szErr = "Failed to commit transaction:" + db.lastError().text();
239+
SetError(szErr);
240+
qCritical(log) << szErr;
234241
throw std::runtime_error(szErr.toStdString());
235242
}
236243

Plugins/WebBrowser/Bookmark/BookmarkDatabase.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,9 @@ QDomElement CBookmarkDatabase::findFirstElement(const QDomElement &parent, const
704704

705705
TreeItem CBookmarkDatabase::BookmarkToTree(const BookmarkItem& tree, bool setKey)
706706
{
707-
TreeItem item;
708707
TreeItem::TYPE type;
709708
type = tree.type == BookmarkType_Folder ? TreeItem::Node: TreeItem::Leaf;
710-
item.SetType(type);
709+
TreeItem item(type);
711710
item.SetId(tree.id);
712711
item.SetParentId(tree.folderId);
713712
item.SetCreateTime(tree.createdTime);

0 commit comments

Comments
 (0)