Skip to content

PimpMySpreadsheet

CustomSpreadsheetColumns

Bases: QObject

A class defining custom columns for Hiero's spreadsheet view. This has a similar, but slightly simplified, interface to the QAbstractItemModel and QItemDelegate classes.

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
class CustomSpreadsheetColumns(QObject):
    """
    A class defining custom columns for Hiero's spreadsheet view. This has a similar, but
    slightly simplified, interface to the QAbstractItemModel and QItemDelegate classes.
  """
    global gStatusTags
    global gArtistList

    # Ideally, we'd set this list on a Per Item basis, but this is expensive for a large mixed selection
    standardColourSpaces = [
        "linear", "sRGB", "rec709", "Cineon", "Gamma1.8", "Gamma2.2",
        "Panalog", "REDLog", "ViperLog"
    ]
    arriColourSpaces = [
        "Video - Rec709", "LogC - Camera Native", "Video - P3", "ACES",
        "LogC - Film", "LogC - Wide Gamut"
    ]
    r3dColourSpaces = [
        "Linear", "Rec709", "REDspace", "REDlog", "PDlog685", "PDlog985",
        "CustomPDlog", "REDgamma", "SRGB", "REDlogFilm", "REDgamma2",
        "REDgamma3"
    ]
    gColourSpaces = standardColourSpaces + arriColourSpaces + r3dColourSpaces

    currentView = hiero.ui.activeView()

    # This is the list of Columns available
    gCustomColumnList = [
        {
            "name": "Tags",
            "cellType": "readonly"
        },
        {
            "name": "Colourspace",
            "cellType": "dropdown"
        },
        {
            "name": "Notes",
            "cellType": "readonly"
        },
        {
            "name": "FileType",
            "cellType": "readonly"
        },
        {
            "name": "Shot Status",
            "cellType": "dropdown"
        },
        {
            "name": "Thumbnail",
            "cellType": "readonly"
        },
        {
            "name": "MediaType",
            "cellType": "readonly"
        },
        {
            "name": "Width",
            "cellType": "readonly"
        },
        {
            "name": "Height",
            "cellType": "readonly"
        },
        {
            "name": "Pixel Aspect",
            "cellType": "readonly"
        },
        {
            "name": "Artist",
            "cellType": "dropdown"
        },
        {
            "name": "Department",
            "cellType": "readonly"
        },
    ]

    def numColumns(self):
        """
      Return the number of custom columns in the spreadsheet view
    """
        return len(self.gCustomColumnList)

    def columnName(self, column):
        """
      Return the name of a custom column
    """
        return self.gCustomColumnList[column]["name"]

    def getTagsString(self, item):
        """
      Convenience method for returning all the Notes in a Tag as a string
    """
        tagNames = []
        tags = item.tags()
        for tag in tags:
            tagNames += [tag.name()]
        tagNameString = ','.join(tagNames)
        return tagNameString

    def getNotes(self, item):
        """
      Convenience method for returning all the Notes in a Tag as a string
    """
        notes = ""
        tags = item.tags()
        for tag in tags:
            note = tag.note()
            if len(note) > 0:
                notes += tag.note() + ', '
        return notes[:-2]

    def getData(self, row, column, item):
        """
      Return the data in a cell
    """
        currentColumn = self.gCustomColumnList[column]
        if currentColumn["name"] == "Tags":
            return self.getTagsString(item)

        if currentColumn["name"] == "Colourspace":
            try:
                colTransform = item.sourceMediaColourTransform()
            except:
                colTransform = "--"
            return colTransform

        if currentColumn["name"] == "Notes":
            try:
                note = self.getNotes(item)
            except:
                note = ""
            return note

        if currentColumn["name"] == "FileType":
            fileType = "--"
            M = item.source().mediaSource().metadata()
            if M.hasKey("foundry.source.type"):
                fileType = M.value("foundry.source.type")
            elif M.hasKey("media.input.filereader"):
                fileType = M.value("media.input.filereader")
            return fileType

        if currentColumn["name"] == "Shot Status":
            status = item.status()
            if not status:
                status = "--"
            return str(status)

        if currentColumn["name"] == "MediaType":
            M = item.mediaType()
            return str(M).split("MediaType")[-1].replace(".k", "")

        if currentColumn["name"] == "Thumbnail":
            return str(item.eventNumber())

        if currentColumn["name"] == "Width":
            return str(item.source().format().width())

        if currentColumn["name"] == "Height":
            return str(item.source().format().height())

        if currentColumn["name"] == "Pixel Aspect":
            return str(item.source().format().pixelAspect())

        if currentColumn["name"] == "Artist":
            if item.artist():
                name = item.artist()["artistName"]
                return name
            else:
                return "--"

        if currentColumn["name"] == "Department":
            if item.artist():
                dep = item.artist()["artistDepartment"]
                return dep
            else:
                return "--"

        return ""

    def setData(self, row, column, item, data):
        """
      Set the data in a cell - unused in this example
    """

        return None

    def getTooltip(self, row, column, item):
        """
      Return the tooltip for a cell
    """
        currentColumn = self.gCustomColumnList[column]
        if currentColumn["name"] == "Tags":
            return str([item.name() for item in item.tags()])

        if currentColumn["name"] == "Notes":
            return str(self.getNotes(item))
        return ""

    def getFont(self, row, column, item):
        """
      Return the tooltip for a cell
    """
        return None

    def getBackground(self, row, column, item):
        """
      Return the background colour for a cell
    """
        if not item.source().mediaSource().isMediaPresent():
            return QColor(80, 20, 20)
        return None

    def getForeground(self, row, column, item):
        """
      Return the text colour for a cell
    """
        #if column == 1:
        #  return QColor(255, 64, 64)
        return None

    def getIcon(self, row, column, item):
        """
      Return the icon for a cell
    """
        currentColumn = self.gCustomColumnList[column]
        if currentColumn["name"] == "Colourspace":
            return QIcon("icons:LUT.png")

        if currentColumn["name"] == "Shot Status":
            status = item.status()
            if status:
                return QIcon(gStatusTags[status])

        if currentColumn["name"] == "MediaType":
            mediaType = item.mediaType()
            if mediaType == hiero.core.TrackItem.kVideo:
                return QIcon("icons:VideoOnly.png")
            elif mediaType == hiero.core.TrackItem.kAudio:
                return QIcon("icons:AudioOnly.png")

        if currentColumn["name"] == "Artist":
            try:
                return QIcon(item.artist()["artistIcon"])
            except:
                return None
        return None

    def getSizeHint(self, row, column, item):
        """
      Return the size hint for a cell
    """
        currentColumnName = self.gCustomColumnList[column]["name"]

        if currentColumnName == "Thumbnail":
            return QSize(90, 50)

        return QSize(50, 50)

    def paintCell(self, row, column, item, painter, option):
        """
      Paint a custom cell. Return True if the cell was painted, or False to continue
      with the default cell painting.
    """
        currentColumn = self.gCustomColumnList[column]
        if currentColumn["name"] == "Tags":
            if option.state & QStyle.State_Selected:
                painter.fillRect(option.rect, option.palette.highlight())
            iconSize = 20
            r = QRect(option.rect.x(),
                      option.rect.y() + (option.rect.height() - iconSize) / 2,
                      iconSize, iconSize)
            tags = item.tags()
            if len(tags) > 0:
                painter.save()
                painter.setClipRect(option.rect)
                for tag in item.tags():
                    M = tag.metadata()
                    if not (M.hasKey("tag.status")
                            or M.hasKey("tag.artistID")):
                        QIcon(tag.icon()).paint(painter, r, Qt.AlignLeft)
                        r.translate(r.width() + 2, 0)
                painter.restore()
                return True

        if currentColumn["name"] == "Thumbnail":
            imageView = None
            pen = QPen()
            r = QRect(option.rect.x() + 2, (option.rect.y() +
                                            (option.rect.height() - 46) / 2),
                      85, 46)
            if not item.source().mediaSource().isMediaPresent():
                imageView = QImage("icons:Offline.png")
                pen.setColor(QColor(Qt.red))

            if item.mediaType() == hiero.core.TrackItem.MediaType.kAudio:
                imageView = QImage("icons:AudioOnly.png")
                #pen.setColor(QColor(Qt.green))
                painter.fillRect(r, QColor(45, 59, 45))

            if option.state & QStyle.State_Selected:
                painter.fillRect(option.rect, option.palette.highlight())

            tags = item.tags()
            painter.save()
            painter.setClipRect(option.rect)

            if not imageView:
                try:
                    imageView = item.thumbnail(item.sourceIn())
                    pen.setColor(QColor(20, 20, 20))
                # If we're here, we probably have a TC error, no thumbnail, so get it from the source Clip...
                except:
                    pen.setColor(QColor(Qt.red))

            if not imageView:
                try:
                    imageView = item.source().thumbnail()
                    pen.setColor(QColor(Qt.yellow))
                except:
                    imageView = QImage("icons:Offline.png")
                    pen.setColor(QColor(Qt.red))

            QIcon(QPixmap.fromImage(imageView)).paint(painter, r,
                                                      Qt.AlignCenter)
            painter.setPen(pen)
            painter.drawRoundedRect(r, 1, 1)
            painter.restore()
            return True

        return False

    def createEditor(self, row, column, item, view):
        """
      Create an editing widget for a custom cell
    """
        self.currentView = view

        currentColumn = self.gCustomColumnList[column]
        if currentColumn["cellType"] == "readonly":
            cle = QLabel()
            cle.setEnabled(False)
            cle.setVisible(False)
            return cle

        if currentColumn["name"] == "Colourspace":
            cb = QComboBox()
            for colourspace in self.gColourSpaces:
                cb.addItem(colourspace)
            cb.currentIndexChanged.connect(self.colourspaceChanged)
            return cb

        if currentColumn["name"] == "Shot Status":
            cb = QComboBox()
            cb.addItem("")
            for key in gStatusTags.keys():
                cb.addItem(QIcon(gStatusTags[key]), key)
            cb.addItem("--")
            cb.currentIndexChanged.connect(self.statusChanged)

            return cb

        if currentColumn["name"] == "Artist":
            cb = QComboBox()
            cb.addItem("")
            for artist in gArtistList:
                cb.addItem(artist["artistName"])
            cb.addItem("--")
            cb.currentIndexChanged.connect(self.artistNameChanged)
            return cb
        return None

    def setModelData(self, row, column, item, editor):
        return False

    def dropMimeData(self, row, column, item, data, items):
        """
      Handle a drag and drop operation - adds a Dragged Tag to the shot
    """
        for thing in items:
            if isinstance(thing, hiero.core.Tag):
                item.addTag(thing)
        return None

    def colourspaceChanged(self, index):
        """
      This method is called when Colourspace widget changes index.
    """
        index = self.sender().currentIndex()
        colourspace = self.gColourSpaces[index]
        selection = self.currentView.selection()
        project = selection[0].project()
        with project.beginUndo("Set Colourspace"):
            items = [
                item for item in selection
                if (item.mediaType() == hiero.core.TrackItem.MediaType.kVideo)
            ]
            for trackItem in items:
                trackItem.setSourceMediaColourTransform(colourspace)

    def statusChanged(self, arg):
        """
      This method is called when Shot Status widget changes index.
    """
        view = hiero.ui.activeView()
        selection = view.selection()
        status = self.sender().currentText()
        project = selection[0].project()
        with project.beginUndo("Set Status"):
            # A string of "--" characters denotes clear the status
            if status != "--":
                for trackItem in selection:
                    trackItem.setStatus(status)
            else:
                for trackItem in selection:
                    tTags = trackItem.tags()
                    for tag in tTags:
                        if tag.metadata().hasKey("tag.status"):
                            trackItem.removeTag(tag)
                            break

    def artistNameChanged(self, arg):
        """
      This method is called when Artist widget changes index.
    """
        view = hiero.ui.activeView()
        selection = view.selection()
        name = self.sender().currentText()
        project = selection[0].project()
        with project.beginUndo("Assign Artist"):
            # A string of "--" denotes clear the assignee...
            if name != "--":
                for trackItem in selection:
                    trackItem.setArtistByName(name)
            else:
                for trackItem in selection:
                    tTags = trackItem.tags()
                    for tag in tTags:
                        if tag.metadata().hasKey("tag.artistID"):
                            trackItem.removeTag(tag)
                            break

artistNameChanged(arg)

This method is called when Artist widget changes index.

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
def artistNameChanged(self, arg):
    """
  This method is called when Artist widget changes index.
"""
    view = hiero.ui.activeView()
    selection = view.selection()
    name = self.sender().currentText()
    project = selection[0].project()
    with project.beginUndo("Assign Artist"):
        # A string of "--" denotes clear the assignee...
        if name != "--":
            for trackItem in selection:
                trackItem.setArtistByName(name)
        else:
            for trackItem in selection:
                tTags = trackItem.tags()
                for tag in tTags:
                    if tag.metadata().hasKey("tag.artistID"):
                        trackItem.removeTag(tag)
                        break

colourspaceChanged(index)

This method is called when Colourspace widget changes index.

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
def colourspaceChanged(self, index):
    """
  This method is called when Colourspace widget changes index.
"""
    index = self.sender().currentIndex()
    colourspace = self.gColourSpaces[index]
    selection = self.currentView.selection()
    project = selection[0].project()
    with project.beginUndo("Set Colourspace"):
        items = [
            item for item in selection
            if (item.mediaType() == hiero.core.TrackItem.MediaType.kVideo)
        ]
        for trackItem in items:
            trackItem.setSourceMediaColourTransform(colourspace)

columnName(column)

Return the name of a custom column

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
155
156
157
158
159
def columnName(self, column):
    """
  Return the name of a custom column
"""
    return self.gCustomColumnList[column]["name"]

createEditor(row, column, item, view)

Create an editing widget for a custom cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
def createEditor(self, row, column, item, view):
    """
  Create an editing widget for a custom cell
"""
    self.currentView = view

    currentColumn = self.gCustomColumnList[column]
    if currentColumn["cellType"] == "readonly":
        cle = QLabel()
        cle.setEnabled(False)
        cle.setVisible(False)
        return cle

    if currentColumn["name"] == "Colourspace":
        cb = QComboBox()
        for colourspace in self.gColourSpaces:
            cb.addItem(colourspace)
        cb.currentIndexChanged.connect(self.colourspaceChanged)
        return cb

    if currentColumn["name"] == "Shot Status":
        cb = QComboBox()
        cb.addItem("")
        for key in gStatusTags.keys():
            cb.addItem(QIcon(gStatusTags[key]), key)
        cb.addItem("--")
        cb.currentIndexChanged.connect(self.statusChanged)

        return cb

    if currentColumn["name"] == "Artist":
        cb = QComboBox()
        cb.addItem("")
        for artist in gArtistList:
            cb.addItem(artist["artistName"])
        cb.addItem("--")
        cb.currentIndexChanged.connect(self.artistNameChanged)
        return cb
    return None

dropMimeData(row, column, item, data, items)

Handle a drag and drop operation - adds a Dragged Tag to the shot

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
448
449
450
451
452
453
454
455
def dropMimeData(self, row, column, item, data, items):
    """
  Handle a drag and drop operation - adds a Dragged Tag to the shot
"""
    for thing in items:
        if isinstance(thing, hiero.core.Tag):
            item.addTag(thing)
    return None

getBackground(row, column, item)

Return the background colour for a cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
278
279
280
281
282
283
284
def getBackground(self, row, column, item):
    """
  Return the background colour for a cell
"""
    if not item.source().mediaSource().isMediaPresent():
        return QColor(80, 20, 20)
    return None

getData(row, column, item)

Return the data in a cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
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
def getData(self, row, column, item):
    """
  Return the data in a cell
"""
    currentColumn = self.gCustomColumnList[column]
    if currentColumn["name"] == "Tags":
        return self.getTagsString(item)

    if currentColumn["name"] == "Colourspace":
        try:
            colTransform = item.sourceMediaColourTransform()
        except:
            colTransform = "--"
        return colTransform

    if currentColumn["name"] == "Notes":
        try:
            note = self.getNotes(item)
        except:
            note = ""
        return note

    if currentColumn["name"] == "FileType":
        fileType = "--"
        M = item.source().mediaSource().metadata()
        if M.hasKey("foundry.source.type"):
            fileType = M.value("foundry.source.type")
        elif M.hasKey("media.input.filereader"):
            fileType = M.value("media.input.filereader")
        return fileType

    if currentColumn["name"] == "Shot Status":
        status = item.status()
        if not status:
            status = "--"
        return str(status)

    if currentColumn["name"] == "MediaType":
        M = item.mediaType()
        return str(M).split("MediaType")[-1].replace(".k", "")

    if currentColumn["name"] == "Thumbnail":
        return str(item.eventNumber())

    if currentColumn["name"] == "Width":
        return str(item.source().format().width())

    if currentColumn["name"] == "Height":
        return str(item.source().format().height())

    if currentColumn["name"] == "Pixel Aspect":
        return str(item.source().format().pixelAspect())

    if currentColumn["name"] == "Artist":
        if item.artist():
            name = item.artist()["artistName"]
            return name
        else:
            return "--"

    if currentColumn["name"] == "Department":
        if item.artist():
            dep = item.artist()["artistDepartment"]
            return dep
        else:
            return "--"

    return ""

getFont(row, column, item)

Return the tooltip for a cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
272
273
274
275
276
def getFont(self, row, column, item):
    """
  Return the tooltip for a cell
"""
    return None

getForeground(row, column, item)

Return the text colour for a cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
286
287
288
289
290
291
292
def getForeground(self, row, column, item):
    """
  Return the text colour for a cell
"""
    #if column == 1:
    #  return QColor(255, 64, 64)
    return None

getIcon(row, column, item)

Return the icon for a cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
def getIcon(self, row, column, item):
    """
  Return the icon for a cell
"""
    currentColumn = self.gCustomColumnList[column]
    if currentColumn["name"] == "Colourspace":
        return QIcon("icons:LUT.png")

    if currentColumn["name"] == "Shot Status":
        status = item.status()
        if status:
            return QIcon(gStatusTags[status])

    if currentColumn["name"] == "MediaType":
        mediaType = item.mediaType()
        if mediaType == hiero.core.TrackItem.kVideo:
            return QIcon("icons:VideoOnly.png")
        elif mediaType == hiero.core.TrackItem.kAudio:
            return QIcon("icons:AudioOnly.png")

    if currentColumn["name"] == "Artist":
        try:
            return QIcon(item.artist()["artistIcon"])
        except:
            return None
    return None

getNotes(item)

Convenience method for returning all the Notes in a Tag as a string

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
172
173
174
175
176
177
178
179
180
181
182
def getNotes(self, item):
    """
  Convenience method for returning all the Notes in a Tag as a string
"""
    notes = ""
    tags = item.tags()
    for tag in tags:
        note = tag.note()
        if len(note) > 0:
            notes += tag.note() + ', '
    return notes[:-2]

getSizeHint(row, column, item)

Return the size hint for a cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
321
322
323
324
325
326
327
328
329
330
def getSizeHint(self, row, column, item):
    """
  Return the size hint for a cell
"""
    currentColumnName = self.gCustomColumnList[column]["name"]

    if currentColumnName == "Thumbnail":
        return QSize(90, 50)

    return QSize(50, 50)

getTagsString(item)

Convenience method for returning all the Notes in a Tag as a string

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
161
162
163
164
165
166
167
168
169
170
def getTagsString(self, item):
    """
  Convenience method for returning all the Notes in a Tag as a string
"""
    tagNames = []
    tags = item.tags()
    for tag in tags:
        tagNames += [tag.name()]
    tagNameString = ','.join(tagNames)
    return tagNameString

getTooltip(row, column, item)

Return the tooltip for a cell

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
260
261
262
263
264
265
266
267
268
269
270
def getTooltip(self, row, column, item):
    """
  Return the tooltip for a cell
"""
    currentColumn = self.gCustomColumnList[column]
    if currentColumn["name"] == "Tags":
        return str([item.name() for item in item.tags()])

    if currentColumn["name"] == "Notes":
        return str(self.getNotes(item))
    return ""

numColumns()

Return the number of custom columns in the spreadsheet view

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
149
150
151
152
153
def numColumns(self):
    """
  Return the number of custom columns in the spreadsheet view
"""
    return len(self.gCustomColumnList)

paintCell(row, column, item, painter, option)

Paint a custom cell. Return True if the cell was painted, or False to continue with the default cell painting.

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
def paintCell(self, row, column, item, painter, option):
    """
  Paint a custom cell. Return True if the cell was painted, or False to continue
  with the default cell painting.
"""
    currentColumn = self.gCustomColumnList[column]
    if currentColumn["name"] == "Tags":
        if option.state & QStyle.State_Selected:
            painter.fillRect(option.rect, option.palette.highlight())
        iconSize = 20
        r = QRect(option.rect.x(),
                  option.rect.y() + (option.rect.height() - iconSize) / 2,
                  iconSize, iconSize)
        tags = item.tags()
        if len(tags) > 0:
            painter.save()
            painter.setClipRect(option.rect)
            for tag in item.tags():
                M = tag.metadata()
                if not (M.hasKey("tag.status")
                        or M.hasKey("tag.artistID")):
                    QIcon(tag.icon()).paint(painter, r, Qt.AlignLeft)
                    r.translate(r.width() + 2, 0)
            painter.restore()
            return True

    if currentColumn["name"] == "Thumbnail":
        imageView = None
        pen = QPen()
        r = QRect(option.rect.x() + 2, (option.rect.y() +
                                        (option.rect.height() - 46) / 2),
                  85, 46)
        if not item.source().mediaSource().isMediaPresent():
            imageView = QImage("icons:Offline.png")
            pen.setColor(QColor(Qt.red))

        if item.mediaType() == hiero.core.TrackItem.MediaType.kAudio:
            imageView = QImage("icons:AudioOnly.png")
            #pen.setColor(QColor(Qt.green))
            painter.fillRect(r, QColor(45, 59, 45))

        if option.state & QStyle.State_Selected:
            painter.fillRect(option.rect, option.palette.highlight())

        tags = item.tags()
        painter.save()
        painter.setClipRect(option.rect)

        if not imageView:
            try:
                imageView = item.thumbnail(item.sourceIn())
                pen.setColor(QColor(20, 20, 20))
            # If we're here, we probably have a TC error, no thumbnail, so get it from the source Clip...
            except:
                pen.setColor(QColor(Qt.red))

        if not imageView:
            try:
                imageView = item.source().thumbnail()
                pen.setColor(QColor(Qt.yellow))
            except:
                imageView = QImage("icons:Offline.png")
                pen.setColor(QColor(Qt.red))

        QIcon(QPixmap.fromImage(imageView)).paint(painter, r,
                                                  Qt.AlignCenter)
        painter.setPen(pen)
        painter.drawRoundedRect(r, 1, 1)
        painter.restore()
        return True

    return False

setData(row, column, item, data)

Set the data in a cell - unused in this example

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
253
254
255
256
257
258
def setData(self, row, column, item, data):
    """
  Set the data in a cell - unused in this example
"""

    return None

statusChanged(arg)

This method is called when Shot Status widget changes index.

Source code in client/ayon_hiero/api/startup/Python/StartupUI/PimpMySpreadsheet.py
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
def statusChanged(self, arg):
    """
  This method is called when Shot Status widget changes index.
"""
    view = hiero.ui.activeView()
    selection = view.selection()
    status = self.sender().currentText()
    project = selection[0].project()
    with project.beginUndo("Set Status"):
        # A string of "--" characters denotes clear the status
        if status != "--":
            for trackItem in selection:
                trackItem.setStatus(status)
        else:
            for trackItem in selection:
                tTags = trackItem.tags()
                for tag in tTags:
                    if tag.metadata().hasKey("tag.status"):
                        trackItem.removeTag(tag)
                        break