本文整理汇总了C++中BookmarksItem::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ BookmarksItem::setEnabled方法的具体用法?C++ BookmarksItem::setEnabled怎么用?C++ BookmarksItem::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookmarksItem
的用法示例。
在下文中一共展示了BookmarksItem::setEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trashBookmark
void BookmarksModel::trashBookmark(BookmarksItem *bookmark)
{
if (!bookmark)
{
return;
}
const BookmarkType type = static_cast<BookmarkType>(bookmark->data(TypeRole).toInt());
if (type != RootBookmark && type != TrashBookmark)
{
if (type == SeparatorBookmark || bookmark->data(IsTrashedRole).toBool())
{
bookmark->remove();
}
else
{
BookmarksItem *trashItem = getTrashItem();
m_trash[bookmark] = qMakePair(bookmark->parent()->index(), bookmark->row());
trashItem->appendRow(bookmark->parent()->takeRow(bookmark->row()));
trashItem->setEnabled(true);
removeBookmarkUrl(bookmark);
emit bookmarkModified(bookmark);
emit bookmarkTrashed(bookmark);
emit modelModified();
}
}
}
示例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: file
BookmarksModel::BookmarksModel(const QString &path, FormatMode mode, QObject *parent) : QStandardItemModel(parent),
m_mode(mode)
{
BookmarksItem *rootItem = new BookmarksItem();
rootItem->setData(RootBookmark, TypeRole);
rootItem->setData(((mode == NotesMode) ? tr("Notes") : tr("Bookmarks")), TitleRole);
rootItem->setDragEnabled(false);
BookmarksItem *trashItem = new BookmarksItem();
trashItem->setData(TrashBookmark, TypeRole);
trashItem->setData(tr("Trash"), TitleRole);
trashItem->setDragEnabled(false);
trashItem->setEnabled(false);
appendRow(rootItem);
appendRow(trashItem);
setItemPrototype(new BookmarksItem());
QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
Console::addMessage(((mode == NotesMode) ? tr("Failed to open notes file: %1") : tr("Failed to open bookmarks file: %1")).arg(file.errorString()), OtherMessageCategory, ErrorMessageLevel, path);
return;
}
QXmlStreamReader reader(file.readAll());
if (reader.readNextStartElement() && reader.name() == QLatin1String("xbel") && reader.attributes().value(QLatin1String("version")).toString() == QLatin1String("1.0"))
{
while (reader.readNextStartElement())
{
if (reader.name() == QLatin1String("folder") || reader.name() == QLatin1String("bookmark") || reader.name() == QLatin1String("separator"))
{
readBookmark(&reader, rootItem);
}
else
{
reader.skipCurrentElement();
}
if (reader.hasError())
{
getRootItem()->removeRows(0, getRootItem()->rowCount());
Console::addMessage(((m_mode == NotesMode) ? tr("Failed to load notes file: %1") : tr("Failed to load bookmarks file: %1")).arg(reader.errorString()), OtherMessageCategory, ErrorMessageLevel, path);
QMessageBox::warning(NULL, tr("Error"), ((m_mode == NotesMode) ? tr("Failed to load notes file.") : tr("Failed to load bookmarks file.")), QMessageBox::Close);
return;
}
}
}
connect(this, SIGNAL(itemChanged(QStandardItem*)), this, SIGNAL(modelModified()));
connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(modelModified()));
connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(modelModified()));
connect(this, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SIGNAL(modelModified()));
}
示例4: emptyTrash
void BookmarksModel::emptyTrash()
{
BookmarksItem *trashItem = getTrashItem();
trashItem->removeRows(0, trashItem->rowCount());
trashItem->setEnabled(false);
m_trash.clear();
emit modelModified();
}