summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-09-14 23:49:32 +0200
committerPetr Mrázek <peterix@gmail.com>2015-09-14 23:49:32 +0200
commit8d3f13c4478f7e99a32a0804d57ac2ece05d7e92 (patch)
tree2a18611e63cfbf501801563982562c136b0bca56 /application
parentdd8eacee1b28ca40f8dc770587d111656d92d5fb (diff)
downloadMultiMC-8d3f13c4478f7e99a32a0804d57ac2ece05d7e92.tar
MultiMC-8d3f13c4478f7e99a32a0804d57ac2ece05d7e92.tar.gz
MultiMC-8d3f13c4478f7e99a32a0804d57ac2ece05d7e92.tar.lz
MultiMC-8d3f13c4478f7e99a32a0804d57ac2ece05d7e92.tar.xz
MultiMC-8d3f13c4478f7e99a32a0804d57ac2ece05d7e92.zip
GH-1227 add world copy and rename
Diffstat (limited to 'application')
-rw-r--r--application/pages/WorldListPage.cpp43
-rw-r--r--application/pages/WorldListPage.h2
-rw-r--r--application/pages/WorldListPage.ui16
3 files changed, 60 insertions, 1 deletions
diff --git a/application/pages/WorldListPage.cpp b/application/pages/WorldListPage.cpp
index 30981978..3b531d5d 100644
--- a/application/pages/WorldListPage.cpp
+++ b/application/pages/WorldListPage.cpp
@@ -22,6 +22,7 @@
#include <QClipboard>
#include <QMessageBox>
#include <QTreeView>
+#include <QInputDialog>
#include "MultiMC.h"
@@ -35,6 +36,7 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
QSortFilterProxyModel * proxy = new QSortFilterProxyModel(this);
+ proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
proxy->setSourceModel(m_worlds.get());
ui->worldTreeView->setSortingEnabled(true);
ui->worldTreeView->setModel(proxy);
@@ -207,6 +209,8 @@ void WorldListPage::worldChanged(const QModelIndex &current, const QModelIndex &
ui->copySeedBtn->setEnabled(enable);
ui->mcEditBtn->setEnabled(enable);
ui->rmWorldBtn->setEnabled(enable);
+ ui->copyBtn->setEnabled(enable);
+ ui->renameBtn->setEnabled(enable);
}
void WorldListPage::on_addBtn_clicked()
@@ -224,4 +228,41 @@ void WorldListPage::on_addBtn_clicked()
}
m_worlds->startWatching();
}
-} \ No newline at end of file
+}
+
+void WorldListPage::on_copyBtn_clicked()
+{
+ QModelIndex index = getSelectedWorld();
+ if (!index.isValid())
+ {
+ return;
+ }
+ auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
+ auto world = (World *) worldVariant.value<void *>();
+ bool ok = false;
+ QString name = QInputDialog::getText(this, tr("World name"), tr("Enter a new name for the copy."), QLineEdit::Normal, world->name(), &ok);
+
+ if (ok && name.length() > 0)
+ {
+ world->install(m_worlds->dir().absolutePath(), name);
+ }
+}
+
+void WorldListPage::on_renameBtn_clicked()
+{
+ QModelIndex index = getSelectedWorld();
+ if (!index.isValid())
+ {
+ return;
+ }
+ auto worldVariant = m_worlds->data(index, WorldList::ObjectRole);
+ auto world = (World *) worldVariant.value<void *>();
+
+ bool ok = false;
+ QString name = QInputDialog::getText(this, tr("World name"), tr("Enter a new world name."), QLineEdit::Normal, world->name(), &ok);
+
+ if (ok && name.length() > 0)
+ {
+ world->rename(name);
+ }
+}
diff --git a/application/pages/WorldListPage.h b/application/pages/WorldListPage.h
index f3111f93..f0b0e7e9 100644
--- a/application/pages/WorldListPage.h
+++ b/application/pages/WorldListPage.h
@@ -82,6 +82,8 @@ private slots:
void on_mcEditBtn_clicked();
void on_rmWorldBtn_clicked();
void on_addBtn_clicked();
+ void on_copyBtn_clicked();
+ void on_renameBtn_clicked();
void on_viewFolderBtn_clicked();
void worldChanged(const QModelIndex &current, const QModelIndex &previous);
};
diff --git a/application/pages/WorldListPage.ui b/application/pages/WorldListPage.ui
index ecd9709f..b5fd33da 100644
--- a/application/pages/WorldListPage.ui
+++ b/application/pages/WorldListPage.ui
@@ -71,6 +71,20 @@
</widget>
</item>
<item>
+ <widget class="QPushButton" name="copyBtn">
+ <property name="text">
+ <string>Copy</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="renameBtn">
+ <property name="text">
+ <string>Rename</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="rmWorldBtn">
<property name="text">
<string>&amp;Remove</string>
@@ -134,6 +148,8 @@
<tabstop>tabWidget</tabstop>
<tabstop>worldTreeView</tabstop>
<tabstop>addBtn</tabstop>
+ <tabstop>copyBtn</tabstop>
+ <tabstop>renameBtn</tabstop>
<tabstop>rmWorldBtn</tabstop>
<tabstop>mcEditBtn</tabstop>
<tabstop>copySeedBtn</tabstop>