Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / client / ryzom_installer / src / serversmodel.cpp
blob7cda521dee0ecf02ffd023ff866c498b9774dbd5
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "stdpch.h"
18 #include "serversmodel.h"
20 CServersModel::CServersModel(QObject *parent):QAbstractListModel(parent)
22 m_servers = CConfigFile::getInstance()->getServers();
25 CServersModel::CServersModel(const CServers &servers, QObject *parent):QAbstractListModel(parent), m_servers(servers)
29 CServersModel::~CServersModel()
33 int CServersModel::rowCount(const QModelIndex &parent) const
35 return m_servers.size();
38 QVariant CServersModel::data(const QModelIndex &index, int role) const
40 if (role != Qt::DisplayRole) return QVariant();
42 const CServer &server = m_servers.at(index.row());
44 return server.name;
47 bool CServersModel::removeRows(int row, int count, const QModelIndex &parent)
49 if (row < 0) return false;
51 beginRemoveRows(parent, row, row + count - 1);
53 m_servers.removeAt(row);
55 endRemoveRows();
57 return true;
60 bool CServersModel::save() const
62 CConfigFile::getInstance()->setServers(m_servers);
64 return true;
67 int CServersModel::getIndexFromServerID(const QString &serverId) const
69 for(int i = 0; i < m_servers.size(); ++i)
71 if (m_servers[i].id == serverId) return i;
74 return -1;
77 QString CServersModel::getServerIDFromIndex(int index) const
79 if (index < 0 || index >= m_servers.size()) return "";
81 return m_servers[index].id;