mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -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
@ -287,6 +287,7 @@ HEADERS += rshare.h \
|
|||||||
gui/common/GroupDefs.h \
|
gui/common/GroupDefs.h \
|
||||||
gui/common/Emoticons.h \
|
gui/common/Emoticons.h \
|
||||||
gui/common/RSTreeWidgetItem.h \
|
gui/common/RSTreeWidgetItem.h \
|
||||||
|
gui/common/RSItemDelegate.h \
|
||||||
gui/common/PeerDefs.h \
|
gui/common/PeerDefs.h \
|
||||||
gui/MessagesDialog.h \
|
gui/MessagesDialog.h \
|
||||||
gui/help/browser/helpbrowser.h \
|
gui/help/browser/helpbrowser.h \
|
||||||
@ -488,6 +489,7 @@ SOURCES += main.cpp \
|
|||||||
gui/common/GroupDefs.cpp \
|
gui/common/GroupDefs.cpp \
|
||||||
gui/common/Emoticons.cpp \
|
gui/common/Emoticons.cpp \
|
||||||
gui/common/RSTreeWidgetItem.cpp \
|
gui/common/RSTreeWidgetItem.cpp \
|
||||||
|
gui/common/RSItemDelegate.cpp \
|
||||||
gui/common/PeerDefs.cpp \
|
gui/common/PeerDefs.cpp \
|
||||||
gui/settings/rsharesettings.cpp \
|
gui/settings/rsharesettings.cpp \
|
||||||
gui/settings/RsharePeerSettings.cpp \
|
gui/settings/RsharePeerSettings.cpp \
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
ChanGroupDelegate::ChanGroupDelegate(QObject *parent) : RSItemDelegate(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void ChanGroupDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
void ChanGroupDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||||
{
|
{
|
||||||
if (index.child(0, 0).isValid()) {
|
if (index.child(0, 0).isValid()) {
|
||||||
@ -19,5 +23,5 @@ void ChanGroupDelegate::paint(QPainter * painter, const QStyleOptionViewItem & o
|
|||||||
QApplication::style()->drawControl(QStyle::CE_PushButtonBevel, &opt, painter);
|
QApplication::style()->drawControl(QStyle::CE_PushButtonBevel, &opt, painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
QItemDelegate::paint(painter, option, index);
|
RSItemDelegate::paint(painter, option, index);
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,13 @@
|
|||||||
#ifndef CHANGROUPDELEGATE_H_
|
#ifndef CHANGROUPDELEGATE_H_
|
||||||
#define CHANGROUPDELEGATE_H_
|
#define CHANGROUPDELEGATE_H_
|
||||||
|
|
||||||
#include <QItemDelegate>
|
#include "common/RSItemDelegate.h"
|
||||||
|
|
||||||
class ChanGroupDelegate : public QItemDelegate
|
class ChanGroupDelegate : public RSItemDelegate
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
ChanGroupDelegate(QObject *parent = 0);
|
||||||
|
|
||||||
virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,7 +93,10 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
|||||||
|
|
||||||
treeView->setModel(model);
|
treeView->setModel(model);
|
||||||
|
|
||||||
treeView->setItemDelegate(new ChanGroupDelegate());
|
RSItemDelegate *itemDelegate = new ChanGroupDelegate(this);
|
||||||
|
itemDelegate->removeFocusRect(COLUMN_POPULARITY);
|
||||||
|
itemDelegate->setSpacing(QSize(0, 2));
|
||||||
|
treeView->setItemDelegate(itemDelegate);
|
||||||
|
|
||||||
connect(treeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(selectChannel(QModelIndex)));
|
connect(treeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(selectChannel(QModelIndex)));
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "msgs/MessageComposer.h"
|
#include "msgs/MessageComposer.h"
|
||||||
#include "settings/rsharesettings.h"
|
#include "settings/rsharesettings.h"
|
||||||
#include "common/Emoticons.h"
|
#include "common/Emoticons.h"
|
||||||
|
#include "common/RSItemDelegate.h"
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsforums.h>
|
#include <retroshare/rsforums.h>
|
||||||
@ -98,36 +99,6 @@
|
|||||||
|
|
||||||
#define IS_UNREAD(status) ((status & FORUM_MSG_STATUS_READ) == 0 || (status & FORUM_MSG_STATUS_UNREAD_BY_USER))
|
#define IS_UNREAD(status) ((status & FORUM_MSG_STATUS_READ) == 0 || (status & FORUM_MSG_STATUS_UNREAD_BY_USER))
|
||||||
|
|
||||||
class ForumsItemDelegate : public QItemDelegate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ForumsItemDelegate(QObject *parent = 0) : QItemDelegate(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
QStyleOptionViewItem ownOption (option);
|
|
||||||
|
|
||||||
if (index.column() == COLUMN_THREAD_READ) {
|
|
||||||
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
||||||
}
|
|
||||||
|
|
||||||
QItemDelegate::paint (painter, ownOption, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
QStyleOptionViewItem ownOption (option);
|
|
||||||
|
|
||||||
if (index.column() == COLUMN_THREAD_READ) {
|
|
||||||
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
||||||
}
|
|
||||||
|
|
||||||
return QItemDelegate::sizeHint(ownOption, index);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int FilterColumnFromComboBox(int nIndex)
|
static int FilterColumnFromComboBox(int nIndex)
|
||||||
{
|
{
|
||||||
switch (nIndex) {
|
switch (nIndex) {
|
||||||
@ -194,8 +165,14 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||||||
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
||||||
|
|
||||||
/* Set own item delegate */
|
/* Set own item delegate */
|
||||||
QItemDelegate *pDelegate = new ForumsItemDelegate(this);
|
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
|
||||||
ui.threadTreeWidget->setItemDelegate(pDelegate);
|
itemDelegate->removeFocusRect(COLUMN_THREAD_READ);
|
||||||
|
itemDelegate->setSpacing(QSize(0, 2));
|
||||||
|
ui.threadTreeWidget->setItemDelegate(itemDelegate);
|
||||||
|
|
||||||
|
itemDelegate = new RSItemDelegate(this);
|
||||||
|
itemDelegate->setSpacing(QSize(0, 2));
|
||||||
|
ui.forumTreeWidget->setItemDelegate(itemDelegate);
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes */
|
/* Set header resize modes and initial section sizes */
|
||||||
QHeaderView * ftheader = ui.forumTreeWidget->header () ;
|
QHeaderView * ftheader = ui.forumTreeWidget->header () ;
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "common/TagDefs.h"
|
#include "common/TagDefs.h"
|
||||||
#include "common/PeerDefs.h"
|
#include "common/PeerDefs.h"
|
||||||
|
#include "common/RSItemDelegate.h"
|
||||||
|
|
||||||
#include <retroshare/rsinit.h>
|
#include <retroshare/rsinit.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
@ -92,36 +93,6 @@
|
|||||||
#define ACTION_TAGS_TAG 1
|
#define ACTION_TAGS_TAG 1
|
||||||
#define ACTION_TAGS_NEWTAG 2
|
#define ACTION_TAGS_NEWTAG 2
|
||||||
|
|
||||||
class MessagesItemDelegate : public QItemDelegate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MessagesItemDelegate(QObject *parent = 0) : QItemDelegate(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
QStyleOptionViewItem ownOption (option);
|
|
||||||
|
|
||||||
if (index.column() == COLUMN_UNREAD) {
|
|
||||||
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
||||||
}
|
|
||||||
|
|
||||||
QItemDelegate::paint (painter, ownOption, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
QStyleOptionViewItem ownOption (option);
|
|
||||||
|
|
||||||
if (index.column() == COLUMN_UNREAD) {
|
|
||||||
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
||||||
}
|
|
||||||
|
|
||||||
return QItemDelegate::sizeHint(ownOption, index);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class MessagesMenu : public QMenu
|
class MessagesMenu : public QMenu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -309,8 +280,10 @@ MessagesDialog::MessagesDialog(QWidget *parent)
|
|||||||
ui.messagestreeView->setModel(proxyModel);
|
ui.messagestreeView->setModel(proxyModel);
|
||||||
ui.messagestreeView->setSelectionBehavior(QTreeView::SelectRows);
|
ui.messagestreeView->setSelectionBehavior(QTreeView::SelectRows);
|
||||||
|
|
||||||
QItemDelegate *pDelegate = new MessagesItemDelegate(this);
|
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
|
||||||
ui.messagestreeView->setItemDelegate(pDelegate);
|
itemDelegate->removeFocusRect(COLUMN_UNREAD);
|
||||||
|
itemDelegate->setSpacing(QSize(0, 2));
|
||||||
|
ui.messagestreeView->setItemDelegate(itemDelegate);
|
||||||
|
|
||||||
ui.messagestreeView->setRootIsDecorated(false);
|
ui.messagestreeView->setRootIsDecorated(false);
|
||||||
ui.messagestreeView->setSortingEnabled(true);
|
ui.messagestreeView->setSortingEnabled(true);
|
||||||
|
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;
|
||||||
|
}
|
45
retroshare-gui/src/gui/common/RSItemDelegate.h
Normal file
45
retroshare-gui/src/gui/common/RSItemDelegate.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* 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.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _RSITEMDELEGATE_H
|
||||||
|
#define _RSITEMDELEGATE_H
|
||||||
|
|
||||||
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
class RSItemDelegate : public QItemDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RSItemDelegate(QObject *parent = 0);
|
||||||
|
|
||||||
|
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
|
||||||
|
void removeFocusRect(int column);
|
||||||
|
void setSpacing(const QSize &spacing);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<int> m_noFocusRect;
|
||||||
|
QSize m_spacing;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user