##// END OF EJS Templates
drop of product on the variables
trabillard -
r874:7d2f05cda6a0
parent child
Show More
@@ -1,94 +1,99
1 1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
2 2 #define SCIQLOP_DATASOURCECONTROLLER_H
3 3
4 4 #include "CoreGlobal.h"
5 5
6 6 #include <QLoggingCategory>
7 7 #include <QObject>
8 8 #include <QUuid>
9 9
10 10 #include <Common/spimpl.h>
11 11
12 12 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
13 13
14 14 class DataSourceItem;
15 15 class IDataProvider;
16 16
17 17 /**
18 18 * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This
19 19 * is the intermediate class that SciQlop has to use in the way to connect a data source. Please
20 20 * first use register method to initialize a plugin specified by its metadata name (JSON plugin
21 21 * source) then others specifics method will be able to access it. You can load a data source driver
22 22 * plugin then create a data source.
23 23 */
24 24 class SCIQLOP_CORE_EXPORT DataSourceController : public QObject {
25 25 Q_OBJECT
26 26 public:
27 27 explicit DataSourceController(QObject *parent = 0);
28 28 virtual ~DataSourceController();
29 29
30 30 /**
31 31 * Registers a data source. The method delivers a unique id that can be used afterwards to
32 32 * access to the data source properties (structure, connection parameters, data provider, etc.)
33 33 * @param dataSourceName the name of the data source
34 34 * @return the unique id with which the data source has been registered
35 35 */
36 36 QUuid registerDataSource(const QString &dataSourceName) noexcept;
37 37
38 38 /**
39 39 * Sets the structure of a data source. The controller takes ownership of the structure.
40 40 * @param dataSourceUid the unique id with which the data source has been registered into the
41 41 * controller. If it is invalid, the method has no effect.
42 42 * @param dataSourceItem the structure of the data source. It must be not null to be registered
43 43 * @sa registerDataSource()
44 44 */
45 45 void setDataSourceItem(const QUuid &dataSourceUid,
46 46 std::unique_ptr<DataSourceItem> dataSourceItem) noexcept;
47 47
48 48 /**
49 49 * Sets the data provider used to retrieve data from of a data source. The controller takes
50 50 * ownership of the provider.
51 51 * @param dataSourceUid the unique id with which the data source has been registered into the
52 52 * controller. If it is invalid, the method has no effect.
53 53 * @param dataProvider the provider of the data source
54 54 * @sa registerDataSource()
55 55 */
56 56 void setDataProvider(const QUuid &dataSourceUid,
57 57 std::unique_ptr<IDataProvider> dataProvider) noexcept;
58 58
59 59 /**
60 60 * Loads an item (product) as a variable in SciQlop
61 61 * @param dataSourceUid the unique id of the data source containing the item. It is used to get
62 62 * the data provider associated to the data source, and pass it to for the variable creation
63 63 * @param productItem the item to load
64 64 */
65 65 void loadProductItem(const QUuid &dataSourceUid, const DataSourceItem &productItem) noexcept;
66 66
67 QByteArray mimeDataForProductsData(const QVariantList &productsData) const;
68 QVariantList productsDataForMimeData(const QByteArray &mimeData) const;
69
67 70 public slots:
68 71 /// Manage init/end of the controller
69 72 void initialize();
70 73 void finalize();
71 74
75 void requestVariable(const QVariantHash &productData);
76
72 77 signals:
73 78 /// Signal emitted when a structure has been set for a data source
74 79 void dataSourceItemSet(DataSourceItem *dataSourceItem);
75 80
76 81 /**
77 82 * Signal emitted when a variable creation is asked for a product
78 83 * @param variableName the name of the variable
79 84 * @param variableMetadata the metadata of the variable
80 85 * @param variableProvider the provider that will be used to retrieve the data of the variable
81 86 * (can be null)
82 87 */
83 88 void variableCreationRequested(const QString &variableName,
84 89 const QVariantHash &variableMetadata,
85 90 std::shared_ptr<IDataProvider> variableProvider);
86 91
87 92 private:
88 93 void waitForFinish();
89 94
90 95 class DataSourceControllerPrivate;
91 96 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
92 97 };
93 98
94 99 #endif // SCIQLOP_DATASOURCECONTROLLER_H
@@ -1,102 +1,110
1 1 #ifndef SCIQLOP_DATASOURCEITEM_H
2 2 #define SCIQLOP_DATASOURCEITEM_H
3 3
4 4 #include "CoreGlobal.h"
5 5
6 6 #include <Common/spimpl.h>
7 7
8 8 #include <QVariant>
9 9 #include <QVector>
10 10
11 11 class DataSourceItemAction;
12 12
13 13 /**
14 14 * Possible types of an item
15 15 */
16 16 enum class DataSourceItemType { NODE, PRODUCT, COMPONENT };
17 17
18 18 /**
19 19 * @brief The DataSourceItem class aims to represent a structure element of a data source.
20 20 * A data source has a tree structure that is made up of a main DataSourceItem object (root)
21 21 * containing other DataSourceItem objects (children).
22 22 * For each DataSourceItem can be associated a set of data representing it.
23 23 */
24 24 class SCIQLOP_CORE_EXPORT DataSourceItem {
25 25 public:
26 26 /// Key associated with the name of the item
27 27 static const QString NAME_DATA_KEY;
28 28
29 29 explicit DataSourceItem(DataSourceItemType type, const QString &name);
30 30 explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {});
31 31
32 32 /// @return the actions of the item as a vector
33 33 QVector<DataSourceItemAction *> actions() const noexcept;
34 34
35 35 /**
36 36 * Adds an action to the item. The item takes ownership of the action, and the action is
37 37 * automatically associated to the item
38 38 * @param action the action to add
39 39 */
40 40 void addAction(std::unique_ptr<DataSourceItemAction> action) noexcept;
41 41
42 42 /**
43 43 * Adds a child to the item. The item takes ownership of the child.
44 44 * @param child the child to add
45 45 */
46 46 void appendChild(std::unique_ptr<DataSourceItem> child) noexcept;
47 47
48 48 /**
49 49 * Returns the item's child associated to an index
50 50 * @param childIndex the index to search
51 51 * @return a pointer to the child if index is valid, nullptr otherwise
52 52 */
53 53 DataSourceItem *child(int childIndex) const noexcept;
54 54
55 55 int childCount() const noexcept;
56 56
57 57 /**
58 58 * Get the data associated to a key
59 59 * @param key the key to search
60 60 * @return the data found if key is valid, default QVariant otherwise
61 61 */
62 62 QVariant data(const QString &key) const noexcept;
63 63
64 64 /// Gets all data
65 65 QVariantHash data() const noexcept;
66 66
67 67 bool isRoot() const noexcept;
68 68
69 69 QString name() const noexcept;
70 70
71 71 /**
72 72 * Get the item's parent
73 73 * @return a pointer to the parent if it exists, nullptr if the item is a root
74 74 */
75 75 DataSourceItem *parentItem() const noexcept;
76 76
77 77 /**
78 78 * Gets the item's root
79 79 * @return the top parent, the item itself if it's the root item
80 80 */
81 81 const DataSourceItem &rootItem() const noexcept;
82 82
83 83 /**
84 84 * Sets or appends a value to a key
85 85 * @param key the key
86 86 * @param value the value
87 87 * @param append if true, the value is added to the values already existing for the key,
88 88 * otherwise it replaces the existing values
89 89 */
90 90 void setData(const QString &key, const QVariant &value, bool append = false) noexcept;
91 91
92 92 DataSourceItemType type() const noexcept;
93 93
94 /**
95 * @brief Searches the first child matching the specified data.
96 * @param data The data to search.
97 * @param recursive So the search recursively.
98 * @return the item matching the data or nullptr if it was not found.
99 */
100 DataSourceItem *findItem(const QVariantHash &data, bool recursive);
101
94 102 bool operator==(const DataSourceItem &other);
95 103 bool operator!=(const DataSourceItem &other);
96 104
97 105 private:
98 106 class DataSourceItemPrivate;
99 107 spimpl::unique_impl_ptr<DataSourceItemPrivate> impl;
100 108 };
101 109
102 110 #endif // SCIQLOP_DATASOURCEITEMMODEL_H
@@ -1,109 +1,110
1 1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 2 #define SCIQLOP_VARIABLEMODEL_H
3 3
4 4 #include "CoreGlobal.h"
5 5
6 6 #include <Data/SqpRange.h>
7 7
8 8 #include <QAbstractTableModel>
9 9 #include <QLoggingCategory>
10 10
11 11 #include <Common/MetaTypes.h>
12 12 #include <Common/spimpl.h>
13 13
14 14 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
15 15
16 16 enum VariableRoles { ProgressRole = Qt::UserRole };
17 17
18 18
19 19 class IDataSeries;
20 20 class Variable;
21 21 class VariableController;
22 22
23 23 /**
24 24 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
25 25 */
26 26 class SCIQLOP_CORE_EXPORT VariableModel : public QAbstractTableModel {
27 27 Q_OBJECT
28 28 public:
29 29 explicit VariableModel(VariableController *parent = nullptr);
30 30
31 31 /**
32 32 * Adds an existing variable in the model.
33 33 * @param variable the variable to add.
34 34 * @remarks the variable's name is modified to avoid name duplicates
35 35 * @remarks this method does nothing if the variable already exists in the model
36 36 */
37 37 void addVariable(std::shared_ptr<Variable> variable) noexcept;
38 38
39 39 /**
40 40 * Checks that a variable is contained in the model
41 41 * @param variable the variable to check
42 42 * @return true if the variable is in the model, false otherwise
43 43 */
44 44 bool containsVariable(std::shared_ptr<Variable> variable) const noexcept;
45 45
46 46 /**
47 47 * Creates a new variable in the model
48 48 * @param name the name of the new variable
49 49 * @param metadata the metadata associated to the new variable
50 50 * @return the pointer to the new variable
51 51 */
52 52 std::shared_ptr<Variable> createVariable(const QString &name,
53 53 const QVariantHash &metadata) noexcept;
54 54
55 55 /**
56 56 * Deletes a variable from the model, if it exists
57 57 * @param variable the variable to delete
58 58 */
59 59 void deleteVariable(std::shared_ptr<Variable> variable) noexcept;
60 60
61 61
62 62 std::shared_ptr<Variable> variable(int index) const;
63 63 std::vector<std::shared_ptr<Variable> > variables() const;
64 64
65 65 void setDataProgress(std::shared_ptr<Variable> variable, double progress);
66 66
67 67
68 68 // /////////////////////////// //
69 69 // QAbstractTableModel methods //
70 70 // /////////////////////////// //
71 71
72 72 virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override;
73 73 virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override;
74 74 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
75 75 virtual QVariant headerData(int section, Qt::Orientation orientation,
76 76 int role = Qt::DisplayRole) const override;
77 77 virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
78 78
79 79 // ///////////////// //
80 80 // Drag&Drop methods //
81 81 // ///////////////// //
82 82
83 83 virtual Qt::DropActions supportedDropActions() const override;
84 84 virtual Qt::DropActions supportedDragActions() const override;
85 85 virtual QStringList mimeTypes() const override;
86 86 virtual QMimeData *mimeData(const QModelIndexList &indexes) const override;
87 87 virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
88 88 const QModelIndex &parent) const override;
89 89 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
90 90 const QModelIndex &parent) override;
91 91
92 92 void abortProgress(const QModelIndex &index);
93 93
94 94 signals:
95 95 void abortProgessRequested(std::shared_ptr<Variable> variable);
96 void requestVariable(const QVariantHash &productData);
96 97
97 98 private:
98 99 class VariableModelPrivate;
99 100 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
100 101
101 102 private slots:
102 103 /// Slot called when data of a variable has been updated
103 104 void onVariableUpdated() noexcept;
104 105 };
105 106
106 107 // Registers QVector<int> metatype so it can be used in VariableModel::dataChanged() signal
107 108 SCIQLOP_REGISTER_META_TYPE(QVECTOR_INT_REGISTRY, QVector<int>)
108 109
109 110 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -1,143 +1,192
1 1 #include "DataSource/DataSourceController.h"
2 2 #include "DataSource/DataSourceItem.h"
3 3
4 4 #include <Data/IDataProvider.h>
5 5
6 6 #include <QMutex>
7 7 #include <QThread>
8 8
9 #include <QDataStream>
9 10 #include <QDir>
10 11 #include <QStandardPaths>
11 12
12 13 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
13 14
14 15 namespace {
15 16
16 17 /**
17 18 * Builds the metadata of the variable that will be generated from the loading of an item
18 19 * @param dataSourceItem the data source item from which to generate the metadata
19 20 * @return the metadata of the variable
20 21 */
21 22 QVariantHash variableMetadata(const DataSourceItem &dataSourceItem)
22 23 {
23 24 // Variable metadata contains...
24 25
25 26 // ... all metadata of the item
26 27 auto result = dataSourceItem.data();
27 28
28 29 // ... and the name of the plugin, recovered from root item
29 30 result.insert(QStringLiteral("plugin"), dataSourceItem.rootItem().name());
30 31
31 32 return result;
32 33 }
33 34
34 35 } // namespace
35 36
36 37 class DataSourceController::DataSourceControllerPrivate {
37 38 public:
38 39 QMutex m_WorkingMutex;
39 40 /// Data sources registered
40 41 QHash<QUuid, QString> m_DataSources;
41 42 /// Data sources structures
42 43 std::map<QUuid, std::unique_ptr<DataSourceItem> > m_DataSourceItems;
43 44 /// Data providers registered
44 45 /// @remarks Data providers are stored as shared_ptr as they can be sent to a variable and
45 46 /// continue to live without necessarily the data source controller
46 47 std::map<QUuid, std::shared_ptr<IDataProvider> > m_DataProviders;
48
49 // Search for the first datasource item matching the specified data
50 DataSourceItem *findDataSourceItem(const QVariantHash &data)
51 {
52 DataSourceItem *sourceItem = nullptr;
53 for (const auto &item : m_DataSourceItems) {
54 sourceItem = item.second->findItem(data, true);
55 if (sourceItem) {
56 break;
57 }
58 }
59
60 return sourceItem;
61 }
47 62 };
48 63
49 64 DataSourceController::DataSourceController(QObject *parent)
50 65 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
51 66 {
52 67 qCDebug(LOG_DataSourceController())
53 68 << tr("DataSourceController construction") << QThread::currentThread();
54 69 }
55 70
56 71 DataSourceController::~DataSourceController()
57 72 {
58 73 qCDebug(LOG_DataSourceController())
59 74 << tr("DataSourceController destruction") << QThread::currentThread();
60 75 this->waitForFinish();
61 76 }
62 77
63 78 QUuid DataSourceController::registerDataSource(const QString &dataSourceName) noexcept
64 79 {
65 80 auto dataSourceUid = QUuid::createUuid();
66 81 impl->m_DataSources.insert(dataSourceUid, dataSourceName);
67 82
68 83 return dataSourceUid;
69 84 }
70 85
71 86 void DataSourceController::setDataSourceItem(
72 87 const QUuid &dataSourceUid, std::unique_ptr<DataSourceItem> dataSourceItem) noexcept
73 88 {
74 89 if (!dataSourceItem) {
75 90 qCWarning(LOG_DataSourceController())
76 91 << tr("Data source item can't be registered (null item)");
77 92 return;
78 93 }
79 94
80 95 if (impl->m_DataSources.contains(dataSourceUid)) {
81 96 // The data provider is implicitly converted to a shared_ptr
82 97 impl->m_DataSourceItems.insert(std::make_pair(dataSourceUid, std::move(dataSourceItem)));
83 98
84 99 // Retrieves the data source item to emit the signal with it
85 100 auto it = impl->m_DataSourceItems.find(dataSourceUid);
86 101 if (it != impl->m_DataSourceItems.end()) {
87 102 emit dataSourceItemSet(it->second.get());
88 103 }
89 104 }
90 105 else {
91 106 qCWarning(LOG_DataSourceController()) << tr("Can't set data source item for uid %1 : no "
92 107 "data source has been registered with the uid")
93 108 .arg(dataSourceUid.toString());
94 109 }
95 110 }
96 111
97 112 void DataSourceController::setDataProvider(const QUuid &dataSourceUid,
98 113 std::unique_ptr<IDataProvider> dataProvider) noexcept
99 114 {
100 115 if (impl->m_DataSources.contains(dataSourceUid)) {
101 116 impl->m_DataProviders.insert(std::make_pair(dataSourceUid, std::move(dataProvider)));
102 117 }
103 118 else {
104 119 qCWarning(LOG_DataSourceController()) << tr("Can't set data provider for uid %1 : no data "
105 120 "source has been registered with the uid")
106 121 .arg(dataSourceUid.toString());
107 122 }
108 123 }
109 124
110 125 void DataSourceController::loadProductItem(const QUuid &dataSourceUid,
111 126 const DataSourceItem &productItem) noexcept
112 127 {
113 128 if (productItem.type() == DataSourceItemType::PRODUCT
114 129 || productItem.type() == DataSourceItemType::COMPONENT) {
115 130 /// Retrieves the data provider of the data source (if any)
116 131 auto it = impl->m_DataProviders.find(dataSourceUid);
117 132 auto dataProvider = (it != impl->m_DataProviders.end()) ? it->second : nullptr;
118 133
119 134 emit variableCreationRequested(productItem.name(), variableMetadata(productItem),
120 135 dataProvider);
121 136 }
122 137 else {
123 138 qCWarning(LOG_DataSourceController()) << tr("Can't load an item that is not a product");
124 139 }
125 140 }
126 141
142 QByteArray DataSourceController::mimeDataForProductsData(const QVariantList &productsData) const
143 {
144 QByteArray encodedData;
145 QDataStream stream(&encodedData, QIODevice::WriteOnly);
146
147 stream << productsData;
148
149 return encodedData;
150 }
151
152 QVariantList DataSourceController::productsDataForMimeData(const QByteArray &mimeData) const
153 {
154 QDataStream stream(mimeData);
155
156 QVariantList productList;
157 stream >> productList;
158
159 return productList;
160 }
161
127 162 void DataSourceController::initialize()
128 163 {
129 164 qCDebug(LOG_DataSourceController())
130 165 << tr("DataSourceController init") << QThread::currentThread();
131 166 impl->m_WorkingMutex.lock();
132 167 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
133 168 }
134 169
135 170 void DataSourceController::finalize()
136 171 {
137 172 impl->m_WorkingMutex.unlock();
138 173 }
139 174
175 void DataSourceController::requestVariable(const QVariantHash &productData)
176 {
177 DataSourceItem *sourceItem = impl->findDataSourceItem(productData);
178
179 if (sourceItem) {
180 auto sourceName = sourceItem->rootItem().name();
181 auto sourceId = impl->m_DataSources.key(sourceName);
182 loadProductItem(sourceId, *sourceItem);
183 }
184 else {
185 qCWarning(LOG_DataSourceController()) << tr("requestVariable, product data not found");
186 }
187 }
188
140 189 void DataSourceController::waitForFinish()
141 190 {
142 191 QMutexLocker locker{&impl->m_WorkingMutex};
143 192 }
@@ -1,145 +1,163
1 1 #include <DataSource/DataSourceItem.h>
2 2 #include <DataSource/DataSourceItemAction.h>
3 3
4 4 #include <QVector>
5 5
6 6 const QString DataSourceItem::NAME_DATA_KEY = QStringLiteral("name");
7 7
8 8 struct DataSourceItem::DataSourceItemPrivate {
9 9 explicit DataSourceItemPrivate(DataSourceItemType type, QVariantHash data)
10 10 : m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)}, m_Actions{}
11 11 {
12 12 }
13 13
14 14 DataSourceItem *m_Parent;
15 15 std::vector<std::unique_ptr<DataSourceItem> > m_Children;
16 16 DataSourceItemType m_Type;
17 17 QVariantHash m_Data;
18 18 std::vector<std::unique_ptr<DataSourceItemAction> > m_Actions;
19 19 };
20 20
21 21 DataSourceItem::DataSourceItem(DataSourceItemType type, const QString &name)
22 22 : DataSourceItem{type, QVariantHash{{NAME_DATA_KEY, name}}}
23 23 {
24 24 }
25 25
26 26 DataSourceItem::DataSourceItem(DataSourceItemType type, QVariantHash data)
27 27 : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))}
28 28 {
29 29 }
30 30
31 31 QVector<DataSourceItemAction *> DataSourceItem::actions() const noexcept
32 32 {
33 33 auto result = QVector<DataSourceItemAction *>{};
34 34
35 35 std::transform(std::cbegin(impl->m_Actions), std::cend(impl->m_Actions),
36 36 std::back_inserter(result), [](const auto &action) { return action.get(); });
37 37
38 38 return result;
39 39 }
40 40
41 41 void DataSourceItem::addAction(std::unique_ptr<DataSourceItemAction> action) noexcept
42 42 {
43 43 action->setDataSourceItem(this);
44 44 impl->m_Actions.push_back(std::move(action));
45 45 }
46 46
47 47 void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept
48 48 {
49 49 child->impl->m_Parent = this;
50 50 impl->m_Children.push_back(std::move(child));
51 51 }
52 52
53 53 DataSourceItem *DataSourceItem::child(int childIndex) const noexcept
54 54 {
55 55 if (childIndex < 0 || childIndex >= childCount()) {
56 56 return nullptr;
57 57 }
58 58 else {
59 59 return impl->m_Children.at(childIndex).get();
60 60 }
61 61 }
62 62
63 63 int DataSourceItem::childCount() const noexcept
64 64 {
65 65 return impl->m_Children.size();
66 66 }
67 67
68 68 QVariant DataSourceItem::data(const QString &key) const noexcept
69 69 {
70 70 return impl->m_Data.value(key);
71 71 }
72 72
73 73 QVariantHash DataSourceItem::data() const noexcept
74 74 {
75 75 return impl->m_Data;
76 76 }
77 77
78 78 bool DataSourceItem::isRoot() const noexcept
79 79 {
80 80 return impl->m_Parent == nullptr;
81 81 }
82 82
83 83 QString DataSourceItem::name() const noexcept
84 84 {
85 85 return data(NAME_DATA_KEY).toString();
86 86 }
87 87
88 88 DataSourceItem *DataSourceItem::parentItem() const noexcept
89 89 {
90 90 return impl->m_Parent;
91 91 }
92 92
93 93 const DataSourceItem &DataSourceItem::rootItem() const noexcept
94 94 {
95 95 return isRoot() ? *this : parentItem()->rootItem();
96 96 }
97 97
98 98 void DataSourceItem::setData(const QString &key, const QVariant &value, bool append) noexcept
99 99 {
100 100 auto it = impl->m_Data.constFind(key);
101 101 if (append && it != impl->m_Data.constEnd()) {
102 102 // Case of an existing value to which we want to add to the new value
103 103 if (it->canConvert<QVariantList>()) {
104 104 auto variantList = it->value<QVariantList>();
105 105 variantList.append(value);
106 106
107 107 impl->m_Data.insert(key, variantList);
108 108 }
109 109 else {
110 110 impl->m_Data.insert(key, QVariantList{*it, value});
111 111 }
112 112 }
113 113 else {
114 114 // Other cases :
115 115 // - new value in map OR
116 116 // - replacement of an existing value (not appending)
117 117 impl->m_Data.insert(key, value);
118 118 }
119 119 }
120 120
121 121 DataSourceItemType DataSourceItem::type() const noexcept
122 122 {
123 123 return impl->m_Type;
124 124 }
125 125
126 DataSourceItem *DataSourceItem::findItem(const QVariantHash &data, bool recursive)
127 {
128 for (const auto &child : impl->m_Children) {
129 if (child->impl->m_Data == data) {
130 return child.get();
131 }
132
133 if (recursive) {
134 auto foundItem = child->findItem(data, true);
135 if (foundItem) {
136 return foundItem;
137 }
138 }
139 }
140
141 return nullptr;
142 }
143
126 144 bool DataSourceItem::operator==(const DataSourceItem &other)
127 145 {
128 146 // Compares items' attributes
129 147 if (std::tie(impl->m_Type, impl->m_Data) == std::tie(other.impl->m_Type, other.impl->m_Data)) {
130 148 // Compares contents of items' children
131 149 return std::equal(std::cbegin(impl->m_Children), std::cend(impl->m_Children),
132 150 std::cbegin(other.impl->m_Children),
133 151 [](const auto &itemChild, const auto &otherChild) {
134 152 return *itemChild == *otherChild;
135 153 });
136 154 }
137 155 else {
138 156 return false;
139 157 }
140 158 }
141 159
142 160 bool DataSourceItem::operator!=(const DataSourceItem &other)
143 161 {
144 162 return !(*this == other);
145 163 }
@@ -1,351 +1,368
1 1 #include <Variable/Variable.h>
2 2 #include <Variable/VariableController.h>
3 3 #include <Variable/VariableModel.h>
4 4
5 5 #include <Common/DateUtils.h>
6 6 #include <Common/MimeTypesDef.h>
7 7 #include <Common/StringUtils.h>
8 8
9 9 #include <Data/IDataSeries.h>
10 10
11 #include <QDataStream>
11 12 #include <QMimeData>
12 13 #include <QSize>
13 14 #include <unordered_map>
14 15
15 16 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
16 17
17 18 namespace {
18 19
19 20 // Column indexes
20 21 const auto NAME_COLUMN = 0;
21 22 const auto TSTART_COLUMN = 1;
22 23 const auto TEND_COLUMN = 2;
23 24 const auto NBPOINTS_COLUMN = 3;
24 25 const auto UNIT_COLUMN = 4;
25 26 const auto MISSION_COLUMN = 5;
26 27 const auto PLUGIN_COLUMN = 6;
27 28 const auto NB_COLUMNS = 7;
28 29
29 30 // Column properties
30 31 const auto DEFAULT_HEIGHT = 25;
31 32 const auto DEFAULT_WIDTH = 100;
32 33
33 34 struct ColumnProperties {
34 35 ColumnProperties(const QString &name = {}, int width = DEFAULT_WIDTH,
35 36 int height = DEFAULT_HEIGHT)
36 37 : m_Name{name}, m_Width{width}, m_Height{height}
37 38 {
38 39 }
39 40
40 41 QString m_Name;
41 42 int m_Width;
42 43 int m_Height;
43 44 };
44 45
45 46 const auto COLUMN_PROPERTIES = QHash<int, ColumnProperties>{
46 47 {NAME_COLUMN, {QObject::tr("Name")}}, {TSTART_COLUMN, {QObject::tr("tStart"), 180}},
47 48 {TEND_COLUMN, {QObject::tr("tEnd"), 180}}, {NBPOINTS_COLUMN, {QObject::tr("Nb points")}},
48 49 {UNIT_COLUMN, {QObject::tr("Unit")}}, {MISSION_COLUMN, {QObject::tr("Mission")}},
49 50 {PLUGIN_COLUMN, {QObject::tr("Plugin")}}};
50 51
51 52 /// Format for datetimes
52 53 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
53 54
54 55 QString uniqueName(const QString &defaultName,
55 56 const std::vector<std::shared_ptr<Variable> > &variables)
56 57 {
57 58 auto forbiddenNames = std::vector<QString>(variables.size());
58 59 std::transform(variables.cbegin(), variables.cend(), forbiddenNames.begin(),
59 60 [](const auto &variable) { return variable->name(); });
60 61 auto uniqueName = StringUtils::uniqueName(defaultName, forbiddenNames);
61 62 Q_ASSERT(!uniqueName.isEmpty());
62 63
63 64 return uniqueName;
64 65 }
65 66
66 67 } // namespace
67 68
68 69 struct VariableModel::VariableModelPrivate {
69 70 /// Variables created in SciQlop
70 71 std::vector<std::shared_ptr<Variable> > m_Variables;
71 72 std::unordered_map<std::shared_ptr<Variable>, double> m_VariableToProgress;
72 73 VariableController *m_VariableController;
73 74
74 75 /// Return the row index of the variable. -1 if it's not found
75 76 int indexOfVariable(Variable *variable) const noexcept;
76 77 };
77 78
78 79 VariableModel::VariableModel(VariableController *parent)
79 80 : QAbstractTableModel{parent}, impl{spimpl::make_unique_impl<VariableModelPrivate>()}
80 81 {
81 82 impl->m_VariableController = parent;
82 83 }
83 84
84 85 void VariableModel::addVariable(std::shared_ptr<Variable> variable) noexcept
85 86 {
86 87 auto insertIndex = rowCount();
87 88 beginInsertRows({}, insertIndex, insertIndex);
88 89
89 90 // Generates unique name for the variable
90 91 variable->setName(uniqueName(variable->name(), impl->m_Variables));
91 92
92 93 impl->m_Variables.push_back(variable);
93 94 connect(variable.get(), &Variable::updated, this, &VariableModel::onVariableUpdated);
94 95
95 96 endInsertRows();
96 97 }
97 98
98 99 bool VariableModel::containsVariable(std::shared_ptr<Variable> variable) const noexcept
99 100 {
100 101 auto end = impl->m_Variables.cend();
101 102 return std::find(impl->m_Variables.cbegin(), end, variable) != end;
102 103 }
103 104
104 105 std::shared_ptr<Variable> VariableModel::createVariable(const QString &name,
105 106 const QVariantHash &metadata) noexcept
106 107 {
107 108 auto variable = std::make_shared<Variable>(name, metadata);
108 109 addVariable(variable);
109 110
110 111 return variable;
111 112 }
112 113
113 114 void VariableModel::deleteVariable(std::shared_ptr<Variable> variable) noexcept
114 115 {
115 116 if (!variable) {
116 117 qCCritical(LOG_Variable()) << "Can't delete a null variable from the model";
117 118 return;
118 119 }
119 120
120 121 // Finds variable in the model
121 122 auto begin = impl->m_Variables.cbegin();
122 123 auto end = impl->m_Variables.cend();
123 124 auto it = std::find(begin, end, variable);
124 125 if (it != end) {
125 126 auto removeIndex = std::distance(begin, it);
126 127
127 128 // Deletes variable
128 129 beginRemoveRows({}, removeIndex, removeIndex);
129 130 impl->m_Variables.erase(it);
130 131 endRemoveRows();
131 132 }
132 133 else {
133 134 qCritical(LOG_VariableModel())
134 135 << tr("Can't delete variable %1 from the model: the variable is not in the model")
135 136 .arg(variable->name());
136 137 }
137 138
138 139 // Removes variable from progress map
139 140 impl->m_VariableToProgress.erase(variable);
140 141 }
141 142
142 143
143 144 std::shared_ptr<Variable> VariableModel::variable(int index) const
144 145 {
145 146 return (index >= 0 && index < impl->m_Variables.size()) ? impl->m_Variables[index] : nullptr;
146 147 }
147 148
148 149 std::vector<std::shared_ptr<Variable> > VariableModel::variables() const
149 150 {
150 151 return impl->m_Variables;
151 152 }
152 153
153 154 void VariableModel::setDataProgress(std::shared_ptr<Variable> variable, double progress)
154 155 {
155 156 if (progress > 0.0) {
156 157 impl->m_VariableToProgress[variable] = progress;
157 158 }
158 159 else {
159 160 impl->m_VariableToProgress.erase(variable);
160 161 }
161 162 auto modelIndex = createIndex(impl->indexOfVariable(variable.get()), NAME_COLUMN);
162 163
163 164 emit dataChanged(modelIndex, modelIndex);
164 165 }
165 166
166 167 int VariableModel::columnCount(const QModelIndex &parent) const
167 168 {
168 169 Q_UNUSED(parent);
169 170
170 171 return NB_COLUMNS;
171 172 }
172 173
173 174 int VariableModel::rowCount(const QModelIndex &parent) const
174 175 {
175 176 Q_UNUSED(parent);
176 177
177 178 return impl->m_Variables.size();
178 179 }
179 180
180 181 QVariant VariableModel::data(const QModelIndex &index, int role) const
181 182 {
182 183 if (!index.isValid()) {
183 184 return QVariant{};
184 185 }
185 186
186 187 if (index.row() < 0 || index.row() >= rowCount()) {
187 188 return QVariant{};
188 189 }
189 190
190 191 if (role == Qt::DisplayRole) {
191 192 if (auto variable = impl->m_Variables.at(index.row()).get()) {
192 193 switch (index.column()) {
193 194 case NAME_COLUMN:
194 195 return variable->name();
195 196 case TSTART_COLUMN: {
196 197 auto range = variable->realRange();
197 198 return range != INVALID_RANGE
198 199 ? DateUtils::dateTime(range.m_TStart).toString(DATETIME_FORMAT)
199 200 : QVariant{};
200 201 }
201 202 case TEND_COLUMN: {
202 203 auto range = variable->realRange();
203 204 return range != INVALID_RANGE
204 205 ? DateUtils::dateTime(range.m_TEnd).toString(DATETIME_FORMAT)
205 206 : QVariant{};
206 207 }
207 208 case NBPOINTS_COLUMN:
208 209 return variable->nbPoints();
209 210 case UNIT_COLUMN:
210 211 return variable->metadata().value(QStringLiteral("units"));
211 212 case MISSION_COLUMN:
212 213 return variable->metadata().value(QStringLiteral("mission"));
213 214 case PLUGIN_COLUMN:
214 215 return variable->metadata().value(QStringLiteral("plugin"));
215 216 default:
216 217 // No action
217 218 break;
218 219 }
219 220
220 221 qWarning(LOG_VariableModel())
221 222 << tr("Can't get data (unknown column %1)").arg(index.column());
222 223 }
223 224 else {
224 225 qWarning(LOG_VariableModel()) << tr("Can't get data (no variable)");
225 226 }
226 227 }
227 228 else if (role == VariableRoles::ProgressRole) {
228 229 if (auto variable = impl->m_Variables.at(index.row())) {
229 230
230 231 auto it = impl->m_VariableToProgress.find(variable);
231 232 if (it != impl->m_VariableToProgress.cend()) {
232 233 return it->second;
233 234 }
234 235 }
235 236 }
236 237
237 238 return QVariant{};
238 239 }
239 240
240 241 QVariant VariableModel::headerData(int section, Qt::Orientation orientation, int role) const
241 242 {
242 243 if (role != Qt::DisplayRole && role != Qt::SizeHintRole) {
243 244 return QVariant{};
244 245 }
245 246
246 247 if (orientation == Qt::Horizontal) {
247 248 auto propertiesIt = COLUMN_PROPERTIES.find(section);
248 249 if (propertiesIt != COLUMN_PROPERTIES.cend()) {
249 250 // Role is either DisplayRole or SizeHintRole
250 251 return (role == Qt::DisplayRole)
251 252 ? QVariant{propertiesIt->m_Name}
252 253 : QVariant{QSize{propertiesIt->m_Width, propertiesIt->m_Height}};
253 254 }
254 255 else {
255 256 qWarning(LOG_VariableModel())
256 257 << tr("Can't get header data (unknown column %1)").arg(section);
257 258 }
258 259 }
259 260
260 261 return QVariant{};
261 262 }
262 263
263 264 Qt::ItemFlags VariableModel::flags(const QModelIndex &index) const
264 265 {
265 266 return QAbstractTableModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
266 267 }
267 268
268 269 Qt::DropActions VariableModel::supportedDropActions() const
269 270 {
270 return Qt::MoveAction;
271 return Qt::CopyAction | Qt::MoveAction;
271 272 }
272 273
273 274 Qt::DropActions VariableModel::supportedDragActions() const
274 275 {
275 276 return Qt::CopyAction | Qt::MoveAction;
276 277 }
277 278
278 279 QStringList VariableModel::mimeTypes() const
279 280 {
280 281 return {MIME_TYPE_VARIABLE_LIST};
281 282 }
282 283
283 284 QMimeData *VariableModel::mimeData(const QModelIndexList &indexes) const
284 285 {
285 286 auto mimeData = new QMimeData;
286 287
287 288 QList<std::shared_ptr<Variable> > variableList;
288 289
289 290 for (const auto &index : indexes) {
290 291 if (index.column() == 0) { // only the first column
291 292 auto variable = impl->m_Variables.at(index.row());
292 293 if (variable.get() && index.isValid()) {
293 294 variableList << variable;
294 295 }
295 296 }
296 297 }
297 298
298 299 auto encodedData = impl->m_VariableController->mimeDataForVariables(variableList);
299 300 mimeData->setData(MIME_TYPE_VARIABLE_LIST, encodedData);
300 301
301 302 return mimeData;
302 303 }
303 304
304 305 bool VariableModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row,
305 306 int column, const QModelIndex &parent) const
306 307 {
307 return false;
308 // drop of a product
309 return data->hasFormat(MIME_TYPE_PRODUCT_LIST);
308 310 }
309 311
310 312 bool VariableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
311 313 const QModelIndex &parent)
312 314 {
313 return false;
315 bool dropDone = false;
316
317 if (data->hasFormat(MIME_TYPE_PRODUCT_LIST)) {
318 QDataStream stream(data->data(MIME_TYPE_PRODUCT_LIST));
319
320 QVariantList productList;
321 stream >> productList;
322
323 for (auto metaData : productList) {
324 emit requestVariable(metaData.toHash());
325 }
326
327 dropDone = true;
328 }
329
330 return dropDone;
314 331 }
315 332
316 333 void VariableModel::abortProgress(const QModelIndex &index)
317 334 {
318 335 if (auto variable = impl->m_Variables.at(index.row())) {
319 336 emit abortProgessRequested(variable);
320 337 }
321 338 }
322 339
323 340 void VariableModel::onVariableUpdated() noexcept
324 341 {
325 342 // Finds variable that has been updated in the model
326 343 if (auto updatedVariable = dynamic_cast<Variable *>(sender())) {
327 344 auto updatedVariableIndex = impl->indexOfVariable(updatedVariable);
328 345
329 346 if (updatedVariableIndex > -1) {
330 347 emit dataChanged(createIndex(updatedVariableIndex, 0),
331 348 createIndex(updatedVariableIndex, columnCount() - 1));
332 349 }
333 350 }
334 351 }
335 352
336 353 int VariableModel::VariableModelPrivate::indexOfVariable(Variable *variable) const noexcept
337 354 {
338 355 auto begin = std::cbegin(m_Variables);
339 356 auto end = std::cend(m_Variables);
340 357 auto it
341 358 = std::find_if(begin, end, [variable](const auto &var) { return var.get() == variable; });
342 359
343 360 if (it != end) {
344 361 // Gets the index of the variable in the model: we assume here that views have the same
345 362 // order as the model
346 363 return std::distance(begin, it);
347 364 }
348 365 else {
349 366 return -1;
350 367 }
351 368 }
@@ -1,38 +1,37
1 1 #include "DataSource/DataSourceTreeWidget.h"
2 2 #include "Common/MimeTypesDef.h"
3 #include "DataSource/DataSourceController.h"
3 4 #include "DataSource/DataSourceItem.h"
4 5 #include "DataSource/DataSourceTreeWidgetItem.h"
5 6
7 #include "SqpApplication.h"
8
6 9 #include <QMimeData>
7 10
8 11 DataSourceTreeWidget::DataSourceTreeWidget(QWidget *parent) : QTreeWidget(parent) {}
9 12
10 13 QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const
11 14 {
12 15 auto mimeData = new QMimeData;
13 16
14 17 // Basic check to ensure the item are correctly typed
15 18 Q_ASSERT(items.isEmpty() || dynamic_cast<DataSourceTreeWidgetItem *>(items.first()) != nullptr);
16 19
17 20 QVariantList productData;
18 21
19 22 for (auto item : items) {
20 23 auto dataSourceTreeItem = static_cast<DataSourceTreeWidgetItem *>(item);
21 24 auto dataSource = dataSourceTreeItem->data();
22 25
23 26 if (dataSource->type() == DataSourceItemType::COMPONENT
24 27 || dataSource->type() == DataSourceItemType::PRODUCT) {
25 28 auto metaData = dataSource->data();
26 29 productData << metaData;
27 30 }
28 31 }
29 32
30 QByteArray encodedData;
31 QDataStream stream(&encodedData, QIODevice::WriteOnly);
32
33 stream << productData;
34
33 auto encodedData = sqpApp->dataSourceController().mimeDataForProductsData(productData);
35 34 mimeData->setData(MIME_TYPE_PRODUCT_LIST, encodedData);
36 35
37 36 return mimeData;
38 37 }
@@ -1,155 +1,159
1 1 #include "SqpApplication.h"
2 2
3 3 #include <Data/IDataProvider.h>
4 4 #include <DataSource/DataSourceController.h>
5 5 #include <DragDropHelper.h>
6 6 #include <Network/NetworkController.h>
7 7 #include <QThread>
8 8 #include <Time/TimeController.h>
9 9 #include <Variable/Variable.h>
10 10 #include <Variable/VariableController.h>
11 #include <Variable/VariableModel.h>
11 12 #include <Visualization/VisualizationController.h>
12 13
13 14 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
14 15
15 16 class SqpApplication::SqpApplicationPrivate {
16 17 public:
17 18 SqpApplicationPrivate()
18 19 : m_DataSourceController{std::make_unique<DataSourceController>()},
19 20 m_NetworkController{std::make_unique<NetworkController>()},
20 21 m_TimeController{std::make_unique<TimeController>()},
21 22 m_VariableController{std::make_unique<VariableController>()},
22 23 m_VisualizationController{std::make_unique<VisualizationController>()},
23 24 m_DragDropHelper{std::make_unique<DragDropHelper>()}
24 25 {
25 26 // /////////////////////////////// //
26 27 // Connections between controllers //
27 28 // /////////////////////////////// //
28 29
29 30 // VariableController <-> DataSourceController
30 31 connect(m_DataSourceController.get(),
31 32 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
32 33 std::shared_ptr<IDataProvider>)),
33 34 m_VariableController.get(),
34 35 SLOT(createVariable(const QString &, const QVariantHash &,
35 36 std::shared_ptr<IDataProvider>)));
36 37
38 connect(m_VariableController->variableModel(), &VariableModel::requestVariable,
39 m_DataSourceController.get(), &DataSourceController::requestVariable);
40
37 41 // VariableController <-> VisualizationController
38 42 connect(m_VariableController.get(),
39 43 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
40 44 m_VisualizationController.get(),
41 45 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
42 46
43 47 connect(m_VariableController.get(),
44 48 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)),
45 49 m_VisualizationController.get(),
46 50 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
47 51
48 52
49 53 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
50 54 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
51 55 m_NetworkController->moveToThread(&m_NetworkControllerThread);
52 56 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
53 57 m_VariableController->moveToThread(&m_VariableControllerThread);
54 58 m_VariableControllerThread.setObjectName("VariableControllerThread");
55 59 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
56 60 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
57 61
58 62
59 63 // Additionnal init
60 64 m_VariableController->setTimeController(m_TimeController.get());
61 65 }
62 66
63 67 virtual ~SqpApplicationPrivate()
64 68 {
65 69 m_DataSourceControllerThread.quit();
66 70 m_DataSourceControllerThread.wait();
67 71
68 72 m_NetworkControllerThread.quit();
69 73 m_NetworkControllerThread.wait();
70 74
71 75 m_VariableControllerThread.quit();
72 76 m_VariableControllerThread.wait();
73 77
74 78 m_VisualizationControllerThread.quit();
75 79 m_VisualizationControllerThread.wait();
76 80 }
77 81
78 82 std::unique_ptr<DataSourceController> m_DataSourceController;
79 83 std::unique_ptr<VariableController> m_VariableController;
80 84 std::unique_ptr<TimeController> m_TimeController;
81 85 std::unique_ptr<NetworkController> m_NetworkController;
82 86 std::unique_ptr<VisualizationController> m_VisualizationController;
83 87 QThread m_DataSourceControllerThread;
84 88 QThread m_NetworkControllerThread;
85 89 QThread m_VariableControllerThread;
86 90 QThread m_VisualizationControllerThread;
87 91
88 92 std::unique_ptr<DragDropHelper> m_DragDropHelper;
89 93 };
90 94
91 95
92 96 SqpApplication::SqpApplication(int &argc, char **argv)
93 97 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
94 98 {
95 99 qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread();
96 100
97 101 connect(&impl->m_DataSourceControllerThread, &QThread::started,
98 102 impl->m_DataSourceController.get(), &DataSourceController::initialize);
99 103 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
100 104 impl->m_DataSourceController.get(), &DataSourceController::finalize);
101 105
102 106 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
103 107 &NetworkController::initialize);
104 108 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
105 109 &NetworkController::finalize);
106 110
107 111 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
108 112 &VariableController::initialize);
109 113 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
110 114 &VariableController::finalize);
111 115
112 116 connect(&impl->m_VisualizationControllerThread, &QThread::started,
113 117 impl->m_VisualizationController.get(), &VisualizationController::initialize);
114 118 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
115 119 impl->m_VisualizationController.get(), &VisualizationController::finalize);
116 120
117 121 impl->m_DataSourceControllerThread.start();
118 122 impl->m_NetworkControllerThread.start();
119 123 impl->m_VariableControllerThread.start();
120 124 impl->m_VisualizationControllerThread.start();
121 125 }
122 126
123 127 SqpApplication::~SqpApplication() {}
124 128
125 129 void SqpApplication::initialize() {}
126 130
127 131 DataSourceController &SqpApplication::dataSourceController() noexcept
128 132 {
129 133 return *impl->m_DataSourceController;
130 134 }
131 135
132 136 NetworkController &SqpApplication::networkController() noexcept
133 137 {
134 138 return *impl->m_NetworkController;
135 139 }
136 140
137 141 TimeController &SqpApplication::timeController() noexcept
138 142 {
139 143 return *impl->m_TimeController;
140 144 }
141 145
142 146 VariableController &SqpApplication::variableController() noexcept
143 147 {
144 148 return *impl->m_VariableController;
145 149 }
146 150
147 151 VisualizationController &SqpApplication::visualizationController() noexcept
148 152 {
149 153 return *impl->m_VisualizationController;
150 154 }
151 155
152 156 DragDropHelper &SqpApplication::dragDropHelper() noexcept
153 157 {
154 158 return *impl->m_DragDropHelper;
155 159 }
@@ -1,46 +1,49
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <ui version="4.0">
3 3 <class>DataSourceWidget</class>
4 4 <widget class="QWidget" name="DataSourceWidget">
5 5 <property name="geometry">
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 9 <width>400</width>
10 10 <height>300</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
14 14 <string>Data sources</string>
15 15 </property>
16 16 <layout class="QGridLayout" name="gridLayout">
17 17 <item row="0" column="0">
18 18 <widget class="QLineEdit" name="filterLineEdit"/>
19 19 </item>
20 20 <item row="1" column="0">
21 21 <widget class="DataSourceTreeWidget" name="treeWidget">
22 22 <property name="dragEnabled">
23 23 <bool>true</bool>
24 24 </property>
25 25 <property name="dragDropMode">
26 26 <enum>QAbstractItemView::DragOnly</enum>
27 27 </property>
28 <property name="selectionMode">
29 <enum>QAbstractItemView::ExtendedSelection</enum>
30 </property>
28 31 <column>
29 32 <property name="text">
30 33 <string notr="true">1</string>
31 34 </property>
32 35 </column>
33 36 </widget>
34 37 </item>
35 38 </layout>
36 39 </widget>
37 40 <customwidgets>
38 41 <customwidget>
39 42 <class>DataSourceTreeWidget</class>
40 43 <extends>QTreeWidget</extends>
41 44 <header>DataSource/DataSourceTreeWidget.h</header>
42 45 </customwidget>
43 46 </customwidgets>
44 47 <resources/>
45 48 <connections/>
46 49 </ui>
General Comments 0
You need to be logged in to leave comments. Login now