Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/views/simpleledgerview.cpp
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 96 | if(bar) { | |||
---|---|---|---|---|---|
100 | w->deleteLater(); | 100 | w->deleteLater(); | ||
101 | connect(bar, SIGNAL(tabMoved(int,int)), this, SLOT(checkTabOrder(int,int))); | 101 | connect(bar, SIGNAL(tabMoved(int,int)), this, SLOT(checkTabOrder(int,int))); | ||
102 | } | 102 | } | ||
103 | 103 | | |||
104 | connect(d->ui->accountCombo, SIGNAL(accountSelected(QString)), this, SLOT(openNewLedger(QString))); | 104 | connect(d->ui->accountCombo, SIGNAL(accountSelected(QString)), this, SLOT(openNewLedger(QString))); | ||
105 | connect(d->ui->ledgerTab, &QTabWidget::currentChanged, this, &SimpleLedgerView::tabSelected); | 105 | connect(d->ui->ledgerTab, &QTabWidget::currentChanged, this, &SimpleLedgerView::tabSelected); | ||
106 | connect(Models::instance(), &Models::modelsLoaded, this, &SimpleLedgerView::updateModels); | 106 | connect(Models::instance(), &Models::modelsLoaded, this, &SimpleLedgerView::updateModels); | ||
107 | connect(d->ui->ledgerTab, &QTabWidget::tabCloseRequested, this, &SimpleLedgerView::closeLedger); | 107 | connect(d->ui->ledgerTab, &QTabWidget::tabCloseRequested, this, &SimpleLedgerView::closeLedger); | ||
108 | connect(m_kmymoneyview, &KMyMoneyView::fileClosed, this, &SimpleLedgerView::closeLedgers); | | |||
109 | connect(m_kmymoneyview, &KMyMoneyView::fileOpened, this, &SimpleLedgerView::openFavoriteLedgers); | | |||
110 | 108 | | |||
111 | d->accountsModel->addAccountGroup(QVector<eMyMoney::Account::Type> {eMyMoney::Account::Type::Asset, eMyMoney::Account::Type::Liability, eMyMoney::Account::Type::Equity}); | 109 | d->accountsModel->addAccountGroup(QVector<eMyMoney::Account::Type> {eMyMoney::Account::Type::Asset, eMyMoney::Account::Type::Liability, eMyMoney::Account::Type::Equity}); | ||
112 | 110 | | |||
113 | d->accountsModel->setHideEquityAccounts(false); | 111 | d->accountsModel->setHideEquityAccounts(false); | ||
114 | auto const model = Models::instance()->accountsModel(); | 112 | auto const model = Models::instance()->accountsModel(); | ||
115 | d->accountsModel->setSourceModel(model); | 113 | d->accountsModel->setSourceModel(model); | ||
116 | d->accountsModel->setSourceColumns(model->getColumns()); | 114 | d->accountsModel->setSourceColumns(model->getColumns()); | ||
117 | d->accountsModel->sort((int)eAccountsModel::Column::Account); | 115 | d->accountsModel->sort((int)eAccountsModel::Column::Account); | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
204 | 202 | | |||
205 | void SimpleLedgerView::showTransactionForm(bool show) | 203 | void SimpleLedgerView::showTransactionForm(bool show) | ||
206 | { | 204 | { | ||
207 | emit showForms(show); | 205 | emit showForms(show); | ||
208 | } | 206 | } | ||
209 | 207 | | |||
210 | void SimpleLedgerView::closeLedgers() | 208 | void SimpleLedgerView::closeLedgers() | ||
211 | { | 209 | { | ||
212 | int tabCount = d->ui->ledgerTab->count(); | 210 | if (d->m_needLoad) | ||
211 | return; | ||||
212 | auto tabCount = d->ui->ledgerTab->count(); | ||||
213 | // check that we have a least one tab that can be closed | 213 | // check that we have a least one tab that can be closed | ||
214 | if(tabCount > 1) { | 214 | if(tabCount > 1) { | ||
215 | // we keep the tab with the selector open at all times | 215 | // we keep the tab with the selector open at all times | ||
216 | // which is located in the right most position | 216 | // which is located in the right most position | ||
217 | --tabCount; | 217 | --tabCount; | ||
218 | do { | 218 | do { | ||
219 | --tabCount; | 219 | --tabCount; | ||
220 | closeLedger(tabCount); | 220 | closeLedger(tabCount); | ||
221 | } while(tabCount > 0); | 221 | } while(tabCount > 0); | ||
222 | } | 222 | } | ||
223 | } | 223 | } | ||
224 | 224 | | |||
225 | void SimpleLedgerView::openFavoriteLedgers() | 225 | void SimpleLedgerView::openFavoriteLedgers() | ||
226 | { | 226 | { | ||
227 | if (d->m_needLoad) | ||||
228 | return; | ||||
229 | | ||||
227 | AccountsModel* model = Models::instance()->accountsModel(); | 230 | AccountsModel* model = Models::instance()->accountsModel(); | ||
228 | QModelIndex start = model->index(0, 0); | 231 | QModelIndex start = model->index(0, 0); | ||
229 | QModelIndexList indexes = model->match(start, (int)eAccountsModel::Role::Favorite, QVariant(true), -1, Qt::MatchRecursive); | 232 | QModelIndexList indexes = model->match(start, (int)eAccountsModel::Role::Favorite, QVariant(true), -1, Qt::MatchRecursive); | ||
230 | 233 | | |||
231 | // indexes now has a list of favorite accounts but two entries for each. | 234 | // indexes now has a list of favorite accounts but two entries for each. | ||
232 | // that doesn't matter here, since openNewLedger() can handle duplicates | 235 | // that doesn't matter here, since openNewLedger() can handle duplicates | ||
233 | Q_FOREACH(QModelIndex index, indexes) { | 236 | Q_FOREACH(QModelIndex index, indexes) { | ||
234 | openNewLedger(model->data(index, (int)eAccountsModel::Role::ID).toString()); | 237 | openNewLedger(model->data(index, (int)eAccountsModel::Role::ID).toString()); | ||
Show All 12 Lines |