Added the state column in PeersDialog again. Now you can choose to show the state in an own column or behind the name.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3919 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-12-18 01:45:32 +00:00
parent dac49e9bfc
commit d3a6f7316c
5 changed files with 131 additions and 70 deletions

View File

@ -94,15 +94,15 @@
#define IMAGE_NEWSFEED ""
#define IMAGE_NEWSFEED_NEW ":/images/message-state-new.png"
#define COLUMN_COUNT 1
#define COLUMN_COUNT 2
#define COLUMN_NAME 0
#define COLUMN_STATE 1
#define COLUMN_DATA 0 // column for storing the userdata id
#define ROLE_SORT_NAME Qt::UserRole
#define ROLE_SORT_STATUS Qt::UserRole + 1
#define ROLE_ID Qt::UserRole + 2
#define ROLE_STANDARD Qt::UserRole + 3
#define ROLE_SORT Qt::UserRole
#define ROLE_ID Qt::UserRole + 1
#define ROLE_STANDARD Qt::UserRole + 2
#define TYPE_GPG 0
#define TYPE_SSL 1
@ -124,11 +124,13 @@ PeersDialog::PeersDialog(QWidget *parent)
groupsHasChanged = false;
m_compareRole = new RSTreeWidgetItemCompareRole;
m_compareRole->setRole(COLUMN_NAME, ROLE_SORT_NAME);
m_compareRole->setRole(COLUMN_NAME, ROLE_SORT);
m_compareRole->setRole(COLUMN_STATE, ROLE_SORT);
connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
connect( ui.peertreeWidget->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(peerSortIndicatorChanged(int,Qt::SortOrder)));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int)));
connect( ui.avatartoolButton, SIGNAL(clicked()), SLOT(getAvatar()));
@ -139,7 +141,8 @@ PeersDialog::PeersDialog(QWidget *parent)
connect(ui.actionAdd_Friend, SIGNAL(triggered()), this, SLOT(addFriend()));
connect(ui.action_Hide_Offline_Friends, SIGNAL(triggered()), this, SLOT(insertPeers()));
connect(ui.action_Sort_by_State, SIGNAL(triggered()), this, SLOT(sortByState()));
connect(ui.action_Hide_Status_Column, SIGNAL(triggered()), this, SLOT(setStateColumn()));
connect(ui.action_Sort_by_State, SIGNAL(triggered()), this, SLOT(setStateColumn()));
connect(ui.actionSort_Peers_Ascending_Order, SIGNAL(triggered()), this, SLOT(sortPeersAscendingOrder()));
connect(ui.actionSort_Peers_Descending_Order, SIGNAL(triggered()), this, SLOT(sortPeersDescendingOrder()));
@ -161,6 +164,9 @@ PeersDialog::PeersDialog(QWidget *parent)
// set header text aligment
QTreeWidgetItem * headerItem = ui.peertreeWidget->headerItem();
headerItem->setTextAlignment(COLUMN_NAME, Qt::AlignHCenter | Qt::AlignVCenter);
headerItem->setTextAlignment(COLUMN_STATE, Qt::AlignLeft | Qt::AlignVCenter);
wasStatusColumnHidden = ui.peertreeWidget->isColumnHidden(COLUMN_STATE);
connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));
@ -229,6 +235,8 @@ PeersDialog::PeersDialog(QWidget *parent)
// load settings
processSettings(true);
ui.peertreeWidget->header()->setStretchLastSection(true);
// workaround for Qt bug, should be solved in next Qt release 4.7.0
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.peertreeWidget, 0, 0, Qt::WidgetShortcut);
@ -269,14 +277,17 @@ void PeersDialog::processSettings(bool bLoad)
// state of peer tree
header->restoreState(Settings->value("PeerTree").toByteArray());
wasStatusColumnHidden = ui.peertreeWidget->isColumnHidden(COLUMN_STATE);
// state of hideUnconnected
ui.action_Hide_Offline_Friends->setChecked(Settings->value("hideUnconnected", false).toBool());
// state of the status
ui.action_Sort_by_State->setChecked(Settings->value("sortByState", false).toBool());
ui.action_Hide_State->setChecked(Settings->value("hideState", false).toBool());
// state of hideStatusColumn
ui.action_Hide_Status_Column->setChecked(Settings->value("hideStatusColumn", false).toBool());
// state of splitter
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
ui.splitter_2->restoreState(Settings->value("GroupChatSplitter").toByteArray());
@ -290,7 +301,7 @@ void PeersDialog::processSettings(bool bLoad)
}
Settings->endArray();
sortByState();
setStateColumn();
} else {
// save settings
@ -301,9 +312,11 @@ void PeersDialog::processSettings(bool bLoad)
Settings->setValue("hideUnconnected", ui.action_Hide_Offline_Friends->isChecked());
// state of the status
Settings->setValue("sortByState", ui.action_Sort_by_State->isChecked());
Settings->setValue("hideState", ui.action_Hide_State->isChecked());
// state of hideStatusColumn
Settings->setValue("hideStatusColumn", ui.action_Hide_Status_Column->isChecked());
// state of splitter
Settings->setValue("Splitter", ui.splitter->saveState());
Settings->setValue("GroupChatSplitter", ui.splitter_2->saveState());
@ -575,7 +588,8 @@ void PeersDialog::insertPeers()
}
bool hideUnconnected = ui.action_Hide_Offline_Friends->isChecked();
bool hideState = ui.action_Hide_State->isChecked();
bool useStatusColumn = !ui.action_Hide_Status_Column->isChecked();
bool showState = !ui.action_Hide_State->isChecked();
// get ids of existing private chat messages
std::list<std::string> privateChatIds;
@ -886,14 +900,18 @@ void PeersDialog::insertPeers()
if (customStateString.isEmpty() == false) {
sText += " - " + customStateString;
}
if (hideState == false && sslDetail.autoconnect.empty() == false) {
sText += " [" + QString::fromStdString(sslDetail.autoconnect) + "]";
if (sslDetail.autoconnect.empty() == false) {
if (useStatusColumn) {
sslItem->setText(COLUMN_STATE, QString::fromStdString(sslDetail.autoconnect));
} else if (showState) {
sText += " [" + QString::fromStdString(sslDetail.autoconnect) + "]";
}
}
sslItem->setText( COLUMN_NAME, sText);
sslItem->setToolTip( COLUMN_NAME, sText);
// sort location
sslItem->setData(COLUMN_NAME, ROLE_SORT_STATUS, sText);
sslItem->setData(COLUMN_STATE, ROLE_SORT, sText);
/* change color and icon */
QIcon sslIcon;
@ -1011,19 +1029,26 @@ void PeersDialog::insertPeers()
gpgIcon = QIcon(StatusDefs::imageUser(bestRSState));
gpgItem->setToolTip(COLUMN_NAME, StatusDefs::tooltip(bestRSState));
gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATUS, BuildStateSortString(true, gpgItemText, bestPeerState));
if (hideState == false) {
if (useStatusColumn) {
gpgItem->setText(COLUMN_STATE, StatusDefs::name(bestRSState));
} else if (showState) {
gpgItemText += " [" + StatusDefs::name(bestRSState) + "]";
}
gpgItem->setToolTip(COLUMN_NAME, StatusDefs::tooltip(bestRSState));
gpgItem->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(true, gpgItemText, bestPeerState));
gpgItem->setData(COLUMN_STATE, ROLE_SORT, BuildStateSortString(true, gpgItem->text(COLUMN_NAME), bestPeerState));
} else if (gpg_online) {
if (useStatusColumn) {
gpgItem->setText(COLUMN_STATE, tr("Available"));
} else if (showState) {
gpgItemText += " [" + tr("Available") + "]";
}
onlineCount++;
gpgItem->setHidden(hideUnconnected);
gpgIcon = QIcon(IMAGE_AVAILABLE);
gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATUS, BuildStateSortString(true, gpgItemText, PEER_STATE_AVAILABLE));
if (hideState == false) {
gpgItemText += " [" + tr("Available") + "]";
}
gpgItem->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(true, gpgItemText, PEER_STATE_AVAILABLE));
QFont font;
font.setBold(true);
@ -1032,12 +1057,15 @@ void PeersDialog::insertPeers()
gpgItem->setFont(i,font);
}
} else {
if (useStatusColumn) {
gpgItem->setText(COLUMN_STATE, StatusDefs::name(RS_STATUS_OFFLINE));
} else if (showState) {
gpgItemText += " [" + StatusDefs::name(RS_STATUS_OFFLINE) + "]";
}
gpgItem->setHidden(hideUnconnected);
gpgIcon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE));
gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATUS, BuildStateSortString(true, gpgItemText, PEER_STATE_OFFLINE));
if (hideState == false) {
gpgItemText += " [" + StatusDefs::name(RS_STATUS_OFFLINE) + "]";
}
gpgItem->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(true, gpgItemText, PEER_STATE_OFFLINE));
QColor textColor = StatusDefs::textColor(RS_STATUS_OFFLINE);
QFont font = StatusDefs::font(RS_STATUS_OFFLINE);
@ -1052,7 +1080,7 @@ void PeersDialog::insertPeers()
}
gpgItem->setText(COLUMN_NAME, gpgItemText);
gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, "2 " + gpgItemText);
gpgItem->setData(COLUMN_NAME, ROLE_SORT, "2 " + gpgItemText);
gpgItem->setIcon(COLUMN_NAME, gpgIcon);
}
@ -1064,7 +1092,7 @@ void PeersDialog::insertPeers()
QString groupName = GroupDefs::name(*groupInfo);
groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(groupName).arg(onlineCount).arg(availableCount));
// show first the standard groups, than the user groups
groupItem->setData(COLUMN_NAME, ROLE_SORT_NAME, ((groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? "0 " : "1 ") + groupName);
groupItem->setData(COLUMN_NAME, ROLE_SORT, ((groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? "0 " : "1 ") + groupName);
}
}
@ -1990,28 +2018,49 @@ void PeersDialog::displayMenu()
displaymenu->addAction(ui.actionSort_Peers_Ascending_Order);
displaymenu->addAction(ui.action_Hide_Offline_Friends);
displaymenu->addAction(ui.action_Sort_by_State);
displaymenu->addAction(ui.action_Hide_Status_Column);
displaymenu->addAction(ui.action_Hide_State);
ui.displayButton->setMenu(displaymenu);
}
void PeersDialog::sortByState()
void PeersDialog::setStateColumn()
{
if(ui.action_Sort_by_State->isChecked()) {
m_compareRole->setRole(COLUMN_NAME, ROLE_SORT_STATUS);
if (ui.action_Hide_Status_Column->isChecked()) {
ui.peertreeWidget->setColumnHidden(COLUMN_STATE, true);
ui.peertreeWidget->setHeaderHidden(true);
ui.action_Hide_State->setEnabled(true);
wasStatusColumnHidden = true;
} else {
m_compareRole->setRole(COLUMN_NAME, ROLE_SORT_NAME);
ui.peertreeWidget->setColumnHidden(COLUMN_STATE, false);
ui.peertreeWidget->setHeaderHidden(false);
ui.action_Hide_State->setEnabled(false);
if (wasStatusColumnHidden) {
ui.peertreeWidget->header()->resizeSection(COLUMN_NAME, ui.peertreeWidget->header()->sectionSize(COLUMN_NAME) - ui.peertreeWidget->header()->sectionSize(COLUMN_STATE));
}
wasStatusColumnHidden = false;
}
if(ui.action_Sort_by_State->isChecked()) {
ui.peertreeWidget->sortByColumn(COLUMN_STATE);
} else {
ui.peertreeWidget->sortByColumn(COLUMN_NAME);
}
}
void PeersDialog::sortPeersAscendingOrder()
{
ui.peertreeWidget->sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
ui.peertreeWidget->sortByColumn(ui.peertreeWidget->sortColumn(), Qt::AscendingOrder);
}
void PeersDialog::sortPeersDescendingOrder()
{
ui.peertreeWidget->sortByColumn(COLUMN_NAME, Qt::DescendingOrder);
ui.peertreeWidget->sortByColumn(ui.peertreeWidget->sortColumn(), Qt::DescendingOrder);
}
void PeersDialog::peerSortIndicatorChanged(int column, Qt::SortOrder)
{
ui.action_Sort_by_State->setChecked(column == COLUMN_STATE);
}
void PeersDialog::on_actionMessageHistory_triggered()

View File

@ -161,9 +161,10 @@ private slots:
void setCurrentFileName(const QString &fileName);
void sortByState();
void setStateColumn();
void sortPeersAscendingOrder();
void sortPeersDescendingOrder();
void peerSortIndicatorChanged(int,Qt::SortOrder);
void newsFeedChanged(int count);
@ -210,6 +211,7 @@ private:
int newsFeedTabIndex;
QColor newsFeedTabColor;
QString newsFeedText;
bool wasStatusColumnHidden;
/** Qt Designer generated object */
Ui::PeersDialog ui;

View File

@ -718,23 +718,22 @@ background: white;}</string>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Friends</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
</widget>
</item>
</layout>
@ -1498,6 +1497,14 @@ p, li { white-space: pre-wrap; }
<string>Hide Offline Friends</string>
</property>
</action>
<action name="action_Hide_Status_Column">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Hide Status Column</string>
</property>
</action>
<action name="action_Sort_by_State">
<property name="checkable">
<bool>true</bool>

View File

@ -7348,12 +7348,12 @@ p, li { white-space: pre-wrap; }
<context>
<name>PeersDialog</name>
<message>
<location filename="../gui/PeersDialog.cpp" line="+431"/>
<location filename="../gui/PeersDialog.cpp" line="+443"/>
<source>Chat</source>
<translation>Chat</translation>
</message>
<message>
<location line="+682"/>
<location line="+697"/>
<source>Save Certificate</source>
<translation>Zertifikat speichern</translation>
</message>
@ -7363,31 +7363,32 @@ p, li { white-space: pre-wrap; }
<translation>Zertifikate (*.pqi)</translation>
</message>
<message>
<location filename="../gui/PeersDialog.ui" line="+734"/>
<source>Status</source>
<translation type="obsolete">Status</translation>
<translation>Status</translation>
</message>
<message>
<location line="-669"/>
<location filename="../gui/PeersDialog.cpp" line="-684"/>
<source>Connect To Friend</source>
<translation>Verbinde zum Freund</translation>
</message>
<message>
<location line="-296"/>
<location line="-307"/>
<source>Profile</source>
<translation>Profil</translation>
</message>
<message>
<location line="+40"/>
<location line="+41"/>
<source>Welcome to RetroShare&apos;s group chat.</source>
<translation>Willkommen bei RetroShare&apos;s Gruppenchat.</translation>
</message>
<message>
<location line="+57"/>
<location line="+59"/>
<source>me</source>
<translation>ich</translation>
</message>
<message>
<location line="+154"/>
<location line="+162"/>
<source>Group</source>
<translation>Gruppe</translation>
</message>
@ -7467,12 +7468,13 @@ p, li { white-space: pre-wrap; }
<translation>Aus allen Gruppen entfernen</translation>
</message>
<message>
<location line="+507"/>
<location line="+512"/>
<location line="+2"/>
<source>Available</source>
<translation>Verfügbar</translation>
</message>
<message>
<location line="+423"/>
<location line="+431"/>
<location line="+2"/>
<source>New group chat</source>
<translation>Neuer Gruppenchat</translation>
@ -7509,7 +7511,7 @@ p, li { white-space: pre-wrap; }
<translation>Ordner können nicht für Drag&apos;n&apos;Drop genutzt werden. Nur Dateien werden akzeptiert.</translation>
</message>
<message>
<location filename="../gui/PeersDialog.ui" line="+1173"/>
<location filename="../gui/PeersDialog.ui" line="+438"/>
<source>Italic</source>
<translation>Kursiv</translation>
</message>
@ -7519,7 +7521,7 @@ p, li { white-space: pre-wrap; }
<translation>Unterstrichen</translation>
</message>
<message>
<location line="-591"/>
<location line="-590"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
@ -7537,7 +7539,7 @@ p, li { white-space: pre-wrap; }
<translation>Hinzufügen</translation>
</message>
<message>
<location line="+241"/>
<location line="+240"/>
<source>Add or Change your Avatar</source>
<translation>Wähle oder ändere dein Avatar Bild</translation>
</message>
@ -7594,7 +7596,7 @@ p, li { white-space: pre-wrap; }
<translation>Statusnachricht ändern</translation>
</message>
<message>
<location line="+32"/>
<location line="+40"/>
<location line="+3"/>
<source>Sort by State</source>
<translation>Sortiere nach Status</translation>
@ -7602,7 +7604,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+8"/>
<source>Hide State</source>
<translation type="unfinished">Status ausblenden</translation>
<translation>Status ausblenden</translation>
</message>
<message>
<location line="+9"/>
@ -7623,8 +7625,8 @@ p, li { white-space: pre-wrap; }
<translation>Aufsteigend sortieren</translation>
</message>
<message>
<location line="-142"/>
<location filename="../gui/PeersDialog.cpp" line="-1479"/>
<location line="-150"/>
<location filename="../gui/PeersDialog.cpp" line="-1494"/>
<source>Add Friend</source>
<translation>Freund hinzufügen</translation>
</message>
@ -7679,12 +7681,12 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location filename="../gui/PeersDialog.cpp" line="-40"/>
<location line="+850"/>
<location line="+865"/>
<source>RetroShare</source>
<translation></translation>
</message>
<message>
<location line="-811"/>
<location line="-826"/>
<source>Message Group</source>
<translation>Gruppe anschreiben</translation>
</message>
@ -7699,7 +7701,7 @@ p, li { white-space: pre-wrap; }
<translation>Gruppe entfernen</translation>
</message>
<message>
<location line="+803"/>
<location line="+818"/>
<source>Do you want to remove this Friend?</source>
<translation>Willst du diesen Freund entfernen?</translation>
</message>
@ -7714,7 +7716,7 @@ p, li { white-space: pre-wrap; }
<translation>Text Datei (*.txt );;Alle Dateien (*)</translation>
</message>
<message>
<location filename="../gui/PeersDialog.ui" line="-879"/>
<location filename="../gui/PeersDialog.ui" line="-878"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
@ -7727,26 +7729,27 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Anzeige&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<location line="+887"/>
<location line="+886"/>
<source>Hide Offline Friends</source>
<translation>Verstecke offline Freunde</translation>
</message>
<message>
<location line="+8"/>
<source>Hide Status Column</source>
<translation type="obsolete">Status Spalte ausblenden</translation>
<translation>Status Spalte ausblenden</translation>
</message>
<message>
<location filename="../gui/PeersDialog.cpp" line="-1803"/>
<location filename="../gui/PeersDialog.cpp" line="-1829"/>
<source>Friends Storm</source>
<translation>Aktivitäten</translation>
</message>
<message>
<location line="+1162"/>
<location line="+1188"/>
<source>is typing...</source>
<translation>tippt...</translation>
</message>
<message>
<location filename="../gui/PeersDialog.ui" line="-19"/>
<location filename="../gui/PeersDialog.ui" line="-27"/>
<source>Browse Message History</source>
<translation>Nachrichtenverlauf anzeigen</translation>
</message>
@ -7756,18 +7759,18 @@ p, li { white-space: pre-wrap; }
<translation>Nachrichtenverlauf</translation>
</message>
<message>
<location line="-747"/>
<location line="-752"/>
<source>Friends</source>
<translation>Freunde</translation>
</message>
<message>
<location filename="../gui/PeersDialog.cpp" line="-866"/>
<location filename="../gui/PeersDialog.cpp" line="-881"/>
<location line="+80"/>
<source>Paste Friend Link</source>
<translation>RetroShare Link einfügen</translation>
</message>
<message>
<location line="+358"/>
<location line="+359"/>
<source>location</source>
<translation>Standort</translation>
</message>