summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/downloadlist.cpp29
-rw-r--r--src/downloadlist.h8
-rw-r--r--src/downloadlistsortproxy.cpp42
-rw-r--r--src/downloadlistwidget.cpp11
-rw-r--r--src/mainwindow.cpp6
5 files changed, 93 insertions, 3 deletions
diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp
index dd72abbd..e7036234 100644
--- a/src/downloadlist.cpp
+++ b/src/downloadlist.cpp
@@ -47,7 +47,7 @@ int DownloadList::rowCount(const QModelIndex&) const
int DownloadList::columnCount(const QModelIndex&) const
{
- return 4;
+ return COL_COUNT;
}
@@ -69,6 +69,9 @@ QVariant DownloadList::headerData(int section, Qt::Orientation orientation, int
(orientation == Qt::Horizontal)) {
switch (section) {
case COL_NAME: return tr("Name");
+ case COL_MODNAME: return tr("Mod name");
+ case COL_VERSION: return tr("Version");
+ case COL_ID: return tr("Nexus ID");
case COL_SIZE: return tr("Size");
case COL_STATUS: return tr("Status");
case COL_FILETIME: return tr("Filetime");
@@ -93,6 +96,30 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const
} else {
switch (index.column()) {
case COL_NAME: return m_MetaDisplay ? m_Manager->getDisplayName(index.row()) : m_Manager->getFileName(index.row());
+ case COL_MODNAME: {
+ if (m_Manager->isInfoIncomplete(index.row())) {
+ return {};
+ } else {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(index.row());
+ return info->modName;
+ }
+ }
+ case COL_VERSION: {
+ if (m_Manager->isInfoIncomplete(index.row())) {
+ return {};
+ } else {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(index.row());
+ return info->version.canonicalString();
+ }
+ }
+ case COL_ID: {
+ if (m_Manager->isInfoIncomplete(index.row())) {
+ return {};
+ } else {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(index.row());
+ return QString("%1").arg(m_Manager->getModID(index.row()));
+ }
+ }
case COL_SIZE: return sizeFormat(m_Manager->getFileSize(index.row()));
case COL_FILETIME: return m_Manager->getFileTime(index.row());
case COL_STATUS:
diff --git a/src/downloadlist.h b/src/downloadlist.h
index bf0cdc37..6f63f0c8 100644
--- a/src/downloadlist.h
+++ b/src/downloadlist.h
@@ -39,7 +39,13 @@ public:
COL_NAME = 0,
COL_STATUS,
COL_SIZE,
- COL_FILETIME
+ COL_FILETIME,
+ COL_MODNAME,
+ COL_VERSION,
+ COL_ID,
+
+ // number of columns
+ COL_COUNT
};
public:
diff --git a/src/downloadlistsortproxy.cpp b/src/downloadlistsortproxy.cpp
index dc97dc3e..7bda139b 100644
--- a/src/downloadlistsortproxy.cpp
+++ b/src/downloadlistsortproxy.cpp
@@ -43,6 +43,48 @@ bool DownloadListSortProxy::lessThan(const QModelIndex &left,
&& (rightIndex < m_Manager->numTotalDownloads())) {
if (left.column() == DownloadList::COL_NAME) {
return m_Manager->getFileName(left.row()).compare(m_Manager->getFileName(right.row()), Qt::CaseInsensitive) < 0;
+ } else if (left.column() == DownloadList::COL_MODNAME) {
+ QString leftName, rightName;
+
+ if (!m_Manager->isInfoIncomplete(left.row())) {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(left.row());
+ leftName = info->modName;
+ }
+
+ if (!m_Manager->isInfoIncomplete(right.row())) {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(right.row());
+ rightName = info->modName;
+ }
+
+ return leftName.compare(rightName, Qt::CaseInsensitive) < 0;
+ } else if (left.column() == DownloadList::COL_VERSION) {
+ MOBase::VersionInfo versionLeft, versionRight;
+
+ if (!m_Manager->isInfoIncomplete(left.row())) {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(left.row());
+ versionLeft = info->version;
+ }
+
+ if (!m_Manager->isInfoIncomplete(right.row())) {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(right.row());
+ versionRight = info->version;
+ }
+
+ return versionLeft < versionRight;
+ } else if (left.column() == DownloadList::COL_ID) {
+ int leftID=0, rightID=0;
+
+ if (!m_Manager->isInfoIncomplete(left.row())) {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(left.row());
+ leftID = info->modID;
+ }
+
+ if (!m_Manager->isInfoIncomplete(right.row())) {
+ const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(right.row());
+ rightID = info->modID;
+ }
+
+ return leftID < rightID;
} else if (left.column() == DownloadList::COL_STATUS) {
DownloadManager::DownloadState leftState = m_Manager->getState(left.row());
DownloadManager::DownloadState rightState = m_Manager->getState(right.row());
diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp
index f0c4da1a..e6029270 100644
--- a/src/downloadlistwidget.cpp
+++ b/src/downloadlistwidget.cpp
@@ -123,6 +123,15 @@ DownloadListWidget::~DownloadListWidget()
void DownloadListWidget::setManager(DownloadManager *manager)
{
m_Manager = manager;
+
+ // hide these columns by default
+ //
+ // note that this is overridden by the ini if MO has been started at least
+ // once before, which is handled in MainWindow::processUpdates() for older
+ // versions
+ header()->hideSection(DownloadList::COL_MODNAME);
+ header()->hideSection(DownloadList::COL_VERSION);
+ header()->hideSection(DownloadList::COL_ID);
}
void DownloadListWidget::setSourceModel(DownloadList *sourceModel)
@@ -199,7 +208,7 @@ void DownloadListWidget::onCustomContextMenu(const QPoint &point)
if (state >= DownloadManager::STATE_READY) {
menu.addAction(tr("Install"), this, SLOT(issueInstall()));
- if (m_Manager->isInfoIncomplete(m_ContextRow))
+ if (m_Manager->isInfoIncomplete(m_ContextRow))
menu.addAction(tr("Query Info"), this, SLOT(issueQueryInfoMd5()));
else
menu.addAction(tr("Visit on Nexus"), this, SLOT(issueVisitOnNexus()));
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 89cb9f56..1b95ea0b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1897,6 +1897,12 @@ void MainWindow::processUpdates() {
instance.remove("");
instance.endGroup();
}
+ if (lastVersion < QVersionNumber(2, 2, 1)) {
+ // hide new columns by default
+ for (int i=DownloadList::COL_MODNAME; i<DownloadList::COL_COUNT; ++i) {
+ ui->downloadView->header()->hideSection(i);
+ }
+ }
}
if (currentVersion > lastVersion) {