MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / refreshData

Method refreshData

gui/ntableview.cpp:454–496  ·  view source on GitHub ↗

Update the list of notes.

Source from the content-addressed store, hash-verified

452
453// Update the list of notes.
454void NTableView::refreshData() {
455 QLOG_TRACE() << "Getting valid lids in filter";
456
457 // Save the current selection in case we need it later
458 priorSelectedLids.clear();
459 getSelectedLids(priorSelectedLids);
460 priorLidOrder.clear();
461 for (int i=0; i<proxy->rowCount(); i++) {
462 QModelIndex idx = proxy->index(i, NOTE_TABLE_LID_POSITION);
463 priorLidOrder.append(idx.data().toInt());
464 }
465
466 NSqlQuery sql(global.db);
467 sql.exec("select lid from filter");
468 proxy->lidMap->clear();
469 while(sql.next()) {
470 proxy->lidMap->insert(sql.value(0).toInt(), 0);
471 }
472 sql.finish();
473 QLOG_DEBUG() << "Valid LIDs retrieved. Refreshing selection";
474 model()->select();
475 while(model()->canFetchMore())
476 model()->fetchMore();
477
478 // resort the table. I'm not sure why, but it doesn't always
479 // do this itself.
480 Qt::SortOrder so = this->tableViewHeader->sortIndicatorOrder();
481 int si = this->tableViewHeader->sortIndicatorSection();
482 this->sortByColumn(si, so);
483
484 // Re-select any notes
485 refreshSelection();
486 if (this->tableViewHeader->isThumbnailVisible())
487 verticalHeader()->setDefaultSectionSize(100);
488 else {
489 QFont f = font();
490 global.getGuiFont(f);
491 //f.setPointSize(global.defaultGuiFontSize);
492 QFontMetrics fm(f);
493 verticalHeader()->setDefaultSectionSize(fm.height());
494 //verticalHeader()->setDefaultSectionSize(QApplication::fontMetrics().height()*200);
495 }
496}
497
498
499// The note list changed, so we need to reselect any valid notes.

Callers 1

Calls 8

indexMethod · 0.80
dataMethod · 0.80
insertMethod · 0.80
valueMethod · 0.80
isThumbnailVisibleMethod · 0.80
getGuiFontMethod · 0.80
clearMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected