From: vsv Date: Thu, 8 May 2014 13:59:19 +0000 (+0400) Subject: Added history branch into data tree (issue #22) X-Git-Tag: V_0.2~79 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=29cf3cffcf4536d96e3546f6c451359387e670e6;p=modules%2Fshaper.git Added history branch into data tree (issue #22) Removed generated TS files --- diff --git a/.gitignore b/.gitignore index 25d046ae1..f55ecf287 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ lib/ *.pro.user moc_*.* *.qm +*.ts #Resources resources !src/*/resources diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 2f4c40ba7..7461196d2 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -28,9 +28,9 @@ SET(PROJECT_RESOURCES PartSet_icons.qrc ) -SET(TEXT_RESOURCES - PartSet_msg_en.ts -) +#SET(TEXT_RESOURCES +# PartSet_msg_fr.ts +#) SET(PROJECT_LIBRARIES ModuleBase @@ -45,10 +45,17 @@ SET(PROJECT_AUTOMOC ) QT4_ADD_RESOURCES(PROJECT_COMPILED_RESOURCES ${PROJECT_RESOURCES}) -QT4_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES}) +#QT4_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES}) +#QT4_CREATE_TRANSLATION(QM_RESOURCES +# ${PROJECT_SOURCES} +# ${TEXT_RESOURCES} +# OPTIONS -extensions cpp -no-recursive +# ) -SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES}) -SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES}) +#SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES}) +SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES}) +#SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES}) +SOURCE_GROUP ("Resource Files" FILES ${PROJECT_RESOURCES}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI ${CMAKE_SOURCE_DIR}/src/Config @@ -68,8 +75,8 @@ ADD_LIBRARY(PartSet SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_COMPILED_RESOURCES} - ${TEXT_RESOURCES} - ${QM_RESOURCES} +# ${TEXT_RESOURCES} +# ${QM_RESOURCES} ) # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore @@ -78,3 +85,4 @@ TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI GeomAlgoAPI) ADD_DEPENDENCIES(PartSet ModuleBase) INSTALL(TARGETS PartSet DESTINATION bin) +#INSTALL(FILES ${QM_RESOURCES} DESTINATION bin) \ No newline at end of file diff --git a/src/PartSet/PartSet_msg_en.ts b/src/PartSet/PartSet_msg_en.ts deleted file mode 100644 index 4270bb8a8..000000000 --- a/src/PartSet/PartSet_msg_en.ts +++ /dev/null @@ -1,18 +0,0 @@ - - - - - @default - - - XGUI_Workshop - - HOME_MENU_TITLE - Home - - - NEW_MENU - New - - - diff --git a/src/PyConsole/CMakeLists.txt b/src/PyConsole/CMakeLists.txt index 4ba2ef124..aa79a1dc4 100644 --- a/src/PyConsole/CMakeLists.txt +++ b/src/PyConsole/CMakeLists.txt @@ -19,10 +19,9 @@ SET(PROJECT_AUTOMOC # resource files / to be processed by lrelease SET(TEXT_RESOURCES - resources/PyConsole_msg_en.ts - resources/PyConsole_msg_fr.ts - resources/PyConsole_msg_ja.ts + PyConsole_msg_fr.ts ) + # sources / static SET(PROJECT_SOURCES PyConsole_Console.cpp @@ -40,7 +39,12 @@ SET(PROJECT_LIBRARIES ${PYTHON_LIBRARIES} ) -QT4_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES}) +#QT4_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES}) +QT4_CREATE_TRANSLATION(QM_RESOURCES + ${PROJECT_SOURCES} + ${TEXT_RESOURCES} + OPTIONS -extensions cpp -no-recursive + ) SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${QM_RESOURCES}) @@ -61,5 +65,6 @@ ADD_LIBRARY(PyConsole SHARED TARGET_LINK_LIBRARIES(PyConsole ${PROJECT_LIBRARIES}) INSTALL(TARGETS PyConsole DESTINATION bin) +INSTALL(FILES ${QM_RESOURCES} DESTINATION bin) diff --git a/src/PyConsole/PyConsole_Console.cpp b/src/PyConsole/PyConsole_Console.cpp index 54391474f..79ae485e9 100644 --- a/src/PyConsole/PyConsole_Console.cpp +++ b/src/PyConsole/PyConsole_Console.cpp @@ -270,23 +270,23 @@ int PyConsole_Console::menuActions() const */ void PyConsole_Console::createActions() { - QAction* a = new QAction( tr( "EDIT_COPY_CMD" ), this ); - a->setStatusTip( tr( "EDIT_COPY_CMD" ) ); + QAction* a = new QAction( tr( "&Copy" ), this ); + a->setStatusTip( tr( "Copy" ) ); connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( copy() ) ); myActions.insert( CopyId, a ); - a = new QAction( tr( "EDIT_PASTE_CMD" ), this ); - a->setStatusTip( tr( "EDIT_PASTE_CMD" ) ); + a = new QAction( tr( "&Paste" ), this ); + a->setStatusTip( tr( "Paste" ) ); connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( paste() ) ); myActions.insert( PasteId, a ); - a = new QAction( tr( "EDIT_CLEAR_CMD" ), this ); - a->setStatusTip( tr( "EDIT_CLEAR_CMD" ) ); + a = new QAction( tr( "Clea&r" ), this ); + a->setStatusTip( tr( "Clear" ) ); connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( clear() ) ); myActions.insert( ClearId, a ); - a = new QAction( tr( "EDIT_SELECTALL_CMD" ), this ); - a->setStatusTip( tr( "EDIT_SELECTALL_CMD" ) ); + a = new QAction( tr( "Select &All" ), this ); + a->setStatusTip( tr( "Select all" ) ); connect( a, SIGNAL( triggered( bool ) ), myEditor, SLOT( selectAll() ) ); myActions.insert( SelectAllId, a ); diff --git a/src/PyConsole/resources/PyConsole_msg_en.ts b/src/PyConsole/resources/PyConsole_msg_en.ts deleted file mode 100644 index 85393a2bf..000000000 --- a/src/PyConsole/resources/PyConsole_msg_en.ts +++ /dev/null @@ -1,42 +0,0 @@ - - - - - PyConsole_Console - - - EDIT_COPY_CMD - &Copy - - - - EDIT_PASTE_CMD - &Paste - - - - EDIT_CLEAR_CMD - Clea&r - - - - EDIT_SELECTALL_CMD - Select &All - - - EDIT_DUMPCOMMANDS_CMD - D&ump commands - - - - PyConsole_Editor - - TOT_DUMP_PYCOMMANDS - Dump commands - - - PYTHON_FILES_FILTER - PYTHON Files (*.py) - - - diff --git a/src/PyConsole/resources/PyConsole_msg_fr.ts b/src/PyConsole/resources/PyConsole_msg_fr.ts deleted file mode 100644 index 910911562..000000000 --- a/src/PyConsole/resources/PyConsole_msg_fr.ts +++ /dev/null @@ -1,42 +0,0 @@ - - - - - PyConsole_Console - - - EDIT_COPY_CMD - &Copier - - - - EDIT_PASTE_CMD - C&oller - - - - EDIT_CLEAR_CMD - &Effacer - - - - EDIT_SELECTALL_CMD - &Tout sélectionner - - - EDIT_DUMPCOMMANDS_CMD - &Générer le script des commandes - - - - PyConsole_Editor - - TOT_DUMP_PYCOMMANDS - &Générer le script des commandes - - - PYTHON_FILES_FILTER - Fichiers PYTHON (*.py) - - - diff --git a/src/PyConsole/resources/PyConsole_msg_ja.ts b/src/PyConsole/resources/PyConsole_msg_ja.ts deleted file mode 100644 index c8d0fb17d..000000000 --- a/src/PyConsole/resources/PyConsole_msg_ja.ts +++ /dev/null @@ -1,42 +0,0 @@ - - - - - PyConsole_Console - - - EDIT_COPY_CMD - コピー(&C) - - - - EDIT_PASTE_CMD - 貼り付け(&P) - - - - EDIT_CLEAR_CMD - 削除(&r) - - - - EDIT_SELECTALL_CMD - すべて選択します。(&A) - - - EDIT_DUMPCOMMANDS_CMD - スクリプト コマンドを生成します。(&u) - - - - PyConsole_Editor - - TOT_DUMP_PYCOMMANDS - スクリプト コマンドを生成します。 - - - PYTHON_FILES_FILTER - ファイル (*.py) PYTHON - - - diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index ebae53b82..e1d4aee48 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -52,12 +52,12 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) XGUI_PartDataModel* aModel = new XGUI_PartDataModel(myDocument, this); aModel->setPartId(myPartModels.count()); myPartModels.append(aModel); - insertRows(partFolderNode(), aStart, aStart); + insertRow(aStart, partFolderNode()); } else { // Update top groups (other except parts QModelIndex aIndex = myModel->findParent(aFeature); int aStart = myModel->rowCount(aIndex) - 1; aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); - insertRows(aIndex, aStart, aStart); + insertRow(aStart, aIndex); } } else { // if sub-objects of first level nodes XGUI_PartModel* aPartModel = 0; @@ -72,7 +72,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) QModelIndex aIndex = aPartModel->findParent(aFeature); int aStart = aPartModel->rowCount(aIndex) - 1; aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); - insertRows(aIndex, aStart, aStart); + insertRow(aStart, aIndex); } } @@ -84,15 +84,13 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) if (aDoc == myDocument) { // If root objects if (aUpdMsg->group().compare(PARTS_GROUP) == 0) { // Updsate only Parts group int aStart = myPartModels.size(); - beginRemoveRows(partFolderNode(), aStart, aStart); removeSubModel(myPartModels.size() - 1); - endRemoveRows(); + removeRow(aStart - 1, partFolderNode()); } else { // Update top groups (other except parts QModelIndex aIndex = myModel->findGroup(aUpdMsg->group()); int aStart = myModel->rowCount(aIndex); aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); - beginRemoveRows(aIndex, aStart, aStart); - endRemoveRows(); + removeRow(aStart - 1, aIndex); } } else { XGUI_PartModel* aPartModel = 0; @@ -107,8 +105,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) QModelIndex aIndex = aPartModel->findGroup(aUpdMsg->group()); int aStart = aPartModel->rowCount(aIndex); aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); - beginRemoveRows(aIndex, aStart, aStart); - endRemoveRows(); + removeRow(aStart - 1, aIndex); } } @@ -145,7 +142,8 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) { if (!theIndex.isValid()) return QVariant(); - if (theIndex.internalId() == 0){ + switch (theIndex.internalId()) { + case PartsFolder: switch (theRole) { case Qt::DisplayRole: return tr("Parts") + QString(" (%1)").arg(rowCount(theIndex)); @@ -156,9 +154,37 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) default: return QVariant(); } + break; + case HistoryNode: + { + int aOffset = historyOffset(); + FeaturePtr aFeature = myDocument->feature(FEATURES_GROUP, theIndex.row() - aOffset); + switch (theRole) { + case Qt::DisplayRole: + if (aFeature) + return aFeature->data()->getName().c_str(); + else + return QVariant(); + case Qt::DecorationRole: + { + std::string aType = aFeature->getKind(); + if (aType.compare("Point") == 0) + return QIcon(":pictures/point_ico.png"); + if (aType.compare("Part") == 0) + return QIcon(":pictures/part_ico.png"); + if (aType.compare("Sketch") == 0) + return QIcon(":icons/sketch.png"); + } + case Qt::ToolTipRole: + return tr("Feature object"); + default: + return QVariant(); + } + } + break; } QModelIndex aParent = theIndex.parent(); - if (aParent.isValid() && (aParent.internalId() == 0)) { + if (aParent.isValid() && (aParent.internalId() == PartsFolder)) { return myPartModels.at(theIndex.row())->data(QModelIndex(), theRole); } return toSourceModelIndex(theIndex).data(theRole); @@ -173,12 +199,18 @@ QVariant XGUI_DocumentDataModel::headerData(int theSection, Qt::Orientation theO int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const { if (!theParent.isValid()) { - int aVal = myModel->rowCount(theParent) + myPartModels.size(); - return myModel->rowCount(theParent) + 1;//myPartModels.size(); + // Size of external models + int aVal = historyOffset(); + // Plus history size + aVal += myDocument->size(FEATURES_GROUP); + return aVal; } - if (theParent.internalId() == 0) { + if (theParent.internalId() == PartsFolder) { return myPartModels.size(); } + if (theParent.internalId() == HistoryNode) { + return 0; + } QModelIndex aParent = toSourceModelIndex(theParent); if (!isSubModel(aParent.model())) return 0; @@ -200,11 +232,13 @@ QModelIndex XGUI_DocumentDataModel::index(int theRow, int theColumn, const QMode aIndex = myModel->index(theRow, theColumn, theParent); aIndex = createIndex(theRow, theColumn, (void*)getModelIndex(aIndex)); } else { - // Create Parts node - aIndex = partFolderNode(); + if (theRow == aOffs) // Create Parts node + aIndex = partFolderNode(); + else // create history node + aIndex = createIndex(theRow, theColumn, HistoryNode); } } else { - if (theParent.internalId() == 0) { + if (theParent.internalId() == PartsFolder) { aIndex = myPartModels.at(theRow)->index(0, theColumn, QModelIndex()); } else { QModelIndex* aParent = (QModelIndex*)theParent.internalPointer(); @@ -218,7 +252,7 @@ QModelIndex XGUI_DocumentDataModel::index(int theRow, int theColumn, const QMode QModelIndex XGUI_DocumentDataModel::parent(const QModelIndex& theIndex) const { - if (theIndex.internalId() == 0) + if ((theIndex.internalId() == PartsFolder) || (theIndex.internalId() == HistoryNode)) return QModelIndex(); QModelIndex aIndex = toSourceModelIndex(theIndex); @@ -286,7 +320,7 @@ void XGUI_DocumentDataModel::clearModelIndexes() FeaturePtr XGUI_DocumentDataModel::feature(const QModelIndex& theIndex) const { - if (theIndex.internalId() == 0) + if (theIndex.internalId() == PartsFolder) return FeaturePtr(); QModelIndex aIndex = toSourceModelIndex(theIndex); @@ -297,14 +331,28 @@ FeaturePtr XGUI_DocumentDataModel::feature(const QModelIndex& theIndex) const return aModel->feature(aIndex); } -void XGUI_DocumentDataModel::insertRows(const QModelIndex& theParent, int theStart, int theEnd) +bool XGUI_DocumentDataModel::insertRows(int theRow, int theCount, const QModelIndex& theParent) { - beginInsertRows(theParent, theStart, theEnd); + beginInsertRows(theParent, theRow, theRow + theCount - 1); + //endInsertRows(); + + // Update history + QModelIndex aRoot; + int aRow = rowCount(aRoot); + beginInsertRows(aRoot, aRow, aRow); endInsertRows(); - if (theStart == 0) // Update parent if this is a first child in order to update node decoration - emit dataChanged(theParent, theParent); + + return true; } +bool XGUI_DocumentDataModel::removeRows(int theRow, int theCount, const QModelIndex& theParent) +{ + beginRemoveRows(theParent, theRow, theRow + theCount - 1); + endRemoveRows(); + return true; +} + + void XGUI_DocumentDataModel::removeSubModel(int theModelId) { XGUI_PartModel* aModel = myPartModels.at(theModelId); @@ -339,5 +387,11 @@ bool XGUI_DocumentDataModel::isPartSubModel(const QAbstractItemModel* theModel) QModelIndex XGUI_DocumentDataModel::partFolderNode() const { int aPos = myModel->rowCount(QModelIndex()); - return createIndex(aPos, columnCount() - 1, 0); + return createIndex(aPos, columnCount() - 1, PartsFolder); } + +int XGUI_DocumentDataModel::historyOffset() const +{ + // Nb of rows of top model + Parts folder + return myModel->rowCount(QModelIndex()) + 1; +} \ No newline at end of file diff --git a/src/XGUI/XGUI_DocumentDataModel.h b/src/XGUI/XGUI_DocumentDataModel.h index e389cd800..3c90dcf1f 100644 --- a/src/XGUI/XGUI_DocumentDataModel.h +++ b/src/XGUI/XGUI_DocumentDataModel.h @@ -46,12 +46,19 @@ public: virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const; + bool insertRows(int theRow, int theCount, const QModelIndex& theParent = QModelIndex()); + + bool removeRows(int theRow, int theCount, const QModelIndex& theParent = QModelIndex()); + //! Returns Feature object by the given Model index. //! Returns 0 if the given index is not index of a feature FeaturePtr feature(const QModelIndex& theIndex) const; private: + enum {PartsFolder, HistoryNode}; + + //! Converts QModelIndex of this model to QModelIndex of a one of sub-models. QModelIndex toSourceModelIndex(const QModelIndex& theProxy) const; @@ -64,9 +71,6 @@ private: //! Deletes all saved pointers on QModelIndex objects. void clearModelIndexes(); - //! Causes inserting of new nodes for given parent and indexes - void insertRows(const QModelIndex& theParent, int theStart, int theEnd); - //! Removes sub-model on removing a part object. Also it removes QModelIndex-es which refer to this model void removeSubModel(int theModelId); @@ -76,8 +80,11 @@ private: //! Returns true if the given model is a one of sub-models of Part type bool isPartSubModel(const QAbstractItemModel* theModel) const; + //! Returns Parts Folder node QModelIndex partFolderNode() const; + int historyOffset() const; + //! Document boost::shared_ptr myDocument; diff --git a/src/XGUI/XGUI_msg_fr.ts b/src/XGUI/XGUI_msg_fr.ts deleted file mode 100644 index 5562247ba..000000000 --- a/src/XGUI/XGUI_msg_fr.ts +++ /dev/null @@ -1,348 +0,0 @@ - - - - - XGUI_DocumentDataModel - - - Parts - - - - - Parts folder - - - - - XGUI_ErrorDialog - - - Application errors - - - - - XGUI_MainMenu - - - General - - - - - XGUI_MainWindow - - - New Geom - - - - - XGUI_OperationMgr - - - Operation launch - - - - - Previous operation is not finished and will be aborted - - - - - XGUI_PartDataModel - - - Parameters - - - - - Constructions - - - - - Bodies - - - - - XGUI_PropertyPanel - - - Property Panel - - - - - XGUI_TopDataModel - - - Parameters - - - - - Constructions - - - - - XGUI_ViewWindow - - - Dump view - - - - - Fit all - - - - - Fit area - - - - - Zoom - - - - - Panning - - - - - Global panning - - - - - Rotate - - - - - Reset - - - - - Front - - - - - Back - - - - - Top - - - - - Bottom - - - - - Left - - - - - Right - - - - - Clone - - - - - Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps) - - - - - XGUI_Viewer - - - Horizontal gradient - - - - - Vertical gradient - - - - - First diagonal gradient - - - - - Second diagonal gradient - - - - - First corner gradient - - - - - Second corner gradient - - - - - Third corner gradient - - - - - Fourth corner gradient - - - - - Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs) - - - - - XGUI_Workshop - - - - Undo - - - - - - Undo last command - - - - - - Redo - - - - - - Redo last command - - - - - Save... - - - - - Save the document - - - - - Rebuild - - - - - Rebuild data objects - - - - - Save as... - - - - - Save the document into a file - - - - - Open... - - - - - Open a new document - - - - - Exit - - - - - Exit application - - - - - - Save current file - - - - - The document is modified, save before exit? - - - - - The document is modified, save before opening another? - - - - - - Warning - - - - - Unable to open the file. - - - - - Unable to save the file. - - - - - Information about module "%1" doesn't exist. - - - - - Error - - - - - Object browser - - - - diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 40ad6a341..399af8230 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -9,8 +9,6 @@ pictures/rebuild.png - pictures/ViewPort.png - pictures/occ_view_back.png pictures/occ_view_bottom.png pictures/occ_view_camera_dump.png diff --git a/src/XGUI/pictures/ViewPort.png b/src/XGUI/pictures/ViewPort.png deleted file mode 100644 index b8273017d..000000000 Binary files a/src/XGUI/pictures/ViewPort.png and /dev/null differ