diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/downloadmanager.cpp | 2 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 18 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/pluginflagicondelegate.cpp | 6 | ||||
| -rw-r--r-- | src/pluginlist.cpp | 34 | ||||
| -rw-r--r-- | src/pluginlist.h | 4 |
6 files changed, 53 insertions, 12 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 31d8bcec..e747b299 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1246,7 +1246,7 @@ void DownloadManager::downloadFinished() textData) { if (info->m_Tries == 0) { if (textData && (reply->error() == QNetworkReply::NoError)) { - emit showMessage(tr("Download failed. Server reported: %1").arg(readFileText(info->m_Output.fileName()))); + emit showMessage(tr("Download failed. Server reported: %1").arg(QString(data))); } else { emit showMessage(tr("Download failed: %1 (%2)").arg(reply->errorString()).arg(reply->error())); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 625b406d..93c1f2f1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3103,6 +3103,22 @@ void MainWindow::reinstallMod_clicked() } +void MainWindow::resumeDownload(int downloadIndex) +{ + if (NexusInterface::instance()->getAccessManager()->loggedIn()) { + m_DownloadManager.resumeDownload(downloadIndex); + } else { + QString username, password; + if (m_Settings.getNexusLogin(username, password)) { + m_PostLoginTasks.push_back(boost::bind(&MainWindow::resumeDownload, _1, downloadIndex)); + NexusInterface::instance()->getAccessManager()->login(username, password); + } else { + MessageDialog::showMessage(tr("You need to be logged in with Nexus to resume a download"), this); + } + } +} + + void MainWindow::endorseMod(ModInfo::Ptr mod) { if (NexusInterface::instance()->getAccessManager()->loggedIn()) { @@ -4689,7 +4705,7 @@ void MainWindow::updateDownloadListDelegate() connect(ui->downloadView->itemDelegate(), SIGNAL(restoreDownload(int)), &m_DownloadManager, SLOT(restoreDownload(int))); connect(ui->downloadView->itemDelegate(), SIGNAL(cancelDownload(int)), &m_DownloadManager, SLOT(cancelDownload(int))); connect(ui->downloadView->itemDelegate(), SIGNAL(pauseDownload(int)), &m_DownloadManager, SLOT(pauseDownload(int))); - connect(ui->downloadView->itemDelegate(), SIGNAL(resumeDownload(int)), &m_DownloadManager, SLOT(resumeDownload(int))); + connect(ui->downloadView->itemDelegate(), SIGNAL(resumeDownload(int)), this, SLOT(resumeDownload(int))); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 250f2a48..46165f0f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -483,6 +483,7 @@ private slots: void hookUpWindowTutorials(); + void resumeDownload(int downloadIndex); void endorseMod(ModInfo::Ptr mod); void cancelModListEditor(); diff --git a/src/pluginflagicondelegate.cpp b/src/pluginflagicondelegate.cpp index 6c0bb29e..761555d7 100644 --- a/src/pluginflagicondelegate.cpp +++ b/src/pluginflagicondelegate.cpp @@ -11,8 +11,10 @@ PluginFlagIconDelegate::PluginFlagIconDelegate(QObject *parent) QList<QIcon> PluginFlagIconDelegate::getIcons(const QModelIndex &index) const
{
QList<QIcon> result;
- foreach (const QVariant &var, index.data(Qt::UserRole + 1).toList()) {
- result.append(var.value<QIcon>());
+ if (index.isValid()) {
+ foreach (const QVariant &var, index.data(Qt::UserRole + 1).toList()) {
+ result.append(var.value<QIcon>());
+ }
}
return result;
}
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index ec063994..289032bb 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -75,7 +75,7 @@ bool ByDate(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RHS) { } PluginList::PluginList(QObject *parent) - : QAbstractTableModel(parent) + : QAbstractItemModel(parent) , m_FontMetrics(QFont()) , m_SaveTimer(this) , m_BOSS(NULL) @@ -951,7 +951,16 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const } break; } } else if ((role == Qt::CheckStateRole) && (modelIndex.column() == 0)) { - return m_ESPs[index].m_Enabled ? Qt::Checked : Qt::Unchecked; + if (m_ESPs[index].m_ForceEnabled) { + return QVariant(); + } else { + return m_ESPs[index].m_Enabled ? Qt::Checked : Qt::Unchecked; + } + } else if (role == Qt::ForegroundRole) { + if ((modelIndex.column() == COL_NAME) && + m_ESPs[index].m_ForceEnabled) { + return QBrush(Qt::gray); + } } else if (role == Qt::FontRole) { QFont result; if (m_ESPs[index].m_IsMaster) { @@ -1070,13 +1079,12 @@ QVariant PluginList::headerData(int section, Qt::Orientation orientation, Qt::ItemFlags PluginList::flags(const QModelIndex &modelIndex) const { int index = modelIndex.row(); - Qt::ItemFlags result = QAbstractTableModel::flags(modelIndex); + Qt::ItemFlags result = QAbstractItemModel::flags(modelIndex); if (modelIndex.isValid()) { - if ((m_ESPs[index].m_ForceEnabled)) { - result &= ~Qt::ItemIsEnabled; + if (!m_ESPs[index].m_ForceEnabled) { + result |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled; } - result |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled; } else { result |= Qt::ItemIsDropEnabled; } @@ -1216,6 +1224,19 @@ bool PluginList::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, return false; } +QModelIndex PluginList::index(int row, int column, const QModelIndex&) const +{ + if ((row < 0) || (row >= rowCount()) || (column < 0) || (column >= columnCount())) { + return QModelIndex(); + } + return createIndex(row, column, row); +} + +QModelIndex PluginList::parent(const QModelIndex&) const +{ + return QModelIndex(); +} + bool PluginList::eventFilter(QObject *obj, QEvent *event) { @@ -1227,7 +1248,6 @@ bool PluginList::eventFilter(QObject *obj, QEvent *event) } QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); - // ctrl+up and ctrl+down -> increase or decrease priority of selected plugins if ((keyEvent->modifiers() == Qt::ControlModifier) && ((keyEvent->key() == Qt::Key_Up) || (keyEvent->key() == Qt::Key_Down))) { diff --git a/src/pluginlist.h b/src/pluginlist.h index 3d7f0926..fff2a595 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -69,7 +69,7 @@ private: /** * @brief model representing the plugins (.esp/.esm) in the current virtual data folder **/ -class PluginList : public QAbstractTableModel, public MOBase::IPluginList +class PluginList : public QAbstractItemModel, public MOBase::IPluginList { Q_OBJECT friend class ChangeBracket<PluginList>; @@ -201,6 +201,8 @@ public: // implementation of the QAbstractTableModel interface virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual Qt::DropActions supportedDropActions() const { return Qt::MoveAction; } virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); + virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + virtual QModelIndex parent(const QModelIndex &child) const; void applyBOSSSorting(boss_db db, std::map<int, QString> &lockedLoadOrder, uint8_t **pluginList, size_t size, int &priority, int &loadOrder, bool recognized, const char *extension); public slots: |
