Mercurial > hg > octave-nkf
annotate gui/src/HistoryDockWidget.cpp @ 13577:e440b3f32f02
Fixed bug with closing subwindows.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 01 Aug 2011 18:51:36 +0200 |
parents | 807e5e9b7591 |
children | c0e66d6e3dc8 |
rev | line source |
---|---|
13504
13e3d60aff2d
Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13495
diff
changeset
|
1 /* OctaveGUI - A graphical user interface for Octave |
13495 | 2 * Copyright (C) 2011 Jacob Dawid |
3 * jacob.dawid@googlemail.com | |
4 * | |
5 * This program is free software: you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation, either version 3 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
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/>. | |
17 */ | |
18 | |
19 #include "HistoryDockWidget.h" | |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
20 #include <QVBoxLayout> |
13495 | 21 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
22 HistoryDockWidget::HistoryDockWidget (QWidget * parent):QDockWidget (parent) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
23 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
24 setObjectName ("HistoryDockWidget"); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
25 construct (); |
13495 | 26 } |
27 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
28 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
29 HistoryDockWidget::construct () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
30 { |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
31 m_sortFilterProxyModel.setSourceModel(OctaveLink::instance ()->historyModel()); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
32 m_historyListView = new QListView (this); |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
33 m_historyListView->setModel (&m_sortFilterProxyModel); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
34 m_historyListView->setAlternatingRowColors (true); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
35 m_historyListView->setEditTriggers (QAbstractItemView::NoEditTriggers); |
13549
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13547
diff
changeset
|
36 m_historyListView->setStatusTip (tr ("Doubleclick a command to transfer it to the terminal.")); |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
37 m_filterLineEdit = new QLineEdit (this); |
13549
807e5e9b7591
Added lots of status tips.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13547
diff
changeset
|
38 m_filterLineEdit->setStatusTip (tr ("Enter text to filter the command history.")); |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
39 QVBoxLayout *layout = new QVBoxLayout (); |
13495 | 40 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
41 setWindowTitle (tr ("Command History")); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
42 setWidget (new QWidget ()); |
13495 | 43 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
44 layout->addWidget (m_historyListView); |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
45 layout->addWidget (m_filterLineEdit); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
46 layout->setMargin (2); |
13495 | 47 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
48 widget ()->setLayout (layout); |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
49 |
13547
7d106550be8f
Connected filterinh via slots, which is significantly faster.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13546
diff
changeset
|
50 connect (m_filterLineEdit, SIGNAL (textEdited (QString)), &m_sortFilterProxyModel, SLOT (setFilterWildcard(QString))); |
13546
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
51 connect (m_historyListView, SIGNAL (doubleClicked (QModelIndex)), this, SLOT (handleDoubleClick (QModelIndex))); |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
52 connect (this, SIGNAL (visibilityChanged(bool)), this, SLOT(handleVisibilityChanged(bool))); |
13495 | 53 } |
13536
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
54 |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
55 void |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
56 HistoryDockWidget::noticeSettings () |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
57 { |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
58 |
869c62c15e95
Few minor improvements, added advanced settings for file browser.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13518
diff
changeset
|
59 } |
13545
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
60 |
ffc2e1d1ad5f
History can be filtered with an input search box while typing.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13536
diff
changeset
|
61 void |
13546
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
62 HistoryDockWidget::handleDoubleClick (QModelIndex modelIndex) |
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
63 { |
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
64 emit commandDoubleClicked (modelIndex.data().toString()); |
5ef33f99a078
Command get inserted by double clicking in the command history again.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13545
diff
changeset
|
65 } |
13577
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
66 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
67 void |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
68 HistoryDockWidget::handleVisibilityChanged (bool visible) |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
69 { |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
70 if (visible) |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
71 emit activeChanged (true); |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
72 } |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
73 |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
74 void |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
75 HistoryDockWidget::closeEvent (QCloseEvent *event) |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
76 { |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
77 emit activeChanged (false); |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
78 QDockWidget::closeEvent (event); |
e440b3f32f02
Fixed bug with closing subwindows.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13549
diff
changeset
|
79 } |