19#include "ui_bookmarksimportdialog.h"
38 , m_importedFolder(nullptr)
41 setAttribute(Qt::WA_DeleteOnClose);
44 ui->browserList->setCurrentRow(0);
47 connect(ui->nextButton, &QAbstractButton::clicked,
this, &BookmarksImportDialog::nextPage);
48 connect(ui->backButton, &QAbstractButton::clicked,
this, &BookmarksImportDialog::previousPage);
49 connect(ui->chooseFile, &QAbstractButton::clicked,
this, &BookmarksImportDialog::setFile);
50 connect(ui->cancelButton, &QDialogButtonBox::rejected,
this, &QWidget::close);
53 ui->browserList->item(IE)->setHidden(
true);
59 ui->treeView->setModel(
nullptr);
61 delete m_importedFolder;
66void BookmarksImportDialog::nextPage()
68 switch (m_currentPage) {
70 if (!ui->browserList->currentItem()) {
74 switch (ui->browserList->currentRow()) {
91 Q_ASSERT(!
"Unreachable");
95 ui->fileLine->clear();
98 ui->nextButton->setEnabled(
false);
99 ui->backButton->setEnabled(
true);
100 ui->stackedWidget->setCurrentIndex(++m_currentPage);
104 if (ui->fileLine->text().isEmpty()) {
112 if (m_importer->
error()) {
113 QMessageBox::critical(
this, tr(
"Error!"), m_importer->
errorString());
117 if (!m_importedFolder || m_importedFolder->
children().isEmpty()) {
118 QMessageBox::warning(
this, tr(
"Error!"), tr(
"No bookmarks were found."));
122 Q_ASSERT(m_importedFolder->
isFolder());
124 ui->stackedWidget->setCurrentIndex(++m_currentPage);
125 ui->nextButton->setText(tr(
"Finish"));
126 showExportedBookmarks();
130 addExportedBookmarks();
135 Q_ASSERT(!
"Unreachable");
139void BookmarksImportDialog::previousPage()
141 switch (m_currentPage) {
146 ui->nextButton->setEnabled(
true);
147 ui->backButton->setEnabled(
false);
148 ui->stackedWidget->setCurrentIndex(--m_currentPage);
151 m_importer =
nullptr;
157 ui->nextButton->setText(tr(
"Next >"));
158 ui->nextButton->setEnabled(
true);
159 ui->backButton->setEnabled(
true);
160 ui->stackedWidget->setCurrentIndex(--m_currentPage);
162 ui->treeView->setModel(
nullptr);
166 delete m_importedFolder;
167 m_importedFolder =
nullptr;
171 Q_ASSERT(!
"Unreachable");
175void BookmarksImportDialog::setFile()
177 Q_ASSERT(m_importer);
179 ui->fileLine->setText(m_importer->
getPath(
this));
180 ui->nextButton->setEnabled(!ui->fileLine->text().isEmpty());
183void BookmarksImportDialog::showImporterPage()
185 ui->iconLabel->setPixmap(ui->browserList->currentItem()->icon().pixmap(48));
186 ui->importingFromLabel->setText(tr(
"<b>Importing from %1</b>").arg(ui->browserList->currentItem()->text()));
188 ui->standardDirLabel->setText(
QSL(
"<i>%1</i>").arg(m_importer->
standardPath()));
191void BookmarksImportDialog::showExportedBookmarks()
194 ui->treeView->setModel(m_model);
195 ui->treeView->header()->resizeSection(0, ui->treeView->header()->width() / 2);
196 ui->treeView->expandAll();
199void BookmarksImportDialog::addExportedBookmarks()
201 mApp->bookmarks()->addBookmark(
mApp->bookmarks()->unsortedFolder(), m_importedFolder);
202 m_importedFolder =
nullptr;
QList< BookmarkItem * > children() const
BookmarksImportDialog(QWidget *parent=nullptr)
virtual QString description() const =0
virtual BookmarkItem * importBookmarks()=0
virtual QString standardPath() const =0
virtual QString getPath(QWidget *parent)=0
QString errorString() const
virtual bool prepareImport()=0