summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/dialogs/AccountListDialog.cpp9
-rw-r--r--logic/lists/MojangAccountList.cpp8
-rw-r--r--logic/lists/MojangAccountList.h5
3 files changed, 21 insertions, 1 deletions
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp
index af074514..838bef7f 100644
--- a/gui/dialogs/AccountListDialog.cpp
+++ b/gui/dialogs/AccountListDialog.cpp
@@ -16,6 +16,8 @@
#include "AccountListDialog.h"
#include "ui_AccountListDialog.h"
+#include <QItemSelectionModel>
+
#include <logger/QsLog.h>
#include <logic/auth/AuthenticateTask.h>
@@ -48,7 +50,12 @@ void AccountListDialog::on_addAccountBtn_clicked()
void AccountListDialog::on_rmAccountBtn_clicked()
{
- // TODO
+ QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
+ if (selection.size() > 0)
+ {
+ QModelIndex selected = selection.first();
+ m_accounts->removeAccount(selected);
+ }
}
void AccountListDialog::on_editAccountBtn_clicked()
diff --git a/logic/lists/MojangAccountList.cpp b/logic/lists/MojangAccountList.cpp
index 32317f84..442ef3af 100644
--- a/logic/lists/MojangAccountList.cpp
+++ b/logic/lists/MojangAccountList.cpp
@@ -73,6 +73,14 @@ void MojangAccountList::removeAccount(const QString& username)
onListChanged();
}
+void MojangAccountList::removeAccount(QModelIndex index)
+{
+ beginResetModel();
+ m_accounts.removeAt(index.row());
+ endResetModel();
+ onListChanged();
+}
+
void MojangAccountList::onListChanged()
{
diff --git a/logic/lists/MojangAccountList.h b/logic/lists/MojangAccountList.h
index 491abf6d..bccc2f9a 100644
--- a/logic/lists/MojangAccountList.h
+++ b/logic/lists/MojangAccountList.h
@@ -73,6 +73,11 @@ public:
virtual void removeAccount(const QString& username);
/*!
+ * Removes the account at the given QModelIndex.
+ */
+ virtual void removeAccount(QModelIndex index);
+
+ /*!
* \brief Finds an account by its username.
* \param The username of the account to find.
* \return A const pointer to the account with the given username. NULL if