Exemplo n.º 1
0
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();
    }
}
Exemplo n.º 2
0
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);
	}
}
Exemplo n.º 3
0
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);
	}
}
Exemplo n.º 4
0
void UserEdit::accept() {
	QList<QListWidgetItem *> ql = qlwUserList->findItems(QString(), Qt::MatchStartsWith);
	foreach(QListWidgetItem * qlwi, ql) {
		const QString &name = qlwi->text();
		int id = qlwi->data(Qt::UserRole).toInt();
		if (qmUsers.value(id) != name) {
			qmChanged.insert(id, name);
		}
	}

	if (! qmChanged.isEmpty()) {
		MumbleProto::UserList mpul;
		QMap<int, QString>::const_iterator i;
		for (i=qmChanged.constBegin(); i!=qmChanged.constEnd(); ++i) {
			MumbleProto::UserList_User *u = mpul.add_users();
			u->set_user_id(i.key());
			if (! i.value().isEmpty())
				u->set_name(u8(i.value()));
		}
		g.sh->sendMessage(mpul);
	}

	QDialog::accept();
}
Exemplo n.º 5
0
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);
}