themesdelegate.h 1.58 KB
Newer Older
Reza Shah's avatar
Reza Shah committed
1
/*
Reza Shah's avatar
Reza Shah committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
    Copyright 2013 by Reza Fatahilah Shah <rshah0385@kireihana.com>
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.
   
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
   
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
Reza Shah's avatar
Reza Shah committed
17 18 19 20 21 22 23 24 25
 */
#ifndef THEMESDELEGATE_H
#define THEMESDELEGATE_H

#include <QAbstractItemDelegate>

class ThemesDelegate : public QAbstractItemDelegate
{
public:
Laurent Montel's avatar
Laurent Montel committed
26
    explicit ThemesDelegate(QObject *parent = nullptr);
Reza Shah's avatar
Reza Shah committed
27
    
Laurent Montel's avatar
Laurent Montel committed
28
    void paint(QPainter *painter,
Reza Shah's avatar
Reza Shah committed
29
                       const QStyleOptionViewItem &option,
Laurent Montel's avatar
Laurent Montel committed
30 31 32
                       const QModelIndex &index) const Q_DECL_OVERRIDE;
    QSize sizeHint(const QStyleOptionViewItem &option,
                           const QModelIndex &index) const Q_DECL_OVERRIDE;
Reza Shah's avatar
Reza Shah committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46
    void setPreviewSize(const QSize &size);
    
    static const int SCREENSHOT_SIZE = 128;
    static const int BLUR_INCREMENT = 9;
    static const int MARGIN = 6;

    void resetMaxHeight() { m_maxHeight = 0; }
    int m_maxHeight;

private:
    int m_maxWidth;
    QSize mSize;
};

Laurent Montel's avatar
Laurent Montel committed
47
#endif //THEMESDELEGATE_H