Mercurial > hg > octave-nkf
comparison gui/src/HistoryDockWidget.cpp @ 13545:ffc2e1d1ad5f
History can be filtered with an input search box while typing.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 26 Jul 2011 23:56:03 +0200 |
parents | 869c62c15e95 |
children | 5ef33f99a078 |
comparison
equal
deleted
inserted
replaced
13544:81eef7babeb5 | 13545:ffc2e1d1ad5f |
---|---|
15 * You should have received a copy of the GNU General Public License | 15 * You should have received a copy of the GNU General Public License |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ | 17 */ |
18 | 18 |
19 #include "HistoryDockWidget.h" | 19 #include "HistoryDockWidget.h" |
20 #include <QHBoxLayout> | 20 #include <QVBoxLayout> |
21 | 21 |
22 HistoryDockWidget::HistoryDockWidget (QWidget * parent):QDockWidget (parent) | 22 HistoryDockWidget::HistoryDockWidget (QWidget * parent):QDockWidget (parent) |
23 { | 23 { |
24 setObjectName ("HistoryDockWidget"); | 24 setObjectName ("HistoryDockWidget"); |
25 construct (); | 25 construct (); |
26 } | 26 } |
27 | 27 |
28 void | 28 void |
29 HistoryDockWidget::construct () | 29 HistoryDockWidget::construct () |
30 { | 30 { |
31 m_sortFilterProxyModel.setSourceModel(OctaveLink::instance ()->historyModel()); | |
31 m_historyListView = new QListView (this); | 32 m_historyListView = new QListView (this); |
32 m_historyListView->setModel (OctaveLink::instance ()->historyModel()); | 33 m_historyListView->setModel (&m_sortFilterProxyModel); |
33 m_historyListView->setAlternatingRowColors (true); | 34 m_historyListView->setAlternatingRowColors (true); |
34 m_historyListView->setEditTriggers (QAbstractItemView::NoEditTriggers); | 35 m_historyListView->setEditTriggers (QAbstractItemView::NoEditTriggers); |
35 QHBoxLayout *layout = new QHBoxLayout (); | 36 m_filterLineEdit = new QLineEdit (this); |
37 QVBoxLayout *layout = new QVBoxLayout (); | |
36 | 38 |
37 setWindowTitle (tr ("Command History")); | 39 setWindowTitle (tr ("Command History")); |
38 setWidget (new QWidget ()); | 40 setWidget (new QWidget ()); |
39 | 41 |
40 layout->addWidget (m_historyListView); | 42 layout->addWidget (m_historyListView); |
43 layout->addWidget (m_filterLineEdit); | |
41 layout->setMargin (2); | 44 layout->setMargin (2); |
42 | 45 |
43 widget ()->setLayout (layout); | 46 widget ()->setLayout (layout); |
47 | |
48 connect (m_filterLineEdit, SIGNAL (textEdited (QString)), this, SLOT (setFilter (QString))); | |
44 } | 49 } |
45 | 50 |
46 void | 51 void |
47 HistoryDockWidget::noticeSettings () | 52 HistoryDockWidget::noticeSettings () |
48 { | 53 { |
49 | 54 |
50 } | 55 } |
56 | |
57 void | |
58 HistoryDockWidget::setFilter(QString filter) | |
59 { | |
60 m_historyListView->setEnabled (false); | |
61 m_sortFilterProxyModel.setFilterWildcard ( QString ("*%1*").arg (filter)); | |
62 m_historyListView->setEnabled (true); | |
63 } |