Exemplo n.º 1
0
class EntriesDlg(QDialog):
    def __init__(self, tadokulog):
        QDialog.__init__(self)

        self.tadokulog = tadokulog

        # Initiate Ui
        self.ui = Ui_EntriesDlg()
        self.ui.setupUi(self)
        self.ui.entriesTable.setRowCount(1)
        self.ui.removeButton.clicked.connect(self.removeEntry)

        self.updateEntries()
        self.exec_()

    def updateEntries(self):
        # Fill the entry table from the tadoku log.
        row = 0

        entries = self.tadokulog.sortChrono()

        if not entries:
            self.ui.entriesTable.clearContents()

        #Turn off sorting so each entry will be placed together on the same row.
        self.ui.entriesTable.setSortingEnabled(False)

        # Expand table to fit.
        self.ui.entriesTable.setRowCount(len(entries))

        for item in entries:
            col = 0
            while col < 3:
                widgetitem = QTableWidgetItem(str(item[col]))
                widgetitem.setText(str(item[col]))
                self.ui.entriesTable.setItem(row, col, widgetitem)
                col += 1
            row += 1

        # Turn sorting back on.
        self.ui.entriesTable.setSortingEnabled(True)

    def removeEntry(self):
        # Remove the currently selected entry from the log.
        row = self.ui.entriesTable.currentRow()

        # Convert the string data back into a timestamp.
        t = self.ui.entriesTable.item(row, 0)
        timestamp = datetime.datetime.strptime(str(t.text()),
                                               "%Y-%m-%d %H:%M:%S.%f")

        # Undo entry and refresh the table.
        self.tadokulog.undoEntry(timestamp)
        self.updateEntries()

        logging.info("Entry removed.")
Exemplo n.º 2
0
class EntriesDlg(QDialog):

    def __init__(self, tadokulog):
        QDialog.__init__(self)

        self.tadokulog = tadokulog

        # Initiate Ui
        self.ui = Ui_EntriesDlg()
        self.ui.setupUi(self)
        self.ui.entriesTable.setRowCount(1)
        self.ui.removeButton.clicked.connect(self.removeEntry)

        self.updateEntries()
        self.exec_()

    def updateEntries(self):
        # Fill the entry table from the tadoku log.
        row = 0

        entries = self.tadokulog.sortChrono()

        if not entries:
            self.ui.entriesTable.clearContents()

        #Turn off sorting so each entry will be placed together on the same row.
        self.ui.entriesTable.setSortingEnabled(False)

        # Expand table to fit.
        self.ui.entriesTable.setRowCount(len(entries))

        for item in entries:
            col = 0
            while col < 3:
                widgetitem = QTableWidgetItem(str(item[col]))
                widgetitem.setText(str(item[col]))
                self.ui.entriesTable.setItem(row, col, widgetitem)
                col += 1
            row += 1
            
        # Turn sorting back on.
        self.ui.entriesTable.setSortingEnabled(True)
        
    def removeEntry(self):
        # Remove the currently selected entry from the log.
        row = self.ui.entriesTable.currentRow()

        # Convert the string data back into a timestamp.
        t = self.ui.entriesTable.item(row, 0)
        timestamp = datetime.datetime.strptime(str(t.text()), "%Y-%m-%d %H:%M:%S.%f")

        # Undo entry and refresh the table.
        self.tadokulog.undoEntry(timestamp)
        self.updateEntries()

        logging.info("Entry removed.")
Exemplo n.º 3
0
    def __init__(self, tadokulog):
        QDialog.__init__(self)

        self.tadokulog = tadokulog

        # Initiate Ui
        self.ui = Ui_EntriesDlg()
        self.ui.setupUi(self)
        self.ui.entriesTable.setRowCount(1)
        self.ui.removeButton.clicked.connect(self.removeEntry)

        self.updateEntries()
        self.exec_()
Exemplo n.º 4
0
    def __init__(self, tadokulog):
        QDialog.__init__(self)

        self.tadokulog = tadokulog

        # Initiate Ui
        self.ui = Ui_EntriesDlg()
        self.ui.setupUi(self)
        self.ui.entriesTable.setRowCount(1)
        self.ui.removeButton.clicked.connect(self.removeEntry)

        self.updateEntries()
        self.exec_()