Exemplo n.º 1
0
    def onRightClick(self,position):
        from citco import scraper

        item = self.itemAt(position)
        if item:
            menu = QtGui.QMenu()
            delAction = menu.addAction("Delete record")
            getPdfAction = menu.addAction("Download pdf")
            openPdfAction = menu.addAction("Open pdf")
            attachPdfAction = menu.addAction("Attach pdf")
            action = menu.exec_(self.mapToGlobal(position))
            if action == delAction:
                idx = self.indexOfTopLevelItem(item)
                self.takeTopLevelItem(idx)
                scraper.remove_from_library(item.record)
            elif action == getPdfAction: 
                results = scraper.download_pdf(item.record,force_overwrite=True)
                if results:
                    choice,ok = QtGui.QInputDialog.getItem(self,'Multiple PDFs found','Choose one:',results,editable=False)
                    choice_idx = results.index(choice)
                    scraper.download_pdf(item.record,pdf_choice=choice_idx,force_overwrite=True)
                self.updatePDFIcon(item)
            elif action == openPdfAction: scraper.display_pdf(item.record)
            elif action == attachPdfAction:
                src_file = QtGui.QFileDialog.getOpenFileName()
                if src_file:
                    scraper.attach_pdf(item.record,src_file,force_overwrite=True)
                    self.updatePDFIcon(item)
Exemplo n.º 2
0
 def onDblClick(self,item,col):
     from citco import scraper
     scraper.display_pdf(item.record)