-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+// Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
// 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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
+// 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
{
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;
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& );
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