def launch_cc_wizard(self, column_type):
        '''
        '''
        self._log_location()
        dialog_resources_path = os.path.join(self.parent.resources_path, 'widgets')
        klass = os.path.join(dialog_resources_path, 'cc_wizard.py')
        if os.path.exists(klass):
            #self._log("importing CC Wizard dialog from '%s'" % klass)
            sys.path.insert(0, dialog_resources_path)
            this_dc = importlib.import_module('cc_wizard')
            sys.path.remove(dialog_resources_path)
            dlg = this_dc.CustomColumnWizard(self,
                                             column_type,
                                             self.WIZARD_PROFILES[column_type],
                                             verbose=True)
            dlg.exec_()

            if dlg.modified_column:
                self._log("modified_column: %s" % dlg.modified_column)

                destination = dlg.modified_column['destination']
                label = dlg.modified_column['label']
                previous = dlg.modified_column['previous']
                source = dlg.modified_column['source']

                if source == 'Collections':
                    all_items = [str(self.collections_comboBox.itemText(i))
                                 for i in range(self.collections_comboBox.count())]
                    if previous and previous in all_items:
                        all_items.remove(previous)
                    all_items.append(destination)

                    self.collections_comboBox.clear()
                    self.collections_comboBox.addItems(sorted(all_items, key=lambda s: s.lower()))
                    idx = self.collections_comboBox.findText(destination)
                    if idx > -1:
                        self.collections_comboBox.setCurrentIndex(idx)

                    # Save Collection field manually in case user cancels
                    set_cc_mapping('marvin_collections', combobox=destination, field=label)

                if source == 'Word count':
                    all_items = [str(self.word_count_comboBox.itemText(i))
                                 for i in range(self.word_count_comboBox.count())]
                    if previous and previous in all_items:
                        all_items.remove(previous)
                    all_items.append(destination)

                    self.word_count_comboBox.clear()
                    self.word_count_comboBox.addItems(sorted(all_items, key=lambda s: s.lower()))
                    idx = self.word_count_comboBox.findText(destination)
                    if idx > -1:
                        self.word_count_comboBox.setCurrentIndex(idx)

                    # Save Word count field manually in case user cancels
                    set_cc_mapping('marvin_word_count', combobox=destination, field=label)
 def collections_selection_changed(self, value):
     '''
     '''
     cf = unicode(self.collections_comboBox.currentText())
     field = None
     if cf:
         datatype = self.WIZARD_PROFILES['Collections']['datatype']
         eligible_collection_fields = self.get_eligible_custom_fields([datatype])
         field = eligible_collection_fields[cf]
     set_cc_mapping('marvin_collections', combobox=cf, field=field)
 def collections_selection_changed(self, value):
     '''
     '''
     cf = unicode(self.collections_comboBox.currentText())
     field = None
     if cf:
         datatype = self.WIZARD_PROFILES['Collections']['datatype']
         eligible_collection_fields = self.get_eligible_custom_fields(
             [datatype])
         field = eligible_collection_fields[cf]
     set_cc_mapping('marvin_collections', combobox=cf, field=field)
 def word_count_selection_changed(self, value):
     '''
     Store both the displayed field name and lookup value to prefs
     '''
     cf = unicode(self.word_count_comboBox.currentText())
     field = None
     if cf:
         datatype = self.WIZARD_PROFILES['Word count']['datatype']
         eligible_word_count_fields = self.get_eligible_custom_fields([datatype])
         field = eligible_word_count_fields[cf]
     set_cc_mapping('marvin_word_count', combobox=cf, field=field)
 def word_count_selection_changed(self, value):
     '''
     Store both the displayed field name and lookup value to prefs
     '''
     cf = unicode(self.word_count_comboBox.currentText())
     field = None
     if cf:
         datatype = self.WIZARD_PROFILES['Word count']['datatype']
         eligible_word_count_fields = self.get_eligible_custom_fields(
             [datatype])
         field = eligible_word_count_fields[cf]
     set_cc_mapping('marvin_word_count', combobox=cf, field=field)
    def launch_cc_wizard(self, column_type):
        '''
        '''
        self._log_location()
        dialog_resources_path = os.path.join(self.parent.resources_path,
                                             'widgets')
        klass = os.path.join(dialog_resources_path, 'cc_wizard.py')
        if os.path.exists(klass):
            #self._log("importing CC Wizard dialog from '%s'" % klass)
            sys.path.insert(0, dialog_resources_path)
            this_dc = importlib.import_module('cc_wizard')
            sys.path.remove(dialog_resources_path)
            dlg = this_dc.CustomColumnWizard(self,
                                             column_type,
                                             self.WIZARD_PROFILES[column_type],
                                             verbose=True)
            dlg.exec_()

            if dlg.modified_column:
                self._log("modified_column: %s" % dlg.modified_column)

                destination = dlg.modified_column['destination']
                label = dlg.modified_column['label']
                previous = dlg.modified_column['previous']
                source = dlg.modified_column['source']

                if source == 'Collections':
                    all_items = [
                        str(self.collections_comboBox.itemText(i))
                        for i in range(self.collections_comboBox.count())
                    ]
                    if previous and previous in all_items:
                        all_items.remove(previous)
                    all_items.append(destination)

                    self.collections_comboBox.blockSignals(True)
                    self.collections_comboBox.clear()
                    self.collections_comboBox.addItems(
                        sorted(all_items, key=lambda s: s.lower()))
                    idx = self.collections_comboBox.findText(destination)
                    if idx > -1:
                        self.collections_comboBox.setCurrentIndex(idx)
                    self.collections_comboBox.blockSignals(False)

                    # Save Collection field manually in case user cancels
                    set_cc_mapping('marvin_collections',
                                   combobox=destination,
                                   field=label)

                if source == 'Locked':
                    all_items = [
                        str(self.locked_comboBox.itemText(i))
                        for i in range(self.locked_comboBox.count())
                    ]
                    if previous and previous in all_items:
                        all_items.remove(previous)
                    all_items.append(destination)

                    self.locked_comboBox.blockSignals(True)
                    self.locked_comboBox.clear()
                    self.locked_comboBox.addItems(
                        sorted(all_items, key=lambda s: s.lower()))
                    idx = self.locked_comboBox.findText(destination)
                    if idx > -1:
                        self.locked_comboBox.setCurrentIndex(idx)
                    self.locked_comboBox.blockSignals(False)

                    # Save Locked field manually in case user cancels
                    set_cc_mapping('marvin_locked',
                                   combobox=destination,
                                   field=label)

                if source == 'Word count':
                    all_items = [
                        str(self.word_count_comboBox.itemText(i))
                        for i in range(self.word_count_comboBox.count())
                    ]
                    if previous and previous in all_items:
                        all_items.remove(previous)
                    all_items.append(destination)

                    self.word_count_comboBox.blockSignals(True)
                    self.word_count_comboBox.clear()
                    self.word_count_comboBox.addItems(
                        sorted(all_items, key=lambda s: s.lower()))
                    idx = self.word_count_comboBox.findText(destination)
                    if idx > -1:
                        self.word_count_comboBox.setCurrentIndex(idx)
                    self.word_count_comboBox.blockSignals(False)

                    # Save Word count field manually in case user cancels
                    set_cc_mapping('marvin_word_count',
                                   combobox=destination,
                                   field=label)