1 | // %flair:license{
|
---|
2 | // This file is part of the Flair framework distributed under the
|
---|
3 | // CECILL-C License, Version 1.0.
|
---|
4 | // %flair:license}
|
---|
5 | /*!
|
---|
6 | * \file ListWidget.h
|
---|
7 | * \brief Class displaying a QListWidget on the ground station
|
---|
8 | * \author Thomas Fuhrmann, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
9 | * \date 2016/07/26
|
---|
10 | * \version 1.0
|
---|
11 | */
|
---|
12 | #ifndef LISTWIDGET_H
|
---|
13 | #define LISTWIDGET_H
|
---|
14 |
|
---|
15 | #include "FormLayout.h"
|
---|
16 |
|
---|
17 | class QListWidget;
|
---|
18 | class Layout;
|
---|
19 | class QStringList;
|
---|
20 | class QListWidgetItem;
|
---|
21 | class QPalette;
|
---|
22 | class QStringList;
|
---|
23 |
|
---|
24 | /*! \class ListWidget
|
---|
25 | *
|
---|
26 | * \brief Class displaying a QListWidget on the ground station
|
---|
27 | *
|
---|
28 | */
|
---|
29 | class ListWidget : public FormLayout {
|
---|
30 | Q_OBJECT
|
---|
31 |
|
---|
32 | public:
|
---|
33 | /**
|
---|
34 | * \brief Default constructor
|
---|
35 | *
|
---|
36 | * \param parent The parent widget
|
---|
37 | * \param[in] row The row where to position the widget
|
---|
38 | * \param[in] col The col where to position the widget
|
---|
39 | * \param[in] name The name of the widget
|
---|
40 | */
|
---|
41 | ListWidget(Layout *parent, int row, int col, QString name);
|
---|
42 | /**
|
---|
43 | * \brief Constructor with a list of default items
|
---|
44 | *
|
---|
45 | * \param parent The parent widget
|
---|
46 | * \param[in] row The row where to position the widget
|
---|
47 | * \param[in] col The col where to position the widget
|
---|
48 | * \param[in] name The name of the widget
|
---|
49 | * \param items List of items to display at creation
|
---|
50 | */
|
---|
51 | ListWidget(Layout *parent, int row, int col, QString name,
|
---|
52 | QStringList &items);
|
---|
53 | /**
|
---|
54 | * \brief Destructor
|
---|
55 | */
|
---|
56 | ~ListWidget();
|
---|
57 |
|
---|
58 | private:
|
---|
59 | /**
|
---|
60 | * \brief Check if the widget is up to date.
|
---|
61 | *
|
---|
62 | * \return True if uptodate, False otherwise.
|
---|
63 | */
|
---|
64 | bool IsUptodate(void);
|
---|
65 | /**
|
---|
66 | * \brief Sets the isUpToDate internal flag.
|
---|
67 | */
|
---|
68 | void SetUptodate(void);
|
---|
69 | /**
|
---|
70 | * \brief Handler to process a new xml file.
|
---|
71 | *
|
---|
72 | * \param[in] dom The dom containing the xml file.
|
---|
73 | */
|
---|
74 | void XmlEvent(QDomElement dom);
|
---|
75 | /**
|
---|
76 | * \brief Reset the widget, load the internal parameters.
|
---|
77 | */
|
---|
78 |
|
---|
79 | void Reset(void);
|
---|
80 | /**
|
---|
81 | * \brief Handler to process the loading of the internal xml file.
|
---|
82 | *
|
---|
83 | * \param[in] dom The dom containing the xml file.
|
---|
84 | */
|
---|
85 | void LoadEvent(QDomElement dom);
|
---|
86 | /**
|
---|
87 | * \brief Save the user interface variables state in the internal members.
|
---|
88 | */
|
---|
89 | void ui_to_var(void);
|
---|
90 | /**
|
---|
91 | * \brief Save the user interface variables state in the internal xml file.
|
---|
92 | */
|
---|
93 | void ui_to_xml(void);
|
---|
94 | /**
|
---|
95 | * \brief Removes the row_to_del element from the internal xml file.
|
---|
96 | *
|
---|
97 | * As the order of the elements is important, all the elements after the one
|
---|
98 | * deleted are shifted to occupy the blank space.
|
---|
99 | *
|
---|
100 | * \param[in] row_to_del The row of the element to delete.
|
---|
101 | */
|
---|
102 | void RemoveItemFromXml(int row_to_del);
|
---|
103 | /**
|
---|
104 | * Pointer to the managed QListWidget widget.
|
---|
105 | */
|
---|
106 | QListWidget *listwidget;
|
---|
107 | /**
|
---|
108 | * Store the list of all the items, in order to use the Reset function.
|
---|
109 | */
|
---|
110 | QStringList *internalItemsList;
|
---|
111 | /**
|
---|
112 | * The row of the currently selected item.
|
---|
113 | */
|
---|
114 | int currentItemRow;
|
---|
115 | /**
|
---|
116 | * Flag to know if the widget is up to date.
|
---|
117 | */
|
---|
118 | bool isUpToDate;
|
---|
119 | /**
|
---|
120 | * Redefined color palette.
|
---|
121 | * The highlight item's text appears in red.
|
---|
122 | */
|
---|
123 | QPalette palListRed;
|
---|
124 | /**
|
---|
125 | * Redefined color palette.
|
---|
126 | * The highlight item's text appears in white (default).
|
---|
127 | */
|
---|
128 | QPalette palListDefault;
|
---|
129 |
|
---|
130 | private slots:
|
---|
131 | /**
|
---|
132 | * \brief Handle the change of the selected item.
|
---|
133 | *
|
---|
134 | * When the selected item has changed, the text of the newly selected item appears in red,
|
---|
135 | * to notify the user to apply the modification.
|
---|
136 | *
|
---|
137 | * \param[in] current_row The row of the currently selected item.
|
---|
138 | */
|
---|
139 | void SelectedItemChanged(int current_row);
|
---|
140 | };
|
---|
141 |
|
---|
142 | #endif // LISTWIDGET_H
|
---|