added categories to the accountspage

This commit is contained in:
fourtf
2018-05-28 08:34:54 +02:00
parent 87f33501b2
commit 6156b1f430
22 changed files with 187 additions and 51 deletions
+34 -2
View File
@@ -9,7 +9,29 @@ namespace accounts {
AccountController::AccountController()
{
this->twitch.accounts.itemInserted.connect([this](const auto &args) {
accounts.insertItem(std::dynamic_pointer_cast<Account>(args.item));
this->accounts.insertItem(std::dynamic_pointer_cast<Account>(args.item));
});
this->twitch.accounts.itemRemoved.connect([this](const auto &args) {
if (args.caller != this) {
auto &accs = this->twitch.accounts.getVector();
auto it = std::find(accs.begin(), accs.end(), args.item);
assert(it != accs.end());
this->accounts.removeItem(it - accs.begin());
}
});
this->accounts.itemRemoved.connect([this](const auto &args) {
switch (args.item->getProviderId()) {
case ProviderId::Twitch: {
auto &accs = this->twitch.accounts.getVector();
auto it = std::find(accs.begin(), accs.end(), args.item);
assert(it != accs.end());
this->twitch.accounts.removeItem(it - accs.begin(), this);
} break;
}
});
}
@@ -21,8 +43,18 @@ void AccountController::load()
AccountModel *AccountController::createModel(QObject *parent)
{
AccountModel *model = new AccountModel(parent);
// model->accountRemoved.connect([this](const auto &account) {
// switch (account->getProviderId()) {
// case ProviderId::Twitch: {
// auto &accs = this->twitch.accounts.getVector();
// auto it = std::find(accs.begin(), accs.end(), account);
// assert(it != accs.end());
// this->twitch.accounts.removeItem(it - accs.begin());
// } break;
// }
// });
//(util::BaseSignalVector<stdAccount> *)
model->init(&this->accounts);
return model;
}