mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
merging before commit
This commit is contained in:
commit
4309642d14
@ -79,7 +79,6 @@
|
|||||||
#define IMAGE_GROUP24 ":/images/user/group24.png"
|
#define IMAGE_GROUP24 ":/images/user/group24.png"
|
||||||
|
|
||||||
#define COLUMN_DATA 0 // column for storing the userdata id
|
#define COLUMN_DATA 0 // column for storing the userdata id
|
||||||
#define COLUMN_SORT COLUMN_NAME // column for sorting
|
|
||||||
|
|
||||||
#define ROLE_ID Qt::UserRole
|
#define ROLE_ID Qt::UserRole
|
||||||
#define ROLE_STANDARD Qt::UserRole + 1
|
#define ROLE_STANDARD Qt::UserRole + 1
|
||||||
@ -130,16 +129,19 @@ FriendList::FriendList(QWidget *parent) :
|
|||||||
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)));
|
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(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->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")) ;
|
||||||
ui->filterLineEdit->showFilterIcon();
|
ui->filterLineEdit->showFilterIcon();
|
||||||
|
|
||||||
|
mActionSortByState = new QAction(tr("Sort by state"), this);
|
||||||
|
mActionSortByState->setCheckable(true);
|
||||||
|
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool)));
|
||||||
|
ui->peerTreeWidget->addHeaderContextMenuAction(mActionSortByState);
|
||||||
|
|
||||||
/* Set sort */
|
/* Set sort */
|
||||||
setSortMode(SORT_MODE_NAME);
|
sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
|
||||||
|
sortByState(false);
|
||||||
|
|
||||||
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
||||||
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
||||||
@ -191,7 +193,7 @@ void FriendList::addToolButton(QToolButton *toolButton)
|
|||||||
void FriendList::processSettings(bool load)
|
void FriendList::processSettings(bool load)
|
||||||
{
|
{
|
||||||
// state of peer tree
|
// state of peer tree
|
||||||
ui->peerTreeWidget->setSettingsVersion(1);
|
ui->peerTreeWidget->setSettingsVersion(2);
|
||||||
ui->peerTreeWidget->processSettings(load);
|
ui->peerTreeWidget->processSettings(load);
|
||||||
|
|
||||||
if (load) {
|
if (load) {
|
||||||
@ -206,7 +208,7 @@ void FriendList::processSettings(bool load)
|
|||||||
setShowGroups(Settings->value("showGroups", mShowGroups).toBool());
|
setShowGroups(Settings->value("showGroups", mShowGroups).toBool());
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
setSortMode((SortMode) Settings->value("sortMode", SORT_MODE_NAME).toInt());
|
sortByState(Settings->value("sortByState", isSortByState()).toBool());
|
||||||
|
|
||||||
// open groups
|
// open groups
|
||||||
int arrayIndex = Settings->beginReadArray("Groups");
|
int arrayIndex = Settings->beginReadArray("Groups");
|
||||||
@ -224,7 +226,7 @@ void FriendList::processSettings(bool load)
|
|||||||
Settings->setValue("showGroups", mShowGroups);
|
Settings->setValue("showGroups", mShowGroups);
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
Settings->setValue("sortMode", sortMode());
|
Settings->setValue("sortByState", isSortByState());
|
||||||
|
|
||||||
// open groups
|
// open groups
|
||||||
Settings->beginWriteArray("Groups");
|
Settings->beginWriteArray("Groups");
|
||||||
@ -687,9 +689,11 @@ void FriendList::insertPeers()
|
|||||||
groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false);
|
groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false);
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_GROUP, 1);
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? 0 : 1);
|
groupItem->setData(i, ROLE_SORT_GROUP, 1);
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_STATE, 0);
|
groupItem->setData(i, ROLE_SORT_STANDARD_GROUP, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? 0 : 1);
|
||||||
|
groupItem->setData(i, ROLE_SORT_STATE, 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// remove all gpg items that are not more assigned
|
// remove all gpg items that are not more assigned
|
||||||
int childCount = groupItem->childCount();
|
int childCount = groupItem->childCount();
|
||||||
@ -786,9 +790,10 @@ void FriendList::insertPeers()
|
|||||||
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
|
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_GROUP, 2);
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
// show first the standard groups, than the user groups
|
gpgItem->setData(i, ROLE_SORT_GROUP, 2);
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP, 1);
|
gpgItem->setData(i, ROLE_SORT_STANDARD_GROUP, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++availableCount;
|
++availableCount;
|
||||||
@ -860,8 +865,10 @@ void FriendList::insertPeers()
|
|||||||
gpgItem->addChild(sslItem);
|
gpgItem->addChild(sslItem);
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_GROUP, 2);
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP, 1);
|
sslItem->setData(i, ROLE_SORT_GROUP, 2);
|
||||||
|
sslItem->setData(i, ROLE_SORT_STANDARD_GROUP, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not displayed, used to find back the item */
|
/* not displayed, used to find back the item */
|
||||||
@ -879,6 +886,7 @@ void FriendList::insertPeers()
|
|||||||
/* last contact */
|
/* last contact */
|
||||||
QDateTime sslLastContact = QDateTime::fromTime_t(sslDetail.lastConnect);
|
QDateTime sslLastContact = QDateTime::fromTime_t(sslDetail.lastConnect);
|
||||||
sslItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, QVariant(sslLastContact));
|
sslItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, QVariant(sslLastContact));
|
||||||
|
sslItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, QVariant(sslLastContact));
|
||||||
if (sslLastContact > bestLastContact) {
|
if (sslLastContact > bestLastContact) {
|
||||||
bestLastContact = sslLastContact;
|
bestLastContact = sslLastContact;
|
||||||
}
|
}
|
||||||
@ -886,6 +894,7 @@ void FriendList::insertPeers()
|
|||||||
/* IP */
|
/* IP */
|
||||||
QString sslIP = (sslDetail.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(sslDetail) : QString("---");
|
QString sslIP = (sslDetail.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(sslDetail) : QString("---");
|
||||||
sslItem->setText(COLUMN_IP, sslIP);
|
sslItem->setText(COLUMN_IP, sslIP);
|
||||||
|
sslItem->setData(COLUMN_IP, ROLE_SORT_NAME, sslIP);
|
||||||
|
|
||||||
/* change color and icon */
|
/* change color and icon */
|
||||||
QPixmap sslOverlayIcon;
|
QPixmap sslOverlayIcon;
|
||||||
@ -1044,10 +1053,11 @@ void FriendList::insertPeers()
|
|||||||
sslItem->setIcon(COLUMN_NAME, createAvatar(sslAvatar, sslOverlayIcon));
|
sslItem->setIcon(COLUMN_NAME, createAvatar(sslAvatar, sslOverlayIcon));
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_NAME, sslName);
|
sslItem->setData(COLUMN_NAME, ROLE_SORT_NAME, sslName);
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_STATE, peerState);
|
|
||||||
|
|
||||||
for (int i = 0; i < columnCount; ++i) {
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
|
sslItem->setData(i, ROLE_SORT_STATE, peerState);
|
||||||
|
|
||||||
sslItem->setTextColor(i, sslColor);
|
sslItem->setTextColor(i, sslColor);
|
||||||
sslItem->setFont(i, sslFont);
|
sslItem->setFont(i, sslFont);
|
||||||
}
|
}
|
||||||
@ -1147,13 +1157,16 @@ void FriendList::insertPeers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
gpgItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, showInfoAtGpgItem ? QVariant(bestLastContact) : "");
|
gpgItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, showInfoAtGpgItem ? QVariant(bestLastContact) : "");
|
||||||
|
gpgItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, showInfoAtGpgItem ? QVariant(bestLastContact) : "");
|
||||||
gpgItem->setText(COLUMN_IP, showInfoAtGpgItem ? bestIP : "");
|
gpgItem->setText(COLUMN_IP, showInfoAtGpgItem ? bestIP : "");
|
||||||
|
gpgItem->setData(COLUMN_IP, ROLE_SORT_NAME, showInfoAtGpgItem ? bestIP : "");
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_NAME, gpgName);
|
gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, gpgName);
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_STATE, bestPeerState);
|
|
||||||
|
|
||||||
for (int i = 0; i < columnCount; ++i) {
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
|
gpgItem->setData(i, ROLE_SORT_STATE, bestPeerState);
|
||||||
|
|
||||||
gpgItem->setTextColor(i, gpgColor);
|
gpgItem->setTextColor(i, gpgColor);
|
||||||
gpgItem->setFont(i, gpgFont);
|
gpgItem->setFont(i, gpgFont);
|
||||||
}
|
}
|
||||||
@ -1173,7 +1186,7 @@ void FriendList::insertPeers()
|
|||||||
groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(groupName).arg(onlineCount).arg(availableCount));
|
groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(groupName).arg(onlineCount).arg(availableCount));
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_NAME, groupName);
|
groupItem->setData(COLUMN_NAME, ROLE_SORT_NAME, groupName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1199,7 +1212,7 @@ void FriendList::insertPeers()
|
|||||||
openPeers = NULL;
|
openPeers = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->peerTreeWidget->sortItems(COLUMN_SORT, Qt::AscendingOrder);
|
ui->peerTreeWidget->resort();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1745,6 +1758,11 @@ void FriendList::setColumnVisible(Column column, bool visible)
|
|||||||
peerTreeColumnVisibleChanged(column, visible);
|
peerTreeColumnVisibleChanged(column, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FriendList::sortByColumn(Column column, Qt::SortOrder sortOrder)
|
||||||
|
{
|
||||||
|
ui->peerTreeWidget->sortByColumn(column, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
void FriendList::peerTreeColumnVisibleChanged(int /*column*/, bool visible)
|
void FriendList::peerTreeColumnVisibleChanged(int /*column*/, bool visible)
|
||||||
{
|
{
|
||||||
if (visible) {
|
if (visible) {
|
||||||
@ -1771,49 +1789,30 @@ void FriendList::setShowState(bool show)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendList::setSortByName()
|
void FriendList::sortByState(bool sort)
|
||||||
{
|
{
|
||||||
setSortMode(SORT_MODE_NAME);
|
int columnCount = ui->peerTreeWidget->columnCount();
|
||||||
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
|
mCompareRole->setRole(i, ROLE_SORT_GROUP);
|
||||||
|
mCompareRole->addRole(i, ROLE_SORT_STANDARD_GROUP);
|
||||||
|
|
||||||
|
if (sort) {
|
||||||
|
mCompareRole->addRole(i, ROLE_SORT_STATE);
|
||||||
|
mCompareRole->addRole(i, ROLE_SORT_NAME);
|
||||||
|
} else {
|
||||||
|
mCompareRole->addRole(i, ROLE_SORT_NAME);
|
||||||
|
mCompareRole->addRole(i, ROLE_SORT_STATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendList::setSortByState()
|
mActionSortByState->setChecked(sort);
|
||||||
|
|
||||||
|
ui->peerTreeWidget->resort();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FriendList::isSortByState()
|
||||||
{
|
{
|
||||||
setSortMode(SORT_MODE_STATE);
|
return mActionSortByState->isChecked();
|
||||||
}
|
|
||||||
|
|
||||||
void FriendList::setSortMode(SortMode sortMode)
|
|
||||||
{
|
|
||||||
// Add changes also in FriendList::sortMode
|
|
||||||
mCompareRole->setRole(COLUMN_SORT, ROLE_SORT_GROUP);
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP);
|
|
||||||
|
|
||||||
switch (sortMode) {
|
|
||||||
case SORT_MODE_STATE:
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_STATE);
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_NAME);
|
|
||||||
break;
|
|
||||||
default: // SORT_MODE_NAME
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_NAME);
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_STATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->peerTreeWidget->sortItems(COLUMN_SORT, Qt::AscendingOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
FriendList::SortMode FriendList::sortMode()
|
|
||||||
{
|
|
||||||
QList<int> roles;
|
|
||||||
mCompareRole->findRoles(COLUMN_SORT, roles);
|
|
||||||
if (roles.count() == 4) {
|
|
||||||
switch (roles.at(2)) {
|
|
||||||
case ROLE_SORT_NAME:
|
|
||||||
return SORT_MODE_NAME;
|
|
||||||
case ROLE_SORT_STATE:
|
|
||||||
return SORT_MODE_STATE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return SORT_MODE_NAME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendList::setShowGroups(bool show)
|
void FriendList::setShowGroups(bool show)
|
||||||
@ -1876,14 +1875,6 @@ 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()));
|
||||||
|
|
||||||
QActionGroup *actionGroup = new QActionGroup(displayMenu);
|
|
||||||
|
|
||||||
QMenu *menu = displayMenu->addMenu(tr("Sort by"));
|
|
||||||
menu->addAction(ui->actionSortByName);
|
|
||||||
ui->actionSortByName->setActionGroup(actionGroup);
|
|
||||||
menu->addAction(ui->actionSortByState);
|
|
||||||
ui->actionSortByState->setActionGroup(actionGroup);
|
|
||||||
|
|
||||||
displayMenu->addAction(ui->actionHideOfflineFriends);
|
displayMenu->addAction(ui->actionHideOfflineFriends);
|
||||||
displayMenu->addAction(ui->actionShowState);
|
displayMenu->addAction(ui->actionShowState);
|
||||||
displayMenu->addAction(ui->actionShowGroups);
|
displayMenu->addAction(ui->actionShowGroups);
|
||||||
@ -1896,14 +1887,4 @@ void FriendList::updateMenu()
|
|||||||
ui->actionHideOfflineFriends->setChecked(mHideUnconnected);
|
ui->actionHideOfflineFriends->setChecked(mHideUnconnected);
|
||||||
ui->actionShowState->setChecked(mShowState);
|
ui->actionShowState->setChecked(mShowState);
|
||||||
ui->actionShowGroups->setChecked(mShowGroups);
|
ui->actionShowGroups->setChecked(mShowGroups);
|
||||||
ui->actionSortByName->setChecked(true);
|
|
||||||
|
|
||||||
switch (sortMode()) {
|
|
||||||
case SORT_MODE_NAME:
|
|
||||||
ui->actionSortByName->setChecked(true);
|
|
||||||
break;
|
|
||||||
case SORT_MODE_STATE:
|
|
||||||
ui->actionSortByState->setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,6 @@ public:
|
|||||||
COLUMN_IP = 2
|
COLUMN_IP = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SortMode
|
|
||||||
{
|
|
||||||
SORT_MODE_NAME = 1,
|
|
||||||
SORT_MODE_STATE = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FriendList(QWidget *parent = 0);
|
explicit FriendList(QWidget *parent = 0);
|
||||||
~FriendList();
|
~FriendList();
|
||||||
@ -79,8 +73,8 @@ public:
|
|||||||
virtual void updateDisplay();
|
virtual void updateDisplay();
|
||||||
void setColumnVisible(Column column, bool visible);
|
void setColumnVisible(Column column, bool visible);
|
||||||
|
|
||||||
void setSortMode(SortMode sortMode);
|
void sortByColumn(Column column, Qt::SortOrder sortOrder);
|
||||||
SortMode sortMode();
|
bool isSortByState();
|
||||||
|
|
||||||
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]; }
|
||||||
@ -98,8 +92,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void filterItems(const QString &text);
|
void filterItems(const QString &text);
|
||||||
void setSortByName();
|
void sortByState(bool sort);
|
||||||
void setSortByState();
|
|
||||||
|
|
||||||
void setShowGroups(bool show);
|
void setShowGroups(bool show);
|
||||||
void setHideUnconnected(bool hidden);
|
void setHideUnconnected(bool hidden);
|
||||||
@ -116,6 +109,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Ui::FriendList *ui;
|
Ui::FriendList *ui;
|
||||||
RSTreeWidgetItemCompareRole *mCompareRole;
|
RSTreeWidgetItemCompareRole *mCompareRole;
|
||||||
|
QAction *mActionSortByState;
|
||||||
|
|
||||||
// Settings for peer list display
|
// Settings for peer list display
|
||||||
bool mShowGroups;
|
bool mShowGroups;
|
||||||
|
@ -75,6 +75,9 @@
|
|||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="allColumnsShowFocus">
|
<property name="allColumnsShowFocus">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -116,28 +119,6 @@
|
|||||||
<string>Hide Offline Friends</string>
|
<string>Hide Offline Friends</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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="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="actionShowState">
|
<action name="actionShowState">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -107,7 +107,7 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
|||||||
mCompareRole = new RSTreeWidgetItemCompareRole;
|
mCompareRole = new RSTreeWidgetItemCompareRole;
|
||||||
mActionSortByState = new QAction(tr("Sort by state"), this);
|
mActionSortByState = new QAction(tr("Sort by state"), this);
|
||||||
mActionSortByState->setCheckable(true);
|
mActionSortByState->setCheckable(true);
|
||||||
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(setSortByState(bool)));
|
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool)));
|
||||||
ui->friendList->addHeaderContextMenuAction(mActionSortByState);
|
ui->friendList->addHeaderContextMenuAction(mActionSortByState);
|
||||||
|
|
||||||
/* initialize list */
|
/* initialize list */
|
||||||
@ -116,7 +116,7 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
|||||||
|
|
||||||
/* sort list by name ascending */
|
/* sort list by name ascending */
|
||||||
ui->friendList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
|
ui->friendList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
|
||||||
setSortByState(false);
|
sortByState(false);
|
||||||
|
|
||||||
ui->filterLineEdit->setPlaceholderText(tr("Search Friends"));
|
ui->filterLineEdit->setPlaceholderText(tr("Search Friends"));
|
||||||
ui->filterLineEdit->showFilterIcon();
|
ui->filterLineEdit->showFilterIcon();
|
||||||
@ -1087,28 +1087,25 @@ std::string FriendSelectionWidget::idFromItem(QTreeWidgetItem *item)
|
|||||||
return item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
return item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::setSortByState(bool sort)
|
void FriendSelectionWidget::sortByState(bool sort)
|
||||||
{
|
{
|
||||||
// Add changes also in FriendSelectionWidget::sortByState
|
|
||||||
mCompareRole->setRole(COLUMN_NAME, ROLE_SORT_GROUP);
|
mCompareRole->setRole(COLUMN_NAME, ROLE_SORT_GROUP);
|
||||||
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP);
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP);
|
||||||
|
|
||||||
if (sort) {
|
if (sort) {
|
||||||
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STATE);
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STATE);
|
||||||
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_NAME);
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_NAME);
|
||||||
|
|
||||||
mActionSortByState->setChecked(true);
|
|
||||||
} else {
|
} else {
|
||||||
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_NAME);
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_NAME);
|
||||||
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STATE);
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STATE);
|
||||||
|
|
||||||
mActionSortByState->setChecked(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mActionSortByState->setChecked(sort);
|
||||||
|
|
||||||
ui->friendList->resort();
|
ui->friendList->resort();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FriendSelectionWidget::sortByState()
|
bool FriendSelectionWidget::isSortByState()
|
||||||
{
|
{
|
||||||
return mActionSortByState->isChecked();
|
return mActionSortByState->isChecked();
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public:
|
|||||||
int addColumn(const QString &title);
|
int addColumn(const QString &title);
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
bool sortByState();
|
bool isSortByState();
|
||||||
|
|
||||||
int selectedItemCount();
|
int selectedItemCount();
|
||||||
std::string selectedId(IdType &idType);
|
std::string selectedId(IdType &idType);
|
||||||
@ -128,7 +128,7 @@ signals:
|
|||||||
void itemSelectionChanged();
|
void itemSelectionChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setSortByState(bool sort);
|
void sortByState(bool sort);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void groupsChanged(int type);
|
void groupsChanged(int type);
|
||||||
|
Loading…
Reference in New Issue
Block a user