labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

PartMdiView.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  File : PartMdiView.cpp
3  Project : LabPlot
4  Description : QMdiSubWindow wrapper for aspect views.
5  --------------------------------------------------------------------
6  Copyright : (C) 2013-2019 by Alexander Semke (alexander.semke@web.de)
7  Copyright : (C) 2007,2008 Tilman Benkert (thzs@gmx.net)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
32 
33 #include <QCloseEvent>
34 #include <QIcon>
35 
36 /*!
37  * \class PartMdiView
38  *
39  * \brief QMdiSubWindow wrapper for aspect views.
40  *
41  * In addition to the functionality provided by QMdiSubWindow,
42  * this class automatically updates the window title when AbstractAspect::caption() is changed
43  * and holds the connection to the actual data visualized in this window via the pointer to \c AbstractPart.
44  */
45 PartMdiView::PartMdiView(AbstractPart* part) : QMdiSubWindow(nullptr), m_part(part) {
46  setWindowIcon(m_part->icon());
47  setWidget(m_part->view());
48  setAttribute(Qt::WA_DeleteOnClose);
50 
51  //resize the MDI sub window to fit the content of the view
52  resize(m_part->view()->size());
53 
56  connect(this, &QMdiSubWindow::windowStateChanged, this, &PartMdiView::slotWindowStateChanged);
57 }
58 
60  m_closing = true;
61 }
62 
64  return m_part;
65 }
66 
68  if (aspect != m_part)
69  return;
70 
71  setWindowTitle(m_part->name());
72 }
73 
75  if (aspect != m_part)
76  return;
77 
78  close();
79 }
80 
81 void PartMdiView::closeEvent(QCloseEvent *event) {
82  m_part->deleteView();
83  event->accept();
84 }
85 
86 void PartMdiView::slotWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState) {
87  Q_UNUSED(oldState);
88 
89  if (m_closing)
90  return;
91 
92  if (newState.testFlag(Qt::WindowActive) || newState.testFlag(Qt::WindowMaximized))
94  else
96 }
Base class of all persistent objects in a Project.
virtual QIcon icon() const
Return an icon to be used for decorating my views.
void aspectDescriptionChanged(const AbstractAspect *)
Emitted after the name, comment or caption spec have changed.
void aspectAboutToBeRemoved(const AbstractAspect *)
Emitted before an aspect is removed from its parent.
QString name() const
Base class of Aspects with MDI windows as views (AspectParts).
Definition: AbstractPart.h:36
void deleteView() const
virtual void registerShortcuts()
Definition: AbstractPart.h:58
virtual void unregisterShortcuts()
Definition: AbstractPart.h:59
virtual QWidget * view() const =0
Construct a primary view on me.
~PartMdiView() override
Definition: PartMdiView.cpp:59
void handleAspectAboutToBeRemoved(const AbstractAspect *)
Definition: PartMdiView.cpp:74
bool m_closing
Definition: PartMdiView.h:49
void handleAspectDescriptionChanged(const AbstractAspect *)
Definition: PartMdiView.cpp:67
AbstractPart * part() const
Definition: PartMdiView.cpp:63
PartMdiView(AbstractPart *)
Definition: PartMdiView.cpp:45
void closeEvent(QCloseEvent *) override
Definition: PartMdiView.cpp:81
AbstractPart * m_part
Definition: PartMdiView.h:48
void slotWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState)
Definition: PartMdiView.cpp:86