本文整理汇总了C++中BookmarksItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ BookmarksItem::data方法的具体用法?C++ BookmarksItem::data怎么用?C++ BookmarksItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookmarksItem
的用法示例。
在下文中一共展示了BookmarksItem::data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
QList<BookmarksItem*> BookmarksModel::findUrls(const QUrl &url, QStandardItem *branch) const
{
if (!branch)
{
branch = item(0, 0);
}
QList<BookmarksItem*> items;
for (int i = 0; i < branch->rowCount(); ++i)
{
BookmarksItem *item = dynamic_cast<BookmarksItem*>(branch->child(i));
if (item)
{
const BookmarkType type = static_cast<BookmarkType>(item->data(TypeRole).toInt());
if (type == FolderBookmark)
{
items.append(findUrls(url, item));
}
else if (type == UrlBookmark && item->data(UrlRole).toUrl() == url)
{
items.append(item);
}
}
}
return items;
}
示例2: restoreBookmark
void BookmarksModel::restoreBookmark(BookmarksItem *bookmark)
{
if (!bookmark)
{
return;
}
BookmarksItem *formerParent = (m_trash.contains(bookmark) ? getBookmark(m_trash[bookmark].first) : getRootItem());
if (!formerParent || static_cast<BookmarkType>(formerParent->data(TypeRole).toInt()) != FolderBookmark)
{
formerParent = getRootItem();
}
if (m_trash.contains(bookmark))
{
formerParent->insertRow(m_trash[bookmark].second, bookmark->parent()->takeRow(bookmark->row()));
m_trash.remove(bookmark);
}
else
{
formerParent->appendRow(bookmark->parent()->takeRow(bookmark->row()));
}
readdBookmarkUrl(bookmark);
BookmarksItem *trashItem = getTrashItem();
trashItem->setEnabled(trashItem->rowCount() > 0);
emit bookmarkModified(bookmark);
emit bookmarkRestored(bookmark);
emit modelModified();
}
示例3: flags
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
Qt::ItemFlags BookmarksModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
{ return 0; }
Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index);
BookmarksItem* item = getItem(index);
QString name = item->data(BookmarksItem::Name).toString();
if (item->data(BookmarksItem::Path).toString().isEmpty())
{
// This is a node
return (defaultFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
}
else
{
// This is a leaf
return (defaultFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
}
}
示例4: pasteNote
void WebWidget::pasteNote(QAction *action)
{
if (action && action->data().isValid())
{
BookmarksItem *note = NotesManager::getModel()->bookmarkFromIndex(action->data().toModelIndex());
if (note)
{
pasteText(note->data(BookmarksModel::DescriptionRole).toString());
}
}
}
示例5: getLastUsedFolder
BookmarksItem* BookmarksManager::getLastUsedFolder()
{
BookmarksItem *folder = getModel()->getBookmark(m_lastUsedFolder);
return ((!folder || static_cast<BookmarksModel::BookmarkType>(folder->data(BookmarksModel::TypeRole).toInt()) != BookmarksModel::FolderBookmark) ? getModel()->getRootItem() : folder);
}
示例6: data
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QVariant BookmarksModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
{
return QVariant();
}
BookmarksItem* item = getItem(index);
if (role == Qt::DisplayRole)
{
return item->data(index.column());
}
else if (role == Qt::UserRole)
{
return item->getItemHasErrors();
}
else if (role == Qt::BackgroundRole)
{
if (item->getItemHasErrors() == true)
{
return QColor(235, 110, 110);
}
else
{
return QVariant();
}
}
else if (role == Qt::ForegroundRole)
{
if (item->getItemHasErrors() == true)
{
return QColor(240, 240, 240);
}
else
{
return QColor(Qt::black);
}
}
else if (role == Qt::ToolTipRole)
{
QString tooltip = "'" + this->index(index.row(), BookmarksItem::Path, index.parent()).data().toString() + "' was not found on the file system.\nYou can either locate the file or delete the entry from the table.";
if (item->getItemHasErrors() == true)
{
return tooltip;
}
else
{
return "";
}
}
else if (role == Qt::DecorationRole)
{
QModelIndex nameIndex = this->index(index.row(), BookmarksItem::Name, index.parent());
if (nameIndex == index)
{
BookmarksItem* item = getItem(index);
return item->getIcon();
}
else
{
return QVariant();
}
}
else
{
return QVariant();
}
}
示例7: createEntry
QStandardItem* ToolBarDialog::createEntry(const QString &identifier)
{
QStandardItem *item = new QStandardItem();
item->setData(identifier, Qt::UserRole);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
if (identifier == QLatin1String("separator"))
{
item->setText(tr("--- separator ---"));
}
else if (identifier == QLatin1String("spacer"))
{
item->setText(tr("--- spacer ---"));
}
else if (identifier == QLatin1String("AddressWidget"))
{
item->setText(tr("Address Field"));
}
else if (identifier == QLatin1String("ClosedWindowsWidget"))
{
item->setText(tr("List of Closed Windows and Tabs"));
}
else if (identifier == QLatin1String("MenuBarWidget"))
{
item->setText(tr("Menu Bar"));
}
else if (identifier == QLatin1String("MenuButtonWidget"))
{
item->setText(tr("Menu Button"));
}
else if (identifier == QLatin1String("PanelChooserWidget"))
{
item->setText(tr("Sidebar Panel Chooser"));
}
else if (identifier == QLatin1String("SearchWidget"))
{
item->setText(tr("Search Field"));
}
else if (identifier == QLatin1String("StatusMessageWidget"))
{
item->setText(tr("Status Message Field"));
}
else if (identifier == QLatin1String("TabBarWidget"))
{
item->setText(tr("Tab Bar"));
}
else if (identifier == QLatin1String("ZoomWidget"))
{
item->setText(tr("Zoom Slider"));
}
else if (identifier.startsWith(QLatin1String("bookmarks:")))
{
BookmarksItem *bookmark = (identifier.startsWith(QLatin1String("bookmarks:/")) ? BookmarksManager::getModel()->getItem(identifier.mid(11)) : BookmarksManager::getBookmark(identifier.mid(10).toULongLong()));
if (bookmark)
{
item->setText(bookmark->data(BookmarksModel::TitleRole).isValid() ? bookmark->data(BookmarksModel::TitleRole).toString() : tr("(Untitled)"));
item->setIcon(bookmark->data(Qt::DecorationRole).value<QIcon>());
}
else
{
item->setText(tr("Invalid Bookmark"));
}
}
else if (identifier.endsWith(QLatin1String("Action")))
{
const int actionIdentifier = ActionsManager::getActionIdentifier(identifier.left(identifier.length() - 6));
if (actionIdentifier < 0)
{
item->setText(tr("Invalid Entry"));
}
else
{
const ActionDefinition definition = ActionsManager::getActionDefinition(actionIdentifier);
item->setText(QCoreApplication::translate("actions", (definition.description.isEmpty() ? definition.text : definition.description).toUtf8().constData()));
item->setIcon(definition.icon);
}
}
else
{
item->setText(tr("Invalid Entry"));
}
return item;
}