int main(int argc, char* argv[]) { Application* app = new Application(ApplicationConfig(800, 600, "Test Harness")); try { app->AttachService<ScriptingService>(); app->AttachService<FramesService>(); app->Startup(); ScriptingService* scripting = dynamic_cast<ScriptingService*>(app->GetService("SCRIPTING")); scripting->RunFile("./boot.lua"); app->Execute(); app->Shutdown(); } catch (exception ex) { cerr << "Exception occurred: " << ex.what() << endl; } delete app; return 0; }
/** * Stores all notes that were changed to disk * * @param currentNote will be set by this method if the filename of the current * note has changed * @param currentNoteChanged true if current note was changed * @param noteWasRenamed true if a note was renamed * @return amount of notes that were saved */ int Note::storeDirtyNotesToDisk(Note ¤tNote, bool *currentNoteChanged, bool *noteWasRenamed) { QSqlDatabase db = QSqlDatabase::database("memory"); QSqlQuery query(db); ScriptingService* scriptingService = ScriptingService::instance(); Note note; // qDebug() << "storeDirtyNotesToDisk"; query.prepare("SELECT * FROM note WHERE has_dirty_data = 1"); if (!query.exec()) { qWarning() << __func__ << ": " << query.lastError(); return 0; } else { int count = 0; for (int r = 0; query.next(); r++) { note = noteFromQuery(query); QString oldName = note.getName(); note.storeNoteTextFileToDisk(); QString newName = note.getName(); // check if the file name has changed if (oldName != newName) { // rename the note file names of note tag links Tag::renameNoteFileNamesOfLinks(oldName, newName); *noteWasRenamed = true; // override the current note because the file name has changed currentNote = note; } // emit the signal for the QML that the note was stored emit scriptingService->noteStored( QVariant::fromValue( static_cast<QObject*>(NoteApi::fromNote(note)))); // reassign currentNote if filename of currentNote has changed if (note.isSameFile(currentNote)) { *currentNoteChanged = true; } qDebug() << "stored note: " << note; count++; } return count; } }
int Note::storeDirtyNotesToDisk(Note ¤tNote) { QSqlDatabase db = QSqlDatabase::database("memory"); QSqlQuery query(db); ScriptingService* scriptingService = ScriptingService::instance(); Note note; // qDebug() << "storeDirtyNotesToDisk"; query.prepare("SELECT * FROM note WHERE has_dirty_data = 1"); if (!query.exec()) { qWarning() << __func__ << ": " << query.lastError(); return 0; } else { int count = 0; for (int r = 0; query.next(); r++) { note = noteFromQuery(query); QString oldFileName = note.getFileName(); note.storeNoteTextFileToDisk(); QString newFileName = note.getFileName(); // emit the signal for the QML that the note was stored emit scriptingService->noteStored( QVariant::fromValue( static_cast<QObject*>(NoteApi::fromNote(note)))); // reassign currentNote if filename of currentNote has changed if ((oldFileName == currentNote.getFileName()) && (oldFileName != newFileName)) { currentNote = note; qDebug() << "filename of currentNote has changed to: " << newFileName; } qDebug() << "stored note: " << note; count++; } return count; } }