Debian Codegraph @

src/view.cpp

raw symbols SCIP
1 /*
2 * midisnoop - MIDI monitor and prober
3 * Copyright (C) 2012 Devin Anderson
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 675 Mass
17 * Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "util.h"
21 #include "view.h"
22
23 View::View(QWidget *rootWidget, QObject *parent):
24 QObject(parent)
25 {
26 connect(&closeEventFilter, SIGNAL(closeRequest()),
27 SIGNAL(closeRequest()));
28 rootWidget->installEventFilter(&closeEventFilter);
29 this->rootWidget = rootWidget;
30 }
31
32 View::~View()
33 {
34 delete rootWidget;
35 }
36
37 const QWidget *
38 View::getRootWidget() const
39 {
40 return rootWidget;
41 }
42
43 QWidget *
44 View::getRootWidget()
45 {
46 return rootWidget;
47 }
48
49 void
50 View::hide()
51 {
52 setVisible(false);
53 }
54
55 bool
56 View::isCloseEnabled() const
57 {
58 return closeEventFilter.isCloseEnabled();
59 }
60
61 bool
62 View::isVisible() const
63 {
64 return rootWidget->isVisible();
65 }
66
67 void
68 View::setCloseEnabled(bool enabled)
69 {
70 if (closeEventFilter.isCloseEnabled() != enabled) {
71 closeEventFilter.setCloseEnabled(enabled);
72 emit closeEnabledChanged(enabled);
73 }
74 }
75
76 void
77 View::setVisible(bool visible)
78 {
79 if (rootWidget->isVisible() != visible) {
80 rootWidget->setVisible(visible);
81 emit visibilityChanged(visible);
82 }
83 }
84
85 void
86 View::show()
87 {
88 setVisible(true);
89 }