mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[Bookmarks] Fixed drag&drop moving folders into bookmarks toolbar
Closes #1097
This commit is contained in:
parent
b4f0096f96
commit
586982e473
|
@ -30,6 +30,7 @@ Version 1.5.0
|
|||
* fixed: enabling disabled rules in AdBlock now works everytime
|
||||
* fixed: parsing OpenSearch files with XML declaration
|
||||
* fixed: don't show urls multiple times in url completer
|
||||
* fixed: drag & drop moving folders under bookmarks toolbar
|
||||
|
||||
Version 1.4.4
|
||||
* released 1 September 2013
|
||||
|
|
|
@ -593,6 +593,10 @@ void BookmarksModel::changeBookmarkParent(int id, const QString &newParent, cons
|
|||
|
||||
void BookmarksModel::changeFolderParent(const QString &name, bool isSubfolder, bool* ok)
|
||||
{
|
||||
if (name.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("UPDATE folders SET subfolder=? WHERE name=?");
|
||||
query.bindValue(0, isSubfolder ? "yes" : "no");
|
||||
|
@ -612,7 +616,6 @@ 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)
|
||||
{
|
||||
QIcon icon = qIconProvider->iconFromImage(qvariant_cast<QImage>(imageVariant));
|
||||
|
|
|
@ -123,18 +123,24 @@ QMimeData* TreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const
|
|||
QByteArray encodedData;
|
||||
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
|
||||
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->write(stream);
|
||||
delete clonedItem;
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Why not just pass pointers ??!!
|
||||
QTreeWidgetItem* clonedItem = item->clone();
|
||||
|
||||
// #1097 Clearing icon will properly write this item into stream ...
|
||||
clonedItem->setIcon(0, QIcon());
|
||||
|
||||
bool parentIsRoot = !item->parent() || item->parent() == invisibleRootItem();
|
||||
|
||||
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(m_mimeType, encodedData);
|
||||
|
@ -171,8 +177,6 @@ bool TreeWidget::dropMimeData(QTreeWidgetItem* parent, int,
|
|||
}
|
||||
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
QSqlDatabase db = QSqlDatabase::database();
|
||||
db.transaction();
|
||||
|
||||
QByteArray ba = data->data(m_mimeType);
|
||||
QDataStream stream(&ba, QIODevice::ReadOnly);
|
||||
|
@ -180,6 +184,9 @@ bool TreeWidget::dropMimeData(QTreeWidgetItem* parent, int,
|
|||
return false;
|
||||
}
|
||||
|
||||
QSqlDatabase db = QSqlDatabase::database();
|
||||
db.transaction();
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
|
@ -202,12 +209,7 @@ bool TreeWidget::dropMimeData(QTreeWidgetItem* parent, int,
|
|||
}
|
||||
|
||||
if (isFolder) {
|
||||
if (parent->text(0) == _bookmarksToolbar) {
|
||||
emit folderParentChanged(item->text(0), true, &ok);
|
||||
}
|
||||
else {
|
||||
emit folderParentChanged(item->text(0), false, &ok);
|
||||
}
|
||||
emit folderParentChanged(item->text(0), parent->text(0) == _bookmarksToolbar, &ok);
|
||||
}
|
||||
else {
|
||||
emit bookmarkParentChanged(item->data(0, Qt::UserRole + 10).toInt(),
|
||||
|
|
Loading…
Reference in New Issue
Block a user