void TestItem::setComments(const QString &comments){ if (m_comments.compare(comments) != 0 ) { m_comments = comments; emit commentsChanged(); emit dataChanged(); } }
CommentsWidget::CommentsWidget(MainWindow *main, QAction *action) : CutterDockWidget(main, action), ui(new Ui::CommentsWidget), main(main) { ui->setupUi(this); commentsModel = new CommentsModel(&comments, &nestedComments, this); commentsProxyModel = new CommentsProxyModel(commentsModel, this); ui->commentsTreeView->setModel(commentsProxyModel); ui->commentsTreeView->sortByColumn(CommentsModel::CommentColumn, Qt::AscendingOrder); // Ctrl-F to show/hide the filter entry QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this); connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter); searchShortcut->setContext(Qt::WidgetWithChildrenShortcut); // Esc to clear the filter entry QShortcut *clearShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(clearShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::clearFilter); clearShortcut->setContext(Qt::WidgetWithChildrenShortcut); connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)), commentsProxyModel, SLOT(setFilterWildcard(const QString &))); connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->commentsTreeView, SLOT(setFocus())); setScrollMode(); ui->actionHorizontal->setChecked(true); this->setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showTitleContextMenu(const QPoint &))); connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshTree())); connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshTree())); }