Exemplo n.º 1
0
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;
		}
	}
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
void NoteHostDialog::slotServiceDoubleClicked(const QModelIndex &idx)
{
    KDNSSD::RemoteService::Ptr srv = idx.data(KDNSSD::ServiceModel::ServicePtrRole).value<KDNSSD::RemoteService::Ptr>();
    m_hostCombo->lineEdit()->setText(srv->hostName() + QLatin1String(":") + QString::number(srv->port()));
    accept();
}