本文整理汇总了C++中XbelReader类的典型用法代码示例。如果您正苦于以下问题:C++ XbelReader类的具体用法?C++ XbelReader怎么用?C++ XbelReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XbelReader类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: node
bool BookmarksModel::dropMimeData(const QMimeData *data,
Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
if (action == Qt::IgnoreAction)
return true;
if (column > 0)
return false;
BookmarkNode *parentNode = node(parent);
if (!data->hasFormat(MIMETYPE)) {
if (!data->hasUrls())
return false;
BookmarkNode *node = new BookmarkNode(BookmarkNode::Bookmark, parentNode);
node->url = QString::fromUtf8(data->urls().at(0).toEncoded());
if (data->hasText())
node->title = data->text();
else
node->title = node->url;
m_bookmarksManager->addBookmark(parentNode, node, row);
return true;
}
QByteArray ba = data->data(MIMETYPE);
QDataStream stream(&ba, QIODevice::ReadOnly);
if (stream.atEnd())
return false;
QUndoStack *undoStack = m_bookmarksManager->undoRedoStack();
undoStack->beginMacro(QLatin1String("Move Bookmarks"));
while (!stream.atEnd()) {
QByteArray encodedData;
stream >> encodedData;
QBuffer buffer(&encodedData);
buffer.open(QBuffer::ReadOnly);
XbelReader reader;
BookmarkNode *rootNode = reader.read(&buffer);
QList<BookmarkNode*> children = rootNode->children();
for (int i = 0; i < children.count(); ++i) {
BookmarkNode *bookmarkNode = children.at(i);
rootNode->remove(bookmarkNode);
row = qMax(0, row);
m_bookmarksManager->addBookmark(parentNode, bookmarkNode, row);
m_endMacro = true;
}
delete rootNode;
}
return true;
}
开发者ID:tibmeister,项目名称:arora,代码行数:55,代码来源:bookmarksmodel.cpp
示例2: QLatin1String
void BookmarksManager::load()
{
if (m_loaded)
return;
m_loaded = true;
QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel");
if (!QFile::exists(bookmarkFile))
bookmarkFile = QLatin1String(":defaultbookmarks.xbel");
XbelReader reader;
m_bookmarkRootNode = reader.read(bookmarkFile);
if (reader.error() != QXmlStreamReader::NoError) {
QMessageBox::warning(0, QLatin1String("Loading Bookmark"),
tr("Error when loading bookmarks on line %1, column %2:\n"
"%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
}
QList<BookmarkNode*> others;
for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) {
BookmarkNode *node = m_bookmarkRootNode->children().at(i);
if (node->type() == BookmarkNode::Folder) {
// Automatically convert
if ((node->title == tr("Toolbar Bookmarks")
|| node->title == QLatin1String(BOOKMARKBAR)) && !m_toolbar) {
node->title = tr(BOOKMARKBAR);
m_toolbar = node;
}
// Automatically convert
if ((node->title == tr("Menu")
|| node->title == QLatin1String(BOOKMARKMENU)) && !m_menu) {
node->title = tr(BOOKMARKMENU);
m_menu = node;
}
} else {
others.append(node);
}
m_bookmarkRootNode->remove(node);
}
Q_ASSERT(m_bookmarkRootNode->children().count() == 0);
if (!m_toolbar) {
m_toolbar = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode);
m_toolbar->title = tr(BOOKMARKBAR);
} else {
m_bookmarkRootNode->add(m_toolbar);
}
if (!m_menu) {
m_menu = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode);
m_menu->title = tr(BOOKMARKMENU);
} else {
m_bookmarkRootNode->add(m_menu);
}
for (int i = 0; i < others.count(); ++i)
m_menu->add(others.at(i));
}
开发者ID:porphyr,项目名称:arora,代码行数:60,代码来源:bookmarks.cpp
示例3: tr
void BookmarksManager::importBookmarks()
{
QString fileName = QFileDialog::getOpenFileName(0, tr("Open File"),
QString(),
tr("XBEL (*.xbel *.xml *.html)"));
if (fileName.isEmpty())
return;
XbelReader reader;
BookmarkNode *importRootNode = 0;
if (fileName.endsWith(QLatin1String(".html"))) {
QString program = QLatin1String("htmlToXBel");
QStringList arguments;
arguments << fileName;
QProcess process;
process.start(program, arguments);
process.waitForFinished(-1);
if (process.error() != QProcess::UnknownError) {
QMessageBox::warning(0, QLatin1String("Loading Bookmark"),
tr("Error when loading html bookmarks: %1\n").arg(process.errorString()));
return;
}
importRootNode = reader.read(&process);
} else {
importRootNode = reader.read(fileName);
}
if (reader.error() != QXmlStreamReader::NoError) {
QMessageBox::warning(0, QLatin1String("Loading Bookmark"),
tr("Error when loading bookmarks on line %1, column %2:\n"
"%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
delete importRootNode;
return;
}
importRootNode->setType(BookmarkNode::Folder);
importRootNode->title = (tr("Imported %1").arg(QDate::currentDate().toString(Qt::SystemLocaleShortDate)));
addBookmark(menu(), importRootNode);
}
开发者ID:porphyr,项目名称:arora,代码行数:38,代码来源:bookmarks.cpp
示例4: tr
void BookmarksManager::importBookmarks()
{
QString fileName = QFileDialog::getOpenFileName(0, tr("Open File"),
QString(),
tr("XBEL (*.xbel *.xml)"));
if (fileName.isEmpty())
return;
XbelReader reader;
BookmarkNode *importRootNode = reader.read(fileName);
if (reader.error() != QXmlStreamReader::NoError) {
QMessageBox::warning(0, QLatin1String("Loading Bookmark"),
tr("Error when loading bookmarks on line %1, column %2:\n"
"%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
}
importRootNode->setType(BookmarkNode::Folder);
importRootNode->title = (tr("Imported %1").arg(QDate::currentDate().toString(Qt::SystemLocaleShortDate)));
addBookmark(menu(), importRootNode);
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:20,代码来源:bookmarks.cpp
示例5: QLatin1String
void BookmarksManager::load()
{
if (m_loaded)
return;
m_loaded = true;
QString dir = BrowserApplication::dataLocation();
QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel");
if (!QFile::exists(bookmarkFile))
#ifdef WINPE
bookmarkFile = QLatin1String(":defaultbookmarks_winpe.xbel");
#else
bookmarkFile = QLatin1String(":defaultbookmarks.xbel");
#endif
XbelReader reader;
m_bookmarkRootNode = reader.read(bookmarkFile);
if (reader.error() != QXmlStreamReader::NoError) {
QMessageBox::warning(0, tr("Loading Bookmark"),
tr("Error when loading bookmarks on line %1, column %2:\n"
"%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
}
BookmarkNode *toolbar = 0;
BookmarkNode *menu = 0;
QList<BookmarkNode*> others;
for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i)
{
BookmarkNode *node = m_bookmarkRootNode->children().at(i);
if (node->type() == BookmarkNode::Folder)
{
// Automatically convert
if (node->title == ("Bookmarks Bar") && !toolbar)
{
node->title = tr("Bookmarks Bar");
}
if (node->title == tr("Bookmarks Bar") && !toolbar)
{
toolbar = node;
}
// Automatically convert
if (node->title == ("Bookmarks Menu") && !menu)
{
node->title = tr("Bookmarks Menu");
}
if (node->title == tr("Bookmarks Menu") && !menu)
{
menu = node;
}
}
else
{
others.append(node);
}
m_bookmarkRootNode->remove(node);
}
Q_ASSERT(m_bookmarkRootNode->children().count() == 0);
if (!toolbar) {
toolbar = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode);
toolbar->title = tr("Bookmarks Bar");
} else
{
m_bookmarkRootNode->add(toolbar);
}
if (!menu)
{
menu = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode);
menu->title = tr("Bookmarks Menu");
} else
{
m_bookmarkRootNode->add(menu);
}
for (int i = 0; i < others.count(); ++i)
menu->add(others.at(i));
}
开发者ID:OS2World,项目名称:APP-INTERNET-QtWeb,代码行数:80,代码来源:bookmarks.cpp
注:本文中的XbelReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论