summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-06-08 22:23:25 +0200
committerTannin <devnull@localhost>2013-06-08 22:23:25 +0200
commit6069decb159ec30b7a69649294ee0e89783bb717 (patch)
treeb1dadc87188d97c9228880c31457751170f3a9bf /src
parent30dece9093fc27779c9d91d9b573ea6ca2430345 (diff)
- mod list no longer loses selection whenever categories context menu gets hidden
Diffstat (limited to 'src')
-rw-r--r--src/installationmanager.cpp3
-rw-r--r--src/mainwindow.cpp40
-rw-r--r--src/modlist.cpp5
-rw-r--r--src/modlistsortproxy.cpp16
-rw-r--r--src/modlistsortproxy.h2
-rw-r--r--src/nexusinterface.cpp2
-rw-r--r--src/organizer.pro5
-rw-r--r--src/version.rc15
8 files changed, 65 insertions, 23 deletions
diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp
index 744b928d..b8cfbcb8 100644
--- a/src/installationmanager.cpp
+++ b/src/installationmanager.cpp
@@ -106,7 +106,8 @@ void InstallationManager::mapToArchive(const DirectoryTree::Node *node, std::wst
for (DirectoryTree::const_leaf_iterator iter = node->leafsBegin(); iter != node->leafsEnd(); ++iter) {
data[iter->getIndex()]->setSkip(false);
- data[iter->getIndex()]->setOutputFileName(path.substr().append(ToWString(iter->getName())).c_str());
+ std::wstring temp = path.substr().append(ToWString(iter->getName()));
+ data[iter->getIndex()]->setOutputFileName(temp.c_str());
}
for (DirectoryTree::const_node_iterator iter = node->nodesBegin(); iter != node->nodesEnd(); ++iter) {
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 64a3d0de..e6f48ea5 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -125,6 +125,11 @@ static bool isOnline()
}
+#ifdef TEST_MODELS
+#include <modeltest.h>
+#endif // TEST_MODELS
+
+
MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow), m_Tutorial(this, "MainWindow"),
m_ExeName(exeName), m_OldProfileIndex(-1),
@@ -163,6 +168,11 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget
m_ModListSortProxy = new ModListSortProxy(m_CurrentProfile, this);
m_ModListSortProxy->setSourceModel(&m_ModList);
+#ifdef TEST_MODELS
+ new ModelTest(&m_ModList, this);
+ new ModelTest(m_ModListSortProxy, this);
+#endif //TEST_MODELS
+
ui->modList->setModel(m_ModListSortProxy);
ui->modList->sortByColumn(ModList::COL_PRIORITY, Qt::AscendingOrder);
@@ -1259,7 +1269,6 @@ void MainWindow::refreshModList()
{
// don't lose changes!
m_CurrentProfile->writeModlistNow(true);
-
ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure);
m_CurrentProfile->refreshModStatus();
@@ -2418,17 +2427,11 @@ void MainWindow::refreshFilters()
ui->modList->setCurrentIndex(QModelIndex());
- // save previous filter text so we can restore it later, in case the filter still exists then
-// QTreeWidgetItem *currentItem = ui->categoriesList->currentItem();
-// QString previousFilter = currentItem != NULL ? currentItem->text(0) : tr("<All>");
-
-
QStringList selectedItems;
foreach (QTreeWidgetItem *item, ui->categoriesList->selectedItems()) {
selectedItems.append(item->text(0));
}
-
ui->categoriesList->clear();
addFilterItem(NULL, tr("<Checked>"), CategoryFactory::CATEGORY_SPECIAL_CHECKED);
addFilterItem(NULL, tr("<Unchecked>"), CategoryFactory::CATEGORY_SPECIAL_UNCHECKED);
@@ -2562,11 +2565,12 @@ void MainWindow::reinstallMod_clicked()
ModInfo::Ptr modInfo = ModInfo::getByIndex(m_ContextRow);
QString installationFile = modInfo->getInstallationFile();
if (installationFile.length() != 0) {
- // there was a bug where mods installed through NCC had the absolute download path stored
+ QString fullInstallationFile;
if (QFileInfo(installationFile).isAbsolute()) {
- installationFile = QFileInfo(installationFile).fileName();
+ fullInstallationFile = installationFile;
+ } else {
+ fullInstallationFile = m_DownloadManager.getOutputDirectory().append("/").append(installationFile);
}
- QString fullInstallationFile = m_DownloadManager.getOutputDirectory().append("/").append(installationFile);
if (QFile::exists(fullInstallationFile)) {
installMod(fullInstallationFile);
} else {
@@ -2955,14 +2959,27 @@ void MainWindow::saveCategories()
int min = INT_MAX;
int max = INT_MIN;
+ QStringList selectedMods;
+
for (int i = 0; i < selected.size(); ++i) {
QModelIndex temp = mapToModel(&m_ModList, selected.at(i));
+ selectedMods.append(temp.data().toString());
if (temp.row() < min) min = temp.row();
if (temp.row() > max) max = temp.row();
saveCategoriesFromMenu(menu, mapToModel(&m_ModList, selected.at(i)).row());
}
//m_ModList.notifyChange(min, max);
refreshModList();
+
+ // find mods by their name because indices are invalidated
+ QAbstractItemModel *model = ui->modList->model();
+ Q_FOREACH(const QString &mod, selectedMods) {
+ QModelIndexList matches = model->match(model->index(0, 0), Qt::DisplayRole, mod, 1,
+ Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive);
+ if (matches.size() > 0) {
+ ui->modList->selectionModel()->select(matches.at(0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
+ }
+ }
} else {
saveCategoriesFromMenu(menu, m_ContextRow);
m_ModList.notifyChange(m_ContextRow);
@@ -4318,6 +4335,9 @@ void MainWindow::on_groupCombo_currentIndexChanged(int index)
}
if (newModel != NULL) {
+#ifdef TEST_MODELS
+ new ModelTest(newModel, this);
+#endif // TEST_MODELS
m_ModListSortProxy->setSourceModel(newModel);
connect(ui->modList, SIGNAL(expanded(QModelIndex)),newModel, SLOT(expanded(QModelIndex)));
connect(ui->modList, SIGNAL(collapsed(QModelIndex)), newModel, SLOT(collapsed(QModelIndex)));
diff --git a/src/modlist.cpp b/src/modlist.cpp
index f87687bb..9510fd46 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -656,8 +656,9 @@ void ModList::removeRow(int row, const QModelIndex&)
void ModList::notifyChange(int rowStart, int rowEnd)
{
if (rowStart < 0) {
- beginResetModel();
- endResetModel();
+ reset();
+// beginResetModel();
+// endResetModel();
} else {
if (rowEnd == -1) rowEnd = rowStart;
emit dataChanged(this->index(rowStart, 0), this->index(rowEnd, this->columnCount() - 1));
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index ede83659..829140b0 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -228,18 +228,20 @@ bool ModListSortProxy::filterMatches(ModInfo::Ptr info, bool enabled) const
bool ModListSortProxy::filterAcceptsRow(int row, const QModelIndex&) const
{
- bool modEnabled = m_Profile != NULL ? m_Profile->modEnabled(row) : false;
+ if (m_Profile == NULL) {
+ return false;
+ }
+
+ if (row >= static_cast<int>(m_Profile->numMods())) {
+ qWarning("invalid row idx %d", row);
+ return false;
+ }
+ bool modEnabled = m_Profile->modEnabled(row);
return filterMatches(ModInfo::getByIndex(row), modEnabled);
}
-/*bool ModListSortProxy::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const
-{
- return m_EnabledColumns.test(source_column);
-}*/
-
-
bool ModListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent)
{
diff --git a/src/modlistsortproxy.h b/src/modlistsortproxy.h
index 21dc9f4d..dbaa2533 100644
--- a/src/modlistsortproxy.h
+++ b/src/modlistsortproxy.h
@@ -54,6 +54,8 @@ public:
bool filterMatches(ModInfo::Ptr info, bool enabled) const;
+void callReset() { reset(); }
+
public slots:
void displayColumnSelection(const QPoint &pos);
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp
index 2b03f5bf..cd78ca4c 100644
--- a/src/nexusinterface.cpp
+++ b/src/nexusinterface.cpp
@@ -388,7 +388,7 @@ void NexusInterface::nextRequest()
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml");
#pragma message("automatically insert the correct version number")
- request.setRawHeader("User-Agent", QString("Mod Organizer v0.13.0 (compatible to Nexus Client v%1)").arg(m_NMMVersion).toUtf8());
+ request.setRawHeader("User-Agent", QString("Mod Organizer v0.99.0 (compatible to Nexus Client v%1)").arg(m_NMMVersion).toUtf8());
info.m_Reply = m_AccessManager->get(request);
diff --git a/src/organizer.pro b/src/organizer.pro
index c4a829cf..ed0c817e 100644
--- a/src/organizer.pro
+++ b/src/organizer.pro
@@ -290,3 +290,8 @@ OTHER_FILES += \
stylesheets/dark.qss \
tutorials/tutorial_window_installer.js \
tutorials/tutorials_installdialog.qml
+
+
+#SOURCES += modeltest.cpp
+#HEADERS += modeltest.h
+#DEFINES += TEST_MODELS
diff --git a/src/version.rc b/src/version.rc
index 9921149a..3d0632b8 100644
--- a/src/version.rc
+++ b/src/version.rc
@@ -1,7 +1,7 @@
#include "Winver.h"
#define VER_FILEVERSION 0,99,0,0
-#define VER_FILEVERSION_STR 0,99,0,0
+#define VER_FILEVERSION_STR "0,99,0,0\0"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
@@ -14,8 +14,19 @@ FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
- VALUE "CompanyName", "Tannin"
+ BLOCK "040904B0"
+ BEGIN
VALUE "FileVersion", VER_FILEVERSION_STR
+ VALUE "CompanyName", "Tannin\0"
+ VALUE "FileDescription", "Mod Organizer UI\0"
+ VALUE "OriginalFilename", "ModOrganizer.exe\0"
+ VALUE "ProductName", "Mod Organizer\0"
+ VALUE "ProductVersion", VER_FILEVERSION_STR
+ END
END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0409L, 1200
+ END
END