File indexing completed on 2024-12-22 05:00:50

0001 
0002 #include <QTime>
0003 /*
0004    SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
0005 
0006    SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 #include "hourcombobox.h"
0009 
0010 HourComboBox::HourComboBox(QWidget *parent)
0011     : QComboBox(parent)
0012 {
0013     initializeList();
0014 }
0015 
0016 HourComboBox::~HourComboBox() = default;
0017 
0018 void HourComboBox::initializeList()
0019 {
0020     for (int i = 0; i < 24; ++i) {
0021         addItem(QTime(i, 0, 0).toString(), i);
0022     }
0023 }
0024 
0025 void HourComboBox::setHour(int hour)
0026 {
0027     const int index = findData(hour);
0028     if (index != -1) {
0029         setCurrentIndex(index);
0030     }
0031 }
0032 
0033 int HourComboBox::hour() const
0034 {
0035     return currentData().toInt();
0036 }
0037 
0038 #include "moc_hourcombobox.cpp"