shortcut for creating linked markers for all traces
This commit is contained in:
parent
b2d3c407fc
commit
8246e80d69
@ -5,6 +5,7 @@
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
|
||||
MarkerWidget::MarkerWidget(MarkerModel &model, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@ -12,6 +13,16 @@ MarkerWidget::MarkerWidget(MarkerModel &model, QWidget *parent) :
|
||||
model(model)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// some image magic to create a button with three "add" icons (not available as standard icon)
|
||||
QImage image(44, 44, QImage::Format_ARGB32);
|
||||
auto origImage = ui->bAddAll->icon().pixmap(22).toImage().convertToFormat(QImage::Format_ARGB32);
|
||||
QPainter painter(&image);
|
||||
painter.drawImage(0, 0, origImage);
|
||||
painter.drawImage(origImage.width(), 0, origImage);
|
||||
painter.drawImage(origImage.width()/2, origImage.height(), origImage);
|
||||
ui->bAddAll->setIcon(QIcon(QPixmap::fromImage(image)));
|
||||
|
||||
ui->treeView->setModel(&model);
|
||||
ui->treeView->setItemDelegateForColumn(MarkerModel::ColIndexTrace, new MarkerTraceDelegate);
|
||||
ui->treeView->setItemDelegateForColumn(MarkerModel::ColIndexType, new MarkerTypeDelegate);
|
||||
@ -123,6 +134,18 @@ void MarkerWidget::on_bAdd_clicked()
|
||||
model.addMarker(marker);
|
||||
}
|
||||
|
||||
void MarkerWidget::on_bAddAll_clicked()
|
||||
{
|
||||
// add a marker for every trace and link them
|
||||
auto group = model.createMarkerGroup();
|
||||
for(auto trace : model.getModel().getTraces()) {
|
||||
auto m = model.createDefaultMarker();
|
||||
m->assignTrace(trace);
|
||||
group->add(m);
|
||||
model.addMarker(m);
|
||||
}
|
||||
}
|
||||
|
||||
bool MarkerWidget::eventFilter(QObject *, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
@ -152,4 +175,3 @@ void MarkerWidget::updatePersistentEditors()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ private slots:
|
||||
void on_bAdd_clicked();
|
||||
void updatePersistentEditors();
|
||||
|
||||
void on_bAddAll_clicked();
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
Ui::MarkerWidget *ui;
|
||||
|
@ -44,7 +44,27 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add</string>
|
||||
<string>Add marker</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="list-add" resource="../../icons.qrc">
|
||||
<normaloff>:/icons/add.png</normaloff>:/icons/add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="bAddAll">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add markers to all traces</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
@ -64,7 +84,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete</string>
|
||||
<string>Delete marker</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
Loading…
Reference in New Issue
Block a user