digiKam
ddatetable.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 1997-04-21
7  * Description : Date selection table.
8  *
9  * Copyright (C) 2011-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 1997 by Tim D. Gilman <tdgilman at best dot org>
11  * Copyright (C) 1998-2001 by Mirko Boehm <mirko at kde dot org>
12  * Copyright (C) 2007 by John Layt <john at layt dot net>
13  *
14  * This program is free software; you can redistribute it
15  * and/or modify it under the terms of the GNU General
16  * Public License as published by the Free Software Foundation;
17  * either version 2, or (at your option)
18  * any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * ============================================================ */
26 
27 #ifndef DIGIKAM_DDATE_TABLE_H
28 #define DIGIKAM_DDATE_TABLE_H
29 
30 // Qt includes
31 
32 #include <QLineEdit>
33 #include <QDateTime>
34 
35 class QMenu;
36 
37 namespace Digikam
38 {
39 
49 class DDateTable : public QWidget
50 {
51  Q_OBJECT
52  Q_PROPERTY(QDate date READ date WRITE setDate)
53  Q_PROPERTY(bool popupMenu READ popupMenuEnabled WRITE setPopupMenuEnabled)
54 
55 public:
56 
58  {
59  NoBgMode = 0,
62  };
63 
64 public:
65 
66  explicit DDateTable(QWidget* const parent = nullptr);
67  explicit DDateTable(const QDate& dt, QWidget* const parent = nullptr);
68  ~DDateTable() override;
69 
77  QSize sizeHint() const override;
78 
82  void setFontSize(int size);
83 
87  bool setDate(const QDate& date);
88 
92  const QDate& date() const;
93 
100  void setPopupMenuEnabled(bool enable);
101 
105  bool popupMenuEnabled() const;
106 
111  void setCustomDatePainting(const QDate& date, const QColor& fgColor,
112  BackgroundMode bgMode = NoBgMode,
113  const QColor& bgColor = QColor());
114 
118  void unsetCustomDatePainting(const QDate& dt);
119 
120 protected:
121 
126  virtual int posFromDate(const QDate& dt);
127 
132  virtual QDate dateFromPos(int pos);
133 
134  void paintEvent(QPaintEvent* e) override;
135 
139  void mousePressEvent(QMouseEvent* e) override;
140  void wheelEvent(QWheelEvent* e) override;
141  void keyPressEvent(QKeyEvent* e) override;
142  void focusInEvent(QFocusEvent* e) override;
143  void focusOutEvent(QFocusEvent* e) override;
144 
148  bool event(QEvent* e) override;
149 
150 Q_SIGNALS:
151 
155  void dateChanged(const QDate& date);
156 
163  void dateChanged(const QDate& cur, const QDate& old);
164 
168  void tableClicked();
169 
175  void aboutToShowContextMenu(QMenu* menu, const QDate& dt);
176 
177 private:
178 
179  void initWidget(const QDate& dt);
180  void initAccels();
181  void paintCell(QPainter* painter, int row, int col);
182 
183 private:
184 
185  class Private;
186  Private* const d;
187 
188  friend class Private;
189 
190  Q_DISABLE_COPY(DDateTable)
191 };
192 
193 } // namespace Digikam
194 
195 #endif // DIGIKAM_DDATE_TABLE_H
Definition: ddatetable_p.h:48
Definition: ddatetable.h:50
void setFontSize(int size)
Definition: ddatetable.cpp:539
void focusInEvent(QFocusEvent *e) override
Definition: ddatetable.cpp:736
void setCustomDatePainting(const QDate &date, const QColor &fgColor, BackgroundMode bgMode=NoBgMode, const QColor &bgColor=QColor())
Definition: ddatetable.cpp:773
~DDateTable() override
Definition: ddatetable.cpp:65
bool popupMenu
Definition: ddatetable.h:53
virtual int posFromDate(const QDate &dt)
Definition: ddatetable.cpp:135
void focusOutEvent(QFocusEvent *e) override
Definition: ddatetable.cpp:741
virtual QDate dateFromPos(int pos)
Definition: ddatetable.cpp:151
DDateTable(QWidget *const parent=nullptr)
Definition: ddatetable.cpp:58
bool event(QEvent *e) override
Definition: ddatetable.cpp:573
void paintEvent(QPaintEvent *e) override
Definition: ddatetable.cpp:166
QDate date
Definition: ddatetable.h:52
void unsetCustomDatePainting(const QDate &dt)
Definition: ddatetable.cpp:792
void dateChanged(const QDate &date)
BackgroundMode
Definition: ddatetable.h:58
@ RectangleMode
Definition: ddatetable.h:60
@ NoBgMode
Definition: ddatetable.h:59
@ CircleMode
Definition: ddatetable.h:61
void setPopupMenuEnabled(bool enable)
Definition: ddatetable.cpp:763
void wheelEvent(QWheelEvent *e) override
Definition: ddatetable.cpp:567
void mousePressEvent(QMouseEvent *e) override
Definition: ddatetable.cpp:635
bool setDate(const QDate &date)
Definition: ddatetable.cpp:708
void keyPressEvent(QKeyEvent *e) override
Definition: ddatetable.cpp:450
bool popupMenuEnabled() const
Definition: ddatetable.cpp:768
QSize sizeHint() const override
Definition: ddatetable.cpp:746
void dateChanged(const QDate &cur, const QDate &old)
void aboutToShowContextMenu(QMenu *menu, const QDate &dt)
Definition: datefolderview.cpp:43