2011-10-22 13:13:57 +02:00
|
|
|
/*
|
2012-02-01 11:02:54 +01:00
|
|
|
Copyright 2010-2012 Grégory Soutadé
|
2011-10-22 13:13:57 +02:00
|
|
|
|
|
|
|
This file is part of KissCount.
|
|
|
|
|
|
|
|
KissCount 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
KissCount 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 KissCount. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TABLEVIEWDELEGATE_H
|
|
|
|
#define TABLEVIEWDELEGATE_H
|
|
|
|
|
|
|
|
#include <QtGui>
|
|
|
|
#include "GridAccount.hpp"
|
|
|
|
|
|
|
|
class TableViewDelegate : public QStyledItemDelegate
|
|
|
|
{
|
2012-03-11 20:40:07 +01:00
|
|
|
protected:
|
2011-10-22 13:13:57 +02:00
|
|
|
GridAccount* _grid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// "Nomme" les rôles utilisés par ce delegate
|
|
|
|
// pour récupèrer les nouvelles propriétés d'un item
|
|
|
|
enum Roles {
|
|
|
|
BorderWidthRole = Qt::UserRole,
|
|
|
|
BorderColorRole,
|
|
|
|
};
|
|
|
|
|
|
|
|
TableViewDelegate(QObject *parent = 0) : QStyledItemDelegate(parent), _grid(qobject_cast<GridAccount*>(parent))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void paint (QPainter * painter,
|
|
|
|
const QStyleOptionViewItem & option,
|
|
|
|
const QModelIndex & index ) const
|
|
|
|
{
|
|
|
|
|
|
|
|
QStyledItemDelegate::paint(painter, option, index);
|
|
|
|
|
|
|
|
if (!_grid) return;
|
|
|
|
|
|
|
|
QPen pen(Qt::black);
|
|
|
|
int row = index.row();
|
|
|
|
painter->setPen(pen);
|
|
|
|
|
|
|
|
// Always paint column
|
|
|
|
painter->drawLine(option.rect.topLeft(), option.rect.bottomLeft());
|
|
|
|
|
|
|
|
if (row == 0)
|
|
|
|
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
|
|
|
|
else if (_grid->_canAddOperation)
|
|
|
|
{
|
|
|
|
if (row == _grid->_fixCosts ||
|
|
|
|
row == _grid->_week1 ||
|
|
|
|
row == _grid->_week2 ||
|
|
|
|
row == _grid->_week3 ||
|
2011-11-01 16:17:20 +01:00
|
|
|
row == _grid->_week4 ||
|
|
|
|
row == _grid->_week5)
|
2011-10-22 13:13:57 +02:00
|
|
|
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|