From 8d3f13c4478f7e99a32a0804d57ac2ece05d7e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 14 Sep 2015 23:49:32 +0200 Subject: GH-1227 add world copy and rename --- application/pages/WorldListPage.cpp | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'application/pages/WorldListPage.cpp') 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 #include #include +#include #include "MultiMC.h" @@ -35,6 +36,7 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr 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 ¤t, 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(); + 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(); + + 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); + } +} -- cgit v1.2.3