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 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2009-04-30
* Description : selection icon view item at mouse hover
*
* SPDX-FileCopyrightText: 2008 by Peter Penz <peter dot penz at gmx dot at>
* SPDX-FileCopyrightText: 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#include "facerejectionoverlay.h"
// KDE includes
#include <klocalizedstring.h>
// Local includes
#include "itemcategorizedview.h"
#include "itemfacedelegate.h"
#include "itemmodel.h"
namespace Digikam
{
FaceRejectionOverlayButton::FaceRejectionOverlayButton(QAbstractItemView* const parentView)
: ItemViewHoverButton(parentView)
{
setup();
}
QSize FaceRejectionOverlayButton::sizeHint() const
{
return QSize(32, 32);
}
QIcon FaceRejectionOverlayButton::icon()
{
return QIcon::fromTheme(QLatin1String("window-close"));
}
void FaceRejectionOverlayButton::updateToolTip()
{
setToolTip(i18nc("@info:tooltip", "If this is not a face, click to delete it."));
}
// --------------------------------------------------------------------
FaceRejectionOverlay::FaceRejectionOverlay(QObject* const parent)
: HoverButtonDelegateOverlay(parent)
{
}
void FaceRejectionOverlay::setActive(bool active)
{
HoverButtonDelegateOverlay::setActive(active);
if (active)
{
connect(button(), SIGNAL(clicked(bool)),
this, SLOT(slotClicked()));
}
else
{
// button is deleted
}
}
ItemViewHoverButton* FaceRejectionOverlay::createButton()
{
return new FaceRejectionOverlayButton(view());
}
void FaceRejectionOverlay::updateButton(const QModelIndex& index)
{
const QRect rect = m_view->visualRect(index);
const int size = qBound(16, rect.width() / 8 - 2, 48);
const int gap = 5;
const int x = rect.right() - gap - size;
const int y = rect.top() + gap;
button()->resize(size, size);
button()->move(QPoint(x, y));
}
void FaceRejectionOverlay::slotClicked()
{
QModelIndex index = button()->index();
if (index.isValid())
{
Q_EMIT rejectFaces(affectedIndexes(index));
}
}
bool FaceRejectionOverlay::checkIndex(const QModelIndex& index) const
{
return !index.data(ItemModel::ExtraDataRole).isNull();
}
void FaceRejectionOverlay::widgetEnterEvent()
{
widgetEnterNotifyMultiple(button()->index());
}
void FaceRejectionOverlay::widgetLeaveEvent()
{
widgetLeaveNotifyMultiple();
}
} // namespace Digikam
#include "moc_facerejectionoverlay.cpp"
|