aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp61
1 files changed, 22 insertions, 39 deletions
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index d9af4ee..8a45cbf 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -7,15 +7,13 @@
*/
#include "bookmarkswidget.h"
+#include "bookmarkitem.h"
+#include "bookmarkmodel.h"
+#include "forms/editbookmarkdialog.h"
#include "ui_bookmarksform.h"
#include "xbel.h"
-#include <QUrl>
-
-#ifdef QT_DEBUG
#include <QTreeView>
-#include "bookmarkmodel.h"
-#include "bookmarkitem.h"
-#include "forms/editbookmarkdialog.h"
+#include <QUrl>
inline void expandChildren(QTreeView *view, BookmarkModel *model, const QModelIndex &rootIndex)
{
@@ -29,7 +27,6 @@ inline void expandChildren(QTreeView *view, BookmarkModel *model, const QModelIn
expandChildren(view, model, idx);
}
}
-#endif
BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
: QWidget(parent)
@@ -47,36 +44,28 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
ui->deleteItem_toolButton->setIcon(style()->standardPixmap(QStyle::SP_TrashIcon));
ui->deleteItem_toolButton->setShortcut(QKeySequence::Delete);
- // Testing model/view
-#ifdef QT_DEBUG
- {
- model = new BookmarkModel(this);
-
- QFile bookmarksFile(path);
- if(bookmarksFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- Xbel::read(&bookmarksFile, model->root());
- bookmarksFile.close();
- }
+ model = new BookmarkModel(this);
+ m_bookmarksPath = path;
+ QFile bookmarksFile(m_bookmarksPath);
+ if(bookmarksFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ Xbel::read(&bookmarksFile, model->root());
+ bookmarksFile.close();
+ }
- ui->treeView->setModel(model);
+ ui->treeView->setModel(model);
- expandChildren(ui->treeView, model, QModelIndex());
+ expandChildren(ui->treeView, model, QModelIndex());
- connect(ui->treeView, &QTreeView::activated, this, [this](const QModelIndex &index) {
- if(index.column() == 1)
- emit openUrl(index.data(Qt::DisplayRole).toUrl());
- else {
- auto *dlg = new EditBookmarkDialog(model, index, this);
- if(dlg->exec() == QDialog::Accepted) {
- m_isChanged = true;
- }
+ connect(ui->treeView, &QTreeView::activated, this, [this](const QModelIndex &index) {
+ if(index.column() == 1)
+ emit openUrl(index.data(Qt::DisplayRole).toUrl());
+ else {
+ auto *dlg = new EditBookmarkDialog(model, index, this);
+ if(dlg->exec() == QDialog::Accepted) {
+ m_isChanged = true;
}
- });
- }
-#endif
- //
-
- m_bookmarksPath = path;
+ }
+ });
}
BookmarksWidget::~BookmarksWidget()
@@ -108,11 +97,5 @@ void BookmarksWidget::addBookmark(const QString &title, const QString &url)
void BookmarksWidget::search(const QString &term, std::function<void(QStringList &)> callback) const
{
QStringList ret = model->search(term);
-// const QList<QTreeWidgetItem *> res = ui->treeWidget->findItems(term, Qt::MatchContains | Qt::MatchRecursive, 1);
-// for(const QTreeWidgetItem *i : res) {
-// if(!i->text(1).isEmpty())
-// ret.append(i->text(1));
-// }
-
callback(ret);
}