void CollapsedSampler::update(){//{{{ Sampler::update(); sampleTheta(); updateSums(); if((doLog)&&(save))appendFile(); }//}}}
ShowFuelDeliveriesDialog::ShowFuelDeliveriesDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ShowFuelDeliveriesDialog) { ui->setupUi(this); connect(this, SIGNAL(settingsChanged()), this, SLOT(updateSums())); /* * Configure table 'Fuels' columns */ //A few columns shouldn't be shown ui->tableFuels->hideColumn(Column_Date); ui->tableFuels->hideColumn(Column_UUID); //Fuel ComboBoxDelegate *delegateFuel = new ComboBoxDelegate(this); QVector<QString> fuels; fuels.push_back("Bois déchiqueté"); fuels.push_back("Granulés"); fuels.push_back("Fioul"); fuels.push_back("Propane"); delegateFuel->setItems(fuels); ui->tableFuels->setItemDelegateForColumn(Column_Fuel, delegateFuel); ui->tableFuels->setColumnWidth(Column_Fuel, 150); //Qauntity ui->tableFuels->setColumnWidth(Column_Quantity, 110); //Unit ComboBoxDelegate *delegateUnit = new ComboBoxDelegate(this); QVector<QString> units; units.push_back("kg"); units.push_back("tonnes"); units.push_back("litres"); units.push_back("m³"); units.push_back("MAP"); units.push_back("kWh"); units.push_back("MWh"); delegateUnit->setItems(units); ui->tableFuels->setItemDelegateForColumn(Column_Unit, delegateUnit); ui->tableFuels->setColumnWidth(Column_Unit, 80); //LHV DoubleSpinBoxDelegate *delegateLHV = new DoubleSpinBoxDelegate(this); delegateLHV->setSuffix(" kWh / unité"); delegateLHV->setPrecision(4); ui->tableFuels->setItemDelegateForColumn(Column_LHV, delegateLHV); ui->tableFuels->setColumnWidth(Column_LHV, 140); //Moisture DoubleSpinBoxDelegate *delegateMoisture = new DoubleSpinBoxDelegate(this); delegateMoisture->setSuffix(" %"); delegateMoisture->setMaximum(100); ui->tableFuels->setItemDelegateForColumn(Column_Moisture, delegateMoisture); ui->tableFuels->setColumnWidth(Column_Moisture, 80); //Energy DoubleSpinBoxDelegate *delegateEnergy = new DoubleSpinBoxDelegate(this); delegateEnergy->setSuffix(" MWh"); delegateEnergy->setPrecision(4); ui->tableFuels->setItemDelegateForColumn(Column_Energy, delegateEnergy); ui->tableFuels->setColumnWidth(Column_Energy, 100); //Bill DoubleSpinBoxDelegate *delegateBill = new DoubleSpinBoxDelegate(this); delegateBill->setSuffix(" €"); delegateBill->setPrecision(6); ui->tableFuels->setItemDelegateForColumn(Column_Bill, delegateBill); ui->tableFuels->setColumnWidth(Column_Bill, 110); //Energy Price DoubleSpinBoxDelegate *delegateEnergyPrice = new DoubleSpinBoxDelegate(this); delegateEnergyPrice->setSuffix(" € / MWh"); delegateEnergyPrice->setPrecision(4); ui->tableFuels->setItemDelegateForColumn(Column_EnergyPrice, delegateEnergyPrice); ui->tableFuels->setColumnWidth(Column_EnergyPrice, 110); //Last column allows user to delete records ui->tableFuels->setColumnWidth(Column_Delete, 34); /* * Configure table 'Natural gas' columns */ //Date shouldn't be shown ui->tableWidget_NaturalGas->hideRow(0); //Gas index will be edited by a DoubleSpinBox with extra parameters DoubleSpinBoxDelegate *delegateIndex_NaturalGas = new DoubleSpinBoxDelegate(this); delegateIndex_NaturalGas->setSuffix(" m³"); delegateIndex_NaturalGas->setPrecision(5); ui->tableWidget_NaturalGas->setItemDelegateForRow(1, delegateIndex_NaturalGas); /* * Configure table 'Electricity' columns */ //Date shouldn't be shown ui->tableWidget_Electricity->hideRow(0); //Gas index will be edited by a DoubleSpinBox with extra parameters DoubleSpinBoxDelegate *delegateIndex_Electricity = new DoubleSpinBoxDelegate(this); delegateIndex_Electricity->setSuffix(" kWh"); delegateIndex_Electricity->setPrecision(5); ui->tableWidget_Electricity->setItemDelegateForRow(1, delegateIndex_Electricity); }
void KSplitTransactionDlg::slotSetTransaction(const MyMoneyTransaction& t) { m_transaction = t; slotUpdateButtons(); updateSums(); }
int KSplitTransactionDlg::exec() { // for deposits, we invert the sign of all splits. // don't forget to revert when we're done ;-) if (m_isDeposit) { for (int i = 0; i < m_transaction.splits().count(); ++i) { MyMoneySplit split = m_transaction.splits()[i]; split.setValue(-split.value()); split.setShares(-split.shares()); m_transaction.modifySplit(split); } } int rc; do { transactionsTable->setFocus(); // initialize the display transactionsTable->setTransaction(m_transaction, m_split, m_account); updateSums(); rc = KSplitTransactionDlgDecl::exec(); if (rc == Accepted) { if (!diffAmount().isZero()) { KSplitCorrectionDlgDecl* corrDlg = new KSplitCorrectionDlgDecl(this); QVBoxLayout *mainLayout = new QVBoxLayout; corrDlg->setLayout(mainLayout); mainLayout->addWidget(corrDlg->findChild<QWidget*>("verticalLayout")); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), corrDlg, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), corrDlg, SLOT(reject())); mainLayout->addWidget(buttonBox); corrDlg->buttonGroup->setId(corrDlg->continueBtn, 0); corrDlg->buttonGroup->setId(corrDlg->changeBtn, 1); corrDlg->buttonGroup->setId(corrDlg->distributeBtn, 2); corrDlg->buttonGroup->setId(corrDlg->leaveBtn, 3); corrDlg->setModal(true); MyMoneySplit split = m_transaction.splits()[0]; QString total = (-split.value()).formatMoney("", m_precision); QString sums = splitsValue().formatMoney("", m_precision); QString diff = diffAmount().formatMoney("", m_precision); // now modify the text items of the dialog to contain the correct values QString q = i18n("The total amount of this transaction is %1 while " "the sum of the splits is %2. The remaining %3 are " "unassigned.", total, sums, diff); corrDlg->explanation->setText(q); q = i18n("Change &total amount of transaction to %1.", sums); corrDlg->changeBtn->setText(q); q = i18n("&Distribute difference of %1 among all splits.", diff); corrDlg->distributeBtn->setText(q); // FIXME remove the following line once distribution among // all splits is implemented corrDlg->distributeBtn->hide(); // if we have only two splits left, we don't allow leaving sth. unassigned. if (m_transaction.splitCount() < 3) { q = i18n("&Leave total amount of transaction at %1.", total); } else { q = i18n("&Leave %1 unassigned.", diff); } corrDlg->leaveBtn->setText(q); if ((rc = corrDlg->exec()) == Accepted) { switch (corrDlg->buttonGroup->checkedId()) { case 0: // continue to edit rc = Rejected; break; case 1: // modify total split.setValue(-splitsValue()); split.setShares(-splitsValue()); m_transaction.modifySplit(split); break; case 2: // distribute difference qDebug("distribution of difference not yet supported in KSplitTransactionDlg::slotFinishClicked()"); break; case 3: // leave unassigned break; } } delete corrDlg; } } else break; } while (rc != Accepted); // for deposits, we inverted the sign of all splits. // now we revert it back, so that things are left correct if (m_isDeposit) { for (int i = 0; i < m_transaction.splits().count(); ++i) { MyMoneySplit split = m_transaction.splits()[i]; split.setValue(-split.value()); split.setShares(-split.shares()); m_transaction.modifySplit(split); } } return rc; }