Exemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindowClass)
{
    ui->setupUi(this);    
    ui->statusBar->showMessage(QString::fromStdString(dtnet::version()));
    
    ui->dockProperties->setObjectName("NetworkProperties");
    ui->dockProperties->setWindowTitle(tr("Network Properties"));
    
    networkToolBox = new QToolBox();
    ui->dockProperties->setWidget(networkToolBox);
	
	tabWidget = new QTabWidget();
	networkView = new NetworkView( NULL );
    
	networkTab = tabWidget->addTab(networkView, QString("Network View"));
    
    voltageLabel = new QLabel;   
    rtvoltageTab = tabWidget->addTab(voltageLabel, QString("Real-Time Voltage"));
	
	setCentralWidget(tabWidget);
	
    // Setup Signals and Slots
    QObject::connect(&ws, SIGNAL(networkChanged()), 
                     this, SLOT(loadNetwork())
                    );
    QObject::connect(&ws, SIGNAL(trialChanged()), 
                     this, SLOT(loadNetwork())
                    );
                    
    // We can't run simulations by default
    ui->actionRun_Simulation->setEnabled( false );
}
Exemplo n.º 2
0
void MainWindow::on_actionImport_NS_triggered()
{
    //Open and parse an NS file
    QFileDialog importDialog(this, "Import NS File");
    importDialog.setFileMode(QFileDialog::ExistingFile);
    importDialog.setNameFilter(tr("NS Files (*.ns)"));

    importDialog.exec();
    QStringList fileList = importDialog.selectedFiles();

    if(fileList.size() == 1) {

        qDebug() << "Importing [" << fileList.at(0) << "]";


        statusBar()->showMessage(QString("Importing file ").append(fileList.at(0)));

        if(netgraphics != NULL) {
            delete netgraphics;
        }

        if(network != NULL) {
            //disconnect(network, SIGNAL(networkChanged()), this, SLOT(update()));
            delete network;
        }


        network = new NetworkDesc(this);
        netgraphics = new NetworkGraphics(network, scene, this);

        connect(network, SIGNAL(networkChanged()), this, SLOT(update()));

        network->parseNSFile(fileList.at(0));

        updateView();
    }
    else if(fileList.size() > 1) {
        qDebug() << "User selected" << fileList.size() << "files!";

        QMessageBox errorMsg(QMessageBox::Warning, "NS Import Error", "Importing multiple files not supported");
        errorMsg.exec();
    }
    else {
        qDebug() << "No NS file selected";
    }

}
Exemplo n.º 3
0
void Session::handleMessage(IrcMessage* message)
{
    // 20s delay since the last message was received
    setPingInterval(20);

    if (message->type() == IrcMessage::Join)
    {
        if (message->isOwn())
            addChannel(static_cast<IrcJoinMessage*>(message)->channel());
    }
    else if (message->type() == IrcMessage::Part)
    {
        if (message->isOwn())
            removeChannel(static_cast<IrcPartMessage*>(message)->channel());
    }
    else if (message->type() == IrcMessage::Pong)
    {
        if (message->parameters().contains("_C_o_m_m_u_n_i_"))
        {
            // slow down to 60s intervals
            setPingInterval(60);

            updateLag(static_cast<int>(m_lagTimer.elapsed()));
            m_lagTimer.invalidate();
        }
    }
    else if (message->type() == IrcMessage::Numeric)
    {
        int code = static_cast<IrcNumericMessage*>(message)->code();
        if (code == Irc::RPL_ISUPPORT)
        {
            foreach (const QString& param, message->parameters().mid(1))
            {
                QStringList keyValue = param.split("=", QString::SkipEmptyParts);
                m_info.insert(keyValue.value(0), keyValue.value(1));
            }
            if (m_info.contains("NETWORK"))
                emit networkChanged(network());
            emit serverInfoReceived();
        }
Exemplo n.º 4
0
void VoreenVisualization::processorRemoved(const Processor* /*processor*/) {
    networkChanged();
}