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

Method buildSelection

gui/nnotebookview.cpp:431–481  ·  view source on GitHub ↗

This function is called when a user selects something within this tree. It also emits a signal that will be picked up by the main nixnote program.

Source from the content-addressed store, hash-verified

429// be picked up by the main nixnote program.
430//*************************************************************
431void NNotebookView::buildSelection() {
432 QLOG_TRACE() << "Inside NNotebookView::buildSelection()";
433
434 QList<QTreeWidgetItem*> selectedItems = this->selectedItems();
435 if (selectedItems.size() > 0 && selectedItems[0]->data(0,Qt::UserRole).toString().startsWith("root"), Qt::CaseInsensitive)
436 return;
437
438 // First, find out if we're already viewing history. If we are we
439 // chop off the end of the history & start a new one
440 if (global.filterPosition+1 < global.filterCriteria.size()) {
441 while (global.filterPosition+1 < global.filterCriteria.size())
442 global.filterCriteria.removeLast();
443 }
444
445 int currentCount = global.filterCriteria.size();
446 FilterCriteria *newFilter = new FilterCriteria();
447 if (currentCount > 0) {
448 FilterCriteria *currentFilter = global.filterCriteria[currentCount-1];
449 if (currentFilter->isLidSet()) {
450 newFilter->setLid(currentFilter->getLid());
451 }
452 if (currentFilter->isSelectedNotesSet()) {
453 QList<qint32> lids;
454 currentFilter->getSelectedNotes(lids);
455 newFilter->setSelectedNotes(lids);
456 }
457 }
458
459 if (selectedItems.size() > 0) {
460 newFilter->setNotebook(*(selectedItems[0]));
461 }
462 qint32 notebookLid = 0;
463 if (selectedItems.size() > 0)
464 notebookLid = selectedItems[0]->data(NAME_POSITION, Qt::UserRole).toInt();
465 newFilter->resetAttribute = true;
466 newFilter->resetDeletedOnly = true;
467 newFilter->resetFavorite = true;
468 newFilter->resetNotebook = true;
469 newFilter->resetSavedSearch = true;
470 newFilter->resetTags = true;
471 newFilter->resetSearchString = true;
472
473 filterPosition++;
474 global.filterPosition++;
475 global.filterCriteria.push_back(newFilter);
476
477 emit updateSelectionRequested();
478 emit notebookSelectionChanged(notebookLid);
479
480 QLOG_TRACE() << "Leaving NNotebookView::buildSelection()";
481}
482
483
484//*************************************************************

Callers

nothing calls this directly

Calls 9

dataMethod · 0.80
isLidSetMethod · 0.80
isSelectedNotesSetMethod · 0.80
getSelectedNotesMethod · 0.80
setSelectedNotesMethod · 0.80
toStringMethod · 0.45
setLidMethod · 0.45
getLidMethod · 0.45
setNotebookMethod · 0.45

Tested by

no test coverage detected