mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Fixed crash when dragging bookmark from manager to sidebar
This commit is contained in:
parent
3aba5ac7a0
commit
5a3f4e5f4d
|
@ -48,8 +48,8 @@ BookmarksManager::BookmarksManager(QupZilla* mainClass, QWidget* parent)
|
|||
ui->setupUi(this);
|
||||
|
||||
ui->bookmarksTree->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
ui->bookmarksTree->setSelectionMode(QAbstractItemView::ContiguousSelection);
|
||||
ui->bookmarksTree->setDragDropReceiver(true, m_bookmarksModel);
|
||||
ui->bookmarksTree->setMimeType(QLatin1String("application/qupzilla.treewidgetitem.bookmarks"));
|
||||
|
||||
connect(ui->bookmarksTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*)));
|
||||
connect(ui->addFolder, SIGNAL(clicked()), this, SLOT(addFolder()));
|
||||
|
@ -64,8 +64,8 @@ BookmarksManager::BookmarksManager(QupZilla* mainClass, QWidget* parent)
|
|||
connect(m_bookmarksModel, SIGNAL(folderAdded(QString)), this, SLOT(addFolder(QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(removeFolder(QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderRenamed(QString, QString)), this, SLOT(renameFolder(QString, QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString,bool)), this, SLOT(changeFolderParent(QString,bool)));
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString,QByteArray,int,QUrl,QString,QString)), this, SLOT(changeBookmarkParent(QString,QByteArray,int,QUrl,QString,QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString, bool)), this, SLOT(changeFolderParent(QString, bool)));
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString, QByteArray, int, QUrl, QString, QString)), this, SLOT(changeBookmarkParent(QString, QByteArray, int, QUrl, QString, QString)));
|
||||
|
||||
connect(ui->optimizeDb, SIGNAL(clicked(QPoint)), this, SLOT(optimizeDb()));
|
||||
connect(ui->importBookmarks, SIGNAL(clicked(QPoint)), this, SLOT(importBookmarks()));
|
||||
|
@ -328,13 +328,13 @@ void BookmarksManager::refreshTable()
|
|||
QTreeWidgetItem* newItem = new QTreeWidgetItem(ui->bookmarksTree);
|
||||
newItem->setText(0, _bookmarksMenu);
|
||||
newItem->setIcon(0, style()->standardIcon(QStyle::SP_DirIcon));
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
newItem->setFlags((newItem->flags() & ~Qt::ItemIsDragEnabled) | Qt::ItemIsDropEnabled);
|
||||
ui->bookmarksTree->addTopLevelItem(newItem);
|
||||
|
||||
QTreeWidgetItem* bookmarksToolbar = new QTreeWidgetItem(ui->bookmarksTree);
|
||||
bookmarksToolbar->setText(0, _bookmarksToolbar);
|
||||
bookmarksToolbar->setIcon(0, style()->standardIcon(QStyle::SP_DirIcon));
|
||||
bookmarksToolbar->setFlags(bookmarksToolbar->flags() & ~Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
bookmarksToolbar->setFlags((bookmarksToolbar->flags() & ~Qt::ItemIsDragEnabled) | Qt::ItemIsDropEnabled);
|
||||
ui->bookmarksTree->addTopLevelItem(bookmarksToolbar);
|
||||
|
||||
query.exec("SELECT name FROM folders WHERE subfolder!='yes'");
|
||||
|
@ -529,12 +529,12 @@ void BookmarksManager::bookmarkEdited(const BookmarksModel::Bookmark &before, co
|
|||
}
|
||||
|
||||
void BookmarksManager::changeBookmarkParent(const QString &name, const QByteArray &, int id,
|
||||
const QUrl &, const QString &, const QString &newParent)
|
||||
const QUrl &, const QString &, const QString &newParent)
|
||||
{
|
||||
QList<QTreeWidgetItem*> list = ui->bookmarksTree->findItems(name, Qt::MatchExactly | Qt::MatchRecursive);
|
||||
|
||||
QTreeWidgetItem* item = 0;
|
||||
foreach (item, list) {
|
||||
foreach(item, list) {
|
||||
if (id == item->data(0, Qt::UserRole + 10).toInt()) {
|
||||
break;
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ void BookmarksManager::addFolder(const QString &name)
|
|||
item->setFlags(item->flags() | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
}
|
||||
else {
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
item->setFlags((item->flags() & ~Qt::ItemIsDragEnabled) | Qt::ItemIsDropEnabled);
|
||||
}
|
||||
|
||||
m_isRefreshing = false;
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ContiguousSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
@ -617,7 +617,7 @@ void BookmarksModel::changeFolderParent(const QString &name, bool isSubfolder, b
|
|||
}
|
||||
|
||||
|
||||
void BookmarksModel::bookmarkDropedLink(const QUrl &url, const QString &title, const QVariant &imageVariant, const QString &folder, bool *ok)
|
||||
void BookmarksModel::bookmarkDropedLink(const QUrl &url, const QString &title, const QVariant &imageVariant, const QString &folder, bool* ok)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
|
|||
connect(m_bookmarksModel, SIGNAL(subfolderAdded(QString)), this, SLOT(subfolderAdded(QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(folderDeleted(QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderRenamed(QString, QString)), this, SLOT(folderRenamed(QString, QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString,bool)), this, SLOT(changeFolderParent(QString,bool)));
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString,QByteArray,int,QUrl,QString,QString)), this, SLOT(changeBookmarkParent(QString,QByteArray,int,QUrl,QString,QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString, bool)), this, SLOT(changeFolderParent(QString, bool)));
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString, QByteArray, int, QUrl, QString, QString)), this, SLOT(changeBookmarkParent(QString, QByteArray, int, QUrl, QString, QString)));
|
||||
|
||||
setMaximumWidth(p_QupZilla->width());
|
||||
|
||||
|
@ -390,7 +390,7 @@ void BookmarksToolbar::folderRenamed(const QString &before, const QString &after
|
|||
}
|
||||
|
||||
void BookmarksToolbar::changeBookmarkParent(const QString &name, const QByteArray &imageData, int id,
|
||||
const QUrl &url, const QString &oldParent, const QString &newParent)
|
||||
const QUrl &url, const QString &oldParent, const QString &newParent)
|
||||
{
|
||||
if (oldParent != _bookmarksToolbar && newParent != _bookmarksToolbar) {
|
||||
return;
|
||||
|
|
|
@ -42,8 +42,8 @@ BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent)
|
|||
ui->setupUi(this);
|
||||
|
||||
ui->bookmarksTree->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
ui->bookmarksTree->setSelectionMode(QAbstractItemView::ContiguousSelection);
|
||||
ui->bookmarksTree->setDragDropReceiver(true, m_bookmarksModel);
|
||||
ui->bookmarksTree->setMimeType(QLatin1String("application/qupzilla.treewidgetitem.bookmarks"));
|
||||
|
||||
ui->bookmarksTree->setDefaultItemShowMode(TreeWidget::ItemsExpanded);
|
||||
connect(ui->bookmarksTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
|
@ -58,8 +58,8 @@ BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent)
|
|||
connect(m_bookmarksModel, SIGNAL(folderAdded(QString)), this, SLOT(addFolder(QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(removeFolder(QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderRenamed(QString, QString)), this, SLOT(renameFolder(QString, QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString,bool)), this, SLOT(changeFolderParent(QString,bool)));
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString,QByteArray,int,QUrl,QString,QString)), this, SLOT(changeBookmarkParent(QString,QByteArray,int,QUrl,QString,QString)));
|
||||
connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString, bool)), this, SLOT(changeFolderParent(QString, bool)));
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString, QByteArray, int, QUrl, QString, QString)), this, SLOT(changeBookmarkParent(QString, QByteArray, int, QUrl, QString, QString)));
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(refreshTable()));
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ void BookmarksSideBar::addFolder(const QString &name)
|
|||
item->setFlags(item->flags() | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
}
|
||||
else {
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
item->setFlags((item->flags() & ~Qt::ItemIsDragEnabled) | Qt::ItemIsDropEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ void BookmarksSideBar::renameFolder(const QString &before, const QString &after)
|
|||
}
|
||||
|
||||
void BookmarksSideBar::changeBookmarkParent(const QString &name, const QByteArray &imageData, int id,
|
||||
const QUrl &url, const QString &oldParent, const QString &newParent)
|
||||
const QUrl &url, const QString &oldParent, const QString &newParent)
|
||||
{
|
||||
if (!newParent.isEmpty() && newParent != QLatin1String("unsorted")
|
||||
&& newParent != _bookmarksUnsorted && !oldParent.isEmpty()
|
||||
|
@ -267,7 +267,7 @@ void BookmarksSideBar::changeBookmarkParent(const QString &name, const QByteArra
|
|||
QList<QTreeWidgetItem*> list = ui->bookmarksTree->findItems(name, Qt::MatchExactly | Qt::MatchRecursive);
|
||||
|
||||
QTreeWidgetItem* item = 0;
|
||||
foreach (item, list) {
|
||||
foreach(item, list) {
|
||||
if (id == item->data(0, Qt::UserRole + 10).toInt()) {
|
||||
break;
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ void BookmarksSideBar::changeFolderParent(const QString &name, bool isSubfolder)
|
|||
else {
|
||||
addFolder(name);
|
||||
QList<Bookmark> bookmarksList = m_bookmarksModel->folderBookmarks(name);
|
||||
foreach (const Bookmark & b, bookmarksList) {
|
||||
foreach(const Bookmark & b, bookmarksList) {
|
||||
addBookmark(b);
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ void BookmarksSideBar::refreshTable()
|
|||
QTreeWidgetItem* newItem = new QTreeWidgetItem(ui->bookmarksTree);
|
||||
newItem->setText(0, _bookmarksMenu);
|
||||
newItem->setIcon(0, style()->standardIcon(QStyle::SP_DirIcon));
|
||||
newItem->setFlags(newItem->flags() & ~Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||
newItem->setFlags((newItem->flags() & ~Qt::ItemIsDragEnabled) | Qt::ItemIsDropEnabled);
|
||||
ui->bookmarksTree->addTopLevelItem(newItem);
|
||||
|
||||
query.exec("SELECT name FROM folders WHERE subfolder!='yes'");
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ContiguousSelection</enum>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <QApplication>
|
||||
#include <QUrl>
|
||||
|
||||
const int ITEM_IS_TOPLEVEL = Qt::UserRole+20;
|
||||
const int ITEM_PARENT_TITLE = Qt::UserRole+21;
|
||||
const int ITEM_IS_TOPLEVEL = Qt::UserRole + 20;
|
||||
const int ITEM_PARENT_TITLE = Qt::UserRole + 21;
|
||||
|
||||
TreeWidget::TreeWidget(QWidget* parent)
|
||||
: QTreeWidget(parent)
|
||||
|
@ -99,6 +99,11 @@ void TreeWidget::iterateAllItems(QTreeWidgetItem* parent)
|
|||
}
|
||||
}
|
||||
|
||||
void TreeWidget::setMimeType(const QString &mimeType)
|
||||
{
|
||||
m_mimeType = mimeType;
|
||||
}
|
||||
|
||||
Qt::DropActions TreeWidget::supportedDropActions()
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
|
@ -107,36 +112,36 @@ Qt::DropActions TreeWidget::supportedDropActions()
|
|||
QStringList TreeWidget::mimeTypes() const
|
||||
{
|
||||
QStringList types;
|
||||
types << QLatin1String("application/qupzilla.treewidgetitem.list");
|
||||
types << m_mimeType;
|
||||
return types;
|
||||
}
|
||||
|
||||
QMimeData *TreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
|
||||
QMimeData* TreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const
|
||||
{
|
||||
QMimeData *data = new QMimeData();
|
||||
QMimeData* data = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
foreach (const QTreeWidgetItem* item, items) {
|
||||
foreach(const QTreeWidgetItem * item, items) {
|
||||
if (item) {
|
||||
QTreeWidgetItem* clonedItem = item->clone();
|
||||
bool parentIsRoot = false;
|
||||
if (!item->parent() || item->parent() == invisibleRootItem()) {
|
||||
parentIsRoot = true;
|
||||
}
|
||||
clonedItem->setData(0, ITEM_IS_TOPLEVEL, parentIsRoot );
|
||||
clonedItem->setData(0, ITEM_PARENT_TITLE, (parentIsRoot ? QString() : item->parent()->text(0)) ) ;
|
||||
clonedItem->setData(0, ITEM_IS_TOPLEVEL, parentIsRoot);
|
||||
clonedItem->setData(0, ITEM_PARENT_TITLE, (parentIsRoot ? QString() : item->parent()->text(0))) ;
|
||||
clonedItem->write(stream);
|
||||
delete clonedItem;
|
||||
}
|
||||
}
|
||||
|
||||
data->setData(QLatin1String("application/qupzilla.treewidgetitem.list"), encodedData);
|
||||
data->setData(m_mimeType, encodedData);
|
||||
return data;
|
||||
}
|
||||
|
||||
bool TreeWidget::dropMimeData(QTreeWidgetItem *parent, int,
|
||||
const QMimeData *data, Qt::DropAction action)
|
||||
bool TreeWidget::dropMimeData(QTreeWidgetItem* parent, int,
|
||||
const QMimeData* data, Qt::DropAction action)
|
||||
{
|
||||
if (action == Qt::IgnoreAction) {
|
||||
return true;
|
||||
|
@ -154,41 +159,43 @@ bool TreeWidget::dropMimeData(QTreeWidgetItem *parent, int,
|
|||
if (data->hasUrls()) {
|
||||
QString folder = (parent == invisibleRootItem()) ? QLatin1String("unsorted") : parent->text(0);
|
||||
QUrl url = data->urls().at(0);
|
||||
QString title = data->text().isEmpty() ? url.host()+url.path() : data->text();
|
||||
QString title = data->text().isEmpty() ? url.host() + url.path() : data->text();
|
||||
emit linkWasDroped(url, title, data->imageData(), folder, &ok);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
if (!data->hasFormat(QLatin1String("application/qupzilla.treewidgetitem.list")))
|
||||
if (!data->hasFormat(m_mimeType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
QSqlDatabase db = QSqlDatabase::database();
|
||||
db.transaction();
|
||||
|
||||
QByteArray ba = data->data(QLatin1String("application/qupzilla.treewidgetitem.list"));
|
||||
QByteArray ba = data->data(m_mimeType);
|
||||
QDataStream stream(&ba, QIODevice::ReadOnly);
|
||||
if (stream.atEnd())
|
||||
if (stream.atEnd()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||
item->read(stream);
|
||||
bool parentIsRoot = item->data(0, ITEM_IS_TOPLEVEL).toBool();
|
||||
QString oldParentTitle = item->data(0, ITEM_PARENT_TITLE).toString();
|
||||
|
||||
bool isFolder = (item && item->text(1).isEmpty());
|
||||
if (isFolder && (item->text(0) == _bookmarksMenu ||
|
||||
item->text(0) == _bookmarksToolbar)) {
|
||||
item->text(0) == _bookmarksToolbar)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool parentIsOldParent = parentIsRoot ? (parent == invisibleRootItem()) : (oldParentTitle == parent->text(0));
|
||||
if ( parentIsOldParent || (isFolder && parent != invisibleRootItem() &&
|
||||
parent->text(0) != _bookmarksToolbar) ) {
|
||||
if (parentIsOldParent || (isFolder && parent != invisibleRootItem() &&
|
||||
parent->text(0) != _bookmarksToolbar)) {
|
||||
// just 'Bookmarks In ToolBar' folder can have subfolders
|
||||
continue;
|
||||
}
|
||||
|
@ -218,11 +225,11 @@ bool TreeWidget::dropMimeData(QTreeWidgetItem *parent, int,
|
|||
return true;
|
||||
}
|
||||
|
||||
void TreeWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||
void TreeWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
const QMimeData* mimeData = event->mimeData();
|
||||
QTreeWidget::dragEnterEvent(event);
|
||||
if (mimeData->hasUrls() || mimeData->hasFormat(QLatin1String("application/qupzilla.treewidgetitem.list"))) {
|
||||
if (mimeData->hasUrls() || mimeData->hasFormat(m_mimeType)) {
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
else {
|
||||
|
@ -230,26 +237,30 @@ void TreeWidget::dragEnterEvent(QDragEnterEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void TreeWidget::dragMoveEvent(QDragMoveEvent *event)
|
||||
void TreeWidget::dragMoveEvent(QDragMoveEvent* event)
|
||||
{
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
const QMimeData* mimeData = event->mimeData();
|
||||
bool accept = false;
|
||||
if (mimeData->hasUrls()) {
|
||||
accept = true;
|
||||
}
|
||||
else if (mimeData->hasFormat(QLatin1String("application/qupzilla.treewidgetitem.list"))) {
|
||||
QTreeWidgetItem *itemUnderMouse = itemAt(event->pos());
|
||||
else if (mimeData->hasFormat(m_mimeType)) {
|
||||
QTreeWidgetItem* itemUnderMouse = itemAt(event->pos());
|
||||
if (!itemUnderMouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool underMouseIsFolder = (itemUnderMouse && itemUnderMouse->text(1).isEmpty());
|
||||
int top = visualItemRect(itemUnderMouse).top();
|
||||
int bottom = visualItemRect(itemUnderMouse).bottom();
|
||||
int y = event->pos().y();
|
||||
bool overEdgeOfItem = (y >= top-1 && y <= top+1) || (y <= bottom+1 && y >= bottom-1);
|
||||
bool overEdgeOfItem = (y >= top - 1 && y <= top + 1) || (y <= bottom + 1 && y >= bottom - 1);
|
||||
|
||||
QByteArray ba = mimeData->data(QLatin1String("application/qupzilla.treewidgetitem.list"));
|
||||
QByteArray ba = mimeData->data(m_mimeType);
|
||||
QDataStream stream(&ba, QIODevice::ReadOnly);
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
QTreeWidgetItem *dragItem = new QTreeWidgetItem;
|
||||
QTreeWidgetItem* dragItem = new QTreeWidgetItem;
|
||||
dragItem->read(stream);
|
||||
bool parentIsRoot = dragItem->data(0, ITEM_IS_TOPLEVEL).toBool();
|
||||
QString oldParentTitle = dragItem->data(0, ITEM_PARENT_TITLE).toString();
|
||||
|
@ -262,11 +273,11 @@ void TreeWidget::dragMoveEvent(QDragMoveEvent *event)
|
|||
break;
|
||||
}
|
||||
bool parentsAreDifferent = parentIsRoot
|
||||
? itemUnderMouse->parent()
|
||||
: (!itemUnderMouse->parent() || itemUnderMouse->parent()->text(0) != oldParentTitle);
|
||||
? itemUnderMouse->parent() != 0
|
||||
: (!itemUnderMouse->parent() || itemUnderMouse->parent()->text(0) != oldParentTitle);
|
||||
bool canHasSubFolder = !itemUnderMouse->parent()
|
||||
|| itemUnderMouse->parent() == invisibleRootItem()
|
||||
|| itemUnderMouse->parent()->text(0) == _bookmarksToolbar;
|
||||
|| itemUnderMouse->parent() == invisibleRootItem()
|
||||
|| itemUnderMouse->parent()->text(0) == _bookmarksToolbar;
|
||||
|
||||
if (!underMouseIsFolder && parentsAreDifferent) {
|
||||
if (!itemIsFolder) {
|
||||
|
@ -274,8 +285,8 @@ void TreeWidget::dragMoveEvent(QDragMoveEvent *event)
|
|||
break;
|
||||
}
|
||||
else if (!itemUnderMouse->parent()
|
||||
|| dragItem->text(0) != itemUnderMouse->parent()->text(0)
|
||||
&& canHasSubFolder) {
|
||||
|| (dragItem->text(0) != itemUnderMouse->parent()->text(0)
|
||||
&& canHasSubFolder)) {
|
||||
accept = true;
|
||||
break;
|
||||
}
|
||||
|
@ -445,13 +456,13 @@ void TreeWidget::setDragDropReceiver(bool enable, QObject* receiver)
|
|||
setDropIndicatorShown(enable);
|
||||
if (enable) {
|
||||
model()->setSupportedDragActions(Qt::CopyAction);
|
||||
connect(this, SIGNAL(folderParentChanged(QString,bool,bool*)), receiver, SLOT(changeFolderParent(QString,bool,bool*)));
|
||||
connect(this, SIGNAL(bookmarkParentChanged(int,QString,QString,bool*)), receiver, SLOT(changeBookmarkParent(int,QString,QString,bool*)));
|
||||
connect(this, SIGNAL(linkWasDroped(QUrl,QString,QVariant,QString,bool*)), receiver, SLOT(bookmarkDropedLink(QUrl,QString,QVariant,QString,bool*)));
|
||||
connect(this, SIGNAL(folderParentChanged(QString, bool, bool*)), receiver, SLOT(changeFolderParent(QString, bool, bool*)));
|
||||
connect(this, SIGNAL(bookmarkParentChanged(int, QString, QString, bool*)), receiver, SLOT(changeBookmarkParent(int, QString, QString, bool*)));
|
||||
connect(this, SIGNAL(linkWasDroped(QUrl, QString, QVariant, QString, bool*)), receiver, SLOT(bookmarkDropedLink(QUrl, QString, QVariant, QString, bool*)));
|
||||
}
|
||||
else {
|
||||
disconnect(this, SIGNAL(folderParentChanged(QString,bool,bool*)), receiver, SLOT(changeFolderParent(QString,bool,bool*)));
|
||||
disconnect(this, SIGNAL(bookmarkParentChanged(int,QString,QString,bool*)), receiver, SLOT(changeBookmarkParent(int,QString,QString,bool*)));
|
||||
disconnect(this, SIGNAL(linkWasDroped(QUrl,QString,QVariant,QString,bool*)), receiver, SLOT(bookmarkDropedLink(QUrl,QString,QVariant,QString,bool*)));
|
||||
disconnect(this, SIGNAL(folderParentChanged(QString, bool, bool*)), receiver, SLOT(changeFolderParent(QString, bool, bool*)));
|
||||
disconnect(this, SIGNAL(bookmarkParentChanged(int, QString, QString, bool*)), receiver, SLOT(changeBookmarkParent(int, QString, QString, bool*)));
|
||||
disconnect(this, SIGNAL(linkWasDroped(QUrl, QString, QVariant, QString, bool*)), receiver, SLOT(bookmarkDropedLink(QUrl, QString, QVariant, QString, bool*)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
void deleteItems(const QList<QTreeWidgetItem*> &items);
|
||||
|
||||
void setDragDropReceiver(bool enable, QObject* receiver = 0);
|
||||
void setMimeType(const QString &mimeType);
|
||||
|
||||
signals:
|
||||
void itemControlClicked(QTreeWidgetItem* item);
|
||||
|
@ -66,15 +67,15 @@ private:
|
|||
|
||||
Qt::DropActions supportedDropActions();
|
||||
QStringList mimeTypes() const;
|
||||
QMimeData *mimeData(const QList<QTreeWidgetItem *> items) const;
|
||||
bool dropMimeData(QTreeWidgetItem *parent, int, const QMimeData *data, Qt::DropAction action);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const;
|
||||
bool dropMimeData(QTreeWidgetItem* parent, int, const QMimeData* data, Qt::DropAction action);
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dragMoveEvent(QDragMoveEvent* event);
|
||||
|
||||
bool m_refreshAllItemsNeeded;
|
||||
QList<QTreeWidgetItem*> m_allTreeItems;
|
||||
ItemShowMode m_showMode;
|
||||
|
||||
QString m_mimeType;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKSTREEWIDGET_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user