from PyQt5 import QtWidgets

class dropEdit(QtWidgets.QLineEdit):
    def __init__(self, _showTextOnDrop, **kwargs):
        super().__init__(**kwargs)

        self.showTextOnDrop = _showTextOnDrop
        self.colSource = None
        

    ####################
    #    Overloadeds
    ####################
    
    # DragEnter: check if is plain text

    def dragEnterEvent(self, event):
        if event.mimeData().hasFormat("text/plain"):
            # TODO: add a regExpress check condition
            event.acceptProposedAction()


    # Drop: parse text to store tuple

    def dropEvent(self, event):
        # Take out the info
        text = event.mimeData().text()
        pos1 = text.find(",")
        pos2 = text.rfind(",")
        fileName = text[:pos1]
        sheetName = text[pos1+1:pos2]
        colName = text[pos2+1:]

        # Store tuple to block
        self.colSource = fileName, sheetName, colName

        # Set text
        if self.showTextOnDrop:
            self.setText(colName)

        print("drop source: {0}".format(self.colSource))
        event.acceptProposedAction()


9a736a29935dcf6a8060baa25e72de0e53ea08f5
<mask token>


class dropEdit(QtWidgets.QLineEdit):
    <mask token>
    <mask token>

    def dropEvent(self, event):
        text = event.mimeData().text()
        pos1 = text.find(',')
        pos2 = text.rfind(',')
        fileName = text[:pos1]
        sheetName = text[pos1 + 1:pos2]
        colName = text[pos2 + 1:]
        self.colSource = fileName, sheetName, colName
        if self.showTextOnDrop:
            self.setText(colName)
        print('drop source: {0}'.format(self.colSource))
        event.acceptProposedAction()

<mask token>


class dropEdit(QtWidgets.QLineEdit):
    <mask token>

    def dragEnterEvent(self, event):
        if event.mimeData().hasFormat('text/plain'):
            event.acceptProposedAction()

    def dropEvent(self, event):
        text = event.mimeData().text()
        pos1 = text.find(',')
        pos2 = text.rfind(',')
        fileName = text[:pos1]
        sheetName = text[pos1 + 1:pos2]
        colName = text[pos2 + 1:]
        self.colSource = fileName, sheetName, colName
        if self.showTextOnDrop:
            self.setText(colName)
        print('drop source: {0}'.format(self.colSource))
        event.acceptProposedAction()

<mask token>


class dropEdit(QtWidgets.QLineEdit):

    def __init__(self, _showTextOnDrop, **kwargs):
        super().__init__(**kwargs)
        self.showTextOnDrop = _showTextOnDrop
        self.colSource = None

    def dragEnterEvent(self, event):
        if event.mimeData().hasFormat('text/plain'):
            event.acceptProposedAction()

    def dropEvent(self, event):
        text = event.mimeData().text()
        pos1 = text.find(',')
        pos2 = text.rfind(',')
        fileName = text[:pos1]
        sheetName = text[pos1 + 1:pos2]
        colName = text[pos2 + 1:]
        self.colSource = fileName, sheetName, colName
        if self.showTextOnDrop:
            self.setText(colName)
        print('drop source: {0}'.format(self.colSource))
        event.acceptProposedAction()

from PyQt5 import QtWidgets


class dropEdit(QtWidgets.QLineEdit):

    def __init__(self, _showTextOnDrop, **kwargs):
        super().__init__(**kwargs)
        self.showTextOnDrop = _showTextOnDrop
        self.colSource = None

    def dragEnterEvent(self, event):
        if event.mimeData().hasFormat('text/plain'):
            event.acceptProposedAction()

    def dropEvent(self, event):
        text = event.mimeData().text()
        pos1 = text.find(',')
        pos2 = text.rfind(',')
        fileName = text[:pos1]
        sheetName = text[pos1 + 1:pos2]
        colName = text[pos2 + 1:]
        self.colSource = fileName, sheetName, colName
        if self.showTextOnDrop:
            self.setText(colName)
        print('drop source: {0}'.format(self.colSource))
        event.acceptProposedAction()

from PyQt5 import QtWidgets

class dropEdit(QtWidgets.QLineEdit):
    def __init__(self, _showTextOnDrop, **kwargs):
        super().__init__(**kwargs)

        self.showTextOnDrop = _showTextOnDrop
        self.colSource = None
        

    ####################
    #    Overloadeds
    ####################
    
    # DragEnter: check if is plain text

    def dragEnterEvent(self, event):
        if event.mimeData().hasFormat("text/plain"):
            # TODO: add a regExpress check condition
            event.acceptProposedAction()


    # Drop: parse text to store tuple

    def dropEvent(self, event):
        # Take out the info
        text = event.mimeData().text()
        pos1 = text.find(",")
        pos2 = text.rfind(",")
        fileName = text[:pos1]
        sheetName = text[pos1+1:pos2]
        colName = text[pos2+1:]

        # Store tuple to block
        self.colSource = fileName, sheetName, colName

        # Set text
        if self.showTextOnDrop:
            self.setText(colName)

        print("drop source: {0}".format(self.colSource))
        event.acceptProposedAction()

