| 75 | } |
| 76 | |
| 77 | QVariant CRecentModel::data(const QModelIndex &index, int role) const |
| 78 | { |
| 79 | if (!index.isValid()) |
| 80 | return QVariant(); |
| 81 | |
| 82 | if(index.row() >= m_Items.count()) |
| 83 | return QVariant(); |
| 84 | |
| 85 | auto item = m_Items.at(index.row()); |
| 86 | |
| 87 | switch (role) { |
| 88 | case Qt::DisplayRole: |
| 89 | switch (index.column()) { |
| 90 | case Name: |
| 91 | return item.szName; |
| 92 | case Protocol: |
| 93 | return item.szProtocol; |
| 94 | case Type: |
| 95 | return item.szType; |
| 96 | case Time: |
| 97 | return item.time.toString(QLocale::system().dateTimeFormat()); |
| 98 | case ID: |
| 99 | return item.szOperateId; |
| 100 | case File: |
| 101 | return item.GetFile(); |
| 102 | } |
| 103 | break; |
| 104 | |
| 105 | case Qt::DecorationRole: |
| 106 | if (index.column() == Name) { |
| 107 | return item.icon; |
| 108 | } |
| 109 | break; |
| 110 | |
| 111 | case Qt::ToolTipRole: |
| 112 | return item.szDescription; |
| 113 | } |
| 114 | |
| 115 | return QVariant(); |
| 116 | } |
| 117 | |
| 118 | bool CRecentModel::removeRows(int row, int count, const QModelIndex &parent) |
| 119 | { |
no test coverage detected