1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

[BookmarksImport] Added back button to import dialog + other small changes

Also moved all bookmarks import classes to bookmarks/bookmarksimport
This commit is contained in:
nowrep 2014-02-15 01:49:12 +01:00
parent 09893f20b4
commit 5301495966
21 changed files with 200 additions and 127 deletions

View File

@ -54,7 +54,7 @@
#include "navigationbar.h" #include "navigationbar.h"
#include "pagescreen.h" #include "pagescreen.h"
#include "webinspectordockwidget.h" #include "webinspectordockwidget.h"
#include "bookmarksimportdialog.h" #include "bookmarksimport/bookmarksimportdialog.h"
#include "qztools.h" #include "qztools.h"
#include "actioncopy.h" #include "actioncopy.h"
#include "reloadstopbutton.h" #include "reloadstopbutton.h"

View File

@ -17,11 +17,11 @@
* ============================================================ */ * ============================================================ */
#include "bookmarksimportdialog.h" #include "bookmarksimportdialog.h"
#include "ui_bookmarksimportdialog.h" #include "ui_bookmarksimportdialog.h"
#include "import/firefoximporter.h" #include "bookmarksimport/firefoximporter.h"
#include "import/chromeimporter.h" #include "bookmarksimport/chromeimporter.h"
#include "import/operaimporter.h" #include "bookmarksimport/operaimporter.h"
#include "import/htmlimporter.h" #include "bookmarksimport/htmlimporter.h"
#include "import/ieimporter.h" #include "bookmarksimport/ieimporter.h"
#include "bookmarks.h" #include "bookmarks.h"
#include "bookmarkitem.h" #include "bookmarkitem.h"
#include "bookmarksmodel.h" #include "bookmarksmodel.h"
@ -35,6 +35,7 @@ BookmarksImportDialog::BookmarksImportDialog(QWidget* parent)
, m_currentPage(0) , m_currentPage(0)
, m_importer(0) , m_importer(0)
, m_importedFolder(0) , m_importedFolder(0)
, m_model(0)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this); ui->setupUi(this);
@ -42,17 +43,21 @@ BookmarksImportDialog::BookmarksImportDialog(QWidget* parent)
ui->browserList->setCurrentRow(0); ui->browserList->setCurrentRow(0);
connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextPage())); connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextPage()));
connect(ui->backButton, SIGNAL(clicked()), this, SLOT(previousPage()));
connect(ui->chooseFile, SIGNAL(clicked()), this, SLOT(setFile())); connect(ui->chooseFile, SIGNAL(clicked()), this, SLOT(setFile()));
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close())); connect(ui->cancelButton, SIGNAL(rejected()), this, SLOT(close()));
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
ui->browserList->setItemHidden(ui->browserList->item(IE), true); ui->browserList->setItemHidden(ui->browserList->item(IE), true);
#endif #endif
} }
BookmarksImportDialog::~BookmarksImportDialog() BookmarksImportDialog::~BookmarksImportDialog()
{ {
ui->treeView->setModel(0);
delete m_model;
delete m_importedFolder;
delete m_importer;
delete ui; delete ui;
} }
@ -85,11 +90,11 @@ void BookmarksImportDialog::nextPage()
break; break;
} }
ui->iconLabel->setPixmap(ui->browserList->currentItem()->icon().pixmap(48)); ui->fileLine->clear();
ui->importingFromLabel->setText(tr("<b>Importing from %1</b>").arg(ui->browserList->currentItem()->text())); showImporterPage();
ui->fileText1->setText(m_importer->description());
ui->standardDirLabel->setText(QString("<i>%1</i>").arg(m_importer->standardPath()));
ui->nextButton->setEnabled(false); ui->nextButton->setEnabled(false);
ui->backButton->setEnabled(true);
ui->stackedWidget->setCurrentIndex(++m_currentPage); ui->stackedWidget->setCurrentIndex(++m_currentPage);
break; break;
@ -115,13 +120,53 @@ void BookmarksImportDialog::nextPage()
Q_ASSERT(m_importedFolder->isFolder()); Q_ASSERT(m_importedFolder->isFolder());
ui->stackedWidget->setCurrentIndex(++m_currentPage); ui->stackedWidget->setCurrentIndex(++m_currentPage);
ui->nextButton->setText(tr("Finish"));
showExportedBookmarks(); showExportedBookmarks();
break; break;
default: case 2:
addExportedBookmarks(); addExportedBookmarks();
close(); close();
break; break;
default:
Q_ASSERT(!"Unreachable");
}
}
void BookmarksImportDialog::previousPage()
{
switch (m_currentPage) {
case 0:
break;
case 1:
ui->nextButton->setEnabled(true);
ui->backButton->setEnabled(false);
ui->stackedWidget->setCurrentIndex(--m_currentPage);
delete m_importer;
m_importer = 0;
break;
case 2:
showImporterPage();
ui->nextButton->setText(tr("Next >"));
ui->nextButton->setEnabled(true);
ui->backButton->setEnabled(true);
ui->stackedWidget->setCurrentIndex(--m_currentPage);
ui->treeView->setModel(0);
delete m_model;
m_model = 0;
delete m_importedFolder;
m_importedFolder = 0;
break;
default:
Q_ASSERT(!"Unreachable");
} }
} }
@ -133,11 +178,18 @@ void BookmarksImportDialog::setFile()
ui->nextButton->setEnabled(!ui->fileLine->text().isEmpty()); ui->nextButton->setEnabled(!ui->fileLine->text().isEmpty());
} }
void BookmarksImportDialog::showImporterPage()
{
ui->iconLabel->setPixmap(ui->browserList->currentItem()->icon().pixmap(48));
ui->importingFromLabel->setText(tr("<b>Importing from %1</b>").arg(ui->browserList->currentItem()->text()));
ui->fileText1->setText(m_importer->description());
ui->standardDirLabel->setText(QString("<i>%1</i>").arg(m_importer->standardPath()));
}
void BookmarksImportDialog::showExportedBookmarks() void BookmarksImportDialog::showExportedBookmarks()
{ {
ui->nextButton->setText(tr("Finish")); m_model = new BookmarksModel(m_importedFolder, 0, this);
ui->treeView->setModel(m_model);
ui->treeView->setModel(new BookmarksModel(m_importedFolder, 0, this));
ui->treeView->header()->resizeSection(0, ui->treeView->header()->width() / 2); ui->treeView->header()->resizeSection(0, ui->treeView->header()->width() / 2);
ui->treeView->expandAll(); ui->treeView->expandAll();
} }
@ -145,4 +197,5 @@ void BookmarksImportDialog::showExportedBookmarks()
void BookmarksImportDialog::addExportedBookmarks() void BookmarksImportDialog::addExportedBookmarks()
{ {
mApp->bookmarks()->addBookmark(mApp->bookmarks()->unsortedFolder(), m_importedFolder); mApp->bookmarks()->addBookmark(mApp->bookmarks()->unsortedFolder(), m_importedFolder);
m_importedFolder = 0;
} }

View File

@ -28,6 +28,7 @@ class BookmarksImportDialog;
} }
class BookmarkItem; class BookmarkItem;
class BookmarksModel;
class BookmarksImporter; class BookmarksImporter;
class QT_QUPZILLA_EXPORT BookmarksImportDialog : public QDialog class QT_QUPZILLA_EXPORT BookmarksImportDialog : public QDialog
@ -40,6 +41,7 @@ public:
private slots: private slots:
void nextPage(); void nextPage();
void previousPage();
void setFile(); void setFile();
private: private:
@ -51,6 +53,7 @@ private:
Html = 4 Html = 4
}; };
void showImporterPage();
void showExportedBookmarks(); void showExportedBookmarks();
void addExportedBookmarks(); void addExportedBookmarks();
@ -59,6 +62,7 @@ private:
int m_currentPage; int m_currentPage;
BookmarksImporter* m_importer; BookmarksImporter* m_importer;
BookmarkItem* m_importedFolder; BookmarkItem* m_importedFolder;
BookmarksModel* m_model;
}; };
#endif // BOOKMARKSIMPORTDIALOG_H #endif // BOOKMARKSIMPORTDIALOG_H

View File

@ -80,7 +80,7 @@
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>From File</string> <string>Html File</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../data/icons.qrc"> <iconset resource="../data/icons.qrc">
@ -92,17 +92,7 @@
<item row="0" column="0" colspan="3"> <item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Choose browser from which you want to import bookmarks:</string> <string>Choose from which you want to import bookmarks:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt; Currently, only import from Html File can import also bookmark folders.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -110,16 +100,82 @@
</widget> </widget>
<widget class="QWidget" name="filePage"> <widget class="QWidget" name="filePage">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1"> <item row="4" column="1">
<widget class="QLabel" name="importingFromLabel"/>
</item>
<item row="3" column="1">
<widget class="QLabel" name="standardDirLabel"> <widget class="QLabel" name="standardDirLabel">
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLabel" name="importingFromLabel"/>
</item>
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="fileLine">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="chooseFile">
<property name="text">
<string>Choose...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>15</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QLabel" name="fileText1"> <widget class="QLabel" name="fileText1">
<property name="wordWrap"> <property name="wordWrap">
@ -140,53 +196,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="fileText2"/>
</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="6" column="1">
<spacer name="verticalSpacer_4">
<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="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="fileLine">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="chooseFile">
<property name="text">
<string>Choose...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="iconLabel"> <widget class="QLabel" name="iconLabel">
<property name="minimumSize"> <property name="minimumSize">
@ -234,16 +243,44 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="nextButton"> <widget class="QPushButton" name="backButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Next</string> <string>&lt; Back</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="cancelButton"> <widget class="QPushButton" name="nextButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Cancel</string> <string>Next &gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -105,5 +105,8 @@ BookmarkItem* FirefoxImporter::importBookmarks()
setError(query.lastError().text()); setError(query.lastError().text());
} }
m_db.close();
QSqlDatabase::removeDatabase("firefox-import");
return root; return root;
} }

View File

@ -35,12 +35,12 @@ QString HtmlImporter::description() const
QString HtmlImporter::standardPath() const QString HtmlImporter::standardPath() const
{ {
return QString(); return QString(".htm, .html");
} }
QString HtmlImporter::getPath(QWidget* parent) QString HtmlImporter::getPath(QWidget* parent)
{ {
m_path = QFileDialog::getOpenFileName(parent, BookmarksImporter::tr("Choose file..."), standardPath(), "Html (*.htm, *.html)"); m_path = QFileDialog::getOpenFileName(parent, BookmarksImporter::tr("Choose file..."), QDir::homePath(), "Html (*.htm, *.html)");
return m_path; return m_path;
} }

View File

@ -21,7 +21,6 @@
#include "bookmarkitem.h" #include "bookmarkitem.h"
#include "bookmarksmodel.h" #include "bookmarksmodel.h"
#include "bookmarkstools.h" #include "bookmarkstools.h"
#include "bookmarksimportdialog.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "qupzilla.h" #include "qupzilla.h"
#include "qztools.h" #include "qztools.h"
@ -214,21 +213,6 @@ void BookmarksManager::enableUpdates()
setUpdatesEnabled(true); setUpdatesEnabled(true);
} }
void BookmarksManager::importBookmarks()
{
BookmarksImportDialog* b = new BookmarksImportDialog(this);
b->show();
}
void BookmarksManager::exportBookmarks()
{
QString file = QzTools::getSaveFileName("BookmarksManager-Export", this, tr("Export to HTML..."), QDir::homePath() + "/bookmarks.html");
if (!file.isEmpty()) {
m_bookmarks->exportToHtml(file);
}
}
void BookmarksManager::updateEditBox(BookmarkItem* item) void BookmarksManager::updateEditBox(BookmarkItem* item)
{ {
setUpdatesEnabled(false); setUpdatesEnabled(false);

View File

@ -67,9 +67,6 @@ private slots:
void descriptionEdited(); void descriptionEdited();
void enableUpdates(); void enableUpdates();
void importBookmarks();
void exportBookmarks();
private: private:
void updateEditBox(BookmarkItem* item); void updateEditBox(BookmarkItem* item);
bool bookmarkEditable(BookmarkItem* item) const; bool bookmarkEditable(BookmarkItem* item) const;

View File

@ -40,7 +40,6 @@ INCLUDEPATH += 3rdparty\
adblock\ adblock\
desktopnotifications\ desktopnotifications\
opensearch\ opensearch\
bookmarksimport\
popupwindow\ popupwindow\
DEPENDPATH += 3rdparty\ DEPENDPATH += 3rdparty\
@ -65,7 +64,6 @@ DEPENDPATH += 3rdparty\
adblock\ adblock\
desktopnotifications\ desktopnotifications\
opensearch\ opensearch\
bookmarksimport\
popupwindow\ popupwindow\
SOURCES += \ SOURCES += \
@ -164,12 +162,13 @@ SOURCES += \
opensearch/searchenginesmanager.cpp \ opensearch/searchenginesmanager.cpp \
opensearch/searchenginesdialog.cpp \ opensearch/searchenginesdialog.cpp \
opensearch/editsearchengine.cpp \ opensearch/editsearchengine.cpp \
bookmarks/import/firefoximporter.cpp \ bookmarks/bookmarksimport/bookmarksimporter.cpp \
bookmarks/import/chromeimporter.cpp \ bookmarks/bookmarksimport/firefoximporter.cpp \
bookmarks/import/operaimporter.cpp \ bookmarks/bookmarksimport/chromeimporter.cpp \
bookmarks/import/ieimporter.cpp \ bookmarks/bookmarksimport/operaimporter.cpp \
bookmarks/import/htmlimporter.cpp \ bookmarks/bookmarksimport/ieimporter.cpp \
bookmarksimport/bookmarksimportdialog.cpp \ bookmarks/bookmarksimport/htmlimporter.cpp \
bookmarks/bookmarksimport/bookmarksimportdialog.cpp \
tools/iconfetcher.cpp \ tools/iconfetcher.cpp \
tools/followredirectreply.cpp \ tools/followredirectreply.cpp \
webview/webhistorywrapper.cpp \ webview/webhistorywrapper.cpp \
@ -255,8 +254,7 @@ SOURCES += \
bookmarks/bookmarksmenu.cpp \ bookmarks/bookmarksmenu.cpp \
bookmarks/bookmarksicon.cpp \ bookmarks/bookmarksicon.cpp \
bookmarks/bookmarksitemdelegate.cpp \ bookmarks/bookmarksitemdelegate.cpp \
bookmarks/bookmarkstoolbarbutton.cpp \ bookmarks/bookmarkstoolbarbutton.cpp
bookmarks/import/bookmarksimporter.cpp
HEADERS += \ HEADERS += \
@ -355,12 +353,13 @@ HEADERS += \
opensearch/searchenginesmanager.h \ opensearch/searchenginesmanager.h \
opensearch/searchenginesdialog.h \ opensearch/searchenginesdialog.h \
opensearch/editsearchengine.h \ opensearch/editsearchengine.h \
bookmarks/import/firefoximporter.h \ bookmarks/bookmarksimport/bookmarksimporter.h \
bookmarks/import/chromeimporter.h \ bookmarks/bookmarksimport/firefoximporter.h \
bookmarks/import/operaimporter.h \ bookmarks/bookmarksimport/chromeimporter.h \
bookmarks/import/ieimporter.h \ bookmarks/bookmarksimport/operaimporter.h \
bookmarks/import/htmlimporter.h \ bookmarks/bookmarksimport/ieimporter.h \
bookmarksimport/bookmarksimportdialog.h \ bookmarks/bookmarksimport/htmlimporter.h \
bookmarks/bookmarksimport/bookmarksimportdialog.h \
tools/iconfetcher.h \ tools/iconfetcher.h \
tools/followredirectreply.h \ tools/followredirectreply.h \
webview/webhistorywrapper.h \ webview/webhistorywrapper.h \
@ -450,8 +449,7 @@ HEADERS += \
bookmarks/bookmarksmenu.h \ bookmarks/bookmarksmenu.h \
bookmarks/bookmarksicon.h \ bookmarks/bookmarksicon.h \
bookmarks/bookmarksitemdelegate.h \ bookmarks/bookmarksitemdelegate.h \
bookmarks/bookmarkstoolbarbutton.h \ bookmarks/bookmarkstoolbarbutton.h
bookmarks/import/bookmarksimporter.h
FORMS += \ FORMS += \
preferences/autofillmanager.ui \ preferences/autofillmanager.ui \
@ -492,7 +490,7 @@ FORMS += \
preferences/addacceptlanguage.ui \ preferences/addacceptlanguage.ui \
opensearch/searchenginesdialog.ui \ opensearch/searchenginesdialog.ui \
opensearch/editsearchengine.ui \ opensearch/editsearchengine.ui \
bookmarksimport/bookmarksimportdialog.ui \ bookmarks/bookmarksimport/bookmarksimportdialog.ui \
other/checkboxdialog.ui \ other/checkboxdialog.ui \
other/iconchooser.ui \ other/iconchooser.ui \
adblock/adblockaddsubscriptiondialog.ui \ adblock/adblockaddsubscriptiondialog.ui \

View File

@ -17,6 +17,7 @@
* ============================================================ */ * ============================================================ */
#include "browsinglibrary.h" #include "browsinglibrary.h"
#include "ui_browsinglibrary.h" #include "ui_browsinglibrary.h"
#include "bookmarksimport/bookmarksimportdialog.h"
#include "historymanager.h" #include "historymanager.h"
#include "bookmarksmanager.h" #include "bookmarksmanager.h"
#include "rssmanager.h" #include "rssmanager.h"
@ -24,8 +25,6 @@
#include "qztools.h" #include "qztools.h"
#include "settings.h" #include "settings.h"
#include "bookmarksimportdialog.h"
#include <QMenu> #include <QMenu>
#include <QCloseEvent> #include <QCloseEvent>

View File

@ -22,7 +22,6 @@ INCLUDEPATH += $$PWD/lib/3rdparty\
$$PWD/lib/adblock\ $$PWD/lib/adblock\
$$PWD/lib/desktopnotifications\ $$PWD/lib/desktopnotifications\
$$PWD/lib/opensearch\ $$PWD/lib/opensearch\
$$PWD/lib/bookmarksimport\
$$PWD/lib/popupwindow\ $$PWD/lib/popupwindow\
DEPENDPATH += $$PWD/lib/3rdparty\ DEPENDPATH += $$PWD/lib/3rdparty\
@ -47,7 +46,6 @@ DEPENDPATH += $$PWD/lib/3rdparty\
$$PWD/lib/adblock\ $$PWD/lib/adblock\
$$PWD/lib/desktopnotifications\ $$PWD/lib/desktopnotifications\
$$PWD/lib/opensearch\ $$PWD/lib/opensearch\
$$PWD/lib/bookmarksimport\
$$PWD/lib/popupwindow\ $$PWD/lib/popupwindow\
TEMPLATE = lib TEMPLATE = lib