Salome HOME
0022628: [CEA 1202] The default icon disposition is not correct in french and in...
authorvsr <vsr@opencascade.com>
Thu, 28 Aug 2014 12:43:13 +0000 (16:43 +0400)
committervsr <vsr@opencascade.com>
Thu, 28 Aug 2014 12:43:13 +0000 (16:43 +0400)
Additional patch to maintain backward compatibility.

src/LightApp/LightApp_Application.cxx
src/Qtx/Qtx.cxx
src/Qtx/Qtx.h
src/Session/SALOME_Session_Server.cxx

index 575039445e162fd8a119248f66cd51248e22c356..edc93cedadcbe59bd338826eb7221eceacc9a458 100644 (file)
@@ -3047,6 +3047,12 @@ void LightApp_Application::savePreferences()
   if ( desktop() )
     aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
 
+#if GUI_DEVELOPMENT > 0
+  aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
+#else
+  aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
+#endif
+
   aResMgr->save();
 }
 
@@ -3242,6 +3248,7 @@ void LightApp_Application::loadDockWindowsState()
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
   bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
   bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
+  long version = Qtx::versionToId( aResMgr->stringValue( "salome", "version", "" ) );
 
   QString modName;
   if ( activeModule() )
@@ -3261,7 +3268,10 @@ void LightApp_Application::loadDockWindowsState()
 
   if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
     QByteArray arr;
-    aResMgr->value("windows_geometry", modName , arr );
+    if ( version > Qtx::versionToId( "7.4.1" ) )
+      aResMgr->value( "windows_geometry", modName , arr );
+    else
+      arr = aDefaultState;
     QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
     desktop()->restoreState( aTargetArray );
   }
index 0dc508b54c2a4864c4659a58f67102f528ea6aa2..9036354bcd14060a56b51e02bee345c7add06567 100755 (executable)
@@ -1991,7 +1991,83 @@ void Qtx::BackgroundData::setGradient( const QGradient& grad )
   myGradient = grad;
   setMode( Qtx::CustomGradientBackground );
 }
+
+/*!
+  \brief Convert string representation of version identifier to the numerical value.
+  Resulting value can be used for comparison of different versions (lower, higher, equal).
+
+  String representation of the version consists of zero or more components:
+
+  [major[.minor[.release[patchid]]]]
+  where
+  - major is version major number
+  - minor is version minor number
+  - release is version release number
+  - patchid is a version dev identifier which is one of the following
+    * 1 letter optionally followed by 1 or 2 digits, e.g. "a" for "alpha", "b1" for "beta 1"
+    * "rc" optionally followed by 1 or 2 digits, e.g. "rc1" for "release candidate 1"
+    * "dev" for development version (note: 7.4.0dev > 7.4.0, 7.4.0dev < 7.4.1, 7.4.0dev < 7.4.0a1)
+
+  If version string does not include any component or has invalid format, the function returns 0.
+
+  Examples:
+    1.0      - version 1.0
+    1.2.3a   - version 1.2.3 alpha
+    3.3.3b1  - version 3.3.3 beta 1
+    7.4.0rc1 - version 7.4.0 release candidate 1
+    7.4.0dev - dev version, i.e. future version 7.4.1 (or 7.5.0)
+
+  \param version string representation of version
+  \return numerical identifier of the version
+*/
+long Qtx::versionToId( const QString& version )
+{
+  long id = 0;
+
+  QRegExp vers_exp( "^([0-9]+)([A-Z]|RC|DEV)?([0-9]{0,2})$", Qt::CaseInsensitive );
+  
+  QStringList vers = version.split( ".", QString::SkipEmptyParts );
+  int major=0, minor=0;
+  int release = 0, dev1 = 0, dev2 = 0;
+  if ( vers.count() > 0 ) major = vers[0].toInt();
+  if ( vers.count() > 1 ) minor = vers[1].toInt();
+  if ( vers.count() > 2 ) {
+    if ( vers_exp.indexIn( vers[2] ) != -1 ) {
+      release = vers_exp.cap( 1 ).toInt();
+      QString tag = vers_exp.cap( 2 ).toLower();
+      if ( !tag.isEmpty() ) {
+       // patchid is subtracted from version number
+       // a   = 55 --> -(55 * 100) + patch number --> 4500..4599, e.g. 7.4.1a1  -> 704004501
+       // b   = 54 --> -(54 * 100) + patch number --> 4600..4699, e.g. 7.4.1b1  -> 704004601
+       // c   = 53 --> -(53 * 100) + patch number --> 4700..4799, e.g. 7.4.1c1  -> 704004701
+       // ...
+       // z   = 30 --> -( 1 * 100) + patch number --> 7000..7099, e.g. 7.4.1z1  -> 704007001
+       // rc  =  1 --> -( 1 * 100) + patch number --> 9900..9999, e.g. 7.4.1rc1 -> 704009901
+       // dev = -1 --> +( 1 * 100) + patch number --> 0100..0199, e.g. 7.4.1dev -> 704010100
+       // ---
+       // i.e. "a" < "b" < ... < "z" < "rc" < [stable] < "dev"
+       if ( tag == "rc" )
+         dev1 = 1;
+       else if ( tag == "dev" )
+         dev1 = -1;
+       else
+         dev1 = (int)( QChar('z').toLatin1() ) - (int)( tag[ 0 ].toLatin1() ) + 30;
+      }
+      if ( !vers_exp.cap( 3 ).isEmpty() )
+       dev2 = vers_exp.cap( 3 ).toInt();
+    }
+  }
   
+  int dev = dev1*100-dev2;
+  id = major;
+  id*=100; id+=minor;
+  id*=100; id+=release;
+  id*=10000;
+  id-=dev;
+
+  return id;
+}
 
 #ifndef WIN32
 
index d4c66b3fdb41ea43116f493671d56d3789abb53c..429653bc1d012acfbcd6b7eb6b431d80b65c961f 100755 (executable)
@@ -258,6 +258,8 @@ public:
   static QString        backgroundToString( const BackgroundData& );
   static BackgroundData stringToBackground( const QString& );
 
+  static long        versionToId( const QString& );
+
 #ifndef WIN32
   static void*       getDisplay();
   static Qt::HANDLE  getVisual();
index 42770dbfca724eb6ff84b328ac8365236e603a45..695015339a978d28812dfa2b20b02e07fac5e410 100755 (executable)
@@ -204,36 +204,10 @@ protected:
       // for backward compatibility we also check files prepended with "." with lower priority
       QRegExp exp( QString( "\\.?%1rc\\.([a-zA-Z0-9.]+)" ).arg( myExtAppName ) );
 #endif
-      QRegExp vers_exp( "^([0-9]+)([A-Z]|RC)?([0-9]*)", Qt::CaseInsensitive );
-      
       QString fname = QFileInfo( _fname ).fileName();
-      if( exp.exactMatch( fname ) ) {
-          QStringList vers = exp.cap( 1 ).split( ".", QString::SkipEmptyParts );
-          int major=0, minor=0;
-          int release = 0, dev1 = 0, dev2 = 0;
-          if ( vers.count() > 0 ) major = vers[0].toInt();
-          if ( vers.count() > 1 ) minor = vers[1].toInt();
-          if ( vers.count() > 2 ) {
-              if ( vers_exp.indexIn( vers[2] ) != -1 ) {
-                  release = vers_exp.cap( 1 ).toInt();
-                  QString tag = vers_exp.cap( 2 ).toLower();
-                  if ( !tag.isEmpty() ) {
-                      if ( tag == "rc" ) // release candidate
-                        dev1 = 49;       // 'rc'=49
-                      else               // a, b, c, ...
-                        dev1 = (int)( tag[ 0 ].toLatin1() ) - (int)( QChar('a').toLatin1() ) + 1; // 'a'=1, 'b'=2, ..., 'z'=26
-                  }
-                  if ( !vers_exp.cap( 3 ).isEmpty() )
-                    dev2 = vers_exp.cap( 3 ).toInt();
-              }
-          }
-
-          int dev = dev1*100+dev2;
-          id = major;
-          id*=100; id+=minor;
-          id*=100; id+=release;
-          id*=10000;
-          if ( dev > 0 ) id-=dev;
+      if ( exp.exactMatch( fname ) ) {
+       long fid = Qtx::versionToId( exp.cap( 1 ) );
+       if ( fid > 0 ) id = fid;
       }
     }
     return id;