Exemplo n.º 1
0
void AbstractContent::toXml(QDomElement & pe) const
{
    // Save general item properties
    pe.setTagName("abstract");
    QDomDocument doc = pe.ownerDocument();
    QDomElement domElement;
    QDomText text;
    QString valueStr;

    // Save item position and size
    QDomElement rectParent = doc.createElement("rect");
    QDomElement xElement = doc.createElement("x");
    rectParent.appendChild(xElement);
    QDomElement yElement = doc.createElement("y");
    rectParent.appendChild(yElement);
    QDomElement wElement = doc.createElement("w");
    rectParent.appendChild(wElement);
    QDomElement hElement = doc.createElement("h");
    rectParent.appendChild(hElement);

    QRectF rect = m_contentsRect;
    xElement.appendChild(doc.createTextNode(QString::number(rect.left())));
    yElement.appendChild(doc.createTextNode(QString::number(rect.top())));
    wElement.appendChild(doc.createTextNode(QString::number(rect.width())));
    hElement.appendChild(doc.createTextNode(QString::number(rect.height())));
    pe.appendChild(rectParent);

    // Save the position
    domElement= doc.createElement("pos");
    xElement = doc.createElement("x");
    yElement = doc.createElement("y");
    valueStr.setNum(pos().x());
    xElement.appendChild(doc.createTextNode(valueStr));
    valueStr.setNum(pos().y());
    yElement.appendChild(doc.createTextNode(valueStr));
    domElement.appendChild(xElement);
    domElement.appendChild(yElement);
    pe.appendChild(domElement);

    // Save the stacking position
    domElement= doc.createElement("zvalue");
    pe.appendChild(domElement);
    valueStr.setNum(zValue());
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    // Save the visible state
    domElement= doc.createElement("visible");
    pe.appendChild(domElement);
    valueStr.setNum(isVisible());
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    // Save the frame class
    valueStr.setNum(frameClass());
    domElement= doc.createElement("frame-class");
    pe.appendChild(domElement);
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    domElement= doc.createElement("frame-text-enabled");
    pe.appendChild(domElement);
    valueStr.setNum(frameTextEnabled());
    text = doc.createTextNode(valueStr);
    domElement.appendChild(text);

    if(frameTextEnabled()) {
        domElement= doc.createElement("frame-text");
        pe.appendChild(domElement);
        text = doc.createTextNode(frameText());
        domElement.appendChild(text);
    }

    // save transformation
    const QTransform t = transform();
    if (!t.isIdentity()) {
        domElement = doc.createElement("transformation");
        domElement.setAttribute("xRot", m_xRotationAngle);
        domElement.setAttribute("yRot", m_yRotationAngle);
        domElement.setAttribute("zRot", m_zRotationAngle);
        pe.appendChild(domElement);
    }
}
Exemplo n.º 2
0
void VCFrame_Test::loadXML()
{
    QWidget w;

    QDomDocument xmldoc;
    QDomElement root = xmldoc.createElement("Frame");
    xmldoc.appendChild(root);

    QDomElement wstate = xmldoc.createElement("WindowState");
    wstate.setAttribute("Width", "42");
    wstate.setAttribute("Height", "69");
    wstate.setAttribute("X", "3");
    wstate.setAttribute("Y", "4");
    wstate.setAttribute("Visible", "True");
    root.appendChild(wstate);

    QDomElement allowChildren = xmldoc.createElement("AllowChildren");
    QDomText allowChildrenText = xmldoc.createTextNode("False");
    allowChildren.appendChild(allowChildrenText);
    root.appendChild(allowChildren);

    QDomElement allowResize = xmldoc.createElement("AllowResize");
    QDomText allowResizeText = xmldoc.createTextNode("False");
    allowResize.appendChild(allowResizeText);
    root.appendChild(allowResize);

    QDomElement frame = xmldoc.createElement("Frame");
    root.appendChild(frame);

    QDomElement label = xmldoc.createElement("Label");
    root.appendChild(label);

    QDomElement button = xmldoc.createElement("Button");
    root.appendChild(button);

    QDomElement xypad = xmldoc.createElement("XYPad");
    root.appendChild(xypad);

    QDomElement slider = xmldoc.createElement("Slider");
    root.appendChild(slider);

    QDomElement soloframe = xmldoc.createElement("SoloFrame");
    root.appendChild(soloframe);

    QDomElement cuelist = xmldoc.createElement("CueList");
    root.appendChild(cuelist);

    QDomElement foobar = xmldoc.createElement("Foobar");
    root.appendChild(foobar);

    VCFrame parent(&w, m_doc);
    QVERIFY(parent.loadXML(&root) == true);
    parent.postLoad();
    QCOMPARE(parent.geometry().width(), 42);
    QCOMPARE(parent.geometry().height(), 69);
    QCOMPARE(parent.geometry().x(), 3);
    QCOMPARE(parent.geometry().y(), 4);
    QVERIFY(parent.allowChildren() == false);
    QVERIFY(parent.allowResize() == false);

    QSet <QString> childSet;
    QCOMPARE(parent.children().size(), 7);
    foreach (QObject* child, parent.children())
        childSet << child->metaObject()->className();
    QVERIFY(childSet.contains("VCFrame"));
    QVERIFY(childSet.contains("VCLabel"));
    QVERIFY(childSet.contains("VCButton"));
    QVERIFY(childSet.contains("VCXYPad"));
    QVERIFY(childSet.contains("VCSlider"));
    QVERIFY(childSet.contains("VCSoloFrame"));
    QVERIFY(childSet.contains("VCCueList"));

    root.setTagName("Farme");
    QVERIFY(parent.loadXML(&root) == false);
}
Exemplo n.º 3
0
// =============================== append element ===============
void CqDocument::appenElement( const QString& tag,const CqElement& element )
{
	QDomElement e = element.domElement();
	e.setTagName( tag );
	_document.appendChild( e );
}
Exemplo n.º 4
0
QDomDocument QgsWCSServer::getCapabilities()
{
  QgsDebugMsg( "Entering." );
  QDomDocument doc;

  //wcs:WCS_Capabilities element
  QDomElement wcsCapabilitiesElement = doc.createElement( "WCS_Capabilities"/*wcs:WCS_Capabilities*/ );
  wcsCapabilitiesElement.setAttribute( "xmlns", WCS_NAMESPACE );
  wcsCapabilitiesElement.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
  wcsCapabilitiesElement.setAttribute( "xsi:schemaLocation", WCS_NAMESPACE + " http://schemas.opengis.net/wcs/1.0.0/wcsCapabilities.xsd" );
  wcsCapabilitiesElement.setAttribute( "xmlns:gml", GML_NAMESPACE );
  wcsCapabilitiesElement.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
  wcsCapabilitiesElement.setAttribute( "version", "1.0.0" );
  wcsCapabilitiesElement.setAttribute( "updateSequence", "0" );
  doc.appendChild( wcsCapabilitiesElement );

  if ( mConfigParser )
  {
    mConfigParser->serviceCapabilities( wcsCapabilitiesElement, doc );
  }

  //INSERT Service

  //wcs:Capability element
  QDomElement capabilityElement = doc.createElement( "Capability"/*wcs:Capability*/ );
  wcsCapabilitiesElement.appendChild( capabilityElement );

  //wcs:Request element
  QDomElement requestElement = doc.createElement( "Request"/*wcs:Request*/ );
  capabilityElement.appendChild( requestElement );

  //wcs:GetCapabilities
  QDomElement getCapabilitiesElement = doc.createElement( "GetCapabilities"/*wcs:GetCapabilities*/ );
  requestElement.appendChild( getCapabilitiesElement );

  QDomElement dcpTypeElement = doc.createElement( "DCPType"/*wcs:DCPType*/ );
  getCapabilitiesElement.appendChild( dcpTypeElement );
  QDomElement httpElement = doc.createElement( "HTTP"/*wcs:HTTP*/ );
  dcpTypeElement.appendChild( httpElement );

  //Prepare url
  QString hrefString;
  if ( mConfigParser )
  {
    hrefString = mConfigParser->wcsServiceUrl();
    if ( hrefString.isEmpty() )
    {
      hrefString = mConfigParser->serviceUrl();
    }
  }
  if ( hrefString.isEmpty() )
  {
    hrefString = serviceUrl();
  }

  QDomElement getElement = doc.createElement( "Get"/*wcs:Get*/ );
  httpElement.appendChild( getElement );
  QDomElement onlineResourceElement = doc.createElement( "OnlineResource"/*wcs:OnlineResource*/ );
  onlineResourceElement.setAttribute( "xlink:type", "simple" );
  onlineResourceElement.setAttribute( "xlink:href", hrefString );
  getElement.appendChild( onlineResourceElement );

  QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
  getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( "Post" );
  getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );

  QDomElement describeCoverageElement = getCapabilitiesElement.cloneNode().toElement();//this is the same as 'GetCapabilities'
  describeCoverageElement.setTagName( "DescribeCoverage" );
  requestElement.appendChild( describeCoverageElement );

  QDomElement getCoverageElement = getCapabilitiesElement.cloneNode().toElement();//this is the same as 'GetCapabilities'
  getCoverageElement.setTagName( "GetCoverage" );
  requestElement.appendChild( getCoverageElement );

  /*
   * Adding layer list in ContentMetadata
   */
  QDomElement contentMetadataElement = doc.createElement( "ContentMetadata"/*wcs:ContentMetadata*/ );
  wcsCapabilitiesElement.appendChild( contentMetadataElement );
  /*
   * Adding layer list in contentMetadataElement
   */
  if ( mConfigParser )
  {
    mConfigParser->wcsContentMetadata( contentMetadataElement, doc );
  }

  return doc;
}
Exemplo n.º 5
0
  QDomDocument createGetCapabilitiesDocument( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
      const QgsServerRequest &request )
  {
    Q_UNUSED( version );

    QDomDocument doc;

    //wcs:WCS_Capabilities element
    QDomElement wcsCapabilitiesElement = doc.createElement( QStringLiteral( "WCS_Capabilities" )/*wcs:WCS_Capabilities*/ );
    wcsCapabilitiesElement.setAttribute( QStringLiteral( "xmlns" ), WCS_NAMESPACE );
    wcsCapabilitiesElement.setAttribute( QStringLiteral( "xmlns:xsi" ), QStringLiteral( "http://www.w3.org/2001/XMLSchema-instance" ) );
    wcsCapabilitiesElement.setAttribute( QStringLiteral( "xsi:schemaLocation" ), WCS_NAMESPACE + " http://schemas.opengis.net/wcs/1.0.0/wcsCapabilities.xsd" );
    wcsCapabilitiesElement.setAttribute( QStringLiteral( "xmlns:gml" ), GML_NAMESPACE );
    wcsCapabilitiesElement.setAttribute( QStringLiteral( "xmlns:xlink" ), QStringLiteral( "http://www.w3.org/1999/xlink" ) );
    wcsCapabilitiesElement.setAttribute( QStringLiteral( "version" ), implementationVersion() );
    wcsCapabilitiesElement.setAttribute( QStringLiteral( "updateSequence" ), QStringLiteral( "0" ) );
    doc.appendChild( wcsCapabilitiesElement );

    //INSERT Service
    wcsCapabilitiesElement.appendChild( getServiceElement( doc, project ) );

    //wcs:Capability element
    QDomElement capabilityElement = doc.createElement( QStringLiteral( "Capability" )/*wcs:Capability*/ );
    wcsCapabilitiesElement.appendChild( capabilityElement );

    //wcs:Request element
    QDomElement requestElement = doc.createElement( QStringLiteral( "Request" )/*wcs:Request*/ );
    capabilityElement.appendChild( requestElement );

    //wcs:GetCapabilities
    QDomElement getCapabilitiesElement = doc.createElement( QStringLiteral( "GetCapabilities" )/*wcs:GetCapabilities*/ );
    requestElement.appendChild( getCapabilitiesElement );

    QDomElement dcpTypeElement = doc.createElement( QStringLiteral( "DCPType" )/*wcs:DCPType*/ );
    getCapabilitiesElement.appendChild( dcpTypeElement );
    QDomElement httpElement = doc.createElement( QStringLiteral( "HTTP" )/*wcs:HTTP*/ );
    dcpTypeElement.appendChild( httpElement );

    //Prepare url
    QString hrefString = serviceUrl( request, project );

    QDomElement getElement = doc.createElement( QStringLiteral( "Get" )/*wcs:Get*/ );
    httpElement.appendChild( getElement );
    QDomElement onlineResourceElement = doc.createElement( QStringLiteral( "OnlineResource" )/*wcs:OnlineResource*/ );
    onlineResourceElement.setAttribute( QStringLiteral( "xlink:type" ), QStringLiteral( "simple" ) );
    onlineResourceElement.setAttribute( QStringLiteral( "xlink:href" ), hrefString );
    getElement.appendChild( onlineResourceElement );

    QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
    getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( QStringLiteral( "Post" ) );
    getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );

    QDomElement describeCoverageElement = getCapabilitiesElement.cloneNode().toElement();//this is the same as 'GetCapabilities'
    describeCoverageElement.setTagName( QStringLiteral( "DescribeCoverage" ) );
    requestElement.appendChild( describeCoverageElement );

    QDomElement getCoverageElement = getCapabilitiesElement.cloneNode().toElement();//this is the same as 'GetCapabilities'
    getCoverageElement.setTagName( QStringLiteral( "GetCoverage" ) );
    requestElement.appendChild( getCoverageElement );

    //INSERT ContentMetadata
    wcsCapabilitiesElement.appendChild( getContentMetadataElement( doc, serverIface, project ) );

    return doc;

  }
Exemplo n.º 6
0
bool DomConvenience::variantToElement(const QVariant& v, QDomElement& e)
{
  bool ok = true;

  clearAttributes(e);

  switch (v.type())
  {
  case QVariant::String:
    e.setTagName("string");
    e.setAttribute("value", v.toString().utf8());
    break;
  case QVariant::CString:
    e.setTagName("string");
    e.setAttribute("value", v.toCString());
    break;
  case QVariant::Int:
    e.setTagName("int");
    e.setAttribute("value", v.toInt());
    break;
  case QVariant::UInt:
    e.setTagName("uint");
    e.setAttribute("value", v.toUInt());
    break;
  case QVariant::Double:
    e.setTagName("double");
    e.setAttribute("value", v.toDouble());
    break;
  case QVariant::Bool:
    e.setTagName("bool");
    e.setAttribute("value", boolString(v.toBool()));
    break;
  case QVariant::Color:
    {
      e.setTagName("color");
      QColor color = v.toColor();
      e.setAttribute("red", color.red());
      e.setAttribute("green", color.green());
      e.setAttribute("blue", color.blue());
    }
    break;
  case QVariant::Point:
    {
      e.setTagName("point");
      QPoint point = v.toPoint();
      e.setAttribute("x", point.x());
      e.setAttribute("y", point.y());
    }
    break;
  case QVariant::Rect:
    {
      e.setTagName("rect");
      QRect rect = v.toRect();
      e.setAttribute("x", rect.x());
      e.setAttribute("y", rect.y());
      e.setAttribute("width", rect.width());
      e.setAttribute("height", rect.height());
    }
    break;
  case QVariant::Size:
    {
      e.setTagName("size");
      QSize qsize = v.toSize();
      e.setAttribute("width", qsize.width());
      e.setAttribute("height", qsize.height());
    }
    break;
  case QVariant::Font:
    {
      e.setTagName("font");
      QFont f(v.toFont());
      e.setAttribute("family", f.family());
      e.setAttribute("pointsize", f.pointSize());
      e.setAttribute("bold", boolString(f.bold()));
      e.setAttribute("italic", boolString(f.italic()));
      e.setAttribute("underline", boolString(f.underline()));
      e.setAttribute("strikeout", boolString(f.strikeOut()));
    }
    break;
  case QVariant::SizePolicy:
    {
      e.setTagName("sizepolicy");
      QSizePolicy sp(v.toSizePolicy());
      e.setAttribute("hsizetype", sp.horData());
      e.setAttribute("vsizetype", sp.verData());
#if (QT_VERSION >= 300)
      e.setAttribute("horstretch", sp.horStretch());
      e.setAttribute("verstretch", sp.verStretch());
#endif
    }
    break;
  case QVariant::Cursor:
    e.setTagName("cursor");
    e.setAttribute("shape", v.toCursor().shape());
    break;

  case QVariant::StringList:
    {
      e.setTagName("stringlist");
      uint j;
      
      QDomNode n;
      QDomNodeList stringNodeList = e.elementsByTagName("string");
      QDomElement stringElem;
      QStringList stringList = v.toStringList();
      QStringList::Iterator it = stringList.begin();

      for (j = 0; 
	   ((j < stringNodeList.length()) && (it != stringList.end()));
	   j++)
      {
	// get the current string element
	stringElem = stringNodeList.item(j).toElement();

	// set it to the current string
	variantToElement(QVariant(*it), stringElem);

	// iterate to the next string
	++it;
      }
      
      // more nodes in previous stringlist then current, remove excess nodes
      if (stringNodeList.count() > stringList.count())
      {
	while (j < stringNodeList.count())
	  e.removeChild(stringNodeList.item(j).toElement());
      }
      else if (j <stringList.count())
      {
	while (it != stringList.end())
	{
	  // create a new element
	  stringElem = m_doc.createElement("string");
	
	  // set it to the currentstring
	  variantToElement(QVariant(*it), stringElem);

	  // append it to the current element
	  e.appendChild(stringElem);

	  // iterate to the next string
	  ++it;
	}
      }
    }
    break;

#if QT_VERSION >= 300
  case QVariant::KeySequence:
    e.setTagName("key");
    e.setAttribute("sequence", (QString)v.toKeySequence());
    break;
#endif

#if 0
  case QVariant::List:
  case QVaraint::Map:
#endif
  default:
    qWarning("Don't know how to persist variant of type: %s (%d)!",
	     v.typeName(), v.type());
    ok = false;
    break;
  }

  return ok;
}
Exemplo n.º 7
0
void VCButton_Test::load()
{
    QWidget w;

    Scene* sc = new Scene(m_doc);
    m_doc->addFunction(sc);
    m_doc->setWorkspacePath(QDir("../../../gfx").absolutePath());

    QDomDocument xmldoc;
    QDomElement root = xmldoc.createElement("Button");
    root.setAttribute("Caption", "Pertti");
    root.setAttribute("Icon", "qlcplus.png");
    xmldoc.appendChild(root);

    QDomElement wstate = xmldoc.createElement("WindowState");
    wstate.setAttribute("X", "20");
    wstate.setAttribute("Y", "20");
    wstate.setAttribute("Width", "60");
    wstate.setAttribute("Height", "60");
    wstate.setAttribute("Visible", "True");
    root.appendChild(wstate);

    QDomElement appearance = xmldoc.createElement("Appearance");
    root.appendChild(appearance);

    QDomElement function = xmldoc.createElement("Function");
    function.setAttribute("ID", QString::number(sc->id()));
    root.appendChild(function);

    QDomElement input = xmldoc.createElement("Input");
    root.appendChild(input);

    QDomElement action = xmldoc.createElement("Action");
    QDomText actionText = xmldoc.createTextNode("Flash");
    action.appendChild(actionText);
    root.appendChild(action);

    QDomElement key = xmldoc.createElement("Key");
    QDomText keyText = xmldoc.createTextNode(QKeySequence(keySequenceA).toString());
    key.appendChild(keyText);
    root.appendChild(key);

    QDomElement intensity = xmldoc.createElement("Intensity");
    intensity.setAttribute("Adjust", "True");
    QDomText intensityText = xmldoc.createTextNode("60");
    intensity.appendChild(intensityText);
    root.appendChild(intensity);

    QDomElement foo = xmldoc.createElement("Foo");
    root.appendChild(foo);

    VCButton btn(&w, m_doc);
    QCOMPARE(btn.loadXML(&root), true);
    QCOMPARE(btn.caption(), QString("Pertti"));
    QCOMPARE(btn.iconPath(), QFileInfo(QString("../../../gfx/qlcplus.png")).canonicalFilePath());
    QCOMPARE(btn.function(), sc->id());
    QCOMPARE(btn.action(), VCButton::Flash);
    QCOMPARE(btn.keySequence(), QKeySequence(keySequenceA));
    QCOMPARE(btn.adjustIntensity(), true);
    QCOMPARE(btn.intensityAdjustment(), qreal(0.6));
    QCOMPARE(btn.pos(), QPoint(20, 20));
    QCOMPARE(btn.size(), QSize(60, 60));

    intensity.setAttribute("Adjust", "False");
    QCOMPARE(btn.loadXML(&root), true);
    QCOMPARE(btn.caption(), QString("Pertti"));
    QCOMPARE(btn.iconPath(), QFileInfo(QString("../../../gfx/qlcplus.png")).canonicalFilePath());
    QCOMPARE(btn.function(), sc->id());
    QCOMPARE(btn.action(), VCButton::Flash);
    QCOMPARE(btn.keySequence(), QKeySequence(keySequenceA));
    QCOMPARE(btn.adjustIntensity(), false);
    QCOMPARE(btn.intensityAdjustment(), qreal(0.6));
    QCOMPARE(btn.pos(), QPoint(20, 20));
    QCOMPARE(btn.size(), QSize(60, 60));

    root.setTagName("Buton");
    QCOMPARE(btn.loadXML(&root), false);
}
Exemplo n.º 8
0
tristate ReportDesignView::afterSwitchFrom ( ::ViewMode mode ) {
    kDebug(planDbg()) << tempData()->document;
    if ( tempData()->document.isEmpty() ) {
        _rd = new ReportDesigner ( this );
    } else {
        if ( _rd ) {
            scr->takeWidget();
            delete _rd;
            _rd = 0;
        }

        QDomDocument doc;
        doc.setContent ( tempData()->document );
        QDomElement root = doc.documentElement();
        QDomElement korep = root.firstChildElement( "koreport" );
        QDomElement conn = root.firstChildElement( "connection" );
        if ( !korep.isNull() ) {
            _rd = new ReportDesigner ( this, korep );
            if (!conn.isNull()) {
                srcsel->setConnectionData(conn);
            }
        } else {
            kDebug(planDbg()) << "no koreport section";

            //TODO remove...just create a blank document
            //Temp - allow load old style report definitions (no data)
            root.setTagName("koreport");
            _rd = new ReportDesigner ( this, root );
        }
    }

    scr->setWidget ( _rd );

    //plugSharedAction ( "edit_copy", _rd, SLOT(slotEditCopy()) );
    //plugSharedAction ( "edit_cut", _rd, SLOT(slotEditCut()) );
    //plugSharedAction ( "edit_paste", _rd, SLOT(slotEditPaste()) );
    //plugSharedAction ( "edit_delete", _rd, SLOT(slotEditDelete()) );

    connect ( _rd, SIGNAL(propertySetChanged()), this, SLOT(slotDesignerPropertySetChanged()) );
    connect ( _rd, SIGNAL(dirty()), this, SLOT(setDirty()) );

    //Edit Actions
    connect ( editCutAction, SIGNAL(activated()), _rd, SLOT(slotEditCut()) );
    connect ( editCopyAction, SIGNAL(activated()), _rd, SLOT(slotEditCopy()) );
    connect ( editPasteAction, SIGNAL(activated()), _rd, SLOT(slotEditPaste()) );
    connect ( editDeleteAction, SIGNAL(activated()), _rd, SLOT(slotEditDelete()) );

    connect ( sectionEdit, SIGNAL(activated()), _rd, SLOT(slotSectionEditor()) );

    //Control Actions
    connect ( res->itemLabel, SIGNAL(clicked()), this, SLOT(slotLabel()) );
    connect ( res->itemField, SIGNAL(clicked()), this, SLOT(slotField()) );
    connect ( res->itemText, SIGNAL(clicked()), this, SLOT(slotText()) );
    connect ( res->itemLine, SIGNAL(clicked()), this, SLOT(slotLine()) );
    connect ( res->itemBarcode, SIGNAL(clicked()), this, SLOT(slotBarcode()) );
    connect ( res->itemChart, SIGNAL(clicked()),this, SLOT(slotChart()) );
    connect ( res->itemImage, SIGNAL(clicked()), this, SLOT(slotImage()) );
    connect ( res->itemShape, SIGNAL(clicked()), this, SLOT(slotShape()) );
    connect ( res->itemCheck, SIGNAL(clicked()), this, SLOT(slotCheck()) );

    //Raise/Lower
    connect ( itemRaiseAction, SIGNAL(activated()), _rd, SLOT(slotRaiseSelected()) );
    connect ( itemLowerAction, SIGNAL(activated()), _rd, SLOT(slotLowerSelected()) );
    return true;
}
Exemplo n.º 9
0
void Dxs::slotResult(QDomNode node, int jobid)
{
    //kDebug() << "LOCALNAME: " << m_soap->localname(node);

    bool success = true;
    if (m_soap->localname(node) == "Fault") {
        success = false;
        emit signalFault();
        return;
    }

    if (m_soap->localname(node) == "GHNSInfoResponse") {
        QString provider = m_soap->xpath(node, "/provider");
        QString server = m_soap->xpath(node, "/server");
        QString version = m_soap->xpath(node, "/version");

        emit signalInfo(provider, server, version);
    } else if (m_soap->localname(node) == "GHNSCategoriesResponse") {
        QList<KNS::Category*> categories;

        QList<QDomNode> catlist = m_soap->directChildNodes(node, "category");
        for (int i = 0; i < catlist.count(); i++) {
            KNS::Category *category = new KNS::Category();

            QDomNode node = catlist.at(i).toElement();
            QString categoryname = m_soap->xpath(node, "/category");
            QString icon = m_soap->xpath(node, "/icon");
            QString name = m_soap->xpath(node, "/name");
            QString description = m_soap->xpath(node, "/description");

            category->setId(categoryname);
            category->setName(name);
            category->setIcon(icon);
            category->setDescription(description);

            categories << category;
        }

        emit signalCategories(categories);
    } else if (m_soap->localname(node) == "GHNSListResponse") {
        QList<KNS::Entry*> entries;

        Feed * thisFeed = m_jobfeeds.value(jobid);
        QDomNode entriesNode = node.firstChild();
        // FIXME: find a way to put a real assertion in here to ensure the entriesNode is the "entries" node
        //Q_ASSERT(entriesNode.localName() == "entries");

        QList<QDomNode> entrylist = m_soap->directChildNodes(entriesNode, "entry");
        for (int i = 0; i < entrylist.count(); i++) {
            QDomElement element = entrylist.at(i).toElement();
            element.setTagName("stuff");
            KNS::EntryHandler handler(element);
            KNS::Entry *entry = handler.entryptr();

            entries << entry;
            thisFeed->addEntry(entry);
            //kDebug() << "ENTRY: " << entry->name().representation() << " location: " << entry->payload().representation();
        }

        emit signalEntries(entries, thisFeed);
    } else if (m_soap->localname(node) == "GHNSCommentsResponse") {
        QStringList comments;

        QList<QDomNode> comlist = m_soap->directChildNodes(node, "comments");
        for (int i = 0; i < comlist.count(); i++) {
            comments << comlist.at(i).toElement().text();
        }

        emit signalComments(comments);
    } else if (m_soap->localname(node) == "GHNSChangesResponse") {
        QStringList changes;

        QList<QDomNode> changelist = m_soap->directChildNodes(node, "entry");
        for (int i = 0; i < changelist.count(); i++) {
            QDomNode node = changelist.at(i);

            QString version = m_soap->xpath(node, "/version");
            QString changelog = m_soap->xpath(node, "/changelog");
            //kDebug() << "CHANGELOG: " << version << " " << changelog;

            changes << changelog;
        }

        // FIXME: pass (version, changelog) pairs - Python I miss you :-)
        emit signalChanges(changes);
    } else if (m_soap->localname(node) == "GHNSHistoryResponse") {
        QStringList entries;

        QList<QDomNode> entrylist = m_soap->directChildNodes(node, "entry");
        for (int i = 0; i < entrylist.count(); i++) {
            entries << entrylist.at(i).toElement().text();
        }

        emit signalHistory(entries);
    } else if (m_soap->localname(node) == "GHNSRemovalResponse") {
        emit signalRemoval(success);
    } else if (m_soap->localname(node) == "GHNSSubscriptionResponse") {
        emit signalSubscription(success);
    } else if (m_soap->localname(node) == "GHNSCommentResponse") {
        emit signalComment(success);
    } else if (m_soap->localname(node) == "GHNSRatingResponse") {
        emit signalRating(success);
    }
}
Exemplo n.º 10
0
/* Take the ENML note and transform it into HTML that WebKit will
  not complain about */
QByteArray NoteFormatter::rebuildNoteHTML() {

    QLOG_DEBUG() << "Rebuilding Note: " << QString::fromStdString(note.guid) << " : " <<
                    QString::fromStdString(note.title);

    formatError = false;
    readOnly = false;

    // First try to read the document.  If it fails we need to clean it up
    content.append(QString::fromStdString(note.content));
    QDomDocument doc;
    QString emsg;
    bool goodReturn = doc.setContent(content, &emsg);

    if (!goodReturn) {
        QLOG_DEBUG() << "Error with initial document: " << emsg << " running through tidy";
        // Run it through "tidy".  It is a program which will fix any invalid XML
        // and give us the results back through stdout.  In a perfect world this
        // wouldn't be needed, but I've seen times where the ENML is bad for some reason.
        QProcess tidyProcess;
        tidyProcess.start("tidy -xml -raw -q -e", QIODevice::ReadWrite|QIODevice::Unbuffered);
        QLOG_DEBUG() << "Starting tidy " << tidyProcess.waitForStarted();
        QByteArray b;
        b.append(QString::fromStdString(note.content));
        tidyProcess.write(b);
        tidyProcess.closeWriteChannel();
        QLOG_DEBUG() << "Stopping tidy " << tidyProcess.waitForFinished() << " Return Code: " << tidyProcess.state();
        QLOG_DEBUG() << "Tidy Errors:" << tidyProcess.readAllStandardError();
        content = tidyProcess.readAllStandardOutput();

        // If the content is null, then we had a problem.  Just risk going forward without tidy cleanup
        if (content.size() == 0)
            content = b;
        doc.setContent(content);
    }
    QLOG_DEBUG() << doc.toString();
    // Remove all the temporary file names
    tempFiles.clear();
    modifyTags(doc);

    // If we have search criteria, then do the highlighting
    if (enableHighlight)
        doc = addHighlight(doc);

    // Finish up and return the HTML to the user
    QDomElement docElem = doc.documentElement();
    docElem.setTagName("body");
    content = doc.toByteArray(3);
        qint32 index = content.indexOf("<body");
    content.remove(0,index);
    content.prepend("<style type=\"text/css\">.en-crypt-temp { border-collapse:collapse; border-style:solid; border-color:blue; padding:0.0mm 0.0mm 0.0mm 0.0mm; }</style>");
    content.prepend("<style type=\"text/css\">en-hilight { background-color: rgb(255,255,0) }</style>");
    content.prepend("<style> img { height:auto; width:auto; max-height:auto; max-width:100%; }</style>");
    content.prepend("<head><meta http-equiv=\"content-type\" content=\"text-html; charset=utf-8\"></head>");
    content.prepend("<html>");
    content.append("</html>");

    if (!formatError && !readOnly) {
        NotebookTable ntable;
        qint32 notebookLid = ntable.getLid(note.notebookGuid);
        if (ntable.isReadOnly(notebookLid))
            readOnly = true;
    }
    if (note.__isset.active && !note.active)
        readOnly = true;
    return content;
}
Exemplo n.º 11
0
// Modify the en-media tag into an attachment
void NoteFormatter::modifyApplicationTags(QDomDocument &doc, QDomElement &docElem, QDomElement &enmedia, QDomAttr &hash, QString appl) {
    QLOG_TRACE() <<  "Entering NeverNote.modifyApplicationTags";
    if (appl.toLower() == "vnd.evernote.ink") {
            inkNote = true;
            readOnly = true;
            buildInkNote(enmedia, hash);
            QLOG_DEBUG() << doc.toString();
            return;
    }
    ResourceTable resTable;
    QString contextFileName;
    qint32 resLid = resTable.getLidByHashHex(QString::fromStdString(note.guid), hash.value());
    Resource r;
    resTable.get(r, resLid);
    if (!r.__isset.data)
        resourceError = true;
    else {
        if (r.mime == "application/pdf" && pdfPreview) {
            modifyPdfTags(resLid, enmedia);
            return;
        }
        QString fileDetails = "";
        MimeReference ref;
        if (r.__isset.attributes && r.attributes.__isset.fileName)
            fileDetails = QString::fromStdString(r.attributes.fileName);
        fileDetails = ref.getExtensionFromMime(QString::fromStdString(r.mime), fileDetails);


        if (fileDetails != "") {
            if (!noteHistory) {
                enmedia.setAttribute("href", QString("nnres:") +QString::number(resLid)
                                     +global.attachmentNameDelimeter +fileDetails);
                contextFileName = global.fileManager.getTmpDirPath(QString::number(resLid) +global.attachmentNameDelimeter + fileDetails);
            } else {
                enmedia.setAttribute("href", QString("nnres:") +QString::number(resLid) +QString("-")+ QString::number(note.updateSequenceNum)
                                     +global.attachmentNameDelimeter +fileDetails);
                contextFileName = global.fileManager.getTmpDirPath(QString::number(resLid) +QString("-")+ QString(note.updateSequenceNum)
                                                                   +global.attachmentNameDelimeter + fileDetails);
            }
        } else {
            if (!noteHistory) {
                enmedia.setAttribute("href", "nnres:" +QString::number(resLid) +QString("-") +QString(note.updateSequenceNum)
                                     +global.attachmentNameDelimeter +appl);
                contextFileName = global.fileManager.getTmpDirPath(QString::number(resLid) +QString("-")
                                                                   +QString(note.updateSequenceNum)
                                                                   +global.attachmentNameDelimeter + appl);
            } else {
                enmedia.setAttribute("href", "nnres:" +QString::number(resLid)
                                     +global.attachmentNameDelimeter +appl);
                contextFileName = global.fileManager.getTmpDirPath(QString::number(resLid)
                                                                   +global.attachmentNameDelimeter + appl);
            }
        }

        // Setup the context menu.  This is useful if we want to do a "save as" or such
        contextFileName = contextFileName.replace("\\", "/");
        enmedia.setAttribute("onContextMenu", "window.browserWindow.resourceContextMenu('" +contextFileName +"');");
        enmedia.setAttribute("en-tag", "en-media");
        enmedia.setAttribute("lid", QString::number(resLid));
        enmedia.setTagName("a");

        QDomElement newText = doc.createElement("img");
        QFile tfile(contextFileName);
        tfile.open(QIODevice::WriteOnly);
        tfile.close();

        // Build an icon of the image
        QString fileExt;
        if (r.__isset.attributes && r.attributes.__isset.fileName)
            fileExt = QString::fromStdString(r.attributes.fileName);
        else
            fileExt = appl;
        fileExt = ref.getExtensionFromMime(r.mime, r.attributes.fileName);
        QString icon = findIcon(resLid, r, fileExt);
        newText.setAttribute("src", "file:///"+icon);
        if (r.__isset.attributes && r.attributes.__isset.fileName)
            newText.setAttribute("title",QString::fromStdString(r.attributes.fileName));
        newText.setAttribute("en-tag", "temporary");
        enmedia.removeChild(enmedia.firstChild());
        enmedia.appendChild(newText);
        QLOG_TRACE() << "Leaving NeverNote.modifyApplicationTags";
    }
}