Version: 9.16.0
QtGuiContext.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "QtGuiContext.hxx"
21#include <QClipboard>
22#include "ItemMimeData.hxx"
23
24//#define _DEVDEBUG_
25#include "YacsTrace.hxx"
26#include "chrono.hxx"
27
28using namespace std;
29using namespace YACS::ENGINE;
30using namespace YACS::HMI;
31
32QtGuiContext * QtGuiContext::_QtCurrent = 0;
33counters *QtGuiContext::_counters = 0;
34bool QtGuiContext::_delayCalc = false;
35std::set<QtGuiContext*> QtGuiContext::_setOfContext;
36
37QtGuiContext::QtGuiContext(GenericGui *gmain) : GuiContext()
38{
39 _gmain = gmain;
40 _schemaModel = 0;
41 _editTree = 0;
43 _scene = 0;
44 _view = 0;
45 _rootEdit = 0;
46 _window = 0;
48 _guiExecutor = 0;
50 _isEdition = true;
52 _fileName = QString();
53 _mapOfSchemaItem.clear();
54 _mapOfSceneItem.clear();
55 _mapOfEditionItem.clear();
57 _setOfContext.insert(this);
58}
59
61{
62 DEBTRACE("QtGuiContext::~QtGuiContext");
63 if (_invoc) delete _invoc;
64 _invoc = 0;
65 if (_subjectProc)
66 {
67 _proc->setEdition(false);
69 delete _subjectProc;
70 _subjectProc = 0;
71 }
72 _current = 0;
73 _QtCurrent = 0;
74 _setOfContext.erase(this);
75 // Avoid any possible copy from the destroyed schema.
76 QClipboard *clipboard = QApplication::clipboard();
77 clipboard->setMimeData(NULL);
78}
79
81{
82 _mapOfSchemaItem.clear();
83 _mapOfSceneItem.clear();
85}
86
88{
89 QClipboard *clipboard = QApplication::clipboard();
90 const QMimeData * data=clipboard->mimeData();
91 const ItemMimeData* myData = dynamic_cast<const ItemMimeData*>(data);
92 Subject * sub=0;
93
94 if(myData)
95 {
96 sub=myData->getSubject();
97 isCut=myData->getControl();
98 }
99
100 return sub;
101}
102
104{
105 ItemMimeData *mime = new ItemMimeData;
106 mime->setSubject(sub);
107 mime->setControl(true);
108 QClipboard *clipboard = QApplication::clipboard();
109 clipboard->setMimeData(mime);
110}
111
113{
114 ItemMimeData *mime = new ItemMimeData;
115 mime->setSubject(sub);
116 mime->setControl(false);
117 QClipboard *clipboard = QApplication::clipboard();
118 clipboard->setMimeData(mime);
119}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Base class for all schema objects.
Definition: Proc.hxx:44
virtual void setEdition(bool edition)
Definition: Proc.cxx:448
YACS::ENGINE::Proc * _proc
Definition: guiContext.hxx:86
static GuiContext * _current
Definition: guiContext.hxx:92
virtual void setProc(YACS::ENGINE::Proc *proc)
Definition: guiContext.cxx:81
YACS::HMI::SubjectProc * _subjectProc
Definition: guiContext.hxx:88
YACS::HMI::ProcInvoc * _invoc
Definition: guiContext.hxx:87
virtual bool getControl() const
virtual Subject * getSubject(int i=0) const
virtual void setSubject(Subject *sub)
virtual void setControl(bool control)
static QtGuiContext * _QtCurrent
YACS::HMI::GuiExecutor * _guiExecutor
YACS::HMI::Subject * _selectedSubject
std::map< YACS::HMI::Subject *, YACS::HMI::SchemaItem * > _mapOfSchemaItem
std::set< YACS::HMI::Subject * > _setOfModifiedSubjects
QItemSelectionModel * _selectionModel
void setSubjectToCut(YACS::HMI::Subject *sub)
YACS::HMI::GraphicsView * _view
std::map< YACS::HMI::Subject *, QWidget * > _mapOfEditionItem
FormEditTree * _editTree
YACS::HMI::GenericGui * _gmain
std::map< YACS::HMI::Subject *, YACS::HMI::SceneItem * > _mapOfSceneItem
QGraphicsScene * _scene
void setSubjectToCopy(YACS::HMI::Subject *sub)
virtual void setProc(YACS::ENGINE::Proc *proc)
static std::set< QtGuiContext * > _setOfContext
YACS::HMI::Subject * getSubjectToPaste(bool &isCut)
YACS::HMI::ItemEditionRoot * _rootEdit
QStackedWidget * _stackedWidget
YACS::HMI::SchemaModel * _schemaModel
virtual void clean(Command *command=0)