示例#1
0
void UIVMPreviewWindow::contextMenuEvent(QContextMenuEvent *pEvent)
{
    QAction *pReturn = m_pUpdateTimerMenu->exec(pEvent->globalPos(), 0);
    if (pReturn)
    {
        UpdateInterval interval = static_cast<UpdateInterval>(pReturn->data().toInt());
        setUpdateInterval(interval, true);
        restart();
    }
}
void UIGMachinePreview::contextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent)
{
    QAction *pReturn = m_pUpdateTimerMenu->exec(pEvent->screenPos(), 0);
    if (pReturn)
    {
        UpdateInterval interval = static_cast<UpdateInterval>(pReturn->data().toInt());
        setUpdateInterval(interval, true);
        restart();
    }
}
UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent)
  : QIWithRetranslateUI<QWidget>(pParent)
  , m_machineState(KMachineState_Null)
  , m_pUpdateTimer(new QTimer(this))
  , m_vMargin(10)
  , m_pbgImage(0)
  , m_pPreviewImg(0)
  , m_pGlossyImg(0)
{
    m_session.createInstance(CLSID_Session);

    setContentsMargins(0, 5, 0, 5);
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    /* Connect the update timer */
    connect(m_pUpdateTimer, SIGNAL(timeout()),
            this, SLOT(sltRecreatePreview()));
    /* Connect the machine state event */
    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
            this, SLOT(sltMachineStateChange(QString, KMachineState)));
    /* Create the context menu */
    setContextMenuPolicy(Qt::DefaultContextMenu);
    m_pUpdateTimerMenu = new QMenu(this);
    QActionGroup *pUpdateTimeG = new QActionGroup(this);
    pUpdateTimeG->setExclusive(true);
    for(int i = 0; i < UpdateEnd; ++i)
    {
        QAction *pUpdateTime = new QAction(pUpdateTimeG);
        pUpdateTime->setData(i);
        pUpdateTime->setCheckable(true);
        pUpdateTimeG->addAction(pUpdateTime);
        m_pUpdateTimerMenu->addAction(pUpdateTime);
        m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime;
    }
    m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(Update500ms)]);
    /* Default value */
    UpdateInterval interval = Update1000ms;
    QString strInterval = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_PreviewUpdate);
    if (strInterval == "disabled")
        interval = UpdateDisabled;
    else if (strInterval == "500")
        interval = Update500ms;
    else if (strInterval == "1000")
        interval = Update1000ms;
    else if (strInterval == "2000")
        interval = Update2000ms;
    else if (strInterval == "5000")
        interval = Update5000ms;
    else if (strInterval == "10000")
        interval = Update10000ms;
    /* Initialize with the new update interval */
    setUpdateInterval(interval, false);

    /* Retranslate the UI */
    retranslateUi();
}
示例#4
0
文件: cli.c 项目: draringi/gini
/*
 * set verbose [value]
 * set raw-time [true | false ]
 * set update-delay value
 * set sched-cycle value
 */
void setCmd()
{
	char *next_tok = strtok(NULL, " \n");
	int level, cyclelen, rawmode, updateinterval;

	if (next_tok == NULL)
		error("[setCmd]:: ERROR!! missing set-parameter");
	else if (!strcmp(next_tok, "sched-cycle"))
	{
		if ((next_tok = strtok(NULL, " \n")) != NULL)
		{
			cyclelen = atoi(next_tok);
			if (cyclelen >=0)
				rconfig.schedcycle = cyclelen;
			else
				verbose(1, "ERROR!! schedule cycle length should be positive \n");
		} else
			printf("\nSchedule cycle length: %d (microseconds) \n", rconfig.schedcycle);
	} else if (!strcmp(next_tok, "verbose"))
	{
		if ((next_tok = strtok(NULL, " \n")) != NULL)
		{
			level = atoi(next_tok);
			if ((level >= 0) && (level <= 6))
				prog_set_verbosity_level(level);
			else
				verbose(1, "[setCmd]:: ERROR!! level should be in [0..6] \n");
		} else
			printf("\nVerbose level: %ld \n", prog_verbosity_level());
	} else if (!strcmp(next_tok, "raw-times"))
	{
		if ((next_tok = strtok(NULL, " \n")) != NULL)
		{
			rawmode = atoi(next_tok);
			if ((rawmode == 0) || (rawmode == 1))
				setTimeMode(rawmode);
			else
				printf("\nRaw time mode: %d  \n", getTimeMode());
		}
		else if (!strcmp(next_tok, "update-delay"))
		{
			if ((next_tok = strtok(NULL, " \n")) != NULL)
			{
				updateinterval = atoi(next_tok);
				if (updateinterval >=2)
					setUpdateInterval(updateinterval);
				else
					verbose(1, "Invalid update interval.. setting failed.. \n");
			}
			else
				printf("Update interval: %d (seconds) \n", getUpdateInterval());
		}
	}
}
示例#5
0
void Server::setLocalDefaults()
{
    m_host             = Local;
    m_type             = Basic;
    m_qchemEnvironment = QString(qgetenv("QC"));
    m_hostAddress      = "localhost";
    m_userName         = QString(qgetenv("USER"));
    m_authentication   = None;
    m_port             = 0;
    m_workingDirectory = QString(qgetenv("HOME"));
    m_executableName   = "qcprog.exe";
    setUpdateInterval(10);
}
int QTimeLine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 10)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 10;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = duration(); break;
        case 1: *reinterpret_cast< int*>(_v) = updateInterval(); break;
        case 2: *reinterpret_cast< int*>(_v) = currentTime(); break;
        case 3: *reinterpret_cast< Direction*>(_v) = direction(); break;
        case 4: *reinterpret_cast< int*>(_v) = loopCount(); break;
        case 5: *reinterpret_cast< CurveShape*>(_v) = curveShape(); break;
        case 6: *reinterpret_cast< QEasingCurve*>(_v) = easingCurve(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDuration(*reinterpret_cast< int*>(_v)); break;
        case 1: setUpdateInterval(*reinterpret_cast< int*>(_v)); break;
        case 2: setCurrentTime(*reinterpret_cast< int*>(_v)); break;
        case 3: setDirection(*reinterpret_cast< Direction*>(_v)); break;
        case 4: setLoopCount(*reinterpret_cast< int*>(_v)); break;
        case 5: setCurveShape(*reinterpret_cast< CurveShape*>(_v)); break;
        case 6: setEasingCurve(*reinterpret_cast< QEasingCurve*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
示例#7
0
文件: Server.C 项目: gechen/IQmol
void Server::setRemoteDefaults()
{
   m_host             = Remote;
   m_type             = Basic;
   //m_qchemEnvironment = "";
   m_hostAddress      = "";
   m_userName         = QString(qgetenv("USER"));
   m_authentication   = Prompt;
   m_port             = 22;
   m_workingDirectory =  "~/";
   m_executableName   = "qcprog.exe";
   setBasicDefaults(m_host);
   setUpdateInterval(20);
}
void QGeoSatelliteInfoSourceNpeBackend::shutdownRequestSession()
{
    requestTimer->stop();
    // Restore updateInterval from before Request Session in case of ongoing tracking session
    if ( satOngoing ) {
        int minimumInterval = minimumUpdateInterval();
        if ( QGeoSatelliteInfoSource::updateInterval() != minimumInterval)
            setUpdateInterval(QGeoSatelliteInfoSource::updateInterval());
    } else {
        // If our timer expired before we could get a sat update, make sure we stop the locationd request
        // (which would otherwise go on until a valid satellite update is obtained).
        m_locationdConn->stopSatelliteUpdates();
    }
}
示例#9
0
/* Constructor: */
UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent)
  : QIWithRetranslateUI<QWidget>(pParent)
  , m_machineState(KMachineState_Null)
  , m_pUpdateTimer(new QTimer(this))
  , m_vMargin(10)
  , m_pbgImage(0)
  , m_pPreviewImg(0)
  , m_pGlossyImg(0)
{
    /* Setup contents: */
    setContentsMargins(0, 5, 0, 5);
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    /* Create session instance: */
    m_session.createInstance(CLSID_Session);

    /* Create the context menu: */
    setContextMenuPolicy(Qt::DefaultContextMenu);
    m_pUpdateTimerMenu = new QMenu(this);
    QActionGroup *pUpdateTimeG = new QActionGroup(this);
    pUpdateTimeG->setExclusive(true);
    for(int i = 0; i < UpdateInterval_Max; ++i)
    {
        QAction *pUpdateTime = new QAction(pUpdateTimeG);
        pUpdateTime->setData(i);
        pUpdateTime->setCheckable(true);
        pUpdateTimeG->addAction(pUpdateTime);
        m_pUpdateTimerMenu->addAction(pUpdateTime);
        m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime;
    }
    m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(UpdateInterval_500ms)]);

    /* Load preview update interval: */
    QString strInterval = vboxGlobal().virtualBox().GetExtraData(GUI_PreviewUpdate);
    /* Parse loaded value: */
    UpdateInterval interval = m_intervals.key(strInterval, UpdateInterval_1000ms);
    /* Initialize with the new update interval: */
    setUpdateInterval(interval, false);

    /* Setup connections: */
    connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview()));
    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
            this, SLOT(sltMachineStateChange(QString, KMachineState)));

    /* Retranslate the UI */
    retranslateUi();
}
示例#10
0
Fog::Fog()
{
    // create fog array
    const unsigned short len = Terrain::getInstance()->getSize();
    m_Fog = new bool*[len];
    for (int i = 0; i < len; i++) {
        m_Fog[i] = new bool[len];
    }

    // set array to false
    for (unsigned short i = 0; i < len; i++) {
        memset(m_Fog[i], false, len * sizeof(bool));
    }

    m_Enabled = true;
    m_ChangeCounter = 0;
    m_UpdateCounter = 100.0f;
    setUpdateInterval(0.5f);
}
示例#11
0
void ExtPlaneConnection::readClient() {
    while(canReadLine()) {
        QByteArray lineBA = readLine();
        QString line = QString(lineBA).trimmed();
        //DEBUG << "Server says: " << line;
        if(!server_ok) { // Waiting for handshake..
            if(line=="EXTPLANE 1") {
                server_ok = true;
                emit connectionMessage("");
                setUpdateInterval(updateInterval);
                // Sub all refs
                foreach(ClientDataRef *ref, dataRefs)
                    subRef(ref);
            }
            return;
        } else { // Handle updates
            QStringList cmd = line.split(" ", QString::SkipEmptyParts);
            if(cmd.size()==3) {
                ClientDataRef *ref = dataRefs.value(cmd.value(1));
                if(ref) {
                    if (cmd.value(0)=="ufa" || cmd.value(0)=="uia"){
                        // Array dataref
                        QString arrayString = cmd.value(2);
                        Q_ASSERT(arrayString[0]=='[' && arrayString[arrayString.length()-1]==']');
                        arrayString = arrayString.mid(1, arrayString.length()-2);
                        QStringList arrayValues = arrayString.split(',');
                        ref->updateValue(arrayValues);
                    } else if ((cmd.value(0)=="uf")||(cmd.value(0)=="ui")||(cmd.value(0)=="ud")) {
                        // Single value dataref
                        ref->updateValue(cmd.value(2));
                    } else if (cmd.value(0)=="ub") {
                        // Data dataref
                        ref->updateValue(QByteArray::fromBase64(cmd.value(2).toUtf8()));
                    } else {
                        INFO << "Unsupported ref type " << cmd.value(0);
                    }
                } else {
                    INFO << "Ref not subscribed " << cmd.value(2);
                }
            }
        }
    }
}
示例#12
0
文件: Server.C 项目: gechen/IQmol
void Server::setWebDefaults()
{
   m_host             = Web;
   m_type             = HTTP;
   //m_qchemEnvironment = "(unused)";
   m_hostAddress      = "www.iqmol.org";
   m_userName         = "******";
   m_port             = 80;
   m_workingDirectory = "(unused)";
   m_authentication   = None;
   setUpdateInterval(20);

   m_executableName   = "/cgi/IQmol";
   m_queueInfo        = "limits.cgi user=${USER}";
   m_killCommand      = "kill.cgi jobID=${JOB_ID}";
   m_queryCommand     = "query.cgi jobID=${JOB_ID}";
   m_submitCommand    = "submit.cgi user=${USER} jobID=${JOB_ID}";
   m_runFileTemplate  = "(unused)";
   m_delegateDefaults.insert("JobLimit", 0);
}
AcSensorBridge::AcSensorBridge(AcSensor *acSensor, AcSensorSettings *settings,
							   bool isSecundary, QObject *parent) :
	DBusBridge(getServiceName(acSensor, settings, isSecundary), true, parent)
{
	Q_ASSERT(acSensor != 0);
	Q_ASSERT(settings != 0);
	connect(acSensor, SIGNAL(destroyed()), this, SLOT(deleteLater()));
	connect(settings, SIGNAL(destroyed()), this, SLOT(deleteLater()));

	bool isGridmeter =
		(isSecundary ? settings->l2ServiceType() : settings->serviceType()) == "grid";
	// Changes in QT properties will not be propagated to the D-Bus at once, but in 1000ms/2500ms
	// intervals.
	setUpdateInterval(isGridmeter ? 1000 : 2500);

	produce(acSensor, "connectionState", "/Connected");
	produce(acSensor, "errorCode", "/ErrorCode");

	producePowerInfo(acSensor->total(), "/Ac", isGridmeter);
	producePowerInfo(acSensor->l1(), "/Ac/L1", isGridmeter);
	producePowerInfo(acSensor->l2(), "/Ac/L2", isGridmeter);
	producePowerInfo(acSensor->l3(), "/Ac/L3", isGridmeter);

	if (isSecundary || settings->serviceType() == "pvinverter")
		produce(settings, isSecundary ? "l2Position" : "position", "/Position");
	produce(settings, isSecundary ? "l2ProductName" : "productName", "/ProductName");
	produce(settings, isSecundary ? "l2CustomName" : "customName", "/CustomName");

	QString processName = QCoreApplication::applicationName();
	// The values of the items below will not change after creation, so we don't
	// need an update mechanism.
	produce("/Mgmt/ProcessName", processName);
	produce("/Mgmt/ProcessVersion", QCoreApplication::applicationVersion());
	produce("/FirmwareVersion", acSensor->firmwareVersion());
	int productId = 0;
	switch (acSensor->protocolType()) {
	case AcSensor::Em24Protocol:
		productId = isSecundary ?
			VE_PROD_ID_CARLO_GAVAZZI_EM24_PIGGY_BACK :
			VE_PROD_ID_CARLO_GAVAZZI_EM24;
		break;
	case AcSensor::Et112Protocol:
		productId = VE_PROD_ID_CARLO_GAVAZZI_ET112;
		break;
	case AcSensor::Em340Protocol:
		productId = isSecundary ?
			VE_PROD_ID_CARLO_GAVAZZI_ET340_PIGGY_BACK :
			VE_PROD_ID_CARLO_GAVAZZI_ET340;
		break;
	default:
		Q_ASSERT(false);
		break;
	}
	produce("/ProductId", productId);
	produce("/DeviceType", acSensor->deviceType());
	produce("/Mgmt/Connection", acSensor->portName());

	int deviceInstance = isSecundary ?
		settings->l2DeviceInstance() :
		settings->deviceInstance();
	produce("/DeviceInstance", deviceInstance);
	produce("/Serial", acSensor->serial());

	registerService();
}
void QGeoPositionInfoSourceBb::setPeriod(double period)
{
    // convert from sec to msec, round to nearest msec
    setUpdateInterval(qRound(static_cast<qreal>(period * 1000.0)));
}
示例#15
0
文件: Server.C 项目: gechen/IQmol
void Server::fromQVariant(QVariant const& qvar)
{
   QVariantMap map(qvar.toMap());
   setDefaults(Local, Basic);
   bool ok;
    
   // Name
   if (map.contains("Name") && !map.value("Name").toString().isEmpty()) {
      m_name = map.value("Name").toString();
   } else {
      throw Server::Exception("???", "Server name not set");
   }

   // Host
   if (map.contains("Host")) {
      int host(map.value("Host").toInt(&ok));
      if (ok) {
         if (host == Remote) setRemoteDefaults();
         if (host == Web) {
            setWebDefaults();
         }
      }
   }else {
      throw Server::Exception(m_name, "Remote/Local type not set");
   }

   // Type
   if (map.contains("Type")) {
      int type(map.value("Type").toInt(&ok));
      if (ok) {
         switch (type) {
            case PBS:   m_type = PBS;    break;
            case SGE:   m_type = SGE;    break;
            case HTTP:  m_type = HTTP;   break;
            default:  m_type = Basic;    break;
         }
      }
   }else {
      throw Server::Exception(m_name, "Server type not set");
   }

   // Job Limit
   if (map.contains("JobLimit")) {
      int limit(map.value("JobLimit").toInt(&ok));
      if (ok) m_delegateDefaults.insert("JobLimit", limit);
   }

   // Cookie (this should be shifted to the delegate
   if (map.contains("Cookie")) {
      m_cookie = map.value("Cookie").toString();
   }

   // $QC
   if (map.contains("QChemEnvironment")) {
	  //m_qchemEnvironment = map.value("QChemEnvironment").toString();
   }

   // Host Address
   if (map.contains("HostAddress")) {
	  m_hostAddress = map.value("HostAddress").toString();
   }

   // User
   if (map.contains("UserName")) {
	  m_userName = map.value("UserName").toString();
   }

   // Authentication
   if (map.contains("Authentication")) {
      int auth(map.value("Authentication").toInt(&ok));
      if (ok) {
         switch (auth) {
            case 0:  m_authentication = None;                 break;
            case 1:  m_authentication = Agent;                break;
            case 2:  m_authentication = PublicKey;            break;
            case 3:  m_authentication = HostBased;            break;
            case 4:  m_authentication = KeyboardInteractive;  break;
            case 5:  m_authentication = Vault;                break;
            case 6:  m_authentication = Prompt;               break;
         }
      }
   }

   // Port
   if (map.contains("Port")) {
      int port(map.value("Port").toInt(&ok));
	  if (ok) m_port = port;
   }

   // Working Directory
   if (map.contains("WorkingDirectory")) {
	  m_workingDirectory = map.value("WorkingDirectory").toString();
   }

   // ${EXE_NAME}
   if (map.contains("ExecutableName")) {
	  m_executableName = map.value("ExecutableName").toString();
   }

   // ${SUBMIT_CMD}
   if (map.contains("SubmitCommand")) {
	  m_submitCommand = map.value("SubmitCommand").toString();
   }

   // ${QUERY_CMD}
   if (map.contains("QueryCommand")) {
	  m_queryCommand = map.value("QueryCommand").toString();
   }

   // ${QUEUE_INFO}
   if (map.contains("QueueInfo")) {
	  m_queueInfo = map.value("QueueInfo").toString();
   }

   // ${KILL_CMD}
   if (map.contains("KillCommand")) {
	  m_killCommand = map.value("KillCommand").toString();
   }

   // Run File Template
   if (map.contains("RunFileTemplate")) {
	  m_runFileTemplate = map.value("RunFileTemplate").toString();
   }

   // UpdateInterval
   if (map.contains("UpdateInterval")) {
      int interval(map.value("UpdateInterval").toInt(&ok));
	  if (ok) setUpdateInterval(interval);
   }

   if (map.contains("DelegateDefaults")) {
      m_delegateDefaults = map.value("DelegateDefaults").toMap();
   }
}
示例#16
0
void TEDisplayEpson::setScrollSpeed(int speed)
{
	speed=speed<1?1:speed>10?10:speed;
	setUpdateInterval(1000/speed);
};
示例#17
0
/*!
    \overload

    Starts providing updates with an update interval of \a msec milliseconds.
*/
void QWhereabouts::startUpdates(int msec)
{
    setUpdateInterval(msec);
    startUpdates();
}