File indexing completed on 2025-02-16 04:47:53

0001 /*
0002   SPDX-FileCopyrightText: 2007 Bruno Virlet <bruno@virlet.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0005 */
0006 #pragma once
0007 
0008 #include <QWidget>
0009 
0010 class QHBoxLayout;
0011 class QScrollArea;
0012 class QTimeZone;
0013 
0014 namespace EventViews
0015 {
0016 class Agenda;
0017 class AgendaView;
0018 
0019 class Prefs;
0020 using PrefsPtr = QSharedPointer<Prefs>;
0021 
0022 class TimeLabelsZone : public QWidget
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit TimeLabelsZone(QWidget *parent, const PrefsPtr &preferences, Agenda *agenda = nullptr);
0027 
0028     /** Add a new time label with the given time zone.
0029         If @p zone is not valid, use the display time zone.
0030     */
0031     void addTimeLabels(const QTimeZone &zone);
0032 
0033     /**
0034        Returns the best width for each TimeLabels widget
0035     */
0036     [[nodiscard]] int preferedTimeLabelsWidth() const;
0037 
0038     void updateAll();
0039     void reset();
0040     void init();
0041     void setAgendaView(AgendaView *agenda);
0042 
0043     [[nodiscard]] QList<QScrollArea *> timeLabels() const;
0044 
0045     void setPreferences(const PrefsPtr &prefs);
0046     [[nodiscard]] PrefsPtr preferences() const;
0047 
0048     /** Checks how much agenda is scrolled relative to it's QScrollArea
0049         and makes each TimeLabels scroll that amount
0050     */
0051     void updateTimeLabelsPosition();
0052 
0053 private:
0054     void setupTimeLabel(QScrollArea *area);
0055     Agenda *mAgenda = nullptr;
0056     PrefsPtr mPrefs;
0057     AgendaView *mParent = nullptr;
0058 
0059     QHBoxLayout *mTimeLabelsLayout = nullptr;
0060     QList<QScrollArea *> mTimeLabelsList;
0061 };
0062 }