Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / Qtx / QtxListResourceEdit.h
index 29a46cc9ae9911f42a1c2c8c281db9cba4793310..fc538004aa9d0eb22264f725c13c68694e8fac37 100644 (file)
@@ -1,3 +1,21 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 // File:      QtxListResourceEdit.h
 // Author:    Sergey TELKOV
 
@@ -10,6 +28,7 @@
 #include <qhbox.h>
 #include <qframe.h>
 #include <qgroupbox.h>
+#include <qvalidator.h>
 
 class QLabel;
 class QListBox;
@@ -22,9 +41,11 @@ class QWidgetStack;
 class QtxIntSpinBox;
 class QtxDblSpinBox;
 
-/*
-  Class: QtxListResourceEdit
-  Descr: GUI implementation of QtxResourceEdit - manager of resources
+class QtxDirListEditor;
+
+/*!
+  \class QtxListResourceEdit
+  GUI implementation of QtxResourceEdit - manager of resources
 */
 
 class QTX_EXPORT QtxListResourceEdit : public QFrame, public QtxResourceEdit
@@ -38,19 +59,26 @@ public:
   class PrefItem;
 
   class Spacer;
-  class ListItem;
   class ColorItem;
   class StateItem;
+  class SelectItem;
   class StringItem;
   class DoubleSpinItem;
   class DoubleEditItem;
   class IntegerSpinItem;
   class IntegerEditItem;
+  class FontItem;
+  class FileItem;
+  class DirListItem;
+
+  enum { Space, Bool, Color, String, Selector, DblSpin, IntSpin, Double, Integer, GroupBox, Font, DirList, File, User };
 
 public:
   QtxListResourceEdit( QtxResourceMgr*, QWidget* = 0 );
   virtual ~QtxListResourceEdit();
 
+  virtual void  setItemProperty( const int, const QString&, const QVariant& );
+
 signals:
   void          resourceChanged( int );
   void          resourceChanged( QString&, QString& );
@@ -60,20 +88,22 @@ private slots:
   void          onSelectionChanged();
 
 protected:
+  virtual void  itemAdded( Item* );
   virtual Item* createItem( const QString&, const int );
   virtual void  changedResources( const QMap<Item*, QString>& );
 
 private:
   void          updateState();
+  void          updateVisible();
 
 private:
   QListBox*     myList;
   QWidgetStack* myStack;
 };
 
-/*
-  Class: QtxListResourceEdit::Category
-  Descr: GUI implementation of 'Category' frame
+/*!
+  \class QtxListResourceEdit::Category
+  GUI implementation of 'Category' frame
 */
 
 class QtxListResourceEdit::Category : public QFrame, public Item
@@ -82,6 +112,8 @@ public:
   Category( QtxListResourceEdit*, QWidget* = 0 );
   virtual ~Category();
 
+  virtual bool     isEmpty() const;
+
   virtual int      type() const;
   virtual void     store();
   virtual void     retrieve();
@@ -100,9 +132,9 @@ private:
   QTabWidget*      myTabs;
 };
 
-/*
-  Class: QtxListResourceEdit::Tab
-  Descr: GUI implementation of resources tab.
+/*!
+  \class QtxListResourceEdit::Tab
+  GUI implementation of resources tab.
 */
 
 class QtxListResourceEdit::Tab : public QFrame, public Item
@@ -125,12 +157,12 @@ private:
   void          adjustLabels();
 
 private:
-  QGroupBox*    myMainFrame;
+  QWidget*      myMainFrame;
 };
 
-/*
-  Class: QtxListResourceEdit::Group
-  Descr: GUI implementation of resources group.
+/*!
+  \class QtxListResourceEdit::Group
+  GUI implementation of resources group.
 */
 
 class QtxListResourceEdit::Group : public QGroupBox, public Item
@@ -152,9 +184,9 @@ protected:
   virtual Item*    createItem( const QString&, const int );
 };
 
-/*
-  Class: QtxListResourceEdit::PrefItem
-  Descr: Base class for preferences items.
+/*!
+  \class QtxListResourceEdit::PrefItem
+  Base class for preferences items.
 */
 
 class QtxListResourceEdit::PrefItem : public QHBox, public Item
@@ -172,9 +204,9 @@ private:
   int           myType;
 };
 
-/*
-  Class: QtxListResourceEdit::Spacer
-  Descr: GUI implementation of resources spacer.
+/*!
+  \class QtxListResourceEdit::Spacer
+  GUI implementation of resources spacer.
 */
 
 class QtxListResourceEdit::Spacer : public PrefItem
@@ -187,16 +219,16 @@ public:
   virtual void retrieve();
 };
 
-/*
-  Class: QtxListResourceEdit::ListItem
-  Descr: GUI implementation of resources list item.
+/*!
+  \class QtxListResourceEdit::SelectItem
+  GUI implementation of resources selector item.
 */
 
-class QtxListResourceEdit::ListItem : public PrefItem
+class QtxListResourceEdit::SelectItem : public PrefItem
 {
 public:
-  ListItem( const QString&, QtxResourceEdit*, Item*, QWidget* = 0 );
-  virtual ~ListItem();
+  SelectItem( const QString&, QtxResourceEdit*, Item*, QWidget* = 0 );
+  virtual ~SelectItem();
 
   virtual void     store();
   virtual void     retrieve();
@@ -216,11 +248,10 @@ private:
   QMap<int, int>   myIndex;
 };
 
-/*
-  Class: QtxListResourceEdit::StateItem
-  Descr: GUI implementation of resources bool item.
+/*!
+  \class  QtxListResourceEdit::StateItem
+  GUI implementation of resources bool item.
 */
-
 class QtxListResourceEdit::StateItem : public PrefItem
 {
 public:
@@ -234,9 +265,9 @@ private:
   QCheckBox*       myState;
 };
 
-/*
-  Class: QtxListResourceEdit::StringItem
-  Descr: GUI implementation of resources string item.
+/*!
+  \class  QtxListResourceEdit::StringItem
+  GUI implementation of resources string item.
 */
 
 class QtxListResourceEdit::StringItem : public PrefItem
@@ -252,9 +283,9 @@ private:
   QLineEdit*       myString;
 };
 
-/*
-  Class: QtxListResourceEdit::IntegerEditItem
-  Descr: GUI implementation of resources integer item.
+/*!
+  \class  QtxListResourceEdit::IntegerEditItem
+  GUI implementation of resources integer item.
 */
 
 class QtxListResourceEdit::IntegerEditItem : public PrefItem
@@ -270,9 +301,9 @@ private:
   QLineEdit*       myInteger;
 };
 
-/*
-  Class: QtxListResourceEdit::IntegerSpinItem
-  Descr: GUI implementation of resources integer item.
+/*!
+  \class  QtxListResourceEdit::IntegerSpinItem
+  GUI implementation of resources integer item.
 */
 
 class QtxListResourceEdit::IntegerSpinItem : public PrefItem
@@ -291,9 +322,9 @@ private:
   QtxIntSpinBox*  myInteger;
 };
 
-/*
-  Class: QtxListResourceEdit::DoubleEditItem
-  Descr: GUI implementation of resources double item.
+/*!
+  \class  QtxListResourceEdit::DoubleEditItem
+  GUI implementation of resources double item.
 */
 
 class QtxListResourceEdit::DoubleEditItem : public PrefItem
@@ -309,9 +340,9 @@ private:
   QLineEdit*       myDouble;
 };
 
-/*
-  Class: QtxListResourceEdit::DoubleSpinItem
-  Descr: GUI implementation of resources double item.
+/*!
+  \class  QtxListResourceEdit::DoubleSpinItem
+  GUI implementation of resources double item.
 */
 
 class QtxListResourceEdit::DoubleSpinItem : public PrefItem
@@ -330,9 +361,9 @@ private:
   QtxDblSpinBox*   myDouble;
 };
 
-/*
-  Class: QtxListResourceEdit::ColorItem
-  Descr: GUI implementation of resources color item.
+/*!
+  \class  QtxListResourceEdit::ColorItem
+  GUI implementation of resources color item.
 */
 
 class QtxListResourceEdit::ColorItem : public PrefItem
@@ -348,4 +379,154 @@ private:
   QWidget*         myColor;
 };
 
+class QtxComboBox;
+class QToolButton;
+
+/*!
+  \class  QtxListResourceEdit::FontItem
+  GUI implementation of resources font item.
+*/
+class QtxListResourceEdit::FontItem : public PrefItem
+{
+  Q_OBJECT
+
+public:
+  typedef enum
+  {
+    Family    = 0x01,
+    Size      = 0x02,
+    UserSize  = 0x04,
+    Bold      = 0x08,
+    Italic    = 0x10,
+    Underline = 0x20,
+    Preview   = 0x40,
+
+    All = Family | Size | UserSize | Bold | Italic | Underline | Preview
+    
+  } WidgetFlags;
+  
+public:
+  FontItem( const QString&, QtxResourceEdit*, Item*, QWidget* = 0 );
+  virtual ~FontItem();
+
+  virtual void store();
+  virtual void retrieve();
+
+  virtual QVariant property( const QString& ) const;
+  virtual void     setProperty( const QString&, const QVariant& );
+
+private slots:
+  void onActivateFamily( int );
+  void onPreview();
+  
+private:
+  void       setFamily( const QString& );
+  QString    family() const;
+  void       setSize( const int );
+  int        size() const;
+  void       setParams( const bool, const bool, const bool );
+  void       params( bool&, bool&, bool& );
+  void       internalUpdate();
+  
+private:
+  int            myFlags;
+  bool           myIsSystem;
+  QtxComboBox   *myFamilies, *mySizes;
+  QCheckBox     *myBold, *myItalic, *myUnderline;
+  QToolButton   *myPreview;
+  QMap<QString, QVariant>   myProperties;
+};
+
+
+/*!
+  \class QtxListResourceEdit
+  \brief GUI implementation of resources directory list item.
+*/
+class QtxListResourceEdit::DirListItem : public PrefItem
+{
+  Q_OBJECT
+  
+public:
+
+  /*!
+   * \brief Constructor
+   */
+  DirListItem( const QString&, QtxResourceEdit*, Item*, QWidget* = 0 );
+  /*!
+   * \brief Destructor
+   */
+  virtual ~DirListItem();
+
+  /*!
+   * \brief Stores the data
+   */
+  virtual void     store();
+
+  /*!
+   * \brief Retrieves the data
+   */
+  virtual void     retrieve();
+
+private:
+  QtxDirListEditor* myDirListEditor; //!< The widget wich implements in GUI the list of directories
+};
+
+class QtxComboBox;
+class QToolButton;
+class QFileDialog;
+
+/*!
+  \class QtxListResourceEdit::FontItem
+  GUI implementation of resources font item.
+*/
+
+class QtxListResourceEdit::FileItem : public PrefItem
+{
+  Q_OBJECT
+
+private:
+  /*!
+    \class QtxListResourceEdit::FileItem::FileValidator
+    custom file validator: checks files on some rights
+  */
+
+  class FileValidator : public QValidator
+  {
+  public:
+    FileValidator( FileItem*, QObject* );
+    ~FileValidator();
+
+    virtual QValidator::State validate( QString&, int& ) const;
+
+  private:
+    FileItem* myItem;
+  };
+
+public:
+  FileItem( const QString&, QtxResourceEdit*, Item*, QWidget* = 0 );
+  virtual ~FileItem();
+
+  virtual void store();
+  virtual void retrieve();
+  
+  virtual QVariant property( const QString& ) const;
+  virtual void     setProperty( const QString&, const QVariant& );
+
+  virtual bool isFileCorrect( const QString& ) const;
+
+private slots:
+  void onOpenFile();
+  void onFileSelected( const QString& );
+
+private:
+  uint          myFlags;
+  bool          myIsReadOnly;
+  QStringList   myFilter;
+  bool          myIsExisting;
+  QLineEdit*    myFile;
+  QToolButton*  myOpenFile;
+  QFileDialog*  myFileDlg;
+};
+
+
 #endif