removecurvedialog.cpp
Go to the documentation of this file.
00001 #include "removecurvedialog.h"
00002 #include "ui_removecurvedialog.h"
00003 #include <QDebug>
00004 #include "plotwidget.h"
00005 
00006 RemoveCurveDialog::RemoveCurveDialog(QWidget *parent) :
00007     QDialog(parent),
00008     ui(new Ui::RemoveCurveDialog)
00009 {
00010     ui->setupUi(this);
00011 }
00012 
00013 RemoveCurveDialog::~RemoveCurveDialog()
00014 {
00015     delete ui;
00016 }
00017 
00018 void RemoveCurveDialog::addCurveName(const QString &name)
00019 {
00020     ui->listCurveWidget->addItem( new QListWidgetItem( name ) );
00021 }
00022 
00023 void RemoveCurveDialog::on_listCurveWidget_itemClicked(QListWidgetItem *item)
00024 {
00025     QFont f = item->font();
00026     f.setStrikeOut( !f.strikeOut() );
00027     item->setFont( f );
00028     qDebug() << "on_listWidget_itemClicked";
00029     item->font().setStrikeOut( true );
00030 }
00031 
00032 void RemoveCurveDialog::on_pushButtonRemove_pressed()
00033 {
00034     PlotWidget* parent = dynamic_cast<PlotWidget*>( this->parentWidget() );
00035     if( parent ) // this should always be true...
00036     {
00037         for(int index = 0; index <ui->listCurveWidget->count(); ++index)
00038         {
00039             QListWidgetItem* item = ui->listCurveWidget->item( index );
00040             if( item->font().strikeOut() && item->isHidden() == false)
00041             {
00042                 parent->removeCurve( item->text() );
00043                 item->setHidden( true );
00044             }
00045         }
00046     }
00047     closeIfEmpty();
00048 }
00049 
00050 void RemoveCurveDialog::on_pushButtonSelectAll_pressed()
00051 {
00052     for(int index = 0; index <ui->listCurveWidget->count(); ++index)
00053     {
00054         QListWidgetItem* item = ui->listCurveWidget->item( index );
00055         QFont f = item->font();
00056         f.setStrikeOut( true );
00057         item->setFont( f );
00058     }
00059 }
00060 
00061 void RemoveCurveDialog::closeIfEmpty()
00062 {
00063     bool isEmpty = true;
00064     for(int index = 0; index <ui->listCurveWidget->count(); ++index)
00065     {
00066         QListWidgetItem* item = ui->listCurveWidget->item( index );
00067         if( item->isHidden() == false)
00068         {
00069             isEmpty = false;
00070             break;
00071         }
00072     }
00073     if( isEmpty ) this->accept();
00074 }


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:57