blob: d42237e7fc750ff640323025c1ca417ec170f019 [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
Edric Milaret25236d92016-03-28 09:40:58 -040030QByteArray QImageToByteArray(QImage image);
31
Edric Milareta0ebd062016-01-13 12:18:23 -050032namespace Interfaces {
33
34class PixbufManipulator : public PixmapManipulatorI {
35public:
36 PixbufManipulator();
37
38 QVariant callPhoto(Call* c, const QSize& size, bool displayPresence = true) override;
39 QVariant callPhoto(const ContactMethod* n, const QSize& size, bool displayPresence = true) override;
40 QVariant contactPhoto(Person* c, const QSize& size, bool displayPresence = true) override;
41 QVariant personPhoto(const QByteArray& data, const QString& type = "PNG") override;
42
43 /* TODO: the following methods return an empty QVariant/QByteArray */
44 QVariant numberCategoryIcon(const QVariant& p, const QSize& size, bool displayPresence = false, bool isPresent = false) override;
45 QVariant securityIssueIcon(const QModelIndex& index) override;
46 QByteArray toByteArray(const QVariant& pxm) override;
47 QVariant collectionIcon(const CollectionInterface* interface, PixmapManipulatorI::CollectionIconHint hint = PixmapManipulatorI::CollectionIconHint::NONE) const override;
48 QVariant securityLevelIcon(const SecurityEvaluationModel::SecurityLevel level) const override;
49 QVariant historySortingCategoryIcon(const CategorizedHistoryModel::SortedProxy::Categories cat) const override;
50 QVariant contactSortingCategoryIcon(const CategorizedContactModel::SortedProxy::Categories cat) const override;
51 QVariant userActionIcon(const UserActionElement& state) const override;
52 QVariant decorationRole(const QModelIndex& index) override;
53 QVariant decorationRole(const Call* c) override;
54 QVariant decorationRole(const ContactMethod* cm) override;
55 QVariant decorationRole(const Person* p) override;
Edric Milareta7cf8652016-04-19 15:37:51 -040056 QVariant decorationRole(const Account* acc) override;
Edric Milareta0ebd062016-01-13 12:18:23 -050057
58private:
59 QImage fallbackAvatar_;
60 QImage scaleAndFrame(const QImage photo, const QSize& size);
61 const QSize imgSize_ {48, 48};
62};
63
64} // namespace Interfaces
65