Skip to content

Commit

Permalink
Merge pull request #2278 from BearWare/checkable_userrightsmodel
Browse files Browse the repository at this point in the history
Use Qt checkable flags in user rights model
  • Loading branch information
bear101 committed May 14, 2024
2 parents 037d274 + ab96099 commit 5f72d08
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Default Qt Client
- "Move Users" dialog
- Locale file size now also use in "file transfer" dialog
- "Check for Update" in "Help" menu
- Use Qt checkable flag in user rights list to allow screenreader to see if an item is checked
Android Client
-
iOS Client
Expand Down
7 changes: 7 additions & 0 deletions Client/qtTeamTalk/useraccountsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ QVariant UserRightsModel::data(const QModelIndex & index, int role /*= Qt::Displ
}

break;
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
case Qt::AccessibleTextRole :
switch (m_userrights[index.row()])
{
Expand All @@ -269,6 +270,7 @@ QVariant UserRightsModel::data(const QModelIndex & index, int role /*= Qt::Displ
default :
return QString("%1: %2").arg(data(index, Qt::DisplayRole).toString()).arg((m_activeUserRights & m_userrights[index.row()])? tr("Enabled") : tr("Disabled"));
}
#endif
case Qt::CheckStateRole :
switch (m_userrights[index.row()])
{
Expand All @@ -282,6 +284,11 @@ QVariant UserRightsModel::data(const QModelIndex & index, int role /*= Qt::Displ
return QVariant();
}

Qt::ItemFlags UserRightsModel::flags(const QModelIndex &index) const
{
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
}

QModelIndex UserRightsModel::index(int row, int column, const QModelIndex & /*parent = QModelIndex()*/) const
{
return createIndex(row, column, m_userrights[row]);
Expand Down
1 change: 1 addition & 0 deletions Client/qtTeamTalk/useraccountsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class UserRightsModel : public QAbstractItemModel
UserRightsModel(QObject* parent);
int columnCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex & index) const;
int rowCount(const QModelIndex & parent = QModelIndex()) const;
Expand Down

0 comments on commit 5f72d08

Please sign in to comment.