mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[BookmarksImport] Show full structure of imported bookmarks
BookmarksModel can now be used with arbitrary root item independently of main bookmarks root item.
This commit is contained in:
parent
167e80f59a
commit
23b55d9158
@ -272,7 +272,7 @@ void Bookmarks::init()
|
||||
}
|
||||
|
||||
m_lastFolder = m_folderUnsorted;
|
||||
m_model = new BookmarksModel(this, this);
|
||||
m_model = new BookmarksModel(m_root, this, this);
|
||||
}
|
||||
|
||||
void Bookmarks::loadBookmarks()
|
||||
|
@ -30,11 +30,14 @@
|
||||
#include "modeltest.h"
|
||||
#endif
|
||||
|
||||
BookmarksModel::BookmarksModel(Bookmarks* bookmarks, QObject* parent)
|
||||
BookmarksModel::BookmarksModel(BookmarkItem* root, Bookmarks* bookmarks, QObject* parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_root(root)
|
||||
, m_bookmarks(bookmarks)
|
||||
{
|
||||
if (m_bookmarks) {
|
||||
connect(m_bookmarks, SIGNAL(bookmarkChanged(BookmarkItem*)), this, SLOT(bookmarkChanged(BookmarkItem*)));
|
||||
}
|
||||
|
||||
#ifdef BOOKMARKSMODEL_DEBUG
|
||||
new ModelTest(this, this);
|
||||
@ -79,7 +82,7 @@ Qt::ItemFlags BookmarksModel::flags(const QModelIndex &index) const
|
||||
flags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
if (m_bookmarks->canBeModified(itm)) {
|
||||
if (m_bookmarks && m_bookmarks->canBeModified(itm)) {
|
||||
flags |= Qt::ItemIsDragEnabled;
|
||||
}
|
||||
|
||||
@ -215,7 +218,7 @@ bool BookmarksModel::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!data->hasFormat(MIMETYPE) || !parent.isValid()) {
|
||||
if (!m_bookmarks || !data->hasFormat(MIMETYPE) || !parent.isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -294,7 +297,7 @@ QModelIndex BookmarksModel::index(BookmarkItem* item, int column) const
|
||||
BookmarkItem* BookmarksModel::item(const QModelIndex &index) const
|
||||
{
|
||||
BookmarkItem* itm = static_cast<BookmarkItem*>(index.internalPointer());
|
||||
return itm ? itm : m_bookmarks->rootItem();
|
||||
return itm ? itm : m_root;
|
||||
}
|
||||
|
||||
void BookmarksModel::bookmarkChanged(BookmarkItem* item)
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
MaxRole = SidebarExpandedRole
|
||||
};
|
||||
|
||||
explicit BookmarksModel(Bookmarks* bookmarks, QObject* parent = 0);
|
||||
explicit BookmarksModel(BookmarkItem* root, Bookmarks* bookmarks, QObject* parent = 0);
|
||||
|
||||
void addBookmark(BookmarkItem* parent, int row, BookmarkItem* item);
|
||||
void removeBookmark(BookmarkItem* item);
|
||||
@ -73,6 +73,7 @@ private slots:
|
||||
void bookmarkChanged(BookmarkItem* item);
|
||||
|
||||
private:
|
||||
BookmarkItem* m_root;
|
||||
Bookmarks* m_bookmarks;
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "htmlimporter.h"
|
||||
#include "ieimporter.h"
|
||||
#include "bookmarkitem.h"
|
||||
#include "bookmarksmodel.h"
|
||||
#include "mainapplication.h"
|
||||
#include "iconprovider.h"
|
||||
#include "qztools.h"
|
||||
@ -168,22 +169,9 @@ void BookmarksImportDialog::showExportedBookmarks()
|
||||
{
|
||||
ui->nextButton->setText(tr("Finish"));
|
||||
|
||||
QTreeWidgetItem* root = new QTreeWidgetItem(ui->treeWidget);
|
||||
root->setText(0, m_exportedFolder->title());
|
||||
root->setIcon(0, m_exportedFolder->icon());
|
||||
ui->treeWidget->addTopLevelItem(root);
|
||||
|
||||
foreach (BookmarkItem* b, m_exportedFolder->children()) {
|
||||
// TODO: Multi-level bookmarks
|
||||
if (b->isUrl()) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(root);
|
||||
item->setText(0, b->title());
|
||||
item->setIcon(0, b->icon());
|
||||
item->setText(1, b->urlString());
|
||||
}
|
||||
}
|
||||
|
||||
ui->treeWidget->expandAll();
|
||||
ui->treeView->setModel(new BookmarksModel(m_exportedFolder, 0, this));
|
||||
ui->treeView->header()->resizeSection(0, ui->treeView->header()->width() / 2);
|
||||
ui->treeView->expandAll();
|
||||
}
|
||||
|
||||
void BookmarksImportDialog::setFile()
|
||||
|
@ -110,6 +110,16 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="filePage">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="importingFromLabel"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="standardDirLabel">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="fileText1">
|
||||
<property name="wordWrap">
|
||||
@ -117,11 +127,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QLabel" name="fileText2"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
@ -164,13 +187,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="standardDirLabel">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="iconLabel">
|
||||
<property name="minimumSize">
|
||||
@ -187,51 +203,15 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="importingFromLabel"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="fetchIcons">
|
||||
<property name="text">
|
||||
<string>Try to fetch icons for all bookmarks (may take a while)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="finalPage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treeWidget">
|
||||
<attribute name="headerMinimumSectionSize">
|
||||
<number>220</number>
|
||||
<widget class="QTreeView" name="treeView">
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Url</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user