void ServerDiscoveryModel::removeService(KDNSSD::RemoteService::Ptr service)
{
	for(int i=0;i<_servers.size();++i) {
		if(_servers.at(i).name == service->serviceName()) {
			beginRemoveRows(QModelIndex(), i, i);
			_servers.removeAt(i);
			endRemoveRows();
			return;
		}
	}
}
void ServerDiscoveryModel::addService(KDNSSD::RemoteService::Ptr service)
{
	QUrl url;
	url.setScheme("drawpile");
	QHostAddress hostname = KDNSSD::ServiceBrowser::resolveHostName(service->hostName());
	url.setHost(hostname.isNull() ? service->hostName() : hostname.toString());
	if(service->port() != DRAWPILE_PROTO_DEFAULT_PORT)
		url.setPort(service->port());

	QDateTime started = QDateTime::fromString(service->textData()["started"], Qt::ISODate);
	started.setTimeSpec(Qt::UTC);

	DiscoveredServer s {
		url,
		service->serviceName(),
		service->textData()["title"],
		service->textData()["protocol"],
		started
	};

	beginInsertRows(QModelIndex(), _servers.size(), _servers.size());
	_servers.append(s);
	endInsertRows();
}