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

Method loadData

gui/nnotebookview.cpp:235–286  ·  view source on GitHub ↗

Load up the data from the database

Source from the content-addressed store, hash-verified

233
234// Load up the data from the database
235void NNotebookView::loadData() {
236 NSqlQuery query(global.db);
237 NotebookTable notebookTable(global.db);
238 QList<qint32> closedLids;
239 notebookTable.getClosedNotebooks(closedLids);
240
241
242 QHash<qint32, NNotebookViewItem*>::iterator i1;
243 for (i1=dataStore.begin(); i1!=dataStore.end(); ++i1) {
244 if (i1.value() != NULL)
245 i1.value()->setHidden(true);
246 }
247
248 QHash<QString, NNotebookViewItem*>::iterator i2;
249 for (i2=stackStore.begin(); i2!=stackStore.end(); ++i2) {
250 if (i2.value() != NULL)
251 i2.value()->setHidden(true);
252 }
253
254 dataStore.clear();
255 query.exec("Select lid, name, stack, username from NotebookModel order by username, name");
256 while (query.next()) {
257 qint32 lid = query.value(0).toInt();
258 if (!notebookTable.isDeleted(query.value(0).toInt())) {
259 NNotebookViewItem *newWidget = new NNotebookViewItem(lid);
260 newWidget->setData(NAME_POSITION, Qt::DisplayRole, query.value(1).toString());
261 newWidget->setData(NAME_POSITION, Qt::UserRole, lid);
262 if (closedLids.contains(lid))
263 newWidget->setHidden(true);
264 QString username = query.value(3).toString();
265 if (username.trimmed() != "")
266 newWidget->stack = username;
267 else
268 newWidget->stack = query.value(2).toString();
269 this->dataStore.insert(query.value(0).toInt(), newWidget);
270 root->addChild(newWidget);
271
272 if (newWidget->stack != "" && !stackStore.contains(newWidget->stack)) {
273 NNotebookViewItem *stackWidget = new NNotebookViewItem(0);
274 stackWidget->setData(NAME_POSITION, Qt::DisplayRole, newWidget->stack);
275 stackWidget->setData(NAME_POSITION, Qt::UserRole, "STACK");
276 if (username != "")
277 stackWidget->setType(NNotebookViewItem::LinkedStack);
278 stackStore.insert(newWidget->stack, stackWidget);
279 root->addChild(stackWidget);
280 }
281 }
282 }
283 query.finish();
284 this->rebuildTree();
285 this->resetSize();
286}
287
288
289// Rebuild the notebook tree view

Callers 1

NNotebookViewMethod · 0.95

Calls 11

rebuildTreeMethod · 0.95
resetSizeMethod · 0.95
getClosedNotebooksMethod · 0.80
valueMethod · 0.80
setDataMethod · 0.80
insertMethod · 0.80
setTypeMethod · 0.80
clearMethod · 0.45
execMethod · 0.45
isDeletedMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected