| 885 | } |
| 886 | |
| 887 | QList<TreeItem> CDatabaseTree::GetLeavesByKey(int key) |
| 888 | { |
| 889 | QList<TreeItem> items; |
| 890 | QSqlQuery query(GetDatabase()); |
| 891 | QString szSql; |
| 892 | szSql = "SELECT `id`, `name`, " |
| 893 | " `created_time`, `modified_time`, `last_visit_time`, `parent_id` " |
| 894 | " FROM `" + m_szTableName + "` " |
| 895 | " WHERE `key` = :key"; |
| 896 | query.prepare(szSql); |
| 897 | query.bindValue(":key", key); |
| 898 | bool success = query.exec(); |
| 899 | if (!success) { |
| 900 | SetError("Failed to get leaves by key: " + query.lastError().text() |
| 901 | + "; Sql: " + query.executedQuery() |
| 902 | + "; key: " + QString::number(key)); |
| 903 | return items; |
| 904 | } |
| 905 | while(query.next()) { |
| 906 | TreeItem item(TreeItem::Leaf); |
| 907 | item.SetId(query.value(0).toInt()); |
| 908 | item.SetName(query.value(1).toString()); |
| 909 | item.SetKey(key); |
| 910 | item.SetCreateTime(query.value(2).toDateTime()); |
| 911 | item.SetModifyTime(query.value(3).toDateTime()); |
| 912 | item.SetLastVisitTime(query.value(4).toDateTime()); |
| 913 | item.SetParentId(query.value(5).toInt()); |
| 914 | |
| 915 | items.append(item); |
| 916 | } |
| 917 | return items; |
| 918 | } |
| 919 | |
| 920 | QList<TreeItem> CDatabaseTree::GetLeavesByKey(QList<int> key) |
| 921 | { |
no test coverage detected