RabbitCommon v2.2.6
Loading...
Searching...
No Matches
RabbitRecentMenu.h
1
6#ifndef CRabbitRecentMenu_H
7#define CRabbitRecentMenu_H
8
9#pragma once
10
11#include <QMenu>
12#include <QList>
13
14#include "rabbitcommon_export.h"
15
16namespace RabbitCommon {
17
26class RABBITCOMMON_EXPORT CRecentMenu : public QMenu
27{
28 Q_OBJECT
29 Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount)
30 Q_PROPERTY(QString format READ format WRITE setFormat)
31
32public:
34 CRecentMenu(QWidget * parent = 0);
36 CRecentMenu(const QString & title, QWidget * parent = 0);
38 CRecentMenu(const QString & title, const QIcon& icon, QWidget * parent = 0);
39
41 int maxCount() const;
42
48 void setFormat(const QString &format);
49
51 const QString & format() const;
52
54 bool disableSaveState(bool disable);
55
63 QByteArray saveState() const;
64
72 bool restoreState(const QByteArray &state);
73
74public slots:
76 void addRecentFile(const QString &fileName, const QString& title = QString());
77
79 void clearMenu();
80
82 void setMaxCount(int);
83
84signals:
86 void recentFileTriggered(const QString & filename);
87
88private slots:
89 void menuTriggered(QAction*);
90 void updateRecentFileActions();
91 void slotSaveState();
92
93signals:
94 void sigSaveState();
95
96private:
97 int m_maxCount;
98 QString m_format;
99
101 {
102 public:
103 _Content(){}
104 _Content(const QString& title, const QString& file) {
105 m_szTitle = title;
106 m_szFile = file;
107 }
108
109 _Content(const _Content& c) {
110 m_szTitle = c.m_szTitle;
111 m_szFile = c.m_szFile;
112 }
113 bool operator==(const _Content& c) const {
114 if(m_szFile == c.m_szFile && m_szTitle == c.m_szTitle)
115 return true;
116 return false;
117 }
118
119 QString m_szTitle;
120 QString m_szFile;
121 };
122
123 friend QDataStream & operator<< (QDataStream& d, const _Content& image);
124 friend QDataStream & operator>> (QDataStream& d, _Content& image);
125
126 QList<_Content> m_OpenContent;
127
128 bool m_DisableSaveState;
129 bool m_bUpdate;
130};
131
132} //namespace RabbitCommon
133#endif // QRECENTFILEMENU_H
Recently opened menu.
void recentFileTriggered(const QString &filename)
This signal is emitted when a recent file in this menu is triggered.