1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Merge pull request #1023 from jdbastardy/ieimport

added internet explorer import
This commit is contained in:
David Rosca 2013-09-10 06:41:27 -07:00
commit 655bb6ffeb
7 changed files with 126 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include "chromeimporter.h"
#include "operaimporter.h"
#include "htmlimporter.h"
#include "ieimporter.h"
#include "mainapplication.h"
#include "bookmarksimporticonfetcher.h"
#include "iconprovider.h"
@ -227,9 +228,22 @@ bool BookmarksImportDialog::exportedOK()
if (html.error()) {
QMessageBox::critical(this, tr("Error!"), html.errorString());
return false;
}
}
#ifdef Q_OS_WIN
else if (m_browser == IE) {
IeImporter ie(this);
ie.setFile(ui->fileLine->text());
if(ie.openFile()) {
m_exportedBookmarks = ie.exportBookmarks();
}
if(ie.error()) {
QMessageBox::critical(this, tr("Error!"), ie.errorString());
}
}
#endif
if (m_exportedBookmarks.isEmpty()) {
QMessageBox::critical(this, tr("Error!"), tr("The file doesn't contain any bookmark."));
return false;
@ -336,7 +350,7 @@ void BookmarksImportDialog::setupBrowser(Browser browser)
break;
case IE:
m_browserPixmap = QPixmap(":icons/browsers/ie.png");
m_browserPixmap = QPixmap(":icons/browsers/internet-explorer.png");
m_browserName = "Internet Explorer";
m_browserFileText = tr("Internet Explorer stores its bookmarks in <b>Favorites</b> folder. "
"This folder is usually located in ");

View File

@ -78,6 +78,15 @@
<normaloff>:/icons/browsers/html.png</normaloff>:/icons/browsers/html.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Internet Explorer</string>
</property>
<property name="icon">
<iconset resource="../data/icons.qrc">
<normaloff>:/icons/browsers/internet-explorer.png</normaloff>:/icons/browsers/internet-explorer.png</iconset>
</property>
</item>
</widget>
</item>
<item row="0" column="0" colspan="3">

View File

@ -0,0 +1,64 @@
#include "ieimporter.h"
#include "bookmarksimportdialog.h"
#include <QDir>
#include <QSettings>
IeImporter::IeImporter(QObject *parent) :
QObject(parent)
, m_error(false)
, m_errorString(BookmarksImportDialog::tr("No Error"))
{
}
void IeImporter::setFile(const QString &path)
{
m_path = path;
}
bool IeImporter::openFile()
{
QDir dir(m_path);
if(!dir.exists()) {
m_error = true;
m_errorString = BookmarksImportDialog::tr("Directory does not exists.");
return false;
}
QStringList filters;
filters << "*.url";
urls = dir.entryInfoList(filters);
if(urls.isEmpty()) {
m_error = true;
m_errorString = BookmarksImportDialog::tr("The directory does not contain any bookmarks.");
return false;
}
return true;
}
QVector<BookmarksModel::Bookmark> IeImporter::exportBookmarks()
{
QVector<BookmarksModel::Bookmark> bookmarks;
foreach (QFileInfo file, urls) {
QSettings urlFile(file.absoluteFilePath(), QSettings::IniFormat, this);
QUrl url = urlFile.value("InternetShortcut/URL").toUrl();
BookmarksModel::Bookmark bookmark;
bookmark.folder = "Internet Explorer Import";
bookmark.title = file.baseName();
bookmark.url = url;
bookmarks.append(bookmark);
}
return bookmarks;
}

View File

@ -0,0 +1,34 @@
#ifndef IEIMPORTER_H
#define IEIMPORTER_H
#include <QObject>
#include "qz_namespace.h"
#include "bookmarksmodel.h"
#include <QFileInfoList>
class IeImporter : public QObject
{
Q_OBJECT
public:
explicit IeImporter(QObject *parent = 0);
void setFile(const QString &path);
bool openFile();
QVector<BookmarksModel::Bookmark> exportBookmarks();
bool error() { return m_error; }
QString errorString() { return m_errorString; }
private:
bool m_error;
QString m_errorString;
QString m_path;
QFileInfoList urls;
};
#endif // IEIMPORTER_H

View File

@ -73,5 +73,6 @@
<file>icons/menu/tab.png</file>
<file>icons/other/geolocation.png</file>
<file>icons/other/notification.png</file>
<file>icons/browsers/internet-explorer.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -171,6 +171,7 @@ SOURCES += \
bookmarksimport/firefoximporter.cpp \
bookmarksimport/chromeimporter.cpp \
bookmarksimport/operaimporter.cpp \
bookmarksimport/ieimporter.cpp \
bookmarksimport/bookmarksimportdialog.cpp \
tools/iconfetcher.cpp \
tools/followredirectreply.cpp \
@ -349,6 +350,7 @@ HEADERS += \
bookmarksimport/firefoximporter.h \
bookmarksimport/chromeimporter.h \
bookmarksimport/operaimporter.h \
bookmarksimport/ieimporter.h \
bookmarksimport/bookmarksimportdialog.h \
tools/iconfetcher.h \
tools/followredirectreply.h \