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

Method moveToNewStackRequested

gui/nnotebookview.cpp:798–848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796
797
798void NNotebookView::moveToNewStackRequested() {
799 QList<QTreeWidgetItem*> items = selectedItems();
800 if (items.size() == 0)
801 return;
802
803 QString newStackName = "New Stack";
804 int i=1;
805 QString iStr;
806 QList<int> books;
807 NotebookTable table(global.db);
808
809 while (i>=0) {
810 books.clear();
811 table.findByStack(books, newStackName);
812 if (books.size() == 0) {
813 i=-1;
814 } else {
815 iStr = QVariant(i).toString();
816 newStackName = tr("New Stack (") +iStr +tr(")");
817 i++;
818 }
819 }
820
821 // Create the new stack & move the child to it
822 NNotebookViewItem *newStack = new NNotebookViewItem(0);
823 newStack->setText(NAME_POSITION, newStackName);
824 newStack->setData(NAME_POSITION, Qt::UserRole, "STACK");
825 stackStore.insert(newStackName, newStack);
826 topLevelItem(0)->addChild(newStack);
827 items[0]->parent()->removeChild(items[0]);
828 newStack->addChild(items[0]);
829
830 // Create a new action item for the menu
831 QAction *newAction = stackMenu->addAction(newStackName);
832 connect(newAction, SIGNAL(triggered()), this, SLOT(moveToStackRequested()));
833 menuData.insert(newStackName, newAction);
834 sortStackMenu();
835
836 // Update the note in the database
837 qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt();
838 Notebook book;
839 table.get(book, lid);
840 book.stack = newStackName;
841 table.update(book, true);
842
843 this->sortItems(NAME_POSITION, Qt::AscendingOrder);
844 resetSize();
845 this->sortByColumn(NAME_POSITION);
846 newStack->setExpanded(true);
847 emit(stackAdded(newStackName));
848}
849
850
851void NNotebookView::removeFromStackRequested() {

Callers

nothing calls this directly

Calls 9

setDataMethod · 0.80
insertMethod · 0.80
dataMethod · 0.80
clearMethod · 0.45
findByStackMethod · 0.45
toStringMethod · 0.45
setTextMethod · 0.45
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected