Changeset View
Changeset View
Standalone View
Standalone View
src/ViewProperties.h
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 45 | public: | |||
---|---|---|---|---|---|
78 | virtual bool confirmClose() const | 78 | virtual bool confirmClose() const | ||
79 | { | 79 | { | ||
80 | return true; | 80 | return true; | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | /** Finds a ViewProperties instance given its numeric identifier. */ | 83 | /** Finds a ViewProperties instance given its numeric identifier. */ | ||
84 | static ViewProperties *propertiesById(int id); | 84 | static ViewProperties *propertiesById(int id); | ||
85 | 85 | | |||
86 | /** Name of mime format to use in drag-and-drop operations. */ | | |||
87 | static QString mimeType() | | |||
88 | { | | |||
89 | return _mimeType; | | |||
90 | } | | |||
91 | | ||||
92 | /** Returns a new QMimeData instance which represents the view with the | | |||
93 | * given @p id (See identifier()). The QMimeData instance returned must | | |||
94 | * be deleted by the caller. | | |||
95 | */ | | |||
96 | static QMimeData *createMimeData(int id) | | |||
97 | { | | |||
98 | auto mimeData = new QMimeData; | | |||
99 | mimeData->setData(mimeType(), QByteArray::number(id)); | | |||
100 | return mimeData; | | |||
101 | } | | |||
102 | | ||||
103 | /** Decodes a QMimeData instance created with createMimeData() and | | |||
104 | * returns the identifier of the associated view. The associated | | |||
105 | * ViewProperties instance can then be retrieved by calling propertiesById() | | |||
106 | * | | |||
107 | * The QMimeData instance must support the mime format returned by mimeType() | | |||
108 | */ | | |||
109 | static int decodeMimeData(const QMimeData *mimeData) | | |||
110 | { | | |||
111 | bool ok; | | |||
112 | // we are not checking return value ok; not sure how int could be invalid | | |||
113 | return mimeData->data(ViewProperties::mimeType()).toInt(&ok); | | |||
114 | } | | |||
115 | | ||||
116 | Q_SIGNALS: | 86 | Q_SIGNALS: | ||
117 | /** Emitted when the icon for a view changes */ | 87 | /** Emitted when the icon for a view changes */ | ||
118 | void iconChanged(ViewProperties *properties); | 88 | void iconChanged(ViewProperties *properties); | ||
119 | /** Emitted when the title for a view changes */ | 89 | /** Emitted when the title for a view changes */ | ||
120 | void titleChanged(ViewProperties *properties); | 90 | void titleChanged(ViewProperties *properties); | ||
121 | /** Emitted when activity has occurred in this view. */ | 91 | /** Emitted when activity has occurred in this view. */ | ||
122 | void activity(ViewProperties *item); | 92 | void activity(ViewProperties *item); | ||
123 | 93 | | |||
Show All 24 Lines | |||||
148 | private: | 118 | private: | ||
149 | Q_DISABLE_COPY(ViewProperties) | 119 | Q_DISABLE_COPY(ViewProperties) | ||
150 | 120 | | |||
151 | QIcon _icon; | 121 | QIcon _icon; | ||
152 | QString _title; | 122 | QString _title; | ||
153 | int _identifier; | 123 | int _identifier; | ||
154 | 124 | | |||
155 | static QHash<int, ViewProperties *> _viewProperties; | 125 | static QHash<int, ViewProperties *> _viewProperties; | ||
156 | static QString _mimeType; | | |||
157 | }; | 126 | }; | ||
158 | } | 127 | } | ||
159 | 128 | | |||
160 | #endif //VIEWPROPERTIES_H | 129 | #endif //VIEWPROPERTIES_H |