예제 #1
0
QList<TabHistory> SessionManager::closedSitesForWindow(const QString &windowName)
{
    QList<TabHistory> list;
    QDomDocument document("session");

    if (!readSessionDocument(document, m_sessionFilePath))
        return list;

    for (unsigned int winNo = 0; winNo < document.elementsByTagName("tab").length(); winNo++)
    {
        QDomElement windowElement = document.elementsByTagName("window").at(winNo).toElement();

        if (windowName != windowElement.attribute("name", ""))
            continue;
        
        for (unsigned int tabNo = 0; tabNo < windowElement.elementsByTagName("tab").length(); tabNo++)
        {
            QDomElement tab = windowElement.elementsByTagName("tab").at(tabNo).toElement();

            TabHistory tabHistory;

            tabHistory.title = tab.attribute("title");
            tabHistory.url = tab.attribute("url");

            QDomCDATASection historySection = tab.firstChild().toCDATASection();
            tabHistory.history = QByteArray::fromBase64(historySection.data().toAscii());

            list << tabHistory;
        }
        
        return list;
    }

    return list;
}
예제 #2
0
QString
vleSmDT::getComputeBody()
{
    QDomElement docElem = mDocSm->documentElement();

    QDomNode computeNode =
        mDocSm->elementsByTagName("compute").item(0);

    QDomNodeList childs = computeNode.childNodes();
    if (childs.length() == 0) {
        return "";
    } else {
        QDomCDATASection cdataCompute = childs.at(0).toCDATASection();
        return cdataCompute.data();
    }

}
예제 #3
0
int loadTabs(RekonqWindow *tw, QDomElement & window, bool useFirstTab, bool justThePinnedOnes = false)
{
    int currentTab = 0;

    for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++)
    {
        QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement();
        bool tabIsPinned = tab.hasAttribute("pinned");
        kDebug() << "Tab #" << tabNo <<  " is pinned? " << tabIsPinned;

        if (!justThePinnedOnes || tabIsPinned)
        {
            if (tab.hasAttribute("currentTab"))
                currentTab = tabNo;

            KUrl u = KUrl(tab.attribute("url"));

            TabHistory tabHistory;
            tabHistory.title = tab.attribute("title");
            tabHistory.url = tab.attribute("url");
            QDomCDATASection historySection = tab.firstChild().toCDATASection();
            tabHistory.history = QByteArray::fromBase64(historySection.data().toAscii());

            if (tabNo == 0 && useFirstTab)
            {
                tw->loadUrl(u, Rekonq::CurrentTab, &tabHistory);
            }
            else
            {
                tw->loadUrl(u, Rekonq::NewTab, &tabHistory);
            }

            if (tabIsPinned)
            {
                tw->tabBar()->setTabData(tabNo, true);
                if (tw->tabBar()->tabButton(tabNo, QTabBar::RightSide))
                    tw->tabBar()->tabButton(tabNo, QTabBar::RightSide)->hide(); // NOTE: this is not good here: where is its proper place?
            }
        }
    }

    return currentTab;
}
예제 #4
0
bool ImageOptions::loadXmlElement(QDomElement element)
{
  bool result = false;

  auto readStringFromNode = [this](QDomElement element, const QString elementName, QString * result) {
    if (element.tagName() == elementName) {
      QDomNode dataNode = element.firstChild();

      if (dataNode.isCDATASection()) {
        QDomCDATASection cdataSection = dataNode.toCDATASection();
        QString strValue = cdataSection.data();
        *result = this->unescapeEmpty(strValue);
      } else {
        QString strValue = element.text();
        *result = this->unescapeEmpty(strValue);
      }
    }
  };


  QDomNode nodeSett = element.firstChild();

  while (!nodeSett.isNull()) {
    QDomElement e = nodeSett.toElement();

    if (e.tagName() == ImageOptions::GroupName) {
      break;
    }

    nodeSett = nodeSett.nextSibling();
  }

  if (nodeSett.isNull()) {
    return result;
  }

  quint32 uBytesOrder = 0, uBlockSize = 0, uBlockDefaultOnes = 0, uSplitToRows = 0;
  quint32 uCompressionRle = 0, uCompressionRleMinLength = 2;
  QString sBlockPrefix = "0x", sBlockSuffix, sBlockDelimiter = ", ";
  QString sPreviewPrefix, sPreviewSuffix, sPreviewDelimiter, sPreviewLevels;

  QDomNode nodeValue = nodeSett.firstChild();

  while (!nodeValue.isNull()) {
    QDomElement e = nodeValue.toElement();

    if (!e.isNull()) {
      if (e.tagName() == ImageOptions::FieldBlockSize) {
        QString str = e.text();
        uBlockSize = str.toUInt(&result);
      }

      if (e.tagName() == ImageOptions::FieldBytesOrder) {
        QString str = e.text();
        uBytesOrder = str.toUInt(&result);
      }

      if (e.tagName() == ImageOptions::FieldSplitToRows) {
        QString str = e.text();
        uSplitToRows = str.toUInt(&result);
      }

      if (e.tagName() == ImageOptions::FieldCompressionRle) {
        QString str = e.text();
        uCompressionRle = str.toUInt(&result);
      }

      if (e.tagName() == ImageOptions::FieldCompressionRleMinLength) {
        QString str = e.text();
        uCompressionRleMinLength = str.toUInt(&result);
      }

      if (e.tagName() == ImageOptions::FieldBlockDefaultOnes) {
        QString str = e.text();
        uBlockDefaultOnes = str.toUInt(&result);
      }

      readStringFromNode(e, ImageOptions::FieldBlockPrefix, &sBlockPrefix);
      readStringFromNode(e, ImageOptions::FieldBlockSuffix, &sBlockSuffix);
      readStringFromNode(e, ImageOptions::FieldBlockDelimiter, &sBlockDelimiter);
      readStringFromNode(e, ImageOptions::FieldPreviewPrefix, &sPreviewPrefix);
      readStringFromNode(e, ImageOptions::FieldPreviewSuffix, &sPreviewSuffix);
      readStringFromNode(e, ImageOptions::FieldPreviewDelimiter, &sPreviewDelimiter);
      readStringFromNode(e, ImageOptions::FieldPreviewLevels, &sPreviewLevels);

      if (!result) {
        break;
      }
    }

    nodeValue = nodeValue.nextSibling();
  }

  if (result) {
    this->setBlockSize((Parsing::Conversion::Options::DataBlockSize)uBlockSize);
    this->setBlockDefaultOnes((bool)uBlockDefaultOnes);
    this->setBytesOrder((Parsing::Conversion::Options::BytesOrder)uBytesOrder);
    this->setSplitToRows((bool)uSplitToRows);
    this->setCompressionRle((bool)uCompressionRle);
    this->setCompressionRleMinLength(uCompressionRleMinLength);
    this->setBlockPrefix(sBlockPrefix);
    this->setBlockSuffix(sBlockSuffix);
    this->setBlockDelimiter(sBlockDelimiter);
    this->setPreviewPrefix(sPreviewPrefix);
    this->setPreviewSuffix(sPreviewSuffix);
    this->setPreviewDelimiter(sPreviewDelimiter);
    this->setPreviewLevels(sPreviewLevels);
  }

  return result;
}