[longomatch/redesign: 5/23] Rename Sections to Categories and apply new API changes
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign: 5/23] Rename Sections to Categories and apply new API changes
- Date: Tue, 23 Nov 2010 00:14:09 +0000 (UTC)
commit fd00d93edf8723b7df59eed3d29fa88d87ea92ba
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Nov 21 16:19:11 2010 +0100
Rename Sections to Categories and apply new API changes
LongoMatch/DB/CategoriesTemplate.cs | 177 +++++++++++++++++++++
LongoMatch/DB/Sections.cs | 293 -----------------------------------
2 files changed, 177 insertions(+), 293 deletions(-)
---
diff --git a/LongoMatch/DB/CategoriesTemplate.cs b/LongoMatch/DB/CategoriesTemplate.cs
new file mode 100644
index 0000000..9685b8c
--- /dev/null
+++ b/LongoMatch/DB/CategoriesTemplate.cs
@@ -0,0 +1,177 @@
+// Sections.cs
+//
+// Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Gdk;
+using LongoMatch.TimeNodes;
+
+namespace LongoMatch.DB
+{
+
+ /// <summary>
+ /// I am a template for the analysis categories used in a project.
+ /// I describe each one of the categories and provide the default values
+ /// to use to create plys in a specific category.
+ /// The position of the category in the index is very important and should
+ /// respect the same index used in the plays list inside a project.
+ /// The <see cref="LongoMatch.DB.Project"/> must handle all the changes
+ /// </summary>
+ [Serializable]
+ public class Categories
+ {
+ private List<Category> categoriesList;
+
+
+ /// <summary>
+ /// Creates a new template
+ /// </summary>
+ public Categories()
+ {
+ categoriesList = new List<Category>();
+ }
+
+ /// <summary>
+ /// Clear the template
+ /// </summary>
+ public void Clear() {
+ categoriesList.Clear();
+ }
+
+ /// <summary>
+ /// Adds a new analysis category to the template
+ /// </summary>
+ /// <param name="tn">
+ /// A <see cref="Category"/>: category to add
+ /// </param>
+ public void AddCategory(Category category) {
+ categoriesList.Add(category);
+ }
+
+ public void AddCategoryAtPos(int pos, Category category) {
+ categoriesList.Insert(pos, category);
+ }
+
+ /// <summary>
+ /// Delete a category from the templates using the it's index
+ /// </summary>
+ /// <param name="index">
+ /// A <see cref="System.Int32"/>: position of the category to delete
+ /// </param>
+ public void RemoveCategory(Category category) {
+ categoriesList.Remove(category);
+ }
+
+ //// <value>
+ /// Number of categories
+ /// </value>
+ public int Count {
+ get {
+ return categoriesList.Count;
+ }
+ }
+
+ //// <value>
+ /// Ordered list with all the categories
+ /// </value>
+ public List<Category> CategoriesList {
+ set {
+ categoriesList.Clear();
+ categoriesList = value;
+ }
+ get {
+ return categoriesList;
+ }
+ }
+
+ /// <summary>
+ /// Retrieves a category at a given index
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position of the category to retrieve
+ /// </param>
+ /// <returns>
+ /// A <see cref="SectionsTimeNode"/>: category retrieved
+ /// </returns>
+ public Category GetCategoryAtPos(int pos) {
+ return categoriesList[pos];
+ }
+
+ /// <summary>
+ /// Returns an array if strings with the categories names
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
+ public List<string> GetSectionsNames() {
+ return (from c in categoriesList
+ orderby c.Position
+ select c.Name).ToList();
+ }
+
+ /// <summary>
+ /// Returns an array of the categories' color
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Color"/>
+ /// </returns>
+ public List<Color> GetColors() {
+ return (from c in categoriesList
+ orderby c.Position
+ select c.Color).ToList();
+ }
+
+ /// <summary>
+ /// Return an array of the hotkeys for this template
+ /// </summary>
+ /// <returns>
+ /// A <see cref="HotKey"/>
+ /// </returns>
+ public List<HotKey> GetHotKeys() {
+ return (from c in categoriesList
+ orderby c.Position
+ select c.HotKey).ToList();
+ }
+
+ /// <summary>
+ /// Returns an array with the default start times
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Time"/>
+ /// </returns>
+ public List<Time> GetSectionsStartTimes() {
+ return (from c in categoriesList
+ orderby c.Position
+ select c.Start).ToList();
+ }
+
+ /// <summary>
+ /// Returns an array with the defaul stop times
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Time"/>
+ /// </returns>
+ public List<Time> GetSectionsStopTimes() {
+ return (from c in categoriesList
+ orderby c.Position
+ select c.Stop).ToList();
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]