Incidenceeditor

ktimezonecombobox.h
1/*
2 SPDX-FileCopyrightText: 2007 Bruno Virlet <bruno.virlet@gmail.com>
3 SPDX-FileCopyrightText: 2008-2009 Allen Winter <winter@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
6*/
7
8#pragma once
9
10#include "incidenceeditor_export.h"
11
12#include <QComboBox>
13#include <QTimeZone>
14
15#include <memory>
16
17namespace IncidenceEditorNG
18{
19class KTimeZoneComboBoxPrivate;
20
21/**
22 * A combobox that shows the system timezones available in QTimeZone
23 * and provides methods to easily select the item corresponding to a given
24 * QTimeZone or to retrieve the QTimeZone associated with the
25 * selected item.
26 */
27class INCIDENCEEDITOR_EXPORT KTimeZoneComboBox : public QComboBox
28{
29 Q_OBJECT
30public:
31 /**
32 * Creates a new time zone combobox.
33 *
34 * @param parent The parent widget.
35 */
36 explicit KTimeZoneComboBox(QWidget *parent = nullptr);
37
38 /**
39 * Destroys the time zone combobox.
40 */
42
43 /**
44 * Selects the item in the combobox corresponding to the given @p zone.
45 */
46 void selectTimeZone(const QTimeZone &zone);
47
48 /**
49 * Selects the item in the combobox corresponding to the zone for the given @p datetime.
50 */
51 void selectTimeZoneFor(const QDateTime &dateTime);
52
53 /**
54 * Convenience version of selectTimeZone(const QTimeZone &).
55 * Selects the local time zone specified in the user settings.
56 */
57 void selectLocalTimeZone();
58
59 /**
60 * If @p floating is true, selects floating time zone, otherwise
61 * if @zone is valid, selects @pzone time zone, if not selects
62 * local time zone.
63 */
64 void setFloating(bool floating, const QTimeZone &zone = {});
65
66 /**
67 * Applies the selected timezone to the given QDateTime
68 * This isn't the same as dt.setTimeZone(selectedTimeZone) because
69 * of the "floating" special case.
70 */
71 void applyTimeZoneTo(QDateTime &dt) const;
72
73 /**
74 * Return the time zone associated with the currently selected item.
75 */
76 [[nodiscard]] QTimeZone selectedTimeZone() const;
77
78 /**
79 * Returns true if the selecting timezone is the floating time zone
80 */
81 [[nodiscard]] bool isFloating() const;
82
83private:
84 //@cond PRIVATE
85 std::unique_ptr<KTimeZoneComboBoxPrivate> const d;
86 //@endcond
87};
88}
A combobox that shows the system timezones available in QTimeZone and provides methods to easily sele...
~KTimeZoneComboBox() override
Destroys the time zone combobox.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:37 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.