MCPcopy Create free account
hub / github.com/LUX-Core/lux / setModel

Method setModel

src/qt/transactionview.cpp:226–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void TransactionView::setModel(WalletModel* model)
227{
228 QSettings settings;
229 this->model = model;
230 if (model) {
231 transactionProxyModel = new TransactionFilterProxy(this);
232 transactionProxyModel->setSourceModel(model->getTransactionTableModel());
233 transactionProxyModel->setDynamicSortFilter(true);
234 transactionProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
235 transactionProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
236
237 transactionProxyModel->setSortRole(Qt::EditRole);
238
239 transactionView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
240 transactionView->setModel(transactionProxyModel);
241 transactionView->setAlternatingRowColors(true);
242 transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
243 transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
244 transactionView->setSortingEnabled(true);
245 transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder);
246 transactionView->verticalHeader()->hide();
247
248 transactionView->setColumnWidth(TransactionTableModel::Status, STATUS_COLUMN_WIDTH);
249 transactionView->setColumnWidth(TransactionTableModel::Watchonly, WATCHONLY_COLUMN_WIDTH);
250 transactionView->setColumnWidth(TransactionTableModel::Date, DATE_COLUMN_WIDTH);
251 transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
252 transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
253
254 // Note: it's a good idea to connect this signal AFTER the model is set
255 connect(transactionView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(computeSum()));
256
257 columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH, this);
258
259 if (model->getOptionsModel()) {
260 // Add third party transaction URLs to context menu
261 QStringList listUrls = model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts);
262 for (int i = 0; i < listUrls.size(); ++i) {
263 QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
264 if (!host.isEmpty()) {
265 QAction* thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label
266 if (i == 0)
267 contextMenu->addSeparator();
268 contextMenu->addAction(thirdPartyTxUrlAction);
269 connect(thirdPartyTxUrlAction, SIGNAL(triggered()), mapperThirdPartyTxUrls, SLOT(map()));
270 mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed());
271 }
272 }
273 }
274
275 // show/hide column Watch-only
276 updateWatchOnlyColumn(model->haveWatchOnly());
277
278 // Watch-only signal
279 connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyColumn(bool)));
280
281 // Update transaction list with persisted settings
282 chooseType(settings.value("transactionType").toInt());
283 chooseDate(settings.value("transactionDate").toInt());

Callers 2

exportClickedMethod · 0.45
editLabelMethod · 0.45

Calls 10

hideMethod · 0.80
haveWatchOnlyMethod · 0.80
toIntMethod · 0.80
QUrlClass · 0.70
getOptionsModelMethod · 0.45
sizeMethod · 0.45
hostMethod · 0.45
isEmptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected