MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / createNoteByTemplateCore

Method createNoteByTemplateCore

src/WizMainWindow.cpp:1236–1320  ·  view source on GitHub ↗

! Create document from template \a tmplData. */

Source from the content-addressed store, hash-verified

1234 Create document from template \a tmplData.
1235 */
1236void WizMainWindow::createNoteByTemplateCore(const TemplateData& tmplData)
1237{
1238 QFileInfo info(tmplData.strFileName);
1239 initVariableBeforCreateNote();
1240
1241 QString kbGUID;
1242 WIZTAGDATA currTag;
1243 QString currLocation;
1244 m_category->getAvailableNewNoteTagAndLocation(kbGUID, currTag, currLocation);
1245
1246 if (currLocation.isEmpty())
1247 currLocation = m_dbMgr.db(kbGUID).getDefaultNoteLocation();
1248
1249 WIZDOCUMENTDATAEX data;
1250 data.strKbGUID = kbGUID;
1251 data.strType = tmplData.buildInName;
1252 data.strTitle = tmplData.strTitle.isEmpty() ? info.completeBaseName() : tmplData.strTitle;
1253
1254 // Journal {date}({week})
1255 if (tmplData.strTitle.isEmpty()) {
1256 data.strTitle = tmplData.strName;
1257 } else {
1258 WizOleDateTime dt;
1259 data.strTitle.replace("{date}", dt.toLocalLongDate());
1260 data.strTitle.replace("{date_time}", dt.toLocalLongDate() + " " + dt.toString("hh:mm:ss"));
1261 QLocale local;
1262 data.strTitle.replace("{week}", local.toString(dt.toLocalTime(), "ddd"));
1263 }
1264
1265 // Personal
1266 if (kbGUID.isEmpty()) {
1267 data.strKbGUID = m_dbMgr.db().kbGUID();
1268 data.strLocation = tmplData.strFolder;
1269
1270 if (data.strLocation.isEmpty()) {
1271 data.strLocation = currLocation;
1272 } else {
1273 data.strLocation.replace("{year}", QDate::currentDate().toString("yyyy"));
1274 data.strLocation.replace("{month}", QDate::currentDate().toString("MM"));
1275
1276 if (WizCategoryViewFolderItem* folder = m_category->findFolder(data.strLocation, true, false))
1277 {
1278 if (m_category->currentItem() != folder)
1279 {
1280 m_category->setCurrentItem(folder);
1281 }
1282 }
1283 }
1284 } else {
1285 data.strLocation = currLocation;
1286 }
1287
1288 // Actually create the note
1289 WizNoteManager noteManager(m_dbMgr);
1290 if (data.strType == "collaboration") {
1291 CollaborationDocView *newView = new CollaborationDocView(data, *this, this);
1292 newView->createDocument(currTag);
1293 m_mainTabBrowser->createTab(newView);

Callers

nothing calls this directly

Calls 14

createHandwritingNoteFunction · 0.85
viewDocumentFunction · 0.85
isEmptyMethod · 0.80
toLocalLongDateMethod · 0.80
createTabMethod · 0.80
getSelectedDocumentsMethod · 0.80
sizeMethod · 0.80
toStringMethod · 0.45
kbGUIDMethod · 0.45
findFolderMethod · 0.45

Tested by

no test coverage detected