1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#include <QApplication>
#include <QtWidgets>
class TimeSlot : public QWidget{
Q_OBJECT
public:
TimeSlot(int hour);
/* parce qu'il faudra bien sauvegarder les informations :D */
void save();
private:
QSpinBox * temperature;
QSpinBox * humidity;
QSpinBox * luminosity;
};
TimeSlot::TimeSlot(int hour){
QLabel * label = new QLabel(QString::number(hour));
temperature = new QSpinBox;
humidity = new QSpinBox;
luminosity = new QSpinBox;
QHBoxLayout * layout = new QHBoxLayout;
layout->addWidget(label);
layout->addWidget(temperature);
layout->addWidget(luminosity);
setLayout(layout);
}
void TimeSlot::save(){
/* ce qu'il faudra faire ici */
}
class ColumnHeaders : public QWidget{
Q_OBJECT
public:
ColumnHeaders();
};
ColumnHeaders::ColumnHeaders(){
QLabel * hour = new QLabel(tr("Heure :"));
QLabel * temperature = new QLabel(tr("Température °"));
QLabel * humidity = new QLabel(tr("Humidité %"));
QLabel * luminosity = new QLabel(tr("Luminosité %"));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(humidity);
layout->addWidget(temperature);
layout->addWidget(luminosity);
setLayout(layout);
}
class Planning : public QWidget{
Q_OBJECT
public:
Planning();
/* parce que l'on veut pouvoir sauvegarder le planning entier */
void save();
private:
/* parce que pour sauvegarder le planning, il faut pouvoir accéder à
* toutes les plages horraires
*/
QList<TimeSlot * > allSlots;
};
Planning::Planning(){
QVBoxLayout * layout = new QVBoxLayout;
/* d'abord, les en-têtes */
ColumnHeaders * headers = new ColumnHeaders;
layout->addWidget(headers);
/* ensuite, les 24 plages horaires */
for(int i = 0; i<24; ++i){
TimeSlot * temp = new TimeSlot(i);
layout->addWidget(temp);
allSlots.append(temp);
}
setLayout(layout);
}
void Planning::save(){
for(auto *it : allSlots)
it->save;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Planning w;
w.show();
return a.exec();
} |
Partager