]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxMRUAction.h
Salome HOME
2611593d5ce07eabbba08077784ecf50a2c55345
[modules/gui.git] / src / Qtx / QtxMRUAction.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File:      QtxMRUAction.h
23 // Author:    Sergey TELKOV
24 //
25 #ifndef QTXMRUACTION_H
26 #define QTXMRUACTION_H
27
28 #include "QtxAction.h"
29
30 #include <QStringList>
31
32 class QtxResourceMgr;
33
34 #ifdef WIN32
35 #pragma warning( disable:4251 )
36 #endif
37
38 class QTX_EXPORT QtxMRUAction : public QtxAction
39 {
40   Q_OBJECT
41
42 public:
43   //! Items insertion policy
44   typedef enum { MoveFirst,   //!< put the specified item to the beginning
45                  MoveLast,    //!< put the specified item to the end
46                  AddFirst,    //!< if specified item doesn't exist, add it to the beginning
47                  AddLast      //!< if specified item doesn't exist, add it to the end
48   } InsertionMode;
49
50   typedef enum { LinkAuto,    //!< put the full path of link into the menu if link file names of severals link are same
51                  LinkShort,   //!< put the only file name of link into the menu
52                  LinkFull     //!< put the full path of link into the menu
53   } LinkType;
54
55 public:
56   QtxMRUAction( QObject* = 0 );
57   QtxMRUAction( const QString&, const QString&, QObject* = 0 );
58   QtxMRUAction( const QString&, const QIcon&, const QString&, QObject* = 0 );
59   virtual ~QtxMRUAction();
60
61   int          insertMode() const;
62   void         setInsertMode( const int );
63
64   int          linkType() const;
65   void         setLinkType( const int );
66
67   int          count() const;
68   bool         isEmpty() const;
69
70   int          visibleCount() const;
71   void         setVisibleCount( const int );
72
73   bool         isClearPossible() const;
74   void         setClearPossible( const bool );
75
76   int          historyCount() const;
77   void         setHistoryCount( const int );
78
79   void         remove( const int );
80   void         remove( const QString& );
81   void         insert( const QString& );
82
83   QString      item( const int ) const;
84   int          find( const QString& ) const;
85   bool         contains( const QString& ) const;
86
87   virtual void loadLinks( QtxResourceMgr*, const QString&, const bool = true );
88   virtual void saveLinks( QtxResourceMgr*, const QString&, const bool = true ) const;
89
90 public slots:
91   void         clear();
92
93 signals:
94   void         activated( const QString& );
95
96 private slots:
97   void         onActivated();
98   void         onAboutToShow();
99   void         onCleared( bool );
100
101 private:
102   void         updateMenu();
103
104 private:
105   QStringList  myLinks;        //!< most recent used items
106   QAction*     myClear;        //!< clear item
107   int          myVisCount;     //!< number of visible MRU items
108   int          myHistoryCount; //!< number of stored MRU items
109   int          myLinkType;     //!< type of link names in menu
110   int          myInsertMode;   //!< items insertion policy
111 };
112
113 #endif