コード例 #1
0
ファイル: servermodel.cpp プロジェクト: DragonZX/qmpdclient
QVariant ServerModel::data(const QModelIndex &index, int role) const {
	if ((role != Qt::DisplayRole && role != Qt::EditRole) || !index.isValid())
		return QVariant();

	ServerInfo si = m_servers.at(index.row());
	switch (index.column()) {
		case 0:
			return si.name();
		case 1:
			return si.address();
		case 2:
			return si.port();
		case 3:
			return role == Qt::EditRole ? "" : si.password().isEmpty() ? "" : "********";
	}
	return QVariant();
}