mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 07:05:26 -04:00
Add spacing again for forums, messages and channels.
Added a new base class "RSItemDelegate" for adding a spacing for the item and remove the focus rectangle of the empty text for items with only an icon. Removed existing classes "ForumsItemDelegate" and "MessagesItemDelegate". git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3771 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ca45c73dc2
commit
e20e9a529a
8 changed files with 139 additions and 68 deletions
64
retroshare-gui/src/gui/common/RSItemDelegate.cpp
Normal file
64
retroshare-gui/src/gui/common/RSItemDelegate.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include "RSItemDelegate.h"
|
||||
|
||||
RSItemDelegate::RSItemDelegate(QObject *parent) : QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void RSItemDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItem ownOption (option);
|
||||
|
||||
if (m_noFocusRect.indexOf(index.column()) >= 0) {
|
||||
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
||||
}
|
||||
|
||||
QItemDelegate::paint (painter, ownOption, index);
|
||||
}
|
||||
|
||||
QSize RSItemDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItem ownOption (option);
|
||||
|
||||
if (m_noFocusRect.indexOf(index.column()) >= 0) {
|
||||
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
||||
}
|
||||
|
||||
QSize size = QItemDelegate::sizeHint(ownOption, index);
|
||||
|
||||
size += m_spacing;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
void RSItemDelegate::removeFocusRect(int column)
|
||||
{
|
||||
if (m_noFocusRect.indexOf(column) == -1) {
|
||||
m_noFocusRect.push_back(column);
|
||||
}
|
||||
}
|
||||
|
||||
void RSItemDelegate::setSpacing(const QSize &spacing)
|
||||
{
|
||||
m_spacing = spacing;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue