Add copy functionality to PipelineTable
Chosen format is tab-separated, suitable for spreadsheet editors.
ADD
resources/documents.svg
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ viewBox="0 0 512.002 512.002" style="enable-background:new 0 0 512.002 512.002;" xml:space="preserve">
+<rect x="125.182" y="1.634" style="fill:#E0E0D3;" width="386.82" height="483.366"/>
+<g>
+ <path style="fill:#5C6670;" d="M454.094,80.196H183.091c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h271.003
+ c4.769,0,8.636,3.865,8.636,8.636S458.864,80.196,454.094,80.196z"/>
+ <path style="fill:#5C6670;" d="M454.094,119.929H352.577c-4.77,0-8.636-3.865-8.636-8.636s3.865-8.636,8.636-8.636h101.517
+ c4.769,0,8.636,3.865,8.636,8.636C462.73,116.064,458.864,119.929,454.094,119.929z"/>
+ <path style="fill:#5C6670;" d="M326.52,119.929H183.091c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636H326.52
+ c4.77,0,8.636,3.865,8.636,8.636S331.29,119.929,326.52,119.929z"/>
+ <path style="fill:#5C6670;" d="M454.094,159.666H183.091c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h271.003
+ c4.769,0,8.636,3.865,8.636,8.636S458.864,159.666,454.094,159.666z"/>
+ <path style="fill:#5C6670;" d="M454.094,199.399h-61.866c-4.77,0-8.636-3.865-8.636-8.636s3.865-8.636,8.636-8.636h61.866
+ c4.769,0,8.636,3.865,8.636,8.636C462.73,195.533,458.864,199.399,454.094,199.399z"/>
+ <path style="fill:#5C6670;" d="M366.173,199.399H183.091c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h183.082
+ c4.77,0,8.636,3.865,8.636,8.636C374.808,195.533,370.942,199.399,366.173,199.399z"/>
+ <path style="fill:#5C6670;" d="M454.094,239.136H302.73c-4.77,0-8.636-3.865-8.636-8.636c0-4.77,3.865-8.636,8.636-8.636h151.363
+ c4.769,0,8.636,3.865,8.636,8.636C462.73,235.27,458.864,239.136,454.094,239.136z"/>
+ <path style="fill:#5C6670;" d="M277.806,239.136H183.09c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h94.716
+ c4.77,0,8.636,3.865,8.636,8.636C286.441,235.27,282.576,239.136,277.806,239.136z"/>
+ <path style="fill:#5C6670;" d="M403.337,278.868H183.091c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h220.246
+ c4.77,0,8.636,3.865,8.636,8.636C411.973,275.003,408.107,278.868,403.337,278.868z"/>
+ <path style="fill:#5C6670;" d="M454.094,318.602H291.337c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h162.757
+ c4.769,0,8.636,3.865,8.636,8.636S458.864,318.602,454.094,318.602z"/>
+ <path style="fill:#5C6670;" d="M259.617,318.602h-76.526c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h76.526
+ c4.77,0,8.636,3.865,8.636,8.636S264.386,318.602,259.617,318.602z"/>
+ <path style="fill:#5C6670;" d="M454.094,358.335h-87.921c-4.77,0-8.636-3.865-8.636-8.636c0-4.77,3.865-8.636,8.636-8.636h87.921
+ c4.769,0,8.636,3.865,8.636,8.636S458.864,358.335,454.094,358.335z"/>
+ <path style="fill:#5C6670;" d="M335.144,358.335H183.091c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h152.053
+ c4.77,0,8.636,3.865,8.636,8.636S339.914,358.335,335.144,358.335z"/>
+ <path style="fill:#5C6670;" d="M454.094,398.07H183.091c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h271.003
+ c4.769,0,8.636,3.865,8.636,8.636C462.73,394.204,458.864,398.07,454.094,398.07z"/>
+ <path style="fill:#5C6670;" d="M352.577,437.803H183.091c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h169.486
+ c4.77,0,8.636,3.865,8.636,8.636C361.212,433.937,357.347,437.803,352.577,437.803z"/>
+</g>
+<rect x="125.182" y="1.634" style="opacity:0.2;enable-background:new ;" width="293.359" height="483.366"/>
+<rect y="27.001" style="fill:#E0E0D3;" width="386.82" height="483.366"/>
+<path style="fill:#333E48;" d="M328.914,105.563H57.911c-4.769,0-8.636-3.866-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h271.003
+ c4.77,0,8.636,3.865,8.636,8.636C337.549,101.696,333.684,105.563,328.914,105.563z"/>
+<g>
+ <path style="fill:#5C6670;" d="M328.914,185.032H57.911c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h271.003
+ c4.77,0,8.636,3.865,8.636,8.636C337.549,181.166,333.684,185.032,328.914,185.032z"/>
+ <path style="fill:#5C6670;" d="M328.914,224.766h-61.866c-4.77,0-8.636-3.865-8.636-8.636s3.865-8.636,8.636-8.636h61.866
+ c4.77,0,8.636,3.865,8.636,8.636S333.684,224.766,328.914,224.766z"/>
+ <path style="fill:#5C6670;" d="M240.992,224.766H57.911c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h183.082
+ c4.769,0,8.636,3.865,8.636,8.636S245.762,224.766,240.992,224.766z"/>
+ <path style="fill:#5C6670;" d="M328.914,264.502H177.55c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h151.363
+ c4.77,0,8.636,3.865,8.636,8.636C337.549,260.635,333.684,264.502,328.914,264.502z"/>
+ <path style="fill:#5C6670;" d="M152.627,264.502H57.911c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h94.716
+ c4.769,0,8.636,3.865,8.636,8.636C161.262,260.635,157.396,264.502,152.627,264.502z"/>
+ <path style="fill:#5C6670;" d="M328.914,343.969H166.159c-4.769,0-8.636-3.866-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h162.756
+ c4.77,0,8.636,3.865,8.636,8.636C337.549,340.103,333.684,343.969,328.914,343.969z"/>
+ <path style="fill:#5C6670;" d="M134.438,343.969H57.911c-4.769,0-8.636-3.866-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h76.527
+ c4.769,0,8.636,3.865,8.636,8.636C143.073,340.103,139.207,343.969,134.438,343.969z"/>
+ <path style="fill:#5C6670;" d="M328.914,383.701h-87.921c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h87.921
+ c4.77,0,8.636,3.865,8.636,8.636C337.549,379.836,333.684,383.701,328.914,383.701z"/>
+ <path style="fill:#5C6670;" d="M209.965,383.701H57.911c-4.769,0-8.636-3.865-8.636-8.636s3.866-8.636,8.636-8.636h152.054
+ c4.769,0,8.636,3.865,8.636,8.636C218.601,379.836,214.734,383.701,209.965,383.701z"/>
+ <path style="fill:#5C6670;" d="M328.914,423.436H57.911c-4.769,0-8.636-3.866-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h271.003
+ c4.77,0,8.636,3.865,8.636,8.636C337.549,419.57,333.684,423.436,328.914,423.436z"/>
+ <path style="fill:#5C6670;" d="M227.398,463.169H57.911c-4.769,0-8.636-3.865-8.636-8.636c0-4.77,3.866-8.636,8.636-8.636h169.487
+ c4.769,0,8.636,3.865,8.636,8.636C236.033,459.302,232.167,463.169,227.398,463.169z"/>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+<g>
+</g>
+</svg>

MODIFY
resources/images.qrc
resources/images.qrc
<file>zoom-out.svg</file>
<file>save.svg</file>
<file>spreadsheet.svg</file>
+ <file>documents.svg</file>
</qresource>
</RCC>

MODIFY
src/pipelinetable.cpp
src/pipelinetable.cpp
#include "pipelinetable.h"
#include "ui_pipelinetable.h"
+#include <QClipboard>
+#include <QFileDialog>
#include <QHeaderView>
PipelineTable::PipelineTable(QWidget* parent) : QDialog(parent), ui(new Ui::PipelineTable) {
@@ -11,8 +13,51 @@ PipelineTable::PipelineTable(QWidget* parent) : QDialog(parent), ui(new Ui::Pipe
void PipelineTable::setModel(QAbstractItemModel* model) {
ui->table->setModel(model);
+ m_model = model;
}
PipelineTable::~PipelineTable() {
delete ui;
}
+
+void PipelineTable::on_save_clicked() {
+ QFileDialog dialog;
+ dialog.setNameFilter("*.png");
+ dialog.setAcceptMode(QFileDialog::AcceptSave);
+ dialog.setOption(QFileDialog::DontUseNativeDialog);
+ if (dialog.exec()) {
+ auto files = dialog.selectedFiles();
+ if (files.length() == 1) {
+ ui->table->resizeColumnsToContents();
+ ui->table->resizeRowsToContents();
+ QPixmap pixmap(ui->table->size());
+ ui->table->render(&pixmap);
+ pixmap.save(files[0]);
+ }
+ }
+}
+
+void PipelineTable::on_copy_clicked() {
+ // Copy entire table to clipboard, including headers
+ Q_ASSERT(m_model != nullptr);
+ QString textualRepr;
+
+ // Copy headers
+ textualRepr.append('\t');
+ for (int j = 0; j < m_model->columnCount(); j++) {
+ textualRepr.append(m_model->headerData(j, Qt::Horizontal).toString());
+ textualRepr.append('\t');
+ }
+ textualRepr.append('\n');
+ // Copy data
+ for (int i = 0; i < m_model->rowCount(); i++) {
+ textualRepr.append(m_model->headerData(i, Qt::Vertical).toString());
+ textualRepr.append('\t');
+ for (int j = 0; j < m_model->columnCount(); j++) {
+ textualRepr.append(m_model->data(m_model->index(i, j)).toString());
+ textualRepr.append('\t');
+ }
+ textualRepr.append('\n');
+ }
+ QApplication::clipboard()->setText(textualRepr);
+}

MODIFY
src/pipelinetable.h
src/pipelinetable.h
@@ -17,8 +17,14 @@ public:
~PipelineTable();
void setModel(QAbstractItemModel* model);
+private slots:
+ void on_save_clicked();
+
+ void on_copy_clicked();
+
private:
Ui::PipelineTable* ui;
+ QAbstractItemModel* m_model = nullptr;
};
#endif // PIPELINETABLE_H

MODIFY
src/pipelinetable.ui
src/pipelinetable.ui
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QToolButton" name="save">
+ <property name="toolTip">
+ <string>Save image of currently viewable part of table</string>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="icon">
+ <iconset resource="../resources/images.qrc">
+ <normaloff>:/icons/save.svg</normaloff>:/icons/save.svg</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="copy">
+ <property name="toolTip">
+ <string>Copy table to clipboard (tab sepearated)</string>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="icon">
+ <iconset resource="../resources/images.qrc">
+ <normaloff>:/icons/documents.svg</normaloff>:/icons/documents.svg</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="autoRaise">
+ <bool>false</bool>
+ </property>
+ <property name="arrowType">
+ <enum>Qt::NoArrow</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
<item>
<widget class="QTableView" name="table"/>
</item>

MODIFY
src/processortab.cpp
src/processortab.cpp
#include <QScrollBar>
#include "instructionmodel.h"
#include "pipelinewidget.h"
-#include "ui_pipelinetable.h"
#include "ui_processortab.h"
#include <QFileDialog>

Add copy functionality to PipelineTable

Chosen format is tab-separated, suitable for spreadsheet editors.