X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fnetworkmodel.cpp;h=6c6a3e806f2f3271bb2735895a3eb8b09f46621e;hp=9d463f64eeada64444f741b9287ff8a2295bf5c0;hb=4ba498c04b9aefee2e3ab9d2eb0645f86e5d1968;hpb=b5385b3ddf6f0e8df8f0af7275b59dcc1fcd0ed1
diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp
index 9d463f64..6c6a3e80 100644
--- a/src/client/networkmodel.cpp
+++ b/src/client/networkmodel.cpp
@@ -144,6 +144,9 @@ void BufferItem::attachIrcChannel(IrcChannel *ircChannel) {
}
void BufferItem::ircChannelDestroyed() {
+ Q_CHECK_PTR(_ircChannel);
+ disconnect(_ircChannel, 0, this, 0);
+ _ircChannel = 0;
emit dataChanged();
removeAllChilds();
}
@@ -288,7 +291,7 @@ QString BufferItem::toolTip(int column) const {
switch(bufferType()) {
case BufferInfo::StatusBuffer: {
QString netName = Client::network(bufferInfo().networkId())->networkName();
- toolTip.append(tr("Status buffer from %1").arg(netName));
+ toolTip.append(tr("Status buffer of %1").arg(netName));
break;
}
case BufferInfo::ChannelBuffer:
@@ -414,7 +417,9 @@ void NetworkItem::attachNetwork(Network *network) {
this, SLOT(attachIrcChannel(QString)));
connect(network, SIGNAL(connectedSet(bool)),
this, SIGNAL(dataChanged()));
-
+ connect(network, SIGNAL(destroyed()),
+ this, SIGNAL(dataChanged()));
+
emit dataChanged();
}
@@ -462,27 +467,26 @@ QString NetworkItem::toolTip(int column) const {
*****************************************/
// we hardcode this even though we have PREFIX in network... but that wouldn't help with mapping modes to
// category strings anyway.
-// TODO make this translateable depending on the number of users in a category
-// -> we can't set the real string here, because tr() needs to get the actual number as second param
-// -> tr("%n User(s)", n) needs to be used somewhere where we do know the user number n
-const QList UserCategoryItem::categories = QList()
- << UserCategoryItem::Category('q', tr("Owners"))
- << UserCategoryItem::Category('a', tr("Admins"))
- << UserCategoryItem::Category('o', tr("Operators"))
- << UserCategoryItem::Category('h', tr("Half-Ops"))
- << UserCategoryItem::Category('v', tr("Voiced"));
+const QList UserCategoryItem::categories = QList() << 'q' << 'a' << 'o' << 'h' << 'v';
UserCategoryItem::UserCategoryItem(int category, AbstractTreeItem *parent)
- : PropertyMapItem(QStringList() << "categoryId", parent),
+ : PropertyMapItem(QStringList() << "categoryName", parent),
_category(category)
{
+
}
-QString UserCategoryItem::categoryId() {
- if(_category < categories.count())
- return categories[_category].displayString;
- else
- return tr("Users");
+// caching this makes no sense, since we display the user number dynamically
+QString UserCategoryItem::categoryName() const {
+ int n = childCount();
+ switch(_category) {
+ case 0: return tr("%n Owner(s)", 0, n);
+ case 1: return tr("%n Admin(s)", 0, n);
+ case 2: return tr("%n Operator(s)", 0, n);
+ case 3: return tr("%n Half-Op(s)", 0, n);
+ case 4: return tr("%n Voiced", 0, n);
+ default: return tr("%n User(s)", 0, n);
+ }
}
quint64 UserCategoryItem::id() const {
@@ -502,7 +506,7 @@ bool UserCategoryItem::removeUser(IrcUser *ircUser) {
int UserCategoryItem::categoryFromModes(const QString &modes) {
for(int i = 0; i < categories.count(); i++) {
- if(modes.contains(categories[i].mode))
+ if(modes.contains(categories[i]))
return i;
}
return categories.count();
@@ -510,6 +514,8 @@ int UserCategoryItem::categoryFromModes(const QString &modes) {
QVariant UserCategoryItem::data(int column, int role) const {
switch(role) {
+ case TreeModel::SortRole:
+ return _category;
case NetworkModel::ItemActiveRole:
return true;
case NetworkModel::ItemTypeRole:
@@ -525,7 +531,7 @@ QVariant UserCategoryItem::data(int column, int role) const {
}
}
-
+
/*****************************************
* Irc User Items
*****************************************/
@@ -589,7 +595,10 @@ QString IrcUserItem::toolTip(int column) const {
if(_ircUser->isAway()) toolTip[0].append(" is away");
if(!_ircUser->awayMessage().isEmpty()) toolTip[0].append(QString(" (%1)").arg(_ircUser->awayMessage()));
if(!_ircUser->realName().isEmpty()) toolTip.append(_ircUser->realName());
- if(!_ircUser->ircOperator().isEmpty()) toolTip.append(_ircUser->ircOperator());
+ if(!_ircUser->ircOperator().isEmpty()) toolTip.append(QString("%1 %2").arg(nickName()).arg(_ircUser->ircOperator()));
+ if(!_ircUser->suserHost().isEmpty()) toolTip.append(_ircUser->suserHost());
+ if(!_ircUser->whoisServiceReply().isEmpty()) toolTip.append(_ircUser->whoisServiceReply());
+
toolTip.append(_ircUser->hostmask().remove(0, _ircUser->hostmask().indexOf("!")+1));
if(_ircUser->idleTime().isValid()) {