FriendList:

- Added customize of columns with RSTreeWidget.
- Reduced display menu.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8583 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-07-09 20:53:28 +00:00
parent e8e02b9c79
commit c0ad7d3e46
6 changed files with 70 additions and 387 deletions

View File

@ -20,7 +20,7 @@ GUI
[X] http://www.cjoint.com/c/EFlhWgeLg4F. Strings too long in Add Friends Wizard on the conclusion page. [X] http://www.cjoint.com/c/EFlhWgeLg4F. Strings too long in Add Friends Wizard on the conclusion page.
[X] RS crashes when right clicking on the People tabs when there's nobody yet [X] RS crashes when right clicking on the People tabs when there's nobody yet
[ ] Network tab cannot shrink the avatar column [X] Network tab cannot shrink the avatar column
[X] newsfeed default: [X] newsfeed default:
Options -- Notify -- Feed Options -- Notify -- Feed
Security <-- Make as Default Enabled Security <-- Make as Default Enabled

View File

@ -142,11 +142,10 @@ QList<int> sizes;
// load settings // load settings
RsAutoUpdatePage::lockAllEvents(); RsAutoUpdatePage::lockAllEvents();
ui.friendList->setShowStatusColumn(false); ui.friendList->setColumnVisible(FriendList::COLUMN_STATE, false);
ui.friendList->setShowLastContactColumn(false); ui.friendList->setColumnVisible(FriendList::COLUMN_LAST_CONTACT, false);
ui.friendList->setShowAvatarColumn(true); ui.friendList->setColumnVisible(FriendList::COLUMN_AVATAR, true);
ui.friendList->setShowIPColumn(false); ui.friendList->setColumnVisible(FriendList::COLUMN_IP, false);
ui.friendList->setRootIsDecorated(true);
ui.friendList->setShowGroups(true); ui.friendList->setShowGroups(true);
processSettings(true); processSettings(true);
RsAutoUpdatePage::unlockAllEvents(); RsAutoUpdatePage::unlockAllEvents();

View File

@ -142,11 +142,10 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
// load settings // load settings
RsAutoUpdatePage::lockAllEvents(); RsAutoUpdatePage::lockAllEvents();
ui.friendList->setShowStatusColumn(false); ui.friendList->setColumnVisible(FriendList::COLUMN_STATE, false);
ui.friendList->setShowLastContactColumn(false); ui.friendList->setColumnVisible(FriendList::COLUMN_LAST_CONTACT, false);
ui.friendList->setShowAvatarColumn(true); ui.friendList->setColumnVisible(FriendList::COLUMN_AVATAR, true);
ui.friendList->setShowIPColumn(false); ui.friendList->setColumnVisible(FriendList::COLUMN_IP, false);
ui.friendList->setRootIsDecorated(true);
ui.friendList->setShowGroups(false); ui.friendList->setShowGroups(false);
processSettings(true); processSettings(true);
ui.friendList->setBigName(true); ui.friendList->setBigName(true);

View File

@ -77,13 +77,6 @@
#define IMAGE_PASTELINK ":/images/pasterslink.png" #define IMAGE_PASTELINK ":/images/pasterslink.png"
#define IMAGE_GROUP24 ":/images/user/group24.png" #define IMAGE_GROUP24 ":/images/user/group24.png"
#define COLUMN_COUNT 5
#define COLUMN_NAME 0
#define COLUMN_AVATAR 1
#define COLUMN_STATE 2
#define COLUMN_LAST_CONTACT 3
#define COLUMN_IP 4
#define COLUMN_DATA 0 // column for storing the userdata id #define COLUMN_DATA 0 // column for storing the userdata id
#define COLUMN_AVATAR_WIDTH 42 #define COLUMN_AVATAR_WIDTH 42
@ -143,21 +136,9 @@ FriendList::FriendList(QWidget *parent) :
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
connect(ui->actionHideOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setHideUnconnected(bool))); connect(ui->actionHideOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setHideUnconnected(bool)));
connect(ui->actionShowStatusColumn, SIGNAL(triggered(bool)), this, SLOT(setShowStatusColumn(bool)));
connect(ui->actionShowAvatarColumn, SIGNAL(triggered(bool)), this, SLOT(setShowAvatarColumn(bool)));
connect(ui->actionShowLastContactColumn, SIGNAL(triggered(bool)), this, SLOT(setShowLastContactColumn(bool)));
connect(ui->actionShowIPColumn, SIGNAL(triggered(bool)), this, SLOT(setShowIPColumn(bool)));
connect(ui->actionHideState, SIGNAL(triggered(bool)), this, SLOT(setHideState(bool))); connect(ui->actionHideState, SIGNAL(triggered(bool)), this, SLOT(setHideState(bool)));
connect(ui->actionRootIsDecorated, SIGNAL(triggered(bool)), this, SLOT(setRootIsDecorated(bool)));
connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool))); connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)));
connect(ui->actionSortByName, SIGNAL(triggered()), this, SLOT(setSortByName()));
connect(ui->actionSortByState, SIGNAL(triggered()), this, SLOT(setSortByState()));
connect(ui->actionSortByLastContact, SIGNAL(triggered()), this, SLOT(setSortByLastContact()));
connect(ui->actionSortByIP, SIGNAL(triggered()), this, SLOT(setSortByIP()));
connect(ui->actionSortPeersAscendingOrder, SIGNAL(triggered()), this, SLOT(sortPeersAscendingOrder()));
connect(ui->actionSortPeersDescendingOrder, SIGNAL(triggered()), this, SLOT(sortPeersDescendingOrder()));
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
ui->filterLineEdit->setPlaceholderText(tr("Search")) ; ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
@ -178,6 +159,10 @@ FriendList::FriendList(QWidget *parent) :
QShortcut *Shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->peerTreeWidget, 0, 0, Qt::WidgetShortcut); QShortcut *Shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->peerTreeWidget, 0, 0, Qt::WidgetShortcut);
connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend())); connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend()));
/* Initialize tree */
ui->peerTreeWidget->setColumnCustomizable(true);
connect(ui->peerTreeWidget, SIGNAL(columnVisibleChanged(int,bool)), this, SLOT(peerTreeColumnVisibleChanged(int,bool)));
/* Initialize display menu */ /* Initialize display menu */
createDisplayMenu(); createDisplayMenu();
} }
@ -202,31 +187,20 @@ void FriendList::addToolButton(QToolButton *toolButton)
ui->titleBarFrame->layout()->addWidget(toolButton); ui->titleBarFrame->layout()->addWidget(toolButton);
} }
void FriendList::processSettings(bool bLoad) void FriendList::processSettings(bool load)
{ {
int peerTreeVersion = 2; // version number for the settings to solve problems when modifying the column count // state of peer tree
ui->peerTreeWidget->processSettings(load);
if (bLoad) { if (load) {
// load settings // load settings
// state of peer tree
if (Settings->value("peerTreeVersion").toInt() == peerTreeVersion) {
ui->peerTreeWidget->header()->restoreState(Settings->value("peerTree").toByteArray());
}
// ui->peerTreeWidget->header()->doItemsLayout(); // is needed because I added a third column // ui->peerTreeWidget->header()->doItemsLayout(); // is needed because I added a third column
// restoreState would corrupt the internal sectionCount // restoreState would corrupt the internal sectionCount
// state of the columns
setShowStatusColumn(Settings->value("showStatusColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_STATE)).toBool());
setShowLastContactColumn(Settings->value("showLastContactColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_LAST_CONTACT)).toBool());
setShowIPColumn(Settings->value("showIPColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_IP)).toBool());
setShowAvatarColumn(Settings->value("showAvatarColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_AVATAR)).toBool());
// states // states
setHideUnconnected(Settings->value("hideUnconnected", mHideUnconnected).toBool()); setHideUnconnected(Settings->value("hideUnconnected", mHideUnconnected).toBool());
setHideState(Settings->value("hideState", mHideState).toBool()); setHideState(Settings->value("hideState", mHideState).toBool());
//setRootIsDecorated(Settings->value("rootIsDecorated", ui->peerTreeWidget->rootIsDecorated()).toBool());
setRootIsDecorated(true) ;
setShowGroups(Settings->value("showGroups", mShowGroups).toBool()); setShowGroups(Settings->value("showGroups", mShowGroups).toBool());
// open groups // open groups
@ -238,20 +212,10 @@ void FriendList::processSettings(bool bLoad)
Settings->endArray(); Settings->endArray();
initializeHeader(true); initializeHeader(true);
updateHeader(); peerTreeColumnVisibleChanged(COLUMN_STATE, !ui->peerTreeWidget->isColumnHidden(COLUMN_STATE));
} else { } else {
// save settings // save settings
// state of peer tree
Settings->setValue("peerTree", ui->peerTreeWidget->header()->saveState());
Settings->setValue("peerTreeVersion", peerTreeVersion);
// state of the columns
Settings->setValue("showStatusColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_STATE));
Settings->setValue("showLastContactColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_LAST_CONTACT));
Settings->setValue("showIPColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_IP));
Settings->setValue("showAvatarColumn", !ui->peerTreeWidget->isColumnHidden(COLUMN_AVATAR));
// states // states
Settings->setValue("hideUnconnected", mHideUnconnected); Settings->setValue("hideUnconnected", mHideUnconnected);
Settings->setValue("hideState", mHideState); Settings->setValue("hideState", mHideState);
@ -295,12 +259,8 @@ void FriendList::initializeHeader(bool /*afterLoadSettings*/)
QHeaderView_setSectionResizeModeColumn(header, COLUMN_LAST_CONTACT, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(header, COLUMN_LAST_CONTACT, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(header, COLUMN_IP, QHeaderView::Interactive); QHeaderView_setSectionResizeModeColumn(header, COLUMN_IP, QHeaderView::Interactive);
QHeaderView_setSectionResizeModeColumn(header, COLUMN_AVATAR, QHeaderView::Fixed); QHeaderView_setSectionResizeModeColumn(header, COLUMN_AVATAR, QHeaderView::Fixed);
header->setStretchLastSection(false);
/* if (!afterLoadSettings) {
header->resizeSection(COLUMN_NAME, 150);
header->resizeSection(COLUMN_LAST_CONTACT, 120);
}*/
header->resizeSection(COLUMN_NAME, 200);
header->resizeSection(COLUMN_AVATAR, COLUMN_AVATAR_WIDTH); header->resizeSection(COLUMN_AVATAR, COLUMN_AVATAR_WIDTH);
} }
@ -560,6 +520,7 @@ void FriendList::insertPeers()
bool isStatusColumnHidden = ui->peerTreeWidget->isColumnHidden(COLUMN_STATE); bool isStatusColumnHidden = ui->peerTreeWidget->isColumnHidden(COLUMN_STATE);
bool isAvatarColumnHidden = ui->peerTreeWidget->isColumnHidden(COLUMN_AVATAR); bool isAvatarColumnHidden = ui->peerTreeWidget->isColumnHidden(COLUMN_AVATAR);
int columnCount = ui->peerTreeWidget->columnCount();
std::list<StatusInfo> statusInfo; std::list<StatusInfo> statusInfo;
rsStatus->getStatusList(statusInfo); rsStatus->getStatusList(statusInfo);
@ -1035,7 +996,7 @@ void FriendList::insertPeers()
} }
sslItem -> setIcon(COLUMN_NAME, sslIcon); sslItem -> setIcon(COLUMN_NAME, sslIcon);
for (int i = 0; i < COLUMN_COUNT; ++i) { for (int i = 0; i < columnCount; ++i) {
sslItem -> setTextColor(i, sslColor); sslItem -> setTextColor(i, sslColor);
sslItem -> setFont(i, sslFont); sslItem -> setFont(i, sslFont);
} }
@ -1055,7 +1016,7 @@ void FriendList::insertPeers()
QColor textColor = mTextColorStatus[bestRSState]; QColor textColor = mTextColorStatus[bestRSState];
QFont font = StatusDefs::font(bestRSState); QFont font = StatusDefs::font(bestRSState);
for(int i = 0; i < COLUMN_COUNT; ++i) { for(int i = 0; i < columnCount; ++i) {
gpgItem->setTextColor(i, textColor); gpgItem->setTextColor(i, textColor);
gpgItem->setFont(i, font); gpgItem->setFont(i, font);
} }
@ -1090,7 +1051,7 @@ void FriendList::insertPeers()
QFont font; QFont font;
font.setBold(true); font.setBold(true);
QColor textColor = mTextColorStatus[RS_STATUS_ONLINE]; QColor textColor = mTextColorStatus[RS_STATUS_ONLINE];
for(int i = 0; i < COLUMN_COUNT; ++i) { for(int i = 0; i < columnCount; ++i) {
gpgItem->setTextColor(i, textColor); gpgItem->setTextColor(i, textColor);
gpgItem->setFont(i,font); gpgItem->setFont(i,font);
} }
@ -1107,7 +1068,7 @@ void FriendList::insertPeers()
QColor textColor = mTextColorStatus[RS_STATUS_OFFLINE]; QColor textColor = mTextColorStatus[RS_STATUS_OFFLINE];
QFont font = StatusDefs::font(RS_STATUS_OFFLINE); QFont font = StatusDefs::font(RS_STATUS_OFFLINE);
for(int i = 0; i < COLUMN_COUNT; ++i) { for(int i = 0; i < columnCount; ++i) {
gpgItem->setTextColor(i, textColor); gpgItem->setTextColor(i, textColor);
gpgItem->setFont(i, font); gpgItem->setFont(i, font);
} }
@ -1161,14 +1122,8 @@ void FriendList::insertPeers()
} }
} }
if (filterText.isEmpty() == false) { if (mFilterText.isEmpty() == false) {
filterItems(filterText); filterItems(mFilterText);
}
QTreeWidgetItem *c = getCurrentPeer();
if (c && c->isHidden()) {
// active item is hidden, deselect it
ui->peerTreeWidget->setCurrentItem(NULL);
} }
groupsHasChanged = false; groupsHasChanged = false;
@ -1721,56 +1676,35 @@ void FriendList::setHideUnconnected(bool hidden)
} }
} }
void FriendList::setShowStatusColumn(bool show) void FriendList::setColumnVisible(Column column, bool visible)
{ {
ui->actionHideState->setEnabled(!show); ui->peerTreeWidget->setColumnHidden(column, !visible);
bool isColumnVisible = !ui->peerTreeWidget->isColumnHidden(COLUMN_STATE); peerTreeColumnVisibleChanged(column, visible);
}
if (isColumnVisible != show) { void FriendList::sortByColumn(Column column, Qt::SortOrder sortOrder)
ui->peerTreeWidget->setColumnHidden(COLUMN_STATE, !show); {
ui->peerTreeWidget->sortByColumn(column, sortOrder);
}
updateHeader(); void FriendList::peerTreeColumnVisibleChanged(int column, bool visible)
{
switch (column) {
case COLUMN_NAME:
case COLUMN_AVATAR:
case COLUMN_LAST_CONTACT:
case COLUMN_IP:
break;
case COLUMN_STATE:
ui->actionHideState->setEnabled(!visible);
break;
}
if (visible) {
insertPeers(); insertPeers();
} }
} }
void FriendList::setShowLastContactColumn(bool show)
{
bool isColumnVisible = !ui->peerTreeWidget->isColumnHidden(COLUMN_LAST_CONTACT);
if (isColumnVisible != show) {
ui->peerTreeWidget->setColumnHidden(COLUMN_LAST_CONTACT, !show);
updateHeader();
insertPeers();
}
}
void FriendList::setShowIPColumn(bool show)
{
bool isColumnVisible = !ui->peerTreeWidget->isColumnHidden(COLUMN_IP);
if (isColumnVisible != show) {
ui->peerTreeWidget->setColumnHidden(COLUMN_IP, !show);
updateHeader();
insertPeers();
}
}
void FriendList::setShowAvatarColumn(bool show)
{
bool isColumnVisible = !ui->peerTreeWidget->isColumnHidden(COLUMN_AVATAR);
if (isColumnVisible == show)
return;
ui->peerTreeWidget->setColumnHidden(COLUMN_AVATAR, !show);
updateHeader();
initializeHeader(true);
insertPeers();
}
void FriendList::setHideState(bool hidden) void FriendList::setHideState(bool hidden)
{ {
if (mHideState != hidden) { if (mHideState != hidden) {
@ -1779,60 +1713,6 @@ void FriendList::setHideState(bool hidden)
} }
} }
/**
* Set the header visible.
*/
void FriendList::updateHeader()
{
if (ui->peerTreeWidget->isColumnHidden(COLUMN_STATE) \
&& ui->peerTreeWidget->isColumnHidden(COLUMN_LAST_CONTACT) \
&& ui->peerTreeWidget->isColumnHidden(COLUMN_IP)) {
ui->peerTreeWidget->setHeaderHidden(true);
initializeHeader(true);
} else {
ui->peerTreeWidget->setHeaderHidden(false);
}
}
void FriendList::setSortByName()
{
ui->peerTreeWidget->sortByColumn(COLUMN_NAME);
sortPeersAscendingOrder();
}
void FriendList::setSortByState()
{
ui->peerTreeWidget->sortByColumn(COLUMN_STATE);
sortPeersAscendingOrder();
}
void FriendList::setSortByLastContact()
{
ui->peerTreeWidget->sortByColumn(COLUMN_LAST_CONTACT);
sortPeersDescendingOrder();
}
void FriendList::setSortByIP()
{
ui->peerTreeWidget->sortByColumn(COLUMN_IP);
sortPeersDescendingOrder();
}
void FriendList::sortPeersAscendingOrder()
{
ui->peerTreeWidget->sortByColumn(ui->peerTreeWidget->sortColumn(), Qt::AscendingOrder);
}
void FriendList::sortPeersDescendingOrder()
{
ui->peerTreeWidget->sortByColumn(ui->peerTreeWidget->sortColumn(), Qt::DescendingOrder);
}
void FriendList::setRootIsDecorated(bool show)
{
ui->peerTreeWidget->setRootIsDecorated(show);
}
void FriendList::setShowGroups(bool show) void FriendList::setShowGroups(bool show)
{ {
if (mShowGroups != show) { if (mShowGroups != show) {
@ -1885,48 +1765,12 @@ void FriendList::setBigName(bool bigName)
} }
/** /**
* Hides all items that don't contain sPattern in the name column. * Hides all items that don't contain text in the name column.
*/ */
void FriendList::filterItems(const QString &text) void FriendList::filterItems(const QString &text)
{ {
filterText = text; mFilterText = text;
int count = ui->peerTreeWidget->topLevelItemCount(); ui->peerTreeWidget->filterItems(COLUMN_NAME, mFilterText);
for (int index = 0; index < count; ++index) {
FriendList::filterItem(ui->peerTreeWidget->topLevelItem(index), filterText);
}
QTreeWidgetItem *c = getCurrentPeer();
if (c && c->isHidden()) {
// active item is hidden, deselect it
ui->peerTreeWidget->setCurrentItem(NULL);
}
}
bool FriendList::filterItem(QTreeWidgetItem *item, const QString &text)
{
bool visible = true;
if (text.isEmpty() == false) {
if (item->text(0).contains(text, Qt::CaseInsensitive) == false) {
visible = false;
}
}
int visibleChildCount = 0;
int count = item->childCount();
for (int index = 0; index < count; ++index) {
if (FriendList::filterItem(item->child(index), text)) {
++visibleChildCount;
}
}
if (visible || visibleChildCount) {
item->setHidden(false);
} else {
item->setHidden(true);
}
return (visible || visibleChildCount);
} }
/** /**
@ -1958,56 +1802,16 @@ void FriendList::createDisplayMenu()
QMenu *displayMenu = new QMenu(this); QMenu *displayMenu = new QMenu(this);
connect(displayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); connect(displayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
// displayMenu->addAction(ui->actionSortPeersDescendingOrder);
// displayMenu->addAction(ui->actionSortPeersAscendingOrder);
QMenu *menu = displayMenu->addMenu(tr("Columns"));
menu->addAction(ui->actionShowAvatarColumn);
menu->addAction(ui->actionShowLastContactColumn);
menu->addAction(ui->actionShowIPColumn);
menu->addAction(ui->actionShowStatusColumn);
menu = displayMenu->addMenu(tr("Sort by"));
// menu->addAction(ui->actionSortByName);
menu->addAction(ui->actionSortByState);
// menu->addAction(ui->actionSortByLastContact);
// menu->addAction(ui->actionSortByIP);
displayMenu->addAction(ui->actionHideOfflineFriends); displayMenu->addAction(ui->actionHideOfflineFriends);
displayMenu->addAction(ui->actionHideState); displayMenu->addAction(ui->actionHideState);
// displayMenu->addAction(ui->actionRootIsDecorated);
displayMenu->addAction(ui->actionShowGroups); displayMenu->addAction(ui->actionShowGroups);
QActionGroup *group = new QActionGroup(this);
// group->addAction(ui->actionSortByName);
group->addAction(ui->actionSortByState);
// group->addAction(ui->actionSortByLastContact);
// group->addAction(ui->actionSortByIP);
ui->displayButton->setMenu(displayMenu); ui->displayButton->setMenu(displayMenu);
} }
void FriendList::updateMenu() void FriendList::updateMenu()
{ {
switch (ui->peerTreeWidget->sortColumn()) {
case COLUMN_NAME:
ui->actionSortByName->setChecked(true);
break;
case COLUMN_STATE:
ui->actionSortByState->setChecked(true);
break;
case COLUMN_LAST_CONTACT:
ui->actionSortByLastContact->setChecked(true);
break;
case COLUMN_IP:
ui->actionSortByIP->setChecked(true);
break;
case COLUMN_AVATAR:
break;
}
ui->actionShowStatusColumn->setChecked(!ui->peerTreeWidget->isColumnHidden(COLUMN_STATE));
ui->actionShowLastContactColumn->setChecked(!ui->peerTreeWidget->isColumnHidden(COLUMN_LAST_CONTACT));
ui->actionShowIPColumn->setChecked(!ui->peerTreeWidget->isColumnHidden(COLUMN_IP));
ui->actionShowAvatarColumn->setChecked(!ui->peerTreeWidget->isColumnHidden(COLUMN_AVATAR));
ui->actionHideOfflineFriends->setChecked(mHideUnconnected); ui->actionHideOfflineFriends->setChecked(mHideUnconnected);
ui->actionHideState->setChecked(mHideState); ui->actionHideState->setChecked(mHideState);
ui->actionRootIsDecorated->setChecked(ui->peerTreeWidget->rootIsDecorated());
ui->actionShowGroups->setChecked(mShowGroups); ui->actionShowGroups->setChecked(mShowGroups);
} }

View File

@ -48,13 +48,23 @@ class FriendList : public RsAutoUpdatePage
Q_PROPERTY(QColor textColorStatusOnline READ textColorStatusOnline WRITE setTextColorStatusOnline) Q_PROPERTY(QColor textColorStatusOnline READ textColorStatusOnline WRITE setTextColorStatusOnline)
Q_PROPERTY(QColor textColorStatusInactive READ textColorStatusInactive WRITE setTextColorStatusInactive) Q_PROPERTY(QColor textColorStatusInactive READ textColorStatusInactive WRITE setTextColorStatusInactive)
public:
enum Column
{
COLUMN_NAME = 0,
COLUMN_AVATAR = 1,
COLUMN_STATE = 2,
COLUMN_LAST_CONTACT = 3,
COLUMN_IP = 4
};
public: public:
explicit FriendList(QWidget *parent = 0); explicit FriendList(QWidget *parent = 0);
~FriendList(); ~FriendList();
// Add a tool button to the tool area // Add a tool button to the tool area
void addToolButton(QToolButton *toolButton); void addToolButton(QToolButton *toolButton);
void processSettings(bool bLoad); void processSettings(bool load);
void addGroupToExpand(const std::string &groupId); void addGroupToExpand(const std::string &groupId);
bool getExpandedGroups(std::set<std::string> &groups) const; bool getExpandedGroups(std::set<std::string> &groups) const;
void addPeerToExpand(const std::string &gpgId); void addPeerToExpand(const std::string &gpgId);
@ -63,6 +73,8 @@ public:
std::string getSelectedGroupId() const; std::string getSelectedGroupId() const;
virtual void updateDisplay(); virtual void updateDisplay();
void setColumnVisible(Column column, bool visible);
void sortByColumn(Column column, Qt::SortOrder sortOrder);
QColor textColorGroup() const { return mTextColorGroup; } QColor textColorGroup() const { return mTextColorGroup; }
QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; } QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; }
@ -85,17 +97,9 @@ public slots:
void setShowGroups(bool show); void setShowGroups(bool show);
void setHideUnconnected(bool hidden); void setHideUnconnected(bool hidden);
void setHideState(bool hidden); void setHideState(bool hidden);
void setShowStatusColumn(bool show);
void setShowLastContactColumn(bool show); private slots:
void setShowIPColumn(bool show); void peerTreeColumnVisibleChanged(int column, bool visible);
void setShowAvatarColumn(bool show);
void setRootIsDecorated(bool show);
void setSortByName();
void setSortByState();
void setSortByLastContact();
void setSortByIP();
void sortPeersAscendingOrder();
void sortPeersDescendingOrder();
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
@ -111,7 +115,7 @@ private:
bool mHideState; bool mHideState;
bool mHideUnconnected; bool mHideUnconnected;
QString filterText; QString mFilterText;
bool groupsHasChanged; bool groupsHasChanged;
std::set<std::string> *openGroups; std::set<std::string> *openGroups;
@ -122,8 +126,6 @@ private:
QColor mTextColorStatus[RS_STATUS_COUNT]; QColor mTextColorStatus[RS_STATUS_COUNT];
QTreeWidgetItem *getCurrentPeer() const; QTreeWidgetItem *getCurrentPeer() const;
static bool filterItem(QTreeWidgetItem *item, const QString &text);
void updateHeader();
void initializeHeader(bool afterLoadSettings); void initializeHeader(bool afterLoadSettings);
void getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &sslIds); void getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &sslIds);

View File

@ -71,7 +71,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTreeWidget" name="peerTreeWidget"> <widget class="RSTreeWidget" name="peerTreeWidget">
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
@ -87,9 +87,6 @@
<property name="indentation"> <property name="indentation">
<number>20</number> <number>20</number>
</property> </property>
<property name="itemsExpandable">
<bool>true</bool>
</property>
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -102,11 +99,8 @@
<property name="columnCount"> <property name="columnCount">
<number>5</number> <number>5</number>
</property> </property>
<attribute name="headerCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="headerStretchLastSection"> <attribute name="headerStretchLastSection">
<bool>true</bool> <bool>false</bool>
</attribute> </attribute>
<column> <column>
<property name="text"> <property name="text">
@ -144,25 +138,6 @@
<string>Hide Offline Friends</string> <string>Hide Offline Friends</string>
</property> </property>
</action> </action>
<action name="actionShowStatusColumn">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Status</string>
</property>
</action>
<action name="actionSortByState">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>State</string>
</property>
<property name="toolTip">
<string>Sort by State</string>
</property>
</action>
<action name="actionHideState"> <action name="actionHideState">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -174,85 +149,6 @@
<string>Hide State</string> <string>Hide State</string>
</property> </property>
</action> </action>
<action name="actionSortPeersDescendingOrder">
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/sort_decrease.png</normaloff>:/images/sort_decrease.png</iconset>
</property>
<property name="text">
<string>Sort Descending Order</string>
</property>
<property name="toolTip">
<string>Sort Descending Order</string>
</property>
</action>
<action name="actionSortPeersAscendingOrder">
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/sort_incr.png</normaloff>:/images/sort_incr.png</iconset>
</property>
<property name="text">
<string>Sort Ascending Order</string>
</property>
<property name="toolTip">
<string>Sort Ascending Order</string>
</property>
</action>
<action name="actionShowAvatarColumn">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Avatar</string>
</property>
<property name="toolTip">
<string>Show Avatar Column</string>
</property>
</action>
<action name="actionSortByName">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="toolTip">
<string>Sort by Name</string>
</property>
</action>
<action name="actionSortByLastContact">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Last Contact</string>
</property>
<property name="toolTip">
<string>Sort by last contact</string>
</property>
</action>
<action name="actionShowLastContactColumn">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Last Contact</string>
</property>
<property name="toolTip">
<string>Show Last Contact Column</string>
</property>
</action>
<action name="actionRootIsDecorated">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Set root is Decorated</string>
</property>
<property name="toolTip">
<string>Set Root Decorated</string>
</property>
</action>
<action name="actionShowGroups"> <action name="actionShowGroups">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -264,28 +160,6 @@
<string>Show Groups</string> <string>Show Groups</string>
</property> </property>
</action> </action>
<action name="actionSortByIP">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>IP</string>
</property>
<property name="toolTip">
<string>Sort by IP</string>
</property>
</action>
<action name="actionShowIPColumn">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>IP</string>
</property>
<property name="toolTip">
<string>Show IP Column</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
@ -293,6 +167,11 @@
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header> <header location="global">gui/common/LineEditClear.h</header>
</customwidget> </customwidget>
<customwidget>
<class>RSTreeWidget</class>
<extends>QTreeWidget</extends>
<header>gui/common/RSTreeWidget.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../images.qrc"/> <include location="../images.qrc"/>