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

Method add

sql/sharednotebooktable.cpp:85–191  ·  view source on GitHub ↗

Add a new shared notebook

Source from the content-addressed store, hash-verified

83
84// Add a new shared notebook
85qint32 SharedNotebookTable::add(qint32 l, const SharedNotebook &t, bool isDirty){
86 Q_UNUSED(isDirty); //suppress unused
87 if (l>0)
88 expunge(l);
89 ConfigStore cs(db);
90 qint32 lid = l;
91 if (lid == 0)
92 lid = cs.incrementLidCounter();
93
94 NSqlQuery query(db);
95 db->lockForWrite();
96
97 if (t.email.isSet()) {
98 query.prepare("Insert into DataStore (lid, key, data) values (:lid, :key, :data)");
99 query.bindValue(":lid", lid);
100 query.bindValue(":key", SHAREDNOTEBOOK_EMAIL);
101 QString email = t.email;
102 query.bindValue(":data",email);
103 query.exec();
104 }
105
106 if (t.id.isSet()) {
107 query.prepare("Insert into DataStore (lid, key, data) values (:lid, :key, :data)");
108 query.bindValue(":lid", lid);
109 query.bindValue(":key", SHAREDNOTEBOOK_ID);
110 qint64 id = t.id;
111 query.bindValue(":data", id);
112 query.exec();
113 }
114
115 if (t.notebookGuid.isSet()) {
116 query.prepare("Insert into DataStore (lid, key, data) values (:lid, :key, :data)");
117 query.bindValue(":lid", lid);
118 query.bindValue(":key", SHAREDNOTEBOOK_NOTEBOOK_GUID);
119 QString notebookGuid = t.notebookGuid;
120 query.bindValue(":data", notebookGuid);
121 query.exec();
122 }
123
124 if (t.notebookModifiable.isSet()) {
125 query.prepare("Insert into DataStore (lid, key, data) values (:lid, :key, :data)");
126 query.bindValue(":lid", lid);
127 query.bindValue(":key", SHAREDNOTEBOOK_MODIFIABLE);
128 bool mod = t.notebookModifiable;
129 query.bindValue(":data", mod);
130 query.exec();
131 }
132 if (t.privilege.isSet()) {
133 query.prepare("Insert into DataStore (lid, key, data) values (:lid, :key, :data)");
134 query.bindValue(":lid", lid);
135 query.bindValue(":key", SHAREDNOTEBOOK_PRIVILEGE);
136 qint32 priv = t.privilege;
137 query.bindValue(":data", priv);
138 query.exec();
139 }
140 if (t.requireLogin.isSet()) {
141 query.prepare("Insert into DataStore (lid, key, data) values (:lid, :key, :data)");
142 query.bindValue(":lid", lid);

Callers

nothing calls this directly

Calls 7

incrementLidCounterMethod · 0.80
lockForWriteMethod · 0.80
bindValueMethod · 0.80
isSetMethod · 0.45
prepareMethod · 0.45
execMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected