BaseTreeDock::BaseTreeDock(QString window_title, QString object_name, bool requires_refresh, QWidget *parent, Qt::WindowFlags flags) : BaseDock(parent, flags) , m_collapsed(true) { setWindowTitle(window_title); setObjectName(object_name); setFeatures(QDockWidget::AllDockWidgetFeatures); setAllowedAreas(Qt::AllDockWidgetAreas); m_arr_in = QIcon(":img/arrow-in.png"); m_arr_out = QIcon(":img/arrow-out.png"); QWidget *w = new QWidget(); QVBoxLayout *l = new QVBoxLayout(); w->setLayout(l); m_tree_view = new QTreeWidget(this); m_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers); m_tree_view->setDropIndicatorShown(false); m_tree_view->setProperty("showSortIndicator",QVariant(true)); m_tree_view->setSelectionMode(QAbstractItemView::ExtendedSelection); QHBoxLayout *s = new QHBoxLayout(); QLabel *lbl_search = new QLabel(tr("Search"),this); s->addWidget(lbl_search); m_le_search = new QLineEdit(this); m_le_search->setObjectName("le_search"); s->addWidget(m_le_search); m_btn_toggle_tree = new QPushButton(this); m_btn_toggle_tree->setIcon(m_arr_out); s->addWidget(m_btn_toggle_tree); QPushButton *btn_clear_search = new QPushButton(this); QIcon icn_cross(":img/cross.png"); btn_clear_search->setIcon(icn_cross); s->addWidget(btn_clear_search); l->addLayout(s); QPushButton *btn = new QPushButton(tr("Clear Filter"),this); w->layout()->addWidget(m_tree_view); w->layout()->addWidget(btn); setWidget(w); connect(btn, SIGNAL(clicked()),this,SLOT(clear_filter())); connect(m_le_search, SIGNAL(textChanged(QString)), this, SLOT(search_changed(QString))); connect(btn_clear_search, SIGNAL(clicked()),this,SLOT(clear_search())); connect(m_btn_toggle_tree, SIGNAL(clicked()), this, SLOT(toggle_tree())); connect(m_tree_view, SIGNAL(itemSelectionChanged()), this, SLOT(selection_changed())); m_requires_refresh = requires_refresh; if(DT){ connect(DT,SIGNAL(units_refreshed()),this,SLOT(refresh())); } }
ThoughtsDock::ThoughtsDock(QWidget *parent, Qt::WindowFlags flags) : BaseDock(parent, flags) { setWindowTitle(tr("Thoughts")); setObjectName("dock_thoughts"); setFeatures(QDockWidget::AllDockWidgetFeatures); setAllowedAreas(Qt::AllDockWidgetAreas); QWidget *w = new QWidget(); QVBoxLayout *l = new QVBoxLayout(); w->setLayout(l); // THOUGHTS TABLE tw_thoughts = new QTableWidget(this); tw_thoughts->setColumnCount(3); tw_thoughts->setEditTriggers(QTableWidget::NoEditTriggers); tw_thoughts->setWordWrap(true); tw_thoughts->setShowGrid(false); tw_thoughts->setGridStyle(Qt::NoPen); tw_thoughts->setAlternatingRowColors(true); tw_thoughts->setSelectionMode(QAbstractItemView::ExtendedSelection); tw_thoughts->setSelectionBehavior(QAbstractItemView::SelectRows); tw_thoughts->setHorizontalHeaderLabels(QStringList() << "Thought" << "Count" << "Description"); tw_thoughts->verticalHeader()->hide(); tw_thoughts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive); tw_thoughts->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive); tw_thoughts->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Interactive); tw_thoughts->setColumnWidth(0,100); tw_thoughts->setColumnWidth(1,50); tw_thoughts->horizontalHeader()->setStretchLastSection(true); QHBoxLayout *s = new QHBoxLayout(); QLabel *lbl_search = new QLabel("Search",this); s->addWidget(lbl_search); QLineEdit *le_search = new QLineEdit(this); le_search->setObjectName("le_search"); s->addWidget(le_search); QPushButton *btn_clear_search = new QPushButton(this); QIcon icn(":img/cross.png"); btn_clear_search->setIcon(icn); s->addWidget(btn_clear_search); l->addLayout(s); QPushButton *btn = new QPushButton("Clear Filter",this); w->layout()->addWidget(tw_thoughts); w->layout()->addWidget(btn); setWidget(w); connect(tw_thoughts,SIGNAL(itemSelectionChanged()),this,SLOT(selection_changed())); connect(btn, SIGNAL(clicked()),this,SLOT(clear_filter())); connect(le_search, SIGNAL(textChanged(QString)),this, SLOT(search_changed(QString))); connect(btn_clear_search, SIGNAL(clicked()),this,SLOT(clear_search())); }