File indexing completed on 2024-04-28 05:11:37

0001 /*
0002     SPDX-FileCopyrightText: 2010 Casey Link <unnamedrambler@gmail.com>
0003     SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org>
0004     SPDX-FileCopyrightText: 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include <Libkdepim/KCheckComboBox>
0012 
0013 #include <QBitArray>
0014 #include <QDate>
0015 
0016 namespace IncidenceEditorNG
0017 {
0018 // FIXME: This class assumes all weeks have 7 days. We should use KCalenderSystem instead.
0019 /**
0020  * A combobox that is populated with the days of the week from the current
0021  * KCalenderSystem. The days are checkable.
0022  * @note: KCalenderSystem numbers weekdays starting with 1, however this widget is 0 indexed and handles the conversion to the 1 based system internally. Use
0023  * this widget as a normal 0 indexed container.
0024  * @see KCalenderSystem
0025  */
0026 class KWeekdayCheckCombo : public KPIM::KCheckComboBox
0027 {
0028     Q_OBJECT
0029 public:
0030     /**
0031      * @param first5Checked if true the first 5 weekdays will be checked by default
0032      */
0033     explicit KWeekdayCheckCombo(QWidget *parent = nullptr, bool first5Checked = false);
0034     ~KWeekdayCheckCombo() override;
0035 
0036     /**
0037      * Retrieve the checked days
0038      * @param days a 7 bit array indicating the checked days (bit 0 = Monday, value 1 = checked).
0039      */
0040     [[nodiscard]] QBitArray days() const;
0041 
0042     /**
0043      * Set the checked days on this combobox
0044      * @param days a 7 bit array indicating the days to check/uncheck (bit 0 = Monday, value 1 = check).
0045      * @param disableDays if not empty, the corresponding days will be disabled, all others enabled (bit 0 = Monday, value 1 = disable).
0046      * @see days()
0047      */
0048     void setDays(const QBitArray &days, const QBitArray &disableDays = QBitArray());
0049 
0050     /**
0051      * Returns the index of the weekday represented by the
0052      * QDate object.
0053      */
0054     int weekdayIndex(const QDate &date) const;
0055 };
0056 }