[longomatch] Save fake live projects directly into the DB
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Save fake live projects directly into the DB
- Date: Sun, 18 Dec 2011 21:43:15 +0000 (UTC)
commit f65a4c1162cd8b0a93eb61bc81982bc5a25aeca4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Dec 12 01:56:39 2011 +0100
Save fake live projects directly into the DB
.../Gui/Component/ProjectDetailsWidget.cs | 9 ++-
LongoMatch.GUI/Gui/GUIToolkit.cs | 14 ++--
LongoMatch.Services/Services/ProjectsManager.cs | 70 +++++++++-----------
3 files changed, 45 insertions(+), 48 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs b/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs
index eaf7769..7118201 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs
@@ -377,7 +377,8 @@ namespace LongoMatch.Gui.Component
i++;
}
tagscombobox.Active = index;
- Categories = tpc.Load(SelectedCategory);
+ if (Categories == null)
+ Categories = tpc.Load(SelectedCategory);
}
private void FillTeamsTemplate() {
@@ -395,8 +396,10 @@ namespace LongoMatch.Gui.Component
}
localcombobox.Active = index;
visitorcombobox.Active = index;
- LocalTeamTemplate = tpt.Load(LocalTeamTemplateFile);
- VisitorTeamTemplate = tpt.Load(VisitorTeamTemplateFile);
+ if (LocalTeamTemplate == null) {
+ LocalTeamTemplate = tpt.Load(LocalTeamTemplateFile);
+ VisitorTeamTemplate = tpt.Load(VisitorTeamTemplateFile);
+ }
}
private void FillFormats() {
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 098fc89..1ba07d7 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -230,7 +230,7 @@ namespace LongoMatch.Gui
public Project EditFakeProject(IDatabase db, Project project, ITemplatesService ts) {
CaptureSettings captureSettings = new CaptureSettings();
- return NewProject(db, null, ProjectType.FakeCaptureProject, ts, null, out captureSettings);
+ return NewProject(db, project, ProjectType.EditProject, ts, null, out captureSettings);
}
public IBusyDialog BusyDialog(string message) {
@@ -249,10 +249,10 @@ namespace LongoMatch.Gui
npd.TransientFor = mainWindow as Gtk.Window;
npd.Use = type;
+ npd.TemplatesService = tps;
npd.Project = project;
if(type == ProjectType.CaptureProject)
npd.Devices = devices;
- npd.TemplatesService = tps;
int response = npd.Run();
while(true) {
if(response != (int)ResponseType.Ok) {
@@ -285,10 +285,12 @@ namespace LongoMatch.Gui
button = "gtk-open";
fChooser = new FileChooserDialog(title, mainWindow as Gtk.Window, action,
- "gtk-cancel",ResponseType.Cancel,
- button,ResponseType.Accept);
- fChooser.SetCurrentFolder(defaultFolder);
- fChooser.SetFilename(defaultName);
+ "gtk-cancel",ResponseType.Cancel, button, ResponseType.Accept);
+
+ if (defaultFolder != null)
+ fChooser.SetCurrentFolder(defaultFolder);
+ if (defaultName != null)
+ fChooser.SetFilename(defaultName);
filter = new FileFilter();
filter.Name = filterName;
filter.AddPattern(extensionFilter);
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index 2bc389b..0ca7259 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -116,24 +116,8 @@ namespace LongoMatch.Services
SetProject(project, ProjectType.FileProject, new CaptureSettings());
}
- private void SaveFakeLiveProject(Project project) {
- Log.Debug("Saving fake live project " + project);
- guiToolkit.InfoMessage(Catalog.GetString("The project will be saved to a file. " +
- "You can insert it later into the database using the "+
- "\"Import project\" function once you copied the video file " +
- "to your computer"));
-
- var filename = guiToolkit.SaveFile(Catalog.GetString("Save Project"), null, Config.HomeDir(),
- Constants.PROJECT_NAME, "*.lpr");
- if(filename != null) {
- Project.Export(project, filename);
- guiToolkit.InfoMessage(Catalog.GetString("Project saved successfully."));
- }
- }
-
private void ImportProject() {
Project project;
- bool isFake, exists;
string fileName;
Log.Debug("Importing project");
@@ -156,16 +140,6 @@ namespace LongoMatch.Services
return;
}
- isFake = (project.Description.File.FilePath == Constants.FAKE_PROJECT);
-
- /* If it's a fake live project prompt for a video file and
- * create a new PreviewMediaFile for this project */
- if(isFake) {
- Log.Debug ("Importing fake live project");
- project.Description.File = null;
- project = guiToolkit.EditFakeProject(Core.DB, project, Core.TemplatesService);
- }
-
/* If the project exists ask if we want to overwrite it */
if(Core.DB.Exists(project)) {
var res = guiToolkit.QuestionMessage(Catalog.GetString("A project already exists for the file:") +
@@ -173,16 +147,10 @@ namespace LongoMatch.Services
Catalog.GetString("Do you want to overwrite it?"), null);
if(!res)
return;
- exists = true;
- } else
- exists = false;
-
- if(isFake)
- CreateThumbnails(project);
- if(exists)
Core.DB.UpdateProject(project);
- else
+ } else {
Core.DB.AddProject(project);
+ }
guiToolkit.InfoMessage(Catalog.GetString("Project successfully imported."));
}
@@ -313,7 +281,11 @@ namespace LongoMatch.Services
Log.Exception(e);
}
} else if (projectType == ProjectType.FakeCaptureProject) {
- SaveFakeLiveProject(project);
+ try {
+ Core.DB.AddProject(project);
+ } catch (Exception e) {
+ Log.Exception(e);
+ }
} else if (projectType == ProjectType.CaptureProject) {
SaveCaptureProject(project);
}
@@ -351,11 +323,31 @@ namespace LongoMatch.Services
}
protected void OpenProject() {
- ProjectDescription project = null;
+ Project project = null;
+ ProjectDescription projectDescription = null;
- project = guiToolkit.SelectProject(Core.DB.GetAllProjects());
- if(project != null)
- SetProject(Core.DB.GetProject(project.UUID), ProjectType.FileProject, new CaptureSettings());
+ projectDescription = guiToolkit.SelectProject(Core.DB.GetAllProjects());
+ if (projectDescription == null)
+ return;
+
+ project = Core.DB.GetProject(projectDescription.UUID);
+
+ if (project.Description.File.FilePath == Constants.FAKE_PROJECT) {
+ /* If it's a fake live project prompt for a video file and
+ * create a new PreviewMediaFile for this project and recreate the thumbnails */
+ Log.Debug ("Importing fake live project");
+ project.Description.File = null;
+
+ guiToolkit.InfoMessage(
+ Catalog.GetString("You are opening a live project without any video file associated yet.") +
+ "\n" + Catalog.GetString("Select a video file in the step."));
+
+ project = guiToolkit.EditFakeProject(Core.DB, project, Core.TemplatesService);
+ if (project == null)
+ return;
+ CreateThumbnails(project);
+ }
+ SetProject(project, ProjectType.FileProject, new CaptureSettings());
}
protected void ExportProject() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]