forked from shotgunsoftware/tk-multi-loader2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_status.py
More file actions
63 lines (52 loc) · 1.97 KB
/
Copy pathmodel_status.py
File metadata and controls
63 lines (52 loc) · 1.97 KB
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
# Copyright (c) 2015 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
import sgtk
from sgtk.platform.qt import QtCore, QtGui
# import the shotgun_model module from the shotgun utils framework
shotgun_model = sgtk.platform.import_framework(
"tk-framework-shotgunutils", "shotgun_model"
)
ShotgunModel = shotgun_model.ShotgunModel
class SgStatusModel(ShotgunModel):
"""
This model represents status codes.
"""
def __init__(self, parent, bg_task_manager):
"""
Constructor
"""
# folder icon
ShotgunModel.__init__(
self, parent, download_thumbs=False, bg_task_manager=bg_task_manager
)
fields = ["bg_color", "icon", "code", "name"]
self._load_data("Status", [], ["code"], fields)
self._refresh_data()
############################################################################################
# public methods
def get_color_str(self, code):
"""
Returns the color, as a string, for example '202,244,231'
"""
for idx in range(self.rowCount()):
item = self.item(idx)
if item.text() == code:
return item.get_sg_data().get("bg_color")
return None
def get_long_name(self, code):
"""
Returns the long name for a status, 'Undefined' if not found.
"""
for idx in range(self.rowCount()):
item = self.item(idx)
if item.text() == code and item.get_sg_data().get("name"):
# avoid non-None values
return item.get_sg_data().get("name")
return "Undefined"