]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
It is recommended to use standard Qt QInputDialog instead QtxNameDlg
authorasl <asl@opencascade.com>
Mon, 28 Nov 2005 09:20:47 +0000 (09:20 +0000)
committerasl <asl@opencascade.com>
Mon, 28 Nov 2005 09:20:47 +0000 (09:20 +0000)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/Qtx/Makefile.in
src/Qtx/QtxNameDlg.cxx [deleted file]
src/Qtx/QtxNameDlg.h [deleted file]
src/Qtx/QtxWorkstack.cxx
src/Qtx/QtxWorkstack.h

index e21e2027b0f14163b24bb328506f7250aaa86d28..930a698a44438a32a0da45674a5322b62a2991cb 100644 (file)
@@ -73,6 +73,7 @@
 #include <qmap.h>
 #include <qstatusbar.h>
 #include <qthread.h>
+#include <qinputdialog.h>
 
 #define OBJECT_BROWSER_WIDTH 300
 #define OBJECT_COLUMN_WIDTH 150
@@ -457,13 +458,9 @@ void LightApp_Application::createActions()
     createMenu( a, newWinMenu, -1 );
   }
 
-  STD_TabDesktop* tab_desk = dynamic_cast<STD_TabDesktop*>( desk );
-  if( tab_desk )
-  {
-    QAction* a = createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_RENAME" ), tr( "PRP_RENAME" ),
-                              0, desk, false, tab_desk->workstack(), SLOT( onRenameActive() ) );
-    createMenu( a, windowMenu, -1 );
-  }
+  createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_RENAME" ), tr( "PRP_RENAME" ),
+               0, desk, false, this, SLOT( onRenameWindow() ) );
+  createMenu( RenameId, windowMenu, -1 );
 
   connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
 
@@ -1877,3 +1874,19 @@ void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
   STD_Application::removeViewManager( vm );
   delete vm;
 }
+
+/*! rename active window of desktop */
+void LightApp_Application::onRenameWindow()
+{
+  if( !desktop() )
+    return;
+
+  QWidget* w = desktop()->activeWindow();
+  if( !w )
+    return;
+
+  bool ok;
+  QString name = QInputDialog::getText( tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->caption(), &ok, w );
+  if( ok && !name.isEmpty() )
+    w->setCaption( name );
+}
index c6f3e8eda03108d1e22c801485db5fc405647c03..14d2e4c23cc6cd00ad045c63543588e52377e9a1 100644 (file)
@@ -44,7 +44,7 @@ class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
 public:
   typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
 
-  enum { NewGLViewId = STD_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId,
+  enum { NewGLViewId = CAM_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId,
          PreferencesId, MRUId, RenameId, UserID };
 public:
   LightApp_Application();
@@ -150,6 +150,7 @@ private slots:
   void                                onPreferences();
   void                                onMRUActivated( QString );
   void                                onPreferenceChanged( QString&, QString&, QString& );
+  void                                onRenameWindow();
 
 protected:
   void                                updateWindows();
index 04f2941ecb3cb22e5b41ba4dd41bd6f78f4b5493..0a92974f92963df40e355629556c4b520d711573 100755 (executable)
@@ -48,8 +48,7 @@ EXPORT_HEADERS= Qtx.h \
                QtxWorkstack.h \
                QtxResourceEdit.h \
                QtxListView.h \
-               QtxDirListEditor.h \
-               QtxNameDlg.h
+               QtxDirListEditor.h
 
 # .po files to transform in .qm
 
@@ -96,8 +95,7 @@ LIB_SRC= \
        QtxResourceEdit.cxx \
        QtxWorkstack.cxx \
        QtxListView.cxx \
-       QtxDirListEditor.cxx \
-       QtxNameDlg.cxx
+       QtxDirListEditor.cxx
 
 LIB_MOC = \
        QtxAction.h \
@@ -129,8 +127,7 @@ LIB_MOC = \
        QtxWorkstack.h \
        QtxListView.h \
        QtxListResourceEdit.h \
-       QtxDirListEditor.h \
-       QtxNameDlg.h
+       QtxDirListEditor.h 
 
 RESOURCES_FILES = \
 
diff --git a/src/Qtx/QtxNameDlg.cxx b/src/Qtx/QtxNameDlg.cxx
deleted file mode 100644 (file)
index 28e4fcb..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-//  File   : QtxNameDlg.cxx\r
-//  Author : Vadim SANDLER\r
-//  $Header$\r
-\r
-#include "QtxNameDlg.h"\r
-\r
-#include <qlayout.h>\r
-#include <qgroupbox.h>\r
-#include <qlabel.h>\r
-#include <qlineedit.h>\r
-#include <qpushbutton.h>\r
-\r
-#ifndef WIN32\r
-using namespace std;\r
-#endif\r
-\r
-/*!\r
-  Constructor\r
-*/\r
-QtxNameDlg::QtxNameDlg( QWidget* parent )\r
-: QtxDialog( parent ? parent : NULL,//application()->desktop(), \r
-            "QtxNameDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )\r
-{\r
-  setCaption( tr("TLT_RENAME") );\r
-  setSizeGripEnabled( TRUE );\r
-\r
-  clearButtonFlags( Help );\r
-  setButtonFlags( OKCancel );\r
-\r
-  QHBoxLayout* topLayout = new QHBoxLayout( mainFrame(), 0, 5 );\r
-\r
-  /***************************************************************/\r
-  QLabel* TextLabel = new QLabel( mainFrame(), "TextLabel1" );\r
-  TextLabel->setText( tr( "NAME_LBL" ) );\r
-  topLayout->addWidget( TextLabel );\r
-  \r
-  myLineEdit = new QLineEdit( mainFrame(), "LineEdit1" );\r
-  myLineEdit->setMinimumSize( 250, 0 );\r
-  topLayout->addWidget( myLineEdit );\r
\r
-  /* Move widget on the botton right corner of main widget */\r
-  setAlignment( Qt::AlignCenter );\r
-\r
-  QPushButton* btn = dynamic_cast<QPushButton*>( button( OK ) );\r
-  if( btn )\r
-    btn->setAutoDefault( true );\r
-\r
-  setFocusProxy( myLineEdit );\r
-}\r
-\r
-/*!\r
-  Destructor\r
-*/\r
-QtxNameDlg::~QtxNameDlg()\r
-{\r
-}\r
-\r
-/*!\r
-  Sets name\r
-*/\r
-void QtxNameDlg::setName( const QString& name )\r
-{\r
-  myLineEdit->setText( name );\r
-  myLineEdit->end(false);\r
-  myLineEdit->home(true);\r
-}\r
-\r
-/*!\r
-  Returns name entered by user\r
-*/\r
-QString QtxNameDlg::name()\r
-{\r
-  return myLineEdit->text();\r
-}\r
-\r
-void QtxNameDlg::accept()\r
-{\r
-  if ( name().stripWhiteSpace().isEmpty() )\r
-    return;\r
-  QDialog::accept();\r
-}\r
-\r
-/*!\r
-  Creates modal <Rename> dialog and returns name entered [ static ]\r
-*/\r
-QString QtxNameDlg::getName( QWidget* parent, const QString& oldName )\r
-{\r
-  QString n;\r
-  QtxNameDlg* dlg = new QtxNameDlg( parent );\r
-  if ( !oldName.isNull() )\r
-    dlg->setName( oldName );\r
-  if ( dlg->exec() == QDialog::Accepted ) \r
-    n = dlg->name();\r
-  delete dlg;\r
-  return n;\r
-}\r
diff --git a/src/Qtx/QtxNameDlg.h b/src/Qtx/QtxNameDlg.h
deleted file mode 100644 (file)
index a6a8193..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-//  SALOME SalomeApp : implementation of desktop and GUI kernel
-//
-//  Copyright (C) 2003  CEA/DEN, EDF R&D
-//
-//
-//
-//  File   : QtxNameDlg.h
-//  Author : Vadim SANDLER
-//  Module : SALOME
-//  $Header$
-
-#ifndef QTX_NAMEDLG_H
-#define QTX_NAMEDLG_H
-
-#include "Qtx.h"
-#include "QtxDialog.h"
-
-class QLineEdit;
-class QPushButton;
-
-//=================================================================================
-// class    : QtxNameDlg
-/*! purpose  : Common <Rename> dialog box class*/
-//=================================================================================
-class QTX_EXPORT QtxNameDlg : public QtxDialog
-{ 
-  Q_OBJECT
-
-public:
-  QtxNameDlg( QWidget* parent = 0 );
-  ~QtxNameDlg();
-    
-  void            setName( const QString& name );
-  QString         name();
-    
-  static QString  getName( QWidget* parent = 0, const QString& oldName = QString::null );
-    
-protected slots:
-  void accept();
-  
-private:
-  QPushButton*    myButtonOk;
-  QPushButton*    myButtonCancel;
-  QLineEdit*      myLineEdit;
-};
-
-#endif // QTX_NAMEDLG_H
index 20cbd051595612d2509c30038a3b9ac94f05b808..5d57ad6e08f82d5c54de87e84b73020223cf85a1 100644 (file)
@@ -709,26 +709,16 @@ void QtxWorkstack::splitHorizontal()
   split( Qt::Vertical );
 }
 
-void QtxWorkstack::renameWindow( QWidget* w )
+void QtxWorkstack::onRename()
 {
-  if ( !w )
+  if ( !myWorkWin )
     return;
 
   bool ok = false;
   QString newName = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal,
-                                           w->caption(), &ok, topLevelWidget() );
-  if ( ok )
-    w->setCaption( newName );
-}
-
-void QtxWorkstack::onRenameActive()
-{
-  renameWindow( activeWindow() );
-}
-
-void QtxWorkstack::onRename()
-{
-  renameWindow( myWorkWin );
+                                           myWorkWin->caption(), &ok, topLevelWidget() );
+  if ( ok && !newName.isEmpty() )
+    myWorkWin->setCaption( newName );
 }
 
 QSplitter* QtxWorkstack::wrapSplitter( QtxWorkstackArea* area )
index 14f18e417da2eece46896e55b6c3d2ebbfa516fa..dfc7dac57aa45640d1d5eb20338cac2e7ab8f4c7 100644 (file)
@@ -69,7 +69,6 @@ signals:
 public slots:
   void                splitVertical();
   void                splitHorizontal();
-  void                onRenameActive();
   
 private slots:
   void                onRename();
@@ -90,7 +89,6 @@ private:
 
   QSplitter*          wrapSplitter( QtxWorkstackArea* );
   void                insertWidget( QWidget*, QWidget*, QWidget* );
-  void                renameWindow( QWidget* );
 
   QtxWorkstackArea*   areaAt( const QPoint& ) const;