void KonvergoWindow::handleHostCommand(QString hostCommand)
{
  QLOG_DEBUG() << "Got command:" << hostCommand;
  QString arguments = "";
  int arguments_start = hostCommand.indexOf(":");
  if (arguments_start > 0)
  {
    arguments = hostCommand.mid(arguments_start + 1);
    hostCommand = hostCommand.mid(0, arguments_start);
  }
  if (hostCommand == "fullscreen")
  {
    SettingsComponent::Get().setValue(SETTINGS_SECTION_MAIN, "fullscreen", !SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "fullscreen").toBool());
  }
  else if (hostCommand == "close")
  {
    close();
  }
  else if (hostCommand == "player")
  {
    PlayerComponent::Get().userCommand(arguments);
  }
  else if (hostCommand == "toggleDebug")
  {
    if (property("showDebugLayer").toBool())
    {
      m_infoTimer->stop();
      setProperty("showDebugLayer", false);
    }
    else
    {
      m_infoTimer->start();
      updateDebugInfo();
      setProperty("showDebugLayer", true);
    }
  }
  else if (hostCommand == "recreateRpiUi")
  {
    DisplayManager* display_manager = DisplayComponent::Get().getDisplayManager();
    if (display_manager)
      display_manager->resetRendering();
  }
  else if (hostCommand == "reload")
  {
    emit reloadWebClient();
  }
  else if (hostCommand == "crash!")
  {
    *(volatile int*)0=0;
  }
  else if (hostCommand == "poweroff")
  {
    PowerComponent::Get().PowerOff();
  }
  else if (hostCommand == "suspend")
  {
    PowerComponent::Get().Suspend();
  }
  else if (hostCommand == "reboot")
  {
    PowerComponent::Get().Reboot();
  }
  else
  {
    QLOG_WARN() << "unknown host command" << hostCommand;
  }
}
Пример #2
0
/*!
    Returns the value of the \a key property.
 */
QString QContent::property( Property key ) const
{
    return property( propertyKey( key ) );
}
Пример #3
0
QString PackageElement::toString( StringOutputRole stringRole) const
{
    Q_UNUSED( stringRole );
    return property( g_contextInfoElementNameKey ).toString();
}
Пример #4
0
const QString ClipController::clipId()
{
    if (m_masterProducer == NULL) return QString();
    return property(QStringLiteral("id"));
}
Пример #5
0
/*!
  Deletes the record with this primary key from the database.
*/
bool TSqlObject::remove()
{
    if (isNew()) {
        sqlError = QSqlError(QLatin1String("No record to remove"),
                             QString(), QSqlError::UnknownError);
        tWarn("Unable to remove the '%s' object. Create it before!", metaObject()->className());
        return false;
    }

    QSqlDatabase &database = Tf::currentSqlDatabase(databaseId());
    QString del = database.driver()->sqlStatement(QSqlDriver::DeleteStatement, tableName(), *static_cast<QSqlRecord *>(this), false);
    if (del.isEmpty()) {
        sqlError = QSqlError(QLatin1String("Unable to delete row"),
                             QString(), QSqlError::StatementError);
        return false;
    }

    del.append(" WHERE ");
    int revIndex = -1;

    for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) {
        const char *propName = metaObject()->property(i).name();
        QByteArray prop = QByteArray(propName).toLower();

        if (prop == LockRevision) {
            bool ok;
            int revision = property(propName).toInt(&ok);

            if (!ok || revision <= 0) {
                sqlError = QSqlError(QLatin1String("Unable to convert the 'revision' property to an int"),
                                     QString(), QSqlError::UnknownError);
                tError("Unable to convert the 'revision' property to an int, %s", qPrintable(objectName()));
                return false;
            }

            del.append(QLatin1String(propName));
            del.append("=").append(TSqlQuery::formatValue(revision, QVariant::Int, database));
            del.append(" AND ");

            revIndex = i;
            break;
        }
    }

    auto metaProp = metaObject()->property(metaObject()->propertyOffset() + primaryKeyIndex());
    const char *pkName = metaProp.name();
    if (primaryKeyIndex() < 0 || !pkName) {
        QString msg = QString("Primary key not found for table ") + tableName() + QLatin1String(". Create a primary key!");
        sqlError = QSqlError(msg, QString(), QSqlError::StatementError);
        tError("%s", qPrintable(msg));
        return false;
    }
    del.append(QLatin1String(pkName));
    del.append("=").append(TSqlQuery::formatValue(value(pkName), metaProp.type(), database));

    TSqlQuery query(database);
    bool ret = query.exec(del);
    sqlError = query.lastError();
    if (ret) {
        // Optimistic lock check
        if (query.numRowsAffected() != 1) {
            if (revIndex >= 0) {
                QString msg = QString("Row was updated or deleted from table ") + tableName() + QLatin1String(" by another transaction");
                sqlError = QSqlError(msg, QString(), QSqlError::UnknownError);
                throw SqlException(msg, __FILE__, __LINE__);
            }
            tWarn("Row was deleted by another transaction, %s", qPrintable(tableName()));
        }
        clear();
    }
    return ret;
}
Пример #6
0
 void preStart() {
     int w = property("wait", 5);
     sleep(w);
     *((int *)0) = 0;
 }
Пример #7
0
//virtual
QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
    if (change == QGraphicsItem::ItemSelectedChange) {
        if (value.toBool()) setZValue(3);
        else setZValue(1);
    }
    CustomTrackScene *scene = NULL;
    if (change == ItemPositionChange && parentItem() == 0) {
        scene = projectScene();
    }
    if (scene) {
        // calculate new position.
        if (scene->isZooming) {
            // For some reason, mouse wheel on selected itm sometimes triggered
            // a position change event corrupting timeline, so discard it
            return pos();
        }
        // calculate new position.
        const int trackHeight = KdenliveSettings::trackheight();
        QPointF start = sceneBoundingRect().topLeft();
        QPointF newPos = value.toPointF();
        int xpos = projectScene()->getSnapPointForPos((int)(start.x() + newPos.x() - pos().x()), KdenliveSettings::snaptopoints());

        xpos = qMax(xpos, 0);
        ////qDebug()<<"GRP XPOS:"<<xpos<<", START:"<<start.x()<<",NEW:"<<newPos.x()<<"; SCENE:"<<scenePos().x()<<",POS:"<<pos().x();
        newPos.setX((int)(pos().x() + xpos - (int) start.x()));
        QStringList lockedTracks = property("locked_tracks").toStringList();
	
        int proposedTrack = trackForPos(property("y_absolute").toInt() + newPos.y());
        // Check if top item is a clip or a transition
        int offset = 0;
        int topTrack = -1;
        QList<int> groupTracks;
        QList<QGraphicsItem *> children = childItems();
        for (int i = 0; i < children.count(); ++i) {
            int currentTrack = 0;
            if (children.at(i)->type() == AVWidget || children.at(i)->type() == TransitionWidget) {
                currentTrack = static_cast <AbstractClipItem*> (children.at(i))->track();
                if (!groupTracks.contains(currentTrack)) groupTracks.append(currentTrack);
            }
            else if (children.at(i)->type() == GroupWidget) {
                currentTrack = static_cast <AbstractGroupItem*> (children.at(i))->track();
            }
            else continue;
            if (children.at(i)->type() == AVWidget) {
                if (topTrack == -1 || currentTrack >= topTrack) {
                    offset = 0;
                    topTrack = currentTrack;
                }
            } else if (children.at(i)->type() == TransitionWidget) {
                if (topTrack == -1 || currentTrack > topTrack) {
                    offset = (int)(trackHeight / 3 * 2 - 1);
                    topTrack = currentTrack;
                }
            } else if (children.at(i)->type() == GroupWidget) {
                QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
                bool clipGroup = false;
                for (int j = 0; j < subchildren.count(); ++j) {
                    if (subchildren.at(j)->type() == AVWidget || subchildren.at(j)->type() == TransitionWidget) {
                        int subTrack = static_cast <AbstractClipItem*> (subchildren.at(j))->track();
                        if (!groupTracks.contains(subTrack)) groupTracks.append(subTrack);
                        clipGroup = true;
                    }
                }
                if (clipGroup) {
                    if (topTrack == -1 || currentTrack >= topTrack) {
                        offset = 0;
                        topTrack = currentTrack;
                    }
                } else {
                    if (topTrack == -1 || currentTrack > topTrack) {
                        offset = (int)(trackHeight / 3 * 2 - 1);
                        topTrack = currentTrack;
                    }
                }
            }
        }
        // Check no clip in the group goes outside of existing tracks
        int maximumTrack = projectScene()->tracksCount();
        int groupHeight = 0;
        for (int i = 0; i < groupTracks.count(); ++i) {
            int trackOffset = topTrack - groupTracks.at(i) + 1;
            if (trackOffset > groupHeight) groupHeight = trackOffset;
        }
        proposedTrack = qBound(groupHeight, proposedTrack, maximumTrack);
        int groupOffset = proposedTrack - topTrack;
        if (!lockedTracks.isEmpty()) {
            for (int i = 0; i < groupTracks.count(); ++i) {
                if (lockedTracks.contains(QString::number(groupTracks.at(i) + groupOffset))) {
                    return pos();
                }
            }
        }
        newPos.setY(posForTrack(proposedTrack) + offset);
        //if (newPos == start) return start;

        /*if (newPos.x() < 0) {
            // If group goes below 0, adjust position to 0
            return QPointF(pos().x() - start.x(), pos().y());
        }*/

        QList<QGraphicsItem*> collidingItems;
        QPainterPath shape;
        if (projectScene()->editMode() == NormalEdit) {
            shape = clipGroupShape(newPos - pos());
            collidingItems = scene->items(shape, Qt::IntersectsItemShape);
            collidingItems.removeAll(this);
            for (int i = 0; i < children.count(); ++i) {
                if (children.at(i)->type() == GroupWidget) {
                    QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
                    for (int j = 0; j < subchildren.count(); ++j) {
                        collidingItems.removeAll(subchildren.at(j));
                    }
                }
                collidingItems.removeAll(children.at(i));
            }
        }
        if (!collidingItems.isEmpty()) {
            bool forwardMove = xpos > start.x();
            int offset = 0;
            for (int i = 0; i < collidingItems.count(); ++i) {
                QGraphicsItem *collision = collidingItems.at(i);
                if (collision->type() == AVWidget) {
                    // Collision
                    if (newPos.y() != pos().y()) {
                        // Track change results in collision, restore original position
                        return pos();
                    }
                    AbstractClipItem *item = static_cast <AbstractClipItem *>(collision);
                    // Determine best pos
                    QPainterPath clipPath;
                    clipPath.addRect(item->sceneBoundingRect());
                    QPainterPath res = shape.intersected(clipPath);
                    offset = qMax(offset, (int)(res.boundingRect().width() + 0.5));
                }
            }
            if (offset > 0) {
                if (forwardMove) {
                    newPos.setX(newPos.x() - offset);
                } else {
                    newPos.setX(newPos.x() + offset);
                }
                // If there is still a collision after our position adjust, restore original pos
                collidingItems = scene->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape);
                collidingItems.removeAll(this);
                for (int i = 0; i < children.count(); ++i) {
                    if (children.at(i)->type() == GroupWidget) {
                        QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
                        for (int j = 0; j < subchildren.count(); ++j) {
                            collidingItems.removeAll(subchildren.at(j));
                        }
                    }
                    collidingItems.removeAll(children.at(i));
                }
                for (int i = 0; i < collidingItems.count(); ++i)
                    if (collidingItems.at(i)->type() == AVWidget) return pos();
            }
        }

        if (projectScene()->editMode() == NormalEdit) {
            shape = transitionGroupShape(newPos - pos());
            collidingItems = scene->items(shape, Qt::IntersectsItemShape);
            collidingItems.removeAll(this);
            for (int i = 0; i < children.count(); ++i) {
                if (children.at(i)->type() == GroupWidget) {
                    QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
                    for (int j = 0; j < subchildren.count(); ++j) {
                        collidingItems.removeAll(subchildren.at(j));
                    }
                }
                collidingItems.removeAll(children.at(i));
            }
        }
        if (collidingItems.isEmpty()) return newPos;
        else {
            bool forwardMove = xpos > start.x();
            int offset = 0;
            for (int i = 0; i < collidingItems.count(); ++i) {
                QGraphicsItem *collision = collidingItems.at(i);
                if (collision->type() == TransitionWidget) {
                    // Collision
                    if (newPos.y() != pos().y()) {
                        // Track change results in collision, restore original position
                        return pos();
                    }
                    AbstractClipItem *item = static_cast <AbstractClipItem *>(collision);
                    // Determine best pos
		    QPainterPath clipPath;
		    clipPath.addRect(item->sceneBoundingRect());
		    QPainterPath res = shape.intersected(clipPath);
		    offset = qMax(offset, (int)(res.boundingRect().width() + 0.5));
                }
            }
            if (offset > 0) {
                if (forwardMove) {
                    newPos.setX(newPos.x() - offset);
                } else {
                    newPos.setX(newPos.x() + offset);
                }
                // If there is still a collision after our position adjust, restore original pos
                collidingItems = scene->items(transitionGroupShape(newPos - pos()), Qt::IntersectsItemShape);
                for (int i = 0; i < children.count(); ++i) {
                    collidingItems.removeAll(children.at(i));
                }
                for (int i = 0; i < collidingItems.count(); ++i)
                    if (collidingItems.at(i)->type() == TransitionWidget) return pos();
            }
        }
        return newPos;
    }
    return QGraphicsItemGroup::itemChange(change, value);
}
Пример #8
0
	Self& signal(Signal<Args...> T::* member, std::string name, std::string description) {
		return property(member, name, description);
	}
Пример #9
0
// Return the instance's property as a reference property.
OMReferenceProperty * ImplAAFRefValue::referenceProperty(void) const
{
  return (static_cast<OMReferenceProperty *>(property()));
}
Пример #10
0
LEDBarGraphDisplay::LEDBarGraphDisplay(ICNDocument* icnDocument, bool newItem, const QString& id)
		: DIPComponent(icnDocument, newItem, id ? id : "bar_graph_display") {
	m_name = i18n("Bar Graph Display");
	m_bDynamicContent = true;

	m_numRows = 0;

	for (unsigned i = 0; i < max_LED_rows; i++)
		m_LEDParts[i] = 0;

	// Create a Row property.
	createProperty("rows", Variant::Type::Int);
	property("rows")->setCaption(i18n("Rows"));
	property("rows")->setMinValue(1);
	property("rows")->setMaxValue(max_LED_rows);
	property("rows")->setValue(7);

	createProperty("color", Variant::Type::Color);
	property("color")->setCaption(i18n("Color"));
	property("color")->setColorScheme(ColorCombo::LED);
	DiodeSettings ds;

	createProperty("I_S", Variant::Type::Double);
	property("I_S")->setCaption("Saturation Current");
	property("I_S")->setUnit("A");
	property("I_S")->setMinValue(1e-20);
	property("I_S")->setMaxValue(1e-0);
	property("I_S")->setValue(ds.I_S);
	property("I_S")->setAdvanced(true);

	createProperty("N", Variant::Type::Double);
	property("N")->setCaption(i18n("Emission Coefficient"));
	property("N")->setMinValue(1e0);
	property("N")->setMaxValue(1e1);
	property("N")->setValue(ds.N);
	property("N")->setAdvanced(true);

	createProperty("V_B", Variant::Type::Double);
	property("V_B")->setCaption(i18n("Breakdown Voltage"));
	property("V_B")->setUnit("V");
	property("V_B")->setMinAbsValue(1e-5);
	property("V_B")->setMaxValue(1e10);
	property("V_B")->setValue(ds.V_B);
	property("V_B")->setAdvanced(true);
}
Пример #11
0
const POP3ServiceInfos::props& POP3ServiceInfos::getProperties() const
{
	static props pop3Props =
	{
		// POP3-specific options
		property("options.apop", serviceInfos::property::TYPE_BOOL, "true"),
		property("options.apop.fallback", serviceInfos::property::TYPE_BOOL, "true"),
#if VMIME_HAVE_SASL_SUPPORT
		property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"),
		property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "true"),
#endif // VMIME_HAVE_SASL_SUPPORT

		// Common properties
		property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED),
		property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED),

#if VMIME_HAVE_TLS_SUPPORT
		property(serviceInfos::property::CONNECTION_TLS),
		property(serviceInfos::property::CONNECTION_TLS_REQUIRED),
#endif // VMIME_HAVE_TLS_SUPPORT

		property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
		property(serviceInfos::property::SERVER_PORT, "110"),
	};

	static props pop3sProps =
	{
		// POP3-specific options
		property("options.apop", serviceInfos::property::TYPE_BOOL, "true"),
		property("options.apop.fallback", serviceInfos::property::TYPE_BOOL, "true"),
#if VMIME_HAVE_SASL_SUPPORT
		property("options.sasl", serviceInfos::property::TYPE_BOOL, "true"),
		property("options.sasl.fallback", serviceInfos::property::TYPE_BOOL, "true"),
#endif // VMIME_HAVE_SASL_SUPPORT

		// Common properties
		property(serviceInfos::property::AUTH_USERNAME, serviceInfos::property::FLAG_REQUIRED),
		property(serviceInfos::property::AUTH_PASSWORD, serviceInfos::property::FLAG_REQUIRED),

#if VMIME_HAVE_TLS_SUPPORT
		property(serviceInfos::property::CONNECTION_TLS),
		property(serviceInfos::property::CONNECTION_TLS_REQUIRED),
#endif // VMIME_HAVE_TLS_SUPPORT

		property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
		property(serviceInfos::property::SERVER_PORT, "995"),
	};

	return m_pop3s ? pop3sProps : pop3Props;
}
Пример #12
0
 /**
  * @brief Class::containsProperty
  * @param name
  * @return
  */
 bool Class::containsProperty(const QString &name) const
 {
     return property(name) != nullptr;
 }
Пример #13
0
void
GcWindow::paintEvent(QPaintEvent * /*event*/)
{
    static QPixmap closeImage = QPixmap(":images/toolbar/popbutton.png");
    static QPixmap aluBar = QPixmap(":images/aluBar.png");
    static QPixmap aluBarDark = QPixmap(":images/aluBarDark.png");
    static QPixmap aluLight = QPixmap(":images/aluLight.jpg");
    static QPixmap carbon = QPixmap(":images/carbon.jpg");
    static QPalette defaultPalette;


    // setup a painter and the area to paint
    QPainter painter(this);
    // background light gray for now?
    QRect all(0,0,width(),height());
    painter.fillRect(all, property("color").value<QColor>());

    if (contentsMargins().top() > 0) {

        // fill in the title bar
        QRect bar(0,0,width(),contentsMargins().top());
        if (contentsMargins().top() < 25) {
        QColor bg;
        if (property("active").toBool() == true) {
            bg = GColor(CTILEBARSELECT);
            painter.drawPixmap(bar, aluBar);
        } else {
            bg = GColor(CTILEBAR);
            painter.drawPixmap(bar, aluBarDark);
        }
        } else {
            painter.setPen(Qt::darkGray);
            painter.drawRect(QRect(0,0,width()-1,height()-1));
        }

        // heading
        QFont font;
        font.setPointSize((contentsMargins().top()/2)+2);
        font.setWeight(QFont::Bold);
        painter.setFont(font);
        QString subtitle = property("subtitle").toString();
        QString title = property("title").toString();
        QString heading = subtitle != "" ? subtitle : title;

        // embossed...
        QRect shad = bar;
        shad.setY(bar.y()+2);
        //shad.setX(bar.x()+2);
        painter.setPen(QColor(255,255,255,180));
        painter.drawText(shad, heading, Qt::AlignVCenter | Qt::AlignCenter);

        painter.setPen(QColor(0,0,0,200));
        painter.drawText(bar, heading, Qt::AlignVCenter | Qt::AlignCenter);

        // border
        painter.setBrush(Qt::NoBrush);
        if (underMouse()) {

            QPixmap sized = closeImage.scaled(QSize(contentsMargins().top()-6,
                                                    contentsMargins().top()-6));
            //painter.drawPixmap(width()-3-sized.width(), 3, sized.width(), sized.height(), sized);

        } else {
            painter.setPen(Qt::darkGray);
            //painter.drawRect(QRect(0,0,width()-1,height()-1)); //XXX pointless
        }
    } else {
        // is this a layout manager?
        // background light gray for now?
        QRect all(0,0,width(),height());
        if (property("isManager").toBool() == true) {
            //painter.drawTiledPixmap(all, carbon);
            painter.fillRect(all, QColor("#B3B4BA"));
        } else {
            //painter.drawTiledPixmap(all, aluLight);
        }
    }
}
Пример #14
0
DPRectangle::DPRectangle( ItemDocument *itemDocument, bool newItem, const char *id )
	: DrawPart( itemDocument, newItem, id ? id : "rectangle" )
{
	m_pRectangularOverlay = new RectangularOverlay(this);
	m_name = i18n("Rectangle");
	
	createProperty( "background", Variant::Type::Bool );
	property("background")->setValue(false);
	property("background")->setCaption( i18n("Display Background") );
	property("background")->setAdvanced(true);
	
	createProperty( "background-color", Variant::Type::Color );
	property("background-color")->setValue(Qt::white);
	property("background-color")->setCaption( i18n("Background Color") );
	property("background-color")->setAdvanced(true);
	
	createProperty( "line-color", Variant::Type::Color );
	property("line-color")->setValue(Qt::black);
	property("line-color")->setCaption( i18n("Line Color") );
	property("line-color")->setAdvanced(true);
	
	createProperty( "line-width", Variant::Type::Int );
	property("line-width")->setCaption( i18n("Line Width") );
	property("line-width")->setMinValue(1);
	property("line-width")->setMaxValue(1000);
	property("line-width")->setValue(1);
	property("line-width")->setAdvanced(true);
	
	createProperty( "line-style", Variant::Type::PenStyle );
	property("line-style")->setAdvanced(true);
	property("line-style")->setCaption( i18n("Line Style") );
	setDataPenStyle( "line-style", Qt::SolidLine );
}
Пример #15
0
int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
{
    Q_Q(QDBusInterface);

    if (c == QMetaObject::InvokeMetaMethod) {
        int offset = metaObject->methodOffset();
        QMetaMethod mm = metaObject->method(id + offset);

        if (mm.methodType() == QMetaMethod::Signal) {
            // signal relay from D-Bus world to Qt world
            QMetaObject::activate(q, metaObject, id, argv);

        } else if (mm.methodType() == QMetaMethod::Slot) {
            // method call relay from Qt world to D-Bus world
            // get D-Bus equivalent signature
            QString methodName = QLatin1String(metaObject->dbusNameForMethod(id));
            const int *inputTypes = metaObject->inputTypesForMethod(id);
            int inputTypesCount = *inputTypes;

            // we will assume that the input arguments were passed correctly
            QVariantList args;
            for (int i = 1; i <= inputTypesCount; ++i)
                args << QVariant(inputTypes[i], argv[i]);

            // make the call
            QPointer<QDBusInterface> qq = q;
            QDBusMessage reply = q->callWithArgumentList(QDBus::Block, methodName, args);
            args.clear();

            // we ignore return values

            // access to "this" or to "q" below this point must check for "qq"
            // we may have been deleted!

            if (!qq.isNull())
                lastError = reply;

            // done
            return -1;
        }
    } else if (c == QMetaObject::ReadProperty) {
        // Qt doesn't support non-readable properties
        // we have to re-check
        QMetaProperty mp = metaObject->property(id + metaObject->propertyOffset());
        if (!mp.isReadable())
            return -1;          // don't read

        QVariant *value = reinterpret_cast<QVariant*>(argv[1]);
        argv[1] = 0;
        *value = property(mp);

        return -1;              // handled, error or not
    } else if (c == QMetaObject::WriteProperty) {
        // QMetaProperty::write has already checked that we're writable
        // it has also checked that the type is right
        QVariant *value = reinterpret_cast<QVariant *>(argv[1]);
        QMetaProperty mp = metaObject->property(id + metaObject->propertyOffset());

        setProperty(mp, *value);
        return -1;
    }
    return id;
}
Пример #16
0
void ShaderEffectItem::updateEffectState(const QMatrix4x4 &matrix)
{
    if (!m_program)
        return;

    for (int i = m_sources.size() - 1; i >= 0; --i) {
        const ShaderEffectItem::SourceData &source = m_sources.at(i);
        if (!source.source)
            continue;

        glActiveTexture(GL_TEXTURE0 + i);
        source.source->bind();
    }

    if (m_respectsOpacity)
        m_program->setUniformValue("qt_Opacity", static_cast<float> (effectiveOpacity()));

    if (m_respectsMatrix) {
        m_program->setUniformValue("qt_ModelViewProjectionMatrix", matrix);
    }

    QSet<QByteArray>::const_iterator it;
    for (it = m_uniformNames.begin(); it != m_uniformNames.end(); ++it) {
        const QByteArray &name = *it;
        QVariant v = property(name.constData());

        switch (v.type()) {
        case QVariant::Color:
            m_program->setUniformValue(name.constData(), qvariant_cast<QColor>(v));
            break;
        case QVariant::Double:
            m_program->setUniformValue(name.constData(), (float) qvariant_cast<double>(v));
            break;
        case QVariant::Transform:
            m_program->setUniformValue(name.constData(), qvariant_cast<QTransform>(v));
            break;
        case QVariant::Int:
            m_program->setUniformValue(name.constData(), GLint(v.toInt()));
            break;
        case QVariant::Bool:
            m_program->setUniformValue(name.constData(), GLint(v.toBool()));
            break;
        case QVariant::Size:
        case QVariant::SizeF:
            m_program->setUniformValue(name.constData(), v.toSizeF());
            break;
        case QVariant::Point:
        case QVariant::PointF:
            m_program->setUniformValue(name.constData(), v.toPointF());
            break;
        case QVariant::Rect:
        case QVariant::RectF:
        {
            QRectF r = v.toRectF();
            m_program->setUniformValue(name.constData(), r.x(), r.y(), r.width(), r.height());
        }
        break;
        case QVariant::Vector3D:
            m_program->setUniformValue(name.constData(), qvariant_cast<QVector3D>(v));
            break;
        default:
            break;
        }
    }
}
Пример #17
0
 void preStart() {
     int w = property("wait", 5);
     sleep(w);
 }
Пример #18
0
void ShaderEffectItem::changeSource(int index)
{
    Q_ASSERT(index >= 0 && index < m_sources.size());
    QVariant v = property(m_sources.at(index).name.constData());
    setSource(v, index);
}
Пример #19
0
QString JSContext::jsxTransform(const QString &jsx)
{
    auto val = TJSLoader("Jtf", "JSXTransformer").load()->call("Jtf.transform", jsx);
    return val.property("code").toString();
}
Пример #20
0
KUrl Nepomuk2::File::url() const
{
    return property( Nepomuk2::Vocabulary::NIE::url() ).toUrl();
}
Пример #21
0
QVariant Table::primaryValue() const
{
    return property(primaryKey().toLatin1().data());
}
bool QmlStateNodeInstance::isStateActive() const
{
    return stateObject() && stateGroup() && stateGroup()->state() == property("name");
}
Пример #23
0
/*!
  Updates the corresponding record with the properties of the object.
*/
bool TSqlObject::update()
{
    if (isNew()) {
        sqlError = QSqlError(QLatin1String("No record to update"),
                             QString(), QSqlError::UnknownError);
        tWarn("Unable to update the '%s' object. Create it before!", metaObject()->className());
        return false;
    }

    QSqlDatabase &database = Tf::currentSqlDatabase(databaseId());
    QString where(" WHERE ");

    // Updates the value of 'updated_at' or 'modified_at' property
    bool updflag = false;
    int revIndex = -1;

    for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) {
        const char *propName = metaObject()->property(i).name();
        QByteArray prop = QByteArray(propName).toLower();

        if (!updflag && (prop == UpdatedAt || prop == ModifiedAt)) {
            setProperty(propName, QDateTime::currentDateTime());
            updflag = true;

        } else if (revIndex < 0 && prop == LockRevision) {
            bool ok;
            int oldRevision = property(propName).toInt(&ok);

            if (!ok || oldRevision <= 0) {
                sqlError = QSqlError(QLatin1String("Unable to convert the 'revision' property to an int"),
                                     QString(), QSqlError::UnknownError);
                tError("Unable to convert the 'revision' property to an int, %s", qPrintable(objectName()));
                return false;
            }

            setProperty(propName, oldRevision + 1);
            revIndex = i;

            where.append(QLatin1String(propName));
            where.append("=").append(TSqlQuery::formatValue(oldRevision, QVariant::Int, database));
            where.append(" AND ");
        } else {
            // continue
        }
    }

    QString upd;   // UPDATE Statement
    upd.reserve(255);
    upd.append(QLatin1String("UPDATE ")).append(tableName()).append(QLatin1String(" SET "));

    int pkidx = metaObject()->propertyOffset() + primaryKeyIndex();
    QMetaProperty metaProp = metaObject()->property(pkidx);
    const char *pkName = metaProp.name();
    if (primaryKeyIndex() < 0 || !pkName) {
        QString msg = QString("Primary key not found for table ") + tableName() + QLatin1String(". Create a primary key!");
        sqlError = QSqlError(msg, QString(), QSqlError::StatementError);
        tError("%s", qPrintable(msg));
        return false;
    }

    QVariant::Type pkType = metaProp.type();
    QVariant origpkval = value(pkName);
    where.append(QLatin1String(pkName));
    where.append("=").append(TSqlQuery::formatValue(origpkval, pkType, database));
    // Restore the value of primary key
    QObject::setProperty(pkName, origpkval);

    for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) {
        metaProp = metaObject()->property(i);
        const char *propName = metaProp.name();
        QVariant newval = QObject::property(propName);
        QVariant recval = QSqlRecord::value(QLatin1String(propName));
        if (i != pkidx && recval.isValid() && recval != newval) {
            upd.append(QLatin1String(propName));
            upd.append(QLatin1Char('='));
            upd.append(TSqlQuery::formatValue(newval, metaProp.type(), database));
            upd.append(QLatin1String(", "));
        }
    }

    if (!upd.endsWith(QLatin1String(", "))) {
        tSystemDebug("SQL UPDATE: Same values as that of the record. No need to update.");
        return true;
    }

    upd.chop(2);
    syncToSqlRecord();
    upd.append(where);

    TSqlQuery query(database);
    bool ret = query.exec(upd);
    sqlError = query.lastError();
    if (ret) {
        // Optimistic lock check
        if (revIndex >= 0 && query.numRowsAffected() != 1) {
            QString msg = QString("Row was updated or deleted from table ") + tableName() + QLatin1String(" by another transaction");
            sqlError = QSqlError(msg, QString(), QSqlError::UnknownError);
            throw SqlException(msg, __FILE__, __LINE__);
        }
    }
    return ret;
}
Пример #24
0
static int print_timesync_property(const char *name, sd_bus_message *m, bool value, bool all) {
        char type;
        const char *contents;
        int r;

        assert(name);
        assert(m);

        r = sd_bus_message_peek_type(m, &type, &contents);
        if (r < 0)
                return r;

        switch (type) {

        case SD_BUS_TYPE_STRUCT:
                if (streq(name, "NTPMessage")) {
                        _cleanup_(ntp_status_info_clear) NTPStatusInfo i = {};
                        char ts[FORMAT_TIMESPAN_MAX], stamp[FORMAT_TIMESTAMP_MAX];

                        r = map_ntp_message(NULL, NULL, m, NULL, &i);
                        if (r < 0)
                                return r;

                        if (i.packet_count == 0)
                                return 1;

                        if (!value) {
                                fputs(name, stdout);
                                fputc('=', stdout);
                        }

                        printf("{ Leap=%u, Version=%u, Mode=%u, Stratum=%u, Precision=%i,",
                               i.leap, i.version, i.mode, i.stratum, i.precision);
                        printf(" RootDelay=%s,",
                               format_timespan(ts, sizeof(ts), i.root_delay, 0));
                        printf(" RootDispersion=%s,",
                               format_timespan(ts, sizeof(ts), i.root_dispersion, 0));

                        if (i.stratum == 1)
                                printf(" Reference=%s,", i.reference.str);
                        else
                                printf(" Reference=%" PRIX32 ",", be32toh(i.reference.val));

                        printf(" OriginateTimestamp=%s,",
                               format_timestamp(stamp, sizeof(stamp), i.origin));
                        printf(" ReceiveTimestamp=%s,",
                               format_timestamp(stamp, sizeof(stamp), i.recv));
                        printf(" TransmitTimestamp=%s,",
                               format_timestamp(stamp, sizeof(stamp), i.trans));
                        printf(" DestinationTimestamp=%s,",
                               format_timestamp(stamp, sizeof(stamp), i.dest));
                        printf(" Ignored=%s PacketCount=%" PRIu64 ",",
                               yes_no(i.spike), i.packet_count);
                        printf(" Jitter=%s }\n",
                               format_timespan(ts, sizeof(ts), i.jitter, 0));

                        return 1;

                } else if (streq(name, "ServerAddress")) {
                        _cleanup_free_ char *str = NULL;

                        r = map_server_address(NULL, NULL, m, NULL, &str);
                        if (r < 0)
                                return r;

                        if (arg_all || !isempty(str))
                                property(name, "%s", str);

                        return 1;
                }
                break;
        }

        return 0;
}
Пример #25
0
void edit_side(int source,int smer)
  {
  TSTENA *p;
  CTL3D b1,b2,b3;
  char s[200];

  p=&mapa.sidedef[source][smer];
  memcpy(&b1,def_border(1,0),sizeof(CTL3D));
  memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D));
  memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D));
  default_font=vga_font;
  memcpy(f_default,flat_color(0x0000),sizeof(charcolors));
  sprintf(s,"Vlastnosti stˆn, sektor %d stˆna %d",source,smer);
  def_window(400,324,s);
  waktual->x=125;
  waktual->y=60;
  waktual->modal=1;
  define(CANCEL_BUTT,10,5,80,20,2,button,"Zru¨it");property(&b1,NULL,NULL,WINCOLOR);
    on_change(close_current);
  define(OK_BUTT,190,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR);
    on_change(edit_side_ok);
  define(3400,100,5,80,20,2,button,"P©edvolba");property(&b1,NULL,NULL,WINCOLOR);
    on_change(edit_side_predvolba_1);on_exit(edit_side_predvolba_2);
  define(10,5,20,300,35,0,label,"Prim rn¡:       Sekundarn¡:       Oblouk:");property(&b3,NULL,NULL,WINCOLOR);
  define(20,10,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->prim);
    on_enter(string_list_sup);
  define(30,110,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->sec);
    on_enter(string_list_sup);
  define(40,210,35,90,12,0,str_line,oblouky);property(&b2,NULL,NULL,WINCOLOR);c_default(p->oblouk & 0x0f);
    on_enter(string_list_sup);
  define(-1,5,60,250,12,0,label,"Animace primarn¡:");
  define(-1,5,75,250,12,0,label,"Animace sekundarn¡:");
  define(-1,5,90,250,12,0,label,"X pozice sek. stˆny:");
  define(-1,5,105,250,12,0,label,"Y pozice sek. stˆny:");
  define(-1,5,120,250,12,0,label,"C¡lov˜ sektor ud losti:");
  define(-1,5,135,250,12,0,label,"C¡lov  stˆna ud losti:");
  define(-1,5,150,250,12,0,label,"Popis akce:");
  define(-1,260,60,100,12,0,label,"Aplikuj na stˆnu:");
  define(50,200,60,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs((p->prim_anim & 0xf)+1));on_exit(test_int);
  define(60,200,75,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs((p->sec_anim & 0xf)+1));on_exit(test_int);
  define(70,200,90,50,10,0,input_line,10,0,499,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->xsec<<1));on_exit(test_int);
  define(80,200,105,50,10,0,input_line,10,0,511,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->ysec<<1));on_exit(test_int);
  define(90,200,120,50,10,0,input_line,10,0,65535,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->sector_tag));on_exit(test_int);
  define(100,200,135,50,10,0,str_line,steny2);property(&b2,NULL,NULL,WINCOLOR);
   c_default(p->side_tag & 0x3);on_enter(string_list_sup);
  define(110,100,150,150,10,0,str_line,actions);property(&b2,NULL,NULL,WINCOLOR);
   on_enter(string_list_sup); c_default(p->action);
  define(120,10,175,150,10,0,check_box,side_flgs[0]);
  define(130,10,187,150,10,0,check_box,side_flgs[1]);
  define(140,10,199,150,10,0,check_box,side_flgs[2]);
  define(150,10,211,150,10,0,check_box,side_flgs[3]);
  define(160,10,223,150,10,0,check_box,side_flgs[4]);
  define(170,10,235,150,10,0,check_box,side_flgs[5]);
  define(180,10,247,150,10,0,check_box,side_flgs[6]);
  define(190,10,259,150,10,0,check_box,side_flgs[7]);
  define(200,190,175,100,10,0,check_box,side_flgs[8]);
  define(210,190,187,100,10,0,check_box,side_flgs[9]);
  define(220,190,199,100,10,0,check_box,side_flgs[10]);
  define(230,190,211,150,10,0,check_box,side_flgs[11]);
  define(240,190,223,150,10,0,check_box,side_flgs[12]);
  define(250,190,235,150,10,0,check_box,side_flgs[13]);
  define(260,190,247,150,10,0,check_box,side_flgs[14]);
  define(270,190,259,150,10,0,check_box,side_flgs[15]);
  define(280,10,271,75,10,0,check_box,side_flgs[16]);
  define(290,10,283,75,10,0,check_box,side_flgs[17]);
  define(300,190,271,150,10,0,check_box,side_flgs[18]);
  define(310,10,295,75,11,0,check_box,side_flgs[19]);
  define(400,290,80,100,10,0,check_box,"Severn¡");
  define(410,290,95,100,10,0,check_box,"V˜chodn¡");
  define(420,290,110,100,10,0,check_box,"Ji‘n¡");
  define(430,290,125,100,10,0,check_box,"Z padn¡");
  define(340,290,150,100,15,0,button2,"V¡ce >>");on_change(action_flags);
  define(350,290,150,100,15,0,value_store,4);c_default(p->flags & 0xfff00000);
  define(360,290,150,100,15,0,value_store,4);c_default(source);
  define(370,290,150,100,15,0,value_store,4);c_default(smer);
  define(-1,5,20,60,10,1,label,"Lclip:");
  define(440,30,35,30,12,1,input_line,3,0,255,"%3d");
   property(&b2,NULL,NULL,WINCOLOR);
  set_default(strs(p->lclip));on_exit(test_int);
  define(450,10,220,30,30,1,radio_butts,3,"-","\x4","\x6");c_default((p->oblouk>>5) & 0x3);
   property(NULL,icones,NULL,WINCOLOR);
  define(460,10,175,80,12,1,button,"V˜klenek");on_change(edit_vyklenek_start);
  define(470,190,283,150,10,0,check_box,"Lze polo‘it za");c_default(p->oblouk>>7);
  define(480,10,307,75,10,0,check_box,"P©edsunout s.");c_default(p->side_tag>>7);
  fill_bit_fields(0,120,p->flags,20); if (source)
  fill_bit_fields(0,400,1<<smer,4); else fill_bit_fields(0,400,0xf,4);
  set_enable(0,3400,source!=0);
  set_enable(0,460,source!=0);
  redraw_window();
  }
Пример #26
0
/*!
 * \~english
 *	Sets property `DefFields', `DefHeaders', `ColWidth', `DefIdList' to
 *	values from metadata.
 * \~russian
 *	Устанавливает свойства `DefFields', `DefHeaders', `ColWidth', `DefIdList'
 *	в значения, определенные в метаданных. Старые значения не сохраняются.
 *	Для документа используется idTable.
 *	\~
 *	\param idTable (in) - 	\~english table id
 *				\~russian id таблицы документа.  Не используется для каталогов и журналов.
 *	\~
 */
void
wDBTable::setFields(int idTable)
{
CHECK_POINT
	int field_count,j;
	int i; //,tableCount;
	//QSqlCursor *cur;
	const Q3SqlFieldInfo *field;
	QString str;
	QStringList Cwidth, list_fields,list_id;
	aCfgItem o, o_table, o_field;
	QString mdtag=QString(md_field);

	list_fields.clear();
	o = tables; // object tables
	QString objClass = md->objClass(o);
	//printf("table parent obj class '%s'\n", (const char*)objClass);
	if(objClass==md_tables)
	{
		o_table = md->find(idTable);
	}
	else
	if(objClass==md_columns)
	{
		o_table = o;
		mdtag=QString(md_column);
	}
	else
	if(objClass==md_element)
	{
		o_table = o;
	}
	colWidth.clear();
	i=0;
	while(i<numCols())
	{
		removeColumn(0);
	}
	cur->clear();
	if(!o_table.isNull())
	{
		field_count = md->countChild(o_table,mdtag);
		//printf("table name '%s'\n",(const char*)md->attr(o_table,mda_name));
		//printf("table id '%s'\n",(const char*)md->attr(o_table,mda_id));
		for (j=0; j<field_count; j++)
		{
			o_field = md->findChild(o_table,mdtag,j);
			//printf("field %i name '%s'\n",j,(const char*)md->attr(o_field,mda_name));
			//printf("field %i id '%s'\n",j,(const char*)md->attr ( o_field, mda_id ));
			list_fields << md->attr(o_field,mda_name);
			list_id << md->attr(o_field,mda_id);
			str.setNum(j);
			field = new Q3SqlFieldInfo(md->attr(o_field,"name"));
			cur->append(*field);
			setSqlCursor(cur);
			addColumn(field->name(),field->name(),property("DefaultColWidth").toInt());
			refresh(RefreshColumns);
			Cwidth << property("DefaultColWidth").toString();
		}
	}
	setProperty("DefFields",list_fields);
	setProperty("DefHeaders",list_fields);
	setProperty("ColWidth",Cwidth);
	setProperty("DefIdList",list_id);
}
Пример #27
0
 virtual OptimizationAlgorithm* construct()
 {
   return createSolver(property().name);
 }
Пример #28
0
/*!
 *\~english
 *	Initialisation the widget on form loaded in engine.
 *\~russian
 *	Инициализация виджета при загрузке в форму инжина.
 *\~
 */
void
wDBTable::init(aDatabase *adb, aEngine *e )
{

	aLog::print(aLog::Debug, tr("wDBTable init in engine "));
//	printf("begin init wdbtable\n");
	unsigned int countField,i;
	aCfgItem o, own;
	QString str, ctype;
	QStringList lst,lstHead,lstWidth;
	int tid;
	aWidget *container = NULL;

	t_doc = rcIcon( "t_doc.png" );
        t_doc_d = rcIcon( "t_doc_d.png" );
        t_doc_t = rcIcon( "t_doc_t.png" );
        t_doc_m = rcIcon( "t_doc_m.png" );
        t_doc_tm = rcIcon( "t_doc_tm.png" );
	t_cat_e = rcIcon( "t_cat_e.png" );
        t_cat_ed = rcIcon( "t_cat_ed.png" );
	t_cat_g = rcIcon( "t_cat_g.png" );
	t_cat_gd = rcIcon( "t_cat_gd.png" );

	engine = e;
	setConfirmDelete(true);
	db = adb;
	md = &adb->cfg;
	tid = property("TableInd").toInt();
	container = aWidget::parentContainer( this );
	if ( !container )
	{
		aLog::print(aLog::Error, tr("wDBTable not in Ananas object container "));
		return; //printf("!no wDBTable parent container\n");
	}
	else
	{
		o = md->objTable( container->getId(), tid );
		if ( o.isNull() )
		{
			//debug_message("Table not found\n");
			aLog::print(aLog::Error, tr("wDBTable init meta object not found "));
		}
		ctype = container->className();
		aLog::print(aLog::Info, tr("wDBTable container type is %1 ").arg(ctype));

		setContainerType(ctype);
	}

	//o  = md->find(property("TableInd").toInt());
	if ( o.isNull() )
	{
		aLog::print(aLog::Error, tr("wDBTable init meta object not found "));
		return;
	}
	countField = numCols();
	for(i=0; i<countField;i++)
	{
		removeColumn(0);
	}
	aSQLTable *tbl = NULL;
	//printf("ctype = %s\n",( const char *) ctype );
	if ( containerType() == "wDocument" )
	{
		QString flt;
		flt = QString("idd=%1").arg(container->uid());
		aLog::print(aLog::Info, tr("wDBTable filter is %1 ").arg(flt));
		setFilter(flt);
		//TODO: fix memory leak
		tbl = new aSQLTable( o, adb );
//		printf("new table ok\n");
	//	tbl->first();

	}
	if ( containerType() == "wCatalogue" ) {
                tbl = container->table(); //new aSQLTable( o, adb );
		setFilter(QString("idg=0"));
		newDataId(0);
		tbl->append( Q3SqlFieldInfo("system_icon") );
//		tbl->setGenerated( "system_icon", false );
		tbl->setCalculated("system_icon", true );
          }
	if ( containerType() == "wJournal" ) {
		tbl = container->table(); //new aSQLTable( o, adb );
		tbl->setMode( 0 );
		tbl->append( Q3SqlFieldInfo( "system_icon" ) );
//		tbl->setGenerated( "system_icon", false );
		tbl->setCalculated( "system_icon", true );
//		tbl->append( QSqlFieldInfo( "t1" ) );
//		tbl->setGenerated( "t1", false );
//		tbl->setCalculated("t1", true );
        }
	refresh();
	cur->clear();
	setSqlCursor(tbl,true);
	refresh(RefreshColumns);
	countField = numCols();
	lst = property("DefIdList").toStringList();
	lstHead = property("DefHeaders").toStringList();
	lstWidth = property("ColWidth").toStringList();
	for ( i = 0; i < countField; i++ )
	{
		//remove all columns in wDBTable, not in sql cursor
		removeColumn( 0 );
		QString s = sqlCursor()->fieldName(i);
//		printf(">>>>s = %s\n",s.ascii());
//		if(sqlCursor()->isCalculated(s))
//		{
//			if((s.left(7)=="text_uf" && lst.findIndex(s.mid(7))!=-1) || s == "system_icon")
//			{
//				continue;
//			}
			// not calculate field, if is not contents in wDBTable
//			sqlCursor()->setCalculated(sqlCursor()->fieldName(i),false);
//		}
	}
	if ( containerType() == "wJournal" ) {
		addColumn( "system_icon", "", 20 );
		setColumnReadOnly( 0, true );
		if (md->objClass(*(container->getMDObject()))==md_journal && !((aDocJournal*) container->dataObject())->type() ) {
			// we have common journal
			// Insert journal system columns.
			addColumn( "ddate", tr("Date"), 100 );
			addColumn( "pnum", tr("Prefix"), 200 );
			addColumn( "num", tr("Number"), 100 );
		}
	}
	if ( containerType() == "wCatalogue" ) {
		addColumn( "system_icon", "", 20 );
	//	printf("set column ro\n");
		setColumnReadOnly( 0, true );
	}

	if ( containerType() == "wDocument" || containerType() == "wCatalogue" ) {

	// Задаем сортировку по индентификатору в обратном порядке для
	// табличной части документа
	// чтобы при добавлении новых позиций в список строки не скакали
	    QSqlIndex pk = sqlCursor()->primaryIndex();
	    pk.setDescending( 0, false);
	    setSort( pk );
	    sqlCursor()->select();
	    sqlCursor()->first();
	    refresh();
	}


	//refresh(RefreshColumns);
	if (md->objClass(*(container->getMDObject()))!=md_journal || ((aDocJournal*) container->dataObject())->type() ) {
		// we have not common journal
		for(i=0; i<lst.count();i++)
		{
			// assemble sql table field names
			if ( containerType() == "wJournal" )
			{
//				str = journalFieldName(lst[i].toLong());

				str = "uf"+QString::number(journalFieldId(lst[i].toLong()));
				//printf(">>>>>>ss=%s\n",str.ascii());
			}
			else
			{
				str = "uf"+lst[i];
			}
			// add defined fields
			addColumn(str,lstHead[i],lstWidth[i].toInt());
		}
	}
	refresh(RefreshAll);
	setWFieldEditor();
	aLog::print(aLog::Debug, tr("wDBTable init in engine ok"));
}
Пример #29
0
int proplist(char **str, struct prop **plist, int *node_req, int *gpu_req)
  {
  struct prop *pp;
  char         name_storage[80];
  char        *pname;
  char        *pequal;

  *node_req = 1; /* default to 1 processor per node */

  pname  = name_storage;
  *pname = '\0';

  for (;;)
    {
    if (property(str, &pname))
      {
      return(1);
      }

    if (*pname == '\0')
      break;

    if ((pequal = strchr(pname, (int)'=')) != NULL)
      {
      /* special property */

      /* identify the special property and place its value */
      /* into node_req       */

      *pequal = '\0';

      if (strcmp(pname, "ppn") == 0)
        {
        pequal++;

        if ((number(&pequal, node_req) != 0) || (*pequal != '\0'))
          {
          return(1);
          }
        }
      else if (strcmp(pname, "gpus") == 0)
        {
        pequal++;

        if ((number(&pequal, gpu_req) != 0) || (*pequal != '\0'))
          {
          return(1);
          }
        }
      else
        {
        return(1); /* not recognized - error */
        }
      }
    else
      {
      pp = (struct prop *)calloc(1, sizeof(struct prop));

      pp->mark = 1;
      pp->name = strdup(pname);
      pp->next = *plist;

      *plist = pp;
      }

    if (**str != ':')
      break;

    (*str)++;
    }  /* END for(;;) */

  return(PBSE_NONE);
  } /* END proplist() */
bool INDIDeviceControllerInstance::ExecuteGlobal()
{
   Console console;

   Exception::DisableGUIOutput();

   INDIClient* indi = INDIClient::TheClient();

   try
   {
      if ( p_serverConnect )
      {
         if ( indi == nullptr )
         {
            indi = INDIClient::NewClient( p_serverHostName.ToUTF8(), p_serverPort );
            if ( p_verbosity > 0 )
            {
               console.NoteLn( "<end><cbr>INDI Control Client --- (C) Klaus Kretzschmar, 2014-2016" );
               console.Flush();
            }
         }

         indi->SetVerbosity( p_verbosity );

         if ( !indi->IsServerConnected() )
         {
            indi->connectServer();
            if ( !indi->IsServerConnected() )
               throw Error( "INDIDeviceControllerInstance: Failure to connect to INDI server " + p_serverHostName + ", port=" + String( p_serverPort ) );

            if ( p_verbosity > 0 )
            {
               console.NoteLn( "* Successfully connected to INDI server " + p_serverHostName + ", port=" + String( p_serverPort ) );
               console.Flush();
            }
         }

         if ( !p_serverCommand.IsEmpty() )
         {
            console.EnableAbort();

            if ( p_serverCommand == "GET" )
            {
               o_getCommandResult.Clear();
               String device( PropertyUtils::Device( p_getCommandParameters ) );
               String property( PropertyUtils::Property( p_getCommandParameters ) );
               String element( PropertyUtils::Element( p_getCommandParameters ) );
               INDIPropertyListItem item;
               if ( !indi->GetPropertyItem( device, property, element, item ) )
                  throw Error( "INDIDeviceControllerInstance: Could not get value of property '" + String( p_getCommandParameters ) + "'" );
               o_getCommandResult = item.PropertyValue;
               if ( p_verbosity > 1 )
                  console.WriteLn( "<end><cbr>Device=" + device +
                                   ", Property=" + property +
                                   ", Element=" + element +
                                   ", Value=" + o_getCommandResult );
            }
            else if ( p_serverCommand == "SET" )
            {
               for ( auto newProperty : p_newProperties )
               {
                  GetNewPropertyListItemParametersFromKey( newProperty );
                  if ( !indi->SendNewPropertyItem( newProperty, false/*async*/ ) )
                     throw Error( "INDIDeviceControllerInstance: Failure to send new property values." );
               }
               p_newProperties.Clear();
            }
            else if ( p_serverCommand == "SET_ASYNC" )
            {
               for ( auto newProperty : p_newProperties )
               {
                  GetNewPropertyListItemParametersFromKey( newProperty );
                  if ( !indi->SendNewPropertyItem( newProperty, true/*async*/ ) )
                     throw Error( "INDIDeviceControllerInstance: Failure to send new property values (asynchronous)." );
               }
               p_newProperties.Clear();
            }
            else
               throw Error( "INDIDeviceControllerInstance: Unknown command '" + p_serverCommand + "'" );

            console.Flush();
         }

         AcquireINDIClientProperties();
      }
      else
      {
         if ( indi != nullptr )
         {
            if ( indi->IsServerConnected() )
            {
               AcquireINDIClientProperties();
               indi->SetVerbosity( p_verbosity );
               indi->disconnectServer();
               if ( p_verbosity > 0 )
                  console.NoteLn( "* Disconnected from INDI server " + p_serverHostName + ", port=" + String( p_serverPort ) );
            }

            INDIClient::DestroyClient();
         }
      }

      return true;
   }
   catch ( const Exception& x )
   {
      if ( p_verbosity > 0 )
         x.Show();
      return false;
   }
   catch ( ... )
   {
      throw;
   }
}