本文整理汇总了C++中BookmarksItem::setDragEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ BookmarksItem::setDragEnabled方法的具体用法?C++ BookmarksItem::setDragEnabled怎么用?C++ BookmarksItem::setDragEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookmarksItem
的用法示例。
在下文中一共展示了BookmarksItem::setDragEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()));
}