mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 14:15:42 +00:00
Select rows at once in perf viewer, and add copy-paste handler
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "RDTableWidget.h"
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QDropEvent>
|
||||
|
||||
RDTableWidget::RDTableWidget(QWidget *parent) : QTableWidget(parent)
|
||||
@@ -81,6 +83,36 @@ void RDTableWidget::dropEvent(QDropEvent *event)
|
||||
|
||||
void RDTableWidget::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
QTableView::keyPressEvent(e);
|
||||
if(!m_customCopyPaste && e->matches(QKeySequence::Copy))
|
||||
{
|
||||
QList<QTableWidgetItem *> items = selectedItems();
|
||||
|
||||
std::sort(items.begin(), items.end(), [this](QTableWidgetItem *a, QTableWidgetItem *b) {
|
||||
if(row(a) != row(b))
|
||||
return row(a) < row(b);
|
||||
return column(a) < column(b);
|
||||
});
|
||||
|
||||
int prevRow = row(items[0]);
|
||||
|
||||
QString clipboardText;
|
||||
for(QTableWidgetItem *i : items)
|
||||
{
|
||||
clipboardText += i->text();
|
||||
|
||||
if(prevRow != row(i))
|
||||
clipboardText += lit("\n");
|
||||
else
|
||||
clipboardText += lit(" | ");
|
||||
}
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(clipboardText.trimmed());
|
||||
}
|
||||
else
|
||||
{
|
||||
QTableView::keyPressEvent(e);
|
||||
}
|
||||
|
||||
emit(keyPress(e));
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ class RDTableWidget : public QTableWidget
|
||||
public:
|
||||
explicit RDTableWidget(QWidget *parent = 0);
|
||||
|
||||
bool customCopyPasteHandler() { return m_customCopyPaste; }
|
||||
void setCustomCopyPasteHandler(bool custom) { m_customCopyPaste = custom; }
|
||||
signals:
|
||||
void keyPress(QKeyEvent *e);
|
||||
|
||||
@@ -39,4 +41,6 @@ private:
|
||||
// implement reordering row drag-drop behaviour
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
bool m_customCopyPaste = false;
|
||||
};
|
||||
|
||||
@@ -72,10 +72,13 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="counterResults">
|
||||
<widget class="RDTableWidget" name="counterResults">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
@@ -83,6 +86,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>RDTableWidget</class>
|
||||
<extends>QTableWidget</extends>
|
||||
<header>Widgets/Extended/RDTableWidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user