当前位置: 首页>>代码示例>>C++>>正文


C++ Element::isNull方法代码示例

本文整理汇总了C++中dom::Element::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::isNull方法的具体用法?C++ Element::isNull怎么用?C++ Element::isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dom::Element的用法示例。


在下文中一共展示了Element::isNull方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: remove

void Textual::remove(const Index& index) {
  DOM::HTMLDocument document = htmlDocument();
  if(index.atVariationStart()) {
    DOM::Element vc = document.getElementById("vc_"+index);
    if(!vc.isNull()) {
      /* remove a number? */
      DOM::Element comm(vc.previousSibling());
      DOM::Element mvnum(vc.nextSibling());
      if(!mvnum.isNull() && mvnum.getAttribute("id").string().startsWith("nm_") &&
            !comm.isNull() && comm.getAttribute("id").string().startsWith("cm_"))
      {
        DOM::Element move(mvnum.nextSibling());
        int mv_num = move.getAttribute("mvnum").string().toInt();
        int sub_mv_num = move.getAttribute("submvnum").string().toInt();
        if(!(mv_num>0 && (sub_mv_num==0 && (mv_num%2 || m_layout_style))))
          mvnum.parentNode().removeChild(mvnum);
      }
      vc.parentNode().removeChild(vc);
    }
  }
  else {
    DOM::Element rm = document.getElementById("nm_"+index);
    if(rm.isNull())
      rm = document.getElementById("mv_"+index);
    if(!rm.isNull())
      clear_from(rm);
  }
  if(m_curr_selected >= index)
    m_curr_selected = Index(-1);
}
开发者ID:Axure,项目名称:tagua,代码行数:30,代码来源:movelist_textual.cpp

示例2: select

void Textual::select(const Index& index) {
  if(index == m_curr_selected)
    return;
  DOM::HTMLDocument document = htmlDocument();
  DOM::Element currs = document.getElementById("mv_"+m_curr_selected);
  DOM::Element news = document.getElementById("mv_"+index);
  if(!currs.isNull())
    currs.style().removeProperty("background-color");
  if(!news.isNull())
    news.style().setProperty("background-color", "#C0E0FF", "important");
  m_curr_selected = index;
}
开发者ID:Axure,项目名称:tagua,代码行数:12,代码来源:movelist_textual.cpp

示例3: slotItemRenamed

void DOMTreeView::slotItemRenamed(QListViewItem *lvi, const QString &str, int col)
{
  AttributeListItem *item = static_cast<AttributeListItem *>(lvi);

  DOM::Element element = infoNode;
  if (element.isNull()) return; // Should never happen

  switch (col) {
    case 0: {
      ManipulationCommand *cmd;
//       kdDebug(90180) << k_funcinfo << "col 0: " << element.nodeName() << " isNew: " << item->isNew() << endl;
      if (item->isNew()) {
        cmd = new AddAttributeCommand(element, str, item->text(1));
	item->setNew(false);
      } else
        cmd = new RenameAttributeCommand(element, item->text(0), str);

      mainWindow()->executeAndAddCommand(cmd);
      break;
    }
    case 1: {
      if (item->isNew()) { lvi->setText(1, QString()); break; }

      ChangeAttributeValueCommand *cmd = new ChangeAttributeValueCommand(
      			  element, item->text(0), str);
      mainWindow()->executeAndAddCommand(cmd);
      break;
    }
  }
}
开发者ID:iegor,项目名称:kdesktop,代码行数:30,代码来源:domtreeview.cpp

示例4: initializeOptionsFromNode

void DOMTreeView::initializeOptionsFromNode(const DOM::Node &node)
{
  infoNode = node;

  nodeName->clear();
  nodeType->clear();
  nodeNamespace->clear();
  nodeValue->clear();

  if (node.isNull()) {
    nodeInfoStack->raiseWidget(EmptyPanel);
    return;
  }

  nodeName->setText(node.nodeName().string());
  nodeType->setText(QString::number(node.nodeType()));
  nodeNamespace->setText(node.namespaceURI().string());
//   nodeValue->setText(node.value().string());

  DOM::Element element = node;
  if (!element.isNull()) {
    initializeOptionsFromElement(element);
    return;
  }

  DOM::CharacterData cdata = node;
  if (!cdata.isNull()) {
    initializeOptionsFromCData(cdata);
    return;
  }

  // Fallback
  nodeInfoStack->raiseWidget(EmptyPanel);
}
开发者ID:iegor,项目名称:kdesktop,代码行数:34,代码来源:domtreeview.cpp

示例5: parseNode

void KHTMLReader::parseNode(DOM::Node node)
{

    // check if this is a text node.
    DOM::Text t = node;
    if (!t.isNull()) {
        _writer->addText(state()->paragraph, t.data().string(), 1, state()->in_pre_mode);
        return; // no children anymore...
    }

    // is this really needed ? it can't do harm anyway.
    state()->format = _writer->currentFormat(state()->paragraph, true);
    state()->layout = _writer->currentLayout(state()->paragraph);
    pushNewState();

    DOM::Element e = node;

    bool go_recursive = true;

    if (!e.isNull()) {
        // get the CSS information
        parseStyle(e);
        // get the tag information
        go_recursive = parseTag(e);
    }
    if (go_recursive) {
        for (DOM::Node q = node.firstChild(); !q.isNull(); q = q.nextSibling()) {
            parseNode(q);
        }
    }
    popState();


}
开发者ID:KDE,项目名称:koffice,代码行数:34,代码来源:khtmlreader.cpp

示例6: showRecursive

void DOMTreeView::showRecursive(const DOM::Node &pNode, const DOM::Node &node, uint depth)
{
  DOMListViewItem *cur_item;
  DOMListViewItem *parent_item = m_itemdict.value(pNode.handle(), 0);

  if (depth > m_maxDepth) {
    m_maxDepth = depth;
  }

  if (depth == 0) {
    cur_item = new DOMListViewItem(node, m_listView);
    m_document = pNode.ownerDocument();
  } else {
    cur_item = new DOMListViewItem(node, parent_item);
  }

  //kDebug(90180) << node.nodeName().string() << " [" << depth << "]";
  cur_item = addElement (node, cur_item, false);
  m_listView->setItemExpanded(cur_item, depth < m_expansionDepth);

  if(node.handle()) {
    m_itemdict.insert(node.handle(), cur_item);
  }

  DOM::Node child = node.firstChild();
  if (child.isNull()) {
    DOM::HTMLFrameElement frame = node;
    if (!frame.isNull()) {
      child = frame.contentDocument().documentElement();
    } else {
      DOM::HTMLIFrameElement iframe = node;
      if (!iframe.isNull())
        child = iframe.contentDocument().documentElement();
    }
  }
  while(!child.isNull()) {
    showRecursive(node, child, depth + 1);
    child = child.nextSibling();
  }

  const DOM::Element element = node;
  if (!m_bPure) {
    if (!element.isNull() && !element.firstChild().isNull()) {
      if(depth == 0) {
	cur_item = new DOMListViewItem(node, m_listView, cur_item);
	m_document = pNode.ownerDocument();
      } else {
	cur_item = new DOMListViewItem(node, parent_item, cur_item);
      }
      //kDebug(90180) << "</" << node.nodeName().string() << ">";
      cur_item = addElement(element, cur_item, true);
//       m_listView->setItemExpanded(cur_item, depth < m_expansionDepth);
    }
  }
}
开发者ID:blue-shell,项目名称:folderview,代码行数:55,代码来源:domtreeview.cpp

示例7: parse_head

void KHTMLReader::parse_head(DOM::Element e)
{
    for (DOM::Element items = e.firstChild();!items.isNull();items = items.nextSibling()) {
        if (items.tagName().string().lower() == "title") {
            DOM::Text t = items.firstChild();
            if (!t.isNull()) {
                _writer->createDocInfo("HTML import filter", t.data().string());
            }
        }
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:11,代码来源:khtmlreader.cpp

示例8: saveRecursive

void DOMTreeView::saveRecursive(const DOM::Node &pNode, int indent)
{
  const QString nodeName(pNode.nodeName().string());
  QString text;
  QString strIndent;
  strIndent.fill(' ', indent);
  const DOM::Element element = static_cast<const DOM::Element>(pNode);

  text = strIndent;

  if ( !element.isNull() ) {
    if (nodeName.at(0)=='-') {
      /* Don't save khtml internal tags '-konq..'
       * Approximating it with <DIV>
       */
      text += "<DIV> <!-- -KONG_BLOCK -->";
    } else {
      text += "<" + nodeName;

      QString attributes;
      DOM::Attr attr;
      const DOM::NamedNodeMap attrs = element.attributes();
      unsigned long lmap = attrs.length();
      for( uint j=0; j<lmap; j++ ) {
	attr = static_cast<DOM::Attr>(attrs.item(j));
	attributes += " " + attr.name().string() + "=\"" + attr.value().string() + "\"";
      }
      if (!(attributes.isEmpty())){
	text += " ";
      }

      text += attributes.simplifyWhiteSpace();

      if(element.firstChild().isNull()) {
	text += "/>";
      } else {
	text += ">";
      }
    }
  } else {
    text = strIndent + pNode.nodeValue().string();
  }

  kdDebug(90180) << text << endl;
  if (!(text.isEmpty())) {
    (*m_textStream) << text << endl;
  }

  DOM::Node child = pNode.firstChild();
  while(!child.isNull()) {
    saveRecursive(child, indent+2);
    child = child.nextSibling();
  }

  if (!(element.isNull()) && (!(element.firstChild().isNull()))) {
    if (nodeName.at(0)=='-') {
      text = strIndent + "</DIV> <!-- -KONG_BLOCK -->";
    } else {
      text = strIndent + "</" + pNode.nodeName().string() + ">";
    }
    kdDebug(90180) << text << endl;
    (*m_textStream) << text << endl;
  }
}
开发者ID:iegor,项目名称:kdesktop,代码行数:64,代码来源:domtreeview.cpp

示例9: addElement

void DOMTreeView::addElement ( const DOM::Node &node,  DOMListViewItem *cur_item, bool isLast)
{
  cur_item->setClosing(isLast);

  const QString nodeName(node.nodeName().string());
  QString text;
  const DOM::Element element = node;
  if (!element.isNull()) {
    if (!m_bPure) {
      if (isLast) {
	text ="</";
      } else {
	text = "<";
      }
      text += nodeName;
    } else {
      text = nodeName;
    }

    if (m_bShowAttributes && !isLast) {
      QString attributes;
      DOM::Attr attr;
      DOM::NamedNodeMap attrs = element.attributes();
      unsigned long lmap = attrs.length();
      for( unsigned int j=0; j<lmap; j++ ) {
	attr = static_cast<DOM::Attr>(attrs.item(j));
	attributes += " " + attr.name().string() + "=\"" + attr.value().string() + "\"";
      }
      if (!(attributes.isEmpty())) {
	text += " ";
      }
      text += attributes.simplifyWhiteSpace();
    }

    if (!m_bPure) {
      if(element.firstChild().isNull()) {
	text += "/>";
      } else {
	text += ">";
      }
    }
    cur_item->setText(0, text);
  } else {
    text = "`" + node.nodeValue().string() + "'";

    // Hacks to deal with PRE
    QTextStream ts( text, IO_ReadOnly );
    while (!ts.eof()) {
      const QString txt(ts.readLine());
      const QFont font(KGlobalSettings::fixedFont());
      cur_item->setFont( font );
      cur_item->setText(0, txt);

      if(node.handle()) {
	m_itemdict.insert(node.handle(), cur_item);
      }

      DOMListViewItem *parent;
      if (cur_item->parent()) {
	parent = static_cast<DOMListViewItem *>(cur_item->parent());
      } else {
	parent = cur_item;
      }
      cur_item = new DOMListViewItem(node, parent, cur_item);
    }
    // This is one is too much
    DOMListViewItem *notLastItem = static_cast<DOMListViewItem *>(cur_item->itemAbove());
    delete cur_item;
    cur_item = notLastItem;
  }

  if (m_bHighlightHTML && node.ownerDocument().isHTMLDocument()) {
    highlightHTML(cur_item, nodeName);
  }
}
开发者ID:iegor,项目名称:kdesktop,代码行数:75,代码来源:domtreeview.cpp

示例10: parse_table

bool KHTMLReader::parse_table(DOM::Element e)
{
    if (_writer->isInTable()) {
        // We are already inside of a table. Tables in tables are not supported
        // yet. So, just add that table-content as text.
        for (DOM::Node rows = e.firstChild().firstChild();!rows.isNull();rows = rows.nextSibling())
            if (!rows.isNull() && rows.nodeName().string().toLower() == "tr")
                for (DOM::Node cols = rows.firstChild();!cols.isNull();cols = cols.nextSibling())
                    if (!cols.isNull())
                        parseNode(cols);
        return false;
    }

    DOM::Element table_body = e.firstChild();
    if (table_body.isNull()) {
        // If the table_body is empty, we don't continue cause else
        // KHTML will throw a DOM::DOMException if we try to access
        // the null element.
        return true;
    }

    int tableno = _writer->createTable();
    int nrow = 0;
    int ncol = 0;
    bool has_borders = false;
    QColor bgcolor = parsecolor("#FFFFFF");

    if (!table_body.getAttribute("bgcolor").string().isEmpty())
        bgcolor = parsecolor(table_body.getAttribute("bgcolor").string());
    if ((e.getAttribute("border").string().toInt() > 0))
        has_borders = true;

    // fixme rewrite this proper
    //(maybe using computed sizes from khtml if thats once exported)
    for (DOM::Node rowsnode = table_body.firstChild();!rowsnode.isNull();rowsnode = rowsnode.nextSibling()) {
        DOM::Element rows = rowsnode;
        if (!rows.isNull() && rows.tagName().string().toLower() == "tr") {
            QColor obgcolor = bgcolor;
            if (!rows.getAttribute("bgcolor").string().isEmpty())
                bgcolor = parsecolor(rows.getAttribute("bgcolor").string());

            ncol = 0;
            for (DOM::Node colsnode = rows.firstChild();!colsnode.isNull();colsnode = colsnode.nextSibling()) {
                DOM::Element cols = colsnode;
                const QString nodename = cols.isNull() ? QString() : cols.nodeName().string().toLower();
                if (nodename == "td" || nodename == "th") {
                    QColor bbgcolor = bgcolor;
                    if (!cols.getAttribute("bgcolor").string().isEmpty())
                        bgcolor = parsecolor(cols.getAttribute("bgcolor").string());

                    pushNewState();
                    QRect colrect = cols.getRect();
                    state()->frameset = _writer->createTableCell(tableno, nrow, ncol, 1, colrect);
                    state()->frameset.firstChild().toElement().setAttribute("bkRed", bgcolor.red());
                    state()->frameset.firstChild().toElement().setAttribute("bkGreen", bgcolor.green());
                    state()->frameset.firstChild().toElement().setAttribute("bkBlue", bgcolor.blue());
                    if (has_borders) {
                        state()->frameset.firstChild().toElement().setAttribute("lWidth", 1);
                        state()->frameset.firstChild().toElement().setAttribute("rWidth", 1);
                        state()->frameset.firstChild().toElement().setAttribute("bWidth", 1);
                        state()->frameset.firstChild().toElement().setAttribute("tWidth", 1);
                    }

                    // fixme don't guess. get it right.
                    state()->paragraph = _writer->addParagraph(state()->frameset);
                    parseNode(cols);
                    _writer->cleanUpParagraph(state()->paragraph);
                    popState();
                    ncol++;
                    bgcolor = bbgcolor;
                }
            }
            nrow++;
            bgcolor = obgcolor;
        }
    }
    _writer->finishTable(tableno/*,0,0,r.right()-r.left(),r.bottom()-r.top()*/); // FIXME find something better.
    startNewParagraph(false, false);
    _writer->createInline(state()->paragraph, _writer->fetchTableCell(tableno, 0, 0));
    startNewParagraph(false, false);
    return false; // we do our own recursion
}
开发者ID:KDE,项目名称:koffice,代码行数:82,代码来源:khtmlreader.cpp

示例11: slotPopupMenu

/*
   we just simplify the process. if we use KParts::BrowserExtension, we have to do
   lots extra work, adding so much classes. so just hack like following.

   grab useful code from TDEHTMLPopupGUIClient(tdehtml_ext.cpp),
   and change a little bit to fit our needs

*/
void EvaChatView::slotPopupMenu( const TQString & _url, const TQPoint & point )
{
    menu->clear();

    bool isImage = false;
    bool hasSelection = TDEHTMLPart::hasSelection();
    KURL url = KURL(_url);

    if(d) delete d;
    d = new MenuPrivateData;
    d->m_url = url;


    DOM::Element e = nodeUnderMouse();
    if ( !e.isNull() && (e.elementId() == ID_IMG) ) {
        DOM::HTMLImageElement ie = static_cast<DOM::HTMLImageElement>(e);
        TQString src = ie.src().string();
        d->m_imageURL = KURL(src);
        d->m_suggestedFilename = src.right(src.length() - src.findRev("/") -1);
        isImage=true;
    }


    TDEAction *action = 0L;

    if(hasSelection) {
        //action =  new TDEAction( i18n( "&Copy Text" ), TDEShortcut("Ctrl+C"), this, SLOT( copy() ),
        //			actionCollection(), "copy" );
        //action = KStdAction::copy( browserExtension(), SLOT(copy()), actionCollection(), "copy");
        //action->setText(i18n("&Copy Text"));
        //action->setEnabled(true);
        copyAction->plug(menu);

        // search text
        TQString selectedText = TDEHTMLPart::selectedText();
        if ( selectedText.length()>18 ) {
            selectedText.truncate(15);
            selectedText+="...";
        }
#ifdef HAS_KONTQUEROR
        // Fill search provider entries
        TDEConfig config("kuriikwsfilterrc");
        config.setGroup("General");
        const TQString defaultEngine = config.readEntry("DefaultSearchEngine", "google");
        const char keywordDelimiter = config.readNumEntry("KeywordDelimiter", ':');


        // default search provider
        KService::Ptr service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(defaultEngine));

        // search provider icon
        TQPixmap icon;
        KURIFilterData data;
        TQStringList list;
        const TQString defaultSearchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;
        data.setData( defaultSearchProviderPrefix + TQString("some keyword") );
        list << "kurisearchfilter" << "kuriikwsfilter";

        TQString name;
        if ( KURIFilter::self()->filterURI(data, list) ) {
            TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
            if ( iconPath.isEmpty() )
                icon = SmallIcon("edit-find");
            else
                icon = TQPixmap( iconPath );

            name = service->name();
        } else {
            icon = SmallIcon("google");
            name = "Google";
        }

        action = new TDEAction( i18n( "Search '%1' at %2" ).arg( selectedText ).arg( name ), icon, 0, this,
                                SLOT( searchProvider() ), actionCollection(), "searchProvider" );
        action->plug(menu);

        // favorite search providers
        TQStringList favoriteEngines;
        favoriteEngines = config.readListEntry("FavoriteSearchEngines"); // for KDE 3.2 API compatibility
        if(favoriteEngines.isEmpty())
            favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia";

        if ( !favoriteEngines.isEmpty()) {
            TDEActionMenu* providerList = new TDEActionMenu( i18n( "Search '%1' At" ).arg( selectedText ), actionCollection(), "searchProviderList" );
            bool hasSubMenus = false;
            TQStringList::ConstIterator it = favoriteEngines.begin();
            for ( ; it != favoriteEngines.end(); ++it ) {
                if (*it==defaultEngine)
                    continue;
                service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(*it));
                if (!service)
                    continue;
//.........这里部分代码省略.........
开发者ID:MagicGroup,项目名称:eva,代码行数:101,代码来源:evachatview.cpp

示例12: setMove

void Textual::setMove(const Index& index, int turn, const DecoratedMove& move,
                                                          const QString& comment) {
  //kDebug() << "i= " << index;
  DOM::HTMLDocument document = htmlDocument();
  QString istr = (QString)index;

  DOM::Element this_mv = document.getElementById("mv_"+istr);
  DOM::Element this_cm = document.getElementById("cm_"+istr);
  if(!this_mv.isNull() && !this_cm.isNull()) {
    clear_node(this_mv);
    for(int i=0;i<move.size();i++) {
      DOM::Text t = document.createTextNode(move[i].m_string);
      this_mv.appendChild(t);
    }

    clear_node(this_cm);
    if(!comment.isEmpty()) {
      this_cm.appendChild(document.createTextNode(comment));
      this_cm.appendChild(document.createTextNode(QString(" ")));
    }
    return;
  }

  DOM::Element parent;
  DOM::Element prev_mv;
  DOM::Element prev_cm;

  if(index != Index(0)) {
    prev_cm = document.getElementById("cm_"+index.prev());
    prev_mv = document.getElementById("mv_"+index.prev());
    if(prev_cm.isNull() || prev_mv.isNull()) {
      kDebug() << " --> Error in Textual::setMove, no previous move!";
      return;
    }
  }

  int mv_num = 0;
  int sub_mv_num = 0;
  if(!prev_mv.isNull()) {
    int prev_turn = prev_mv.getAttribute("turn").string().toInt();
    int prev_mv_num = prev_mv.getAttribute("mvnum").string().toInt();
    int prev_sub_mv_num = prev_mv.getAttribute("submvnum").string().toInt();
    if(prev_turn != turn)
      mv_num = prev_mv_num+1;
    else {
      mv_num = prev_mv_num;
      sub_mv_num = prev_sub_mv_num+1;
    }
  }

  if(!index.nested.size()) {
    parent = document.body();
    if(parent.isNull()) {
      kDebug() << "QUEEEEEEEEE!!!!!!!";
      return;
    }
  }
  else if(index.atVariationStart()) {
    QString var_id = "vc_" + istr;
    DOM::Element add_before = prev_cm.nextSibling();

    while(!add_before.isNull()) {

      QString id = add_before.getAttribute("id").string();
      if(id.startsWith("vc_") && id < var_id)
        add_before = add_before.nextSibling();
      else
        break;
    }

    DOM::Element var_el = document.createElement("span");
    var_el.setAttribute("id", var_id);
    var_el.setAttribute("class", "variation");
    var_el.appendChild(document.createTextNode("[ "));


    parent = document.createElement("span");
    parent.setAttribute("id", "vr_" + istr);
    DOM::Element vk_el = document.createElement("span");
    vk_el.setAttribute("id", "vk_" + istr);
    vk_el.setAttribute("class", "comment");
    //vk_el.setContentEditable(true);
    parent.appendChild(vk_el);
    var_el.appendChild(parent);

    var_el.appendChild(document.createTextNode("] "));
    prev_cm.parentNode().insertBefore(var_el, add_before);

    if(!add_before.isNull() && add_before.getAttribute("id").string().startsWith("mv_")) {
      int mv_num = add_before.getAttribute("mvnum").string().toInt();
      int sub_mv_num = add_before.getAttribute("submvnum").string().toInt();
      QString num_str;
      if(m_layout_style == 0) {
        if(mv_num%2)
          num_str = QString("%1. ").arg((mv_num+1)/2);
        else
          num_str = QString("%1. ... ").arg((mv_num+2)/2);
      }
      else {
        if(sub_mv_num==0)
//.........这里部分代码省略.........
开发者ID:Axure,项目名称:tagua,代码行数:101,代码来源:movelist_textual.cpp


注:本文中的dom::Element::isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。