summaryrefslogtreecommitdiffstats
path: root/logic/auth/MojangAccountList.cpp
diff options
context:
space:
mode:
authorSky <git@bunnies.cc>2013-12-14 09:35:23 +0000
committerSky <git@bunnies.cc>2013-12-14 09:35:23 +0000
commit20a332e97cad70582ac9fa89e37e231dbfeed454 (patch)
treeb73bc7cb6beeb19ebe1631c5129dc567c7c899d0 /logic/auth/MojangAccountList.cpp
parent50e9574c0cf8ffc6167799608d95201e6dcfb391 (diff)
downloadMultiMC-20a332e97cad70582ac9fa89e37e231dbfeed454.tar
MultiMC-20a332e97cad70582ac9fa89e37e231dbfeed454.tar.gz
MultiMC-20a332e97cad70582ac9fa89e37e231dbfeed454.tar.lz
MultiMC-20a332e97cad70582ac9fa89e37e231dbfeed454.tar.xz
MultiMC-20a332e97cad70582ac9fa89e37e231dbfeed454.zip
Make the account selection list use checkboxes rather than text for active boolean
Diffstat (limited to 'logic/auth/MojangAccountList.cpp')
-rw-r--r--logic/auth/MojangAccountList.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/logic/auth/MojangAccountList.cpp b/logic/auth/MojangAccountList.cpp
index 0d13cd34..841552f5 100644
--- a/logic/auth/MojangAccountList.cpp
+++ b/logic/auth/MojangAccountList.cpp
@@ -148,9 +148,6 @@ QVariant MojangAccountList::data(const QModelIndex &index, int role) const
case Qt::DisplayRole:
switch (index.column())
{
- case ActiveColumn:
- return account == m_activeAccount;
-
case NameColumn:
return account->username();
@@ -164,6 +161,13 @@ QVariant MojangAccountList::data(const QModelIndex &index, int role) const
case PointerRole:
return qVariantFromValue(account);
+ case Qt::CheckStateRole:
+ switch (index.column())
+ {
+ case ActiveColumn:
+ return account == m_activeAccount;
+ }
+
default:
return QVariant();
}
@@ -212,6 +216,36 @@ int MojangAccountList::columnCount(const QModelIndex &parent) const
return 2;
}
+Qt::ItemFlags MojangAccountList::flags(const QModelIndex &index) const
+{
+ if (index.row() < 0 || index.row() >= rowCount(index) || !index.isValid())
+ {
+ return Qt::NoItemFlags;
+ }
+
+ return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+bool MojangAccountList::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (index.row() < 0 || index.row() >= rowCount(index) || !index.isValid())
+ {
+ return false;
+ }
+
+ if(role == Qt::CheckStateRole)
+ {
+ if(value == Qt::Checked)
+ {
+ MojangAccountPtr account = this->at(index.row());
+ this->setActiveAccount(account->username());
+ }
+ }
+
+ emit dataChanged(index, index);
+ return true;
+}
+
void MojangAccountList::updateListData(QList<MojangAccountPtr> versions)
{
beginResetModel();