Example #1
0
    def __init__(self, qnotero):
        """
		Constructor

		Arguments:
		qnotero -- a Qnotero instance
		"""

        QListWidget.__init__(self, qnotero)
        self.setMouseTracking(True)
Example #2
0
	def __init__(self, qnotero):

		"""
		Constructor

		Arguments:
		qnotero -- a Qnotero instance
		"""

		QListWidget.__init__(self, qnotero)
		self.setMouseTracking(True)
Example #3
0
    def __init__(self, qnotero):
        """
		Constructor

		Arguments:
		qnotero -- a Qnotero instance
		"""

        QListWidget.__init__(self, qnotero)
        self.itemDoubleClicked.connect(self.DoubleClicked)
        self.itemClicked.connect(self.Clicked)
        self.setMouseTracking(True)
Example #4
0
    def mousePressEvent(self, e):
        """
		Start a drag operation

		Arguments:
		e -- a QMouseEvent
		"""

        if e.button() == Qt.RightButton:
            item = self.itemAt(e.pos())
            if item == None:
                return
            note = item.zoteroItem.get_note()
            if note != None:
                self.qnotero.previewNote(note)
            return

        QListWidget.mousePressEvent(self, e)
        qnoteroItem = self.currentItem()
        if qnoteroItem == None:
            return
        if not hasattr(qnoteroItem, "zoteroItem"):
            return
        zoteroItem = qnoteroItem.zoteroItem
        if zoteroItem.fulltext == None:
            return

        path = zoteroItem.fulltext.encode("latin-1")
        tmpName = '%s.pdf' % zoteroItem.filename_format()
        tmpFile = os.path.join(tempfile.gettempdir(), tmpName)
        suffix = 1
        while os.path.exists(tmpFile):
            tmpName = '%s-%d.pdf' % (zoteroItem.filename_format(), suffix)
            tmpFile = os.path.join(tempfile.gettempdir(), tmpName)
            suffix += 1
        try:
            shutil.copy(path, tmpFile)
        except:
            print(
                "qnoteroResults.mousePressEvent(): failed to copy file, sorry..."
            )
            return

        print("qnoteroResults.mousePressEvent(): prepare to copy %s" % path)
        print("qnoteroResults.mousePressEvent(): prepare to copy (tmp) %s" \
         % tmpFile)
        mimeData = QMimeData()
        mimeData.setUrls([QUrl.fromLocalFile(tmpFile)])
        mimeData.setData("text/plain", tmpFile)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.exec_(Qt.CopyAction)
Example #5
0
	def mousePressEvent(self, e):

		"""
		Start a drag operation

		Arguments:
		e -- a QMouseEvent
		"""

		if e.button() == Qt.RightButton:
			item = self.itemAt(e.pos())
			if item == None:
				return
			note = item.zoteroItem.get_note()
			if note != None:
				self.qnotero.previewNote(note)
			return

		QListWidget.mousePressEvent(self, e)
		qnoteroItem = self.currentItem()
		if qnoteroItem == None:
			return
		if not hasattr(qnoteroItem, "zoteroItem"):
			return
		zoteroItem = qnoteroItem.zoteroItem
		if zoteroItem.fulltext == None:
			return
		
		path = zoteroItem.fulltext.encode("latin-1")
		tmpName = '%s.pdf' % zoteroItem.filename_format()
		tmpFile = os.path.join(tempfile.gettempdir(), tmpName)
		suffix = 1
		while os.path.exists(tmpFile):
			tmpName = '%s-%d.pdf' % (zoteroItem.filename_format(), suffix)
			tmpFile = os.path.join(tempfile.gettempdir(), tmpName)			
			suffix += 1
		try:
			shutil.copy(path, tmpFile)
		except:
			print("qnoteroResults.mousePressEvent(): failed to copy file, sorry...")
			return
			
		print("qnoteroResults.mousePressEvent(): prepare to copy %s" % path)
		print("qnoteroResults.mousePressEvent(): prepare to copy (tmp) %s" \
			% tmpFile)
		mimeData = QMimeData()
		mimeData.setUrls([QUrl.fromLocalFile(tmpFile)])
		mimeData.setData("text/plain", tmpFile)
		drag = QDrag(self)
		drag.setMimeData(mimeData)
		drag.exec_(Qt.CopyAction)
Example #6
0
    def keyPressEvent(self, e):
        """
		Handle key presses

		Arguments:
		e -- a QKeyEvent
		"""

        if (e.key() == Qt.Key_Up and self.currentRow() == 0) \
         or (e.key() == Qt.Key_F and Qt.ControlModifier & e.modifiers()):
            self.qnotero.ui.lineEditQuery.selectAll()
            self.qnotero.ui.lineEditQuery.setFocus()
            return
        QListWidget.keyPressEvent(self, e)
Example #7
0
	def keyPressEvent(self, e):

		"""
		Handle key presses

		Arguments:
		e -- a QKeyEvent
		"""

		if (e.key() == Qt.Key_Up and self.currentRow() == 0) \
			or (e.key() == Qt.Key_F and Qt.ControlModifier & e.modifiers()):
			self.qnotero.ui.lineEditQuery.selectAll()
			self.qnotero.ui.lineEditQuery.setFocus()
			return
		QListWidget.keyPressEvent(self, e)