X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Firclistmodel.cpp;h=8091ca428eb3e0461c5bea1b1a1407c4fcba0666;hp=83dd7c165b3559c17a1ae37b82d438467a9464ad;hb=52209badc8e769e50aa3019b63689dda0e79e9d0;hpb=f824db0e31b54969e0b7fa0b5405b1e9173d482c diff --git a/src/client/irclistmodel.cpp b/src/client/irclistmodel.cpp index 83dd7c16..8091ca42 100644 --- a/src/client/irclistmodel.cpp +++ b/src/client/irclistmodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,75 +15,77 @@ * 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 "irclistmodel.h" #include -IrcListModel::IrcListModel(QObject *parent) - : QAbstractItemModel(parent) -{ -} +IrcListModel::IrcListModel(QObject* parent) + : QAbstractItemModel(parent) +{} -QVariant IrcListModel::data(const QModelIndex &index, int role) const { - if(!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount() || role != Qt::DisplayRole) - return QVariant(); +QVariant IrcListModel::data(const QModelIndex& index, int role) const +{ + if (!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount() || role != Qt::DisplayRole) + return QVariant(); - IrcListHelper::ChannelDescription channel = _channelList[index.row()]; + IrcListHelper::ChannelDescription channel = _channelList[index.row()]; - switch(index.column()) { - case 0: - return channel.channelName; - case 1: - return channel.userCount; - case 2: - return channel.topic; - default: - return QVariant(); - } + switch (index.column()) { + case 0: + return channel.channelName; + case 1: + return channel.userCount; + case 2: + return channel.topic; + default: + return QVariant(); + } } -Qt::ItemFlags IrcListModel::flags(const QModelIndex &index) const { - if(!index.isValid()) { - return Qt::ItemIsDropEnabled; - } else { - return Qt::ItemIsSelectable | Qt::ItemIsEnabled; - } +Qt::ItemFlags IrcListModel::flags(const QModelIndex& index) const +{ + if (!index.isValid()) { + return Qt::ItemIsDropEnabled; + } + else { + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; + } } +QVariant IrcListModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + QStringList header; + header << tr("Channel") << tr("Users") << tr("Topic"); -QVariant IrcListModel::headerData(int section, Qt::Orientation orientation, int role) const { - QStringList header; - header << tr("Channel") - << tr("Users") - << tr("Topic"); - - if(orientation == Qt::Horizontal && role == Qt::DisplayRole) - return header[section]; + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + return header[section]; - return QVariant(); + return QVariant(); } -QModelIndex IrcListModel::index(int row, int column, const QModelIndex &parent) const { - Q_UNUSED(parent); - if(row >= rowCount() || column >= columnCount()) - return QModelIndex(); +QModelIndex IrcListModel::index(int row, int column, const QModelIndex& parent) const +{ + Q_UNUSED(parent); + if (row >= rowCount() || column >= columnCount()) + return {}; - return createIndex(row, column); + return createIndex(row, column); } -void IrcListModel::setChannelList(const QList &channelList) { - if(rowCount() > 0) { - beginRemoveRows(QModelIndex(), 0, _channelList.count() - 1); - _channelList.clear(); - endRemoveRows(); - } +void IrcListModel::setChannelList(const QList& channelList) +{ + if (rowCount() > 0) { + beginRemoveRows(QModelIndex(), 0, _channelList.count() - 1); + _channelList.clear(); + endRemoveRows(); + } - if(channelList.count() > 0) { - beginInsertRows(QModelIndex(), 0, channelList.count() - 1); - _channelList = channelList; - endInsertRows(); - } + if (channelList.count() > 0) { + beginInsertRows(QModelIndex(), 0, channelList.count() - 1); + _channelList = channelList; + endInsertRows(); + } }