Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/kmymoneypricedlg.cpp
Context not available. | |||||
9 | John C <thetacoturtle@users.sourceforge.net> | 9 | John C <thetacoturtle@users.sourceforge.net> | ||
---|---|---|---|---|---|
10 | Thomas Baumgart <ipwizard@users.sourceforge.net> | 10 | Thomas Baumgart <ipwizard@users.sourceforge.net> | ||
11 | Kevin Tambascio <ktambascio@users.sourceforge.net> | 11 | Kevin Tambascio <ktambascio@users.sourceforge.net> | ||
12 | (C) 2017 by Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
12 | ***************************************************************************/ | 13 | ***************************************************************************/ | ||
13 | 14 | | |||
14 | /*************************************************************************** | 15 | /*************************************************************************** | ||
Context not available. | |||||
28 | #include <QCheckBox> | 29 | #include <QCheckBox> | ||
29 | #include <QPushButton> | 30 | #include <QPushButton> | ||
30 | #include <QIcon> | 31 | #include <QIcon> | ||
31 | #include <QDialogButtonBox> | | |||
32 | #include <QVBoxLayout> | 32 | #include <QVBoxLayout> | ||
33 | 33 | | |||
34 | // ---------------------------------------------------------------------------- | 34 | // ---------------------------------------------------------------------------- | ||
35 | // KDE Includes | 35 | // KDE Includes | ||
36 | 36 | | |||
37 | #include <KGuiItem> | | |||
38 | #include <KMessageBox> | 37 | #include <KMessageBox> | ||
39 | #include <KLocalizedString> | 38 | #include <KLocalizedString> | ||
40 | #include <KTreeWidgetSearchLine> | 39 | #include <KTreeWidgetSearchLine> | ||
Context not available. | |||||
43 | // ---------------------------------------------------------------------------- | 42 | // ---------------------------------------------------------------------------- | ||
44 | // Project Includes | 43 | // Project Includes | ||
45 | 44 | | |||
45 | #include "ui_kmymoneypricedlg.h" | ||||
46 | #include "ui_kupdatestockpricedlg.h" | ||||
47 | | ||||
46 | #include "kupdatestockpricedlg.h" | 48 | #include "kupdatestockpricedlg.h" | ||
47 | #include "kcurrencycalculator.h" | 49 | #include "kcurrencycalculator.h" | ||
48 | #include "mymoneyprice.h" | 50 | #include "mymoneyprice.h" | ||
Context not available. | |||||
58 | 60 | | |||
59 | using namespace Icons; | 61 | using namespace Icons; | ||
60 | 62 | | |||
63 | class KMyMoneyPriceDlgPrivate | ||||
64 | { | ||||
65 | Q_DISABLE_COPY(KMyMoneyPriceDlgPrivate) | ||||
66 | Q_DECLARE_PUBLIC(KMyMoneyPriceDlg) | ||||
67 | | ||||
68 | public: | ||||
69 | KMyMoneyPriceDlgPrivate(KMyMoneyPriceDlg *qq) : | ||||
70 | q_ptr(qq), | ||||
71 | ui(new Ui::KMyMoneyPriceDlg), | ||||
72 | m_searchWidget(nullptr) | ||||
73 | { | ||||
74 | } | ||||
75 | | ||||
76 | ~KMyMoneyPriceDlgPrivate() | ||||
77 | { | ||||
78 | delete ui; | ||||
79 | } | ||||
80 | | ||||
81 | KMyMoneyPriceDlg *q_ptr; | ||||
82 | Ui::KMyMoneyPriceDlg *ui; | ||||
83 | QTreeWidgetItem* m_currentItem; | ||||
84 | /** | ||||
85 | * Search widget for the list | ||||
86 | */ | ||||
87 | KTreeWidgetSearchLineWidget* m_searchWidget; | ||||
88 | QMap<QString, QString> m_stockNameMap; | ||||
89 | }; | ||||
90 | | ||||
61 | KMyMoneyPriceDlg::KMyMoneyPriceDlg(QWidget* parent) : | 91 | KMyMoneyPriceDlg::KMyMoneyPriceDlg(QWidget* parent) : | ||
62 | KMyMoneyPriceDlgDecl(parent) | 92 | QDialog(parent), | ||
93 | d_ptr(new KMyMoneyPriceDlgPrivate(this)) | ||||
63 | { | 94 | { | ||
64 | QVBoxLayout *mainLayout = new QVBoxLayout; | 95 | Q_D(KMyMoneyPriceDlg); | ||
65 | setLayout(mainLayout); | 96 | d->ui->setupUi(this); | ||
66 | mainLayout->addWidget(m_layoutWidget); | | |||
67 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); | | |||
68 | connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); | | |||
69 | connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); | | |||
70 | mainLayout->addWidget(buttonBox); | | |||
71 | 97 | | |||
72 | // create the searchline widget | 98 | // create the searchline widget | ||
73 | // and insert it into the existing layout | 99 | // and insert it into the existing layout | ||
74 | m_searchWidget = new KTreeWidgetSearchLineWidget(this, m_priceList); | 100 | d->m_searchWidget = new KTreeWidgetSearchLineWidget(this, d->ui->m_priceList); | ||
75 | m_searchWidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); | 101 | d->m_searchWidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); | ||
76 | m_listLayout->insertWidget(0, m_searchWidget); | 102 | | ||
77 | 103 | d->ui->m_listLayout->insertWidget(0, d->m_searchWidget); | |||
78 | m_priceList->header()->setSortIndicator(0, Qt::AscendingOrder); | 104 | | ||
79 | m_priceList->header()->setStretchLastSection(true); | 105 | d->ui->m_priceList->header()->setSortIndicator(0, Qt::AscendingOrder); | ||
80 | m_priceList->setContextMenuPolicy(Qt::CustomContextMenu); | 106 | d->ui->m_priceList->header()->setStretchLastSection(true); | ||
81 | 107 | d->ui->m_priceList->setContextMenuPolicy(Qt::CustomContextMenu); | |||
82 | KGuiItem removeButtonItem(i18n("&Delete"), | 108 | | ||
83 | QIcon::fromTheme(g_Icons[Icon::EditDelete]), | 109 | d->ui->m_deleteButton->setIcon(QIcon::fromTheme(g_Icons[Icon::EditDelete])); | ||
84 | i18n("Delete this entry"), | 110 | d->ui->m_newButton->setIcon(QIcon::fromTheme(g_Icons[Icon::DocumentNew])); | ||
85 | i18n("Remove this price item from the file")); | 111 | d->ui->m_editButton->setIcon(QIcon::fromTheme(g_Icons[Icon::DocumentEdit])); | ||
86 | KGuiItem::assign(m_deleteButton, removeButtonItem); | 112 | | ||
87 | 113 | d->ui->m_onlineQuoteButton->setIcon(KMyMoneyUtils::overlayIcon(g_Icons[Icon::ViewInvestment], g_Icons[Icon::Download])); | |||
88 | KGuiItem newButtonItem(i18nc("New price entry", "&New"), | 114 | | ||
89 | QIcon::fromTheme(g_Icons[Icon::DocumentNew]), | 115 | connect(d->ui->m_editButton, &QAbstractButton::clicked, this, &KMyMoneyPriceDlg::slotEditPrice); | ||
90 | i18n("Add a new entry"), | 116 | connect(d->ui->m_deleteButton, &QAbstractButton::clicked, this, &KMyMoneyPriceDlg::slotDeletePrice); | ||
91 | i18n("Create a new price entry.")); | 117 | connect(d->ui->m_newButton, &QAbstractButton::clicked, this, &KMyMoneyPriceDlg::slotNewPrice); | ||
92 | KGuiItem::assign(m_newButton, newButtonItem); | 118 | connect(d->ui->m_priceList, &QTreeWidget::itemSelectionChanged, this, &KMyMoneyPriceDlg::slotSelectPrice); | ||
93 | 119 | connect(d->ui->m_onlineQuoteButton, &QAbstractButton::clicked, this, &KMyMoneyPriceDlg::slotOnlinePriceUpdate); | |||
94 | KGuiItem editButtonItem(i18n("&Edit"), | 120 | connect(d->ui->m_priceList, &QWidget::customContextMenuRequested, this, &KMyMoneyPriceDlg::slotOpenContextMenu); | ||
95 | QIcon::fromTheme(g_Icons[Icon::DocumentEdit]), | 121 | | ||
96 | i18n("Modify the selected entry"), | 122 | connect(d->ui->m_showAllPrices, &QAbstractButton::toggled, this, &KMyMoneyPriceDlg::slotLoadWidgets); | ||
97 | i18n("Change the details of selected price information.")); | 123 | connect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, this, &KMyMoneyPriceDlg::slotLoadWidgets); | ||
98 | KGuiItem::assign(m_editButton, editButtonItem); | | |||
99 | | ||||
100 | m_onlineQuoteButton->setIcon(KMyMoneyUtils::overlayIcon(g_Icons[Icon::ViewInvestment], g_Icons[Icon::Download])); | | |||
101 | | ||||
102 | connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEditPrice())); | | |||
103 | connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(slotDeletePrice())); | | |||
104 | connect(m_newButton, SIGNAL(clicked()), this, SLOT(slotNewPrice())); | | |||
105 | connect(m_priceList, SIGNAL(itemSelectionChanged()), this, SLOT(slotSelectPrice())); | | |||
106 | connect(m_onlineQuoteButton, SIGNAL(clicked()), this, SLOT(slotOnlinePriceUpdate())); | | |||
107 | connect(m_priceList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotOpenContextMenu(QPoint))); | | |||
108 | | ||||
109 | connect(m_showAllPrices, SIGNAL(toggled(bool)), this, SLOT(slotLoadWidgets())); | | |||
110 | connect(MyMoneyFile::instance(), SIGNAL(dataChanged()), this, SLOT(slotLoadWidgets())); | | |||
111 | 124 | | |||
112 | slotLoadWidgets(); | 125 | slotLoadWidgets(); | ||
113 | slotSelectPrice(); | 126 | slotSelectPrice(); | ||
Context not available. | |||||
115 | 128 | | |||
116 | KMyMoneyPriceDlg::~KMyMoneyPriceDlg() | 129 | KMyMoneyPriceDlg::~KMyMoneyPriceDlg() | ||
117 | { | 130 | { | ||
131 | Q_D(KMyMoneyPriceDlg); | ||||
132 | delete d; | ||||
118 | } | 133 | } | ||
119 | 134 | | |||
120 | void KMyMoneyPriceDlg::slotLoadWidgets() | 135 | void KMyMoneyPriceDlg::slotLoadWidgets() | ||
121 | { | 136 | { | ||
122 | MyMoneyFile* file = MyMoneyFile::instance(); | 137 | Q_D(KMyMoneyPriceDlg); | ||
138 | auto file = MyMoneyFile::instance(); | ||||
123 | 139 | | |||
124 | //clear the list and disable the sorting while it loads the widgets, for performance | 140 | //clear the list and disable the sorting while it loads the widgets, for performance | ||
125 | m_priceList->setSortingEnabled(false); | 141 | d->ui->m_priceList->setSortingEnabled(false); | ||
126 | m_priceList->clear(); | 142 | d->ui->m_priceList->clear(); | ||
127 | m_stockNameMap.clear(); | 143 | d->m_stockNameMap.clear(); | ||
128 | 144 | | |||
129 | //load the currencies for investments, which we'll need later | 145 | //load the currencies for investments, which we'll need later | ||
130 | QList<MyMoneyAccount> accList; | 146 | QList<MyMoneyAccount> accList; | ||
Context not available. | |||||
132 | QList<MyMoneyAccount>::const_iterator acc_it; | 148 | QList<MyMoneyAccount>::const_iterator acc_it; | ||
133 | for (acc_it = accList.constBegin(); acc_it != accList.constEnd(); ++acc_it) { | 149 | for (acc_it = accList.constBegin(); acc_it != accList.constEnd(); ++acc_it) { | ||
134 | if ((*acc_it).isInvest()) { | 150 | if ((*acc_it).isInvest()) { | ||
135 | if (m_stockNameMap.contains((*acc_it).currencyId())) { | 151 | if (d->m_stockNameMap.contains((*acc_it).currencyId())) { | ||
136 | m_stockNameMap[(*acc_it).currencyId()] = QString(m_stockNameMap.value((*acc_it).currencyId()) + ", " + (*acc_it).name()); | 152 | d->m_stockNameMap[(*acc_it).currencyId()] = QString(d->m_stockNameMap.value((*acc_it).currencyId()) + ", " + (*acc_it).name()); | ||
137 | } else { | 153 | } else { | ||
138 | m_stockNameMap[(*acc_it).currencyId()] = (*acc_it).name(); | 154 | d->m_stockNameMap[(*acc_it).currencyId()] = (*acc_it).name(); | ||
139 | } | 155 | } | ||
140 | } | 156 | } | ||
141 | } | 157 | } | ||
Context not available. | |||||
145 | MyMoneyPriceList::ConstIterator it_allPrices; | 161 | MyMoneyPriceList::ConstIterator it_allPrices; | ||
146 | for (it_allPrices = list.constBegin(); it_allPrices != list.constEnd(); ++it_allPrices) { | 162 | for (it_allPrices = list.constBegin(); it_allPrices != list.constEnd(); ++it_allPrices) { | ||
147 | MyMoneyPriceEntries::ConstIterator it_priceItem; | 163 | MyMoneyPriceEntries::ConstIterator it_priceItem; | ||
148 | if (m_showAllPrices->isChecked()) { | 164 | if (d->ui->m_showAllPrices->isChecked()) { | ||
149 | for (it_priceItem = (*it_allPrices).constBegin(); it_priceItem != (*it_allPrices).constEnd(); ++it_priceItem) { | 165 | for (it_priceItem = (*it_allPrices).constBegin(); it_priceItem != (*it_allPrices).constEnd(); ++it_priceItem) { | ||
150 | loadPriceItem(*it_priceItem); | 166 | loadPriceItem(*it_priceItem); | ||
151 | } | 167 | } | ||
Context not available. | |||||
161 | } | 177 | } | ||
162 | } | 178 | } | ||
163 | //reenable sorting and sort by the commodity column | 179 | //reenable sorting and sort by the commodity column | ||
164 | m_priceList->setSortingEnabled(true); | 180 | d->ui->m_priceList->setSortingEnabled(true); | ||
165 | m_priceList->sortByColumn(KPriceTreeItem::ePriceCommodity); | 181 | d->ui->m_priceList->sortByColumn(KPriceTreeItem::ePriceCommodity); | ||
166 | 182 | | |||
167 | //update the search widget so the list gets refreshed correctly if it was being filtered | 183 | //update the search widget so the list gets refreshed correctly if it was being filtered | ||
168 | if (!m_searchWidget->searchLine()->text().isEmpty()) | 184 | if (!d->m_searchWidget->searchLine()->text().isEmpty()) | ||
169 | m_searchWidget->searchLine()->updateSearch(m_searchWidget->searchLine()->text()); | 185 | d->m_searchWidget->searchLine()->updateSearch(d->m_searchWidget->searchLine()->text()); | ||
170 | } | 186 | } | ||
171 | 187 | | |||
172 | QTreeWidgetItem* KMyMoneyPriceDlg::loadPriceItem(const MyMoneyPrice& basePrice) | 188 | QTreeWidgetItem* KMyMoneyPriceDlg::loadPriceItem(const MyMoneyPrice& basePrice) | ||
173 | { | 189 | { | ||
190 | Q_D(KMyMoneyPriceDlg); | ||||
174 | MyMoneySecurity from, to; | 191 | MyMoneySecurity from, to; | ||
175 | MyMoneyPrice price = MyMoneyPrice(basePrice); | 192 | auto price = MyMoneyPrice(basePrice); | ||
176 | 193 | | |||
177 | KPriceTreeItem* priceTreeItem = new KPriceTreeItem(m_priceList); | 194 | auto priceTreeItem = new KPriceTreeItem(d->ui->m_priceList); | ||
178 | 195 | | |||
179 | if (!price.isValid()) | 196 | if (!price.isValid()) | ||
180 | price = MyMoneyFile::instance()->price(price.from(), price.to(), price.date()); | 197 | price = MyMoneyFile::instance()->price(price.from(), price.to(), price.date()); | ||
Context not available. | |||||
191 | 208 | | |||
192 | priceTreeItem->setData(KPriceTreeItem::ePriceCommodity, Qt::UserRole, QVariant::fromValue(price)); | 209 | priceTreeItem->setData(KPriceTreeItem::ePriceCommodity, Qt::UserRole, QVariant::fromValue(price)); | ||
193 | priceTreeItem->setText(KPriceTreeItem::ePriceCommodity, (from.isCurrency()) ? from.id() : from.tradingSymbol()); | 210 | priceTreeItem->setText(KPriceTreeItem::ePriceCommodity, (from.isCurrency()) ? from.id() : from.tradingSymbol()); | ||
194 | priceTreeItem->setText(KPriceTreeItem::ePriceStockName, (from.isCurrency()) ? QString() : m_stockNameMap.value(from.id())); | 211 | priceTreeItem->setText(KPriceTreeItem::ePriceStockName, (from.isCurrency()) ? QString() : d->m_stockNameMap.value(from.id())); | ||
195 | priceTreeItem->setToolTip(KPriceTreeItem::ePriceStockName, (from.isCurrency()) ? QString() : m_stockNameMap.value(from.id())); | 212 | priceTreeItem->setToolTip(KPriceTreeItem::ePriceStockName, (from.isCurrency()) ? QString() : d->m_stockNameMap.value(from.id())); | ||
196 | priceTreeItem->setText(KPriceTreeItem::ePriceCurrency, to.id()); | 213 | priceTreeItem->setText(KPriceTreeItem::ePriceCurrency, to.id()); | ||
197 | priceTreeItem->setText(KPriceTreeItem::ePriceDate, QLocale().toString(price.date(), QLocale::ShortFormat)); | 214 | priceTreeItem->setText(KPriceTreeItem::ePriceDate, QLocale().toString(price.date(), QLocale::ShortFormat)); | ||
198 | priceTreeItem->setData(KPriceTreeItem::ePriceDate, KPriceTreeItem::OrderRole, QVariant(price.date())); | 215 | priceTreeItem->setData(KPriceTreeItem::ePriceDate, KPriceTreeItem::OrderRole, QVariant(price.date())); | ||
Context not available. | |||||
206 | 223 | | |||
207 | void KMyMoneyPriceDlg::slotSelectPrice() | 224 | void KMyMoneyPriceDlg::slotSelectPrice() | ||
208 | { | 225 | { | ||
226 | Q_D(KMyMoneyPriceDlg); | ||||
209 | QTreeWidgetItem* item = 0; | 227 | QTreeWidgetItem* item = 0; | ||
210 | if (m_priceList->selectedItems().count() > 0) { | 228 | if (d->ui->m_priceList->selectedItems().count() > 0) { | ||
211 | item = m_priceList->selectedItems().at(0); | 229 | item = d->ui->m_priceList->selectedItems().at(0); | ||
212 | } | 230 | } | ||
213 | m_currentItem = item; | 231 | d->m_currentItem = item; | ||
214 | m_editButton->setEnabled(item != 0); | 232 | d->ui->m_editButton->setEnabled(item != 0); | ||
215 | bool deleteEnabled = (item != 0); | 233 | bool deleteEnabled = (item != 0); | ||
216 | 234 | | |||
217 | //if one of the selected entries is a default, then deleting is disabled | 235 | //if one of the selected entries is a default, then deleting is disabled | ||
218 | QList<QTreeWidgetItem*> itemsList = m_priceList->selectedItems(); | 236 | QList<QTreeWidgetItem*> itemsList = d->ui->m_priceList->selectedItems(); | ||
219 | QList<QTreeWidgetItem*>::const_iterator item_it; | 237 | QList<QTreeWidgetItem*>::const_iterator item_it; | ||
220 | for (item_it = itemsList.constBegin(); item_it != itemsList.constEnd(); ++item_it) { | 238 | for (item_it = itemsList.constBegin(); item_it != itemsList.constEnd(); ++item_it) { | ||
221 | MyMoneyPrice price = (*item_it)->data(0, Qt::UserRole).value<MyMoneyPrice>(); | 239 | MyMoneyPrice price = (*item_it)->data(0, Qt::UserRole).value<MyMoneyPrice>(); | ||
222 | if (price.source() == "KMyMoney") | 240 | if (price.source() == "KMyMoney") | ||
223 | deleteEnabled = false; | 241 | deleteEnabled = false; | ||
224 | } | 242 | } | ||
225 | m_deleteButton->setEnabled(deleteEnabled); | 243 | d->ui->m_deleteButton->setEnabled(deleteEnabled); | ||
226 | 244 | | |||
227 | // Modification of automatically added entries is not allowed | 245 | // Modification of automatically added entries is not allowed | ||
228 | // Multiple entries cannot be edited at once | 246 | // Multiple entries cannot be edited at once | ||
229 | if (item) { | 247 | if (item) { | ||
230 | MyMoneyPrice price = item->data(0, Qt::UserRole).value<MyMoneyPrice>(); | 248 | MyMoneyPrice price = item->data(0, Qt::UserRole).value<MyMoneyPrice>(); | ||
231 | if (price.source() == "KMyMoney" || itemsList.count() > 1) | 249 | if (price.source() == "KMyMoney" || itemsList.count() > 1) | ||
232 | m_editButton->setEnabled(false); | 250 | d->ui->m_editButton->setEnabled(false); | ||
233 | emit selectObject(price); | 251 | emit selectObject(price); | ||
234 | } | 252 | } | ||
235 | } | 253 | } | ||
236 | 254 | | |||
237 | void KMyMoneyPriceDlg::slotNewPrice() | 255 | void KMyMoneyPriceDlg::slotNewPrice() | ||
238 | { | 256 | { | ||
257 | Q_D(KMyMoneyPriceDlg); | ||||
239 | QPointer<KUpdateStockPriceDlg> dlg = new KUpdateStockPriceDlg(this); | 258 | QPointer<KUpdateStockPriceDlg> dlg = new KUpdateStockPriceDlg(this); | ||
240 | try { | 259 | try { | ||
241 | QTreeWidgetItem* item = m_priceList->currentItem(); | 260 | auto item = d->ui->m_priceList->currentItem(); | ||
242 | if (item) { | 261 | if (item) { | ||
243 | MyMoneySecurity security; | 262 | MyMoneySecurity security; | ||
244 | security = MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().from()); | 263 | security = MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().from()); | ||
245 | dlg->m_security->setSecurity(security); | 264 | dlg->ui->m_security->setSecurity(security); | ||
246 | security = MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().to()); | 265 | security = MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().to()); | ||
247 | dlg->m_currency->setSecurity(security); | 266 | dlg->ui->m_currency->setSecurity(security); | ||
248 | } | 267 | } | ||
249 | 268 | | |||
250 | if (dlg->exec()) { | 269 | if (dlg->exec()) { | ||
251 | MyMoneyPrice price(dlg->m_security->security().id(), dlg->m_currency->security().id(), dlg->date(), MyMoneyMoney::ONE); | 270 | MyMoneyPrice price(dlg->ui->m_security->security().id(), dlg->ui->m_currency->security().id(), dlg->date(), MyMoneyMoney::ONE); | ||
252 | QTreeWidgetItem* p = loadPriceItem(price); | 271 | QTreeWidgetItem* p = loadPriceItem(price); | ||
253 | m_priceList->setCurrentItem(p, true); | 272 | d->ui->m_priceList->setCurrentItem(p, true); | ||
254 | // If the user cancels the following operation, we delete the new item | 273 | // If the user cancels the following operation, we delete the new item | ||
255 | // and re-select any previously selected one | 274 | // and re-select any previously selected one | ||
256 | if (slotEditPrice() == Rejected) { | 275 | if (slotEditPrice() == Rejected) { | ||
257 | delete p; | 276 | delete p; | ||
258 | if (item) | 277 | if (item) | ||
259 | m_priceList->setCurrentItem(item, true); | 278 | d->ui->m_priceList->setCurrentItem(item, true); | ||
260 | } | 279 | } | ||
261 | } | 280 | } | ||
262 | } catch (...) { | 281 | } catch (...) { | ||
Context not available. | |||||
268 | 287 | | |||
269 | int KMyMoneyPriceDlg::slotEditPrice() | 288 | int KMyMoneyPriceDlg::slotEditPrice() | ||
270 | { | 289 | { | ||
290 | Q_D(KMyMoneyPriceDlg); | ||||
271 | int rc = Rejected; | 291 | int rc = Rejected; | ||
272 | QTreeWidgetItem* item = m_priceList->currentItem(); | 292 | auto item = d->ui->m_priceList->currentItem(); | ||
273 | if (item) { | 293 | if (item) { | ||
274 | MyMoneySecurity from(MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().from())); | 294 | MyMoneySecurity from(MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().from())); | ||
275 | MyMoneySecurity to(MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().to())); | 295 | MyMoneySecurity to(MyMoneyFile::instance()->security(item->data(0, Qt::UserRole).value<MyMoneyPrice>().to())); | ||
Context not available. | |||||
294 | 314 | | |||
295 | void KMyMoneyPriceDlg::slotDeletePrice() | 315 | void KMyMoneyPriceDlg::slotDeletePrice() | ||
296 | { | 316 | { | ||
297 | QList<QTreeWidgetItem*> listItems = m_priceList->selectedItems(); | 317 | Q_D(KMyMoneyPriceDlg); | ||
318 | QList<QTreeWidgetItem*> listItems = d->ui->m_priceList->selectedItems(); | ||||
298 | if (listItems.count() > 0) { | 319 | if (listItems.count() > 0) { | ||
299 | if (KMessageBox::questionYesNo(this, i18np("Do you really want to delete the selected price entry?", "Do you really want to delete the selected price entries?", listItems.count()), i18n("Delete price information"), KStandardGuiItem::yes(), KStandardGuiItem::no(), "DeletePrice") == KMessageBox::Yes) { | 320 | if (KMessageBox::questionYesNo(this, i18np("Do you really want to delete the selected price entry?", "Do you really want to delete the selected price entries?", listItems.count()), i18n("Delete price information"), KStandardGuiItem::yes(), KStandardGuiItem::no(), "DeletePrice") == KMessageBox::Yes) { | ||
300 | MyMoneyFileTransaction ft; | 321 | MyMoneyFileTransaction ft; | ||
Context not available. | |||||
321 | 342 | | |||
322 | void KMyMoneyPriceDlg::slotOpenContextMenu(const QPoint& p) | 343 | void KMyMoneyPriceDlg::slotOpenContextMenu(const QPoint& p) | ||
323 | { | 344 | { | ||
324 | QTreeWidgetItem* item = m_priceList->itemAt(p); | 345 | Q_D(KMyMoneyPriceDlg); | ||
346 | auto item = d->ui->m_priceList->itemAt(p); | ||||
325 | if (item) { | 347 | if (item) { | ||
326 | m_priceList->setCurrentItem(item, QItemSelectionModel::ClearAndSelect); | 348 | d->ui->m_priceList->setCurrentItem(item, QItemSelectionModel::ClearAndSelect); | ||
327 | emit openContextMenu(item->data(0, Qt::UserRole).value<MyMoneyPrice>()); | 349 | emit openContextMenu(item->data(0, Qt::UserRole).value<MyMoneyPrice>()); | ||
328 | } | 350 | } | ||
329 | } | 351 | } | ||
Context not available. |