def _merge_collections(self):
        '''
        '''
        self._log_location()

        # Merge the two collection lists without dupes
        cl = set(self._get_calibre_collections())
        ml = set(self._get_marvin_collections())
        deltas = ml - cl
        merged_collections = sorted(self._get_calibre_collections() + list(deltas), key=sort_key)

        # Clear both
        self.calibre_lw.clear()
        self.marvin_lw.clear()

        # Assign to both
        for ca in merged_collections:
            item = ListWidgetItem(ca)
            item.setData(Qt.UserRole, ca)
            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.calibre_lw.addItem(item)

            item = ListWidgetItem(ca)
            item.setData(Qt.UserRole, ca)
            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.marvin_lw.addItem(item)
Esempio n. 2
0
    def _merge_collections(self):
        '''
        '''
        self._log_location()

        # Merge the two collection lists without dupes
        cl = set(self._get_calibre_collections())
        ml = set(self._get_marvin_collections())
        deltas = ml - cl
        merged_collections = sorted(self._get_calibre_collections() +
                                    list(deltas),
                                    key=sort_key)

        # Clear both
        self.calibre_lw.clear()
        self.marvin_lw.clear()

        # Assign to both
        for ca in merged_collections:
            item = ListWidgetItem(ca)
            item.setData(Qt.UserRole, ca)
            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.calibre_lw.addItem(item)

            item = ListWidgetItem(ca)
            item.setData(Qt.UserRole, ca)
            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.marvin_lw.addItem(item)
Esempio n. 3
0
 def _import_from_marvin(self):
     '''
     Copy Marvin collections to calibre
     '''
     self._log_location()
     self.calibre_lw.clear()
     for i in range(self.marvin_lw.count()):
         mitem = self.marvin_lw.item(i).text()
         item = ListWidgetItem(mitem)
         item.setData(Qt.UserRole, mitem)
         item.setFlags(item.flags() | Qt.ItemIsEditable)
         self.calibre_lw.addItem(item)
Esempio n. 4
0
 def _export_to_marvin(self):
     '''
     Copy calibre assignments to Marvin
     '''
     self._log_location()
     self.marvin_lw.clear()
     for i in range(self.calibre_lw.count()):
         citem = self.calibre_lw.item(i).text()
         item = ListWidgetItem(citem)
         item.setData(Qt.UserRole, citem)
         item.setFlags(item.flags() | Qt.ItemIsEditable)
         self.marvin_lw.addItem(item)
 def _import_from_marvin(self):
     '''
     Copy Marvin collections to calibre
     '''
     self._log_location()
     self.calibre_lw.clear()
     for i in range(self.marvin_lw.count()):
         mitem = self.marvin_lw.item(i).text()
         item = ListWidgetItem(mitem)
         item.setData(Qt.UserRole, mitem)
         item.setFlags(item.flags() | Qt.ItemIsEditable)
         self.calibre_lw.addItem(item)
 def _export_to_marvin(self):
     '''
     Copy calibre assignments to Marvin
     '''
     self._log_location()
     self.marvin_lw.clear()
     for i in range(self.calibre_lw.count()):
         citem = self.calibre_lw.item(i).text()
         item = ListWidgetItem(citem)
         item.setData(Qt.UserRole, citem)
         item.setFlags(item.flags() | Qt.ItemIsEditable)
         self.marvin_lw.addItem(item)
    def __init__(self, parent, tag_to_match, data, key, connected_device):
        QDialog.__init__(self, parent.opts.gui)
        Ui_DeviceCategoryEditor.__init__(self)
        self.setupUi(self)
        self.connected_device = connected_device
        self.verbose = parent.opts.verbose

        # Subscribe to Marvin driver change events
        connected_device.marvin_device_signals.reader_app_status_changed.connect(
            self.marvin_status_changed)

        # Remove help icon on title bar
        self.setWindowFlags(self.windowFlags()
                            & (~Qt.WindowContextHelpButtonHint))
        self.setWindowIcon(
            QIcon(
                os.path.join(parent.opts.resources_path, 'icons',
                             'edit_collections.png')))
        self.setWindowTitle("Manage collections")
        self.label.setText("Active collections")

        self.to_rename = {}
        self.to_delete = set([])

        try:
            cc = set(data['calibre'])
        except:
            cc = set([])

        try:
            mc = set(data['Marvin'])
        except:
            mc = set([])

        merged = list(cc.union(mc))
        for tag in sorted(merged, key=key):
            item = ListWidgetItem(tag)
            item.setData(Qt.UserRole, tag)
            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.available_tags.addItem(item)

        self.delete_button.clicked.connect(self.delete_tags)
        self.rename_button.clicked.connect(self.rename_tag)
        self.available_tags.itemDoubleClicked.connect(self._rename_tag)
        self.available_tags.itemChanged.connect(self.finish_editing)
Esempio n. 8
0
    def _initialize_collections(self):
        '''
        Populate the data model with current collection assignments
        Hook click, doubleClick events
        '''
        self._log_location()

        # Set the bg color of the description text fields to the dialog bg color
        if False:
            bgcolor = self.palette().color(QPalette.Background)
            palette = QPalette()
            palette.setColor(QPalette.Base, bgcolor)
            self.calibre_lw.setPalette(palette)
            self.marvin_lw.setPalette(palette)

        if self.calibre_collections is not None:
            for ca in self.calibre_collections:
                item = ListWidgetItem(ca)
                item.setData(Qt.UserRole, ca)
                if RENAMING_ENABLED:
                    item.setFlags(item.flags() | Qt.ItemIsEditable)
                self.calibre_lw.addItem(item)

        for ma in self.marvin_collections:
            item = ListWidgetItem(ma)
            item.setData(Qt.UserRole, ma)
            if RENAMING_ENABLED:
                item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.marvin_lw.addItem(item)

        # Capture click events to clear selections in opposite list
        self.calibre_lw.clicked.connect(self._clear_marvin_selection)
        self.marvin_lw.clicked.connect(self._clear_calibre_selection)

        # Hook double-click events
        if RENAMING_ENABLED:
            self.calibre_lw.doubleClicked.connect(self.rename_calibre_tag)
            self.marvin_lw.doubleClicked.connect(self.rename_marvin_tag)

        # Enable sorting
        if self.calibre_collections is not None:
            self.calibre_lw.setSortingEnabled(True)
        self.marvin_lw.setSortingEnabled(True)
    def __init__(self, parent, tag_to_match, data, key, connected_device):
        QDialog.__init__(self, parent.opts.gui)
        Ui_DeviceCategoryEditor.__init__(self)
        self.setupUi(self)
        self.connected_device = connected_device
        self.verbose = parent.opts.verbose

        # Subscribe to Marvin driver change events
        connected_device.marvin_device_signals.reader_app_status_changed.connect(
            self.marvin_status_changed)

        # Remove help icon on title bar
        self.setWindowFlags(self.windowFlags() & (~Qt.WindowContextHelpButtonHint))
        self.setWindowIcon(QIcon(os.path.join(parent.opts.resources_path,
                                 'icons',
                                 'edit_collections.png')))
        self.setWindowTitle("Manage collections")
        self.label.setText("Active collections")

        self.to_rename = {}
        self.to_delete = set([])

        try:
            cc = set(data['calibre'])
        except:
            cc = set([])

        try:
            mc = set(data['Marvin'])
        except:
            mc = set([])

        merged = list(cc.union(mc))
        for tag in sorted(merged, key=key):
            item = ListWidgetItem(tag)
            item.setData(Qt.UserRole, tag)
            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.available_tags.addItem(item)

        self.delete_button.clicked.connect(self.delete_tags)
        self.rename_button.clicked.connect(self.rename_tag)
        self.available_tags.itemDoubleClicked.connect(self._rename_tag)
        self.available_tags.itemChanged.connect(self.finish_editing)
    def _initialize_collections(self):
        '''
        Populate the data model with current collection assignments
        Hook click, doubleClick events
        '''
        self._log_location()

        # Set the bg color of the description text fields to the dialog bg color
        if False:
            bgcolor = self.palette().color(QPalette.Background)
            palette = QPalette()
            palette.setColor(QPalette.Base, bgcolor)
            self.calibre_lw.setPalette(palette)
            self.marvin_lw.setPalette(palette)

        if self.calibre_collections is not None:
            for ca in self.calibre_collections:
                item = ListWidgetItem(ca)
                item.setData(Qt.UserRole, ca)
                if RENAMING_ENABLED:
                    item.setFlags(item.flags() | Qt.ItemIsEditable)
                self.calibre_lw.addItem(item)

        for ma in self.marvin_collections:
            item = ListWidgetItem(ma)
            item.setData(Qt.UserRole, ma)
            if RENAMING_ENABLED:
                item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.marvin_lw.addItem(item)

        # Capture click events to clear selections in opposite list
        self.calibre_lw.clicked.connect(self._clear_marvin_selection)
        self.marvin_lw.clicked.connect(self._clear_calibre_selection)

        # Hook double-click events
        if RENAMING_ENABLED:
            self.calibre_lw.doubleClicked.connect(self.rename_calibre_tag)
            self.marvin_lw.doubleClicked.connect(self.rename_marvin_tag)

        # Enable sorting
        if self.calibre_collections is not None:
            self.calibre_lw.setSortingEnabled(True)
        self.marvin_lw.setSortingEnabled(True)