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

Method NNotebookView

gui/nnotebookview.cpp:49–160  ·  view source on GitHub ↗

Constructor

Source from the content-addressed store, hash-verified

47
48// Constructor
49NNotebookView::NNotebookView(QWidget *parent) :
50 QTreeWidget(parent)
51{
52 stackStore.clear();
53 dataStore.clear();
54 this->setFont(global.getGuiFont(font()));
55
56 filterPosition = -1;
57 maxCount = 0; // Highest count of any notebook. Used in calculating column width
58 // setup options
59 this->setEditTriggers(QAbstractItemView::NoEditTriggers);
60 this->setSelectionBehavior(QAbstractItemView::SelectRows);
61 this->setSelectionMode(QAbstractItemView::SingleSelection);
62 this->setRootIsDecorated(true);
63 this->setSortingEnabled(false);
64 this->header()->setVisible(false);
65 this->setStyleSheet("QTreeView {border-image:none; image:none;} ");
66 root = new NNotebookViewItem(0);
67 root->setType(NNotebookViewItem::Stack);
68 root->setData(NAME_POSITION, Qt::UserRole, "rootsynchronized");
69 root->setData(NAME_POSITION, Qt::DisplayRole, tr("Notebooks"));
70 QFont rootFont = root->font(NAME_POSITION);
71 rootFont.setBold(true);
72 root->setFont(NAME_POSITION, rootFont);
73
74 root->setRootColor(false);
75
76 this->setMinimumHeight(1);
77 this->addTopLevelItem(root);
78 this->rebuildNotebookTreeNeeded = true;
79 this->loadData();
80 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
81 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
82 connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
83 connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
84 connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection()));
85
86 addAction = context.addAction(tr("Create New Notebook"));
87 addAction->setShortcut(QKeySequence(Qt::Key_Insert));
88 addAction->setShortcutContext(Qt::WidgetShortcut);
89
90 addShortcut = new QShortcut(this);
91 addShortcut->setKey(QKeySequence(Qt::Key_Insert));
92 addShortcut->setContext(Qt::WidgetShortcut);
93
94 context.addSeparator();
95 deleteAction = context.addAction(tr("Delete"));
96 deleteAction->setShortcut(QKeySequence(Qt::Key_Delete));
97
98 deleteShortcut = new QShortcut(this);
99 deleteShortcut->setKey(QKeySequence(Qt::Key_Delete));
100 deleteShortcut->setContext(Qt::WidgetShortcut);
101
102 // Start building the stack menu
103 stackMenu = context.addMenu(tr("Add to stack"));
104 QAction *newAction;
105 NotebookTable table(global.db);
106 QStringList stacks;

Callers

nothing calls this directly

Calls 9

loadDataMethod · 0.95
getGuiFontMethod · 0.80
setTypeMethod · 0.80
setDataMethod · 0.80
setKeyMethod · 0.80
addSeparatorMethod · 0.80
clearMethod · 0.45
setRootColorMethod · 0.45
getStacksMethod · 0.45

Tested by

no test coverage detected