scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

PartMdiView.cpp
Go to the documentation of this file.
1 
13 
31 #include "PartMdiView.h"
32 #include "AbstractPart.h"
33 
34 #include <QCloseEvent>
35 #include <QMenu>
36 #include <QMdiArea>
37 
38 PartMdiView::PartMdiView(AbstractPart *part, QWidget * embedded_view)
39  : QMdiSubWindow(0), d_part(part), d_closing(false), d_status(Closed)
40 {
41  setWindowIcon(d_part->icon());
43  connect(d_part, SIGNAL(aspectDescriptionChanged(const AbstractAspect *)),
44  this, SLOT(handleAspectDescriptionChanged(const AbstractAspect *)));
45  connect(d_part, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect*)),
46  this, SLOT(handleAspectAboutToBeRemoved(const AbstractAspect*)));
47  setWidget(embedded_view);
48 }
49 
50 void PartMdiView::contextMenuEvent(QContextMenuEvent *event)
51 {
52  QMenu *menu = d_part->createContextMenu();
53  menu->exec(event->globalPos());
54  delete menu;
55 }
56 
58 {
59 }
60 
62 {
63  if (aspect != d_part) return;
64  setWindowTitle(d_part->caption());
65  update();
66 }
67 
69 {
70  if (aspect != d_part) return;
71  d_closing = true;
72  close();
73 }
74 
75 void PartMdiView::closeEvent(QCloseEvent *event)
76 {
77  if (!d_closing) {
78  d_closing = true;
79  d_part->remove();
80  event->accept();
81  }
82  d_closing = false;
83 
84  SubWindowStatus old_status = d_status;
85  d_status = Closed;
86  emit statusChanged(this, old_status, d_status);
87 }
88 
89 void PartMdiView::hideEvent(QHideEvent *event)
90 {
91  SubWindowStatus old_status = d_status;
92  d_status = Hidden;
93  emit statusChanged(this, old_status, d_status);
94  event->accept();
95 }
96 
97 void PartMdiView::showEvent(QShowEvent *event)
98 {
99  SubWindowStatus old_status = d_status;
100  d_status = Visible;
101  emit statusChanged(this, old_status, d_status);
102  event->accept();
103 }
104 
AbstractPart.h
PartMdiView::hideEvent
virtual void hideEvent(QHideEvent *event)
Definition: PartMdiView.cpp:89
PartMdiView::showEvent
virtual void showEvent(QShowEvent *event)
Definition: PartMdiView.cpp:97
PartMdiView::d_part
AbstractPart * d_part
The aspect that owns the view.
Definition: PartMdiView.h:93
PartMdiView::d_status
SubWindowStatus d_status
Definition: PartMdiView.h:103
PartMdiView::Hidden
@ Hidden
Definition: PartMdiView.h:64
PartMdiView::closeEvent
virtual void closeEvent(QCloseEvent *event)
When I'm being closed, remove my Aspect from its parent.
Definition: PartMdiView.cpp:75
PartMdiView::handleAspectAboutToBeRemoved
void handleAspectAboutToBeRemoved(const AbstractAspect *aspect)
Definition: PartMdiView.cpp:68
AbstractAspect::icon
virtual QIcon icon() const
Return an icon to be used for decorating my views.
Definition: AbstractAspect.cpp:298
PartMdiView::statusChanged
void statusChanged(PartMdiView *view, PartMdiView::SubWindowStatus from, PartMdiView::SubWindowStatus to)
PartMdiView::d_closing
bool d_closing
Whether I'm just being closed.
Definition: PartMdiView.h:102
AbstractAspect::caption
QString caption() const
Definition: AbstractAspect.cpp:293
PartMdiView::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *event)
Show a context menu for the view and the aspect.
Definition: PartMdiView.cpp:50
PartMdiView::Visible
@ Visible
Definition: PartMdiView.h:65
PartMdiView::SubWindowStatus
SubWindowStatus
Definition: PartMdiView.h:62
PartMdiView::~PartMdiView
virtual ~PartMdiView()
Definition: PartMdiView.cpp:57
PartMdiView::PartMdiView
PartMdiView(AbstractPart *part, QWidget *embedded_view)
Construct a view owned by the given aspect.
Definition: PartMdiView.cpp:38
PartMdiView::handleAspectDescriptionChanged
void handleAspectDescriptionChanged(const AbstractAspect *aspect)
Keep my window title in sync with AbstractAspect::caption().
Definition: PartMdiView.cpp:61
AbstractAspect::remove
virtual void remove()
Remove me from my parent's list of children.
Definition: AbstractAspect.h:250
AbstractPart::createContextMenu
virtual QMenu * createContextMenu() const
Return AbstractAspect::createContextMenu() plus operations on the primary view.
Definition: AbstractPart.cpp:42
PartMdiView::Closed
@ Closed
Definition: PartMdiView.h:63
PartMdiView.h
AbstractAspect
Base class of all persistent objects in a Project.
Definition: AbstractAspect.h:86
AbstractPart
Base class of Aspects with MDI windows as views.
Definition: AbstractPart.h:44