Tulip  5.2.0
Large graphs analysis and drawing
TulipMimes.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef _TLP_MIMES_H
22 #define _TLP_MIMES_H
23 
24 #include <QMimeData>
25 #include <QStringList>
26 
27 #include <tulip/tulipconf.h>
28 #include <tulip/DataSet.h>
29 
30 namespace tlp {
31 class Graph;
32 class WorkspacePanel;
33 class Algorithm;
34 class DataSet;
35 
36 const QString GRAPH_MIME_TYPE = QString("application/x-tulip-mime;value=\"graph\"");
37 const QString WORKSPACE_PANEL_MIME_TYPE =
38  QString("application/x-tulip-mime;value=\"workspace-panel\"");
39 const QString ALGORITHM_NAME_MIME_TYPE =
40  QString("application/x-tulip-mime;value=\"algorithm-name\"");
41 const QString DATASET_MIME_TYPE = QString("application/x-tulip-mime;value=\"dataset\"");
42 
43 /**
44  * @brief The GraphMimeType class allows to tranfer a graph pointer trought a QMimeData
45  */
46 class TLP_QT_SCOPE GraphMimeType : public QMimeData {
47 public:
48  GraphMimeType() : QMimeData(), _graph(nullptr) {}
49  void setGraph(tlp::Graph *graph) {
50  _graph = graph;
51  }
52 
53  tlp::Graph *graph() const {
54  return _graph;
55  }
56 
57  QStringList formats() const override;
58 
59 private:
60  tlp::Graph *_graph;
61 };
62 
63 class TLP_QT_SCOPE AlgorithmMimeType : public QMimeData {
64  Q_OBJECT
65 
66  QString _algorithm;
67  tlp::DataSet _params;
68 
69 public:
70  AlgorithmMimeType(QString algorithmName, const tlp::DataSet &data);
71  void run(tlp::Graph *) const;
72 
73  QString algorithm() const {
74  return _algorithm;
75  }
76  tlp::DataSet params() const {
77  return _params;
78  }
79 
80  QStringList formats() const override;
81 
82 signals:
83  void mimeRun(tlp::Graph *) const;
84 };
85 
86 class TLP_QT_SCOPE PanelMimeType : public QMimeData {
87 public:
88  void setPanel(tlp::WorkspacePanel *panel) {
89  _panel = panel;
90  }
91 
92  tlp::WorkspacePanel *panel() const {
93  return _panel;
94  }
95 
96  QStringList formats() const override;
97 
98 private:
99  tlp::WorkspacePanel *_panel;
100 };
101 }
102 #endif //_TLP_MIMES_H
103 ///@endcond
A container that can store data from any type.
Definition: DataSet.h:189