From 93676811d7c3fdfddef84aa413aeb78885ba033b Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 25 Sep 2018 17:50:10 +0200 Subject: Bookmarks: remove debug defines --- lib/bookmarks/bookmarkswidget.cpp | 61 ++++++++++++++------------------------- 1 file 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 - -#ifdef QT_DEBUG #include -#include "bookmarkmodel.h" -#include "bookmarkitem.h" -#include "forms/editbookmarkdialog.h" +#include 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 callback) const { QStringList ret = model->search(term); -// const QList 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); } -- cgit v1.2.1