18 const QString &url, QWidget *parent)
22 , bookmarkModel(sourceModel)
27 ui.bookmarkEdit->setText(m_title);
28 ui.newFolderButton->setVisible(
false);
29 ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(
true);
31 connect(ui.buttonBox, &QDialogButtonBox::accepted,
this, &BookmarkDialog::accepted);
32 connect(ui.buttonBox, &QDialogButtonBox::rejected,
this, &BookmarkDialog::rejected);
33 connect(ui.newFolderButton, &QAbstractButton::clicked,
this, &BookmarkDialog::addFolder);
34 connect(ui.toolButton, &QAbstractButton::clicked,
this, &BookmarkDialog::toolButtonClicked);
35 connect(ui.bookmarkEdit, &QLineEdit::textChanged,
this, &BookmarkDialog::textChanged);
37 bookmarkProxyModel =
new BookmarkFilterModel(
this);
38 bookmarkProxyModel->setSourceModel(bookmarkModel);
39 ui.bookmarkFolders->setModel(bookmarkProxyModel);
40 connect(ui.bookmarkFolders, &QComboBox::currentIndexChanged,
41 this, QOverload<
int>::of(&BookmarkDialog::currentIndexChanged));
43 bookmarkTreeModel =
new BookmarkTreeModel(
this);
44 bookmarkTreeModel->setSourceModel(bookmarkModel);
45 ui.treeView->setModel(bookmarkTreeModel);
47 ui.treeView->expandAll();
48 ui.treeView->setVisible(
false);
49 ui.treeView->installEventFilter(
this);
50 ui.treeView->viewport()->installEventFilter(
this);
51 ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu);
53 connect(ui.treeView, &QWidget::customContextMenuRequested,
54 this, &BookmarkDialog::customContextMenuRequested);
55 connect(ui.treeView->selectionModel(), &QItemSelectionModel::currentChanged,
56 this, QOverload<
const QModelIndex &>::of(&BookmarkDialog::currentIndexChanged));
58 ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->count() > 1 ? 1 : 0);
62 setFont(helpEngine.appFont());
78 if (object != ui.treeView && object != ui.treeView->viewport())
79 return QWidget::eventFilter(object, event);
81 if (event->type() == QEvent::KeyPress) {
82 QKeyEvent *ke =
static_cast<QKeyEvent*>(event);
85 const QModelIndex &index = ui.treeView->currentIndex();
86 if (!isRootItem(index)) {
88 ui.treeView->edit(index);
96 return QObject::eventFilter(object, event);