本文整理汇总了C++中BookmarkItem::setUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ BookmarkItem::setUrl方法的具体用法?C++ BookmarkItem::setUrl怎么用?C++ BookmarkItem::setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookmarkItem
的用法示例。
在下文中一共展示了BookmarkItem::setUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readBookmarks
void ChromeImporter::readBookmarks(const QVariantList &list, BookmarkItem* parent)
{
Q_ASSERT(parent);
foreach (const QVariant &entry, list) {
const QVariantMap map = entry.toMap();
const QString typeString = map.value("type").toString();
BookmarkItem::Type type;
if (typeString == QLatin1String("url")) {
type = BookmarkItem::Url;
}
else if (typeString == QLatin1String("folder")) {
type = BookmarkItem::Folder;
}
else {
continue;
}
BookmarkItem* item = new BookmarkItem(type, parent);
item->setTitle(map.value("name").toString());
if (item->isUrl()) {
item->setUrl(QUrl::fromEncoded(map.value("url").toByteArray()));
}
if (map.contains("children")) {
readBookmarks(map.value("children").toList(), item);
}
}
}
示例2: addBookmark
void BookmarksManager::addBookmark()
{
BookmarkItem* item = new BookmarkItem(BookmarkItem::Url);
item->setTitle(tr("New Bookmark"));
item->setUrl(QUrl("http://"));
addBookmark(item);
}
示例3: bookmarkEdited
void BookmarksManager::bookmarkEdited()
{
Q_ASSERT(ui->tree->selectedBookmarks().count() == 1);
BookmarkItem* item = ui->tree->selectedBookmarks().first();
item->setTitle(ui->title->text());
item->setUrl(QUrl::fromEncoded(ui->address->text().toUtf8()));
item->setKeyword(ui->keyword->text());
item->setDescription(ui->description->toPlainText());
m_bookmarks->changeBookmark(item);
}
示例4: importBookmarks
BookmarkItem* IeImporter::importBookmarks()
{
BookmarkItem* root = new BookmarkItem(BookmarkItem::Folder);
root->setTitle("Internet Explorer Import");
foreach (QFileInfo file, urls) {
QSettings urlFile(file.absoluteFilePath(), QSettings::IniFormat, this);
QUrl url = urlFile.value("InternetShortcut/URL").toUrl();
BookmarkItem* b = new BookmarkItem(BookmarkItem::Url, root);
b->setTitle(file.baseName());
b->setUrl(url);
}
示例5: importBookmarks
BookmarkItem* FirefoxImporter::importBookmarks()
{
BookmarkItem* root = new BookmarkItem(BookmarkItem::Folder);
root->setTitle("Firefox Import");
QSqlQuery query(m_db);
query.exec("SELECT title, fk FROM moz_bookmarks WHERE title != ''");
while (query.next()) {
QString title = query.value(0).toString();
int placesId = query.value(1).toInt();
QSqlQuery query2(m_db);
query2.exec("SELECT url FROM moz_places WHERE id=" + QString::number(placesId));
if (!query2.next()) {
continue;
}
QUrl url = query2.value(0).toUrl();
if (title.isEmpty() || url.isEmpty() || url.scheme() == QLatin1String("place")
|| url.scheme() == QLatin1String("about")) {
continue;
}
BookmarkItem* b = new BookmarkItem(BookmarkItem::Url, root);
b->setTitle(title);
b->setUrl(url);
}
if (query.lastError().isValid()) {
setError(query.lastError().text());
}
m_db.close();
QSqlDatabase::removeDatabase("firefox-import");
return root;
}
示例6: toggleBookmark
void BookmarksWidget::toggleBookmark()
{
if (m_bookmark) {
if (m_edited) {
// Change folder
m_bookmarks->removeBookmark(m_bookmark);
m_bookmarks->addBookmark(ui->folderButton->selectedFolder(), m_bookmark);
}
else {
// Remove
m_bookmarks->removeBookmark(m_bookmark);
}
}
else {
// Save bookmark
BookmarkItem* bookmark = new BookmarkItem(BookmarkItem::Url);
bookmark->setTitle(m_view->title());
bookmark->setUrl(m_view->url());
m_bookmarks->addBookmark(ui->folderButton->selectedFolder(), bookmark);
}
closePopup();
}
示例7: importBookmarks
BookmarkItem* HtmlImporter::importBookmarks()
{
QString bookmarks = QString::fromUtf8(m_file.readAll());
m_file.close();
// Converting tags to lower case -,-
// For some reason Qt::CaseInsensitive is not everytime insensitive :-D
bookmarks.replace(QLatin1String("<DL"), QLatin1String("<dl"));
bookmarks.replace(QLatin1String("</DL"), QLatin1String("</dl"));
bookmarks.replace(QLatin1String("<DT"), QLatin1String("<dt"));
bookmarks.replace(QLatin1String("</DT"), QLatin1String("</dt"));
bookmarks.replace(QLatin1String("<P"), QLatin1String("<p"));
bookmarks.replace(QLatin1String("</P"), QLatin1String("</p"));
bookmarks.replace(QLatin1String("<A"), QLatin1String("<a"));
bookmarks.replace(QLatin1String("</A"), QLatin1String("</a"));
bookmarks.replace(QLatin1String("HREF="), QLatin1String("href="));
bookmarks.replace(QLatin1String("<H3"), QLatin1String("<h3"));
bookmarks.replace(QLatin1String("</H3"), QLatin1String("</h3"));
bookmarks = bookmarks.left(bookmarks.lastIndexOf(QLatin1String("</dl><p>")));
int start = bookmarks.indexOf(QLatin1String("<dl><p>"));
BookmarkItem* root = new BookmarkItem(BookmarkItem::Folder);
root->setTitle("HTML Import");
QList<BookmarkItem*> folders;
folders.append(root);
while (start > 0) {
QString string = bookmarks.mid(start);
int posOfFolder = string.indexOf(QLatin1String("<dt><h3"));
int posOfEndFolder = string.indexOf(QLatin1String("</dl><p>"));
int posOfLink = string.indexOf(QLatin1String("<dt><a"));
int nearest = qzMin(posOfLink, qzMin(posOfFolder, posOfEndFolder));
if (nearest == -1) {
break;
}
if (nearest == posOfFolder) {
// Next is folder
QzRegExp rx("<dt><h3(.*)>(.*)</h3>");
rx.setMinimal(true);
rx.indexIn(string);
// QString arguments = rx.cap(1);
QString folderName = rx.cap(2).trimmed();
BookmarkItem* folder = new BookmarkItem(BookmarkItem::Folder, folders.isEmpty() ? root : folders.last());
folder->setTitle(folderName);
folders.append(folder);
start += posOfFolder + rx.cap(0).size();
}
else if (nearest == posOfEndFolder) {
// Next is end of folder
if (!folders.isEmpty()) {
folders.removeLast();
}
start += posOfEndFolder + 8;
}
else {
// Next is link
QzRegExp rx("<dt><a(.*)>(.*)</a>");
rx.setMinimal(true);
rx.indexIn(string);
QString arguments = rx.cap(1);
QString linkName = rx.cap(2).trimmed();
QzRegExp rx2("href=\"(.*)\"");
rx2.setMinimal(true);
rx2.indexIn(arguments);
QUrl url = QUrl::fromEncoded(rx2.cap(1).trimmed().toUtf8());
start += posOfLink + rx.cap(0).size();
if (linkName.isEmpty() || url.isEmpty() || url.scheme() == QLatin1String("place")
|| url.scheme() == QLatin1String("about")) {
continue;
}
BookmarkItem* b = new BookmarkItem(BookmarkItem::Url, folders.isEmpty() ? root : folders.last());
b->setTitle(linkName);
b->setUrl(url);
}
}
return root;
}