Exemple #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();
}
Exemple #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;
}