"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.9.0/src/widgets/ListDockWidget.cpp" (6 Sep 2019, 2281 Bytes) of package /linux/privat/cutter-1.9.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ListDockWidget.cpp" see the Fossies "Dox" file reference documentation.

    1 #include "ListDockWidget.h"
    2 #include "ui_ListDockWidget.h"
    3 #include "core/MainWindow.h"
    4 #include "common/Helpers.h"
    5 #include "menus/AddressableItemContextMenu.h"
    6 
    7 #include <QMenu>
    8 #include <QResizeEvent>
    9 #include <QShortcut>
   10 
   11 ListDockWidget::ListDockWidget(MainWindow *main, QAction *action, SearchBarPolicy searchBarPolicy) :
   12     CutterDockWidget(main, action),
   13     ui(new Ui::ListDockWidget),
   14     tree(new CutterTreeWidget(this)),
   15     searchBarPolicy(searchBarPolicy)
   16 {
   17     ui->setupUi(this);
   18 
   19     // Add Status Bar footer
   20     tree->addStatusBar(ui->verticalLayout);
   21 
   22     if (searchBarPolicy != SearchBarPolicy::Hide) {
   23         // Ctrl-F to show/hide the filter entry
   24         QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this);
   25         connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter);
   26         searchShortcut->setContext(Qt::WidgetWithChildrenShortcut);
   27 
   28         // Esc to clear the filter entry
   29         QShortcut *clearShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
   30         connect(clearShortcut, &QShortcut::activated, [this]() {
   31             ui->quickFilterView->clearFilter();
   32             ui->treeView->setFocus();
   33         });
   34         clearShortcut->setContext(Qt::WidgetWithChildrenShortcut);
   35     }
   36 
   37     qhelpers::setVerticalScrollMode(ui->treeView);
   38 
   39     ui->treeView->setMainWindow(mainWindow);
   40 
   41     if (searchBarPolicy != SearchBarPolicy::ShowByDefault) {
   42         ui->quickFilterView->closeFilter();
   43     }
   44 }
   45 
   46 ListDockWidget::~ListDockWidget() {}
   47 
   48 void ListDockWidget::showCount(bool show)
   49 {
   50     tree->showStatusBar(show);
   51 }
   52 
   53 void ListDockWidget::setModels(AddressableFilterProxyModel *objectFilterProxyModel)
   54 {
   55     this->objectFilterProxyModel = objectFilterProxyModel;
   56 
   57 
   58     ui->treeView->setModel(objectFilterProxyModel);
   59 
   60 
   61     connect(ui->quickFilterView, &QuickFilterView::filterTextChanged,
   62             objectFilterProxyModel, &QSortFilterProxyModel::setFilterWildcard);
   63     connect(ui->quickFilterView, &QuickFilterView::filterClosed, ui->treeView,
   64             static_cast<void(QWidget::*)()>(&QWidget::setFocus));
   65 
   66 
   67     connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
   68         tree->showItemsNumber(this->objectFilterProxyModel->rowCount());
   69     });
   70 }