Update the list of notes.
| 452 | |
| 453 | // Update the list of notes. |
| 454 | void 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. |
no test coverage detected