X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftitlesetter.cpp;h=a7429e0e27abc9357b365c67376a18b454d6cb07;hp=297b4cecbf76307afef5c61da689f04181988a88;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hpb=c8129b5a72cbc000542b4c529861199989c75f6d diff --git a/src/qtui/titlesetter.cpp b/src/qtui/titlesetter.cpp index 297b4cec..a7429e0e 100644 --- a/src/qtui/titlesetter.cpp +++ b/src/qtui/titlesetter.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "titlesetter.h" @@ -24,37 +24,38 @@ #include "client.h" #include "mainwin.h" -TitleSetter::TitleSetter(MainWin *parent) - : AbstractItemView(parent), - _mainWin(parent) -{ +TitleSetter::TitleSetter(MainWin* parent) + : AbstractItemView(parent) + , _mainWin(parent) +{} +void TitleSetter::currentChanged(const QModelIndex& current, const QModelIndex& previous) +{ + Q_UNUSED(previous); + changeWindowTitle(current.sibling(current.row(), 0)); } -void TitleSetter::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { - Q_UNUSED(previous); - changeWindowTitle(current.sibling(current.row(), 0)); +void TitleSetter::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) +{ + QItemSelectionRange changedArea(topLeft, bottomRight); + QModelIndex currentTopicIndex = selectionModel()->currentIndex().sibling(selectionModel()->currentIndex().row(), 0); + if (changedArea.contains(currentTopicIndex)) + changeWindowTitle(currentTopicIndex); } -void TitleSetter::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { - QItemSelectionRange changedArea(topLeft, bottomRight); - QModelIndex currentTopicIndex = selectionModel()->currentIndex().sibling(selectionModel()->currentIndex().row(), 0); - if(changedArea.contains(currentTopicIndex)) - changeWindowTitle(currentTopicIndex); -}; - -void TitleSetter::changeWindowTitle(const QModelIndex &index) { - BufferId id = index.data(NetworkModel::BufferIdRole).value(); - if(!id.isValid()) - return; - - QString title; - if(Client::networkModel()->bufferType(id) == BufferInfo::StatusBuffer) - title = index.data().toString(); - else - title = QString("%1 (%2)").arg(index.data().toString(), Client::networkModel()->networkName(id)); - QString newTitle = QString("%1 - %2").arg("Quassel IRC").arg(title); - - _mainWin->setWindowTitle(newTitle); - _mainWin->setWindowIconText(newTitle); +void TitleSetter::changeWindowTitle(const QModelIndex& index) +{ + BufferId id = index.data(NetworkModel::BufferIdRole).value(); + if (!id.isValid()) + return; + + QString title; + if (Client::networkModel()->bufferType(id) == BufferInfo::StatusBuffer) + title = index.data().toString(); + else + title = QString("%1 (%2)").arg(index.data().toString(), Client::networkModel()->networkName(id)); + QString newTitle = QString("%1 - %2").arg("Quassel IRC").arg(title); + + _mainWin->setWindowTitle(newTitle); + _mainWin->setWindowIconText(newTitle); }