1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
/* ============================================================
 *
 * This file is a part of digiKam project
 * https://www.digikam.org
 *
 * Date        : 1997-04-21
 * Description : Date selection table.
 *
 * SPDX-FileCopyrightText: 2011-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
 * SPDX-FileCopyrightText: 1997      by Tim D. Gilman <tdgilman at best dot org>
 * SPDX-FileCopyrightText: 1998-2001 by Mirko Boehm <mirko at kde dot org>
 * SPDX-FileCopyrightText: 2007      by John Layt <john at layt dot net>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * ============================================================ */

#include "ddatetable_p.h"

// C++ includes

#include <cmath>

// Qt includes

#include <QAction>
#include <QFontDatabase>
#include <QPainter>
#include <QStyle>
#include <QStyleOptionViewItem>
#include <QActionEvent>
#include <QApplication>
#include <QMenu>

// Local includes

#include "digikam_debug.h"

namespace Digikam
{

DDateTable::DDateTable(const QDate& date, QWidget* const parent)
    : QWidget(parent),
      d      (new Private(this))
{
    initWidget(date);
}

DDateTable::DDateTable(QWidget* const parent)
    : QWidget(parent),
      d      (new Private(this))
{
    initWidget(QDate::currentDate());
}

DDateTable::~DDateTable()
{
    delete d;
}

void DDateTable::initWidget(const QDate& date)<--- Shadow argument
{
    d->numWeekRows = 7;

    setFontSize(10);
    setFocusPolicy(Qt::StrongFocus);
    setBackgroundRole(QPalette::Base);
    setAutoFillBackground(true);
    initAccels();
    setAttribute(Qt::WA_Hover, true);

    setDate(date);
}

void DDateTable::initAccels()
{
    QAction* const next = new QAction(this);
    next->setObjectName(QLatin1String("next"));
    next->setShortcuts(QKeySequence::keyBindings(QKeySequence::Forward));
    next->setShortcutContext(Qt::WidgetWithChildrenShortcut);

    connect(next, SIGNAL(triggered(bool)),
            d, SLOT(nextMonth()));

    QAction* const prior = new QAction(this);
    prior->setObjectName(QLatin1String("prior"));
    prior->setShortcuts(QKeySequence::keyBindings(QKeySequence::Back));
    prior->setShortcutContext(Qt::WidgetWithChildrenShortcut);

    connect(prior, SIGNAL(triggered(bool)),
            d, SLOT(previousMonth()));

    QAction* const beginMonth = new QAction(this);
    beginMonth->setObjectName(QLatin1String("beginMonth"));
    beginMonth->setShortcuts(QKeySequence::keyBindings(QKeySequence::MoveToStartOfDocument));
    beginMonth->setShortcutContext(Qt::WidgetWithChildrenShortcut);

    connect(beginMonth, SIGNAL(triggered(bool)),
            d, SLOT(beginningOfMonth()));

    QAction* const endMonth = new QAction(this);
    endMonth->setObjectName(QLatin1String("endMonth"));
    endMonth->setShortcuts(QKeySequence::keyBindings(QKeySequence::MoveToEndOfDocument));
    endMonth->setShortcutContext(Qt::WidgetWithChildrenShortcut);

    connect(endMonth, SIGNAL(triggered(bool)),
            d, SLOT(endOfMonth()));

    QAction* const beginWeek = new QAction(this);
    beginWeek->setObjectName(QLatin1String("beginWeek"));
    beginWeek->setShortcuts(QKeySequence::keyBindings(QKeySequence::MoveToStartOfLine));
    beginWeek->setShortcutContext(Qt::WidgetWithChildrenShortcut);

    connect(beginWeek, SIGNAL(triggered(bool)),
            d, SLOT(beginningOfWeek()));

    QAction* const endWeek = new QAction(this);
    endWeek->setObjectName(QLatin1String("endWeek"));
    endWeek->setShortcuts(QKeySequence::keyBindings(QKeySequence::MoveToEndOfLine));
    endWeek->setShortcutContext(Qt::WidgetWithChildrenShortcut);

    connect(endWeek, SIGNAL(triggered(bool)),
            d, SLOT(endOfWeek()));
}

int DDateTable::posFromDate(const QDate& date)<--- Shadow argument
{
    int initialPosition = date.day();
    int offset          = (d->weekDayFirstOfMonth - locale().firstDayOfWeek() + d->numDayColumns) % d->numDayColumns;

    // make sure at least one day of the previous month is visible.
    // adjust this < 1 if more days should be forced visible:

    if (offset < 1)
    {
        offset += d->numDayColumns;
    }

    return initialPosition + offset;
}

QDate DDateTable::dateFromPos(int position)
{
    int offset = (d->weekDayFirstOfMonth - locale().firstDayOfWeek() + d->numDayColumns) % d->numDayColumns;

    // make sure at least one day of the previous month is visible.
    // adjust this < 1 if more days should be forced visible:

    if (offset < 1)
    {
        offset += d->numDayColumns;
    }

    return QDate(d->date.year(), d->date.month(), 1).addDays(position - offset);
}

void DDateTable::paintEvent(QPaintEvent *e)
{
    QPainter p(this);
    const QRect& rectToUpdate = e->rect();
    double cellWidth          = width() / (double) d->numDayColumns;
    double cellHeight         = height() / (double) d->numWeekRows;
    int leftCol               = (int)std::floor(rectToUpdate.left() / cellWidth);
    int topRow                = (int)std::floor(rectToUpdate.top() / cellHeight);
    int rightCol              = (int)std::ceil(rectToUpdate.right() / cellWidth);
    int bottomRow             = (int)std::ceil(rectToUpdate.bottom() / cellHeight);
    bottomRow                 = qMin(bottomRow, d->numWeekRows - 1);
    rightCol                  = qMin(rightCol, d->numDayColumns - 1);

    if (layoutDirection() == Qt::RightToLeft)
    {
        p.translate((d->numDayColumns - leftCol - 1) * cellWidth, topRow * cellHeight);
    }
    else
    {
        p.translate(leftCol * cellWidth, topRow * cellHeight);
    }

    for (int i = leftCol ; i <= rightCol ; ++i)
    {
        for (int j = topRow ; j <= bottomRow ; ++j)
        {
            paintCell(&p, j, i);
            p.translate(0, cellHeight);
        }

        if (layoutDirection() == Qt::RightToLeft)
        {
            p.translate(-cellWidth, 0);
        }
        else
        {
            p.translate(cellWidth, 0);
        }

        p.translate(0, -cellHeight * (bottomRow - topRow + 1));
    }
}

void DDateTable::paintCell(QPainter* painter, int row, int col)
{
    double w    = (width() / (double) d->numDayColumns) - 1;
    double h    = (height() / (double) d->numWeekRows) - 1;
    QRectF cell = QRectF(0, 0, w, h);
    QString cellText;
    QColor cellBackgroundColor, cellTextColor;
    QFont cellFont  = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
    bool workingDay = false;
    int cellWeekDay, pos;

    // Calculate the position of the cell in the grid

    pos = d->numDayColumns * (row - 1) + col;

    // Calculate what day of the week the cell is

    if ((col + locale().firstDayOfWeek()) <= d->numDayColumns)
    {
        cellWeekDay = col + locale().firstDayOfWeek();
    }
    else
    {
        cellWeekDay = col + locale().firstDayOfWeek() - d->numDayColumns;
    }

    // FIXME This is wrong if the widget is not using the global!
    // See if cell day is normally a working day

    if (locale().weekdays().constFirst() <= locale().weekdays().constLast())
    {
        if (
            (cellWeekDay >= locale().weekdays().constFirst()) &&
            (cellWeekDay <= locale().weekdays().constLast())
           )
        {
            workingDay = true;
        }
    }
    else
    {
        if (
            (cellWeekDay >= locale().weekdays().constFirst()) ||
            (cellWeekDay <= locale().weekdays().constLast())
           )
        {
            workingDay = true;
        }
    }

    if (row == 0)
    {
        // We are drawing a header cell

        // If not a normal working day, then use "do not work today" color

        if (workingDay)
        {
            cellTextColor = palette().color(QPalette::WindowText);
        }
        else
        {
            cellTextColor = Qt::darkRed;
        }

        cellBackgroundColor = palette().color(QPalette::Window);

        // Set the text to the short day name and bold it

        cellFont.setBold(true);
        cellText = locale().standaloneDayName(cellWeekDay, QLocale::ShortFormat);
    }
    else
    {
        // We are drawing a day cell

        // Calculate the date the cell represents

        QDate cellDate = dateFromPos(pos);
        bool validDay  = cellDate.isValid();

        // Draw the day number in the cell, if the date is not valid then we don't want to show it

        if (validDay)
        {
            cellText = QString::number(cellDate.day());
        }
        else
        {
            cellText = QLatin1String("");
        }

        if (! validDay || (cellDate.month() != d->date.month()))
        {
            // we are either
            // ° painting an invalid day
            // ° painting a day of the previous month or
            // ° painting a day of the following month or

            cellBackgroundColor = palette().color(backgroundRole());
            cellTextColor       = palette().color(QPalette::Disabled, QPalette::Text);
        }
        else
        {
            // Paint a day of the current month

            // Background Colour priorities will be (high-to-low):
            // * Selected Day Background Colour
            // * Customized Day Background Colour
            // * Normal Day Background Colour

            // Background Shape priorities will be (high-to-low):
            // * Customized Day Shape
            // * Normal Day Shape

            // Text Colour priorities will be (high-to-low):
            // * Customized Day Colour
            // * Day of Pray Colour (Red letter)
            // * Selected Day Colour
            // * Normal Day Colour

            // Determine various characteristics of the cell date

            bool selectedDay = (cellDate == date());
            bool currentDay  = (cellDate == QDate::currentDate());
            bool dayOfPray   = (cellDate.dayOfWeek() == Qt::Sunday);

            // TODO: Uncomment if QLocale ever gets the feature...
/*
            bool dayOfPray = ( cellDate.dayOfWeek() == locale().dayOfPray() );
*/
            bool customDay   = (d->useCustomColors && d->customPaintingModes.contains(cellDate.toJulianDay()));

            // Default values for a normal cell

            cellBackgroundColor = palette().color(backgroundRole());
            cellTextColor = palette().color(foregroundRole());

            // If we are drawing the current date, then draw it bold and active

            if (currentDay)
            {
                cellFont.setBold(true);
                cellTextColor = palette().color(QPalette::LinkVisited);
            }

            // if we are drawing the day cell currently selected in the table

            if (selectedDay)
            {
                // set the background to highlighted

                cellBackgroundColor = palette().color(QPalette::Highlight);
                cellTextColor = palette().color(QPalette::HighlightedText);
            }

            // If custom colors or shape are required for this date

            if (customDay)
            {
                Private::DatePaintingMode mode = d->customPaintingModes[cellDate.toJulianDay()];

                if (mode.bgMode != NoBgMode)
                {
                    if (!selectedDay)
                    {
                        cellBackgroundColor = mode.bgColor;
                    }
                }

                cellTextColor = mode.fgColor;
            }

            // If the cell day is the day of religious observance, then always color text red unless Custom overrides

            if (! customDay && dayOfPray)
            {
                cellTextColor = Qt::darkRed;
            }
        }
    }

    // Draw the background

    if      (row == 0)
    {
        painter->setPen(cellBackgroundColor);
        painter->setBrush(cellBackgroundColor);
        painter->drawRect(cell);
    }
    else if ((cellBackgroundColor != palette().color(backgroundRole())) || (pos == d->hoveredPos))
    {
        QStyleOptionViewItem opt;
        opt.initFrom(this);
        opt.rect = cell.toRect();

        if (cellBackgroundColor != palette().color(backgroundRole()))
        {
            opt.palette.setBrush(QPalette::Highlight, cellBackgroundColor);
            opt.state |= QStyle::State_Selected;
        }

        if ((pos == d->hoveredPos) && (opt.state & QStyle::State_Enabled))
        {
            opt.state |= QStyle::State_MouseOver;
        }
        else
        {
            opt.state &= ~QStyle::State_MouseOver;
        }

        opt.showDecorationSelected = true;
        opt.viewItemPosition       = QStyleOptionViewItem::OnlyOne;
        style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, this);
    }

    // Draw the text

    painter->setPen(cellTextColor);
    painter->setFont(cellFont);
    painter->drawText(cell, Qt::AlignCenter, cellText, &cell);

    // Draw the base line

    if (row == 0)
    {
        painter->setPen(palette().color(foregroundRole()));
        painter->drawLine(QPointF(0, h), QPointF(w, h));
    }

    // If the day cell we just drew is bigger than the current max cell sizes,
    // then adjust the max to the current cell

    if (cell.width() > d->maxCell.width())
    {
        d->maxCell.setWidth(cell.width());
    }

    if (cell.height() > d->maxCell.height())
    {
        d->maxCell.setHeight(cell.height());
    }
}

void DDateTable::keyPressEvent(QKeyEvent *e)
{
    switch (e->key())
    {
        case Qt::Key_Up:
        {
            // setDate does validity checking for us

            setDate(d->date.addDays(- d->numDayColumns));
            break;
        }

        case Qt::Key_Down:
        {
            // setDate does validity checking for us

            setDate(d->date.addDays(d->numDayColumns));
            break;
        }

        case Qt::Key_Left:
        {
            // setDate does validity checking for us

            setDate(d->date.addDays(-1));
            break;
        }

        case Qt::Key_Right:
        {
            // setDate does validity checking for us

            setDate(d->date.addDays(1));
            break;
        }

        case Qt::Key_Minus:
        {
            // setDate does validity checking for us

            setDate(d->date.addDays(-1));
            break;
        }

        case Qt::Key_Plus:
        {
            // setDate does validity checking for us

            setDate(d->date.addDays(1));
            break;
        }

        case Qt::Key_N:
        {
            // setDate does validity checking for us

            setDate(QDate::currentDate());
            break;
        }

        case Qt::Key_Return:
        case Qt::Key_Enter:
        {
            Q_EMIT tableClicked();

            break;
        }

        case Qt::Key_Control:
        case Qt::Key_Alt:
        case Qt::Key_Meta:
        case Qt::Key_Shift:
        {
            // Don't beep for modifiers

            break;
        }

        default:
        {
            if (!e->modifiers())
            {
                // hm

                QApplication::beep();
            }
        }
    }
}

void DDateTable::setFontSize(int size)
{
    QFontMetricsF metrics(fontMetrics());
    QRectF rect;

    // ----- store rectangles:

    d->fontsize = size;

    // ----- find largest day name:

    d->maxCell.setWidth(0);
    d->maxCell.setHeight(0);

    for (int weekday = 1 ; weekday <= 7 ; ++weekday)
    {
        rect = metrics.boundingRect(locale().standaloneDayName(weekday, QLocale::ShortFormat));
        d->maxCell.setWidth(qMax(d->maxCell.width(), rect.width()));
        d->maxCell.setHeight(qMax(d->maxCell.height(), rect.height()));
    }

    // ----- compare with a real wide number and add some space:

    rect = metrics.boundingRect(QLatin1String("88"));
    d->maxCell.setWidth(qMax(d->maxCell.width() + 2, rect.width()));
    d->maxCell.setHeight(qMax(d->maxCell.height() + 4, rect.height()));
}

void DDateTable::wheelEvent(QWheelEvent *e)
{
    setDate(d->date.addMonths(-(int)(e->angleDelta().y() / 120)));
    e->accept();
}

bool DDateTable::event(QEvent *ev)
{
    switch (ev->type())
    {
        case QEvent::HoverMove:
        {
            QHoverEvent* const e = static_cast<QHoverEvent*>(ev);

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

            const int row        = e->position().toPoint().y() * d->numWeekRows / height();

#else

            const int row        = e->pos().y() * d->numWeekRows / height();

#endif

            int col;

            if (layoutDirection() == Qt::RightToLeft)
            {

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

                col = d->numDayColumns - (e->position().toPoint().x() * d->numDayColumns / width()) - 1;

#else

                col = d->numDayColumns - (e->pos().x() * d->numDayColumns / width()) - 1;

#endif

            }
            else
            {

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

                col = e->position().toPoint().x() * d->numDayColumns / width();

#else

                col = e->pos().x() * d->numDayColumns / width();

#endif

            }

            const int pos = row < 1 ? -1 : (d->numDayColumns * (row - 1)) + col;

            if (pos != d->hoveredPos)
            {
                d->hoveredPos = pos;
                update();
            }

            break;
        }

        case QEvent::HoverLeave:
        {
            if (d->hoveredPos != -1)
            {
                d->hoveredPos = -1;
                update();
            }

            break;
        }

        default:
        {
            break;
        }
    }

    return QWidget::event(ev);
}

void DDateTable::mousePressEvent(QMouseEvent *e)
{
    if (e->type() != QEvent::MouseButtonPress)
    {
        // the Date Picker only reacts on mouse press events:

        return;
    }

    if (!isEnabled())
    {
        QApplication::beep();

        return;
    }

    int row, col, pos;

    QPoint mouseCoord = e->pos();
    row               = mouseCoord.y() * d->numWeekRows / height();

    if (layoutDirection() == Qt::RightToLeft)
    {
        col = d->numDayColumns - (mouseCoord.x() * d->numDayColumns / width()) - 1;
    }
    else
    {
        col = mouseCoord.x() * d->numDayColumns / width();
    }

    if ((row < 1) || (col < 0))
    {
        // the user clicked on the frame of the table

        return;
    }

    // Rows and columns are zero indexed.  The (row - 1) below is to avoid counting
    // the row with the days of the week in the calculation.

    // new position and date

    pos               = (d->numDayColumns * (row - 1)) + col;
    QDate clickedDate = dateFromPos(pos);

    // set the new date. If it is in the previous or next month, the month will
    // automatically be changed, no need to do that manually...
    // validity checking done inside setDate

    setDate(clickedDate);

    // This could be optimized to only call update over the regions
    // of old and new cell, but 99% of times there is also a call to
    // setDate that already calls update() so no need to optimize that
    // much here

    update();

    Q_EMIT tableClicked();

    if ((e->button() == Qt::RightButton) && d->popupMenuEnabled)
    {
        QMenu* const menu = new QMenu();
        menu->addSection(locale().toString(d->date));

        Q_EMIT aboutToShowContextMenu(menu, clickedDate);

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))

        menu->popup(e->globalPosition().toPoint());

#else

        menu->popup(e->globalPos());

#endif

    }
}

bool DDateTable::setDate(const QDate& toDate)
{
    if (!toDate.isValid())
    {
        return false;
    }

    if (toDate == date())
    {
        return true;
    }

    QDate oldDate = date();
    d->setDate(toDate);

    Q_EMIT selectedDateChanged(date(), oldDate);
    Q_EMIT dateChanged(date());

    update();

    return true;
}

const QDate& DDateTable::date() const
{
    return d->date;
}

void DDateTable::focusInEvent(QFocusEvent* e)
{
    QWidget::focusInEvent(e);
}

void DDateTable::focusOutEvent(QFocusEvent* e)
{
    QWidget::focusOutEvent(e);
}

QSize DDateTable::sizeHint() const
{
    if ((d->maxCell.height() > 0) && (d->maxCell.width() > 0))
    {
        return QSize(
                      qRound(d->maxCell.width()       * d->numDayColumns),
                     (qRound(d->maxCell.height() + 2) * d->numWeekRows)
                    );
    }
    else
    {
        //qCDebug(DIGIKAM_GENERAL_LOG) << "DDateTable::sizeHint: obscure failure - " << Qt::endl;

        return QSize(-1, -1);
    }
}

void DDateTable::setPopupMenuEnabled(bool enable)
{
    d->popupMenuEnabled = enable;
}

bool DDateTable::popupMenuEnabled() const
{
    return d->popupMenuEnabled;
}

void DDateTable::setCustomDatePainting(const QDate& date, const QColor& fgColor,<--- Shadow argument
                                       BackgroundMode bgMode, const QColor& bgColor)
{
    if (!fgColor.isValid())
    {
        unsetCustomDatePainting(date);
        return;
    }

    Private::DatePaintingMode mode;
    mode.bgMode        = bgMode;
    mode.fgColor       = fgColor;
    mode.bgColor       = bgColor;

    d->customPaintingModes.insert(date.toJulianDay(), mode);
    d->useCustomColors = true;
    update();
}

void DDateTable::unsetCustomDatePainting(const QDate& date)<--- Shadow argument
{
    d->customPaintingModes.remove(date.toJulianDay());

    if (d->customPaintingModes.isEmpty())
    {
        d->useCustomColors = false;
    }

    update();
}

} // namespace Digikam

#include "moc_ddatetable.cpp"