blob: e0181acf85e82e161f9a18fbae3af7773b6a6094 [file] [log] [blame]
Edric Milareta0ebd062016-01-13 12:18:23 -05001/***************************************************************************
2 * Copyright (C) 2016 by Savoir-faire Linux *
3 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
19#pragma once
20
21#include <QImage>
22
23#include <memory>
24#include <interfaces/pixmapmanipulatori.h>
25
26Q_DECLARE_METATYPE(QImage);
27
28class Person;
29
30namespace Interfaces {
31
32class PixbufManipulator : public PixmapManipulatorI {
33public:
34 PixbufManipulator();
35
36 QVariant callPhoto(Call* c, const QSize& size, bool displayPresence = true) override;
37 QVariant callPhoto(const ContactMethod* n, const QSize& size, bool displayPresence = true) override;
38 QVariant contactPhoto(Person* c, const QSize& size, bool displayPresence = true) override;
39 QVariant personPhoto(const QByteArray& data, const QString& type = "PNG") override;
40
41 /* TODO: the following methods return an empty QVariant/QByteArray */
42 QVariant numberCategoryIcon(const QVariant& p, const QSize& size, bool displayPresence = false, bool isPresent = false) override;
43 QVariant securityIssueIcon(const QModelIndex& index) override;
44 QByteArray toByteArray(const QVariant& pxm) override;
45 QVariant collectionIcon(const CollectionInterface* interface, PixmapManipulatorI::CollectionIconHint hint = PixmapManipulatorI::CollectionIconHint::NONE) const override;
46 QVariant securityLevelIcon(const SecurityEvaluationModel::SecurityLevel level) const override;
47 QVariant historySortingCategoryIcon(const CategorizedHistoryModel::SortedProxy::Categories cat) const override;
48 QVariant contactSortingCategoryIcon(const CategorizedContactModel::SortedProxy::Categories cat) const override;
49 QVariant userActionIcon(const UserActionElement& state) const override;
50 QVariant decorationRole(const QModelIndex& index) override;
51 QVariant decorationRole(const Call* c) override;
52 QVariant decorationRole(const ContactMethod* cm) override;
53 QVariant decorationRole(const Person* p) override;
54
55private:
56 QImage fallbackAvatar_;
57 QImage scaleAndFrame(const QImage photo, const QSize& size);
58 const QSize imgSize_ {48, 48};
59};
60
61} // namespace Interfaces
62