void MultiSlidingValueDialog::updateText(int value)
{
	int i;
	QObject *slider;
	if (sender() != NULL) {
		for (i = 0; i < mSliders.count(); i++) {
			if (mSliders.at(i) == sender()) {
				break;
			}
		}
		slider = sender();
	} else {
		i = mSliders.count() - 1;
		slider = mSliders.at(i);
	}
	QString name = slider->objectName();
	QString textVal = QString::number(value);
	mLabels[i]->setText(mText.arg(name, textVal));
}
示例#2
0
void LuaAVConsole :: fileAction() {
	QObject *s = sender();
	const char *name = s->objectName().toStdString().data();	
	const char *idx = strchr(name, ':')+1;
	int i = 0;
	sscanf(idx, "%d", &i);

	const char *filename = getFilenameWithScriptIndex(i);

	if(strncmp(name, "close", strlen("close")) == 0) {
		lua::call(luaav_getstate(luaav_app_state()), "fileclose", filename);
	}
	else if(strncmp(name, "reload", strlen("reload")) == 0) {
		lua::call(luaav_getstate(luaav_app_state()), "fileopen", filename);
	}
	else if(strncmp(name, "edit", strlen("edit")) == 0) {
		lua::call(luaav_getstate(luaav_app_state()), "fileedit", filename);
	}
}
示例#3
0
/**
 * Forward the QKeyEvent to the QsciScintilla base class.
 * Under Gnome on Linux with Qscintilla versions < 2.4.2 there is a bug with the
 * autocomplete
 * box that means the editor loses focus as soon as it the box appears. This
 * functions
 * forwards the call and sets the correct flags on the resulting window so that
 * this does not occur
 */
void ScriptEditor::forwardKeyPressToBase(QKeyEvent *event) {
    // Hack to get around a bug in QScitilla
    // If you pressed ( after typing in a autocomplete command the calltip does
    // not appear, you have to delete the ( and type it again
    // This does that for you!
    if (event->text() == "(") {
        QKeyEvent *backspEvent =
            new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier);
        QKeyEvent *bracketEvent = new QKeyEvent(*event);
        QsciScintilla::keyPressEvent(bracketEvent);
        QsciScintilla::keyPressEvent(backspEvent);

        delete backspEvent;
        delete bracketEvent;
    }

    QsciScintilla::keyPressEvent(event);

// Only need to do this for Unix and for QScintilla version < 2.4.2. Moreover,
// only Gnome but I don't think we can detect that
#ifdef Q_OS_LINUX
#if QSCINTILLA_VERSION < 0x020402
    // If an autocomplete box has surfaced, correct the window flags.
    // Unfortunately the only way to
    // do this is to search through the child objects.
    if (isListActive()) {
        QObjectList children = this->children();
        QListIterator<QObject *> itr(children);
        // Search is performed in reverse order as we want the last one created
        itr.toBack();
        while (itr.hasPrevious()) {
            QObject *child = itr.previous();
            if (child->inherits("QListWidget")) {
                QWidget *w = qobject_cast<QWidget *>(child);
                w->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
                w->show();
                break;
            }
        }
    }
#endif
#endif
}
示例#4
0
void KviWindow::childRemoved(QWidget * pObject)
{
    pObject->removeEventFilter(this);

    if(pObject == m_pFocusHandler)
        m_pFocusHandler = NULL;
    if(pObject == m_pLastFocusedChild)
        m_pLastFocusedChild = NULL;

    QList<QObject *> list = pObject->children();
    for(QList<QObject *>::Iterator it = list.begin(); it != list.end(); ++it)
    {
        QObject * pObj = *it;
        if(pObj->isWidgetType())
        {
            childRemoved((QWidget *)pObj);
        }
    }
}
示例#5
0
/*
 * This is test case that loads dependency automatically. Both success and fail case.
 */
void TestCreateFile::testLoadDependency()
{
    QQmlEngine *engine = new QQmlEngine;
    QmcLoader loader(engine);
    loader.setLoadDependenciesAutomatically(false);
    QQmlComponent *c = NULL;
    c = loader.loadComponent(tempDirPath(SUB_ITEM_WITH_SCRIPT_QMC));
    QVERIFY(!c);
    loader.setLoadDependenciesAutomatically(true);
    c = loader.loadComponent(tempDirPath(SUB_ITEM_WITH_SCRIPT_QMC));
    QVERIFY(c);
    QObject *obj = c->create();
    QVariant var = obj->property("height");
    QVERIFY(!var.isNull());
    QVERIFY(var.toInt() == 40);
    delete obj;
    delete c;
    delete engine;
}
示例#6
0
KoFilter* KoFilterEntry::createFilter(KoFilterChain* chain, QObject* parent)
{
    KLibFactory *factory = qobject_cast<KLibFactory *>(m_loader->instance());

    if (!factory) {
        warnMain << m_loader->errorString();
        return 0;
    }

    QObject* obj = factory->create<KoFilter>(parent);
    if (!obj || !obj->inherits("KoFilter")) {
        delete obj;
        return 0;
    }

    KoFilter* filter = static_cast<KoFilter*>(obj);
    filter->m_chain = chain;
    return filter;
}
示例#7
0
void HistoWidget::buttonPressedX()
{
  if (!mpModel) return;

  //  mpObjectX = CCopasiSelectionDialog::getObjectSingle(this, CQSimpleSelectionTree::NUMERIC, mpObjectX);
  //mpObjectX = CCopasiSelectionDialog::getObjectSingle(this, CQSimpleSelectionTree::PLOT_OBJECT, mpObjectX);

  std::vector< const CCopasiObject * > oldSelection;

  if (mpObjectX)
    oldSelection.push_back(mpObjectX);

  std::vector< const CCopasiObject * > objects =
    CCopasiSelectionDialog::getObjectVector(this,
        CQSimpleSelectionTree::NumericValues,
        &oldSelection);

  if (objects.size() && objects[0])
    {
      mpObjectX = objects[0];
      mpEditVariable->setText(FROM_UTF8(mpObjectX->getObjectDisplayName()));
      mpEditTitle->setText("Histogram: " + FROM_UTF8(mpObjectX->getObjectDisplayName()));
    }
  else
    {
      mpObjectX = NULL;
      mpEditVariable->setText("");
      mpEditTitle->setText("Histogram");
    }

  //check if more than one object was selected...
  if (objects.size() > 1)
    {
      CQPlotSubwidget * pParent;
      QObject* tmp = this;

      while (!(pParent = dynamic_cast< CQPlotSubwidget * >(tmp)) && this)
        tmp = tmp->parent();

      if (pParent) //tell the parent to create the remaining histogram descriptions.
        pParent->createHistograms(objects, mpEditIncrement->text().toDouble());
    }
}
示例#8
0
void EngineTest::engineErrorHandlerSkipTest(){
    Engine* engine = new Engine(new QQmlEngine);

    bool isWarning = false;
    bool isError   = false;
    QObject::connect(engine, &Engine::applicationWarning, [&isWarning, this](QJSValue){
        isWarning = true;
    });
    QObject::connect(engine, &Engine::applicationError, [&isError, this](QJSValue){
        isError = true;
    });

    QObject livecvStub;
    livecvStub.setProperty("engine", QVariant::fromValue(engine));

    engine->engine()->rootContext()->setContextProperty("engine", engine);
    engine->engine()->rootContext()->setContextProperty("livecv", &livecvStub);
    QObject* obj = engine->createObject(
        "import QtQuick 2.3\n import base 1.0\n "
        "Item{\n"
            "id: root;\n"
            "ErrorHandler{\n"
                "onError:   skip(e);\n"
                "onWarning: skip(e);\n"
            "}\n"
            "EngineTestStub{\n"
                "Component.onCompleted: {\n"
                    "throwJsWarning();"
                    "throwJsError();"
                "}\n"
            "}\n"
        "}\n",
        0,
        QUrl::fromLocalFile("enginetest.qml")
    );

    QVERIFY(obj != 0);

    QCoreApplication::processEvents();

    QVERIFY(isWarning);
    QVERIFY(isError);
}
示例#9
0
            void connectFunctions(ChildrenInterface* children) {
                Q_ASSERT( m_engine );
                Q_ASSERT( ! m_engine->hasUncaughtException() );
                QString eval;
                QScriptValue global = m_engine->globalObject();
                QHashIterator< QString, ChildrenInterface::Options > it( children->objectOptions() );
                while(it.hasNext()) {
                    it.next();
                    if( it.value() & ChildrenInterface::AutoConnectSignals ) {
                        QObject* sender = children->object(it.key());
                        if( ! sender )
                            continue;
                        QScriptValue obj = m_engine->globalObject().property(it.key());
                        if( ! obj.isQObject() )
                            continue;
                        const QMetaObject* mo = sender->metaObject();
                        const int count = mo->methodCount();
                        for(int i = 0; i < count; ++i) {
                            QMetaMethod mm = mo->method(i);
#if QT_VERSION < 0x050000
                            const QString signature = mm.signature();
#else
                            const QString signature = mm.methodSignature();
#endif
                            const QString name = signature.left(signature.indexOf('('));
                            if( mm.methodType() == QMetaMethod::Signal ) {
                                QScriptValue func = global.property(name);
                                if( ! func.isFunction() ) {
                                    //qrossdebug( QString("EcmaScript::connectFunctions No function to connect with %1.%2").arg(it.key()).arg(name) );
                                    continue;
                                }
                                qrossdebug( QString("EcmaScript::connectFunctions Connecting with %1.%2").arg(it.key()).arg(name) );
                                eval += QString("try { %1.%2.connect(%3); } catch(e) { print(e); }\n").arg(it.key()).arg(name).arg(name);
                            }
                        }
                    }
                }
                Q_ASSERT( ! m_engine->hasUncaughtException() );
                if( ! eval.isNull() ) {
                    m_engine->evaluate(eval);
                    Q_ASSERT( ! m_engine->hasUncaughtException() );
                }
            }
示例#10
0
void TestSimpleQmlLoad::loadComponent1()
{
    QQmlEngine *engine = new QQmlEngine;
    const QString TEST_FILE(":/testqml/testcomponent1.qml");
    QQmlComponent* component = load(engine, TEST_FILE);
    QVERIFY(component);

    QObject *myObject = component->create();
    QVERIFY(myObject != NULL);
    QVariant var = myObject->property("c1");
    QVERIFY(!var.isNull());

    QVariant ret;
    QMetaObject::invokeMethod(myObject, "getSubWidth1", Q_RETURN_ARG(QVariant, ret));
    QVERIFY(ret.toInt() == 10);

    delete component;
    delete engine;
}
示例#11
0
void KviWindow::updateBackgrounds(QObject * pObject)
{
    if(!pObject)
        pObject = this;
    QList<QObject *> list = pObject->children();
    if(list.count())
    {
        for(QList<QObject *>::Iterator it = list.begin(); it != list.end(); ++it)
        {
            QObject * pChild = *it;
            if(pChild->metaObject()->indexOfProperty("TransparencyCapable") != -1)
            {
                //if (child->isWidgetType())
                ((QWidget *)pChild)->update();
            }
            updateBackgrounds(pChild);
        }
    }
}
示例#12
0
void TestSimpleQmlLoad::compileAndLoadAlias1()
{
    QQmlEngine *engine = new QQmlEngine;
    const QString TEST_FILE(":/testqml/testalias1.qml");
    QQmlComponent* component = compileAndLoad(engine, TEST_FILE);
    QVERIFY(component);

    QObject* myObject = component->create();
    QVERIFY(myObject);
    QVariant v = myObject->property("w");
    QVERIFY(!v.isNull());
    QVERIFY(v.toInt() == 100);
    myObject->setProperty("width", QVariant(200));
    v = myObject->property("w");
    QVERIFY(v.toInt() == 200);

    delete component;
    delete engine;
}
示例#13
0
void WaitForEventTest::testWaitEnded() {
    QObject parentObject;

    WaitForEvent waitForEvent(&parentObject, QEvent::ChildAdded);
    waitForEvent.setActive(true);

    //WaitFor* must be registered in order to be used with QSignalSpy
    int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*");
    QSignalSpy waitEndedSpy(&waitForEvent, SIGNAL(waitEnded(WaitFor*)));

    QObject* childObject = new QObject();
    childObject->setParent(&parentObject);

    QVERIFY(waitForEvent.conditionMet());
    QCOMPARE(waitEndedSpy.count(), 1);
    QVariant argument = waitEndedSpy.at(0).at(0);
    QCOMPARE(argument.userType(), waitForStarType);
    QCOMPARE(qvariant_cast<WaitFor*>(argument), &waitForEvent);
}
示例#14
0
QSqlRecord DbSchema::sqlRecord(QObject *table, bool lowercase_field_names)
{
	QSqlRecord ret;
	QQmlListReference fields(table, "fields", m_eventPlugin->qmlEngine());
	for (int i = 0; i < fields.count(); ++i) {
		QObject *field = fields.at(i);
		QString name = field->property("name").toString();
		if(lowercase_field_names)
			name = name.toLower();
		QVariant typev = field->property("type");
		QObject *type = typev.value<QObject*>();
		QF_ASSERT(type != nullptr, "Internal error: Cannot get field type", return QSqlRecord());
		QByteArray type_name = type->property("metaTypeName").toString().toLatin1();
		QSqlField fld(name, QVariant::nameToType(type_name.constData()));
		ret.append(fld);
		//qfInfo() << type << "name:" << name << "type:" << type_name;
	}
	return ret;
}
static const sipTypeDef *sipSubClass_QHelpEngineCore(void **sipCppRet)
{
    QObject *sipCpp = reinterpret_cast<QObject *>(*sipCppRet);
    const sipTypeDef *sipType;

#line 37 "/Users/ktaylora/PLJV/tillage_likelihood_model/gui/PyQt4/sip/QtHelp/qhelpenginecore.sip"
    static struct class_graph {
            const char *name;
            sipTypeDef **type;
            int yes, no;
        } graph[] = {
            {sipName_QHelpIndexWidget,	&sipType_QHelpIndexWidget,	-1, 1},
            {sipName_QHelpContentWidget,	&sipType_QHelpContentWidget,	-1, 2},
            {sipName_QHelpContentModel,	&sipType_QHelpContentModel,	-1, 3},
            {sipName_QHelpIndexModel,	&sipType_QHelpIndexModel,	-1, 4},
            {sipName_QHelpSearchResultWidget,	&sipType_QHelpSearchResultWidget,	-1, 5},
            {sipName_QHelpEngineCore,	&sipType_QHelpEngineCore,	8, 6},
            {sipName_QHelpSearchQueryWidget,	&sipType_QHelpSearchQueryWidget,	-1, 7},
            {sipName_QHelpSearchEngine,	&sipType_QHelpSearchEngine,	-1, -1},
            {sipName_QHelpEngine,	&sipType_QHelpEngine,	-1, -1},
        };
    
        int i = 0;
    
        sipType = 0;
    
        do
        {
            struct class_graph *cg = &graph[i];
    
            if (cg->name != NULL && sipCpp->inherits(cg->name))
            {
                sipType = *cg->type;
                i = cg->yes;
            }
            else
                i = cg->no;
        }
        while (i >= 0);
#line 315 "/Users/ktaylora/PLJV/tillage_likelihood_model/gui/PyQt4/QtHelp/sipQtHelpcmodule.cpp"

    return sipType;
}
示例#16
0
void QObject::setThreadData_helper(QThreadData *currentData, QThreadData *targetData)
{
   // move posted events
   int eventsMoved = 0;

   for (int i = 0; i < currentData->postEventList.size(); ++i) {
      const QPostEvent &postedEvent = currentData->postEventList.at(i);

      if (! postedEvent.event) {
         continue;
      }

      if (postedEvent.receiver == this) {
         // move this post event to the targetList
         targetData->postEventList.addEvent(postedEvent);
         const_cast<QPostEvent &>(postedEvent).event = 0;
         ++eventsMoved;
      }
   }

   if (eventsMoved > 0 && targetData->eventDispatcher) {
      targetData->canWait = false;
      targetData->eventDispatcher->wakeUp();
   }

   // the current emitting thread shouldn't restore currentSender after calling moveToThread()
   if (m_currentSender)  {
      m_currentSender->ref = 0;
   }

   m_currentSender = 0;

   // set new thread data
   targetData->ref();

	QThreadData *threadData = m_threadData.exchange(targetData);
   threadData->deref();
   
   for (int k = 0; k < m_children.size(); ++k) {
      QObject *child = m_children.at(k);
      child->setThreadData_helper(currentData, targetData);
   }
}
示例#17
0
static ParseNode f_executeSlot(Parser* parser, const ParameterList& params)
{
  ParameterList::ConstIterator it = params.begin(); 
  QString slotName = (*it).toString()+"("; 
  ++it;
  QString widgetName = (*it).toString();
  KommanderWidget* widget = parser->currentWidget();
  if (!widget)
    return ParseNode::error("unknown widget");
  widget = widget->widgetByName(widgetName);
  if (!widget)
    return ParseNode::error("unknown widget");
  QObject *object = widget->object();
  if (!object)
    return ParseNode::error("unknown widget");
  QStrList slotSignatures = object->metaObject()->slotNames(true);
  QStringList slotNames = QStringList::fromStrList(slotSignatures);
  int slotNum = -1;
  uint i = 0;
  while (i < slotNames.count())
  {
    if (slotNames[i].startsWith(slotName))
    {
      slotNum = i;
      break;
    }  
    i++;
  }
  if (slotNum == -1)
    return ParseNode::error("unknown function");
  QStringList args;
  ++it;   // skip widget
  while (it != params.end())
  {
    args += (*it).toString(); 
    ++it;
  }
  InvokeClass* inv = new InvokeClass(0);
  inv->invokeSlot(object, slotSignatures.at(slotNum), args);
  inv->deleteLater();

  return ParseNode();
}
示例#18
0
void HalBasicTest::testBasic()
{
    Solid::Backends::Hal::HalManager *manager = new Solid::Backends::Hal::HalManager(0);

    QVERIFY(manager->deviceExists("/org/freedesktop/Hal/devices/computer"));
    QVERIFY(!manager->allDevices().isEmpty());

    QVERIFY(!manager->devicesFromQuery(QString(), Solid::DeviceInterface::Processor).isEmpty());

    QString proc_udi = manager->devicesFromQuery(QString(), Solid::DeviceInterface::Processor).at(0);

    Solid::Backends::Hal::HalDevice *processor = qobject_cast<Solid::Backends::Hal::HalDevice *>(manager->createDevice(proc_udi));

    QCOMPARE(processor->udi(), proc_udi);
    QCOMPARE(processor->parentUdi(), QString("/org/freedesktop/Hal/devices/computer"));
    QVERIFY(!processor->allProperties().isEmpty());
    QVERIFY(processor->propertyExists("info.product"));
    QVERIFY(!processor->propertyExists("the.meaning.of.life"));
    QVERIFY(processor->queryDeviceInterface(Solid::DeviceInterface::Processor));
    QVERIFY(!processor->queryDeviceInterface(Solid::DeviceInterface::OpticalDisc));

    QObject *interface = processor->createDeviceInterface(Solid::DeviceInterface::Processor);
    Solid::Ifaces::Processor *proc_iface = qobject_cast<Solid::Ifaces::Processor *>(interface);

    QVERIFY(proc_iface!=0);

#if 0
    // HAL locking support being broken anyway...
    QVERIFY(!processor->isLocked());
    QVERIFY(processor->lock("No reason..."));
    QVERIFY(processor->isLocked());
    QCOMPARE(processor->lockReason(), QString("No reason..."));
    QVERIFY(!processor->lock("Need a reason?"));
    QVERIFY(processor->unlock());
#endif

    QObject *object = processor;
    QCOMPARE(interface->parent(), object);

    delete processor;
    delete manager;
}
示例#19
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget widget;
    widget.setWindowTitle(QT_VERSION_STR);

    QHBoxLayout *hLayout = new QHBoxLayout(&widget);
    QGroupBox *groupBox = new QGroupBox("QuickWidget", &widget);
    QVBoxLayout *vLayout = new QVBoxLayout(groupBox);
    QQuickWidget *quickWidget = new QQuickWidget(groupBox);
    quickWidget->setMinimumSize(360, 520);
    vLayout->addWidget(quickWidget);
    quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
    quickWidget->setSource(QUrl(QLatin1String("qrc:/main.qml")));
    if (quickWidget->status() == QQuickWidget::Error) {
        qWarning() << quickWidget->errors();
        return 1;
    }
    hLayout->addWidget(groupBox);

    const QUrl gallerySource(QLatin1String("qrc:/gallery.qml"));
    QQmlApplicationEngine engine(gallerySource);
    QObject *root = engine.rootObjects().value(0, Q_NULLPTR);
    if (!root || !root->isWindowType()) {
        qWarning() << "Load error" << gallerySource;
        return 1;
    }
    groupBox = new QGroupBox("QQuickView/createWindowContainer", &widget);
    vLayout = new QVBoxLayout(groupBox);
    QWidget *container = QWidget::createWindowContainer(qobject_cast<QWindow *>(root), groupBox);
    container->setMinimumSize(360, 520);
    vLayout->addWidget(container);
    hLayout->addWidget(groupBox);

    const QRect availableGeometry = QApplication::desktop()->availableGeometry(&widget);
    widget.move(availableGeometry.center() - QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height() / 2));

    widget.show();

    return app.exec();
}
示例#20
0
void QuickInterpreter::addTopLevelObject(QObject *o)
{
    QSEngine::init();
    if (!toplevel)
	toplevel = new QObjectList;
    if (toplevel->indexOf(o) != -1)
	return;

    Q_ASSERT(!hasTopLevelParent(o));

    for(int i=0; i<toplevel->size(); ++i) {
        QObject *cur = toplevel->at(i);
	if(cur == o) {
	    return;
	} else if (cur && o
                   && cur->objectName() == o->objectName()) {
	    return;
	}
    }


    toplevel->append(o);

    kids.clear();
    if (!toplevel)
	return;
    for (int i=0; i<toplevel->size(); ++i) {
        QObject *obj = toplevel->at(i);
	kids.append(obj->objectName());
    }
    connect(o, SIGNAL(destroyed(QObject *)), this, SLOT(topLevelDestroyed(QObject *)));

    QSObject global = env()->globalObject();
    const_cast<QSClass *>(global.objectType())->deleteMember(o->objectName());
    QString context_name = o->objectName();
    if (context_name.isEmpty()) {
        context_name = "unnamed";
    } else {
        staticGlobals << context_name;
    }
    env()->globalObject().put(context_name, wrap(o));
}
示例#21
0
void TSBrowserApplication::showDownloadManager(QObject *wid, bool _show/* = true*/)
{
	if( !wid ) return;
	
	QObject *p = wid;
	TSMainWindow *_mw = 0;

	while(p)
	{	
		_mw = dynamic_cast<TSMainWindow*>(p);
	
		if( _mw ) 
		{
			_mw->showDownloadManager(TSBrowserApplication::instance()->downloadManager(), _show);
			return;
		}

		p = p->parent();
	}		
}
void CollocationsDialogController::sl_minusClicked() {
    if (task != NULL) {
        return;
    }

    QObject* o = sender();
    QString name = o->objectName();

    assert(usedNames.contains(name));
    usedNames.remove(name);
    for (int i=0, n = annotationsTree->topLevelItemCount(); i<n; i++) {
        QTreeWidgetItem* item = annotationsTree->topLevelItem(i);
        if (item->text(0) == name) {
            annotationsTree->takeTopLevelItem(i);
            delete item;
            break;
        }
    }
    updateState();
}
示例#23
0
void ErrorHandler::componentComplete(){
    m_componentComplete = true;
    if ( !m_target ){
        m_target = parent();
        if ( !m_target )
            return;
    }

    QObject* livecv  = qmlEngine(this)->rootContext()->contextProperty("livecv").value<QObject*>();
    if ( !livecv ){
        qCritical("ErrorHandler: Failed to find engine. ErrorHandling will not work.");
        return;
    }
    m_engine = qobject_cast<Engine*>(livecv->property("engine").value<QObject*>());
    if ( !m_engine ){
        qCritical("ErrorHandler: Failed to find engine. ErrorHandling will not work.");
    }

    m_engine->registerErrorHandler(m_target, this);
}
示例#24
0
文件: qgroupbox.cpp 项目: redanium/qt
/*
  sets all children of the group box except the qt_groupbox_checkbox
  to either disabled/enabled
*/
void QGroupBoxPrivate::_q_setChildrenEnabled(bool b)
{
    Q_Q(QGroupBox);
    QObjectList childList = q->children();
    for (int i = 0; i < childList.size(); ++i) {
        QObject *o = childList.at(i);
        if (o->isWidgetType()) {
            QWidget *w = static_cast<QWidget *>(o);
            if (b) {
                if (!w->testAttribute(Qt::WA_ForceDisabled))
                    w->setEnabled(true);
            } else {
                if (w->isEnabled()) {
                    w->setEnabled(false);
                    w->setAttribute(Qt::WA_ForceDisabled, false);
                }
            }
        }
    }
}
示例#25
0
static QWidget *get_next_widget(QObjectList &list, int &index)
{
	QObject *ob;
	
	for(;;)
	{
		if (index >= list.count())
			return NULL;
	
		ob = list.at(index); // ob might be null if we are inside the QWidget destructor
		index++;
		
		if (ob && ob->isWidgetType())
		{
			QWidget *w = (QWidget *)ob;
			if (!w->isHidden() && !qobject_cast<QSizeGrip *>(w))
				return w;
		}
	}
}
示例#26
0
void WaitForEventTest::testHandleEventEventTypeNotExpected() {
    QObject parentObject;

    WaitForEventWithCustomHandling waitForEvent(&parentObject,
                                                QEvent::ChildRemoved);
    waitForEvent.setActive(true);

    QObject* childObject = new QObject();
    childObject->setParent(&parentObject);

    QCOMPARE(waitForEvent.mHandledEventsCount, 0);

    childObject->setParent(0);

    QCOMPARE(waitForEvent.mHandledEventsCount, 1);

    childObject->setParent(&parentObject);

    QCOMPARE(waitForEvent.mHandledEventsCount, 1);
}
示例#27
0
void QueueLocal::jobFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
  QByteArray result = m_process->readAllStandardError();
  qDebug() << "Program output:" << result;
  qDebug() << "Return code:" << exitCode << exitStatus;

  QObject *theSender = QObject::sender();
  if (!theSender)
    return;

  qDebug() << "The job was successfully finished:"
           << theSender->property("JOB_ID");
  int id = theSender->property("JOB_ID").toInt();
  m_jobs[id]->setStatus(Job::COMPLETE);
  emit(jobStateChanged(0));
  // Submit the next job if there is one
  ++m_currentJob;
  if (m_currentJob < m_jobs.size())
    runProgram(m_currentJob);
}
示例#28
0
CopasiWidget::CopasiWidget(QWidget * parent, const char * name, Qt::WFlags f)
  : QWidget(parent, f),
    mpListView(NULL),
    mKey(),
    mpObject(NULL),
    mpDataModel(NULL),
    mIgnoreUpdates(false),
    mFramework(0)
{
  setObjectName(name);
  QObject *pParent = parent;

  while (pParent != NULL &&
         (mpListView = dynamic_cast< ListViews * >(pParent)) == NULL)
    {
      pParent = pParent->parent();
    }

  assert(mpListView != NULL);
}
void tst_qdeclarativemoduleplugin::remoteImportWithQuotedUrl()
{
    TestHTTPServer server(SERVER_PORT);
    QVERIFY(server.isValid());
    server.serveDirectory(SRCDIR "/imports");

    QDeclarativeEngine engine;
    QDeclarativeComponent component(&engine);
    component.setData("import \"http://127.0.0.1:14450/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());

    QTRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
    QObject *object = component.create();
    QCOMPARE(object->property("width").toInt(), 300);
    QVERIFY(object != 0);
    delete object;

    foreach (QDeclarativeError err, component.errors())
        qWarning() << err;
    VERIFY_ERRORS(0);
}
示例#30
0
void TestPlugins::plugins02()
      {
      QString path = root + DIR + "plugins02.qml";
      QDeclarativeComponent component(&engine,
         QUrl::fromLocalFile(path));
      QObject* object = component.create();
      QVERIFY(object != 0);
      if (object == 0) {
            qDebug("creating component <%s> failed", qPrintable(path));
            foreach(QDeclarativeError e, component.errors())
                  qDebug("   line %d: %s", e.line(), qPrintable(e.description()));
            }
      else {
            qreal width  = object->property("width").toDouble();
            qreal height = object->property("height").toDouble();
            QCOMPARE(width, 150.0);
            QCOMPARE(height, 75.0);
            }
      delete object;
      }