| 816 | } |
| 817 | |
| 818 | TreeItem CDatabaseTree::GetLeaf(int id) |
| 819 | { |
| 820 | TreeItem item(TreeItem::Leaf); |
| 821 | |
| 822 | QSqlQuery query(GetDatabase()); |
| 823 | query.prepare( |
| 824 | "SELECT `name`, `key`, `created_time`, `modified_time`, `last_visit_time`, `parent_id` " |
| 825 | " FROM `" + m_szTableName + "` " |
| 826 | " WHERE `id` = :id"); |
| 827 | query.bindValue(":id", id); |
| 828 | bool bRet = query.exec(); |
| 829 | if (!bRet) { |
| 830 | QString szErr |
| 831 | = "Failed to get leaf: " + query.lastError().text() |
| 832 | + "; Sql: " + query.executedQuery() |
| 833 | + "; id: " + QString::number(id); |
| 834 | SetError(szErr); |
| 835 | qCritical(log) << GetError(); |
| 836 | return item; |
| 837 | } |
| 838 | |
| 839 | if(query.next()) { |
| 840 | item.SetId(id); |
| 841 | item.SetName(query.value(0).toString()); |
| 842 | item.SetKey(query.value(1).toInt()); |
| 843 | item.SetCreateTime(query.value(2).toDateTime()); |
| 844 | item.SetModifyTime(query.value(3).toDateTime()); |
| 845 | item.SetLastVisitTime(query.value(4).toDateTime()); |
| 846 | item.SetParentId(query.value(5).toInt()); |
| 847 | } |
| 848 | |
| 849 | return item; |
| 850 | } |
| 851 | |
| 852 | QList<TreeItem> CDatabaseTree::GetLeaves(int nodeId) |
| 853 | { |
no test coverage detected