Example #1
0
void XUIObject::onLeftButtonDown(int x, int y) {
  m_trieddnd = false;
  eventSource_onLeftButtonDown(x, y);
  int _x = x;
  int _y = y;
  m_wnd->clientToScreen(&_x, &_y);
  m_draganchor_x = _x;
  m_draganchor_y = _y;
  if (getAttributeBool("dragwindow")) {
    m_draggingWindow = 1;
  }
  if (getAttributeBool("dndsource")) {
    beginCapture(CAPTURETYPE_DND);
    m_dndlbuttondown = true;
  }
  XUIObject *o = this;
  while (1) {
    o = o->getParent();
    if (!o) break;
    if (o->wantFocus()) 
      o->focus();
  }
}
Example #2
0
bool GwfObjectInfoReader::parseNode(const QDomElement &element)
{
    std::auto_ptr<SCgNodeInfo> nodeInfo(new SCgNodeInfo());

    if(!parseObject(element,nodeInfo.get()))
        return false;

    qreal& x = nodeInfo->posRef().rx();
    qreal& y = nodeInfo->posRef().ry();
    if (!getAttributeDouble(element, "x", x) || !getAttributeDouble(element, "y", y))
        return false;


    // get identifier position
    int& idtfPos = nodeInfo->idtfPosRef();
    if (!getAttributeInt(element, "idtf_pos", idtfPos))
        idtfPos = 0;

    // get content element
    QDomElement contEl = element.firstChildElement("content");
    if (contEl.isNull())
    {
        errorHaventContent(element.tagName());
        return false;
    }

    // get content type
    int& cType = nodeInfo->contentTypeRef();
    if (!getAttributeInt(contEl, "type", cType))
        return false;

    // get mime type
    if (!getAttributeString(contEl, "mime_type", nodeInfo->contentMimeTypeRef()))
        return false;

    // in old versions format, there wasn't content_visibility attribute, so we need to check if it exists
    if (contEl.hasAttribute("content_visibility") && !getAttributeBool(contEl, "content_visibility", nodeInfo->contentVisibleRef()))
        return false;

    // set content to nodeInfo
    if (cType > 0 && cType < 5)
    {
        if (cType == 1 || cType == 2 || cType == 3)
            nodeInfo->contentDataRef() = QVariant(contEl.firstChild().nodeValue());
        else if (cType == 4)
        {
            // get file name
            getAttributeString(contEl, "file_name", nodeInfo->contentFilenameRef());
            QString cData = contEl.firstChild().nodeValue();
            QByteArray arr = QByteArray::fromBase64(cData.toLocal8Bit());
            nodeInfo->contentDataRef() = QVariant(arr);
        }else
        {
            mLastError = QObject::tr("Content type '%1' doesn't supported for now").arg(cType);
            return false;
        }
    }else if (cType != 0)
    {
        mLastError = QObject::tr("Unknown content type '%1'").arg(cType);
        return false;
    }

    mObjectsInfo[SCgNode::Type].append(nodeInfo.release());
    return true;
}