コード例 #1
0
    def _setup_defaults(self):
        """setting up the defaults
        """
        # fill the asset_types_comboBox with all the asset types from the db
        all_types = map(lambda x: x[0], db.query(distinct(Asset.type)).all())

        if conf.default_asset_type_name not in all_types:
            all_types.append(conf.default_asset_type_name)

        logger.debug('all_types: %s' % all_types)

        self.asset_types_comboBox.addItems(all_types)
コード例 #2
0
    def _setup_defaults(self):
        """setting up the defaults
        """
        # fill the asset_types_comboBox with all the asset types from the db
        all_types = map(lambda x: x[0], db.query(distinct(Asset.type)).all())

        if conf.default_asset_type_name not in all_types:
            all_types.append(conf.default_asset_type_name)
        
        logger.debug('all_types: %s' % all_types)
         
        self.asset_types_comboBox.addItems(all_types)
コード例 #3
0
    def test_another_class_mixed_in_with_IOMixin(self):
        """testing if everything works properly if more than one class is mixed
        in with the IOMixin
        """
        db.setup()
        new_io_mixed_in_obj2 = IOMixedInClass2(**self.kwargs)
        db.session.add(self.test_io_mixed_in_obj)
        db.session.add(new_io_mixed_in_obj2)
        db.session.commit()

        # delete them and retrieve back from DB
        del new_io_mixed_in_obj2
        del self.test_io_mixed_in_obj

        a = db.query(IOMixedInClass).first()
        b = db.query(IOMixedInClass2).first()

        self.assertEqual(a.inputs, self.kwargs['inputs'])
        self.assertEqual(a.outputs, self.kwargs['outputs'])

        self.assertEqual(b.inputs, self.kwargs['inputs'])
        self.assertEqual(b.outputs, self.kwargs['outputs'])
コード例 #4
0
 def test_another_class_mixed_in_with_IOMixin(self):
     """testing if everything works properly if more than one class is mixed
     in with the IOMixin
     """
     db.setup()
     new_io_mixed_in_obj2 = IOMixedInClass2(**self.kwargs)
     db.session.add(self.test_io_mixed_in_obj)
     db.session.add(new_io_mixed_in_obj2)
     db.session.commit()
     
     # delete them and retrieve back from DB
     del new_io_mixed_in_obj2
     del self.test_io_mixed_in_obj
     
     a = db.query(IOMixedInClass).first()
     b = db.query(IOMixedInClass2).first()
     
     self.assertEqual(a.inputs, self.kwargs['inputs'])
     self.assertEqual(a.outputs, self.kwargs['outputs'])
     
     self.assertEqual(b.inputs, self.kwargs['inputs'])
     self.assertEqual(b.outputs, self.kwargs['outputs'])
コード例 #5
0
 def fill_shots_tableWidget(self):
     """fills the shots_tableWidget
     """
     
     # TODO: merge cells of the same shot, or at least paint them in some other color
     
     # clear the tableWidget
     self.shots_tableWidget.clear()
     
     shot_vtypes = VersionType.query()\
         .filter(VersionType.type_for=='Shot')\
         .order_by(VersionType.name)\
         .all()
     
     shot_vtype_codes = map(lambda x: x.code, shot_vtypes)
     
     labels = ['Thumbnail', 'Sequence', 'Number', 'Take']
     labels.extend(map(lambda x: x.code, shot_vtypes))
     
     #logger.debug('shot_tableWidget.labels: %s' % labels)
     
     self.shots_tableWidget.setColumnCount(len(labels))
     self.shots_tableWidget.setHorizontalHeaderLabels(labels)
     
     # get the project
     project = self.get_current_project()
     
     if project is None:
         return
     
     # get all the shots for the sequence
     sequences = Sequence.query()\
         .filter(Sequence.project==project)\
         .order_by(Sequence.name)\
         .all()
     
     shot_count = db.query(func.count(Shot.id))\
         .join(Sequence)\
         .filter(Sequence.id==Shot.sequence_id)\
         .filter(Sequence.project==project)\
         .all()[0][0]
     
     # set the row count for all shots in that sequence
     self.shots_tableWidget.setRowCount(shot_count)
     
     items = []
     row = 0
     column = 0
     for sequence in sequences:    
         shots = Shot.query()\
             .filter(Shot.sequence==sequence)\
             .order_by(Shot.number)\
             .all()
         
         # sort according to numbers
         shots.sort(key=lambda x: utils.embedded_numbers(x.number))
         
         #logger.debug('shots of sequence %s is %s' % (sequence.name, shots))
         
         # feed the shots to the list
         
         previous_shot = None
         for shot in shots:
             take_names = map(
                 lambda x: x[0],
                 db.query(distinct(Version.take_name))
                     .filter(Version.version_of==shot)
                     .all()
             )
             
             if not len(take_names):
                 take_names = ['-']
             
             for take_name in take_names:
                 # add the seq name to the first column
                 column = 0
                 item = QtGui.QTableWidgetItem()
                 item.setTextAlignment(0x0004 | 0x0080)
                 #set the thumbnail
                 if os.path.exists(shot.thumbnail_full_path):
                     thumbnail_full_path = shot.thumbnail_full_path
                     pixmap = QtGui.QPixmap(thumbnail_full_path)
                     pixmap = pixmap.scaled(
                         conf.thumbnail_size[0] / 2,
                         conf.thumbnail_size[1] / 2,
                         QtCore.Qt.KeepAspectRatio,
                         QtCore.Qt.SmoothTransformation
                     )
                     brush = QtGui.QBrush(pixmap)
                     item.has_thumbnail = True
                     item.setBackground(brush)
                 else:
                     item.has_thumbnail = False
                 items.append(item)
                 
                 column = 1
                 item = QtGui.QTableWidgetItem(sequence.name)
                 item.setTextAlignment(0x0004 | 0x0080)
                 #self.shots_tableWidget.setItem(row, column, item)
                 items.append(item)
                 
                 # add the shot code to the second column
                 column = 2
                 item = QtGui.QTableWidgetItem(shot.code)
                 item.setTextAlignment(0x0004 | 0x0080)
                 #self.shots_tableWidget.setItem(row, column, item)
                 items.append(item)
                 
                 # add the take name to the third column
                 column = 3
                 item = QtGui.QTableWidgetItem(take_name)
                 item.setTextAlignment(0x0004 | 0x0080)
                 #self.assets_tableWidget.setItem(row, column, item)
                 items.append(item)
             
                 for type_code in shot_vtype_codes:
                     column += 1
                     
                     # get the latest version of that type and take
                     version = Version.query()\
                         .join(VersionType)\
                         .filter(Version.version_of==shot)\
                         .filter(Version.type_id==VersionType.id)\
                         .filter(VersionType.code==type_code)\
                         .filter(Version.take_name==take_name)\
                         .order_by(Version.version_number.desc())\
                         .first()
                     
                     if version:
                         # mark the status of that type in that take
                         item = QtGui.QTableWidgetItem(
                             version.status + '\n' + version.created_by.name
                         )
                         item.setTextAlignment(0x0004 | 0x0080)
                         
                         # set the color according to status
                         index = conf.status_list.index(version.status)
                         bgcolor = conf.status_bg_colors[index]
                         fgcolor = conf.status_fg_colors[index]
                         
                         bg = item.background()
                         bg.setColor(QtGui.QColor(*bgcolor))
                         item.setBackground(bg)
                         
                         fg = item.foreground()
                         fg.setColor(QtGui.QColor(*fgcolor))
                         item.setForeground(fg)
                         
                         try:
                             item.setBackgroundColor(QtGui.QColor(*bgcolor))
                         except AttributeError: # for PySide
                             pass
                         
                         # set this version to the item
                         item.version = version
                         
                     else:
                         # set the background color to black
                         item = QtGui.QTableWidgetItem('-')
                         item.setTextAlignment(0x0004 | 0x0080)
                         bg = item.background()
                         bg.setColor(QtGui.QColor(0, 0, 0))
                         item.setBackground(bg)
                         
                         try:
                             item.setBackgroundColor(QtGui.QColor(0, 0, 0))
                         except AttributeError: # for PySide
                             pass
                         
                         # set the version to None for this item
                         item.version = None
                     
                     items.append(item)
                 
                 row += 1
     
     self.shots_tableWidget.setRowCount(row)
     
     item_index = 0
     for r in range(row):
         for c in range(column + 1):
             item = items[item_index]
             self.shots_tableWidget.setItem(r, c, item)
             item_index += 1
     
     # adjust the row heights accordingly
     self.shots_tableWidget.resizeRowsToContents()
     
     # need to pass over the first rows again
     # to resize the thumbnail cell
     for r in range(row):
         item_index = r * (column + 1)
         item = items[item_index]
         if item.has_thumbnail:
             # scale the row height
             self.shots_tableWidget.setRowHeight(
                 r,
                 conf.thumbnail_size[1] / 2
             )
     
     # resize columns to fit the content
     self.shots_tableWidget.resizeColumnsToContents()
     
     # set the column width
     self.shots_tableWidget.setColumnWidth(0, conf.thumbnail_size[0] / 2)
コード例 #6
0
 def fill_assets_tableWidget(self):
     """fills the asset_tableWidget
     """
     # clear the table
     self.assets_tableWidget.clear()
     
     asset_vtypes = VersionType.query()\
         .filter(VersionType.type_for=='Asset')\
         .order_by(VersionType.name)\
         .all()
     
     asset_vtype_codes = map(lambda x: x.code, asset_vtypes)
     
     labels = ['Thumbnail', 'Type', 'Name', 'Take']
     labels.extend(map(lambda x: x.code, asset_vtypes))
     
     logger.debug('asset_tableWidget.labels: %s' % labels)
     
     self.assets_tableWidget.setColumnCount(len(labels))
     self.assets_tableWidget.setHorizontalHeaderLabels(labels)
     
     # get the project
     project = self.get_current_project()
     
     if project is None:
         return
     
     # get all the assets for the project
     assets = Asset.query()\
         .filter(Asset.project==project)\
         .order_by(Asset.type)\
         .all()
     
     # feed the assets to the list
     items = []
     
     row = 0
     column = 0
     for asset in assets:
        # get the distinct take names
         take_names = map(
             lambda x: x[0],
             db.query(distinct(Version.take_name))
                 .filter(Version.version_of==asset)
                 .all()
         )
         
         if not len(take_names):
             take_names = ['-']
         
         for take_name in take_names:
             
             # add the asset type to the first column
             column = 0
             item = QtGui.QTableWidgetItem()
             item.setTextAlignment(0x0004 | 0x0080)
             # set the thumbnail
             if os.path.exists(asset.thumbnail_full_path):
                 thumbnail_full_path = asset.thumbnail_full_path
                 pixmap = QtGui.QPixmap(thumbnail_full_path)
                 pixmap = pixmap.scaled(
                     conf.thumbnail_size[0] / 2,
                     conf.thumbnail_size[1] / 2,
                     QtCore.Qt.KeepAspectRatio,
                     QtCore.Qt.SmoothTransformation
                 )
                 brush = QtGui.QBrush(pixmap)
                 item.has_thumbnail = True
                 item.setBackground(brush)
             else:
                 item.has_thumbnail = False
             items.append(item)
             
             column = 1
             item = QtGui.QTableWidgetItem(asset.type)
             item.setTextAlignment(0x0004 | 0x0080)
             items.append(item)
             
             # add the asset name to the second column
             column = 2
             item = QtGui.QTableWidgetItem(asset.name)
             item.setTextAlignment(0x0004 | 0x0080)
             items.append(item)
             
             # add the take name to the third column
             column = 3
             item = QtGui.QTableWidgetItem(take_name)
             item.setTextAlignment(0x0004 | 0x0080)
             #self.assets_tableWidget.setItem(row, column, item)
             items.append(item)
             
             for type_code in asset_vtype_codes:
                 column += 1
                 
                 # now for every asset vtype create two rows instead of one
                 # and show the users name on the second row
                 
                 # get the latest version of that type and take
                 version = Version.query()\
                     .join(VersionType)\
                     .filter(Version.version_of==asset)\
                     .filter(Version.type_id==VersionType.id)\
                     .filter(VersionType.code==type_code)\
                     .filter(Version.take_name==take_name)\
                     .order_by(Version.version_number.desc())\
                     .first()
                 
                 if version:
                     # mark the status of that type in that take
                     item = QtGui.QTableWidgetItem(
                         version.status + '\n' + version.created_by.name
                     )
                     item.setTextAlignment(0x0004 | 0x0080)
                     
                     # set the color according to status
                     index = conf.status_list.index(version.status)
                     bgcolor = conf.status_bg_colors[index]
                     fgcolor = conf.status_fg_colors[index]
                     
                     bg = item.background()
                     bg.setColor(QtGui.QColor(*bgcolor))
                     item.setBackground(bg)
                     
                     fg = item.foreground()
                     fg.setColor(QtGui.QColor(*fgcolor))
                     item.setForeground(fg)
                     
                     try:
                         item.setBackgroundColor(QtGui.QColor(*bgcolor))
                     except AttributeError: # gives errpor with PySide
                         pass
                     
                     # add this version to the item
                     item.version = version
                     
                 else:
                     # set the background color to black
                     item = QtGui.QTableWidgetItem('-')
                     item.setTextAlignment(0x0004 | 0x0080)
                     bg = item.background()
                     bg.setColor(QtGui.QColor(0, 0, 0))
                     item.setBackground(bg)
                     
                     try:
                         item.setBackgroundColor(QtGui.QColor(0, 0, 0))
                     except AttributeError: # gives error with PySide
                         pass
                     
                     # set the related version to None
                     item.version = None
                 
                 items.append(item)
                 
             row += 1
     
     self.assets_tableWidget.setRowCount(row)
     
     item_index = 0
     for r in range(row):
         for c in range(column + 1):
             item = items[item_index]
             self.assets_tableWidget.setItem(r, c, item)
             item_index += 1
     
     # adjust the row heights accordingly
     self.assets_tableWidget.resizeRowsToContents()
     
     # need to pass over the first rows again
     # to resize the thumbnail cell
     for r in range(row):
         item_index = r * (column + 1)
         item = items[item_index]
         if item.has_thumbnail:
             # scale the row height
             self.assets_tableWidget.setRowHeight(
                 r,
                 conf.thumbnail_size[1] / 2
             )
     
     # resize columns to fit the content
     self.assets_tableWidget.resizeColumnsToContents()
     
     # set column width
     self.assets_tableWidget.setColumnWidth(0, conf.thumbnail_size[0] / 2)
コード例 #7
0
 def query(cls):
     from oyProjectManager.db import query
     return query(cls)
コード例 #8
0
 def query(cls):
     from oyProjectManager.db import query
     return query(cls)