Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @licence end@
*/

#include "qabstractitemmodel.h"
#include "qdebug.h"
#include <algorithm>
#include <QMimeData>
#include <QTreeView>
Expand Down Expand Up @@ -7049,6 +7051,38 @@ void MainWindow::on_tableView_customContextMenuRequested(QPoint pos)

menu.addSeparator();

action = new QAction("Copy Selection as image to Clipboard", &menu);
connect(action, &QAction::triggered, this, [this](){
// save and clear selection for clean screenshot
auto selectionIndexes = ui->tableView->selectionModel()->selection().indexes();

auto headerRect = ui->tableView->horizontalHeader()->rect();

ui->tableView->selectionModel()->clearSelection();

QRect res;
for (qsizetype i = 0; i < selectionIndexes.size(); ++i)
{
res |= ui->tableView->visualRect(selectionIndexes[i]);
}
// take into account height of the table header
res.translate(0, headerRect.height());

auto tableViewRect = ui->tableView->contentsRect();
auto pixmap = ui->tableView->grab(res & tableViewRect);

QApplication::clipboard()->setPixmap(pixmap);

// restore selection
for (const auto& index : selectionIndexes)
{
ui->tableView->selectionModel()->select(index, QItemSelectionModel::Select);
}
});
menu.addAction(action);

menu.addSeparator();

action = new QAction("&Export...", &menu);
if(qfile.sizeFilter() <= 0)
{
Expand Down
Loading