Beispiel #1
0
    def fill_process_combo_box(self, process_dict, current_process=None):
        if current_process:
            current_process = current_process.get('name')

        builtin_processes = ['publish', 'icon', 'attachment']

        if process_dict:
            process_list = process_dict.keys()
        else:
            process_list = builtin_processes

        if gf.get_value_from_config(cfg_controls.get_checkin(), 'showAllProcessCheckBox') == 1:
            show_builtins = True
        else:
            show_builtins = False

        if show_builtins:
            for builtin_process in builtin_processes:
                if builtin_process not in process_list:
                    process_list.append(builtin_process)

        self.processComboBox.clear()
        for i, process in enumerate(process_list):
            self.processComboBox.addItem(process)
            if current_process and current_process == process:
                self.processComboBox.setCurrentIndex(i)
Beispiel #2
0
    def create_control_buttons(self):
        self.addNewButton = QtGui.QPushButton('Create')
        self.addNewButton.setMaximumWidth(80)
        self.saveButton = QtGui.QPushButton('Save')
        self.saveButton.setMaximumWidth(80)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.setMaximumWidth(80)
        self.buildDirectoryButton = QtGui.QPushButton('Build Full Directory Structure')
        self.buildDirectoryButton.setIcon(gf.get_icon('database'))
        self.build_directory_checkbox = QtGui.QCheckBox('Build Full Directory Structure')
        self.build_directory_checkbox.setChecked(False)
        self.build_directory_checkbox.setIcon(gf.get_icon('database'))

        self.repositoryComboBox = QtGui.QComboBox()
        base_dirs = env_tactic.get_all_base_dirs()
        # Default repo states
        current_repo = gf.get_value_from_config(cfg_controls.get_checkin(), 'repositoryComboBox')
        for key, val in base_dirs:
            if val['value'][4]:
                self.repositoryComboBox.addItem(val['value'][1])
                self.repositoryComboBox.setItemData(self.repositoryComboBox.count() - 1, val)

        # Special for build all repos dirs
        self.repositoryComboBox.addItem('All Repos')

        if current_repo:
            self.repositoryComboBox.setCurrentIndex(current_repo)

        if self.tactic_widget.view == 'insert':
            self.main_layout.addWidget(self.build_directory_checkbox, 1, 0, 1, 1)
            self.main_layout.addWidget(self.repositoryComboBox, 1, 1, 1, 1)
            spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            self.main_layout.addItem(spacerItem, 1, 2, 1, 1)
            self.main_layout.addWidget(self.addNewButton, 1, 3, 1, 1)
            self.main_layout.addWidget(self.cancelButton, 1, 4, 1, 1)
            self.main_layout.setColumnStretch(1, 0)
        else:
            self.main_layout.addWidget(self.buildDirectoryButton, 1, 0, 1, 1)
            self.main_layout.addWidget(self.repositoryComboBox, 1, 1, 1, 1)
            spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            self.main_layout.addItem(spacerItem, 1, 2, 1, 1)
            self.main_layout.addWidget(self.saveButton, 1, 3, 1, 1)
            self.main_layout.addWidget(self.cancelButton, 1, 4, 1, 1)
            self.main_layout.setColumnStretch(1, 0)

        if self.item:
            if self.item.type != 'sobject':
                self.buildDirectoryButton.setHidden(True)
                self.repositoryComboBox.setHidden(True)
    def fill_repo_combo_box(self):

        self.repo_combo_box.clear()

        base_dirs = env_tactic.get_all_base_dirs()

        for key, val in base_dirs:
            if val['value'][4]:
                self.repo_combo_box.addItem(val['value'][1])
                self.repo_combo_box.setItemData(self.repo_combo_box.count() - 1, val)

        current_repo = gf.get_value_from_config(cfg_controls.get_checkin(), 'repositoryComboBox')

        if current_repo:
            self.repo_combo_box.setCurrentIndex(current_repo)
    def fill_repo_combo_box(self, exlude_list=None):

        self.repo_combo_box.clear()

        if not exlude_list:
            exlude_list = []

        base_dirs = env_tactic.get_all_base_dirs()

        # Default repo states
        for key, val in base_dirs:
            if val['value'][4] and val['value'][3] not in exlude_list:
                self.repo_combo_box.addItem(val['value'][1])
                self.repo_combo_box.setItemData(self.repo_combo_box.count() - 1, val)

        self.repo_combo_box.addItem('All Repos')

        current_repo = gf.get_value_from_config(cfg_controls.get_checkin(), 'repositoryComboBox')

        if current_repo:
            self.repo_combo_box.setCurrentIndex(current_repo)
    def open_file_from_tree(self, index=None):

        if gf.get_value_from_config(cfg_controls.get_checkin(), 'checkoutMethodComboBox') == 0:
            checkout_method = 'local'
        else:
            checkout_method = 'http'

        item = self.filesTreeWidget.currentItem()
        file_object = item.data(0, QtCore.Qt.UserRole)

        if checkout_method == 'http':
            repo_sync_widget = env_inst.ui_repo_sync_queue.schedule_file_object(file_object)

            # preventing double opening of the file
            connected = False
            if not connected:
                repo_sync_widget.downloaded.connect(file_object.open_file)
                connected = True
            repo_sync_widget.download()

        elif checkout_method == 'local':
            file_object.open_file()
    def open_file_from_graphics_view(self):
        if self.file_list:

            if gf.get_value_from_config(cfg_controls.get_checkin(), 'checkoutMethodComboBox') == 0:
                checkout_method = 'local'
            else:
                checkout_method = 'http'

            file_object = self.file_list[self.current_pix]

            if checkout_method == 'http':
                repo_sync_widget = env_inst.ui_repo_sync_queue.schedule_file_object(file_object)

                # preventing double opening of the file
                connected = False
                if not connected:
                    repo_sync_widget.downloaded.connect(file_object.open_file)
                    connected = True
                repo_sync_widget.download()

            elif checkout_method == 'local':
                file_object.open_file()
    def fill_files_tree(self):
        self.filesTreeWidget.clear()

        show_more_info = self.showMoreInfoCheckBox.isChecked()
        show_all_files = self.showAllCheckBox.isChecked()
        if not show_more_info:
            self.filesTreeWidget.setHeaderHidden(True)
            self.filesTreeWidget.setColumnCount(1)
        else:
            self.filesTreeWidget.setHeaderHidden(False)
            self.filesTreeWidget.setColumnCount(5)

        icon_provider = QtGui.QFileIconProvider()
        known_icon_ext = {}
        if self.snapshots:

            # Making versionless on top of tree
            if self.item_widget.type == 'snapshot':
                if self.item_widget.is_versionless():
                    versionless_snapshot = self.item_widget.get_snapshot()
                    if versionless_snapshot and versionless_snapshot not in self.snapshots:
                        self.snapshots.insert(0, versionless_snapshot)

            for snapshot in self.snapshots:
                snapshot_info = snapshot.get_snapshot()
                snapshot_files_objects = snapshot.get_files_objects(group_by='type')

                if show_all_files:
                    sn_item = QtGui.QTreeWidgetItem()
                    sn_item.setText(0, 'Snapshot ({0}), Version: {1}'.format(snapshot_info.get('id'), snapshot_info.get('version')))
                    self.filesTreeWidget.addTopLevelItem(sn_item)
                    sn_item.setExpanded(True)

                # Download from http
                for file_type, files_objects in snapshot_files_objects.items():
                    for file_object in files_objects:

                        if gf.get_value_from_config(cfg_controls.get_checkin(), 'getPreviewsThroughHttpCheckbox') == 1:
                            if file_type in ['icon', 'playblast', 'web', 'image']:
                                if file_object.is_exists():
                                    if file_object.get_file_size() != file_object.get_file_size(True):
                                        self.download_web_preview(file_object)
                                else:
                                    self.download_web_preview(file_object)

                preview = []
                if not show_all_files:
                    preview = ['icon', 'playblast', 'web']

                # Adding files to tree
                for i, (file_type, files_objects) in enumerate(snapshot_files_objects.items()):
                    type_item = QtGui.QTreeWidgetItem()
                    if file_type not in preview:
                        if show_all_files:
                            type_item.setText(0, file_type)
                            sn_item.addChild(type_item)
                            type_item.setExpanded(True)

                        for file_object in files_objects:

                            # removing unnecessary calls to icon provider
                            file_ext = file_object.get_ext()
                            if known_icon_ext.get(file_ext):
                                file_icon = known_icon_ext[file_ext]
                            else:
                                file_icon = icon_provider.icon(file_object.get_full_abs_path())
                                known_icon_ext[file_ext] = file_icon

                            # multiple files in snapshot
                            if file_object.is_meta_file_obj():
                                self.add_item_with_meta_file_object(file_object, show_more_info, show_all_files, snapshot_info, type_item, file_icon)
                            else:
                                self.add_item_with_tactic_file_object(file_object, show_more_info, show_all_files, snapshot_info, type_item, file_icon)

            self.filesTreeWidget.resizeColumnToContents(0)
            if show_more_info:
                self.filesTreeWidget.resizeColumnToContents(1)
                self.filesTreeWidget.resizeColumnToContents(2)
                self.filesTreeWidget.resizeColumnToContents(4)
                self.filesTreeWidget.resizeColumnToContents(5)