mirror of
https://github.com/wassname/sloth.git
synced 2026-07-19 11:28:06 +08:00
Add functions to set/unset unlabeled and unconfirmed properties
This commit is contained in:
@@ -259,9 +259,25 @@ class KeyValueModelItem(ModelItem, MutableMapping):
|
||||
def isUnlabeled(self):
|
||||
return 'unlabeled' in self._dict and self._dict['unlabeled']
|
||||
|
||||
def setUnlabeled(self, val):
|
||||
if val:
|
||||
self._dict['unlabeled'] = val
|
||||
else:
|
||||
if 'unlabeled' in self._dict:
|
||||
del self['unlabeled']
|
||||
self._emitDataChanged('unlabeled')
|
||||
|
||||
def isUnconfirmed(self):
|
||||
return 'unconfirmed' in self._dict and self._dict['unconfirmed']
|
||||
|
||||
def setUnconfirmed(self, val):
|
||||
if val:
|
||||
self._dict['unconfirmed'] = val
|
||||
else:
|
||||
if 'unconfirmed' in self._dict:
|
||||
del self['unconfirmed']
|
||||
self._emitDataChanged('unconfirmed')
|
||||
|
||||
class FileModelItem(KeyValueModelItem):
|
||||
def __init__(self, fileinfo, hidden=['filename']):
|
||||
KeyValueModelItem.__init__(self, hidden=hidden, properties=fileinfo)
|
||||
@@ -295,6 +311,15 @@ class ImageModelItem(ModelItem):
|
||||
def addAnnotation(self, ann):
|
||||
self.appendChild(AnnotationModelItem(ann))
|
||||
|
||||
def annotations(self):
|
||||
for child in self._children:
|
||||
if isinstance(child, AnnotationModelItem):
|
||||
yield child
|
||||
|
||||
def confirmAll(self):
|
||||
for ann in self.annotations():
|
||||
ann.setUnconfirmed(False)
|
||||
|
||||
class ImageFileModelItem(FileModelItem, ImageModelItem):
|
||||
def __init__(self, fileinfo):
|
||||
annotations = fileinfo.get("annotations", [])
|
||||
|
||||
Reference in New Issue
Block a user