1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
|
/*
Q Light Controller Plus
functionmanager.h
Copyright (c) Massimo Callegari
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef FUNCTIONMANAGER_H
#define FUNCTIONMANAGER_H
#include <QStringList>
#include <QQuickView>
#include <QQuickItem>
#include <QObject>
#include "scenevalue.h"
#include "treemodel.h"
class Doc;
class Function;
class SceneEditor;
class FunctionEditor;
class GenericDMXSource;
typedef struct
{
quint32 m_fID;
QQuickItem *m_item;
} selectedFunction;
class FunctionManager : public QObject
{
Q_OBJECT
Q_PROPERTY(quint32 startupFunctionID READ startupFunctionID WRITE setStartupFunctionID NOTIFY startupFunctionIDChanged)
Q_PROPERTY(QVariant functionsList READ functionsList NOTIFY functionsListChanged)
Q_PROPERTY(int functionsFilter READ functionsFilter CONSTANT)
Q_PROPERTY(QString searchFilter READ searchFilter WRITE setSearchFilter NOTIFY searchFilterChanged)
Q_PROPERTY(int selectedFunctionCount READ selectedFunctionCount NOTIFY selectedFunctionCountChanged)
Q_PROPERTY(int selectedFolderCount READ selectedFolderCount NOTIFY selectedFolderCountChanged)
Q_PROPERTY(bool isEditing READ isEditing NOTIFY isEditingChanged)
Q_PROPERTY(int viewPosition READ viewPosition WRITE setViewPosition NOTIFY viewPositionChanged)
Q_PROPERTY(int sceneCount READ sceneCount NOTIFY sceneCountChanged)
Q_PROPERTY(int chaserCount READ chaserCount NOTIFY chaserCountChanged)
Q_PROPERTY(int sequenceCount READ sequenceCount NOTIFY sequenceCountChanged)
Q_PROPERTY(int efxCount READ efxCount NOTIFY efxCountChanged)
Q_PROPERTY(int collectionCount READ collectionCount NOTIFY collectionCountChanged)
Q_PROPERTY(int rgbMatrixCount READ rgbMatrixCount NOTIFY rgbMatrixCountChanged)
Q_PROPERTY(int scriptCount READ scriptCount NOTIFY scriptCountChanged)
Q_PROPERTY(int showCount READ showCount NOTIFY showCountChanged)
Q_PROPERTY(int audioCount READ audioCount NOTIFY audioCountChanged)
Q_PROPERTY(int videoCount READ videoCount NOTIFY videoCountChanged)
Q_PROPERTY(QStringList audioExtensions READ audioExtensions CONSTANT)
Q_PROPERTY(QStringList pictureExtensions READ pictureExtensions CONSTANT)
Q_PROPERTY(QStringList videoExtensions READ videoExtensions CONSTANT)
Q_PROPERTY(bool previewEnabled READ previewEnabled WRITE setPreviewEnabled NOTIFY previewEnabledChanged)
public:
FunctionManager(QQuickView *view, Doc *doc, QObject *parent = 0);
~FunctionManager();
quint32 startupFunctionID() const;
void setStartupFunctionID(quint32 fid);
signals:
void startupFunctionIDChanged();
/*********************************************************************
* Functions
*********************************************************************/
public:
/** Read only property to expose the function tree to the QML UI */
QVariant functionsList();
Q_INVOKABLE quint32 nextFunctionId() const;
/** Get a list of Functions that use $fid */
Q_INVOKABLE QVariantList usageList(quint32 fid);
/** Get a list of the currently selected Function IDs, suitable to be used in QML */
Q_INVOKABLE QVariantList selectedFunctionsID();
/** Get a list of the currently selected item names, suitable to be used in QML */
Q_INVOKABLE QStringList selectedItemNames();
/** Enable/disable the display of a Function type in the functions tree */
Q_INVOKABLE void setFunctionFilter(quint32 filter, bool enable);
int functionsFilter() const;
/** Get/Set a string to filter Function names */
QString searchFilter() const;
void setSearchFilter(QString searchFilter);
/** Create a new Function with the specified $type
* If the optional fixturesList is provided, fixture IDs
* will be added to the Function where possible.
*/
Q_INVOKABLE quint32 createFunction(int type, QVariantList fixturesList = QVariantList());
/** Create a new Audio/Video Function for each
* file path provided in fileList.
*/
Q_INVOKABLE quint32 createAudioVideoFunction(int type, QStringList fileList = QStringList());
/** Return a reference to a Function with the specified $id */
Q_INVOKABLE Function *getFunction(quint32 id);
/** Return the associated qrc icon resource for the specified Function $type */
Q_INVOKABLE QString functionIcon(int type);
Q_INVOKABLE QString functionPath(quint32 id);
/** Enable/disable the Function preview feature */
bool previewEnabled() const;
void setPreviewEnabled(bool enable);
/** Add $fID to the list of the currently selected Function IDs,
* considering $multiSelection as an append/replace action */
Q_INVOKABLE void selectFunctionID(quint32 fID, bool multiSelection);
/** Get the QML resource for a Function editor that can edit $funcID */
Q_INVOKABLE QString getEditorResource(int funcID);
/** Set $fID as the current Function ID being edited */
Q_INVOKABLE void setEditorFunction(quint32 fID, bool requestUI, bool back);
/** Return a reference of the currently open Function editor */
FunctionEditor *currentEditor() const;
/** Returns if the UI is editing a Function */
bool isEditing() const;
void deleteFunction(quint32 fid);
/** Delete the list of Function IDs in $IDList. This happens AFTER a popup confirmation */
Q_INVOKABLE void deleteFunctions(QVariantList IDList);
/** Move the currently selected Function to the specified $newPath */
Q_INVOKABLE void moveFunctions(QString newPath);
/** Clone the currently selected Functions */
Q_INVOKABLE void cloneFunctions();
/** Generic method to delete a list of item IDs specified in $list.
* This is used from within a Function editor and items can be of any type
* such as Functions, Fixtures, etc. as long as they have an ID.
* This happens AFTER a popup confirmation */
Q_INVOKABLE void deleteEditorItems(QVariantList list);
/** Specific method to delete fixtures from the currently edited Sequence.
* This happens AFTER a popup confirmation */
Q_INVOKABLE void deleteSequenceFixtures(QVariantList list);
/** Rename the currently selected items (functions and/or folders)
* with the provided $newName.
* If $numbering is true, then $startNumber and $digits will compose
* a progress number following $newName */
Q_INVOKABLE bool renameSelectedItems(QString newName, bool numbering, int startNumber, int digits);
/** Returns the number of the currently selected Functions */
int selectedFunctionCount() const;
int sceneCount() const { return m_sceneCount; }
int chaserCount() const { return m_chaserCount; }
int sequenceCount() const { return m_sequenceCount; }
int efxCount() const { return m_efxCount; }
int collectionCount() const { return m_collectionCount; }
int rgbMatrixCount() const { return m_rgbMatrixCount; }
int scriptCount() const { return m_scriptCount; }
int showCount() const { return m_showCount; }
int audioCount() const { return m_audioCount; }
int videoCount() const { return m_videoCount; }
QStringList audioExtensions() const;
QStringList pictureExtensions() const;
QStringList videoExtensions() const;
void setViewPosition(int viewPosition);
int viewPosition() const;
protected:
quint32 addFunctiontoDoc(Function *func, QString name, bool select);
void addFunctionTreeItem(Function *func);
void updateFunctionsTree();
void clearTree();
void moveFunction(quint32 fID, QString newPath);
signals:
void functionsListChanged();
void searchFilterChanged();
void sceneCountChanged();
void chaserCountChanged();
void sequenceCountChanged();
void efxCountChanged();
void collectionCountChanged();
void rgbMatrixCountChanged();
void scriptCountChanged();
void showCountChanged();
void audioCountChanged();
void videoCountChanged();
void selectedFunctionCountChanged(int count);
void previewEnabledChanged();
void isEditingChanged(bool editing);
void viewPositionChanged(int viewPosition);
public slots:
void slotDocLoaded();
void slotFunctionAdded(quint32 fid);
private:
/** Reference of the QML view */
QQuickView *m_view;
/** Reference of the project workspace */
Doc *m_doc;
/** Reference to the Functions tree model */
TreeModel *m_functionTree;
/** The QML ListView position in pixel for state restoring */
int m_viewPosition;
/** Flag that hold if Functions preview is enabled or not */
bool m_previewEnabled;
/** List of the Function IDs currently selected
* and previewed, if preview is enabled */
QVariantList m_selectedIDList;
quint32 m_filter;
QString m_searchFilter;
int m_sceneCount, m_chaserCount, m_sequenceCount, m_efxCount;
int m_collectionCount, m_rgbMatrixCount, m_scriptCount;
int m_showCount, m_audioCount, m_videoCount;
FunctionEditor *m_currentEditor;
FunctionEditor *m_sceneEditor;
/*********************************************************************
* Folders
*********************************************************************/
public:
/** Select a folder with the given $path */
Q_INVOKABLE void selectFolder(QString path, bool multiSelection);
/** Return the number of currently selected folders */
int selectedFolderCount() const;
/** Change the path of an existing folder and all its children */
Q_INVOKABLE void setFolderPath(QString oldAbsPath, QString newPath, bool isRelative);
/** Create an empty folder with path starting from the currently
* selected item */
Q_INVOKABLE void createFolder();
/** Delete the currently selected folders. If a folder is not empty,
* delete also all the sub items in it */
Q_INVOKABLE void deleteSelectedFolders();
signals:
void selectedFolderCountChanged(int count);
private:
/** List of the folder paths that don't include any Function yet */
QStringList m_emptyFolderList;
/** List of the folders currently selected */
QStringList m_selectedFolderList;
/*********************************************************************
* DMX values (dumping and Scene editor)
*********************************************************************/
public:
/** Return the currently set channel values */
QList <SceneValue> dumpValues() const;
/** Reset the currently set channel values */
void resetDumpValues();
void dumpDmxValues(QList<SceneValue> dumpValues, QList<quint32> selectedFixtures,
quint32 channelMask, QString sceneName, quint32 sceneID, bool nonZeroOnly);
/** Dump DMX values provided by $dumpValues, filtered by the provided $selectedFixtures
* and the provided $channelMask.
* The new Scene will be named with $name if not empty, otherwise with an autogenerated name */
void dumpOnNewScene(QList<SceneValue> dumpValues, QList<quint32> selectedFixtures,
quint32 channelMask, QString name);
/** Dump DMX values provided by $dumpValues, filtered by the provided $selectedFixtures
* and the provided $channelMask. Values are dumped on an existing Scene with $sceneID */
void dumpOnScene(QList<SceneValue> dumpValues, QList<quint32> selectedFixtures,
quint32 channelMask, quint32 sceneID);
Q_INVOKABLE void setChannelValue(quint32 fxID, quint32 channel, uchar value);
protected:
quint32 getChannelTypeMask(quint32 fxID, quint32 channel);
};
#endif // FUNCTIONMANAGER_H
|