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

Method contextMenuEvent

gui/ntableview.cpp:367–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365
366
367void NTableView::contextMenuEvent(QContextMenuEvent *event) {
368 openNoteAction->setEnabled(false);
369 deleteNoteAction->setEnabled(false);
370 QList<qint32> lids;
371 getSelectedLids(lids);
372 mergeNotesAction->setVisible(false);
373
374 // Deterimne if the merge notes menu option is visible.
375 // If it is a read-only notebook or if the number of selected notes
376 // is < 1 then we can't merge.
377 if (lids.size() > 1) {
378 mergeNotesAction->setVisible(true);
379 NoteTable nTable(global.db);
380 NotebookTable bookTable(global.db);
381 for (int i=0; i<lids.size(); i++) {
382 qint32 notebookLid = nTable.getNotebookLid(lids[i]);
383 if (bookTable.isReadOnly(notebookLid)) {
384 mergeNotesAction->setVisible(false);
385 i=lids.size();
386 }
387 }
388 }
389 if (lids.size() > 0) {
390 bool readOnlySelected = false;
391 for (int i=0; i<lids.size(); i++) {
392 Note n;
393 NotebookTable bTable(global.db);
394 NoteTable nTable(global.db);
395 nTable.get(n, lids[i], false, false);
396 qint32 notebookLid = bTable.getLid(n.notebookGuid);
397 if (bTable.isReadOnly(notebookLid)) {
398 readOnlySelected = true;
399 i=lids.size();
400 }
401 }
402 if (!readOnlySelected)
403 deleteNoteAction->setEnabled(true);
404 openNoteAction->setEnabled(true);
405 }
406 if (global.filterCriteria[global.filterPosition]->isDeletedOnlySet() &&
407 global.filterCriteria[global.filterPosition]->getDeletedOnly())
408 restoreNoteAction->setVisible(true);
409 else
410 restoreNoteAction->setVisible(false);
411 contextMenu->popup(event->globalPos());
412}
413
414
415

Callers

nothing calls this directly

Calls 7

setEnabledMethod · 0.80
getNotebookLidMethod · 0.80
isReadOnlyMethod · 0.80
isDeletedOnlySetMethod · 0.80
getDeletedOnlyMethod · 0.80
getMethod · 0.45
getLidMethod · 0.45

Tested by

no test coverage detected