예제 #1
0
    def setRecord(self, record):
        """
        :type record: Record
        """
        self._record = record

        if hasattr(self.ui, 'name'):
            self.ui.name.setText(record.name())

        if hasattr(self.ui, 'owner'):
            self.ui.owner.setText(str(record.owner()))

        if hasattr(self.ui, 'comment'):
            if isinstance(self.ui.comment, QtGui.QLabel):
                self.ui.comment.setText(record.description())
            else:
                self.ui.comment.setPlainText(record.description())

        if hasattr(self.ui, "contains"):
            self.updateContains()

        if hasattr(self.ui, 'snapshotButton'):
            path = record.iconPath()
            if os.path.exists(path):
                self.setIconPath(record.iconPath())

        ctime = record.ctime()
        if hasattr(self.ui, 'created') and ctime:
            self.ui.created.setText(studiolibrary.timeAgo(str(ctime)))
예제 #2
0
    def setPath(self, path):
        """
        Set the path location on disc for the item.

        :type path: str
        :rtype: None
        """
        if not path:
            raise ItemError('Cannot set an empty item path.')

        path = studiolibrary.normPath(path)

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setName(name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        self.setText("Type", extension)
예제 #3
0
    def updateData(self):
        """
        Update the data when the item is created or when a new path is set.
        
        :rtype: None 
        """
        path = self.path()

        dirname, basename, extension = studiolibrary.splitPath(path)

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setName(name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        self.setText("Type", extension)
    def setRecord(self, record):
        """
        :type record: Record
        """
        self._record = record

        if hasattr(self.ui, 'name'):
            self.ui.name.setText(record.name())

        if hasattr(self.ui, 'owner'):
            self.ui.owner.setText(str(record.owner()))

        if hasattr(self.ui, 'comment'):
            if isinstance(self.ui.comment, QtGui.QLabel):
                self.ui.comment.setText(record.description())
            else:
                self.ui.comment.setPlainText(record.description())

        if hasattr(self.ui, "contains"):
            self.updateContains()

        if hasattr(self.ui, 'snapshotButton'):
            path = record.iconPath()
            if os.path.exists(path):
                self.setIconPath(record.iconPath())

        ctime = record.ctime()
        if hasattr(self.ui, 'created') and ctime:
            self.ui.created.setText(studiolibrary.timeAgo(str(ctime)))
예제 #5
0
    def __init__(self, record, libraryWidget=None):
        """
        :type record: Record
        :type libraryWidget: studiolibrary.LibraryWidget
        """
        QtGui.QWidget.__init__(self, None)
        studiolibrary.loadUi(self)

        self._scriptJob = None
        self._record = record
        self._iconPath = ""
        self._libraryWidget = libraryWidget

        self.loadSettings()

        if studiolibrary.isPySide():
            self.layout().setContentsMargins(0, 0, 0, 0)

        if hasattr(self.ui, 'title'):
            self.ui.title.setText(self.record().plugin().name())

        if hasattr(self.ui, 'name'):
            self.ui.name.setText(self.record().name())

        if hasattr(self.ui, 'owner'):
            self.ui.owner.setText(str(self.record().owner()))

        if hasattr(self.ui, 'comment'):
            if isinstance(self.ui.comment, QtGui.QLabel):
                self.ui.comment.setText(self.record().description())
            else:
                self.ui.comment.setPlainText(self.record().description())

        if hasattr(self.ui, "contains"):
            self.updateContains()

        if hasattr(self.ui, 'snapshotButton'):
            path = self.record().iconPath()
            if os.path.exists(path):
                self.setIconPath(self.record().iconPath())

        ctime = self.record().ctime()
        if hasattr(self.ui, 'created') and ctime:
            self.ui.created.setText(studiolibrary.timeAgo(str(ctime)))

        try:
            self.selectionChanged()
            self._scriptJob = mutils.ScriptJob(e=['SelectionChanged', self.selectionChanged])
        except NameError:
            import traceback
            traceback.print_exc()
예제 #6
0
    def __init__(self, parent=None, record=None):
        """
        @param parent: QtGui.QWidget
        @param record:
        """
        QtGui.QWidget.__init__(self, parent)
        studiolibrary.loadUi(self)

        self._record = record
        self.loadSettings()

        if studiolibrary.isPySide():
            self.layout().setContentsMargins(0, 0, 0, 0)

        if hasattr(self.ui, 'title'):
            self.ui.title.setText(self.record().plugin().name())

        if hasattr(self.ui, 'name'):
            self.ui.name.setText(self.record().name())

        if hasattr(self.ui, 'owner'):
            self.ui.owner.setText(str(self.record().owner()))

        if hasattr(self.ui, 'comment'):
            if isinstance(self.ui.comment, QtGui.QLabel):
                self.ui.comment.setText(self.record().description())
            else:
                self.ui.comment.setPlainText(self.record().description())

        if hasattr(self.ui, "contains"):
            self.updateContains()

        if hasattr(self.ui, 'snapshotButton'):
            self.setSnapshot(self.record().icon())

        ctime = self.record().ctime()
        if hasattr(self.ui, 'created') and ctime:
            self.ui.created.setText(studiolibrary.timeAgo(str(ctime)))

        try:
            self._scriptJob = None
            self._scriptJob = mutils.ScriptJob(
                e=['SelectionChanged', self.selectionChanged])
            self.selectionChanged()
        except NameError:
            import traceback
            traceback.print_exc()
예제 #7
0
    def setItem(self, item):
        """
        Set the item for the preview widget.

        :type item: BaseItem
        """
        self._item = item

        self.ui.name.setText(item.name())
        self.ui.owner.setText(item.owner())
        self.ui.comment.setText(item.description())

        self.updateContains()

        ctime = item.ctime()
        if ctime:
            self.ui.created.setText(studiolibrary.timeAgo(ctime))
    def __init__(self, parent=None, record=None):
        """
        @param parent: QtGui.QWidget
        @param record:
        """
        QtGui.QWidget.__init__(self, parent)
        studiolibrary.loadUi(self)

        self._record = record
        self.loadSettings()

        if studiolibrary.isPySide():
            self.layout().setContentsMargins(0, 0, 0, 0)

        if hasattr(self.ui, 'title'):
            self.ui.title.setText(self.record().plugin().name())

        if hasattr(self.ui, 'name'):
            self.ui.name.setText(self.record().name())

        if hasattr(self.ui, 'owner'):
            self.ui.owner.setText(str(self.record().owner()))

        if hasattr(self.ui, 'comment'):
            if isinstance(self.ui.comment, QtGui.QLabel):
                self.ui.comment.setText(self.record().description())
            else:
                self.ui.comment.setPlainText(self.record().description())

        if hasattr(self.ui, "contains"):
            self.updateContains()

        if hasattr(self.ui, 'snapshotButton'):
            self.setSnapshot(self.record().icon())

        ctime = self.record().ctime()
        if hasattr(self.ui, 'created') and ctime:
            self.ui.created.setText(studiolibrary.timeAgo(str(ctime)))

        try:
            self._scriptJob = None
            self._scriptJob = mutils.ScriptJob(e=['SelectionChanged', self.selectionChanged])
            self.selectionChanged()
        except NameError:
            import traceback
            traceback.print_exc()
예제 #9
0
    def setPath(self, path):
        """
        :type path: str
        :rtype: None
        """
        if not path:
            raise RecordError('Cannot set empty record path.')

        plugin = self.plugin()

        dirname, basename, extension = studiolibrary.splitPath(path)

        iconPath = path + "/thumbnail.jpg"

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setIconPath(iconPath)
        self.setText("Icon", name)
        self.setText("Name", name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        if extension:
            if plugin:
                if extension != plugin.extension():
                    path += plugin.extension()
        else:
            if plugin:
                path += plugin.extension()
            else:
                raise RecordSaveError('No extension found!')

        if plugin:
            self.setText("Type", plugin.extension())

        studiolibrary.BasePath.setPath(self, path)
예제 #10
0
    def setPath(self, path):
        """
        :type path: str
        :rtype: None
        """
        if not path:
            raise RecordError('Cannot set empty record path.')

        plugin = self.plugin()

        dirname, basename, extension = studiolibrary.splitPath(path)

        iconPath = path + "/thumbnail.jpg"

        name = os.path.basename(path)
        category = os.path.basename(dirname)

        self.setIconPath(iconPath)
        self.setText("Icon", name)
        self.setText("Name", name)
        self.setText("Path", path)
        self.setText("Category", category)

        if os.path.exists(path):
            modified = os.path.getmtime(path)
            timeAgo = studiolibrary.timeAgo(modified)

            self.setText("Modified", timeAgo)
            self.setSortText("Modified", str(modified))

        if extension:
            if plugin:
                if extension != plugin.extension():
                    path += plugin.extension()
        else:
            if plugin:
                path += plugin.extension()
            else:
                raise RecordSaveError('No extension found!')

        if plugin:
            self.setText("Type", plugin.extension())

        studiolibrary.BasePath.setPath(self, path)
예제 #11
0
    def info(self):
        """
        Get the info to display to user.

        :rtype: list[dict]
        """
        ctime = self.ctime()
        if ctime:
            ctime = studiolibrary.timeAgo(ctime)

        count = self.transferObject().objectCount()
        plural = "s" if count > 1 else ""
        contains = str(count) + " Object" + plural

        return [
            {
                "name": "infoGroup",
                "title": "Info",
                "type": "group",
            },
            {
                "name": "name",
                "value": self.name(),
            },
            {
                "name": "owner",
                "value": self.transferObject().owner(),
            },
            {
                "name": "created",
                "value": ctime,
            },
            {
                "name": "contains",
                "value": contains,
            },
            {
                "name": "comment",
                "value": self.transferObject().description() or "No comment",
            },
        ]
예제 #12
0
    def setItem(self, item):
        """
        :type item: BaseItem
        """
        self._item = item

        if hasattr(self.ui, 'name'):
            self.ui.name.setText(item.name())

        if hasattr(self.ui, 'owner'):
            self.ui.owner.setText(item.owner())

        if hasattr(self.ui, 'comment'):
            if isinstance(self.ui.comment, QtWidgets.QLabel):
                self.ui.comment.setText(item.description())
            else:
                self.ui.comment.setPlainText(item.description())

        if hasattr(self.ui, "contains"):
            self.updateContains()

        ctime = item.ctime()
        if hasattr(self.ui, 'created') and ctime:
            self.ui.created.setText(studiolibrary.timeAgo(ctime))
예제 #13
0
    def info(self):
        """
        Get the info to display to user.
        
        :rtype: list[dict]
        """
        ctime = self.ctime()
        if ctime:
            ctime = studiolibrary.timeAgo(ctime)

        count = self.objectCount()
        plural = "s" if count > 1 else ""
        contains = str(count) + " Object" + plural

        return [
            {
                "name": "name",
                "value": self.name(),
            },
            {
                "name": "owner",
                "value": self.owner(),
            },
            {
                "name": "created",
                "value": ctime,
            },
            {
                "name": "contains",
                "value": contains,
            },
            {
                "name": "comment",
                "value": self.description() or "No comment",
            },
        ]
예제 #14
0
    def loadSchema(self):
        """
        Get schema used to load the item.

        :rtype: list[dict]
        """
        modified = self.itemData().get("modified")
        if modified:
            modified = studiolibrary.timeAgo(modified)

        count = self.transferObject().objectCount()
        plural = "s" if count > 1 else ""
        contains = str(count) + " Object" + plural

        return [
            {
                "name": "infoGroup",
                "title": "Info",
                "type": "group",
                "order": 1,
            },
            {
                "name": "name",
                "value": self.name(),
            },
            {
                "name": "owner",
                "value": self.transferObject().owner(),
            },
            {
                "name": "created",
                "value": modified,
            },
            {
                "name": "contains",
                "value": contains,
            },
            {
                "name": "comment",
                "value": self.transferObject().description() or "No comment",
            },
            {
                "name": "namespaceGroup",
                "title": "Namespace",
                "type": "group",
                "order": 10,
            },
            {
                "name": "namespaceOption",
                "title": "",
                "type": "radio",
                "value": "From file",
                "items": ["From file", "From selection", "Use custom"],
                "persistent": True,
                "persistentKey": "BaseItem",
            },
            {
                "name": "namespaces",
                "title": "",
                "type": "tags",
                "value": [],
                "items": mutils.namespace.getAll(),
                "persistent": True,
                "label": {
                    "visible": False
                },
                "persistentKey": "BaseItem",
            },
        ]