Skip to content

Commit

Permalink
Sort user accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
bear101 committed Feb 14, 2019
1 parent 8291681 commit fa1e012
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Client/qtTeamTalk/useraccountsdlg.cpp
Expand Up @@ -176,7 +176,15 @@ UserAccountsDlg::UserAccountsDlg(const useraccounts_t& useraccounts, UserAccount
setWindowIcon(QIcon(APPICON));

m_model = new UserAccountsModel(this);
ui.usersTreeView->setModel(m_model);
m_proxyModel = new QSortFilterProxyModel(this);
m_proxyModel->setSourceModel(m_model);
ui.usersTreeView->setModel(m_proxyModel);

#if defined(Q_OS_MAC)
auto font = ui.usersTreeView->font();
font.setPointSize(13);
ui.usersTreeView->setFont(font);
#endif

int count = 0;
TT_GetServerChannels(ttInst, NULL, &count);
Expand Down Expand Up @@ -573,8 +581,9 @@ void UserAccountsDlg::slotAddUser()

void UserAccountsDlg::slotDelUser()
{
int index = ui.usersTreeView->currentIndex().row();
if(index<0)
auto proxySelection = ui.usersTreeView->currentIndex();
int index = m_proxyModel->mapToSource(proxySelection).row();
if (index < 0)
return;

m_del_cmdid = TT_DoDeleteUserAccount(ttInst, m_model->getUsers()[index].szUsername);
Expand All @@ -585,8 +594,8 @@ void UserAccountsDlg::slotDelUser()

void UserAccountsDlg::slotUserSelected(const QModelIndex & index )
{
int i = index.row();
if(i<0)
int i = m_proxyModel->mapToSource(index).row();
if (i < 0)
{
ui.delButton->setEnabled(false);
return;
Expand Down
2 changes: 2 additions & 0 deletions Client/qtTeamTalk/useraccountsdlg.h
Expand Up @@ -27,6 +27,7 @@
#include "common.h"

#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <QVector>
#include <QSet>
#include "ui_useraccounts.h"
Expand Down Expand Up @@ -75,6 +76,7 @@ public slots:
private:
Ui::UserAccountsDlg ui;
UserAccountsModel* m_model;
QSortFilterProxyModel* m_proxyModel;
int m_add_cmdid, m_del_cmdid;

UserAccount m_add_user;
Expand Down

0 comments on commit fa1e012

Please sign in to comment.