mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
fixed colors in keyring with new ModelIndex based view (patch from sss)
This commit is contained in:
parent
acbcba8a64
commit
3007fec1b2
@ -58,18 +58,22 @@
|
||||
#define IMAGE_MESSAGE ":/images/mail_new.png"
|
||||
|
||||
/* Images for Status icons */
|
||||
#define IMAGE_AUTHED ":/images/accepted16.png"
|
||||
|
||||
//following defined in model
|
||||
/*#define IMAGE_AUTHED ":/images/accepted16.png"
|
||||
#define IMAGE_DENIED ":/images/denied16.png"
|
||||
#define IMAGE_TRUSTED ":/images/rs-2.png"
|
||||
#define IMAGE_TRUSTED ":/images/rs-2.png" */
|
||||
|
||||
// Defines for key list columns
|
||||
#define COLUMN_CHECK 0
|
||||
|
||||
//following defined in model
|
||||
/*#define COLUMN_CHECK 0
|
||||
#define COLUMN_PEERNAME 1
|
||||
#define COLUMN_I_AUTH_PEER 2
|
||||
#define COLUMN_PEER_AUTH_ME 3
|
||||
#define COLUMN_PEERID 4
|
||||
#define COLUMN_LAST_USED 5
|
||||
#define COLUMN_COUNT 6
|
||||
#define COLUMN_COUNT 6 */
|
||||
|
||||
//RsPeerId getNeighRsCertId(QTreeWidgetItem *i);
|
||||
|
||||
@ -77,12 +81,13 @@
|
||||
* #define NET_DEBUG 1
|
||||
*****/
|
||||
|
||||
static const unsigned int ROLE_SORT = Qt::UserRole + 1 ;
|
||||
//static const unsigned int ROLE_SORT = Qt::UserRole + 1 ;
|
||||
|
||||
/** Constructor */
|
||||
NetworkDialog::NetworkDialog(QWidget *parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
Q_UNUSED(parent);
|
||||
ui.setupUi(this);
|
||||
|
||||
connect( ui.filterLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterItems(QString)));
|
||||
@ -91,6 +96,7 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
||||
|
||||
//list data model
|
||||
float f = QFontMetricsF(font()).height()/14.0 ;
|
||||
|
||||
PGPIdItemModel = new pgpid_item_model(neighs, f, this);
|
||||
PGPIdItemProxy = new pgpid_item_proxy(this);
|
||||
connect(ui.onlyTrustedKeys, SIGNAL(toggled(bool)), PGPIdItemProxy, SLOT(use_only_trusted_keys(bool)));
|
||||
@ -105,11 +111,10 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
||||
ui.connectTreeWidget->setUpdatesEnabled(true);
|
||||
ui.connectTreeWidget->setSortingEnabled(true);
|
||||
ui.connectTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
ui.connectTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
connect(ui.connectTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connectTreeWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect(ui.connectTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(peerdetails()));
|
||||
|
||||
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
/* QHeaderView * _header = ui.connectTreeWidget->header () ;
|
||||
QHeaderView_setSectionResizeModeColumn(_header, COLUMN_CHECK, QHeaderView::Custom);
|
||||
@ -122,8 +127,6 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
||||
|
||||
ui.onlyTrustedKeys->setMinimumWidth(20*f);
|
||||
|
||||
|
||||
|
||||
/* QMenu *menu = new QMenu();
|
||||
menu->addAction(ui.actionTabsright);
|
||||
menu->addAction(ui.actionTabswest);
|
||||
@ -159,7 +162,9 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
|
||||
QModelIndexList l = ui.connectTreeWidget->selectionModel()->selection().indexes();
|
||||
if(l.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu *contextMnu = new QMenu;
|
||||
|
||||
|
@ -33,6 +33,7 @@ class QTreeWidgetItem;
|
||||
|
||||
class RSTreeWidgetItemCompareRole ;
|
||||
|
||||
|
||||
class NetworkDialog : public RsAutoUpdatePage
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -55,11 +56,11 @@ public:
|
||||
QColor backgroundColorHasSignedMe() const { return mBackgroundColorHasSignedMe; }
|
||||
QColor backgroundColorDenied() const { return mBackgroundColorDenied; }
|
||||
|
||||
void setBackgroundColorSelf(QColor color) { mBackgroundColorSelf = color; }
|
||||
void setBackgroundColorOwnSign(QColor color) { mBackgroundColorOwnSign = color; }
|
||||
void setBackgroundColorAcceptConnection(QColor color) { mBackgroundColorAcceptConnection = color; }
|
||||
void setBackgroundColorHasSignedMe(QColor color) { mBackgroundColorHasSignedMe = color; }
|
||||
void setBackgroundColorDenied(QColor color) { mBackgroundColorDenied = color; }
|
||||
void setBackgroundColorSelf(QColor color) { PGPIdItemModel->setBackgroundColorSelf(color); mBackgroundColorSelf = color; }
|
||||
void setBackgroundColorOwnSign(QColor color) { PGPIdItemModel->setBackgroundColorOwnSign(color); mBackgroundColorOwnSign = color; }
|
||||
void setBackgroundColorAcceptConnection(QColor color) { PGPIdItemModel->setBackgroundColorAcceptConnection(color); mBackgroundColorAcceptConnection = color; }
|
||||
void setBackgroundColorHasSignedMe(QColor color) { PGPIdItemModel->setBackgroundColorHasSignedMe(color); mBackgroundColorHasSignedMe = color; }
|
||||
void setBackgroundColorDenied(QColor color) { PGPIdItemModel->setBackgroundColorDenied(color); mBackgroundColorDenied = color; }
|
||||
|
||||
private:
|
||||
// void insertConnect();
|
||||
|
@ -2,10 +2,8 @@
|
||||
#include <time.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <QIcon>
|
||||
#include <QBrush>
|
||||
|
||||
#define IMAGE_AUTHED ":/images/accepted16.png"
|
||||
#define IMAGE_DENIED ":/images/denied16.png"
|
||||
#define IMAGE_TRUSTED ":/images/rs-2.png"
|
||||
|
||||
/*TODO:
|
||||
* using list here for internal data storage is not best option
|
||||
@ -151,6 +149,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
|
||||
}
|
||||
//we using editrole only where it is useful, for other data we use display, so no "else if" here
|
||||
if(role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
{
|
||||
switch(index.column())
|
||||
@ -261,23 +260,29 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
else if(role == Qt::BackgroundRole)
|
||||
{
|
||||
switch(index.column())
|
||||
if (detail.accept_connection)
|
||||
{
|
||||
default:
|
||||
{
|
||||
//TODO: add access to bckground colors from networkdialog
|
||||
if (detail.accept_connection)
|
||||
if (detail.ownsign)
|
||||
{
|
||||
if (detail.ownsign)
|
||||
;
|
||||
return QBrush(mBackgroundColorOwnSign);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QBrush(mBackgroundColorAcceptConnection);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
else
|
||||
{
|
||||
if (detail.hasSignedMe)
|
||||
{
|
||||
return QBrush(mBackgroundColorHasSignedMe);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QBrush(mBackgroundColorDenied);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -300,14 +305,14 @@ void pgpid_item_model::data_updated(std::list<RsPgpId> &new_neighs)
|
||||
//reflect actual row count in model
|
||||
if(old_size < new_size)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), old_size - 1, old_size - 1 + new_size - old_size);
|
||||
insertRows(old_size - 1 , new_size - old_size);
|
||||
beginInsertRows(QModelIndex(), old_size, new_size);
|
||||
insertRows(old_size, new_size - old_size);
|
||||
endInsertRows();
|
||||
}
|
||||
else if(new_size < old_size)
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), new_size - 1, new_size - 1 + old_size - new_size);
|
||||
removeRows(old_size - 1, old_size - new_size);
|
||||
beginRemoveRows(QModelIndex(), new_size, old_size);
|
||||
removeRows(old_size, old_size - new_size);
|
||||
endRemoveRows();
|
||||
}
|
||||
//update data in ui, to avoid unnecessary redraw and ui updates, updating only changed elements
|
||||
|
@ -3,6 +3,12 @@
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <QColor>
|
||||
|
||||
#define IMAGE_AUTHED ":/images/accepted16.png"
|
||||
#define IMAGE_DENIED ":/images/denied16.png"
|
||||
#define IMAGE_TRUSTED ":/images/rs-2.png"
|
||||
|
||||
|
||||
#define COLUMN_CHECK 0
|
||||
#define COLUMN_PEERNAME 1
|
||||
@ -29,12 +35,24 @@ public:
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void setBackgroundColorSelf(QColor color) { mBackgroundColorSelf = color; }
|
||||
void setBackgroundColorOwnSign(QColor color) { mBackgroundColorOwnSign = color; }
|
||||
void setBackgroundColorAcceptConnection(QColor color) { mBackgroundColorAcceptConnection = color; }
|
||||
void setBackgroundColorHasSignedMe(QColor color) { mBackgroundColorHasSignedMe = color; }
|
||||
void setBackgroundColorDenied(QColor color) { mBackgroundColorDenied = color; }
|
||||
|
||||
|
||||
public slots:
|
||||
void data_updated(std::list<RsPgpId> &new_neighs);
|
||||
|
||||
private:
|
||||
std::list<RsPgpId> &neighs;
|
||||
float &font_height;
|
||||
float font_height;
|
||||
QColor mBackgroundColorSelf;
|
||||
QColor mBackgroundColorOwnSign;
|
||||
QColor mBackgroundColorAcceptConnection;
|
||||
QColor mBackgroundColorHasSignedMe;
|
||||
QColor mBackgroundColorDenied;
|
||||
};
|
||||
|
||||
#endif // KEY_ITEM_MODEL_H
|
||||
|
Loading…
Reference in New Issue
Block a user