diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 1f6c6cf98..4699ba90e 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -54,7 +54,7 @@ #include "navigationbar.h" #include "pagescreen.h" #include "webinspectordockwidget.h" -#include "bookmarksimportdialog.h" +#include "bookmarksimport/bookmarksimportdialog.h" #include "qztools.h" #include "actioncopy.h" #include "reloadstopbutton.h" diff --git a/src/lib/bookmarksimport/bookmarksimportdialog.cpp b/src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.cpp similarity index 65% rename from src/lib/bookmarksimport/bookmarksimportdialog.cpp rename to src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.cpp index ed356648c..fc173bfeb 100644 --- a/src/lib/bookmarksimport/bookmarksimportdialog.cpp +++ b/src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.cpp @@ -17,11 +17,11 @@ * ============================================================ */ #include "bookmarksimportdialog.h" #include "ui_bookmarksimportdialog.h" -#include "import/firefoximporter.h" -#include "import/chromeimporter.h" -#include "import/operaimporter.h" -#include "import/htmlimporter.h" -#include "import/ieimporter.h" +#include "bookmarksimport/firefoximporter.h" +#include "bookmarksimport/chromeimporter.h" +#include "bookmarksimport/operaimporter.h" +#include "bookmarksimport/htmlimporter.h" +#include "bookmarksimport/ieimporter.h" #include "bookmarks.h" #include "bookmarkitem.h" #include "bookmarksmodel.h" @@ -35,6 +35,7 @@ BookmarksImportDialog::BookmarksImportDialog(QWidget* parent) , m_currentPage(0) , m_importer(0) , m_importedFolder(0) + , m_model(0) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); @@ -42,17 +43,21 @@ BookmarksImportDialog::BookmarksImportDialog(QWidget* parent) ui->browserList->setCurrentRow(0); 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->cancelButton, SIGNAL(clicked()), this, SLOT(close())); + connect(ui->cancelButton, SIGNAL(rejected()), this, SLOT(close())); #ifndef Q_OS_WIN ui->browserList->setItemHidden(ui->browserList->item(IE), true); #endif - } BookmarksImportDialog::~BookmarksImportDialog() { + ui->treeView->setModel(0); + delete m_model; + delete m_importedFolder; + delete m_importer; delete ui; } @@ -85,11 +90,11 @@ void BookmarksImportDialog::nextPage() break; } - ui->iconLabel->setPixmap(ui->browserList->currentItem()->icon().pixmap(48)); - ui->importingFromLabel->setText(tr("Importing from %1").arg(ui->browserList->currentItem()->text())); - ui->fileText1->setText(m_importer->description()); - ui->standardDirLabel->setText(QString("%1").arg(m_importer->standardPath())); + ui->fileLine->clear(); + showImporterPage(); + ui->nextButton->setEnabled(false); + ui->backButton->setEnabled(true); ui->stackedWidget->setCurrentIndex(++m_currentPage); break; @@ -115,13 +120,53 @@ void BookmarksImportDialog::nextPage() Q_ASSERT(m_importedFolder->isFolder()); ui->stackedWidget->setCurrentIndex(++m_currentPage); + ui->nextButton->setText(tr("Finish")); showExportedBookmarks(); break; - default: + case 2: addExportedBookmarks(); close(); 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()); } +void BookmarksImportDialog::showImporterPage() +{ + ui->iconLabel->setPixmap(ui->browserList->currentItem()->icon().pixmap(48)); + ui->importingFromLabel->setText(tr("Importing from %1").arg(ui->browserList->currentItem()->text())); + ui->fileText1->setText(m_importer->description()); + ui->standardDirLabel->setText(QString("%1").arg(m_importer->standardPath())); +} + void BookmarksImportDialog::showExportedBookmarks() { - ui->nextButton->setText(tr("Finish")); - - ui->treeView->setModel(new BookmarksModel(m_importedFolder, 0, this)); + m_model = new BookmarksModel(m_importedFolder, 0, this); + ui->treeView->setModel(m_model); ui->treeView->header()->resizeSection(0, ui->treeView->header()->width() / 2); ui->treeView->expandAll(); } @@ -145,4 +197,5 @@ void BookmarksImportDialog::showExportedBookmarks() void BookmarksImportDialog::addExportedBookmarks() { mApp->bookmarks()->addBookmark(mApp->bookmarks()->unsortedFolder(), m_importedFolder); + m_importedFolder = 0; } diff --git a/src/lib/bookmarksimport/bookmarksimportdialog.h b/src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.h similarity index 94% rename from src/lib/bookmarksimport/bookmarksimportdialog.h rename to src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.h index d0aad28b2..57ab9c86c 100644 --- a/src/lib/bookmarksimport/bookmarksimportdialog.h +++ b/src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.h @@ -28,6 +28,7 @@ class BookmarksImportDialog; } class BookmarkItem; +class BookmarksModel; class BookmarksImporter; class QT_QUPZILLA_EXPORT BookmarksImportDialog : public QDialog @@ -40,6 +41,7 @@ public: private slots: void nextPage(); + void previousPage(); void setFile(); private: @@ -51,6 +53,7 @@ private: Html = 4 }; + void showImporterPage(); void showExportedBookmarks(); void addExportedBookmarks(); @@ -59,6 +62,7 @@ private: int m_currentPage; BookmarksImporter* m_importer; BookmarkItem* m_importedFolder; + BookmarksModel* m_model; }; #endif // BOOKMARKSIMPORTDIALOG_H diff --git a/src/lib/bookmarksimport/bookmarksimportdialog.ui b/src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.ui similarity index 79% rename from src/lib/bookmarksimport/bookmarksimportdialog.ui rename to src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.ui index d04e78b48..356023897 100644 --- a/src/lib/bookmarksimport/bookmarksimportdialog.ui +++ b/src/lib/bookmarks/bookmarksimport/bookmarksimportdialog.ui @@ -80,7 +80,7 @@ - From File + Html File @@ -92,17 +92,7 @@ - Choose browser from which you want to import bookmarks: - - - - - - - <b>Note:</b> Currently, only import from Html File can import also bookmark folders. - - - true + Choose from which you want to import bookmarks: @@ -110,16 +100,82 @@ - - - - + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + false + + + + + + + Choose... + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 15 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + @@ -140,53 +196,6 @@ - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - false - - - - - - - Choose... - - - - - @@ -234,16 +243,44 @@ - + + + false + + + + 0 + 0 + + - Next + < Back - + + + + 0 + 0 + + - Cancel + Next > + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Cancel diff --git a/src/lib/bookmarks/import/bookmarksimporter.cpp b/src/lib/bookmarks/bookmarksimport/bookmarksimporter.cpp similarity index 100% rename from src/lib/bookmarks/import/bookmarksimporter.cpp rename to src/lib/bookmarks/bookmarksimport/bookmarksimporter.cpp diff --git a/src/lib/bookmarks/import/bookmarksimporter.h b/src/lib/bookmarks/bookmarksimport/bookmarksimporter.h similarity index 100% rename from src/lib/bookmarks/import/bookmarksimporter.h rename to src/lib/bookmarks/bookmarksimport/bookmarksimporter.h diff --git a/src/lib/bookmarks/import/chromeimporter.cpp b/src/lib/bookmarks/bookmarksimport/chromeimporter.cpp similarity index 100% rename from src/lib/bookmarks/import/chromeimporter.cpp rename to src/lib/bookmarks/bookmarksimport/chromeimporter.cpp diff --git a/src/lib/bookmarks/import/chromeimporter.h b/src/lib/bookmarks/bookmarksimport/chromeimporter.h similarity index 100% rename from src/lib/bookmarks/import/chromeimporter.h rename to src/lib/bookmarks/bookmarksimport/chromeimporter.h diff --git a/src/lib/bookmarks/import/firefoximporter.cpp b/src/lib/bookmarks/bookmarksimport/firefoximporter.cpp similarity index 97% rename from src/lib/bookmarks/import/firefoximporter.cpp rename to src/lib/bookmarks/bookmarksimport/firefoximporter.cpp index 38d1176ae..1f7752d23 100644 --- a/src/lib/bookmarks/import/firefoximporter.cpp +++ b/src/lib/bookmarks/bookmarksimport/firefoximporter.cpp @@ -105,5 +105,8 @@ BookmarkItem* FirefoxImporter::importBookmarks() setError(query.lastError().text()); } + m_db.close(); + QSqlDatabase::removeDatabase("firefox-import"); + return root; } diff --git a/src/lib/bookmarks/import/firefoximporter.h b/src/lib/bookmarks/bookmarksimport/firefoximporter.h similarity index 100% rename from src/lib/bookmarks/import/firefoximporter.h rename to src/lib/bookmarks/bookmarksimport/firefoximporter.h diff --git a/src/lib/bookmarks/import/htmlimporter.cpp b/src/lib/bookmarks/bookmarksimport/htmlimporter.cpp similarity index 98% rename from src/lib/bookmarks/import/htmlimporter.cpp rename to src/lib/bookmarks/bookmarksimport/htmlimporter.cpp index ccc4ebee1..e92ffbe3c 100644 --- a/src/lib/bookmarks/import/htmlimporter.cpp +++ b/src/lib/bookmarks/bookmarksimport/htmlimporter.cpp @@ -35,12 +35,12 @@ QString HtmlImporter::description() const QString HtmlImporter::standardPath() const { - return QString(); + return QString(".htm, .html"); } 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; } diff --git a/src/lib/bookmarks/import/htmlimporter.h b/src/lib/bookmarks/bookmarksimport/htmlimporter.h similarity index 100% rename from src/lib/bookmarks/import/htmlimporter.h rename to src/lib/bookmarks/bookmarksimport/htmlimporter.h diff --git a/src/lib/bookmarks/import/ieimporter.cpp b/src/lib/bookmarks/bookmarksimport/ieimporter.cpp similarity index 100% rename from src/lib/bookmarks/import/ieimporter.cpp rename to src/lib/bookmarks/bookmarksimport/ieimporter.cpp diff --git a/src/lib/bookmarks/import/ieimporter.h b/src/lib/bookmarks/bookmarksimport/ieimporter.h similarity index 100% rename from src/lib/bookmarks/import/ieimporter.h rename to src/lib/bookmarks/bookmarksimport/ieimporter.h diff --git a/src/lib/bookmarks/import/operaimporter.cpp b/src/lib/bookmarks/bookmarksimport/operaimporter.cpp similarity index 100% rename from src/lib/bookmarks/import/operaimporter.cpp rename to src/lib/bookmarks/bookmarksimport/operaimporter.cpp diff --git a/src/lib/bookmarks/import/operaimporter.h b/src/lib/bookmarks/bookmarksimport/operaimporter.h similarity index 100% rename from src/lib/bookmarks/import/operaimporter.h rename to src/lib/bookmarks/bookmarksimport/operaimporter.h diff --git a/src/lib/bookmarks/bookmarksmanager.cpp b/src/lib/bookmarks/bookmarksmanager.cpp index ea845c6a3..8f5e20c76 100644 --- a/src/lib/bookmarks/bookmarksmanager.cpp +++ b/src/lib/bookmarks/bookmarksmanager.cpp @@ -21,7 +21,6 @@ #include "bookmarkitem.h" #include "bookmarksmodel.h" #include "bookmarkstools.h" -#include "bookmarksimportdialog.h" #include "mainapplication.h" #include "qupzilla.h" #include "qztools.h" @@ -214,21 +213,6 @@ void BookmarksManager::enableUpdates() 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) { setUpdatesEnabled(false); diff --git a/src/lib/bookmarks/bookmarksmanager.h b/src/lib/bookmarks/bookmarksmanager.h index 9e08f02e1..18dfac91a 100644 --- a/src/lib/bookmarks/bookmarksmanager.h +++ b/src/lib/bookmarks/bookmarksmanager.h @@ -67,9 +67,6 @@ private slots: void descriptionEdited(); void enableUpdates(); - void importBookmarks(); - void exportBookmarks(); - private: void updateEditBox(BookmarkItem* item); bool bookmarkEditable(BookmarkItem* item) const; diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 3ad88c943..206480f54 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -40,7 +40,6 @@ INCLUDEPATH += 3rdparty\ adblock\ desktopnotifications\ opensearch\ - bookmarksimport\ popupwindow\ DEPENDPATH += 3rdparty\ @@ -65,7 +64,6 @@ DEPENDPATH += 3rdparty\ adblock\ desktopnotifications\ opensearch\ - bookmarksimport\ popupwindow\ SOURCES += \ @@ -164,12 +162,13 @@ SOURCES += \ opensearch/searchenginesmanager.cpp \ opensearch/searchenginesdialog.cpp \ opensearch/editsearchengine.cpp \ - bookmarks/import/firefoximporter.cpp \ - bookmarks/import/chromeimporter.cpp \ - bookmarks/import/operaimporter.cpp \ - bookmarks/import/ieimporter.cpp \ - bookmarks/import/htmlimporter.cpp \ - bookmarksimport/bookmarksimportdialog.cpp \ + bookmarks/bookmarksimport/bookmarksimporter.cpp \ + bookmarks/bookmarksimport/firefoximporter.cpp \ + bookmarks/bookmarksimport/chromeimporter.cpp \ + bookmarks/bookmarksimport/operaimporter.cpp \ + bookmarks/bookmarksimport/ieimporter.cpp \ + bookmarks/bookmarksimport/htmlimporter.cpp \ + bookmarks/bookmarksimport/bookmarksimportdialog.cpp \ tools/iconfetcher.cpp \ tools/followredirectreply.cpp \ webview/webhistorywrapper.cpp \ @@ -255,8 +254,7 @@ SOURCES += \ bookmarks/bookmarksmenu.cpp \ bookmarks/bookmarksicon.cpp \ bookmarks/bookmarksitemdelegate.cpp \ - bookmarks/bookmarkstoolbarbutton.cpp \ - bookmarks/import/bookmarksimporter.cpp + bookmarks/bookmarkstoolbarbutton.cpp HEADERS += \ @@ -355,12 +353,13 @@ HEADERS += \ opensearch/searchenginesmanager.h \ opensearch/searchenginesdialog.h \ opensearch/editsearchengine.h \ - bookmarks/import/firefoximporter.h \ - bookmarks/import/chromeimporter.h \ - bookmarks/import/operaimporter.h \ - bookmarks/import/ieimporter.h \ - bookmarks/import/htmlimporter.h \ - bookmarksimport/bookmarksimportdialog.h \ + bookmarks/bookmarksimport/bookmarksimporter.h \ + bookmarks/bookmarksimport/firefoximporter.h \ + bookmarks/bookmarksimport/chromeimporter.h \ + bookmarks/bookmarksimport/operaimporter.h \ + bookmarks/bookmarksimport/ieimporter.h \ + bookmarks/bookmarksimport/htmlimporter.h \ + bookmarks/bookmarksimport/bookmarksimportdialog.h \ tools/iconfetcher.h \ tools/followredirectreply.h \ webview/webhistorywrapper.h \ @@ -450,8 +449,7 @@ HEADERS += \ bookmarks/bookmarksmenu.h \ bookmarks/bookmarksicon.h \ bookmarks/bookmarksitemdelegate.h \ - bookmarks/bookmarkstoolbarbutton.h \ - bookmarks/import/bookmarksimporter.h + bookmarks/bookmarkstoolbarbutton.h FORMS += \ preferences/autofillmanager.ui \ @@ -492,7 +490,7 @@ FORMS += \ preferences/addacceptlanguage.ui \ opensearch/searchenginesdialog.ui \ opensearch/editsearchengine.ui \ - bookmarksimport/bookmarksimportdialog.ui \ + bookmarks/bookmarksimport/bookmarksimportdialog.ui \ other/checkboxdialog.ui \ other/iconchooser.ui \ adblock/adblockaddsubscriptiondialog.ui \ diff --git a/src/lib/other/browsinglibrary.cpp b/src/lib/other/browsinglibrary.cpp index 840510492..c3f84b8e4 100644 --- a/src/lib/other/browsinglibrary.cpp +++ b/src/lib/other/browsinglibrary.cpp @@ -17,6 +17,7 @@ * ============================================================ */ #include "browsinglibrary.h" #include "ui_browsinglibrary.h" +#include "bookmarksimport/bookmarksimportdialog.h" #include "historymanager.h" #include "bookmarksmanager.h" #include "rssmanager.h" @@ -24,8 +25,6 @@ #include "qztools.h" #include "settings.h" -#include "bookmarksimportdialog.h" - #include #include diff --git a/src/plugins.pri b/src/plugins.pri index d1fde9da1..3e487e510 100644 --- a/src/plugins.pri +++ b/src/plugins.pri @@ -22,7 +22,6 @@ INCLUDEPATH += $$PWD/lib/3rdparty\ $$PWD/lib/adblock\ $$PWD/lib/desktopnotifications\ $$PWD/lib/opensearch\ - $$PWD/lib/bookmarksimport\ $$PWD/lib/popupwindow\ DEPENDPATH += $$PWD/lib/3rdparty\ @@ -47,7 +46,6 @@ DEPENDPATH += $$PWD/lib/3rdparty\ $$PWD/lib/adblock\ $$PWD/lib/desktopnotifications\ $$PWD/lib/opensearch\ - $$PWD/lib/bookmarksimport\ $$PWD/lib/popupwindow\ TEMPLATE = lib