mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Fix Internet Explorer Bookmarks Importer
It is now possible to select the whole Favorites folder and it will now also import all subfolder structure. Closes #1475
This commit is contained in:
parent
52f3811916
commit
6cb8717fd6
@ -41,7 +41,7 @@ QString IeImporter::standardPath() const
|
||||
|
||||
QString IeImporter::getPath(QWidget* parent)
|
||||
{
|
||||
m_path = QFileDialog::getOpenFileName(parent, BookmarksImporter::tr("Choose file..."), standardPath());
|
||||
m_path = QFileDialog::getExistingDirectory(parent, BookmarksImporter::tr("Choose file..."), standardPath());
|
||||
return m_path;
|
||||
}
|
||||
|
||||
@ -53,16 +53,6 @@ bool IeImporter::prepareImport()
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList filters;
|
||||
filters << "*.url";
|
||||
|
||||
urls = dir.entryInfoList(filters);
|
||||
|
||||
if (urls.isEmpty()) {
|
||||
setError(BookmarksImporter::tr("The directory does not contain any bookmarks."));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -71,15 +61,28 @@ BookmarkItem* IeImporter::importBookmarks()
|
||||
BookmarkItem* root = new BookmarkItem(BookmarkItem::Folder);
|
||||
root->setTitle("Internet Explorer Import");
|
||||
|
||||
foreach (QFileInfo file, urls) {
|
||||
QSettings urlFile(file.absoluteFilePath(), QSettings::IniFormat, this);
|
||||
|
||||
QUrl url = urlFile.value("InternetShortcut/URL").toUrl();
|
||||
|
||||
BookmarkItem* b = new BookmarkItem(BookmarkItem::Url, root);
|
||||
b->setTitle(file.baseName());
|
||||
b->setUrl(url);
|
||||
}
|
||||
|
||||
readDir(QDir(m_path), root);
|
||||
return root;
|
||||
}
|
||||
|
||||
void IeImporter::readDir(const QDir &dir, BookmarkItem *parent)
|
||||
{
|
||||
foreach (const QFileInfo &file, dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
|
||||
if (file.isDir()) {
|
||||
BookmarkItem* folder = new BookmarkItem(BookmarkItem::Folder, parent);
|
||||
folder->setTitle(file.baseName());
|
||||
|
||||
QDir folderDir = dir;
|
||||
folderDir.cd(file.baseName());
|
||||
readDir(folderDir, folder);
|
||||
}
|
||||
else if (file.isFile()) {
|
||||
QSettings urlFile(file.absoluteFilePath(), QSettings::IniFormat);
|
||||
const QUrl url = urlFile.value("InternetShortcut/URL").toUrl();
|
||||
|
||||
BookmarkItem* item = new BookmarkItem(BookmarkItem::Url, parent);
|
||||
item->setTitle(file.baseName());
|
||||
item->setUrl(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,9 @@ public:
|
||||
BookmarkItem* importBookmarks();
|
||||
|
||||
private:
|
||||
void readDir(const QDir &dir, BookmarkItem* parent);
|
||||
|
||||
QString m_path;
|
||||
QFileInfoList urls;
|
||||
};
|
||||
|
||||
#endif // IEIMPORTER_H
|
||||
|
Loading…
Reference in New Issue
Block a user