| 111 | } |
| 112 | |
| 113 | void SearchResultWidgetPrivate::updateMessage() |
| 114 | { |
| 115 | Q_EMIT q->resultCountChanged(); |
| 116 | const auto &result = resultModel.allResult(); |
| 117 | if (result.isEmpty()) { |
| 118 | msgLabel->clear(); |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | int totalResult = 0; |
| 123 | for (const auto &list : result) { |
| 124 | totalResult += list.size(); |
| 125 | } |
| 126 | |
| 127 | QString msg; |
| 128 | auto color = q->palette().color(QPalette::Highlight).name(); |
| 129 | auto colorFormat = "<font color='" + color + "'>%1</font>"; |
| 130 | if (result.count() == 1 && result.first().count() == 1) { |
| 131 | msg = SearchResultWidget::tr("%1 result in %2 file").arg(colorFormat.arg(1), colorFormat.arg(1)); |
| 132 | } else if (result.count() == 1) { |
| 133 | msg = SearchResultWidget::tr("%1 results in %2 file").arg(colorFormat.arg(totalResult), colorFormat.arg(1)); |
| 134 | } else { |
| 135 | msg = SearchResultWidget::tr("%1 results in %2 files").arg(colorFormat.arg(totalResult), colorFormat.arg(result.count())); |
| 136 | } |
| 137 | |
| 138 | msgLabel->setText(msg); |
| 139 | } |
| 140 | |
| 141 | void SearchResultWidgetPrivate::readyReplace(const QModelIndex &index) |
| 142 | { |