Example #1
0
void NewProtocol::protocolChanged(int n)
{
    if (m_last){
        removePage(m_last);
        delete m_last;
        m_last = NULL;
    }
    if (m_connectWnd){
        removePage(m_connectWnd);
        delete m_connectWnd;
        m_connectWnd = NULL;
    }
    if (m_setup){
        removePage(m_setup);
        delete m_setup;
        m_setup = NULL;
    }
    if (m_client){
        delete m_client;
        m_client = NULL;
    }
    if ((n < 0) || (n >= (int)(m_protocols.size())))
        return;
    Protocol *protocol = m_protocols[n];
    m_client = protocol->createClient(NULL);
    if (m_client == NULL)
        return;
    m_setup = m_client->setupWnd();
    if (m_setup == NULL){
        delete m_client;
        m_client = NULL;
        return;
    }
    connect(m_setup, SIGNAL(okEnabled(bool)), this, SLOT(okEnabled(bool)));
    connect(this, SIGNAL(apply()), m_setup, SLOT(apply()));
    addPage(m_setup, i18n(protocol->description()->text));
    m_connectWnd = new ConnectWnd(m_bStart);
    addPage(m_connectWnd, i18n(protocol->description()->text));
    if (m_bStart){
        m_last = new QWidget;
        addPage(m_last, i18n(protocol->description()->text));
    }
    setNextEnabled(currentPage(), true);
    setIcon(Pict(protocol->description()->icon));
    Event e(EventRaiseWindow, this);
    e.process();
}