Exemplo n.º 1
0
	def __init__(self, files, parent=None):
		super(ImportDialog, self).__init__(parent=parent)
		self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
		self.setupUi(self)
		self.__dataSaved = False
		self.__importInProgress = False
		self.__cancelImport = False

		self.progressBar.setVisible(False)

		self.currencyComboBox.addItems(currency.currencyCodes())
		self.currencyComboBox.setCurrentIndex(
			self.currencyComboBox.findText(currency.defaultCurrencyCode())
		)

		query = QtSql.QSqlQuery("""
			    SELECT a.id, a.name, at.*
			      FROM accounts a
			INNER JOIN accounttypes at
			        ON at.accounttypeid=a.accounttypeid
			       AND a.userid=%d
			""" % db.userId)

		rec = query.record()
		self.accountTypeComboBox.addItem('Raw')

		while query.next():
			accountId =  query.value(rec.indexOf('id'))
			name = query.value(rec.indexOf('name'))
			dateIdx = query.value(rec.indexOf('datefield'))
			descIdx = query.value(rec.indexOf('descriptionfield'))
			creditIdx = query.value(rec.indexOf('creditfield'))
			debitIdx = query.value(rec.indexOf('debitfield'))
			currencySign = query.value(rec.indexOf('currencysign'))
			dateFormat = query.value(rec.indexOf('dateFormat'))
			self.accountTypeComboBox.addItem(name, (
				accountId, (dateIdx, descIdx, creditIdx, debitIdx, currencySign, dateFormat,))
			)

		self.accountTypeComboBox.setCurrentIndex(-1)

		model = ImportModel(files)

		self.importCancelButton.setEnabled(False)
		self.selectAllButton.setEnabled(False)
		self.view.setModel(model)
		model.modelReset.connect(self.view.expandAll)
		self.view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
		self.view.expandAll()

		selectionModel = self.view.selectionModel()
		selectionModel.selectionChanged.connect(self._recordsSelected)
		self.accountTypeComboBox.currentIndexChanged.connect(self._accountChanged)

		self.importCancelButton.clicked.connect(self.__importCancelPressed)
		self.selectAllButton.clicked.connect(self.view.selectAll)
		self.closeButton.clicked.connect(self.__close)

		self.accountTypeComboBox.setCurrentIndex(0)
Exemplo n.º 2
0
    def __init__(self, files, parent=None):
        super(ImportDialog, self).__init__(parent=parent)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setupUi(self)
        self.__dataSaved = False
        self.__importInProgress = False
        self.__cancelImport = False

        self.progressBar.setVisible(False)

        self.currencyComboBox.addItems(currency.currencyCodes())
        self.currencyComboBox.setCurrentIndex(
            self.currencyComboBox.findText(currency.defaultCurrencyCode()))

        query = QtSql.QSqlQuery("""
			    SELECT a.id, a.name, at.*
			      FROM accounts a
			INNER JOIN accounttypes at
			        ON at.accounttypeid=a.accounttypeid
			       AND a.userid=%d
			""" % db.userId)

        rec = query.record()
        self.accountTypeComboBox.addItem('Raw')

        while query.next():
            accountId = query.value(rec.indexOf('id'))
            name = query.value(rec.indexOf('name'))
            dateIdx = query.value(rec.indexOf('datefield'))
            descIdx = query.value(rec.indexOf('descriptionfield'))
            creditIdx = query.value(rec.indexOf('creditfield'))
            debitIdx = query.value(rec.indexOf('debitfield'))
            currencySign = query.value(rec.indexOf('currencysign'))
            dateFormat = query.value(rec.indexOf('dateFormat'))
            self.accountTypeComboBox.addItem(name, (accountId, (
                dateIdx,
                descIdx,
                creditIdx,
                debitIdx,
                currencySign,
                dateFormat,
            )))

        self.accountTypeComboBox.setCurrentIndex(-1)

        model = ImportModel(files)

        self.importCancelButton.setEnabled(False)
        self.selectAllButton.setEnabled(False)
        self.view.setModel(model)
        model.modelReset.connect(self.view.expandAll)
        self.view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
        self.view.expandAll()

        selectionModel = self.view.selectionModel()
        selectionModel.selectionChanged.connect(self._recordsSelected)
        self.accountTypeComboBox.currentIndexChanged.connect(
            self._accountChanged)

        self.importCancelButton.clicked.connect(self.__importCancelPressed)
        self.selectAllButton.clicked.connect(self.view.selectAll)
        self.closeButton.clicked.connect(self.__close)

        self.accountTypeComboBox.setCurrentIndex(0)
Exemplo n.º 3
0
	def test_defaultCurrencyCode(self):
		self.assertEqual(currency.defaultCurrencyCode(), 'GBP')