| 850 | } |
| 851 | |
| 852 | QList<TreeItem> CDatabaseTree::GetLeaves(int nodeId) |
| 853 | { |
| 854 | QList<TreeItem> items; |
| 855 | QSqlQuery query(GetDatabase()); |
| 856 | QString szSql; |
| 857 | szSql = "SELECT `id`, `name`, `key`, " |
| 858 | "`created_time`, `modified_time`, `last_visit_time`, `parent_id` " |
| 859 | "FROM `" + m_szTableName + "`"; |
| 860 | if(0 <= nodeId) |
| 861 | szSql += " WHERE `parent_id` = :parent_id"; |
| 862 | query.prepare(szSql); |
| 863 | query.bindValue(":parent_id", nodeId); |
| 864 | bool bRet = query.exec(); |
| 865 | if (!bRet) { |
| 866 | SetError("Failed to get leaves: " + query.lastError().text() |
| 867 | + "; Sql: " + query.executedQuery() |
| 868 | + "; parentId: " + QString::number(nodeId)); |
| 869 | qCritical(log) << GetError(); |
| 870 | return items; |
| 871 | } |
| 872 | while(query.next()) { |
| 873 | TreeItem item(TreeItem::Leaf); |
| 874 | item.SetId(query.value(0).toInt()); |
| 875 | item.SetName(query.value(1).toString()); |
| 876 | item.SetKey(query.value(2).toInt()); |
| 877 | item.SetCreateTime(query.value(3).toDateTime()); |
| 878 | item.SetModifyTime(query.value(4).toDateTime()); |
| 879 | item.SetLastVisitTime(query.value(5).toDateTime()); |
| 880 | item.SetParentId(query.value(6).toInt()); |
| 881 | |
| 882 | items.append(item); |
| 883 | } |
| 884 | return items; |
| 885 | } |
| 886 | |
| 887 | QList<TreeItem> CDatabaseTree::GetLeavesByKey(int key) |
| 888 | { |
no test coverage detected