Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / Qtx / QtxMRUAction.h
index 6325860f8144ef362ceccd57b1597efb9db6a54b..2611593d5ce07eabbba08077784ecf50a2c55345 100755 (executable)
@@ -1,33 +1,34 @@
-// 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.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// 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
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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:      QtxMRUAction.h
 // Author:    Sergey TELKOV
-
+//
 #ifndef QTXMRUACTION_H
 #define QTXMRUACTION_H
 
 #include "QtxAction.h"
 
-#include <qmap.h>
-#include <qstringlist.h>
+#include <QStringList>
 
-class QPopupMenu;
 class QtxResourceMgr;
 
 #ifdef WIN32
@@ -38,23 +39,30 @@ class QTX_EXPORT QtxMRUAction : public QtxAction
 {
   Q_OBJECT
 
-  Q_PROPERTY( int visibleCount READ visibleCount WRITE setVisibleCount )
-
 public:
-  enum { Items, SubMenu };
-  enum { MoveFirst, MoveLast, AddFirst, AddLast };
+  //! Items insertion policy
+  typedef enum { MoveFirst,   //!< put the specified item to the beginning
+                MoveLast,    //!< put the specified item to the end
+                AddFirst,    //!< if specified item doesn't exist, add it to the beginning
+                AddLast      //!< if specified item doesn't exist, add it to the end
+  } InsertionMode;
+
+  typedef enum { LinkAuto,    //!< put the full path of link into the menu if link file names of severals link are same
+                LinkShort,   //!< put the only file name of link into the menu
+                LinkFull     //!< put the full path of link into the menu
+  } LinkType;
 
 public:
-  QtxMRUAction( QObject* = 0, const char* = 0 );
-  QtxMRUAction( const QString&, const QString&, QObject*, const char* = 0 );
-  QtxMRUAction( const QString&, const QIconSet&, const QString&, QObject*, const char* = 0 );
+  QtxMRUAction( QObject* = 0 );
+  QtxMRUAction( const QString&, const QString&, QObject* = 0 );
+  QtxMRUAction( const QString&, const QIcon&, const QString&, QObject* = 0 );
   virtual ~QtxMRUAction();
 
   int          insertMode() const;
   void         setInsertMode( const int );
 
-  int          popupMode() const;
-  void         setPopupMode( const int );
+  int          linkType() const;
+  void         setLinkType( const int );
 
   int          count() const;
   bool         isEmpty() const;
@@ -62,6 +70,12 @@ public:
   int          visibleCount() const;
   void         setVisibleCount( const int );
 
+  bool         isClearPossible() const;
+  void         setClearPossible( const bool );
+
+  int          historyCount() const;
+  void         setHistoryCount( const int );
+
   void         remove( const int );
   void         remove( const QString& );
   void         insert( const QString& );
@@ -70,46 +84,30 @@ public:
   int          find( const QString& ) const;
   bool         contains( const QString& ) const;
 
-  virtual bool addTo( QWidget* );
-  virtual bool addTo( QWidget*, const int );
-
-  virtual bool removeFrom( QWidget* );
-
   virtual void loadLinks( QtxResourceMgr*, const QString&, const bool = true );
   virtual void saveLinks( QtxResourceMgr*, const QString&, const bool = true ) const;
 
-signals:
-  void         activated( QString );
-
 public slots:
-  virtual void setEnabled( bool );
+  void         clear();
+
+signals:
+  void         activated( const QString& );
 
 private slots:
+  void         onActivated();
   void         onAboutToShow();
-  void         onActivated( int );
-  void         onDestroyed( QObject* );
-
-private:
-  void         updateState();
-  void         checkPopup( QPopupMenu* );
-  void         updatePopup( QPopupMenu*, const int );
-  bool         removeLinks( QPopupMenu*, const int );
-  bool         insertLinks( QPopupMenu*, const int, const int = -1 );
-
-  int          findId( QPopupMenu*, QPopupMenu* ) const;
+  void         onCleared( bool );
 
 private:
-  typedef struct { int pId, nId; QIntList idList; } Item;
-  typedef QMap<QPopupMenu*, Item>                   ItemsMap;
-  typedef QMap<QPopupMenu*, QPopupMenu*>            MenusMap;
+  void         updateMenu();
 
 private:
-  QStringList  myLinks;
-  ItemsMap     myItems;
-  MenusMap     myMenus;
-  int          myVisCount;
-  int          myPopupMode;
-  int          myInsertMode;
+  QStringList  myLinks;        //!< most recent used items
+  QAction*     myClear;        //!< clear item
+  int          myVisCount;     //!< number of visible MRU items
+  int          myHistoryCount; //!< number of stored MRU items
+  int          myLinkType;     //!< type of link names in menu
+  int          myInsertMode;   //!< items insertion policy
 };
 
 #endif