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:
thunder2 2010-11-09 23:56:02 +00:00
parent ca45c73dc2
commit e20e9a529a
8 changed files with 139 additions and 68 deletions

View file

@ -39,6 +39,7 @@
#include "util/misc.h"
#include "common/TagDefs.h"
#include "common/PeerDefs.h"
#include "common/RSItemDelegate.h"
#include <retroshare/rsinit.h>
#include <retroshare/rspeers.h>
@ -92,36 +93,6 @@
#define ACTION_TAGS_TAG 1
#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
{
public:
@ -309,8 +280,10 @@ MessagesDialog::MessagesDialog(QWidget *parent)
ui.messagestreeView->setModel(proxyModel);
ui.messagestreeView->setSelectionBehavior(QTreeView::SelectRows);
QItemDelegate *pDelegate = new MessagesItemDelegate(this);
ui.messagestreeView->setItemDelegate(pDelegate);
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
itemDelegate->removeFocusRect(COLUMN_UNREAD);
itemDelegate->setSpacing(QSize(0, 2));
ui.messagestreeView->setItemDelegate(itemDelegate);
ui.messagestreeView->setRootIsDecorated(false);
ui.messagestreeView->setSortingEnabled(true);