Grégory Soutadé
a9bcdcc733
Fix a bug : Fix category in choices of normal operation Fix a bug : bad request in Database.cpp Fix a bug : bad month in calendar Add a 5th week for black line
75 lines
2.0 KiB
C++
75 lines
2.0 KiB
C++
/*
|
|
Copyright 2010-2011 Grégory Soutadé
|
|
|
|
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
|
|
{
|
|
private:
|
|
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 ||
|
|
row == _grid->_week4 ||
|
|
row == _grid->_week5)
|
|
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
|
|
}
|
|
}
|
|
};
|
|
|
|
#endif
|