From ea6292168a6acd4c263913f0ccd7dd64daf4f5cf Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Fri, 23 Feb 2018 01:45:58 +0100 Subject: Revert "Applied clang-format on source" This reverts commit 5e5c9c07291f6b09623d31c92b1fb61c4ede576e. --- src/downloadlist.cpp | 123 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 51 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 4feffa04..f13cdef1 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -23,71 +23,92 @@ along with Mod Organizer. If not, see . #include -DownloadList::DownloadList(DownloadManager* manager, QObject* parent) - : QAbstractTableModel(parent), m_Manager(manager) { - connect(m_Manager, SIGNAL(update(int)), this, SLOT(update(int))); - connect(m_Manager, SIGNAL(aboutToUpdate()), this, SLOT(aboutToUpdate())); + +DownloadList::DownloadList(DownloadManager *manager, QObject *parent) + : QAbstractTableModel(parent), m_Manager(manager) +{ + connect(m_Manager, SIGNAL(update(int)), this, SLOT(update(int))); + connect(m_Manager, SIGNAL(aboutToUpdate()), this, SLOT(aboutToUpdate())); } -int DownloadList::rowCount(const QModelIndex&) const { - return m_Manager->numTotalDownloads() + m_Manager->numPendingDownloads(); + +int DownloadList::rowCount(const QModelIndex&) const +{ + return m_Manager->numTotalDownloads() + m_Manager->numPendingDownloads(); } -int DownloadList::columnCount(const QModelIndex&) const { return 3; } -QModelIndex DownloadList::index(int row, int column, const QModelIndex&) const { return createIndex(row, column, row); } +int DownloadList::columnCount(const QModelIndex&) const +{ + return 3; +} -QModelIndex DownloadList::parent(const QModelIndex&) const { return QModelIndex(); } -QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int role) const { - if ((role == Qt::DisplayRole) && (orientation == Qt::Horizontal)) { - switch (section) { - case COL_NAME: - return tr("Name"); - case COL_FILETIME: - return tr("Filetime"); - default: - return tr("Done"); - } - } else { - return QAbstractItemModel::headerData(section, orientation, role); +QModelIndex DownloadList::index(int row, int column, const QModelIndex&) const +{ + return createIndex(row, column, row); +} + + +QModelIndex DownloadList::parent(const QModelIndex&) const +{ + return QModelIndex(); +} + + +QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int role) const +{ + if ((role == Qt::DisplayRole) && + (orientation == Qt::Horizontal)) { + switch (section) { + case COL_NAME: return tr("Name"); + case COL_FILETIME: return tr("Filetime"); + default: return tr("Done"); } + } else { + return QAbstractItemModel::headerData(section, orientation, role); + } } -QVariant DownloadList::data(const QModelIndex& index, int role) const { - if (role == Qt::DisplayRole) { - return index.row(); - } else if (role == Qt::ToolTipRole) { - if (index.row() < m_Manager->numTotalDownloads()) { - QString text = m_Manager->getFileName(index.row()) + "\n"; - if (m_Manager->isInfoIncomplete(index.row())) { - text += tr("Information missing, please select \"Query Info\" from the context menu to re-retrieve."); - } else { - const MOBase::ModRepositoryFileInfo* info = m_Manager->getFileInfo(index.row()); - return QString("%1 (ID %2) %3
%4") - .arg(info->modName) - .arg(m_Manager->getModID(index.row())) - .arg(info->version.canonicalString()) - .arg(info->description); - } - return text; - } else { - return tr("pending download"); - } + +QVariant DownloadList::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole) { + return index.row(); + } else if (role == Qt::ToolTipRole) { + if (index.row() < m_Manager->numTotalDownloads()) { + QString text = m_Manager->getFileName(index.row()) + "\n"; + if (m_Manager->isInfoIncomplete(index.row())) { + text += tr("Information missing, please select \"Query Info\" from the context menu to re-retrieve."); + } else { + const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(index.row()); + return QString("%1 (ID %2) %3
%4").arg(info->modName).arg(m_Manager->getModID(index.row())).arg(info->version.canonicalString()).arg(info->description); + } + return text; } else { - return QVariant(); + return tr("pending download"); } + } else { + return QVariant(); + } +} + + +void DownloadList::aboutToUpdate() +{ + emit beginResetModel(); } -void DownloadList::aboutToUpdate() { emit beginResetModel(); } -void DownloadList::update(int row) { - if (row < 0) { - emit endResetModel(); - } else if (row < this->rowCount()) { +void DownloadList::update(int row) +{ + if (row < 0) { + emit endResetModel(); + } else if (row < this->rowCount()) { #pragma message("updating only the one column is a hack") - emit dataChanged(this->index(row, 2, QModelIndex()), this->index(row, 2, QModelIndex())); - } else { - qCritical("invalid row %d in download list, update failed", row); - } + emit dataChanged(this->index(row, 2, QModelIndex()), this->index(row, 2, QModelIndex())); + } else { + qCritical("invalid row %d in download list, update failed", row); + } } + -- cgit v1.3.1