119 lines
1.6 KiB
C++
119 lines
1.6 KiB
C++
#ifndef STATEGROUP_H
|
|
#define STATEGROUP_H
|
|
|
|
#include <QWidget>
|
|
#include "StateWidget.h"
|
|
#include "QGroupBox"
|
|
#include "QGridLayout"
|
|
|
|
class StateGroup : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit StateGroup(int index, QWidget *parent = nullptr);
|
|
|
|
~StateGroup();
|
|
|
|
int id;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setID(int value)
|
|
{
|
|
id = value;
|
|
}
|
|
|
|
int ID(void)
|
|
{
|
|
return id;
|
|
}
|
|
|
|
QMap<int,StateWidget *> Items(void)
|
|
{
|
|
return ItemList;
|
|
}
|
|
|
|
void addItem(StateWidget * w);
|
|
void addItems(QMap<int,StateWidget *> list);
|
|
|
|
void removeItem(int index);
|
|
void removeItem(StateWidget * w);
|
|
|
|
StateWidget *Item(int key)
|
|
{
|
|
StateWidget *w = nullptr;
|
|
|
|
if(ItemList.contains(key))
|
|
{
|
|
w = ItemList.value(key);
|
|
}
|
|
|
|
return w;
|
|
}
|
|
|
|
StateWidget *Item(QString name)
|
|
{
|
|
StateWidget *w = nullptr;
|
|
|
|
foreach (StateWidget *i, ItemList) {
|
|
if(i->Name() == name){
|
|
w = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return w;
|
|
}
|
|
|
|
|
|
void setValue(int index, QString value);
|
|
void setColor(int index,StateWidget::state s);
|
|
|
|
|
|
int count(void)
|
|
{
|
|
return ItemList.size();
|
|
}
|
|
|
|
|
|
int lenght(void)
|
|
{
|
|
return m_lenght;
|
|
}
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void updateUI(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QMap<int,StateWidget *> ItemList;
|
|
|
|
QString title;
|
|
|
|
|
|
QGroupBox *box = nullptr;
|
|
|
|
QGridLayout *toplayout = nullptr;
|
|
QGridLayout *layout = nullptr;
|
|
|
|
|
|
int m_lenght = 0;
|
|
|
|
};
|
|
|
|
#endif // STATEGROUP_H
|