ServiceBlock::ServiceBlock(int idC, QWidget *parent) : QDialog(parent), idCar(idC), ui(new Ui::ServiceBlock) { ui->setupUi(this); setCalendarColor(ui->deBegin->calendarWidget(),QColor(255,140,0)); setCalendarColor(ui->deEnd->calendarWidget(),QColor(255,140,0)); setCalendarColor(ui->deEvent->calendarWidget(),QColor(255,140,0)); setCalendarColor(ui->deGuarantee->calendarWidget(),QColor(255,140,0)); QSqlQueryModel * windTitle = new QSqlQueryModel(this); windTitle->setQuery(QString("SELECT Brand, Model, LicensePlate FROM car WHERE idCar = %1").arg(idCar)); this->setWindowTitle( QString("Naprawy - ") + windTitle->data(windTitle->index(windTitle->rowCount()-1,0)).toString() + QString(" ") + windTitle->data(windTitle->index(windTitle->rowCount()-1,1)).toString() + QString(" - ") + windTitle->data(windTitle->index(windTitle->rowCount()-1,2)).toString() ); connect(this,SIGNAL(saved()),this,SLOT(updateView()),Qt::DirectConnection); connect(this,SIGNAL(deleted()),this,SLOT(updateView())); // fill category combobox QStringList categoryList({QString("Silnik"),QString("Zawieszenie"),QString("Elektronika"), QString("Elektryka"),QString("Układ napędowy"),QString("Układ hamulcowy"), QString("Układ kierowniczy"),QString("Nadwozie")}); ui->cbCategory->addItems(categoryList); updateView(); isOpen = true; }
//---------------------------------------------------------------------------- // Set Transaction Filter //---------------------------------------------------------------------------- void ReportPieChart::setTransactionFilter( const Transaction::FilterType& aFilter ) { hideDisplayLabel(); mFilter = aFilter; mDataList.clear(); switch( mChartType ) { case ASSET_BY_ACCOUNT: case DEBT_BY_ACCOUNT: { Month* month = Month::getMonth( aFilter.mEndDate ); if( month ) { for( int i = 0; i < aFilter.mAccountList.size() && i < Account::sAccountList.size(); i++ ) { if( aFilter.mAccountList[i] ) { Account* account = Account::sAccountList[i]; bool accountExist = false; float netWorth = month->getNetWorth( account, &accountExist ); if( accountExist ) { bool allow = false; if( netWorth >= 0 ) { allow = (mChartType == ASSET_BY_ACCOUNT); } else { allow = (mChartType == DEBT_BY_ACCOUNT); netWorth = -netWorth; } if( allow ) { PieDataType data; data.mName = account->getName(); data.mValue = netWorth; mDataList.append( data ); } } } } } } break; case INCOME_BY_CATEGORY: case EXPENSE_BY_CATEGORY: { QList<Transaction*> transactionList = Transaction::filterTransactions( TransactionManager::sTransactionList, aFilter ); int categoryCnt = ( mGroupCategories ) ? (int)Category::PARENT_CATEGORY_TYPE_CNT : (int)Category::getCategoryCount(); QVector<float> categoryList( categoryCnt, 0 ); for( int i = 0; i < transactionList.size(); i++ ) { Transaction* transaction = transactionList[i]; Category::TransactionType transType = transaction->getTransactionType(); int categoryIdx = ( mGroupCategories ) ? transaction->getParentCategory() : transaction->getCategory(); if( ( mChartType == INCOME_BY_CATEGORY && transType == Category::TRANSACTION_TYPE_INCOME ) || ( mChartType == EXPENSE_BY_CATEGORY && transType == Category::TRANSACTION_TYPE_EXPENSE ) || ( mShowTransfers && transType == Category::TRANSACTION_TYPE_TRANSFER ) ) { categoryList[categoryIdx] += transaction->getAmount(); } } for( int i = 0; i < categoryList.size(); i++ ) { bool addItem = ( (mChartType == INCOME_BY_CATEGORY && categoryList[i] > 0) || (mChartType == EXPENSE_BY_CATEGORY && categoryList[i] < 0) ); if( addItem ) { PieDataType data; data.mName = ( mGroupCategories ) ? Category::getParentCategoryText( (Category::ParentCategoryType)i ) : Category::getCategoryText( (Category::CategoryIdxType)i, true ); data.mValue = categoryList[i]; mDataList.append( data ); } } } break; default: break; } updateChart(); } // ReportPieChart::setTransactionFilter