Ejemplo n.º 1
0
class ElementList(QtGui.QListWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()       
        
    def initUI(self):
        #define gui elements
        self.refreshList('Asset')
            
    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        else:
            self.elements = self.project.list_shots()
            
        self.clear()
        for e in self.elements:
            self.addItem(e)

    def setElement(self, element):
        for idx in xrange(self.count()):
            eItem = self.item(idx)
            if str(eItem.text())==element:
                self.setCurrentRow(idx)
                break
Ejemplo n.º 2
0
class AssetListWindow(QtGui.QListWidget):
    def __init__(self, parent):
        super(AssetListWindow, self).__init__()
        self.parent = parent
        self.current_selection = None
        self.project = Project()
        self.initUI()
        
    def initUI(self):
        self.currentItemChanged.connect(self.set_current_item)
        
    def set_current_item(self, index):
        self.current_selection = str(index.text())
        body = self.project.get_body(self.current_selection)
        element = body.get_element(str(self.parent.departmentMenu.currentText()))
        path = element.get_app_filepath()
        self.parent.filePath = path
        
    def refreshList(self, department):
        if department in Department.FRONTEND:
            asset_filter = None
            if(self.typeFilter.currentIndex()):
                asset_filter_str = str(self.typeFilter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.elements = self.project.list_assets(asset_filter)
        else:
            self.elements = self.project.list_shots()
		    
        self.clear()
        for e in self.elements:
		    self.addItem(e)
Ejemplo n.º 3
0
class ElementList(QtGui.QListWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()       
        
    def initUI(self):
        #define gui elements
        self.refreshList('Asset')
            
    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        else:
            self.elements = self.project.list_shots()
            
        self.clear()
        for e in self.elements:
            self.addItem(e)

    def setElement(self, element):
        for idx in xrange(self.count()):
            eItem = self.item(idx)
            if str(eItem.text())==element:
                self.setCurrentRow(idx)
                break
Ejemplo n.º 4
0
class ElementList(QtWidgets.QListWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()

    def initUI(self):
        #define gui elements
        self.refreshList('Asset')

    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        elif element == 'Shot':
            self.elements = self.project.list_shots()
        elif element == 'Tool':
            self.elements = self.project.list_tools()
        elif element == 'CrowdCycle':
            self.elements = self.project.list_crowd_cycles()
        else:
            self.elements = list()
            message_gui.error(
                'There was a problem loading in the elements from of ' +
                str(element) + ' type.')
        self.clear()
        for e in self.elements:
            self.addItem(e)

    def setElement(self, element):
        for idx in xrange(self.count()):
            eItem = self.item(idx)
            if str(eItem.text()) == element:
                self.setCurrentRow(idx)
                break
Ejemplo n.º 5
0
class CheckoutWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)

    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtGui.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        #create tabs
        for dept in dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtGui.QHBoxLayout()
            element_list = QtGui.QListWidget()
            commentBox = QtGui.QTextEdit()
            commentBox.setReadOnly(True)
            tab.commentBox = commentBox

            if dept in Department.FRONTEND:
                for asset in self.project.list_assets():
                    item = QtGui.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            elif dept in Department.BACKEND:
                for shot in self.project.list_shots():
                    item = QtGui.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            tab_layout.addWidget(element_list)
            tab_layout.addWidget(commentBox)
            tab.setLayout(tab_layout)

        #create buttons
        self.checkout_button = QtGui.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtGui.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtGui.QHBoxLayout()
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtGui.QLabel()
        pixmap = QtGui.QPixmap(os.environ['BYU_TOOLS_DIR'] +
                               '/byugui/assets/images/taijitu.jpg')
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtGui.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)

        self.show()

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.FRONTEND:
            self.current_item = str(index.text())
        elif current_dept in Department.BACKEND:
            self.current_item = str(index.text())

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = "No publishes for this element"
        currentTab = self.dept_tabs.currentWidget()
        currentTab.commentBox.setText(last_publish_comment)

    def checkout(self):
        """
        Checks out the currently selected item
        :return:
        """
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            self.result = element_path
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Ejemplo n.º 6
0
class ElementBrowser(QtGui.QWidget):

    ASSETS = "Assets"
    SHOTS = "Shots"

    BODY_DATA_COLUMN = 1
    BODY_DESCRIPTION_COLUMN = 7

    @staticmethod
    def dark_palette():
        palette = QtGui.QPalette()
        base_color = QtGui.QColor(39,39,39)
        alt_color = QtGui.QColor(30,30,30)
        text_color = QtGui.QColor(192,192,192)
        highlight_color = QtGui.QColor(57,86,115)
        highlight_text_color = QtCore.Qt.white
        disabled_alt_color = QtGui.QColor(49,49,49)
        disabled_base_color = QtGui.QColor(40,40,40)
        disabled_text_color = QtGui.QColor(100,100,100)
        palette.setColor(QtGui.QPalette.Window, base_color)
        palette.setColor(QtGui.QPalette.WindowText, text_color)
        palette.setColor(QtGui.QPalette.Base, base_color)
        palette.setColor(QtGui.QPalette.AlternateBase, alt_color)
        palette.setColor(QtGui.QPalette.ToolTipBase, alt_color)
        palette.setColor(QtGui.QPalette.ToolTipText, text_color)
        palette.setColor(QtGui.QPalette.Button, base_color)
        palette.setColor(QtGui.QPalette.ButtonText, text_color)
        palette.setColor(QtGui.QPalette.Text, text_color)
        palette.setColor(QtGui.QPalette.Highlight, highlight_color)
        palette.setColor(QtGui.QPalette.HighlightedText, highlight_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Window, disabled_base_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Base, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, disabled_alt_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Button, disabled_base_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Text, disabled_text_color)
        return palette

    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle("Element Browser")
        self.setGeometry(0, 0, REF_WINDOW_WIDTH, REF_WINDOW_HEIGHT)
        self.palette = self.dark_palette()
        self.setPalette(self.palette)

        # initialize project
        self.project = Project()
        self.user_list = self.project.list_users()
        self.user_completer = QtGui.QCompleter(self.user_list)

        #filters
        self.filter_label = QtGui.QLabel("Filter by: ")

        self.dept_filter_label = QtGui.QLabel("Department")
        self.dept_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.dept_filter = QtGui.QComboBox()
        self.dept_filter.addItem("all")
        for each in Department.ALL:
            self.dept_filter.addItem(each)
        self.dept_list = Department.ALL

        self.type_filter_label = QtGui.QLabel("Asset Type")
        self.type_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.type_filter = QtGui.QComboBox()
        self.type_filter.addItem("all")
        for each in AssetType.ALL:
            self.type_filter.addItem(each)

        self.name_filter_label = QtGui.QLabel("Name")
        self.name_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.name_filter = QtGui.QLineEdit()

        # menu bar
        self.menu_bar = QtGui.QMenuBar()
        self.view_menu = QtGui.QMenu("View")
        self.menu_bar.addMenu(self.view_menu)
        self.expand_action = self.view_menu.addAction("Expand All")
        self.user_list_action = self.view_menu.addAction("User Directory")
        self.theme_action = self.view_menu.addAction("Default Theme")
        self.theme_action.setCheckable(True)

        # asset/shot menu
        self.body_menu = QtGui.QComboBox()
        self.body_menu.addItem(self.ASSETS)
        self.body_menu.addItem(self.SHOTS)
        self.current_body = self.ASSETS
        self._set_bodies()

        # new button
        self.new_button = QtGui.QPushButton("New")

        # refresh button
        self.refresh_button = QtGui.QPushButton("Refresh")

        # tree
        self.tree = QtGui.QTreeWidget()
        self.tree.setItemDelegate(TreeGridDelegate(self.tree))
        self.columnCount = 8
        self.tree.setColumnCount(self.columnCount)
        tree_header = QtGui.QTreeWidgetItem(["name", "", "assigned", "status", "start", "end", "publish", "note"])
        self.tree.setHeaderItem(tree_header)

        self.init_tree = [None]*self.columnCount
        self.init_tree[0] = self.init_name
        self.init_tree[1] = self.init_dept
        self.init_tree[2] = self.init_assigned_user
        self.init_tree[3] = self.init_status
        self.init_tree[4] = self.init_start_date
        self.init_tree[5] = self.init_end_date
        self.init_tree[6] = self.init_last_publish
        self.init_tree[7] = self.init_note

        self._build_tree()

        self.update_tree = [None]*self.columnCount
        self.update_tree[0] = self.update_name
        self.update_tree[1] = self.update_dept
        self.update_tree[2] = self.update_assigned_user
        self.update_tree[3] = self.update_status
        self.update_tree[4] = self.update_start_date
        self.update_tree[5] = self.update_end_date
        self.update_tree[6] = self.update_last_publish
        self.update_tree[7] = self.update_note
        
        # status bar
        self.status_bar = QtGui.QStatusBar()

        # connect events
        self.expand_action.triggered.connect(self._expand_all)
        self.user_list_action.triggered.connect(self._show_user_directory)
        self.theme_action.triggered.connect(self._toggle_theme)
        self.body_menu.currentIndexChanged.connect(self._body_changed)
        self.new_button.clicked.connect(self._new_body)
        self.refresh_button.clicked.connect(self._refresh)
        self.tree.itemExpanded.connect(self._load_elements)
        self.tree.itemChanged.connect(self._item_edited)
        self.dept_filter.currentIndexChanged.connect(self._dept_filter_changed)
        self.name_filter.editingFinished.connect(self._filter_by_name)
        self.type_filter.currentIndexChanged.connect(self._refresh)

        # layout
        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(5)
        layout.setMargin(6)
        options_layout = QtGui.QGridLayout()
        options_layout.addWidget(self.body_menu, 0, 0)
        options_layout.addWidget(self.new_button, 0, 1)
        options_layout.addWidget(self.refresh_button, 0, 3)
        options_layout.setColumnMinimumWidth(0, 100)
        options_layout.setColumnMinimumWidth(1, 100)
        options_layout.setColumnMinimumWidth(3, 100)
        options_layout.setColumnStretch(2, 1)
        filter_layout = QtGui.QGridLayout()
        filter_layout.addWidget(self.filter_label, 0, 0)
        filter_layout.addWidget(self.dept_filter_label, 0, 1)
        filter_layout.addWidget(self.dept_filter, 0, 2)
        filter_layout.addWidget(self.name_filter_label, 0, 3)
        filter_layout.addWidget(self.name_filter, 0, 4)
        filter_layout.addWidget(self.type_filter_label, 0, 5)
        filter_layout.addWidget(self.type_filter, 0, 6)
        filter_layout.setColumnMinimumWidth(0, 50)
        filter_layout.setColumnMinimumWidth(1, 100)
        filter_layout.setColumnMinimumWidth(2, 100)
        filter_layout.setColumnMinimumWidth(3, 100)
        filter_layout.setColumnMinimumWidth(4, 100)
        filter_layout.setColumnMinimumWidth(5, 100)
        filter_layout.setColumnMinimumWidth(6, 100)
        cal = QtGui.QCalendarWidget()
        
        filter_layout.setColumnStretch(7, 1)
        layout.addWidget(self.menu_bar)
        layout.addLayout(options_layout)
        layout.addWidget(self.tree)
        layout.addLayout(filter_layout)
        # layout.addWidget(self.filter_label)
        # layout.addWidget(self.type_filter)
        # layout.addWidget(self.dept_filter)
        layout.addWidget(self.status_bar)
        self.setLayout(layout)

        request_email.check_user_email(self)

    def _build_tree(self):
        self.tree.clear()
        tree_state = self.tree.blockSignals(True)
        for body in self.bodies:
            if(str(self.name_filter.text()) in body):
                tree_item = QtGui.QTreeWidgetItem([body])
                self.tree.addTopLevelItem(tree_item)
                tree_flags = tree_item.flags()
                tree_item.setFlags(tree_flags | QtCore.Qt.ItemIsEditable)
                # for col in xrange(self.columnCount):
                #     tree_item.setBackground(col, QtGui.QColor(30,30,30))
                body_obj = self.project.get_body(body)
                self._load_body(body_obj, tree_item)
                tree_item.addChild(QtGui.QTreeWidgetItem()) # empty item
        self.tree.blockSignals(tree_state)

    def _load_body(self, body, item):
        tree_state = self.tree.blockSignals(True)
        item.setText(0, body.get_name())
        namelabel = TreeLabel(body.get_name())
        self.tree.setItemWidget(item, 0, namelabel)
        if self.current_body==self.ASSETS:
            body_type = body.get_type()
            item.setText(self.BODY_DATA_COLUMN, body_type)
            combobox = TreeComboBoxItem(item, self.BODY_DATA_COLUMN)
            type_idx = 0
            for idx, type in enumerate(AssetType.ALL):
                combobox.addItem(type)
                if type == body_type:
                    type_idx = idx
            combobox.setCurrentIndex(type_idx)
            self.tree.setItemWidget(item, self.BODY_DATA_COLUMN, combobox)
        elif self.current_body==self.SHOTS:
            item.setText(self.BODY_DATA_COLUMN, str(body.get_frame_range()))
        else:
            self.status_bar.showMessage("Error: unknown body type")

        description_edit = TreeLineEdit(body.get_description(), item, self.BODY_DESCRIPTION_COLUMN)
        self.tree.setItemWidget(item, self.BODY_DESCRIPTION_COLUMN, description_edit)

        for col in xrange(self.BODY_DATA_COLUMN+1, self.columnCount-1): # disable remaining columns
            emptylabel = TreeLabel()
            self.tree.setItemWidget(item, col, emptylabel)
        self.tree.blockSignals(tree_state)

    def _load_elements(self, item):
        tree_state = self.tree.blockSignals(True)
        body = str(item.text(0))
        body_obj = self.project.get_body(body)
        elements = []
        for dept in self.dept_list:
            dept_elements = body_obj.list_elements(dept)
            for dept_element in dept_elements:
                elements.append((dept, dept_element))
        item.takeChildren() # clear children
        for dept, element in elements:
            element_obj = body_obj.get_element(dept, element)
            child_item = QtGui.QTreeWidgetItem()
            item.addChild(child_item)
            child_item.setFlags(child_item.flags() | QtCore.Qt.ItemIsEditable)
            for col, init in enumerate(self.init_tree):
                init(element_obj, child_item, col)
        self.tree.blockSignals(tree_state)

    def _expand_all(self):
        # self.tree.expandAll()
        count = self.tree.topLevelItemCount()
        for i in xrange(count):
            item = self.tree.topLevelItem(i)
            self.tree.expandItem(item)
    
    def _show_user_directory(self):
        user_directory = UserListDialog(self)
        user_directory.show()

    def _toggle_theme(self):
        checked = self.theme_action.isChecked()
        if not checked:
            self.palette = self.dark_palette()
        else:
            self.palette = QtGui.QPalette()
        self.setPalette(self.palette)

    def _set_bodies(self):
        if self.current_body == self.ASSETS:
            asset_filter = None
            if(self.type_filter.currentIndex()):
                asset_filter_str = str(self.type_filter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.bodies = self.project.list_assets(asset_filter)
        elif self.current_body == self.SHOTS:
            self.bodies = self.project.list_shots()
        else:
            self.bodies = []

    def _item_edited(self, item, column):
        parent = item.parent()
        if parent is not None:
            body = str(parent.text(0))
            body_obj = self.project.get_body(body)
            element = str(item.text(0))
            dept = str(item.text(1))
            element_obj = body_obj.get_element(dept, element)
            self.update_tree[column](element_obj, item, column)
            # self.tree.resizeColumnToContents(column)
        else:
            body = str(item.text(0))
            body_obj = self.project.get_body(body)
            if column==self.BODY_DATA_COLUMN:
                self._update_body_data(body_obj, item)
            elif column==self.BODY_DESCRIPTION_COLUMN:
                self._update_body_description(body_obj, item)
                

    def _refresh(self): # TODO: maintain expanded rows on refresh
        self._set_bodies()
        self._build_tree()
        self.status_bar.clearMessage()

    def _body_changed(self, index):
        self.current_body = str(self.body_menu.itemText(index))
        if(self.body_menu.currentIndex()):
            self.type_filter.setEnabled(False)
            self.type_filter_label.setEnabled(False)
        else:
            self.type_filter.setEnabled(True)
            self.type_filter_label.setEnabled(True)
        self._refresh()

    def _dept_filter_changed(self):
        if(self.dept_filter.currentIndex()):
            self.dept_list = [str(self.dept_filter.currentText())]
        else:
            self.dept_list = Department.ALL
        self._refresh()

    def _filter_by_name(self):
        self._refresh()
        # target = str(self.name_filter.text())
        # for i in reversed(xrange(self.tree.topLevelItemCount())):
        #     if (target not in self.tree.topLevelItem(i).text(0)):
        #         self.tree.takeTopLevelItem(i)

    def _new_body(self):
        from byugui import new_asset_gui
        self.new_body_dialog = new_asset_gui.CreateWindow(self)
        if self.current_body == self.ASSETS:
            self.new_body_dialog.setCurrentIndex(self.new_body_dialog.ASSET_INDEX)
        elif self.current_body == self.SHOTS:
            self.new_body_dialog.setCurrentIndex(self.new_body_dialog.SHOT_INDEX)
        self.new_body_dialog.finished.connect(self._refresh)

    def _update_body_data(self, body, item):
        if self.current_body==self.ASSETS:
            body.update_type(str(item.text(self.BODY_DATA_COLUMN)))
        elif self.current_body==self.SHOTS:
            body.update_frame_range(int(item.text(self.BODY_DATA_COLUMN)))
        else:
            self.status_bar.showMessage("Error: unknown body type")

    def _update_body_description(self, body, item):
        body.update_description(str(item.text(self.BODY_DESCRIPTION_COLUMN)))

    def _valid_date(self, date):
        try:
            date_obj = datetime.datetime.strptime(date, "%Y-%m-%d").date()
            return str(date_obj)
        except ValueError:
            self.status_bar.showMessage(date+" not a valid date, please use format: YYYY-MM-DD")
            return None

    def init_name(self, element, item, column):
        item.setText(column, element.get_name())
        namelabel = TreeLabel(element.get_name())
        self.tree.setItemWidget(item, column, namelabel)

    def init_dept(self, element, item, column):
        item.setText(column, element.get_department())
        deptlabel = TreeLabel(element.get_department())
        self.tree.setItemWidget(item, column, deptlabel)

    def init_assigned_user(self, element, item, column):
        user = element.get_assigned_user()
        item.setText(column, user)
        lineedit = TreeLineEdit(user, item, column)
        lineedit.setCompleter(self.user_completer)
        self.tree.setItemWidget(item, column, lineedit)

    def init_status(self, element, item, column):
        item.setText(column, element.get_status())
        combobox = TreeComboBoxItem(item, column)
        element_type = element.get_status()
        type_idx = 0
        for idx, type in enumerate(Status.ALL):
            combobox.addItem(type)
            if type == element_type:
                type_idx = idx
        combobox.setCurrentIndex(type_idx)
        self.tree.setItemWidget(item, column, combobox)

    def init_start_date(self, element, item, column):
        item.setText(column, element.get_start_date())

    def init_end_date(self, element, item, column):
        item.setText(column, element.get_end_date())

    def init_last_publish(self, element, item, column):
        publish = element.get_last_publish()
        if publish is not None:
            item.setText(column, publish[0]+", "+publish[1]+", "+publish[2])
        else:
            item.setText(column, "")

    def init_note(self, element, item, column):
        item.setText(column, element.get_last_note())

    def update_name(self, element, item, column):
        self.status_bar.showMessage("can't change name")

    def update_dept(self, element, item, column):
        self.status_bar.showMessage("can't change department")

    def update_assigned_user(self, element, item, column):
        user = str(item.text(column))
        if user in self.user_list:
            element.update_assigned_user(user)
            self.status_bar.clearMessage()
        else:
            self.tree.itemWidget(item, column).setText(element.get_assigned_user())
            self.status_bar.showMessage('"' + user + '" is not a valid username')

    def update_status(self, element, item, column):
        element.update_status(str(item.text(column)))
        self.status_bar.clearMessage()

    def update_start_date(self, element, item, column):
        date_str = str(item.text(column))
        valid_date_str = self._valid_date(date_str)
        if valid_date_str:
            element.update_start_date(valid_date_str)
            self.status_bar.clearMessage()
        else:
            self.init_start_date(element, item, column)

    def update_end_date(self, element, item, column):
        date_str = str(item.text(column))
        valid_date_str = self._valid_date(date_str)
        if valid_date_str:
            element.update_end_date(valid_date_str)
            self.status_bar.clearMessage()
        else:
            self.init_end_date(element, item, column)

    def update_last_publish(self, element, item, column):
        self.status_bar.showMessage("can't modify publish data")
        self.init_last_publish(element, item, column)

    def update_note(self, element, item, column):
        element.update_notes(str(item.text(column)))
        self.status_bar.clearMessage()
Ejemplo n.º 7
0
class ElementList(QtWidgets.QTreeWidget):
    def __init__(self, parent):
        super(ElementList, self).__init__()
        self.parent = parent
        self.project = Project()
        self.elements = self.project.list_assets()
        self.initUI()

    def initUI(self):
        #define gui elements
        self.refreshList('Asset')

    def recurseTree(self, treeItem, array, asset):
        #This is for setting bottom level text attributes
        if len(array) == 0:
            treeItem.setText(1, asset)
            treeItem.setTextColor(0, "#3c83f9")
            font = QtGui.QFont()
            font.setPointSize(12)
            font.setBold(False)
            treeItem.setFont(0, font)
            return
        else:  #This is for setting parent level text attributes and settin up the structure
            item = QtWidgets.QTreeWidgetItem(array[0])
            item.setText(0, array[0])
            item.setText(1, "This is not a file")
            item.setTextColor(0, "#d0d0d0")
            font = QtGui.QFont()
            font.setPointSize(11)
            font.setBold(True)
            item.setFont(0, font)
            skip = False
            # this is to check if the child already exists
            for i in range(0, treeItem.childCount()):
                if treeItem.child(i).text(0) == item.text(0):
                    item = treeItem.child(i)
                    skip = True
            if skip == False:  # Executes if the child doesnt already exist
                treeItem.addChild(item)
            newArray = array[1:]
            self.recurseTree(item, newArray, asset)
        return

    #Update the list based on the input element type
    def refreshList(self, element):
        if element == 'Asset':
            self.elements = self.project.list_assets()
        elif element == 'Shot':
            self.elements = self.project.list_shots()
        elif element == 'Tool':
            self.elements = self.project.list_tools()
        elif element == 'CrowdCycle':
            self.elements = self.project.list_crowd_cycles()
        else:
            self.elements = list()
            message_gui.error(
                'There was a problem loading in the elements from of ' +
                str(element) + ' type.')
        self.clear()
        for e in self.elements:
            asset_array = e.split("_")
            firstelement = self.findItems(asset_array[0], 0, 0)
            if not firstelement:
                item = QtWidgets.QTreeWidgetItem(asset_array[0])
                item.setText(0, asset_array[0])
                item.setTextColor(0, "#d0d0d0")
                font = QtGui.QFont()
                font.setPointSize(11)
                font.setBold(True)
                item.setFont(0, font)
                self.recurseTree(item, asset_array[1:], e)
                self.insertTopLevelItem(0, item)
            else:
                self.recurseTree(firstelement[0], asset_array[1:], e)
            #self.addItem(e)

    def setElement(self, element):
        print(element)
Ejemplo n.º 8
0
class CheckoutWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)
        
    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtGui.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        #create tabs
        for dept in dept_list:
            tab = DepartmentTab(self)
            #tab = QtGui.QWidget()
            # self.dept_tabs.insertTab(self.ASSET_INDEX, tab, dept)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtGui.QVBoxLayout()
            element_list = QtGui.QListWidget()
				
            if dept in Department.FRONTEND:
                for asset in self.project.list_assets():
                    item = QtGui.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(self.set_current_item)
            elif dept in Department.BACKEND:
                for shot in self.project.list_shots():
                    item = QtGui.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(self.set_current_item)
            tab_layout.addWidget(element_list)
            tab.setLayout(tab_layout)
            
        #create buttons
        self.checkout_button = QtGui.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtGui.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)    
		
        #create button layout
        button_layout = QtGui.QHBoxLayout()
        #button_layout.setSpacing(2)
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtGui.QLabel()
        pixmap = QtGui.QPixmap(os.environ['BYU_TOOLS_DIR'] + '/byugui/assets/images/taijitu.jpg')
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtGui.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)
            
        self.show()
            
    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.FRONTEND:
            self.current_item = str(index.text())
        elif current_dept in Department.BACKEND:
            self.current_item = str(index.text())
            
    def checkout(self):
        """
        Checks out the currently selected item
        :return:
        """
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            # self.parent.close()
            self.result = element_path
            self.close()
            

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Ejemplo n.º 9
0
class SelectionWindow(QtWidgets.QDialog):

    finished = QtCore.Signal()

    def __init__(self, parent, dept_list=Department.ALL, showWindow=True):
        super(SelectionWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list, showWindow)

    def initUI(self, dept_list, showWindow):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Select Asset')
        self.dept_tabs = QtWidgets.QTabWidget()
        self.dept_list = dept_list
        self.result = None
        self.instructions = QtWidgets.QLabel(
            'Select the asset you would like affect:')

        #create Tabs
        self.createTabs()

        #create buttons
        self.select_button = QtWidgets.QPushButton('Select')
        self.select_button.clicked.connect(self.select)
        self.cancel_button = QtWidgets.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addWidget(self.select_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtWidgets.QLabel()
        image_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui',
                                  'assets', 'images', 'film-banner.jpg')
        pixmap = QtGui.QPixmap(image_path)
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        # main_layout.setMargin(6)
        main_layout.addWidget(self.instructions)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addLayout(button_layout)

        if showWindow:
            self.show()

    def createTabs(self):
        #remember the current index so that we can restore it when we create the tabs
        currIndex = self.dept_tabs.currentIndex()
        #clear out the old tabs
        self.dept_tabs.clear()
        #create tabs
        for dept in self.dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtWidgets.QHBoxLayout()
            element_list = QtWidgets.QListWidget()

            if dept in Department.ASSET_DEPTS:
                for asset in self.project.list_assets():
                    item = QtWidgets.QListWidgetItem(asset)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            elif dept in Department.SHOT_DEPTS:
                for shot in self.project.list_shots():
                    item = QtWidgets.QListWidgetItem(shot)
                    element_list.addItem(item)
                    element_list.currentItemChanged.connect(
                        self.set_current_item)
            tab_layout.addWidget(element_list)
            tab.setLayout(tab_layout)

        #restore the previous index
        self.dept_tabs.setCurrentIndex(currIndex)

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.ASSET_DEPTS:
            self.current_item = str(index.text())
        elif current_dept in Department.SHOT_DEPTS:
            self.current_item = str(index.text())

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = 'Last published {0} by {1} \n \"{2}\"'.format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = 'No publishes for this element'
        currentTab = self.dept_tabs.currentWidget()

    def hasPreviousPublish(self, body, department):
        asset_obj = self.project.get_body(body)
        element_obj = asset_obj.get_element(department)
        last_publish = element_obj.get_last_publish()
        if last_publish is None:
            return False
        return True

    def select(self):
        '''
		Selects the currently selected item
		:return:
		'''
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        if element_obj != None:
            self.result = element_obj
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Ejemplo n.º 10
0
class ReferenceWindow(QtGui.QWidget):

    finished = QtCore.pyqtSignal()

    def __init__(self, parent, src, dept_list=Department.ALL):
        super(ReferenceWindow, self).__init__()
        self.project = Project()
        self.parent = parent
        self.src = src
        self.filePaths = []
        self.done = True
        self.reference = False
        self.initUI(dept_list)

    def initUI(self, dept_list):
        #define gui elements
        self.setGeometry(300, 300, WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Taijitu Reference Manager')
        self.departmentMenu = QtGui.QComboBox()
        for i in dept_list:
            self.departmentMenu.addItem(i)
        self.departmentMenu.activated[str].connect(self.setElementType)

        self.assetList = AssetListWindow(self)
        for asset in self.project.list_assets():
            item = QtGui.QListWidgetItem(asset)
            self.assetList.addItem(item)

        self.typeFilterLabel = QtGui.QLabel("Type Filter")
        self.typeFilterLabel.setAlignment(QtCore.Qt.AlignRight
                                          | QtCore.Qt.AlignVCenter)
        self.typeFilter = QtGui.QComboBox()
        self.typeFilter.addItem("all")
        for i in AssetType.ALL:
            self.typeFilter.addItem(i)

        self.typeFilter.currentIndexChanged.connect(self.setElementType)
        self.referenceButton = QtGui.QPushButton('Reference')
        self.referenceButton.clicked.connect(self.createReference)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.close)

        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.assetList, 1, 0, 1, 0)
        self.grid.addWidget(self.typeFilterLabel, 2, 0)
        self.grid.addWidget(self.typeFilter, 2, 1)
        self.grid.addWidget(self.referenceButton, 3, 0)
        self.grid.addWidget(self.cancelButton, 3, 1)

        self.show()

    def setElementType(self, idx=0):
        department = str(self.departmentMenu.currentText())
        self.refreshList(department)

    def createReference(self):
        selected = []
        del self.filePaths[:]
        for item in self.assetList.selectedItems():
            body = self.project.get_body(str(item.text()))
            element = body.get_element(str(self.departmentMenu.currentText()))
            path = element.get_app_filepath()
            self.filePaths.append(path)
            selected.append(str(item.text()))
        checkout = self.project.get_checkout(os.path.dirname(self.src))
        if checkout is not None:
            body_name = checkout.get_body_name()
            body = self.project.get_body(body_name)
            for sel in selected:
                body.add_reference(sel)
        self.done = False
        self.reference = True
        self.close()

    def refreshList(self, department):
        if department in Department.FRONTEND:
            asset_filter = None
            if (self.typeFilter.currentIndex()):
                asset_filter_str = str(self.typeFilter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.elements = self.project.list_assets(asset_filter)
        else:
            self.elements = self.project.list_shots()

        self.assetList.clear()
        for e in self.elements:
            self.assetList.addItem(e)

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Ejemplo n.º 11
0
class ElementBrowser(QtGui.QWidget):

    ASSETS = "Assets"
    SHOTS = "Shots"

    BODY_DATA_COLUMN = 1
    BODY_DESCRIPTION_COLUMN = 7

    @staticmethod
    def dark_palette():
        palette = QtGui.QPalette()
        base_color = QtGui.QColor(39,39,39)
        alt_color = QtGui.QColor(30,30,30)
        text_color = QtGui.QColor(192,192,192)
        highlight_color = QtGui.QColor(57,86,115)
        highlight_text_color = QtCore.Qt.white
        disabled_alt_color = QtGui.QColor(49,49,49)
        disabled_base_color = QtGui.QColor(40,40,40)
        disabled_text_color = QtGui.QColor(100,100,100)
        palette.setColor(QtGui.QPalette.Window, base_color)
        palette.setColor(QtGui.QPalette.WindowText, text_color)
        palette.setColor(QtGui.QPalette.Base, base_color)
        palette.setColor(QtGui.QPalette.AlternateBase, alt_color)
        palette.setColor(QtGui.QPalette.ToolTipBase, alt_color)
        palette.setColor(QtGui.QPalette.ToolTipText, text_color)
        palette.setColor(QtGui.QPalette.Button, base_color)
        palette.setColor(QtGui.QPalette.ButtonText, text_color)
        palette.setColor(QtGui.QPalette.Text, text_color)
        palette.setColor(QtGui.QPalette.Highlight, highlight_color)
        palette.setColor(QtGui.QPalette.HighlightedText, highlight_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Window, disabled_base_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Base, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, disabled_alt_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Button, disabled_base_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, disabled_text_color)
        palette.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Text, disabled_text_color)
        return palette

    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle("Element Browser")
        self.setGeometry(0, 0, REF_WINDOW_WIDTH, REF_WINDOW_HEIGHT)
        self.palette = self.dark_palette()
        self.setPalette(self.palette)

        # initialize project
        self.project = Project()
        self.user_list = self.project.list_users()
        self.user_completer = QtGui.QCompleter(self.user_list)

        #filters
        self.filter_label = QtGui.QLabel("Filter by: ")

        self.dept_filter_label = QtGui.QLabel("Department")
        self.dept_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.dept_filter = QtGui.QComboBox()
        self.dept_filter.addItem("all")
        for each in Department.ALL:
            self.dept_filter.addItem(each)
        self.dept_list = Department.ALL

        self.type_filter_label = QtGui.QLabel("Asset Type")
        self.type_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.type_filter = QtGui.QComboBox()
        self.type_filter.addItem("all")
        for each in AssetType.ALL:
            self.type_filter.addItem(each)

        self.name_filter_label = QtGui.QLabel("Name")
        self.name_filter_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.name_filter = QtGui.QLineEdit()

        # menu bar
        self.menu_bar = QtGui.QMenuBar()
        self.view_menu = QtGui.QMenu("View")
        self.menu_bar.addMenu(self.view_menu)
        self.expand_action = self.view_menu.addAction("Expand All")
        self.user_list_action = self.view_menu.addAction("User Directory")
        self.theme_action = self.view_menu.addAction("Default Theme")
        self.theme_action.setCheckable(True)

        # asset/shot menu
        self.body_menu = QtGui.QComboBox()
        self.body_menu.addItem(self.ASSETS)
        self.body_menu.addItem(self.SHOTS)
        self.current_body = self.ASSETS
        self._set_bodies()

        # new button
        self.new_button = QtGui.QPushButton("New")

        # refresh button
        self.refresh_button = QtGui.QPushButton("Refresh")

        # tree
        self.tree = QtGui.QTreeWidget()
        self.tree.setItemDelegate(TreeGridDelegate(self.tree))
        self.columnCount = 8
        self.tree.setColumnCount(self.columnCount)
        tree_header = QtGui.QTreeWidgetItem(["name", "", "assigned", "status", "start", "end", "publish", "note"])
        self.tree.setHeaderItem(tree_header)
        tree_header_view = self.tree.header()
        tree_header_view.resizeSection(4, 120)
        tree_header_view.resizeSection(5, 120)

        self.init_tree = [None]*self.columnCount
        self.init_tree[0] = self.init_name
        self.init_tree[1] = self.init_dept
        self.init_tree[2] = self.init_assigned_user
        self.init_tree[3] = self.init_status
        self.init_tree[4] = self.init_start_date
        self.init_tree[5] = self.init_end_date
        self.init_tree[6] = self.init_last_publish
        self.init_tree[7] = self.init_note

        self._build_tree()

        self.update_tree = [None]*self.columnCount
        self.update_tree[0] = self.update_name
        self.update_tree[1] = self.update_dept
        self.update_tree[2] = self.update_assigned_user
        self.update_tree[3] = self.update_status
        self.update_tree[4] = self.update_start_date
        self.update_tree[5] = self.update_end_date
        self.update_tree[6] = self.update_last_publish
        self.update_tree[7] = self.update_note
        
        # status bar
        self.status_bar = QtGui.QStatusBar()

        # connect events
        self.expand_action.triggered.connect(self._expand_all)
        self.user_list_action.triggered.connect(self._show_user_directory)
        self.theme_action.triggered.connect(self._toggle_theme)
        self.body_menu.currentIndexChanged.connect(self._body_changed)
        self.new_button.clicked.connect(self._new_body)
        self.refresh_button.clicked.connect(self._refresh)
        self.tree.itemExpanded.connect(self._load_elements)
        self.tree.itemChanged.connect(self._item_edited)
        self.dept_filter.currentIndexChanged.connect(self._dept_filter_changed)
        self.name_filter.editingFinished.connect(self._filter_by_name)
        self.type_filter.currentIndexChanged.connect(self._refresh)

        # layout
        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(5)
        layout.setMargin(6)
        options_layout = QtGui.QGridLayout()
        options_layout.addWidget(self.body_menu, 0, 0)
        options_layout.addWidget(self.new_button, 0, 1)
        options_layout.addWidget(self.refresh_button, 0, 3)
        options_layout.setColumnMinimumWidth(0, 100)
        options_layout.setColumnMinimumWidth(1, 100)
        options_layout.setColumnMinimumWidth(3, 100)
        options_layout.setColumnStretch(2, 1)
        filter_layout = QtGui.QGridLayout()
        filter_layout.addWidget(self.filter_label, 0, 0)
        filter_layout.addWidget(self.dept_filter_label, 0, 1)
        filter_layout.addWidget(self.dept_filter, 0, 2)
        filter_layout.addWidget(self.name_filter_label, 0, 3)
        filter_layout.addWidget(self.name_filter, 0, 4)
        filter_layout.addWidget(self.type_filter_label, 0, 5)
        filter_layout.addWidget(self.type_filter, 0, 6)
        filter_layout.setColumnMinimumWidth(0, 50)
        filter_layout.setColumnMinimumWidth(1, 100)
        filter_layout.setColumnMinimumWidth(2, 100)
        filter_layout.setColumnMinimumWidth(3, 100)
        filter_layout.setColumnMinimumWidth(4, 100)
        filter_layout.setColumnMinimumWidth(5, 100)
        filter_layout.setColumnMinimumWidth(6, 100)
        
        filter_layout.setColumnStretch(7, 1)
        layout.addWidget(self.menu_bar)
        layout.addLayout(options_layout)
        layout.addWidget(self.tree)
        layout.addLayout(filter_layout)
        
        layout.addWidget(self.status_bar)
        self.setLayout(layout)

        request_email.check_user_email(self)

    def _build_tree(self):
        self.tree.clear()
        tree_state = self.tree.blockSignals(True)
        for body in self.bodies:
            if(str(self.name_filter.text()) in body):
                tree_item = QtGui.QTreeWidgetItem([body])
                self.tree.addTopLevelItem(tree_item)
                tree_flags = tree_item.flags()
                tree_item.setFlags(tree_flags | QtCore.Qt.ItemIsEditable)
                # for col in xrange(self.columnCount):
                #     tree_item.setBackground(col, QtGui.QColor(30,30,30))
                body_obj = self.project.get_body(body)
                self._load_body(body_obj, tree_item)
                tree_item.addChild(QtGui.QTreeWidgetItem()) # empty item
        self.tree.blockSignals(tree_state)

    def _load_body(self, body, item):
        tree_state = self.tree.blockSignals(True)
        item.setText(0, body.get_name())
        namelabel = TreeLabel(body.get_name())
        self.tree.setItemWidget(item, 0, namelabel)
        if self.current_body==self.ASSETS:
            body_type = body.get_type()
            item.setText(self.BODY_DATA_COLUMN, body_type)
            combobox = TreeComboBoxItem(item, self.BODY_DATA_COLUMN)
            type_idx = 0
            for idx, type in enumerate(AssetType.ALL):
                combobox.addItem(type)
                if type == body_type:
                    type_idx = idx
            combobox.setCurrentIndex(type_idx)
            self.tree.setItemWidget(item, self.BODY_DATA_COLUMN, combobox)
        elif self.current_body==self.SHOTS:
            item.setText(self.BODY_DATA_COLUMN, str(body.get_frame_range()))
        else:
            self.status_bar.showMessage("Error: unknown body type")

        description_edit = TreeLineEdit(body.get_description(), item, self.BODY_DESCRIPTION_COLUMN)
        self.tree.setItemWidget(item, self.BODY_DESCRIPTION_COLUMN, description_edit)

        for col in xrange(self.BODY_DATA_COLUMN+1, self.columnCount-1): # disable remaining columns
            emptylabel = TreeLabel()
            self.tree.setItemWidget(item, col, emptylabel)
        self.tree.blockSignals(tree_state)

    def _load_elements(self, item):
        tree_state = self.tree.blockSignals(True)
        body = str(item.text(0))
        body_obj = self.project.get_body(body)
        elements = []
        for dept in self.dept_list:
            dept_elements = body_obj.list_elements(dept)
            for dept_element in dept_elements:
                elements.append((dept, dept_element))
        item.takeChildren() # clear children
        for dept, element in elements:
            element_obj = body_obj.get_element(dept, element)
            child_item = QtGui.QTreeWidgetItem()
            item.addChild(child_item)
            child_item.setFlags(child_item.flags() | QtCore.Qt.ItemIsEditable)
            for col, init in enumerate(self.init_tree):
                init(element_obj, child_item, col)
        self.tree.blockSignals(tree_state)

    def _expand_all(self):
        # self.tree.expandAll()
        count = self.tree.topLevelItemCount()
        for i in xrange(count):
            item = self.tree.topLevelItem(i)
            self.tree.expandItem(item)
    
    def _show_user_directory(self):
        user_directory = UserListDialog(self)
        user_directory.show()

    def _toggle_theme(self):
        checked = self.theme_action.isChecked()
        if not checked:
            self.palette = self.dark_palette()
        else:
            self.palette = QtGui.QPalette()
        self.setPalette(self.palette)

    def _set_bodies(self):
        if self.current_body == self.ASSETS:
            asset_filter = None
            if(self.type_filter.currentIndex()):
                asset_filter_str = str(self.type_filter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.bodies = self.project.list_assets(asset_filter)
        elif self.current_body == self.SHOTS:
            self.bodies = self.project.list_shots()
        else:
            self.bodies = []

    def _item_edited(self, item, column):
        parent = item.parent()
        if parent is not None:
            body = str(parent.text(0))
            body_obj = self.project.get_body(body)
            element = str(item.text(0))
            dept = str(item.text(1))
            element_obj = body_obj.get_element(dept, element)
            self.update_tree[column](element_obj, item, column)
            # self.tree.resizeColumnToContents(column)
        else:
            body = str(item.text(0))
            body_obj = self.project.get_body(body)
            if column==self.BODY_DATA_COLUMN:
                self._update_body_data(body_obj, item)
            elif column==self.BODY_DESCRIPTION_COLUMN:
                self._update_body_description(body_obj, item)
                

    def _refresh(self): # TODO: maintain expanded rows on refresh
        self._set_bodies()
        self._build_tree()
        self.status_bar.clearMessage()

    def _body_changed(self, index):
        self.current_body = str(self.body_menu.itemText(index))
        if(self.body_menu.currentIndex()):
            self.type_filter.setEnabled(False)
            self.type_filter_label.setEnabled(False)
        else:
            self.type_filter.setEnabled(True)
            self.type_filter_label.setEnabled(True)
        self._refresh()

    def _dept_filter_changed(self):
        if(self.dept_filter.currentIndex()):
            self.dept_list = [str(self.dept_filter.currentText())]
        else:
            self.dept_list = Department.ALL
        self._refresh()

    def _filter_by_name(self):
        self._refresh()
        # target = str(self.name_filter.text())
        # for i in reversed(xrange(self.tree.topLevelItemCount())):
        #     if (target not in self.tree.topLevelItem(i).text(0)):
        #         self.tree.takeTopLevelItem(i)

    def _new_body(self):
        from byugui import new_asset_gui
        self.new_body_dialog = new_asset_gui.CreateWindow(self)
        if self.current_body == self.ASSETS:
            self.new_body_dialog.setCurrentIndex(self.new_body_dialog.ASSET_INDEX)
        elif self.current_body == self.SHOTS:
            self.new_body_dialog.setCurrentIndex(self.new_body_dialog.SHOT_INDEX)
        self.new_body_dialog.finished.connect(self._refresh)

    def _update_body_data(self, body, item):
        if self.current_body==self.ASSETS:
            body.update_type(str(item.text(self.BODY_DATA_COLUMN)))
        elif self.current_body==self.SHOTS:
            body.update_frame_range(int(item.text(self.BODY_DATA_COLUMN)))
        else:
            self.status_bar.showMessage("Error: unknown body type")

    def _update_body_description(self, body, item):
        body.update_description(str(item.text(self.BODY_DESCRIPTION_COLUMN)))

    def _valid_date(self, date):
        try:
            date_obj = datetime.datetime.strptime(date, "%Y-%m-%d").date()
            return str(date_obj)
        except ValueError:
            self.status_bar.showMessage(date+" not a valid date, please use format: YYYY-MM-DD")
            return None

    def init_name(self, element, item, column):
        item.setText(column, element.get_name())
        namelabel = TreeLabel(element.get_name())
        self.tree.setItemWidget(item, column, namelabel)

    def init_dept(self, element, item, column):
        item.setText(column, element.get_department())
        deptlabel = TreeLabel(element.get_department())
        self.tree.setItemWidget(item, column, deptlabel)

    def init_assigned_user(self, element, item, column):
        user = element.get_assigned_user()
        item.setText(column, user)
        lineedit = TreeLineEdit(user, item, column)
        lineedit.setCompleter(self.user_completer)
        self.tree.setItemWidget(item, column, lineedit)

    def init_status(self, element, item, column):
        item.setText(column, element.get_status())
        combobox = TreeComboBoxItem(item, column)
        element_type = element.get_status()
        type_idx = 0
        for idx, type in enumerate(Status.ALL):
            combobox.addItem(type)
            if type == element_type:
                type_idx = idx
        combobox.setCurrentIndex(type_idx)
        self.tree.setItemWidget(item, column, combobox)

    def init_start_date(self, element, item, column):
        start_date = element.get_start_date()
        item.setText(column, " "+start_date)
        start_dateedit = TreeDateEdit(start_date, item, column, self.tree)
        self.tree.setItemWidget(item, column, start_dateedit)

    def init_end_date(self, element, item, column):
        end_date = element.get_end_date()
        item.setText(column, " "+end_date)
        end_dateedit = TreeDateEdit(end_date, item, column, self.tree)
        self.tree.setItemWidget(item, column, end_dateedit)

    def init_last_publish(self, element, item, column):
        publish = element.get_last_publish()
        if publish is not None:
            item.setText(column, publish[0]+", "+publish[1]+", "+publish[2])
        else:
            item.setText(column, "")

    def init_note(self, element, item, column):
        item.setText(column, element.get_last_note())

    def update_name(self, element, item, column):
        self.status_bar.showMessage("can't change name")

    def update_dept(self, element, item, column):
        self.status_bar.showMessage("can't change department")

    def update_assigned_user(self, element, item, column):
        user = str(item.text(column))
        if user in self.user_list:
            element.update_assigned_user(user)
            self.status_bar.clearMessage()
        else:
            self.tree.itemWidget(item, column).setText(element.get_assigned_user())
            self.status_bar.showMessage('"' + user + '" is not a valid username')

    def update_status(self, element, item, column):
        element.update_status(str(item.text(column)))
        self.status_bar.clearMessage()

    def update_start_date(self, element, item, column):
        date_str = str(item.text(column))
        valid_date_str = self._valid_date(date_str)
        if valid_date_str:
            element.update_start_date(valid_date_str)
            item.setText(column, " "+date_str)
            self.status_bar.clearMessage()
        else:
            self.init_start_date(element, item, column)

    def update_end_date(self, element, item, column):
        date_str = str(item.text(column))
        valid_date_str = self._valid_date(date_str)
        if valid_date_str:
            element.update_end_date(valid_date_str)
            item.setText(column, " "+date_str)
            self.status_bar.clearMessage()
        else:
            self.init_end_date(element, item, column)

    def update_last_publish(self, element, item, column):
        self.status_bar.showMessage("can't modify publish data")
        self.init_last_publish(element, item, column)

    def update_note(self, element, item, column):
        element.update_notes(str(item.text(column)))
        self.status_bar.clearMessage()
Ejemplo n.º 12
0
class CheckoutWindow(QtWidgets.QWidget):

	finished = QtCore.Signal()

	def __init__(self, parent, dept_list=Department.ALL):
		super(CheckoutWindow, self).__init__()
		self.parent = parent
		self.project = Project()
		self.environment = Environment()
		self.initUI(dept_list)

	def initUI(self, dept_list):
		#define gui elements
		self.resize(WINDOW_WIDTH,WINDOW_HEIGHT)
		self.setWindowTitle('Checkout')
		self.dept_tabs = QtWidgets.QTabWidget()
		self.dept_list = dept_list
		self.result = None

		#create checkbox to show only published assets
		self.show_published = QtWidgets.QCheckBox("Display only assets or shots with previous publishes")
		self.show_published.setCheckState(QtCore.Qt.Unchecked)
		self.show_published.stateChanged.connect(self.changeBodyCheckoutVisibility)

		#create Tabs
		self.createTabs()

		#create buttons
		self.checkout_button = QtWidgets.QPushButton('Checkout')
		self.checkout_button.clicked.connect(self.checkout)
		self.cancel_button = QtWidgets.QPushButton('Cancel')
		self.cancel_button.clicked.connect(self.close)

		#create button layout
		button_layout = QtWidgets.QHBoxLayout()
		button_layout.addWidget(self.checkout_button)
		button_layout.addWidget(self.cancel_button)

		self.img = QtWidgets.QLabel()
		banner_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui', 'assets', 'images', 'film-banner.jpg')
		pixmap = QtGui.QPixmap(banner_path)
		scaled = pixmap.scaledToWidth(self.size().width())
		self.img.setPixmap(scaled)

		#create main layout
		main_layout = QtWidgets.QVBoxLayout()
		self.setLayout(main_layout)
		main_layout.addWidget(self.img)
		main_layout.setSpacing(5)
		# main_layout.setMargin(6)
		main_layout.addWidget(self.dept_tabs)
		main_layout.addWidget(self.show_published)
		main_layout.addLayout(button_layout)

		self.show()

	def createTabs(self):
		#remember the current index so that we can restore it when we create the tabs
		currIndex = self.dept_tabs.currentIndex()
		#clear out the old tabs
		self.dept_tabs.clear()
		#create tabs
		for dept in self.dept_list:
			tab = DepartmentTab(self)
			self.dept_tabs.addTab(tab, dept)
			tab_layout = QtWidgets.QHBoxLayout()
			element_list = QtWidgets.QListWidget()
			commentBox = QtWidgets.QTextEdit()
			commentBox.setReadOnly(True)
			tab.commentBox = commentBox

			if dept in Department.ASSET_DEPTS:
				for asset in self.project.list_assets():
					if not self.show_published.isChecked() or self.hasPreviousPublish(asset, dept):
						item = QtWidgets.QListWidgetItem(asset)
						element_list.addItem(item)
						element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.SHOT_DEPTS:
				for shot in self.project.list_shots():
					if not self.show_published.isChecked() or self.hasPreviousPublish(shot, dept):
						item = QtWidgets.QListWidgetItem(shot)
						element_list.addItem(item)
						element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.CROWD_DEPTS:
				for crowdCycle in self.project.list_crowd_cycles():
					if not self.show_published.isChecked() or self.hasPreviousPublish(crowdCycle, dept):
						item = QtWidgets.QListWidgetItem(crowdCycle)
						element_list.addItem(item)
						element_list.currentItemChanged.connect(self.set_current_item)
			tab_layout.addWidget(element_list)
			tab_layout.addWidget(commentBox)
			tab.setLayout(tab_layout)

		#restore the previous index
		self.dept_tabs.setCurrentIndex(currIndex)

	def hasPreviousPublish(self, body, department):
		asset_obj = self.project.get_body(body)
		element_obj = asset_obj.get_element(department)
		last_publish = element_obj.get_last_publish()
		if last_publish is None:
			return False
		return True

	def changeBodyCheckoutVisibility(self):
		#recreate tabs the with the new check option
		self.createTabs()

	def set_current_item(self, index):
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]
		if current_dept in Department.ASSET_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.SHOT_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.CROWD_DEPTS:
			self.current_item = str(index.text())
			#TODO what the heck? Why do we have three identical results from three different conditions? What are we trying to accomplish here? Admitadly the last one I added just following the crowd.

		asset_obj = self.project.get_body(self.current_item)
		element_obj = asset_obj.get_element(current_dept)
		last_publish = element_obj.get_last_publish()
		last_publish_comment = None
		if last_publish is not None:
			last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(last_publish[1], last_publish[0], last_publish[2])
		else:
			last_publish_comment = "No publishes for this element"
		currentTab = self.dept_tabs.currentWidget()
		currentTab.commentBox.setText(last_publish_comment)

	def checkout(self):
		"""
		Checks out the currently selected item
		:return:
		"""
		current_user = self.environment.get_current_username()
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]
		asset_obj = self.project.get_body(self.current_item)
		element_obj = asset_obj.get_element(current_dept)
		element_path = element_obj.checkout(current_user)
		if element_path != None:
			self.result = element_path
			self.close()


	def closeEvent(self, event):
		self.finished.emit()
		event.accept()
Ejemplo n.º 13
0
class AssembleWindow(QtWidgets.QWidget):

	finished = QtCore.Signal()

	def __init__(self, parent, dept_list=Department.ALL):
		super(AssembleWindow, self).__init__()
		self.parent = parent
		self.project = Project()
		self.environment = Environment()
		self.initUI(dept_list)

	def initUI(self, dept_list):
		#define gui elements
		self.resize(WINDOW_WIDTH,WINDOW_HEIGHT)
		self.setWindowTitle('Assemble')
		self.dept_tabs = QtWidgets.QTabWidget()
		self.dept_list = dept_list
		self.result = None

		#create Tabs
		self.createTabs()

		#create buttons
		self.assemble_button = QtWidgets.QPushButton('Assemble')
		self.assemble_button.clicked.connect(self.assemble)
		self.cancel_button = QtWidgets.QPushButton('Cancel')
		self.cancel_button.clicked.connect(self.close)

		#create button layout
		button_layout = QtWidgets.QHBoxLayout()
		button_layout.addWidget(self.assemble_button)
		button_layout.addWidget(self.cancel_button)

		self.img = QtWidgets.QLabel()
		banner_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui', 'assets', 'images', 'film-banner.jpg')
		pixmap = QtGui.QPixmap(banner_path)
		scaled = pixmap.scaledToWidth(self.size().width())
		self.img.setPixmap(scaled)

		#create main layout
		main_layout = QtWidgets.QVBoxLayout()
		self.setLayout(main_layout)
		main_layout.addWidget(self.img)
		main_layout.setSpacing(5)
		# main_layout.setMargin(6)
		main_layout.addWidget(self.dept_tabs)
		main_layout.addLayout(button_layout)

		self.show()

	def createTabs(self):
		#remember the current index so that we can restore it when we create the tabs
		currIndex = self.dept_tabs.currentIndex()
		#clear out the old tabs
		self.dept_tabs.clear()
		#create tabs
		for dept in self.dept_list:
			tab = DepartmentTab(self)
			self.dept_tabs.addTab(tab, dept)
			tab_layout = QtWidgets.QHBoxLayout()
			element_list = QtWidgets.QListWidget()

			if dept in Department.ASSET_DEPTS:
				for asset in self.project.list_assets():
					item = QtWidgets.QListWidgetItem(asset)
					element_list.addItem(item)
					element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.SHOT_DEPTS:
				for shot in self.project.list_shots():
					item = QtWidgets.QListWidgetItem(shot)
					element_list.addItem(item)
					element_list.currentItemChanged.connect(self.set_current_item)
			elif dept in Department.TOOL_DEPTS:
				for tool in self.project.list_tools():
					item = QtWidgets.QListWidgetItem(tool)
					element_list.addItem(item)
					element_list.currentItemChanged.connect(self.set_current_item)
			tab_layout.addWidget(element_list)
			tab.setLayout(tab_layout)

		#restore the previous index
		self.dept_tabs.setCurrentIndex(currIndex)

	def set_current_item(self, index):
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]
		if current_dept in Department.ASSET_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.SHOT_DEPTS:
			self.current_item = str(index.text())
		elif current_dept in Department.TOOL_DEPTS:
			self.current_item = str(index.text())

		asset_obj = self.project.get_body(self.current_item)
		element_obj = asset_obj.get_element(current_dept)
		last_publish = element_obj.get_last_publish()
		last_publish_comment = None
		if last_publish is not None:
			last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(last_publish[1], last_publish[0], last_publish[2])
		else:
			last_publish_comment = "No publishes for this element"
		currentTab = self.dept_tabs.currentWidget()

	def hasPreviousPublish(self, body, department):
		asset_obj = self.project.get_body(body)
		element_obj = asset_obj.get_element(department)
		last_publish = element_obj.get_last_publish()
		if last_publish is None:
			return False
		return True

	def assemble(self):
		"""
		Checks out the currently selected item
		:return:
		"""
		current_user = self.environment.get_current_username()
		current_dept = self.dept_list[self.dept_tabs.currentIndex()]

		# Make sure that the asset hasn't been assemble yet
		startAssembling = False
		if self.hasPreviousPublish(self.current_item, current_dept):
			startAssembling = message_gui.light_error("This asset has already been assembled for " + current_dept + ".\n Are you sure you want to assemble it again?")
		else:
			startAssembling = True

		if startAssembling is True:
			asset_obj = self.project.get_body(self.current_item)
			element_obj = asset_obj.get_element(current_dept)
			element_path = element_obj.checkout(current_user)
			if element_path != None:
				self.result = self.current_item
				self.close()
		else:
			return

	def closeEvent(self, event):
		self.finished.emit()
		event.accept()
Ejemplo n.º 14
0
class ReferenceWindow(QtGui.QWidget):
    
    finished = QtCore.pyqtSignal()
    
    def __init__(self, parent, src, dept_list=Department.ALL):
        super(ReferenceWindow, self).__init__()
        self.project = Project()
        self.parent = parent
        self.src = src
        self.filePath = None
        self.done = True
        self.reference = False
        self.initUI(dept_list)
        
    def initUI(self, dept_list):
        #define gui elements
        self.setGeometry(300,300,WINDOW_WIDTH,WINDOW_HEIGHT)
        self.setWindowTitle('Taijitu Reference Manager')
        self.departmentMenu = QtGui.QComboBox()
        for i in dept_list:
            self.departmentMenu.addItem(i)
        self.departmentMenu.activated[str].connect(self.setElementType)
        
        self.assetList = AssetListWindow(self)
        for asset in self.project.list_assets():
            item = QtGui.QListWidgetItem(asset)
            self.assetList.addItem(item)

        self.typeFilterLabel = QtGui.QLabel("Type Filter")
        self.typeFilterLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.typeFilter = QtGui.QComboBox()
        self.typeFilter.addItem("all")
        for i in AssetType.ALL:
            self.typeFilter.addItem(i)
            
        self.typeFilter.currentIndexChanged.connect(self.setElementType)
        self.referenceButton = QtGui.QPushButton('Reference')
        self.referenceButton.clicked.connect(self.createReference)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.close)
            
        #set gui layout
        self.grid = QtGui.QGridLayout(self)
        self.setLayout(self.grid)
        self.grid.addWidget(self.departmentMenu, 0, 0)
        self.grid.addWidget(self.assetList, 1, 0, 1, 0)
        self.grid.addWidget(self.typeFilterLabel, 2, 0)
        self.grid.addWidget(self.typeFilter, 2, 1)
        self.grid.addWidget(self.referenceButton, 3, 0)
        self.grid.addWidget(self.cancelButton, 3, 1)
        
        self.show()
        
    def setElementType(self, idx=0):
        department = str(self.departmentMenu.currentText())
        self.refreshList(department)
        
    def createReference(self):
        checkout = self.project.get_checkout(os.path.dirname(self.src))
        if checkout is not None:
            body_name = checkout.get_body_name()
            body = self.project.get_body(body_name)
            body.add_reference(self.assetList.current_selection)
        self.done = False
        self.reference = True
        self.close()

    def refreshList(self, department):
        if department in Department.FRONTEND:
            asset_filter = None
            if(self.typeFilter.currentIndex()):
                asset_filter_str = str(self.typeFilter.currentText())
                asset_filter = (Asset.TYPE, operator.eq, asset_filter_str)
            self.elements = self.project.list_assets(asset_filter)
        else:
            self.elements = self.project.list_shots()
            
        self.assetList.clear()
        for e in self.elements:
            self.assetList.addItem(e)
        
    def closeEvent(self, event):
        self.finished.emit()
        event.accept()
Ejemplo n.º 15
0
class CheckoutWindow(QtWidgets.QWidget):

    finished = QtCore.Signal()

    def __init__(self, parent, dept_list=Department.ALL):
        super(CheckoutWindow, self).__init__()
        self.parent = parent
        self.project = Project()
        self.environment = Environment()
        self.initUI(dept_list)

    def initUI(self, dept_list):
        #define gui elements
        self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
        self.setWindowTitle('Checkout')
        self.dept_tabs = QtWidgets.QTabWidget()
        self.dept_list = dept_list
        self.result = None

        #create checkbox to show only published assets
        self.show_published = QtWidgets.QCheckBox(
            "Display only assets or shots with previous publishes")
        self.show_published.setCheckState(QtCore.Qt.Unchecked)
        self.show_published.stateChanged.connect(
            self.changeBodyCheckoutVisibility)

        #create Tabs
        self.createTabs()

        #create buttons
        self.checkout_button = QtWidgets.QPushButton('Checkout')
        self.checkout_button.clicked.connect(self.checkout)
        self.cancel_button = QtWidgets.QPushButton('Cancel')
        self.cancel_button.clicked.connect(self.close)

        #create button layout
        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addWidget(self.checkout_button)
        button_layout.addWidget(self.cancel_button)

        self.img = QtWidgets.QLabel()
        banner_path = os.path.join(os.environ['BYU_TOOLS_DIR'], 'byugui',
                                   'assets', 'images', 'film-banner.jpg')
        pixmap = QtGui.QPixmap(banner_path)
        scaled = pixmap.scaledToWidth(self.size().width())
        self.img.setPixmap(scaled)

        #create main layout
        main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.addWidget(self.img)
        main_layout.setSpacing(5)
        # main_layout.setMargin(6)
        main_layout.addWidget(self.dept_tabs)
        main_layout.addWidget(self.show_published)
        main_layout.addLayout(button_layout)

        self.show()

    #Recursivly goes through the asset's file name
    def recurseTree(self, treeItem, array, asset):
        #This is for setting bottom level text attributes
        if len(array) == 0:
            treeItem.setText(1, asset)
            treeItem.setTextColor(0, "#3c83f9")
            font = QtGui.QFont()
            font.setPointSize(12)
            font.setBold(False)
            treeItem.setFont(0, font)
            return
        else:  #This is for setting parent level text attributes and settin up the structure
            item = QtWidgets.QTreeWidgetItem(array[0])
            item.setText(0, array[0])
            item.setText(1, "This is not a file")
            item.setTextColor(0, "#d0d0d0")
            font = QtGui.QFont()
            font.setPointSize(11)
            font.setBold(True)
            item.setFont(0, font)
            skip = False
            # this is to check if the child already exists
            for i in range(0, treeItem.childCount()):
                if treeItem.child(i).text(0) == item.text(0):
                    item = treeItem.child(i)
                    skip = True
            if skip == False:  # Executes if the child doesnt already exist
                treeItem.addChild(item)
            newArray = array[1:]
            self.recurseTree(item, newArray, asset)
        return

    def createTabs(self):
        #remember the current index so that we can restore it when we create the tabs
        currIndex = self.dept_tabs.currentIndex()
        #clear out the old tabs
        self.dept_tabs.clear()
        #create tabs
        for dept in self.dept_list:
            tab = DepartmentTab(self)
            self.dept_tabs.addTab(tab, dept)
            tab_layout = QtWidgets.QHBoxLayout()
            element_list = QtWidgets.QTreeWidget()
            element_list.setColumnCount(1)
            commentBox = QtWidgets.QTextEdit()
            commentBox.setReadOnly(False)
            tab.commentBox = commentBox

            if dept in Department.ASSET_DEPTS:
                for asset in self.project.list_assets():
                    #print(asset)
                    if not self.show_published.isChecked(
                    ) or self.hasPreviousPublish(asset, dept):
                        asset_array = asset.split("_")
                        firstelement = element_list.findItems(
                            asset_array[0], 0, 0)
                        if not firstelement:
                            item = QtWidgets.QTreeWidgetItem(asset_array[0])
                            item.setText(0, asset_array[0])
                            item.setTextColor(0, "#d0d0d0")
                            font = QtGui.QFont()
                            font.setPointSize(11)
                            font.setBold(True)
                            item.setFont(0, font)
                            self.recurseTree(item, asset_array[1:], asset)
                            element_list.insertTopLevelItem(0, item)
                        else:
                            self.recurseTree(firstelement[0], asset_array[1:],
                                             asset)
                        element_list.currentItemChanged.connect(
                            self.set_current_item)
            elif dept in Department.SHOT_DEPTS:
                for shot in self.project.list_shots():
                    #print(shot)
                    if not self.show_published.isChecked(
                    ) or self.hasPreviousPublish(shot, dept):
                        shot_array = shot.split("_")
                        firstelement = element_list.findItems(
                            shot_array[0], 0, 0)
                        if not firstelement:
                            item = QtWidgets.QTreeWidgetItem(shot_array[0])
                            item.setText(0, shot_array[0])
                            item.setTextColor(0, "#d0d0d0")
                            font = QtGui.QFont()
                            font.setPointSize(11)
                            font.setBold(True)
                            item.setFont(0, font)
                            self.recurseTree(item, shot_array[1:], shot)
                            element_list.insertTopLevelItem(0, item)
                        else:
                            self.recurseTree(firstelement[0], shot_array[1:],
                                             shot)
                        element_list.currentItemChanged.connect(
                            self.set_current_item)
            elif dept in Department.CROWD_DEPTS:
                for crowdCycle in self.project.list_crowd_cycles():
                    if not self.show_published.isChecked(
                    ) or self.hasPreviousPublish(crowdCycle, dept):
                        crowdCycle_array = crowdCycle.split("_")
                        firstelement = element_list.findItems(
                            crowdCycle_array[0], 0, 0)
                        if not firstelement:
                            item = QtWidgets.QTreeWidgetItem(
                                crowdCycle_array[0])
                            item.setText(0, crowdCycle_array[0])
                            item.setTextColor(0, "#d0d0d0")
                            font = QtGui.QFont()
                            font.setPointSize(11)
                            font.setBold(True)
                            item.setFont(0, font)
                            self.recurseTree(item, crowdCycle_array[1:],
                                             crowdCycle)
                            element_list.insertTopLevelItem(0, item)
                        else:
                            self.recurseTree(firstelement[0],
                                             crowdCycle_array[1:], crowdCycle)
                        element_list.currentItemChanged.connect(
                            self.set_current_item)
            tab_layout.addWidget(element_list)
            tab_layout.addWidget(commentBox)
            tab.setLayout(tab_layout)

        #restore the previous index
        self.dept_tabs.setCurrentIndex(currIndex)

    def hasPreviousPublish(self, body, department):
        asset_obj = self.project.get_body(body)
        element_obj = asset_obj.get_element(department)
        last_publish = element_obj.get_last_publish()
        if last_publish is None:
            return False
        return True

    def changeBodyCheckoutVisibility(self):
        #recreate tabs the with the new check option
        self.createTabs()

    def set_current_item(self, index):
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        if current_dept in Department.ASSET_DEPTS:
            self.current_item = str(index.text(1))
        elif current_dept in Department.SHOT_DEPTS:
            self.current_item = str(index.text(1))
        elif current_dept in Department.CROWD_DEPTS:
            self.current_item = str(index.text(1))
            #TODO what the heck? Why do we have three identical results from three different conditions? What are we trying to accomplish here? Admitadly the last one I added just following the crowd.

        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept)
        last_publish = element_obj.get_last_publish()
        last_publish_comment = None
        if last_publish is not None:
            last_publish_comment = "Last published {0} by {1} \n \"{2}\"".format(
                last_publish[1], last_publish[0], last_publish[2])
        else:
            last_publish_comment = "No publishes for this element"
        currentTab = self.dept_tabs.currentWidget()
        currentTab.commentBox.setText(last_publish_comment)

    def checkout(self):
        """
		Checks out the currently selected item
		:return:
		"""
        current_user = self.environment.get_current_username()
        current_dept = self.dept_list[self.dept_tabs.currentIndex()]
        asset_obj = self.project.get_body(self.current_item)
        element_obj = asset_obj.get_element(current_dept, force_create=True)
        element_path = element_obj.checkout(current_user)
        if element_path != None:
            self.result = element_path
            self.close()

    def closeEvent(self, event):
        self.finished.emit()
        event.accept()