コード例 #1
0
void MetabarFunctions::toggle(DOM::DOMString item)
{
    DOM::HTMLDocument doc = m_html->htmlDocument();
    DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item));

    if(!node.isNull()) {
        DOM::NodeList children = node.childNodes();
        DOM::CSSStyleDeclaration style = node.style();
        DOM::DOMString expanded = node.getAttribute("expanded");

        bool isExpanded = expanded == "true";

        int height = 0;
        if(!isExpanded) {
            height = getHeight(node);
        }

        DOM::DOMString att = isExpanded ? "false" : "true";
        node.setAttribute("expanded", att);

        KConfig config("metabarrc");
        config.setGroup("General");

        if(config.readBoolEntry("AnimateResize", false)) {
            resizeMap[item.string()] = height;

            if(!timer->isActive()) {
                timer->start(RESIZE_SPEED);
            }
        }
        else {
            style.setProperty("height", QString("%1px").arg(height), CSS_PRIORITY);
        }
    }
}
コード例 #2
0
int MetabarFunctions::getHeight(DOM::HTMLElement &element)
{
    int height = 0;
    DOM::NodeList children = element.childNodes();
    for(uint i = 0; i < children.length(); i++) {
        DOM::HTMLElement node = static_cast<DOM::HTMLElement>(children.item(i));
        DOM::CSSStyleDeclaration style = node.style();

        DOM::DOMString css_height = style.getPropertyValue("height");
        if(!css_height.isNull()) {
            height += css_height.string().left(css_height.string().length() - 2).toInt();
        }
        else {
            int h = 0;
            if(!node.isNull()) {
                h = node.getRect().height();
            }

            DOM::DOMString display = style.getPropertyValue("display");
            if(display == "none") {
                h = 0;
            }
            else if(h == 0) {
                h = 20;
            }

            height += h;
        }
    }

    return height;
}
コード例 #3
0
void MetabarFunctions::hide(DOM::DOMString item)
{
    DOM::HTMLDocument doc = m_html->htmlDocument();
    DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item));
    if(!node.isNull()) {
        DOM::HTMLElement parent = static_cast<DOM::HTMLElement>(node.parentNode());

        DOM::CSSStyleDeclaration style = parent.style();
        style.setProperty("display", "none", CSS_PRIORITY);
    }
}
コード例 #4
0
KJSO KJS::getDOMCSSStyleDeclaration(DOM::CSSStyleDeclaration s)
{
  DOMCSSStyleDeclaration *ret;
  if (s.isNull())
    return Null();
  else if ((ret = domCSSStyleDeclarations[s.handle()]))
    return ret;
  else {
    ret = new DOMCSSStyleDeclaration(s);
    domCSSStyleDeclarations.insert(s.handle(),ret);
    return ret;
  }
}
コード例 #5
0
Value DOMCSSStyleDeclarationProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
{
    KJS_CHECK_THIS(KJS::DOMCSSStyleDeclaration, thisObj);
    DOM::CSSStyleDeclaration styleDecl = static_cast< DOMCSSStyleDeclaration * >(thisObj.imp())->toStyleDecl();
    String str = args[0].toString(exec);
    DOM::DOMString s = str.value().string();

    switch(id)
    {
        case DOMCSSStyleDeclaration::GetPropertyValue:
            return String(styleDecl.getPropertyValue(s));
        case DOMCSSStyleDeclaration::GetPropertyCSSValue:
            return getDOMCSSValue(exec, styleDecl.getPropertyCSSValue(s));
        case DOMCSSStyleDeclaration::RemoveProperty:
            return String(styleDecl.removeProperty(s));
        case DOMCSSStyleDeclaration::GetPropertyPriority:
            return String(styleDecl.getPropertyPriority(s));
        case DOMCSSStyleDeclaration::SetProperty:
            styleDecl.setProperty(args[0].toString(exec).string(), args[1].toString(exec).string(), args[2].toString(exec).string());
            return Undefined();
        case DOMCSSStyleDeclaration::Item:
            return String(styleDecl.item(args[0].toInteger(exec)));
        default:
            return Undefined();
    }
}
コード例 #6
0
void MetabarFunctions::animate()
{
    QMap<QString, int>::Iterator it;
    for(it = resizeMap.begin(); it != resizeMap.end(); ++it ) {
        QString id = it.key();
        int height = it.data();
        int currentHeight = 0;

        DOM::HTMLDocument doc = m_html->htmlDocument();
        DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(id));
        DOM::CSSStyleDeclaration style = node.style();

        QString currentHeightString = style.getPropertyValue("height").string();
        if(currentHeightString.endsWith("px")) {
            currentHeight = currentHeightString.left(currentHeightString.length() - 2).toInt();
        }

        if(currentHeight == height) {
            resizeMap.remove(id);

            if(resizeMap.isEmpty()) {
                timer->stop();
            }
        }
        else {
            int diff = kAbs(currentHeight - height);
            int changeValue = RESIZE_STEP;

            if(diff < RESIZE_STEP) {
                changeValue = diff;
            }

            int change = currentHeight < height ? changeValue : -changeValue;
            style.setProperty("height", QString("%1px").arg(currentHeight + change), CSS_PRIORITY);
            doc.updateRendering();
        }
    }
}
コード例 #7
0
ファイル: domtreeview.cpp プロジェクト: blue-shell/folderview
void DOMTreeView::initializeCSSInfoFromElement(const DOM::Element &element)
{
  DOM::Document doc = element.ownerDocument();
  DOM::AbstractView view = doc.defaultView();
  DOM::CSSStyleDeclaration styleDecl = view.getComputedStyle(element,
                                                             DOM::DOMString());

  unsigned long l = styleDecl.length();
  cssProperties->clear();
  cssProperties->setEnabled(true);
  QList<QTreeWidgetItem *> items;
  for (unsigned long i = 0; i < l; ++i) {
    DOM::DOMString name = styleDecl.item(i);
    DOM::DOMString value = styleDecl.getPropertyValue(name);

    QStringList values;
    values.append(name.string());
    values.append(value.string());
    items.append(new QTreeWidgetItem(static_cast<QTreeWidget*>(0), values));
  }

  cssProperties->insertTopLevelItems(0, items);
  cssProperties->resizeColumnToContents(0);
}