dialog_with_itemlist.h
Go to the documentation of this file.
00001 #ifndef DIALOG_WITH_ITEMLIST_H
00002 #define DIALOG_WITH_ITEMLIST_H
00003 
00004 #include <QDialog>
00005 #include <QLabel>
00006 #include <QListWidget>
00007 #include <QAbstractButton>
00008 #include <unordered_set>
00009 
00010 #include "ui_dialog_with_itemlist.h"
00011 
00012 namespace Ui {
00013 class DialogWithItemList;
00014 }
00015 
00016 class DialogWithItemList : public QDialog
00017 {
00018     Q_OBJECT
00019 private:
00020     Ui::DialogWithItemList *ui;
00021 
00022 public:
00023     explicit DialogWithItemList(QWidget *parent, QString title, QString text,
00024                                 std::unordered_set<std::string> list) :
00025         QDialog(parent),
00026         ui(new Ui::DialogWithItemList)
00027     {
00028         QStringList name_list;
00029         for(auto& name: list)
00030         {
00031             name_list.push_back( name.c_str() );
00032         }
00033 
00034         ui->setupUi(this);
00035         this->setWindowTitle(title);
00036         ui->label->setText(text);
00037         ui->listWidget->addItems(name_list);
00038         ui->listWidget->sortItems();
00039     }
00040     ~DialogWithItemList()
00041     {
00042         delete ui;
00043     }
00044 
00045     static void warning(const QString& message, std::unordered_set<std::string> list)
00046     {
00047       auto dialog = new DialogWithItemList(0, tr("Warning"), message, list );
00048       dialog->exec();
00049       dialog->deleteLater();
00050     }
00051 
00052 private slots:
00053     void on_buttonBox_clicked(QAbstractButton *button)
00054     {
00055         this->close();
00056     }
00057 };
00058 
00059 #endif // DIALOG_WITH_ITEMLIST_H


plotjuggler
Author(s): Davide Faconti
autogenerated on Wed Jul 3 2019 19:28:04