forked from facontidavide/PlotJuggler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremovecurvedialog.cpp
74 lines (67 loc) · 1.88 KB
/
removecurvedialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "removecurvedialog.h"
#include "ui_removecurvedialog.h"
#include <QDebug>
#include "plotwidget.h"
RemoveCurveDialog::RemoveCurveDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::RemoveCurveDialog)
{
ui->setupUi(this);
}
RemoveCurveDialog::~RemoveCurveDialog()
{
delete ui;
}
void RemoveCurveDialog::addCurveName(const QString &name)
{
ui->listCurveWidget->addItem( new QListWidgetItem( name ) );
}
void RemoveCurveDialog::on_listCurveWidget_itemClicked(QListWidgetItem *item)
{
QFont f = item->font();
f.setStrikeOut( !f.strikeOut() );
item->setFont( f );
qDebug() << "on_listWidget_itemClicked";
item->font().setStrikeOut( true );
}
void RemoveCurveDialog::on_pushButtonRemove_pressed()
{
PlotWidget* parent = dynamic_cast<PlotWidget*>( this->parentWidget() );
if( parent ) // this should always be true...
{
for(int index = 0; index <ui->listCurveWidget->count(); ++index)
{
QListWidgetItem* item = ui->listCurveWidget->item( index );
if( item->font().strikeOut() && item->isHidden() == false)
{
parent->removeCurve( item->text() );
item->setHidden( true );
}
}
}
closeIfEmpty();
}
void RemoveCurveDialog::on_pushButtonSelectAll_pressed()
{
for(int index = 0; index <ui->listCurveWidget->count(); ++index)
{
QListWidgetItem* item = ui->listCurveWidget->item( index );
QFont f = item->font();
f.setStrikeOut( true );
item->setFont( f );
}
}
void RemoveCurveDialog::closeIfEmpty()
{
bool isEmpty = true;
for(int index = 0; index <ui->listCurveWidget->count(); ++index)
{
QListWidgetItem* item = ui->listCurveWidget->item( index );
if( item->isHidden() == false)
{
isEmpty = false;
break;
}
}
if( isEmpty ) this->accept();
}