Go to the documentation of this file.00001 #ifndef _RQT_MRTA_ROBOTS_TREE_WIDGET_H_
00002 #define _RQT_MRTA_ROBOTS_TREE_WIDGET_H_
00003
00004 #include <QList>
00005 #include <QTreeWidget>
00006
00007 namespace rqt_mrta
00008 {
00009 namespace config
00010 {
00011 namespace application
00012 {
00013 class Robots;
00014 class Robot;
00015 class Tasks;
00016 class Task;
00017 }
00018 }
00019
00020 typedef config::application::Robots RobotsConfig;
00021 typedef config::application::Robot RobotConfig;
00022 typedef config::application::Tasks TasksConfig;
00023 typedef config::application::Task TaskConfig;
00024
00025 class RobotTreeWidget : public QTreeWidget
00026 {
00027 Q_OBJECT
00028 public:
00029 enum Type
00030 {
00031 None,
00032 Robot,
00033 Task
00034 };
00035 RobotTreeWidget(QWidget* parent = NULL);
00036 virtual ~RobotTreeWidget();
00037 RobotsConfig* getConfig() const;
00038 void setConfig(RobotsConfig* config);
00039 QStringList getTasks() const;
00040 QString getCurrentId() const;
00041 void setCurrentId(const QString& id);
00042 void addRobot();
00043 void addTask();
00044 QString validate() const;
00045 void clear();
00046
00047 signals:
00048 void changed();
00049 void robotAdded(const QString& robot_id);
00050 void taskAdded(const QString& task_id);
00051 void robotSelected(const QString& robot_id);
00052 void taskSelected(const QString& task_id);
00053 void selected(Type type, const QString& id);
00054
00055 private:
00056 RobotsConfig* config_;
00057 union Selection
00058 {
00059 RobotConfig* robot_;
00060 TaskConfig* task_;
00061 };
00062 Type current_type_;
00063 Selection current_;
00064 void addRobot(RobotConfig* robot);
00065 void addTask(TaskConfig* task, QTreeWidgetItem* parent);
00066
00067 private slots:
00068 void currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
00069 void robotsConfigChanged();
00070 void configRobotIdChanged(size_t robot_index, const QString& robot_id);
00071 void configRobotAdded(size_t robot_index);
00072 void configRobotRemoved(const QString& robot_id);
00073 void configRobotsCleared();
00074 void configTaskIdChanged(size_t robot_index, size_t task_index,
00075 const QString& task_id);
00076 void configTaskAdded(size_t robot_index, size_t task_index);
00077 void configTaskRemoved(size_t robot_index, const QString& task_id);
00078 void configTasksCleared(size_t robot_index);
00079 };
00080 }
00081
00082 #endif // _RQT_MRTA_ROBOTS_TREE_WIDGET_H_