Exemplo n.º 1
0
void QuickInterpreter::setTopLevelObjects(QObjectList *l)
{
    QSEngine::init();
    if(toplevel)
        for (int i=0; i<toplevel->size(); ++i) {
            QObject *o = toplevel->at(i);
	    disconnect(o, SIGNAL(destroyed(QObject*)),
			this, SLOT(topLevelDestroyed(QObject*)));
        }
    delete toplevel;
    toplevel = new QObjectList;

    kids.clear();
    if (!l) {
	toplevel->clear();
	return;
    }
    QSObject global(env()->globalObject());

    for (int i=0; i<toplevel->size(); ++i) {
        QObject *o = toplevel->at(i);
	if (hasTopLevelParent(o)) {
	    continue;
	}
	kids.append(o->objectName());
	connect(o, SIGNAL(destroyed(QObject *)),
		 this, SLOT(topLevelDestroyed(QObject *)));
	global.put(o->objectName(), wrap(o));
	staticGlobals << o->objectName();
	toplevel->append(o);
    }
    delete l;
}
Exemplo n.º 2
0
static QObject *qChildHelper(const char *objName, const char *inheritsClass,
                             bool recursiveSearch, const QObjectList &children)
{
    if (children.isEmpty())
        return 0;

    bool onlyWidgets = (inheritsClass
                        && qstrcmp(inheritsClass, "QWidget") == 0);
    const QLatin1String oName(objName);

    for (int i = 0; i < children.size(); ++i)
    {
        QObject *obj = children.at(i);

        if (onlyWidgets)
        {
            if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
                return obj;
        }
        else if ((!inheritsClass || obj->inherits(inheritsClass))
                 && (!objName || obj->objectName() == oName))
            return obj;

        if (recursiveSearch && (dynamic_cast<MythUIGroup *>(obj) != NULL)
            && (obj = qChildHelper(objName, inheritsClass,
                                   recursiveSearch,
                                   obj->children())))
            return obj;
    }

    return 0;
}
Exemplo n.º 3
0
void Object::setAttribute()
{
    IObject::setAttribute();
    QObject* widget = sender();
    if(widget->objectName() == "experience")
        _experience = ((QSpinBox*)widget)->value();
    else if(widget->objectName() == "cooldown")
        _cooldown = ((QSpinBox*)widget)->value();
}
Exemplo n.º 4
0
void WinControl::callQTModule( )
{
    QObject *obj = (QObject *)sender();
    if(string("*exit*") == obj->objectName().toAscii().data())	SYS->stop();
    else
    {
	try{ callQTModule(obj->objectName().toAscii().data()); }
	catch(TError err) {  }
    }
}
void ClientBackgroundManager::callClient() {
    QObject* sendedFrom = sender();
    qDebug() << "Called callClient" << sendedFrom->objectName();
    //send message to server
    MessageEnvelop call(REQUEST_CALL_TO_CLIENT_FROM_SERVER);
    call.setName(sendedFrom->objectName());
    emit sendDataToServer(call);
    //myClient2ServerThread.sendMessageToServer(call);
    //GUI

}
Exemplo n.º 6
0
void Object::setAttribute()
{
    IObject::setAttribute();
    QObject* widget = sender();
    if(widget->objectName() == "bonus")
        _bonus = ((QSpinBox*)widget)->value();
    else if(widget->objectName() == "time")
        _time = ((QSpinBox*)widget)->value();
    else if(widget->objectName() == "cooldown")
        _cooldown = ((QSpinBox*)widget)->value();
}
Exemplo n.º 7
0
void Courier::setForwardRescheduleSignal(QObject &ob, bool fwd)
{
	if(fwd) {
		if(!connect(&ob,SIGNAL(reschedule(quint64)),this,SIGNAL(reschedule(quint64)),OC_CONTYPE)) {
			qWarning()<<"ERROR: Could not connect "<<ob.objectName();
		}
	} else {
		if(!disconnect(&ob,SIGNAL(reschedule(quint64)),this,SIGNAL(reschedule(quint64)))) {
			qWarning()<<"ERROR: Could not disconnect "<<ob.objectName();
		}
	}
}
Exemplo n.º 8
0
void qt_object_node::init(QObject& obj)
{
  auto name = obj.objectName();

  if (!name.isEmpty())
    set_name(obj.objectName().toStdString());
  else
  {
    std::string str;
    const QMetaObject* mo = obj.metaObject();
    while (str.empty())
    {
      str = mo->className();
      mo = mo->superClass();
      if (!mo)
        break;
    }

    if (!str.empty())
    {
      set_name(std::move(str));
    }
    else
    {
      set_name("Object");
    }
  }

  // Note : we create the childrens, and then lock the vector
  // because the children creation operation calls node_base::children() which
  // causes
  // double locking.
  decltype(m_children) children_vect;
  for (auto c : obj.children())
  {
    children_vect.push_back(
        std::make_unique<qt_object_node>(*c, m_device, *this));
  }

  for (int i = 0; i < obj.metaObject()->propertyCount(); i++)
  {
    children_vect.push_back(std::make_unique<qt_property_node>(
        obj, obj.metaObject()->property(i), m_device, *this));
  }

  {
    write_lock_t lock{m_mutex};
    std::move(
        children_vect.begin(), children_vect.end(),
        std::back_inserter(m_children));
  }
}
Exemplo n.º 9
0
void            GUI::EverywhereWindow::switchView() {
    QObject* senderObj = sender();
    ui->globalWidget->setStyleSheet("QWidget#globalWidget { background : url(C:/everywhere/images/"
                                    + _menuWidgets[senderObj->objectName()].first + "Background.png); }");
    ui->globalWidget->style()->unpolish(ui->globalWidget);
    ui->globalWidget->style()->polish(ui->globalWidget);
    ui->globalWidget->update();

    _current = _menuWidgets[senderObj->objectName()];
    manageMenu();
    _current.second->initialize();
    QTimer::singleShot(400, this, SLOT(updateView()));
}
Exemplo n.º 10
0
void Combat::buttonClickedSlot()
{
    if(!rollDice)
    {
        //we can apply the hit now
        for(int i = 0; i < playerCount.size(); i++)
        {
            if(getPlayerTurn() == playerCount.at(i))
            {
                int hitPoint = playerHitPoint.at(i)->objectName().toInt();
                //get the button
                QObject *button = sender();
                QWidget *widget = qobject_cast<QWidget *>(button);
                //get the player rack
                QObject *PlayerRack = button->parent();
                int playerWidgetID = PlayerRack->objectName().toInt();
                if(playerWidgetID == getPlayerTurn())
                {
                    Message("Warning", "You can't remove your things");
                } else {
                    //remove the thing and button
                    if(hitPoint == 0)
                    {
                        //not enough hitpoint,change to next player
                        popMessageBox();
                        Message("Warning", "Don't have hitpoint!");
                        break;
                    } else {
                        //remove the things
                        int ThingID = button->objectName().toInt();
                        removePlayerThingFromID(ThingID);
                        //delete the button
                        delete widget;
                        //refresh the playerhitpoint label
                        playerHitPoint.at(i)->setObjectName(QString::number(hitPoint-1));
                        QString temp ="Player " + QString::number(playerCount.at(i)) +  " HitPoint : " + playerHitPoint.at(i)->objectName();
                        playerHitPoint.at(i)->setText(temp);
                        //check if the hitPoint become to 0
                        if(!checkAllPlayerRack()&&(hitPoint == 1))
                        {
                            popMessageBox();
                            break;
                        }
                    }
                }
            }
        }

    }

}
Exemplo n.º 11
0
void format_arg(fmt::BasicFormatter<char>& f, const char*&, const QObject& qobj)
{
    auto& w = f.writer();

    w.write("{}<{:#x}", qobj.metaObject()->className(), reinterpret_cast<uintptr_t>(&qobj));

    if (!qobj.objectName().isEmpty())
    {
        w.write(" ");
        w.write(qobj.objectName().toStdString());
    }

    w.write(">");
}
Exemplo n.º 12
0
int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegExp& regExp, QList<QObject*>& list)
{
  const QObjectList& children = parent->children();
  int i;

  for (i = 0; i < children.size(); ++i) {
    QObject* obj = children.at(i);

    if (!obj)
      return -1;

    // Skip if the name doesn't match.
    if (regExp.indexIn(obj->objectName()) == -1)
      continue;

    if ((typeName && obj->inherits(typeName)) ||
      (meta && meta->cast(obj))) {
        list += obj;
    }

    if (findChildren(obj, typeName, meta, regExp, list) < 0)
      return -1;
  }

  return 0;
}
Exemplo n.º 13
0
QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name)
{
  const QObjectList &children = parent->children();

  int i;
  for (i = 0; i < children.size(); ++i) {
    QObject* obj = children.at(i);

    if (!obj)
      return NULL;

    // Skip if the name doesn't match.
    if (!name.isNull() && obj->objectName() != name)
      continue;

    if ((typeName && obj->inherits(typeName)) ||
      (meta && meta->cast(obj)))
      return obj;
  }

  for (i = 0; i < children.size(); ++i) {
    QObject* obj = findChild(children.at(i), typeName, meta, name);

    if (obj != NULL)
      return obj;
  }

  return NULL;
}
Exemplo n.º 14
0
void RibbonWidget::itemSelected()
{
	QObject *source = this->sender();
	QString name = source->objectName();

	emit itemSelected(name);
}
Exemplo n.º 15
0
void MyMenu::componentComplete()
{
    QObjectList temp_list = children ();
    for (int i=0; i<temp_list.count (); ++i) {
        QObject *obj = temp_list.at (i);
        if( obj->objectName ()=="MyMenuItem"){
            MyMenuItem *item = qobject_cast<MyMenuItem*>(obj);
            menu->addAction(item);
        }else if(obj->objectName ()=="MenuSeparator"){
            menu->addSeparator ();
        }else if(obj->objectName ()=="MyMenu"){
            MyMenu *item = qobject_cast<MyMenu*>(obj);
            menu->addMenu (item->menu);
        }
    }
}
Exemplo n.º 16
0
void Home::contactClick()
{
	QObject *senderObj = sender();
	QString senderObjName = senderObj->objectName();
	QPushButton *tmp = (QPushButton *)senderObj;
	if (_pushtmp != NULL)
	{
		_pushtmp->setEnabled(true);
		//_pushtmp->setStyleSheet("QPushButton{color: rgb(0, 0, 0);}");
	}
	tmp->setEnabled(false);
	_pushtmp = tmp;
	_activeUser = senderObjName.toInt();
	if (_activeUser == _myid)
	{
		ui->_lineContactName->setReadOnly(false);
		ui->_lineSurnameEdit->setReadOnly(false);
		ui->_lineBirthday->setReadOnly(false);
		ui->_lineLocalisation->setReadOnly(false);
		ui->_linePhoneNumber->setReadOnly(false);
	}
	else
	{
		ui->_lineContactName->setReadOnly(true);
		ui->_lineSurnameEdit->setReadOnly(true);
		ui->_lineBirthday->setReadOnly(true);
		ui->_lineLocalisation->setReadOnly(true);
		ui->_linePhoneNumber->setReadOnly(true);
	}
	ui->_lineContactName->setText(_musers[_activeUser]->get_name().c_str());
	ui->_lineSurnameEdit->setText(_musers[_activeUser]->get_surname().c_str());
	ui->_lineBirthday->setText(_musers[_activeUser]->get_birth().c_str());
	ui->_lineLocalisation->setText(_musers[_activeUser]->get_address().c_str());
	ui->_linePhoneNumber->setText(_musers[_activeUser]->get_phone().c_str());
}
Exemplo n.º 17
0
int main() {
    QObject* pobj1 = new QObject;
    QObject* pobj2 = new QObject(pobj1);
    QObject* pobj4 = new QObject(pobj2);
    QObject* pobj3 = new QObject(pobj1);
    pobj2->setObjectName("the first child of pobj1");
    pobj3->setObjectName("the second child of pobj1");
    pobj4->setObjectName("the first child of pobj2");

    for (QObject* pobj = pobj4; pobj; pobj = pobj->parent()) {
        qDebug() << pobj->objectName();
    }

    QObject* pobj =
        pobj1->findChild<QObject*>("the first child of pobj2");
    QList<QObject*> plist1 = 
        pobj1->findChildren<QObject*>(QRegExp("th*"));
    QList<QObject*> plist2 =
        pobj1->findChildren<QObject*>();

    pobj1->dumpObjectInfo();
    pobj1->dumpObjectTree();

    qDebug() << pobj1->metaObject()->className();

    return 0;
}
Exemplo n.º 18
0
void tst_QWidgetsVariant::qvariant_cast_QObject()
{
    QFETCH(QVariant, data);
    QFETCH(bool, success);

    QObject *o = qvariant_cast<QObject *>(data);
    QCOMPARE(o != 0, success);
    if (success) {
        QCOMPARE(o->objectName(), QString::fromLatin1("Hello"));
        QVERIFY(data.canConvert<QObject*>());
        QVERIFY(data.canConvert(QMetaType::QObjectStar));
        QVERIFY(data.canConvert(::qMetaTypeId<QObject*>()));
        QVERIFY(data.value<QObject*>());
        QVERIFY(data.convert(QMetaType::QObjectStar));
        QCOMPARE(data.userType(), int(QMetaType::QObjectStar));

        QVERIFY(data.canConvert<QWidget*>());
        QVERIFY(data.canConvert(::qMetaTypeId<QWidget*>()));
        QVERIFY(data.value<QWidget*>());
        QVERIFY(data.convert(qMetaTypeId<QWidget*>()));
        QCOMPARE(data.userType(), qMetaTypeId<QWidget*>());
    } else {
        QVERIFY(!data.canConvert<QObject*>());
        QVERIFY(!data.canConvert(QMetaType::QObjectStar));
        QVERIFY(!data.canConvert(::qMetaTypeId<QObject*>()));
        QVERIFY(!data.value<QObject*>());
        QVERIFY(!data.convert(QMetaType::QObjectStar));
        QVERIFY(data.userType() != QMetaType::QObjectStar);
    }
    delete o;
}
Exemplo n.º 19
0
QString General::getPackage() const{
    QObject *p = parent();
    if(p)
        return p->objectName();
    else
        return QString(); // avoid null pointer exception;
}
Exemplo n.º 20
0
QVariant QObjectTreeModel::data( const QModelIndex& index, int role ) const
{
    if( !index.isValid() )
        return QVariant();

    if( role != Qt::DisplayRole )
        return QVariant();

    QObject* item = static_cast<QObject*>( index.internalPointer() );

    switch( index.column() )
    {
        case 0:
        {
            Gluon::GluonObject* gobj = qobject_cast<Gluon::GluonObject*>( item );
            if( gobj ) return gobj->name();
            return item->objectName();
            break;
        }
        case 1:
            return item->metaObject()->className();
            break;
        default:
            return QVariant();
    }
}
Exemplo n.º 21
0
/**
 * Makes a connection between the sender widget \a sender and its signal \a signal
 * of the created resource and Python callback function \a cb.
 * If the sender widget does not exist or no resource has been loaded this method returns FALSE, 
 * otherwise it returns TRUE.
 */
bool PyResource::connect(const char* sender, const char* signal, PyObject* cb)
{
    if ( !myDlg )
        return false;

    QObject* objS=0L;
    QList<QWidget*> list = myDlg->findChildren<QWidget*>();
    QList<QWidget*>::const_iterator it = list.begin();
    QObject *obj;
    QString sigStr = QString::fromAscii("2%1").arg(QString::fromAscii(signal));

    while ( it != list.end() ) {
        obj = *it;
        ++it;
        if (obj->objectName() == QLatin1String(sender)) {
            objS = obj;
            break;
        }
    }

    if (objS) {
        SignalConnect* sc = new SignalConnect(this, cb, objS);
        mySingals.push_back(sc);
        return QObject::connect(objS, sigStr.toAscii(), sc, SLOT ( onExecute() )  );
    }
    else
        qWarning( "'%s' does not exist.\n", sender );

    return false;
}
Exemplo n.º 22
0
void ColumnDropCSVView::mousePressEvent(QMouseEvent *press)
{
	QModelIndex atClick = indexAt(press->pos());
	if (!atClick.isValid() || atClick.row())
		return;

	QRect indexRect = visualRect(atClick);
	QPixmap pix(indexRect.width(), indexRect.height());
	pix.fill(QColor(0,0,0,0));
	render(&pix, QPoint(0, 0),QRegion(indexRect));

	QDrag *drag = new QDrag(this);
	QMimeData *mimeData = new QMimeData;
	mimeData->setData(subsurface_mimedata, atClick.data().toByteArray());
	mimeData->setData(subsurface_index, QString::number(atClick.column()).toUtf8());
	drag->setPixmap(pix);
	drag->setMimeData(mimeData);
	if (drag->exec() != Qt::IgnoreAction){
		QObject *target = drag->target();
		if (target->objectName() ==  "qt_scrollarea_viewport")
			target = target->parent();
		if (target != drag->source())
			model()->setData(atClick, QString());
	}
}
Exemplo n.º 23
0
JSValue QtInstance::stringValue(ExecState* exec) const
{
    QObject* obj = getObject();
    if (!obj)
        return jsNull();

    // Hmm.. see if there is a toString defined
    QByteArray buf;
    bool useDefault = true;
    getClass();
    if (m_class) {
        // Cheat and don't use the full name resolution
        int index = obj->metaObject()->indexOfMethod("toString()");
        if (index >= 0) {
            QMetaMethod m = obj->metaObject()->method(index);
            // Check to see how much we can call it
            if (m.access() != QMetaMethod::Private
                && m.methodType() != QMetaMethod::Signal
#if HAVE(QT5)
                && m.parameterCount() == 0
                && m.returnType() != QMetaType::Void) {
                QVariant ret(m.returnType(), (void*)0);
                void * qargs[1];
                qargs[0] = ret.data();

                if (QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, qargs) < 0) {
                    if (ret.isValid() && ret.canConvert(QVariant::String)) {
                        buf = ret.toString().toLatin1().constData(); // ### Latin 1? Ascii?
                        useDefault = false;
#else
                && m.parameterTypes().isEmpty()) {
                const char* retsig = m.typeName();
                if (retsig && *retsig) {
                    QVariant ret(QMetaType::type(retsig), (void*)0);
                    void * qargs[1];
                    qargs[0] = ret.data();

                    if (QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, qargs) < 0) {
                        if (ret.isValid() && ret.canConvert(QVariant::String)) {
                            buf = ret.toString().toLatin1().constData(); // ### Latin 1? Ascii?
                            useDefault = false;
                        }
#endif
                    }
                }
            }
        }
    }

    if (useDefault) {
        const QMetaObject* meta = obj ? obj->metaObject() : &QObject::staticMetaObject;
        QString name = obj ? obj->objectName() : QString::fromUtf8("unnamed");
        QString str = QString::fromUtf8("%0(name = \"%1\")")
                      .arg(QLatin1String(meta->className())).arg(name);

        buf = str.toLatin1();
    }
    return jsString(exec, buf.constData());
}
Exemplo n.º 24
0
// Forward the async storeReady signal
void NodeAssociateStore::hookSignals(QObject &ob)
{
	if(!connect(this, SIGNAL(peerStoreReady(bool)), &ob, SLOT(onPeerStoreReady(bool)),OC_CONTYPE)) {
		qWarning()<<"Could not connect "<<ob.objectName();
	} else {
		//qDebug()<<"HOOKING peerStoreReady";
	}
	if(!connect(this,SIGNAL(peerAdded(QString)),&ob,SLOT(onPeerAdded(QString)),OC_CONTYPE)) {
Exemplo n.º 25
0
void BCI2000Viewer::ExecuteAction()
{
  QObject* pSender = sender();
  for( size_t i = 0; i < sizeof( sActions ) / sizeof( *sActions ); ++i )
    if( pSender->objectName() == sActions[i].object )
      (this->*sActions[i].action)();
  UpdateActions();
}
Exemplo n.º 26
0
void KeyStore::unhookSignals(QObject &ob)
{
	if(!disconnect(this, SIGNAL(keystoreReady(bool)), &ob, SLOT(onKeystoreReady(bool)))) {
		qWarning()<<"Could not disconnect "<<ob.objectName();
	} else {
		//qDebug()<<"UN-HOOKING keystoreReady";
	}
}
Exemplo n.º 27
0
void Node::unHookColorSignals(QObject &ob)
{
	if(nullptr!=mSensorsCourier) {
		if(!disconnect(&ob,SIGNAL(colorChanged(QColor)),mSensorsCourier,SLOT(onColorUpdated(QColor)))) {
			qWarning()<<"ERROR: Could not disconnect "<<ob.objectName();
		}
	}
}
Exemplo n.º 28
0
void mafHierarchy::printInformation(QString &string) {
    for (mafTree<QObject *>::prefix_iterator i = m_Tree->prefix_begin(); i != m_Tree->prefix_end(); ++i) {
        mafTreeNode<QObject *> *n = i.simplify().node();
        QObject *obj = n->m_data;
        if(obj != NULL) {
            if (n->m_parent) {
                QObject *objParent = n->m_parent->m_data;
                string.append(objParent->objectName());
                string.append("->");
            }
            string.append(obj->objectName());
            if (m_TreeIterator.node() == n) {
                string.append("<-current");
            }
            string.append("\n");
        }
    }
}
Exemplo n.º 29
0
void NameList::putResult(QObject *object) {
    QObject *p = object;
    while (!hasSiblings(p)) {
        p = p->parent();
    }
    bool ok;
    int index = p->property("index").toInt(&ok);
    if (ok && index < result.size())
        result[index] = p->objectName();
}
Exemplo n.º 30
0
/*!
    Adds \a object to the manager. Scripts handled by this manager
    can access the object in the code using the object's
    \l{QObject::objectName}{objectName} property.

    You must add all the necessary objects before loading any scripts.
*/
void QAxScriptManager::addObject(QAxBase *object)
{
    QObject *obj = object->qObject();
    QString name = obj->objectName();
    if (d->objectDict.contains(name))
        return;
    
    d->objectDict.insert(name, object);
    connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
}