| 19 | explicit CFavoriteDatabase(QObject *parent = nullptr); |
| 20 | |
| 21 | struct Item { |
| 22 | int id; // is the id of tree table |
| 23 | int parentId; |
| 24 | QString szName; |
| 25 | QIcon icon; |
| 26 | QString szFile; |
| 27 | QString szDescription; |
| 28 | TreeItem::TYPE type; |
| 29 | explicit Item(TreeItem::TYPE t = TreeItem::Node) |
| 30 | : id(0) |
| 31 | , parentId(0) |
| 32 | , type(t) |
| 33 | {} |
| 34 | QIcon GetIcon() { |
| 35 | if(!icon.isNull()) |
| 36 | return icon; |
| 37 | if(isFolder()) |
| 38 | return QIcon::fromTheme("folder"); |
| 39 | return QIcon::fromTheme("file"); |
| 40 | } |
| 41 | bool isFolder() const { return type == TreeItem::Node; } |
| 42 | bool isFavorite() const { return type == TreeItem::Leaf; } |
| 43 | // 添加有效性检查 |
| 44 | bool isValid() const { |
| 45 | return id > 0 || !szFile.isEmpty(); |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | int AddFavorite(const QString &szFile, const QString& szName, |
| 50 | const QIcon &icon, const QString szDescription, |
nothing calls this directly
no outgoing calls
no test coverage detected