1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +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 "pagescreen.h"
#include "webinspectordockwidget.h"
#include "bookmarksimportdialog.h"
#include "bookmarksimport/bookmarksimportdialog.h"
#include "qztools.h"
#include "actioncopy.h"
#include "reloadstopbutton.h"

View File

@ -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("<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()));
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("<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()
{
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;
}

View File

@ -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

View File

@ -80,7 +80,7 @@
</item>
<item>
<property name="text">
<string>From File</string>
<string>Html File</string>
</property>
<property name="icon">
<iconset resource="../data/icons.qrc">
@ -92,17 +92,7 @@
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Choose browser 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>
<string>Choose from which you want to import bookmarks:</string>
</property>
</widget>
</item>
@ -110,16 +100,82 @@
</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">
<item row="4" column="1">
<widget class="QLabel" name="standardDirLabel">
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</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">
<widget class="QLabel" name="fileText1">
<property name="wordWrap">
@ -140,53 +196,6 @@
</property>
</spacer>
</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">
<widget class="QLabel" name="iconLabel">
<property name="minimumSize">
@ -234,16 +243,44 @@
</spacer>
</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">
<string>Next</string>
<string>&lt; Back</string>
</property>
</widget>
</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">
<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>
</widget>
</item>

View File

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

View File

@ -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;
}

View File

@ -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);

View File

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

View File

@ -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 \

View File

@ -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 <QMenu>
#include <QCloseEvent>

View File

@ -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