UserListModel::UserListModel(const MumbleProto::UserList& userList, QObject *parent) : QAbstractTableModel(parent) , m_legacyMode(false) { m_userList.reserve(userList.users_size()); for (int i = 0; i < userList.users_size(); ++i) { m_userList.append(userList.users(i)); } if (!m_userList.empty()) { const MumbleProto::UserList_User& user = m_userList.back(); m_legacyMode = !user.has_last_seen() || !user.has_last_channel(); } }
UserEdit::UserEdit(const MumbleProto::UserList &msg, QWidget *p) : QDialog(p) { setupUi(this); qlwUserList->setContextMenuPolicy(Qt::CustomContextMenu); for (int i=0;i<msg.users_size(); ++i) { const MumbleProto::UserList_User &u = msg.users(i); int id = u.user_id(); const QString &name = u8(u.name()); UserEditListItem *ueli = new UserEditListItem(name, id); qlwUserList->addItem(ueli); qmUsers.insert(id, name); } }
UserEdit::UserEdit(const MumbleProto::UserList &msg, QWidget *p) : QDialog(p) { setupUi(this); qlwUserList->setContextMenuPolicy(Qt::CustomContextMenu); for (int i=0;i<msg.users_size(); ++i) { const MumbleProto::UserList_User &u = msg.users(i); int id = u.user_id(); const QString &name = u8(u.name()); QListWidgetItem *qlwi = new QListWidgetItem(name); qlwi->setFlags(qlwi->flags() | Qt::ItemIsEditable); qlwi->setData(Qt::UserRole, id); qlwUserList->addItem(qlwi); qmUsers.insert(id, name); } }
UserEdit::UserEdit(const MumbleProto::UserList &userList, QWidget *p) : QDialog(p) , m_model(new UserListModel(userList, this)) , m_filter(new UserListFilterProxyModel(this)) { setupUi(this); const int userCount = userList.users_size(); setWindowTitle(tr("Registered users: %n account(s)", "", userCount)); m_filter->setSourceModel(m_model); qtvUserList->setModel(m_filter); QItemSelectionModel *selectionModel = qtvUserList->selectionModel(); connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(onSelectionChanged(QItemSelection,QItemSelection))); connect(selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(onCurrentRowChanged(QModelIndex,QModelIndex))); qtvUserList->setFocus(); qtvUserList->setContextMenuPolicy(Qt::CustomContextMenu); #if QT_VERSION >= 0x050000 qtvUserList->header()->setSectionResizeMode(UserListModel::COL_NICK, QHeaderView::Stretch); if (!m_model->isLegacy()) { qtvUserList->header()->setSectionResizeMode(UserListModel::COL_INACTIVEDAYS, QHeaderView::ResizeToContents); qtvUserList->header()->setSectionResizeMode(UserListModel::COL_LASTCHANNEL, QHeaderView::Stretch); } #else qtvUserList->header()->setResizeMode(UserListModel::COL_NICK, QHeaderView::Stretch); if (!m_model->isLegacy()) { qtvUserList->header()->setResizeMode(UserListModel::COL_INACTIVEDAYS, QHeaderView::ResizeToContents); qtvUserList->header()->setResizeMode(UserListModel::COL_LASTCHANNEL, QHeaderView::Stretch); } #endif if (m_model->isLegacy()) { qlInactive->hide(); qsbInactive->hide(); qcbInactive->hide(); } qtvUserList->sortByColumn(UserListModel::COL_NICK, Qt::AscendingOrder); }