void BookmarksManager::save() const { if (!m_loaded) return; XbelWriter writer; QString dir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); if (!writer.write(bookmarkFile, m_bookmarkRootNode)) qWarning() << "BookmarkManager: error saving to" << bookmarkFile; }
void BookmarksManager::save() const { if (!m_loaded) return; XbelWriter writer; QString dir = BrowserApplication::dataLocation(); QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); if (!writer.write(bookmarkFile, m_bookmarkRootNode)) qWarning() << "BookmarkManager: error saving to" << bookmarkFile; }
void BookmarksManager::exportBookmarks() { QString fileName = QFileDialog::getSaveFileName(0, tr("Save File"), tr("%1 Bookmarks.xbel").arg(QCoreApplication::applicationName()), tr("XBEL (*.xbel *.xml)")); if (fileName.isEmpty()) return; XbelWriter writer; if (!writer.write(fileName, m_bookmarkRootNode)) QMessageBox::critical(0, tr("Export error"), tr("error saving bookmarks")); }
void BookmarksManager::save() const { if (!m_loaded) return; XbelWriter writer; QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); // Save root folder titles in English (i.e. not localized) m_menu->title = QLatin1String(BOOKMARKMENU); m_toolbar->title = QLatin1String(BOOKMARKBAR); if (!writer.write(bookmarkFile, m_bookmarkRootNode)) qWarning() << "BookmarkManager: error saving to" << bookmarkFile; // Restore localized titles retranslate(); }
QMimeData *BookmarksModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); foreach (QModelIndex index, indexes) { if (index.column() != 0 || !index.isValid()) continue; QByteArray encodedData; QBuffer buffer(&encodedData); buffer.open(QBuffer::ReadWrite); XbelWriter writer; const BookmarkNode *parentNode = node(index); writer.write(&buffer, parentNode); stream << encodedData; } mimeData->setData(MIMETYPE, data); return mimeData; }