X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftitlesetter.cpp;h=731b9131f3baf582e74637abd2d1c00de249cd05;hp=297b4cecbf76307afef5c61da689f04181988a88;hb=00e1a9c29e792ba4d65dba21b7ba04131bcb13bc;hpb=c8129b5a72cbc000542b4c529861199989c75f6d diff --git a/src/qtui/titlesetter.cpp b/src/qtui/titlesetter.cpp index 297b4cec..731b9131 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" @@ -25,36 +25,41 @@ #include "mainwin.h" TitleSetter::TitleSetter(MainWin *parent) - : AbstractItemView(parent), + : AbstractItemView(parent), _mainWin(parent) { +} + +void TitleSetter::currentChanged(const QModelIndex ¤t, 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); }