示例#1
0
void ProxyEditWindow::updateProxyView()
{
    QModelIndexList selection = ProxyView->selectionModel()->selectedIndexes();
    if (1 != selection.size())
        return;

    Host->clear();
    Port->clear();
    User->clear();
    Password->clear();

    NetworkProxy proxy = selection.at(0).data(NetworkProxyRole).value<NetworkProxy>();
    if (proxy)
    {
        int type = Type->findData(proxy.type());
        Type->setCurrentIndex(type == -1 ? 0 : type);
        Host->setText(proxy.address());
        Port->setText(QString::number(proxy.port()));
        User->setText(proxy.user());
        Password->setText(proxy.password());
        PollingUrl->setText(proxy.pollingUrl());

        SaveButton->setText(tr("Save"));
        RemoveButton->show();
    }
    else
    {
        SaveButton->setText(tr("Add"));
        RemoveButton->hide();
    }

    dataChanged();
}
示例#2
0
ConfigurationValueState ProxyEditWindow::state(NetworkProxy proxy)
{
    bool valid = !Host->text().isEmpty()
                 && !Port->text().isEmpty();
    bool changed = proxy.type() != Type->itemData(Type->currentIndex()).toString()
                   || proxy.address() != Host->text()
                   || ((QString::number(proxy.port()) != Port->text()) && (proxy.port() != 0 || !Port->text().isEmpty()))
                   || proxy.user() != User->text()
                   || proxy.password() !=  Password->text()
                   || proxy.pollingUrl() !=  PollingUrl->text();

    if (!changed)
        return StateNotChanged;

    return valid
           ? StateChangedDataValid
           : StateChangedDataInvalid;
}
void NetworkAccessManagerWrapper::configurationUpdated()
{
	NetworkProxy networkProxy;

	if (Application::instance()->configuration()->deprecatedApi()->readBoolEntry("SMS", "DefaultProxy", true))
		networkProxy = NetworkProxyManager::instance()->defaultProxy();
	else
		networkProxy = NetworkProxyManager::instance()->byUuid(Application::instance()->configuration()->deprecatedApi()->readEntry("SMS", "Proxy"));

	QNetworkProxy proxy;

	if (networkProxy)
	{
		proxy.setType(QNetworkProxy::HttpProxy);
		proxy.setHostName(networkProxy.address());
		proxy.setPort(networkProxy.port());
		proxy.setUser(networkProxy.user());
		proxy.setPassword(networkProxy.password());
	}
	else
		proxy.setType(QNetworkProxy::NoProxy);

	setProxy(proxy);
}