Esempio n. 1
0
        server::server(const std::string& address, const std::string& port)
          : io_service_(),
            signals_(io_service_),
            acceptor_(io_service_),
            connection_manager_(),
            socket_(io_service_),
            request_handler_()
        {
          // Register to handle the signals that indicate when the server should exit.
          // It is safe to register for the same signal multiple times in a program,
          // provided all registration for the specified signal is made through asio.
          signals_.add(SIGINT);
          signals_.add(SIGTERM);
#if defined(SIGQUIT)
          signals_.add(SIGQUIT);
#endif // defined(SIGQUIT)

          doAwaitStop();

          // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
          boost::asio::ip::tcp::resolver resolver(io_service_);
          boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve({address, port});
          acceptor_.open(endpoint.protocol());
          acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
          acceptor_.bind(endpoint);
          acceptor_.listen();

          doAccept();
        }
Esempio n. 2
0
void ConfigComputerDialog::createControls()
{
    lstView = new QListWidget(this);
    pages = new QStackedWidget(this);

    panMain = createMainWidget();
    panSolver = createSolverWidget();

    // List View
    lstView->setCurrentRow(0);
    lstView->setViewMode(QListView::IconMode);
    lstView->setResizeMode(QListView::Adjust);
    lstView->setMovement(QListView::Static);
    lstView->setFlow(QListView::TopToBottom);
    lstView->setIconSize(QSize(60, 60));
    lstView->setMinimumWidth(135);
    lstView->setMaximumWidth(135);
    lstView->setMinimumHeight((45+fontMetrics().height()*4)*5);
    connect(lstView, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
            this, SLOT(doCurrentItemChanged(QListWidgetItem *, QListWidgetItem *)));

    QSize sizeItem(131, 85);

    // listView items
    QListWidgetItem *itemMain = new QListWidgetItem(icon("options-main"), tr("Main"), lstView);
    itemMain->setTextAlignment(Qt::AlignHCenter);
    itemMain->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    itemMain->setSizeHint(sizeItem);

    QListWidgetItem *itemSolver = new QListWidgetItem(icon("options-solver"), tr("Solver"), lstView);
    itemSolver->setTextAlignment(Qt::AlignHCenter);
    itemSolver->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    itemSolver->setSizeHint(sizeItem);

    pages->addWidget(panMain);
    pages->addWidget(panSolver);

    QHBoxLayout *layoutHorizontal = new QHBoxLayout();
    layoutHorizontal->addWidget(lstView);
    layoutHorizontal->addWidget(pages);

    // dialog buttons
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addLayout(layoutHorizontal);
    // layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);
}
Esempio n. 3
0
ccDisplayOptionsDlg::ccDisplayOptionsDlg(QWidget* parent)
	: QDialog(parent, Qt::Tool)
	, Ui::DisplayOptionsDlg()
{
	setupUi(this);

	connect(ambientColorButton,              SIGNAL(clicked()),         this, SLOT(changeLightAmbientColor()));
	connect(diffuseColorButton,              SIGNAL(clicked()),         this, SLOT(changeLightDiffuseColor()));
	connect(specularColorButton,             SIGNAL(clicked()),         this, SLOT(changeLightSpecularColor()));
	connect(meshBackColorButton,             SIGNAL(clicked()),         this, SLOT(changeMeshBackDiffuseColor()));
	connect(meshSpecularColorButton,         SIGNAL(clicked()),         this, SLOT(changeMeshSpecularColor()));
	connect(meshFrontColorButton,            SIGNAL(clicked()),         this, SLOT(changeMeshFrontDiffuseColor()));
	connect(bbColorButton,                   SIGNAL(clicked()),         this, SLOT(changeBBColor()));
	connect(bkgColorButton,                  SIGNAL(clicked()),         this, SLOT(changeBackgroundColor()));
	connect(labelBkgColorButton,             SIGNAL(clicked()),         this, SLOT(changeLabelBackgroundColor()));
	connect(labelMarkerColorButton,          SIGNAL(clicked()),         this, SLOT(changeLabelMarkerColor()));
	connect(enableGradientCheckBox,          SIGNAL(clicked()),         this, SLOT(changeBackgroundGradient()));
	connect(pointsColorButton,               SIGNAL(clicked()),         this, SLOT(changePointsColor()));
	connect(textColorButton,                 SIGNAL(clicked()),         this, SLOT(changeTextColor()));
	connect(decimateMeshBox,                 SIGNAL(clicked()),         this, SLOT(changeMeshDecimation()));
	connect(decimateCloudBox,                SIGNAL(clicked()),         this, SLOT(changeCloudDecimation()));
	connect(useVBOCheckBox,                  SIGNAL(clicked()),         this, SLOT(changeVBOUsage()));
	connect(showCrossCheckBox,               SIGNAL(clicked()),         this, SLOT(changeCrossDisplayed()));

	connect(colorScaleShowHistogramCheckBox, SIGNAL(clicked()),         this, SLOT(changeColorScaleShowHistogram()));
	connect(useColorScaleShaderCheckBox,     SIGNAL(clicked()),         this, SLOT(changeColorScaleUseShader()));
	connect(colorRampWidthSpinBox,           SIGNAL(valueChanged(int)), this, SLOT(changeColorScaleRampWidth(int)));

	connect(defaultFontSizeSpinBox,          SIGNAL(valueChanged(int)), this, SLOT(changeDefaultFontSize(int)));
	connect(labelFontSizeSpinBox,            SIGNAL(valueChanged(int)), this, SLOT(changeLabelFontSize(int)));
	connect(numberPrecisionSpinBox,          SIGNAL(valueChanged(int)), this, SLOT(changeNumberPrecision(int)));
	connect(labelOpacitySpinBox,             SIGNAL(valueChanged(int)), this, SLOT(changeLabelOpacity(int)));
	connect(labelMarkerSizeSpinBox,          SIGNAL(valueChanged(int)), this, SLOT(changeLabelMarkerSize(int)));

	connect(zoomSpeedDoubleSpinBox,          SIGNAL(valueChanged(double)), this, SLOT(changeZoomSpeed(double)));
	connect(maxCloudSizeDoubleSpinBox,       SIGNAL(valueChanged(double)), this, SLOT(changeMaxCloudSize(double)));
	connect(maxMeshSizeDoubleSpinBox,        SIGNAL(valueChanged(double)), this, SLOT(changeMaxMeshSize(double)));

	connect(autoComputeOctreeComboBox,       SIGNAL(currentIndexChanged(int)), this, SLOT(changeAutoComputeOctreeOption(int)));

	connect(okButton,                        SIGNAL(clicked()),         this, SLOT(doAccept()));
	connect(applyButton,                     SIGNAL(clicked()),         this, SLOT(apply()));
	connect(resetButton,                     SIGNAL(clicked()),         this, SLOT(reset()));
	connect(cancelButton,                    SIGNAL(clicked()),         this, SLOT(doReject()));

	oldParameters = parameters = ccGui::Parameters();

	refresh();

	setUpdatesEnabled(true);
}
Esempio n. 4
0
void DSceneBasic::createControls()
{
    logMessage("DSceneBasic::createControls()");

    // dialog buttons
    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));

    layout->addLayout(createContent());
    layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);
}
void
SocketServer::doRun(){

  while(!m_stopThread){
    m_session_mutex.lock();
    checkSessionsImpl();
    if(m_sessions.size() < m_maxSessions){
      m_session_mutex.unlock();
      doAccept();
    } else {
      m_session_mutex.unlock();
      NdbSleep_MilliSleep(200);
    }
  }
}
Esempio n. 6
0
        void server::doAccept()
        {
          acceptor_.async_accept(socket_,
              [this](boost::system::error_code ec)
              {
                // Check whether the server was stopped by a signal before this
                // completion handler had a chance to run.
                if(!acceptor_.is_open()) {
                  return;
                }

                if(!ec) {
                  connection_manager_.start(std::make_shared<connection>(std::move(socket_), connection_manager_, request_handler_));
                }

                doAccept();
              });
        }
void
SocketServer::doRun(){

  while(!m_stopThread){
    m_session_mutex.lock();
    checkSessionsImpl();
    m_session_mutex.unlock();

    if(m_sessions.size() >= m_maxSessions){
      // Don't accept more connections yet
      NdbSleep_MilliSleep(200);
      continue;
    }

    if (!doAccept()){
      // accept failed, step back
      NdbSleep_MilliSleep(200);
    }
  }
}
Esempio n. 8
0
DatabaseConfigDialog::DatabaseConfigDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DatabaseConfigDialog)
{
    ui->setupUi(this);

    // booleano para especificar si se pudo conectar al abrir
    // la aplicacion
    initialStage = false;

    // establecer el nombre del controlador para la conexion a BD
    ui->comboBoxDriver->insertItem(0,"psql");

    // conexiones
    connect(ui->okButton, SIGNAL(clicked()), this, SLOT(doAccept()));
    connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(doCancel()));
    connect(ui->checkBoxDBLocal, SIGNAL(stateChanged(int)), this, SLOT(checkBoxLocal(int)));

    cancelFlag = false;
}
Esempio n. 9
0
OptionsDialog::OptionsDialog(QWidget *parent)
: QDialog(parent)
{
    setupUi(this);

    //qDebug("...OptionsDialog...connect..(%d)...(%d)",ui.loadButton, this );
    //OptionsDialog *mydlg = this;   
   // connect(checkButton, SIGNAL(clicked()), SLOT(doLoadWidget()) );
    connect(loadButton, SIGNAL(clicked()), SLOT(doLoadWidget()) );
    connect(addButton, SIGNAL(clicked()), SLOT(addWidget()) );
     connect(delButton, SIGNAL(clicked()), SLOT(delWidget()) );
      connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
     Q_CHECK_PTR( parent );
     MainWindow* mw = qobject_cast<MainWindow*>(parent);
     Q_CHECK_PTR( mw );
     Q_CHECK_PTR( listWidget );
     listWidget->addItems( mw->plugs() );
     buildTab();
     //setWindowOpacity(0.5);

}
Esempio n. 10
0
void main(int argc,char **argv)
{
	int listener;
	int c;
	int f;
	
	while ((c = getopt (argc, argv, "d")) != -1)
	{
		switch(c)
		{
			case 'd':
				debug++;
				break;
			default:
				exit(1);
		}
	}
	if(!debug) {
		f = fork();
		if(f<0) { printf("Fork error [err=%d]\n",errno); exit(1); }
		if(f>0) exit(0); // Parent
		setsid(); for (f=getdtablesize();f>=0;--f) close(f);
		f=open("/dev/null",O_RDWR); dup(f); dup(f); umask(027); chdir("/tmp/");
		signal( SIGCHLD, SIG_IGN ); 
	}
        openlog ("nbd", LOG_CONS|LOG_PID|LOG_NDELAY , LOG_USER);
	doLog("NBD server v0.1 started");
	if(doCreatePid()<0) {
		doLog("-- ABORT");
		exit(1);
	}
	if((listener=getSocket())>0) {
		doAccept(listener);
		close(listener);
	}
	doLog("NBD server stopped");
	closelog ();
	exit(0); 
}
Esempio n. 11
0
void ProblemDialog::createControls()
{
    logMessage("ProblemDialog::createControls()");

    // tab
    QTabWidget *tabType = new QTabWidget();
    tabType->addTab(createControlsGeneral(), icon(""), tr("General"));
    tabType->addTab(createControlsStartupScript(), icon(""), tr("Startup script"));
    tabType->addTab(createControlsDescription(), icon(""), tr("Description"));

    // dialog buttons
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(tabType);
    layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);
}
Esempio n. 12
0
void SceneBasicSelectDialog::createControls()
{
    logMessage("SceneBasicSelectDialog::createControls()");

    // edge
    lstEdges = new QListWidget(this);
    for (int i = 1; i < Util::scene()->edges.count(); i++)
    {
        QListWidgetItem *item = new QListWidgetItem(lstEdges);
        item->setText(QString::number(i)); // Util::scene()->edges[i]->
        if (Util::scene()->edges[i]->isSelected)
            item->setCheckState(Qt::Checked);
        else
            item->setCheckState(Qt::Unchecked);
        lstEdges->addItem(item);
    }

    connect(lstEdges, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
            this, SLOT(currentItemChanged(QListWidgetItem *, QListWidgetItem *)));

    QGridLayout *layoutSurface = new QGridLayout();
    layoutSurface->addWidget(lstEdges);

    widEdge = new QWidget();
    widEdge->setLayout(layoutSurface);

    // dialog buttons
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(widEdge, 1);
    layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);
}
Esempio n. 13
0
 void TiffComponent::accept(TiffVisitor& visitor)
 {
     if (visitor.go()) doAccept(visitor);    // one for NVI :)
 } // TiffComponent::accept
Esempio n. 14
0
	/*! @detail
	 * The created BaseTCP must later be freed
	 */
	BaseTCP *Accept() { return doAccept(); }
Esempio n. 15
0
int main (int argc, char **argv)
{
	int port = 0;
	const int poolSize = EPOLL_SIZE;
	const int epollSize= EVENT_SIZE;
	struct epoll_event *events;
	struct epoll_event ev;
	int efd=0, sfd=0, cfd=0;
	int rst=0;
	int rvEvents=0;
	int i=0;

	printf ("WEB SERVER v1.0 - build date: %s\n", __DATE__);
	if (argc > 1){
		port = atoi (argv[1]);
	}
	else {
		printf ("usage: $webserver port\n");
		return 0;
	}

	signal (SIGPIPE, SIG_IGN);

	efd = epoll_init (epollSize);
	if (efd < 0) {
		perror (" init_epoll error");
		return 0;
	}

	events = (struct epoll_event *) malloc(sizeof(*events) * poolSize); 
	if (NULL == events) {
		perror (" epoll_event malloc error");
		close(efd);
		return 0;
	}

	sfd = initAcceptSock (port);
	if (sfd < 0) {
		perror (" init_acceptsock error");
		close(efd);
		close(sfd);
		free(events);
		return 0;
	}

	rst = epoll_in_add (efd, sfd);
	if (rst < 0) {
		perror ("epollf_in_add error");
		close(efd);
		close(sfd);
		free(events);
		return 0;
	}

	while (1) 
	{ 
		rvEvents = epoll_wait (efd, events, poolSize, -1); 
		for (i = 0; i < rvEvents; i++)
		{ 
			if (events[i].data.fd == sfd) { 
				cfd = doAccept (efd, sfd);
			} 
			else {
				doEcho (efd, events[i].data.fd);
			} 
		} 
	} 

}
Esempio n. 16
0
void CWSAThread::doWSAEvent()
{
    SOCKET_KEY* pkey = NULL;

    while (m_bOperate)
    {
        //TODO check here, WSA_MAXIMUM_WAIT_EVENTS
        int nIndex = ::WSAWaitForMultipleEvents(m_nEventTotal, m_eventArray, FALSE, 10, FALSE);
        nIndex = nIndex - WSA_WAIT_EVENT_0;
        for (int i = nIndex; i < m_nEventTotal; ++i)
        {
            if (m_eventArray[i] == WSA_INVALID_EVENT)
            {
                continue;
            }

            int nret = ::WSAWaitForMultipleEvents(1, &m_eventArray[i], TRUE, 10, FALSE);

            if (nret == WSA_WAIT_FAILED || nret == WSA_WAIT_TIMEOUT)
            {
                if (nret == WSA_WAIT_FAILED)
                    LOG(_ERROR_, "CWSAThread::doWSAEvent() error, (nIndex == WSA_WAIT_FAILED)");
                continue;
            }
            else
            {
                WSANETWORKEVENTS event;
                if (::WSAEnumNetworkEvents(m_sockArray[i], m_eventArray[i], &event) == SOCKET_ERROR)
                {
                    LOG(_ERROR_, "CWSAThread::doWSAEvent() error, ::WSAEnumNetworkEvents() failed, error=%s", WSAGetLastError());
                    continue;
                }

                SOCKET_KEY* pkey = m_keymap[i];
                if (pkey == NULL)
                {
                    LOG(_ERROR_, "CWSAThread::doWSAEvent() error, pkey == NULL, SOCKET_KEY* pkey = m_keymap[%d]", i);
                    continue;
                }

                if (event.lNetworkEvents & FD_ACCEPT)
                {
                    LOG(_INFO_, "CWSAThread::doWSAEvent(), FD_ACCEPT, m_listenfd=%d, m_sockArray[i]=%d", m_listenfd, m_sockArray[i]);
                    if (event.iErrorCode[FD_ACCEPT_BIT] == 0)
                    {
                        if (m_nEventTotal > WSA_MAXIMUM_WAIT_EVENTS)
                        {
                            LOG(_INFO_, "CWSAThread::doWSAEvent() error, m_nEventTotal > WSA_MAXIMUM_WAIT_EVENTS");
                            continue;
                        }

                        if (m_listenfd == m_sockArray[i] && m_listenfd == pkey->fd)
                        {
                            if (!doAccept(m_listenfd))
                            {
                                LOG(_ERROR_, "CWSAThread::doWSAEvent() error, m_listenfd=%d", m_listenfd);
                            }
                        }
                    }
                }
                else if (event.lNetworkEvents & FD_READ)
                {
                    LOG(_INFO_, "CWSAThread::doWSAEvent(), FD_READ, m_listenfd=%d, m_sockArray[i]=%d", m_listenfd, m_sockArray[i]);
                    if (event.iErrorCode[FD_ACCEPT_BIT] == 0)
                    {
                        if (m_nEventTotal > WSA_MAXIMUM_WAIT_EVENTS)
                        {
                            LOG(_INFO_, "CWSAThread::doWSAEvent() error, m_nEventTotal > WSA_MAXIMUM_WAIT_EVENTS");
                            continue;
                        }
                        if (m_listenfd == m_sockArray[i] && m_listenfd == pkey->fd)
                        {
                            if (!doAccept(m_listenfd))
                            {
                                LOG(_ERROR_, "CWSAThread::doWSAEvent() error, m_listenfd=%d", m_listenfd);
                            }
                            continue;
                        }
                        doRecvMessage(pkey);
                    }
                }
                else if (event.lNetworkEvents & FD_WRITE)
                {
                    LOG(_INFO_, "CWSAThread::doWSAEvent(), FD_WRITE, m_listenfd=%d, m_sockArray[i]=%d", m_listenfd, m_sockArray[i]);
                    if (doSendMessage(pkey) < 0)
                    {
                        closeClient(pkey->fd, pkey->connect_time);
                    }
                    else
                    {
                        //TODO reset socket event here ?
                    }
                }
                else
                {
                    LOG(_INFO_, "CWSAThread::doWSAEvent(), FD_XXX, m_listenfd=%d, m_sockArray[i]=%d", m_listenfd, m_sockArray[i]);
                    closeClient(pkey->fd, pkey->connect_time);
                }
            }
        }//end for
        //// end handle WSAWaitForMultipleEvents /////

        /////////////////begin copy all recv message to recv list/////////////////
        if (m_recvtmplst.size() > 0)
        {
            CSysQueue<NET_DATA>* precvlist = CGlobalMgr::getInstance()->getRecvQueue();
            precvlist->Lock();
            list<NET_DATA*>::iterator iter = m_recvtmplst.begin();
            for (; iter != m_recvtmplst.end(); ++iter)
            {
                if ( (*iter) == NULL)
                    continue;
                if (!precvlist->inQueueWithoutLock(*iter, false))
                {
                    LOG(_ERROR_, "CWSAThread::doEpollEvent() error, inQueueWithoutLock() failed");
                    delete (*iter);
                }
            }
            precvlist->UnLock();
            m_recvtmplst.clear();
        }
        /////////////////end copy all recv message to recv list/////////////////

        //////////////////begin handle system events////////////////////////////
        doSystemEvent();
        //////////////////end handle system events//////////////////////////////////

        //////////////////begin set write wsa event by sendset////////////////
        CGlobalMgr::getInstance()->switchSendMap();
        map<int, list<NET_DATA*>*>* psendmap = CGlobalMgr::getInstance()->getBakSendMap();

        for (map<int, list<NET_DATA*>*>::iterator itersendmap = psendmap->begin(); itersendmap != psendmap->end(); ++itersendmap)
        {
            map<int, SOCKET_SET*>::iterator itersockmap = m_socketmap.find(itersendmap->first);
            if (itersockmap == m_socketmap.end() || itersockmap->second == NULL || itersockmap->second->key == NULL)
            {
                LOG(_ERROR_, "CEpollThread::doEpollEvent() error, m_socketmap.find(fd) failed");
                m_delsendfdlist.push_back(itersendmap->first);
                continue;
            }

            int i = 0;
            for (; i < WSA_MAXIMUM_WAIT_EVENTS; ++i)
            {
                if (itersendmap->first == m_sockArray[i])
                    break;
            }
            if (i > WSA_MAXIMUM_WAIT_EVENTS)
            {
                LOG(_ERROR_, "CEpollThread::doEpollEvent() error, m_sockArray[i] can't find(fd) failed");
                m_delsendfdlist.push_back(itersendmap->first);
                continue;
            }
            if (::WSAEventSelect(m_sockArray[i], m_eventArray[i], FD_WRITE) == SOCKET_ERROR)
            {
                LOG(_ERROR_, "CWSAThread::doEpollEvent() error, WSAEventSelect() failed, listen fd=%d, error=%ld", m_listenfd, WSAGetLastError());
                break;
            }
        }

        for (list<int>::iterator iterdelsendfdlist = m_delsendfdlist.begin(); iterdelsendfdlist != m_delsendfdlist.end(); ++iterdelsendfdlist)
        {
            deleteSendMsgFromSendMap(*iterdelsendfdlist);
        }
        m_delsendfdlist.clear();

        doKeepaliveTimeout();

        doSendKeepaliveToServer();
    }//end while
}
Esempio n. 17
0
void MaterialEditDialog::createControls()
{    
    lstProperties = new QListWidget(this);
    lstProperties->setMouseTracking(true);
    lstProperties->setMaximumWidth(200);

    connect(lstProperties, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(doPropertyChanged(QListWidgetItem *, QListWidgetItem *)));

    txtName = new QLineEdit();
    txtDescription = new QLineEdit();

    QGridLayout *layoutNameAndDescription = new QGridLayout();
    layoutNameAndDescription->addWidget(new QLabel(tr("Name:")), 0, 0);
    layoutNameAndDescription->addWidget(txtName, 0, 1);
    layoutNameAndDescription->addWidget(new QLabel(tr("Description:")), 1, 0);
    layoutNameAndDescription->addWidget(txtDescription, 2, 0, 1, 3);

    QPushButton *btnAddProperty = new QPushButton(tr("Add..."));
    btnAddProperty->setDefault(false);

    QAction *actAddCustom = new QAction(tr("Custom property"), this);
    connect(actAddCustom, SIGNAL(triggered()), this, SLOT(addProperty()));

    // TODO: more general
    QAction *actAddThermalConductivity = new QAction(tr("Thermal conductivity"), this);
    connect(actAddThermalConductivity, SIGNAL(triggered()), this, SLOT(addPropertyThermalConductivity()));
    QAction *actAddSpecificHeat = new QAction(tr("Specific heat"), this);
    connect(actAddSpecificHeat, SIGNAL(triggered()), this, SLOT(addPropertySpecificHeat()));
    QAction *actAddDensity = new QAction(tr("Density"), this);
    connect(actAddDensity, SIGNAL(triggered()), this, SLOT(addPropertyDensity()));
    QAction *actAddMagneticPermeability = new QAction(tr("Magnetic permeability"), this);
    connect(actAddMagneticPermeability, SIGNAL(triggered()), this, SLOT(addPropertyMagneticPermeability()));

    QMenu *menu = new QMenu();
    menu->addAction(actAddCustom);
    menu->addSeparator();
    menu->addAction(actAddThermalConductivity);
    menu->addAction(actAddSpecificHeat);
    menu->addAction(actAddDensity);
    menu->addSeparator();
    menu->addAction(actAddMagneticPermeability);

    btnAddProperty->setMenu(menu);

    btnDeleteProperty = new QPushButton(tr("Delete"));
    btnDeleteProperty->setDefault(false);
    connect(btnDeleteProperty, SIGNAL(clicked()), this, SLOT(deleteProperty()));

    QGridLayout *layoutList = new QGridLayout();
    layoutList->addWidget(lstProperties, 0, 0, 1, 2);
    layoutList->addWidget(btnAddProperty, 1, 0);
    layoutList->addWidget(btnDeleteProperty, 1, 1);

    propertyGUI = createPropertyGUI();

    QHBoxLayout *layoutNonlinearProperties = new QHBoxLayout();
    layoutNonlinearProperties->addLayout(layoutList);
    layoutNonlinearProperties->addWidget(propertyGUI, 1);

    // table
    txtPropertyTableKeys = new QPlainTextEdit();
    txtPropertyTableValues = new QPlainTextEdit();

    QGridLayout *layoutTable = new QGridLayout();
    layoutTable->addWidget(new QLabel(tr("Keys:")), 0, 0);
    layoutTable->addWidget(txtPropertyTableKeys, 1, 0);
    layoutTable->addWidget(new QLabel(tr("Values:")), 0, 1);
    layoutTable->addWidget(txtPropertyTableValues, 1, 1);

    widNonlinearTable = new QGroupBox(tr("Table"));
    widNonlinearTable->setLayout(layoutTable);

    // function
    txtPropertyFunction = new ScriptEditor(currentPythonEngine(), this);
    txtPropertyFunctionFrom = new LineEditDouble(0.0);
    txtPropertyFunctionTo = new LineEditDouble(0.0);

    QGridLayout *layoutFunction = new QGridLayout();
    layoutFunction->addWidget(txtPropertyFunction, 0, 0, 1, 4);
    layoutFunction->addWidget(new QLabel(tr("From:")), 1, 0);
    layoutFunction->addWidget(txtPropertyFunctionFrom, 1, 1);
    layoutFunction->addWidget(new QLabel(tr("To:")), 1, 2);
    layoutFunction->addWidget(txtPropertyFunctionTo, 1, 3);
    layoutFunction->setRowStretch(0, 1);

    widNonlinearFunction = new QGroupBox(tr("Nonlinear function"));
    widNonlinearFunction->setLayout(layoutFunction);

    chartNonlinear = new QCustomPlot();
    chartNonlinear->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
    chartNonlinear->setMinimumHeight(120);
    chartNonlinear->addGraph();
    chartNonlinear->graph(0)->setLineStyle(QCPGraph::lsLine);

    QHBoxLayout *layoutChartNonlinear = new QHBoxLayout();
    layoutChartNonlinear->addWidget(chartNonlinear);

    widChartNonlinear = new QGroupBox(tr("Chart"));
    widChartNonlinear->setLayout(layoutChartNonlinear);

    layoutNonlinearType = new QStackedLayout();
    layoutNonlinearType->addWidget(widNonlinearFunction);
    layoutNonlinearType->addWidget(widNonlinearTable);

    QHBoxLayout *layoutNonlinearChart = new QHBoxLayout();
    layoutNonlinearChart->addLayout(layoutNonlinearType, 2);
    layoutNonlinearChart->addWidget(widChartNonlinear, 1);

    QVBoxLayout *layoutNonlinear = new QVBoxLayout();
    layoutNonlinear->addLayout(layoutNonlinearProperties);
    layoutNonlinear->addLayout(layoutNonlinearChart, 1);

    // dialog buttons
    QPushButton *btnPlot = new QPushButton(tr("Plot"));
    connect(btnPlot, SIGNAL(clicked()), this, SLOT(drawChart()));

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    buttonBox->addButton(btnPlot, QDialogButtonBox::ActionRole);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addLayout(layoutNameAndDescription);
    layout->addLayout(layoutNonlinear, 1);
    layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);
}
Esempio n. 18
0
Error Socket::accept(Socket **sock, SocketAddress **addr)
{
	return doAccept(sock,addr);
}
Esempio n. 19
0
void DSceneFunction::createControls()
{
    logMessage("DSceneFunction::createControls()");

    // chart
    chart = new Chart(this);
    // axis labels
    QwtText text("");
    text.setFont(QFont("Helvetica", 10, QFont::Normal));
    text.setText("x");
    chart->setAxisTitle(QwtPlot::xBottom, text);
    text.setText("y");
    chart->setAxisTitle(QwtPlot::yLeft, text);

    // name
    txtName = new QLineEdit("");
    txtFunction = new QLineEdit();

    // interval
    txtStart = new ValueLineEdit();
    txtStart->setMaximumWidth(100);
    connect(txtStart, SIGNAL(editingFinished()), this, SLOT(doPlot()));

    txtEnd = new ValueLineEdit();
    txtEnd->setMaximumWidth(100);
    connect(txtEnd, SIGNAL(editingFinished()), this, SLOT(doPlot()));

    lblError = new QLabel();
    lblError->setVisible(false);

    QPushButton *btnPlot = new QPushButton(this);
    btnPlot->setText(tr("Plot"));
    connect(btnPlot, SIGNAL(clicked()), this, SLOT(doPlot()));

    QPushButton *btnSaveImage = new QPushButton(this);
    btnSaveImage->setText(tr("Save image"));
    connect(btnSaveImage, SIGNAL(clicked()), SLOT(doSaveImage()));

    QGridLayout *controlsLayout = new QGridLayout();
    controlsLayout->addWidget(new QLabel(tr("Start:")), 0, 0);
    controlsLayout->addWidget(txtStart, 0, 1);
    controlsLayout->addWidget(new QLabel(tr("End:")), 1, 0);
    controlsLayout->addWidget(txtEnd, 1, 1);
    controlsLayout->addWidget(new QLabel(tr("Name:")), 0, 2);
    controlsLayout->addWidget(txtName, 0, 3);
    controlsLayout->addWidget(new QLabel(tr("Function:")), 1, 2);
    controlsLayout->addWidget(txtFunction, 1, 3);
    controlsLayout->addWidget(lblError, 0, 4, 2, 1);
    controlsLayout->addWidget(btnPlot, 0, 5);
    controlsLayout->addWidget(btnSaveImage, 1, 5);

    // dialog buttons
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(chart);
    layout->addLayout(controlsLayout);
    layout->addWidget(buttonBox);

    setLayout(layout);
}
Esempio n. 20
0
//-----------------------------------------------------------------------------
KMFolderDialog::KMFolderDialog(KMFolder* aFolder, QWidget *parent,
			       const char *name) :
  KMFolderDialogInherited(parent, name, TRUE)
{
  KMAccount* acct;
  QLabel *label;
  QString type;

  folder = (KMAcctFolder*)aFolder;

  label = new QLabel(this);
  label->setGeometry(20,20,60,25);
  label->setText(i18n("Name:"));
  label->setAlignment(290);

  nameEdit = new QLineEdit(this);
  nameEdit->setGeometry(90,20,320,25);
  nameEdit->setFocus();
  nameEdit->setText(folder ? folder->name().data() : i18n("unnamed"));

  if (folder)
  {
    type = folder->type();
    if (!type.isEmpty() && type!="plain")
      nameEdit->setEnabled(false);
  }

  label = new QLabel(this);
  label->setText(i18n("Associated with"));
  label->adjustSize();
  label->move(20,74);

  assocList = new QListBox(this);
  assocList->setGeometry(20,95,160,140);
  connect(assocList,SIGNAL(highlighted(int)),this,SLOT(doAssocHighlighted(int)));
  connect(assocList,SIGNAL(selected(int)),this,SLOT(doAssocSelected(int)));

  label = new QLabel(this);
  label->setText(i18n("Unassociated Accounts"));
  label->adjustSize();
  label->move(250,74);

  accountList = new QListBox(this);
  accountList->setGeometry(250,95,160,140);
  connect(accountList,SIGNAL(highlighted(int)),this,SLOT(doAccountHighlighted(int)));
  connect(accountList,SIGNAL(selected(int)),this,SLOT(doAccountSelected(int)));

  addButton = new QPushButton(this);
  addButton->setGeometry(190,115,50,40);
  addButton->setText("<<");
  addButton->setEnabled(FALSE);
  connect(addButton,SIGNAL(clicked()),this,SLOT(doAdd()));

  removeButton = new QPushButton(this);
  removeButton->setGeometry(190,175,50,40);
  removeButton->setText(">>");
  removeButton->setEnabled(FALSE);
  connect(removeButton,SIGNAL(clicked()),this,SLOT(doRemove()));

  QPushButton *button = new QPushButton(this);
  button->setGeometry(190,260,100,30);
  button->setText(i18n("OK"));
  connect(button,SIGNAL(clicked()),this,SLOT(doAccept()));

  if (type=="Out" || type=="St")
    button->setEnabled(false);

  button = new QPushButton(this);
  button->setGeometry(310,260,100,30);
  button->setText(i18n("Cancel"));
  connect(button,SIGNAL(clicked()),this,SLOT(reject()));

  resize(430,340);
  setFixedSize(430,340);

  if (folder)
  {
    // Grab the list of accounts associated with the given folder.
    for (acct=folder->account(); acct; acct=folder->nextAccount())
    {
      assocList->inSort(acct->name());
    }
  }

  // insert list of available accounts that are not associated with
  // any account
  for (acct=acctMgr->first(); acct; acct=acctMgr->next())
  {
    if (!acct->folder())
      accountList->inSort(acct->name());
  }
}
Esempio n. 21
0
UnitTestsWidget::UnitTestsWidget(QWidget *parent)
    : QDialog(parent), m_test(XMLTest::tests()), m_isAborted(false)
{
    setWindowTitle(tr("Unit tests"));
    setModal(true);

    webView = new QWebView();
    webView->page()->setNetworkAccessManager(new QNetworkAccessManager());
    webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    webView->setMinimumSize(200, 200);

    logWidget = new LogWidget(this);
    logWidget->setMemoryLabelVisible(false);

    trvTests = new QTreeWidget(this);
    trvTests->setMouseTracking(true);
    trvTests->setColumnCount(1);
    trvTests->setIndentation(15);
    trvTests->setIconSize(QSize(24, 24));
    trvTests->setHeaderHidden(true);
    trvTests->setMinimumWidth(360);
    trvTests->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(trvTests, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(doContextMenu(const QPoint &)));
    // connect(trvTests, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(doItemDoubleClicked(QTreeWidgetItem *, int)));
    // connect(trvTests, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(doItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));

    btnRunTests = new QPushButton(tr("Run tests"));
    connect(btnRunTests, SIGNAL(clicked()), this, SLOT(runTestsFromSuite()));

    // dialog buttons
    btnScenarios = new QPushButton(tr("Scenarios..."));
    btnUncheckTests = new QPushButton(tr("Uncheck tests"));
    connect(btnUncheckTests, SIGNAL(clicked()), this, SLOT(uncheckTests()));
    btnStopTest = new QPushButton(tr("Stop"));
    btnStopTest->setEnabled(false);
    connect(btnStopTest, SIGNAL(clicked()), this, SLOT(stopTest()));

    QGridLayout *leftLayout = new QGridLayout();
    leftLayout->setContentsMargins(0, 0, 0, 0);
    leftLayout->addWidget(trvTests, 0, 0, 1, 5);
    leftLayout->addWidget(btnScenarios, 1, 0);
    leftLayout->addWidget(btnUncheckTests, 1, 1);
    leftLayout->setColumnStretch(2, 1);
    leftLayout->addWidget(btnStopTest, 1, 3);
    leftLayout->addWidget(btnRunTests, 1, 4);

    QWidget *leftWidget = new QWidget();
    leftWidget->setLayout(leftLayout);

    QVBoxLayout *rightLayout = new QVBoxLayout();
    rightLayout->addWidget(webView, 3);
    rightLayout->addWidget(logWidget, 1);

    QWidget *rightWidget = new QWidget();
    rightWidget->setLayout(rightLayout);

    splitter = new QSplitter(this);
    splitter->setOrientation(Qt::Horizontal);
    splitter->addWidget(leftWidget);
    splitter->addWidget(rightWidget);

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(splitter, 1);
    layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);

    QSettings settings;
    splitter->restoreState(settings.value("UnitTestsWidget/SplitterState").toByteArray());
    splitter->restoreGeometry(settings.value("UnitTestsWidget/SplitterGeometry").toByteArray());
    restoreGeometry(settings.value("UnitTestsWidget/Geometry", saveGeometry()).toByteArray());

    // init ctemplate
    // stylesheet
    std::string style;
    ctemplate::TemplateDictionary stylesheet("style");
    stylesheet.SetValue("FONTFAMILY", htmlFontFamily().toStdString());
    stylesheet.SetValue("FONTSIZE", (QString("%1").arg(htmlFontSize() + 1).toStdString()));

    ctemplate::ExpandTemplate(compatibleFilename(datadir() + TEMPLATEROOT + "/panels/style_results.css").toStdString(), ctemplate::DO_NOT_STRIP, &stylesheet, &style);
    m_cascadeStyleSheet = QString::fromStdString(style);

    // read tests from test_suite
    readTestsFromSuite();
    readScenariosFromSuite();

    // read last test
    QDir dirUser(QString("%1/tests").arg(userDataDir()));
    if (!dirUser.exists())
        QDir(userDataDir()).mkpath(dirUser.absolutePath());

    dirUser.setFilter(QDir::Files | QDir::NoSymLinks);
    if (!dirUser.entryInfoList().isEmpty())
    {
        QString file = QString("%1").arg(dirUser.entryInfoList().last().absoluteFilePath());
        readTestFromDisk(file);
    }
}