Example #1
0
    def addCat(self):
        """ When button pressed, add a new category.
        Note: the addItem dialog does the checking for duplicate category names """

        Dialog_addCat = QtGui.QDialog()
        ui = Ui_Dialog_addItem(self.cats)
        ui.setupUi(Dialog_addCat, "Category")
        Dialog_addCat.exec_()
        newCatText = ui.getNewItem()
        if newCatText is not None:
            #add to database
            # need to generate a new id as the RQDA database does not have an autoincrement id field
            newid = 1
            for cat in self.cats:
                if cat['catid'] >= newid:
                    newid = cat['catid']+1
            item = {'name':newCatText.encode('raw_unicode_escape'),'cid':None, 'catid':newid, 'memo':"", 'owner':self.settings['codername'], 'date':datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y"), 'dateM':"", 'status':1}
            self.cats.append(item)
            cur = self.settings['conn'].cursor()
            cur.execute("insert into codecat (name, cid, catid, memo, owner, date, dateM, status) values(?,?,?,?,?,?,?,?)"
                        ,(item['name'], item['cid'], item['catid'],item['memo'],item['owner'],item['date'],item['dateM'],item['status']))
            self.settings['conn'].commit()

            #update widget
            self.tableWidget_cats.insertRow(0)
            newItem = QtGui.QTableWidgetItem(item['name'])
            self.tableWidget_cats.setItem(0, self.CAT_NAME_COLUMN, newItem)
            newItem = QtGui.QTableWidgetItem(item['memo'])
            self.tableWidget_cats.setItem(0, self.CAT_MEMO_COLUMN, newItem)
            newItem = QtGui.QTableWidgetItem(str(item['catid']))
            self.tableWidget_cats.setItem(0, self.CAT_ID_COLUMN, newItem)
            self.tableWidget_cats.resizeColumnsToContents()
            self.tableWidget_cats.resizeRowsToContents()
Example #2
0
    def addCase(self):
        """ When add case button pressed, open addItem dialog to get new case text.
        AddItem dialog checks for duplicate case name.
        New case is added to the model and database """

        Dialog_addCase = QtGui.QDialog()
        ui = Ui_Dialog_addItem(self.cases)
        ui.setupUi(Dialog_addCase, "Case")
        Dialog_addCase.exec_()
        newCaseText = ui.getNewItem()
        if newCaseText is not None:
            #update case list and database
            # need to generate a new id as the RQDA database does not have an autoincrement id field
            newid = 1
            for fc in self.cases:
                if fc['id'] >= newid: newid = fc['id']+1
            item = {'name':newCaseText.encode('raw_unicode_escape'), 'memo':"", 'owner':self.settings['codername'],
                     'date':datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y"), 'dateM':"", 'id':newid, 'status':1}
            self.cases.append(item)
            cur = self.settings['conn'].cursor()
            cur.execute("insert into cases (name,memo,owner,date,dateM,id,status) values(?,?,?,?,?,?,?)"
                        ,(item['name'],item['memo'],item['owner'],item['date'],item['dateM'],item['id'],item['status']))
            self.settings['conn'].commit()

            #update table widget
            for c in self.cases:
                self.tableWidget_cases.removeRow(0)
            self.fillTableWidget_cases()
Example #3
0
    def addCode(self):
        """ open addItem dialog to get new code text.
        AddItem dialog checks for duplicate code name.
        New code is added to the model and database """

        Dialog_addCode = QtGui.QDialog()
        ui = Ui_Dialog_addItem(self.freecode)
        ui.setupUi(Dialog_addCode, "Code")
        Dialog_addCode.exec_()
        newCodeText = ui.getNewItem()
        if newCodeText is not None:
            # update freecode list and database
            # need to generate a new id as the RQDA database does not have an autoincrement id field
            newid = 1
            for fc in self.freecode:
                if fc["id"] >= newid:
                    newid = fc["id"] + 1
            item = {
                "name": newCodeText.decode("utf-8"),
                "memo": "",
                "owner": self.settings["codername"],
                "date": datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y"),
                "dateM": "",
                "id": newid,
                "status": 1,
                "color": "",
            }
            self.freecode.append(item)
            cur = self.settings["conn"].cursor()
            cur.execute(
                "insert into freecode (name,memo,owner,date,dateM,id,status,color) values(?,?,?,?,?,?,?,?)",
                (
                    item["name"],
                    item["memo"],
                    item["owner"],
                    item["date"],
                    item["dateM"],
                    item["id"],
                    item["status"],
                    item["color"],
                ),
            )
            self.settings["conn"].commit()

            # update table widget
            for codes in self.freecode:
                self.tableWidget_codes.removeRow(0)
            self.fillTableWidget_codes()
Example #4
0
    def addCat(self):
        """ When button pressed, add a new category.
        Note: the addItem dialog does the checking for duplicate category names """

        Dialog_addCat = QtGui.QDialog()
        ui = Ui_Dialog_addItem(self.cats)
        ui.setupUi(Dialog_addCat, "Category")
        Dialog_addCat.exec_()
        newCatText = ui.getNewItem()
        if newCatText is not None:
            #add to database
            # need to generate a new id as the RQDA database does not have an autoincrement id field
            newid = 1
            for cat in self.cats:
                if cat['catid'] >= newid:
                    newid = cat['catid'] + 1
            item = {
                'name': newCatText.encode('raw_unicode_escape'),
                'cid': None,
                'catid': newid,
                'memo': "",
                'owner': self.settings['codername'],
                'date':
                datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y"),
                'dateM': "",
                'status': 1
            }
            self.cats.append(item)
            cur = self.settings['conn'].cursor()
            cur.execute(
                "insert into codecat (name, cid, catid, memo, owner, date, dateM, status) values(?,?,?,?,?,?,?,?)",
                (item['name'], item['cid'], item['catid'], item['memo'],
                 item['owner'], item['date'], item['dateM'], item['status']))
            self.settings['conn'].commit()

            #update widget
            self.tableWidget_cats.insertRow(0)
            newItem = QtGui.QTableWidgetItem(item['name'])
            self.tableWidget_cats.setItem(0, self.CAT_NAME_COLUMN, newItem)
            newItem = QtGui.QTableWidgetItem(item['memo'])
            self.tableWidget_cats.setItem(0, self.CAT_MEMO_COLUMN, newItem)
            newItem = QtGui.QTableWidgetItem(str(item['catid']))
            self.tableWidget_cats.setItem(0, self.CAT_ID_COLUMN, newItem)
            self.tableWidget_cats.resizeColumnsToContents()
            self.tableWidget_cats.resizeRowsToContents()
Example #5
0
    def addCode(self):
        """ open addItem dialog to get new code text.
        AddItem dialog checks for duplicate code name.
        New code is added to the model and database """

        Dialog_addCode = QtGui.QDialog()
        ui = Ui_Dialog_addItem(self.freecode)
        ui.setupUi(Dialog_addCode, "Code")
        Dialog_addCode.exec_()
        newCodeText = ui.getNewItem()
        if newCodeText is not None:
            # update freecode list and database
            # need to generate a new id as the RQDA database does not have an autoincrement id field
            newid = 1
            for fc in self.freecode:
                if fc['id'] >= newid: newid = fc['id'] + 1
            item = {
                'name': newCodeText.decode("utf-8"),
                'memo': "",
                'owner': self.settings['codername'],
                'date':
                datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y"),
                'dateM': "",
                'id': newid,
                'status': 1,
                'color': ""
            }
            self.freecode.append(item)
            cur = self.settings['conn'].cursor()
            cur.execute(
                "insert into freecode (name,memo,owner,date,dateM,id,status,color) values(?,?,?,?,?,?,?,?)",
                (item['name'], item['memo'], item['owner'], item['date'],
                 item['dateM'], item['id'], item['status'], item['color']))
            self.settings['conn'].commit()

            # update table widget
            for codes in self.freecode:
                self.tableWidget_codes.removeRow(0)
            self.fillTableWidget_codes()
Example #6
0
    def addCase(self):
        """ When add case button pressed, open addItem dialog to get new case text.
        AddItem dialog checks for duplicate case name.
        New case is added to the model and database """

        Dialog_addCase = QtGui.QDialog()
        ui = Ui_Dialog_addItem(self.cases)
        ui.setupUi(Dialog_addCase, "Case")
        Dialog_addCase.exec_()
        newCaseText = ui.getNewItem()
        if newCaseText is not None:
            #update case list and database
            # need to generate a new id as the RQDA database does not have an autoincrement id field
            newid = 1
            for fc in self.cases:
                if fc['id'] >= newid: newid = fc['id'] + 1
            item = {
                'name': newCaseText.encode('raw_unicode_escape'),
                'memo': "",
                'owner': self.settings['codername'],
                'date':
                datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y"),
                'dateM': "",
                'id': newid,
                'status': 1
            }
            self.cases.append(item)
            cur = self.settings['conn'].cursor()
            cur.execute(
                "insert into cases (name,memo,owner,date,dateM,id,status) values(?,?,?,?,?,?,?)",
                (item['name'], item['memo'], item['owner'], item['date'],
                 item['dateM'], item['id'], item['status']))
            self.settings['conn'].commit()

            #update table widget
            for c in self.cases:
                self.tableWidget_cases.removeRow(0)
            self.fillTableWidget_cases()
Example #7
0
    def addAttribute(self):
        """ When add button pressed, open addItem dialog to get new attribute text.
        AddItem dialog checks for duplicate attribute name.
        New attribute is added to the model and database """

        Dialog_add = QtGui.QDialog()
        ui = Ui_Dialog_addItem(self.attributes)
        ui.setupUi(Dialog_add, "Attribute")
        Dialog_add.exec_()
        newText = ui.getNewItem()

        if newText is not None and newText !="":
            attrClass = ""
            Dialog_type = QtGui.QDialog()
            ui = Ui_Dialog_attrType()
            ui.setupUi(Dialog_type)
            ok = Dialog_type.exec_()
            if ok and ui.radioButton_char.isChecked():
                attrClass = "character"
            if ok and ui.radioButton_numeric.isChecked():
                attrClass = "numeric"

            # update attribute list and database
            item = {'name':newText.encode('raw_unicode_escape'), 'memo':"", 'owner':self.settings['codername'],
                    'date':datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y"), 'dateM':"", 'status':1, 'class':attrClass}
            self.attributes.append(item)
            cur = self.settings['conn'].cursor()
            cur.execute("insert into attributes (name,status,date,dateM,owner,memo,class) values(?,?,?,?,?,?,?)"
                        ,(item['name'], item['status'], item['date'], item['dateM'], item['owner'],
                        item['memo'], item['class']))
            self.settings['conn'].commit()

            # update widget
            for attr in self.attributes:
                self.tableWidget.removeRow(0)

            self.fillTableWidget()