blob: 705faef7a25eedf5a1d64ac46e4feeb90842c04c [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Edric Milaretbab169d2016-01-07 15:13:33 -05002 * Copyright (C) 2015-2016 by Savoir-faire Linux *
Edric Milaret627500d2015-03-27 16:41:40 -04003 * 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
Edric Milaret5f316da2015-09-28 11:57:42 -040019#pragma once
Edric Milaret627500d2015-03-27 16:41:40 -040020
Edric Milareted0b2802015-10-01 15:10:02 -040021#include <QObject>
Edric Milareta0ebd062016-01-13 12:18:23 -050022#include <QItemDelegate>
Edric Milaret627500d2015-03-27 16:41:40 -040023
Edric Milareted0b2802015-10-01 15:10:02 -040024class QPainter;
Edric Milaret627500d2015-03-27 16:41:40 -040025
Edric Milareta0ebd062016-01-13 12:18:23 -050026class SmartListDelegate : public QItemDelegate
Edric Milaret627500d2015-03-27 16:41:40 -040027{
28 Q_OBJECT
Edric Milaret627500d2015-03-27 16:41:40 -040029public:
Nicolas Jager97a21b42015-12-03 16:55:45 -050030 explicit SmartListDelegate(QObject* parent = 0);
31 inline void setRowHighlighted(int i){rowHighlighted_ = i;};
Edric Milaret627500d2015-03-27 16:41:40 -040032
Edric Milareted0b2802015-10-01 15:10:02 -040033protected:
Nicolas Jager97a21b42015-12-03 16:55:45 -050034 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
35 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
36
Edric Milaret627500d2015-03-27 16:41:40 -040037private:
Nicolas Jager97a21b42015-12-03 16:55:45 -050038 constexpr static int sizeImage_ = 48;
39 constexpr static int cellHeight_ = 60;
Edric Milareta0ebd062016-01-13 12:18:23 -050040 constexpr static int dy_ = 6;
41 constexpr static int dx_ = 12;
42 constexpr static int fontSize_ = 10;
Edric Milaret23fd3fa2016-01-15 15:37:35 -050043 constexpr static int pinSize_ = 12;
Nicolas Jager97a21b42015-12-03 16:55:45 -050044 int rowHighlighted_ = -1;
45
46signals:
47 void rowSelected(const QRect& rect) const;
Edric Milaret627500d2015-03-27 16:41:40 -040048};