1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author: Guillaume Boulant (EDF/R&D)
23 #include "DataProcessor.hxx"
24 #include <Basics_Utils.hxx>
25 #include "QtHelper.hxx"
27 DataProcessor::DataProcessor(DataModel * dataModel) {
28 _dataModel = dataModel;
32 * This function retrieves in the data model all the DataObject
33 * associated to the item nameIds contained in the specified list. The
34 * input list is what the TreeView sends via the notification signal.
36 DataObjectVector * DataProcessor::extract(QStringList itemNameIdList) {
37 if ( _dataModel == NULL ) {
38 STDLOG("No data model associated to this processor");
42 DataObjectVector * dataObjectList = new DataObjectVector();
44 // We can request the dataModel to obtain the dataObject associated
45 // to each of the item (iteNameId is a TreeView id, Qt stuff only).
46 QStringList::const_iterator it;
47 for (it = itemNameIdList.constBegin(); it != itemNameIdList.constEnd(); ++it) {
48 QString itemNameId = *it;
49 DataObject * dataObject = _dataModel->getDataObject(QS2S(itemNameId));
51 if ( dataObject != NULL ) {
52 dataObjectList->push_back(dataObject);
54 LOG("No data object associated to the item "<<itemNameId);
57 return dataObjectList;
61 void DataProcessor::process(QStringList itemNameIdList) {
62 if ( _dataModel == NULL ) {
63 STDLOG("No data model");
67 this->preprocess(itemNameIdList);
69 // We can request the dataModel to obtain the dataObject associated
70 // to each of the item (iteNameId is a TreeView id, Qt stuff only).
71 QStringList::const_iterator it;
72 for (it = itemNameIdList.constBegin(); it != itemNameIdList.constEnd(); ++it) {
73 QString itemNameId = *it;
74 DataObject * dataObject = _dataModel->getDataObject(QS2S(itemNameId));
76 if ( dataObject != NULL ) {
77 this->processDataObject(dataObject);
79 STDLOG("No data object associated to the item "<<QS2S(itemNameId));
83 this->postprocess(itemNameIdList);