| 172 | } |
| 173 | |
| 174 | void ProgramTableView::keyPressEvent(QKeyEvent *event) { |
| 175 | if (event->matches(QKeySequence::Copy)) { |
| 176 | QString text; |
| 177 | QItemSelectionRange range = selectionModel()->selection().first(); |
| 178 | for (auto i = range.top(); i <= range.bottom(); ++i) { |
| 179 | QStringList rowContents; |
| 180 | for (auto j = range.left(); j <= range.right(); ++j) { |
| 181 | rowContents << model()->index(i, j).data().toString(); |
| 182 | } |
| 183 | text += rowContents.join("\t"); |
| 184 | text += "\n"; |
| 185 | } |
| 186 | QApplication::clipboard()->setText(text); |
| 187 | } else { |
| 188 | Super::keyPressEvent(event); |
| 189 | } |
| 190 | } |