Commit 9711bc07 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[backend][assetmodel] Made AssetType a python enum

This will make the enum itself more usable. Style wise, this makes
it an independent element of AssetModel.
parent 5706658e
......@@ -25,25 +25,28 @@
import os
from enum import Enum
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtCore import pyqtProperty
from PyQt5.QtCore import Q_ENUMS
from PyQt5.QtCore import QStringListModel
class AssetType:
class AssetType(Enum):
"""All possible assets available on the BEAT platform"""
Unknown = 0
Algorithm = 1
Database = 2
Dataformat = 3
Experiment = 4
Library = 5
Plotter = 6
PlotterParameters = 7
Toolchain = 8
(
Unknown,
Algorithm,
Database,
Dataformat,
Experiment,
Library,
Plotter,
PlotterParameters,
Toolchain,
) = range(9)
@classmethod
def path(cls, type_):
......@@ -68,11 +71,9 @@ class AssetType:
return path
class AssetModel(QStringListModel, AssetType):
class AssetModel(QStringListModel):
"""The asset model present a list of available asset from a given type"""
Q_ENUMS(AssetType)
assetTypeChanged = pyqtSignal(AssetType)
prefixPathChanged = pyqtSignal(str)
......
......@@ -23,7 +23,7 @@
# #
###############################################################################
from ..backend.assetmodel import AssetModel
from ..backend.assetmodel import AssetModel, AssetType
class TestAssetModel:
......@@ -31,7 +31,7 @@ class TestAssetModel:
def test_model_load(self, qtbot, test_prefix):
model = AssetModel()
asset_type = AssetModel.Dataformat
asset_type = AssetType.Dataformat
with qtbot.waitSignals(
[model.assetTypeChanged, model.prefixPathChanged]
......@@ -48,7 +48,7 @@ class TestAssetModel:
def test_experiment_model_load(self, qtbot, test_prefix):
model = AssetModel()
asset_type = AssetModel.Experiment
asset_type = AssetType.Experiment
with qtbot.waitSignals(
[model.assetTypeChanged, model.prefixPathChanged]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment