From fe3832b3391a90867da0b3935ff474cd313ffbcc Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 20 Sep 2005 14:44:40 +0000 Subject: [PATCH] Fix some problems with Study Properties --- src/SalomeApp/SalomeApp_Application.cxx | 51 +++---- .../SalomeApp_StudyPropertiesDlg.cxx | 137 ++++++++++++------ src/SalomeApp/resources/SalomeApp_msg_en.po | 2 +- 3 files changed, 116 insertions(+), 74 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 16b7ab939..f787fc207 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -241,11 +241,11 @@ QString SalomeApp_Application::applicationVersion() const if ( _app_version.isEmpty() ) { QString resVersion = tr( "APP_VERSION" ); - if ( resVersion != "APP_VERSION" ) + if ( resVersion != "APP_VERSION" ) { _app_version = resVersion; } - else + else { QString path( ::getenv( "GUI_ROOT_DIR" ) ); if ( !path.isEmpty() ) @@ -258,15 +258,15 @@ QString SalomeApp_Application::applicationVersion() const QString line; vf.readLine( line, 1024 ); vf.close(); - + if ( !line.isEmpty() ) { while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) ) line.remove( line.length() - 1, 1 ); - + int idx = line.findRev( ":" ); if ( idx != -1 ) - _app_version = line.mid( idx + 1 ).stripWhiteSpace(); + _app_version = line.mid( idx + 1 ).stripWhiteSpace(); } } } @@ -299,7 +299,7 @@ bool SalomeApp_Application::activateModule( const QString& modName ) if ( actName == modName ) return true; - putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) ); + putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) ); saveWindowsGeometry(); @@ -307,7 +307,7 @@ bool SalomeApp_Application::activateModule( const QString& modName ) updateModuleActions(); - putInfo( "" ); + putInfo( "" ); if ( !status ) return false; @@ -789,7 +789,7 @@ void SalomeApp_Application::onDeleteReferences() _PTR(Study) aStudyDS = aStudy->studyDS(); _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder(); _PTR(SObject) anObj; - + for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { if ( it.Value()->hasEntry() ) @@ -1550,7 +1550,7 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref ) pref->setItemProperty( vtkTS, "min", 1 ); pref->setItemProperty( vtkTS, "max", 150 ); - + pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup, SalomeApp_Preferences::Bool, "Plot2d", "ShowLegend" ); @@ -1561,28 +1561,28 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref ) aLegendPosList.append( tr("PREF_RIGHT") ); aLegendPosList.append( tr("PREF_TOP") ); aLegendPosList.append( tr("PREF_BOTTOM") ); - + QValueList anIndexesList; anIndexesList.append(0); anIndexesList.append(1); anIndexesList.append(2); anIndexesList.append(3); - + pref->setItemProperty( legendPosition, "strings", aLegendPosList ); pref->setItemProperty( legendPosition, "indexes", anIndexesList ); - + int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup, SalomeApp_Preferences::Selector, "Plot2d", "CurveType" ); QStringList aCurveTypesList; aCurveTypesList.append( tr("PREF_POINTS") ); aCurveTypesList.append( tr("PREF_LINES") ); aCurveTypesList.append( tr("PREF_SPLINE") ); - + anIndexesList.clear(); anIndexesList.append(0); anIndexesList.append(1); anIndexesList.append(2); - + pref->setItemProperty( curveType, "strings", aCurveTypesList ); pref->setItemProperty( curveType, "indexes", anIndexesList ); @@ -1591,15 +1591,15 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref ) pref->setItemProperty( markerSize, "min", 0 ); pref->setItemProperty( markerSize, "max", 100 ); - + QStringList aScaleModesList; aScaleModesList.append( tr("PREF_LINEAR") ); aScaleModesList.append( tr("PREF_LOGARITHMIC") ); - + anIndexesList.clear(); anIndexesList.append(0); anIndexesList.append(1); - + int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup, SalomeApp_Preferences::Selector, "Plot2d", "HorScaleMode" ); @@ -1608,13 +1608,13 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref ) int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup, SalomeApp_Preferences::Selector, "Plot2d", "VerScaleMode" ); - + pref->setItemProperty( verScale, "strings", aScaleModesList ); pref->setItemProperty( verScale, "indexes", anIndexesList ); pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup, SalomeApp_Preferences::Color, "Plot2d", "Background" ); - + int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat ); int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab ); pref->setItemProperty( dirGroup, "columns", 1 ); @@ -1939,6 +1939,7 @@ void SalomeApp_Application::onProperties() //study->updateCaptions(); updateDesktopTitle(); + updateActions(); } /*!*/ @@ -1987,19 +1988,19 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t mgr->selectedObjects(aList); // "Delete reference" item should appear only for invalid references - + // Check if selected objects is invalid references bool isInvalidRefs = true; - + if ( aList.Extent() < 1 ) isInvalidRefs = false; - + if ( isInvalidRefs ) { SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); _PTR(Study) aStudyDS = aStudy->studyDS(); _PTR(SObject) anObj; - + for ( SALOME_ListIteratorOfListIO it( aList ); it.More() && isInvalidRefs; it.Next() ) { if ( it.Value()->hasEntry() ) @@ -2010,7 +2011,7 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t } } } - + // Add "Delete refrence" item to popup if ( isInvalidRefs ) { @@ -2029,7 +2030,7 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t if (currentModule && currentModule->moduleName() == aModuleTitle) return; thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) ); - + } /*!Update obect browser*/ diff --git a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx index 35015ee04..2a7040d54 100644 --- a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx +++ b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx @@ -14,11 +14,21 @@ #include "SalomeApp_Study.h" #include "SUIT_Session.h" +#include +#include -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +// OCCT Includes +#include +#include +// CORBA Headers +#include +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +// QT Includes #include #include + using namespace std; #define DEFAULT_MARGIN 11 @@ -54,23 +64,24 @@ public: { QStringList list; switch(getUserType()) { - case SalomeApp_StudyPropertiesDlg::prpModeId: - { - list << SalomeApp_StudyPropertiesDlg::tr("PRP_MODE_FROM_SCRATCH") << - SalomeApp_StudyPropertiesDlg::tr("PRP_MODE_FROM_COPYFROM"); - theWidget->insertList(list); - break; - } + //case SalomeApp_StudyPropertiesDlg::prpModeId: + // { + // list << SalomeApp_StudyPropertiesDlg::tr("PRP_MODE_FROM_SCRATCH") << + // SalomeApp_StudyPropertiesDlg::tr("PRP_MODE_FROM_COPYFROM"); + // theWidget->insertList(list); + // break; + // } case SalomeApp_StudyPropertiesDlg::prpLockedId: { list << SalomeApp_StudyPropertiesDlg::tr( "PRP_NO" ) << SalomeApp_StudyPropertiesDlg::tr( "PRP_YES" ); - theWidget->insertList(list, getValue() == SalomeApp_StudyPropertiesDlg::tr( "PRP_NO" ) ? 0 : 1 ); + theWidget->insertList(list, getValue() == SalomeApp_StudyPropertiesDlg::tr( "PRP_NO" ) ? 0 : 1 ); break; } case SalomeApp_StudyPropertiesDlg::prpModificationsId: { - SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); - if (study) { + SalomeApp_Study* study = + dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + if (study) { _PTR(Study) studyDoc = study->studyDS(); _PTR(AttributeStudyProperties) propAttr; if ( studyDoc ) { @@ -82,17 +93,17 @@ public: int aCnt = aUsers.size(); for ( int i = 0; i < aCnt; i++ ) { QString val; - val.sprintf("%2.2d/%2.2d/%2d %2.2d:%2.2d", - aDays [i], - aMonths[i], - aYears [i], - aHours [i], + val.sprintf("%2.2d/%2.2d/%2d %2.2d:%2.2d", + aDays [i], + aMonths[i], + aYears [i], + aHours [i], aMins [i]); val = val + " : " + QString( aUsers[i].c_str() ); list.prepend(val); } theWidget->setDuplicatesEnabled(true); - theWidget->insertList(list); + theWidget->insertList(list); } } } @@ -127,7 +138,7 @@ SalomeApp_StudyPropertiesDlg::SalomeApp_StudyPropertiesDlg(QWidget* parent) QGridLayout* mainLayout = new QGridLayout(this); mainLayout->setMargin(DEFAULT_MARGIN); mainLayout->setSpacing(DEFAULT_SPACING); - + myPropList = new SalomeApp_ListView(this); myPropList->addColumn(""); myPropList->addColumn(""); @@ -141,11 +152,13 @@ SalomeApp_StudyPropertiesDlg::SalomeApp_StudyPropertiesDlg(QWidget* parent) myCancelBtn = new QPushButton(tr("BUT_CANCEL"), this); mainLayout->addWidget(myCancelBtn, 1, 2); - QSpacerItem* spacer1 = new QSpacerItem(SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum); + QSpacerItem* spacer1 = + new QSpacerItem(SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum); mainLayout->addItem(spacer1, 1, 1); // Display study properties - SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + SalomeApp_Study* study = + dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); if (study) myStudyDoc = study->studyDS(); @@ -169,7 +182,7 @@ void SalomeApp_StudyPropertiesDlg::initData() { bool hasData = myStudyDoc; _PTR(AttributeStudyProperties) propAttr; - if (hasData) + if (hasData) propAttr = myStudyDoc->GetProperties(); hasData = hasData && propAttr; @@ -188,7 +201,7 @@ void SalomeApp_StudyPropertiesDlg::initData() item->setValue(strDate); } } - + // Creation mode // item = new SalomeApp_PropItem(myPropList, item, tr("PRP_MODE")+":", true, prpModeId); // item->setEditingType( SalomeApp_EntityEdit::etComboBox); @@ -196,12 +209,23 @@ void SalomeApp_StudyPropertiesDlg::initData() // Locked or not item = new SalomeApp_PropItem(myPropList, item, tr("PRP_LOCKED")+":", true, prpLockedId); - item->setEditingType( SalomeApp_EntityEdit::etComboBox); + item->setEditingType( SalomeApp_EntityEdit::etComboBox); if ( hasData ) item->setValue( tr( propAttr->IsLocked() ? "PRP_YES" : "PRP_NO" ) ); // Saved or not item = new SalomeApp_PropItem(myPropList, item, tr("PRP_MODIFIED")+":", false, prpSavedId); + bool isModified = false; + SalomeApp_Study* study = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); + if (study) { + isModified = study->isModified(); + if (hasData) { + if (propAttr->IsModified() != isModified) { + propAttr->SetModified((int)isModified); + } + } + } if (hasData) { if (propAttr->IsModified()) item->setValue( tr( "PRP_YES" ) ); @@ -210,20 +234,20 @@ void SalomeApp_StudyPropertiesDlg::initData() } // Modifications list - item = new SalomeApp_PropItem(myPropList, item, tr("PRP_MODIFICATIONS")+":", true, prpModificationsId); - item->setEditingType( SalomeApp_EntityEdit::etComboBox); - if (hasData) { + item = new SalomeApp_PropItem(myPropList, item, tr("PRP_MODIFICATIONS")+":", true, prpModificationsId); + item->setEditingType( SalomeApp_EntityEdit::etComboBox); + if (hasData) { std::vector aUsers; std::vector aMins, aHours, aDays, aMonths, aYears; propAttr->GetModificationsList(aUsers, aMins, aHours, aDays, aMonths, aYears, false); int aLast = aUsers.size()-1; if (aLast >= 0) { QString val; - val.sprintf("%2.2d/%2.2d/%2d %2.2d:%2.2d", - aDays [aLast], - aMonths[aLast], - aYears [aLast], - aHours [aLast], + val.sprintf("%2.2d/%2.2d/%2d %2.2d:%2.2d", + aDays [aLast], + aMonths[aLast], + aYears [aLast], + aHours [aLast], aMins [aLast]); val = val + " : " + QString(aUsers[aUsers.size()-1].c_str()); item->setValue(val); @@ -250,21 +274,37 @@ void SalomeApp_StudyPropertiesDlg::onOK() if (acceptData()) { _PTR(AttributeStudyProperties) propAttr = myStudyDoc->GetProperties(); - myChanged = propChanged(); - if ( propAttr && myChanged ) { + //myChanged = propChanged(); + if ( propAttr /*&& myChanged*/ ) { QListViewItemIterator it( myPropList ); // iterate through all items of the listview for ( ; it.current(); ++it ) { SalomeApp_PropItem* item = (SalomeApp_PropItem*)(it.current()); switch (item->getUserType()) { case prpAuthorId: - propAttr->SetUserName(item->getValue().stripWhiteSpace().latin1()); - break; - case prpModeId: - propAttr->SetCreationMode(item->getValue().stripWhiteSpace().latin1()); + if (QString(propAttr->GetUserName().c_str()) != item->getValue().stripWhiteSpace()) { + if (!propAttr->IsLocked()) { + propAttr->SetUserName(item->getValue().stripWhiteSpace().latin1()); + myChanged = true; + } else { + SUIT_MessageBox::warn1(SUIT_Session::session()->activeApplication()->desktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); + } + } break; + //case prpModeId: + // propAttr->SetCreationMode(item->getValue().stripWhiteSpace().latin1()); + // break; case prpLockedId: - propAttr->SetLocked(item->getValue().compare(tr("PRP_YES")) == 0); + { + bool bLocked = item->getValue().compare(tr("PRP_YES")) == 0; + if (propAttr->IsLocked() != bLocked) { + propAttr->SetLocked(bLocked); + myChanged = true; + } + } break; default: break; @@ -276,14 +316,15 @@ void SalomeApp_StudyPropertiesDlg::onOK() } /*! - Check is properties chenged? + Check is properties changed? */ -bool SalomeApp_StudyPropertiesDlg::propChanged() { +bool SalomeApp_StudyPropertiesDlg::propChanged() +{ _PTR(AttributeStudyProperties) propAttr = myStudyDoc->GetProperties(); - if ( propAttr ) { - QListViewItemIterator it( myPropList ); + if (propAttr) { + QListViewItemIterator it (myPropList); // iterate through all items of the listview - for ( ; it.current(); ++it ) { + for (; it.current(); ++it) { SalomeApp_PropItem* item = (SalomeApp_PropItem*)(it.current()); switch (item->getUserType()) { case prpAuthorId: @@ -291,11 +332,11 @@ bool SalomeApp_StudyPropertiesDlg::propChanged() { return true; } break; - case prpModeId: - if ( QString( propAttr->GetCreationMode().c_str() ) != item->getValue().stripWhiteSpace() ) { - return true; - } - break; + //case prpModeId: + // if ( QString( propAttr->GetCreationMode().c_str() ) != item->getValue().stripWhiteSpace() ) { + // return true; + // } + // break; case prpLockedId: { bool bLocked = item->getValue().compare( tr( "PRP_YES" ) ) == 0; diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index ad917a2ce..f9296e3e5 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -357,7 +357,7 @@ msgid "SalomeApp_StudyPropertiesDlg::PRP_AUTHOR" msgstr "Author" msgid "SalomeApp_StudyPropertiesDlg::PRP_DATE" -msgstr "Date" +msgstr "Created" msgid "SalomeApp_StudyPropertiesDlg::PRP_MODE" msgstr "Mode" -- 2.39.2