| 1 | /* |
|---|
| 2 | * SapphireImporterDataMenu.h |
|---|
| 3 | * Sapphire |
|---|
| 4 | * |
|---|
| 5 | * Created by pnmerrill on Jun. 24, 2007. |
|---|
| 6 | * Copyright 2007 Sapphire Development Team and/or www.nanopi.net |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
|---|
| 10 | * General Public License as published by the Free Software Foundation; either version 3 of the License, |
|---|
| 11 | * or (at your option) any later version. |
|---|
| 12 | * |
|---|
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
|---|
| 14 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|---|
| 15 | * Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License along with this program; if not, |
|---|
| 18 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #import "SapphireMetaData.h" |
|---|
| 22 | #import "SapphireLayerController.h" |
|---|
| 23 | |
|---|
| 24 | @protocol SapphireFileMetaDataProtocol; |
|---|
| 25 | @class SapphireImporterDataMenu; |
|---|
| 26 | |
|---|
| 27 | /*! |
|---|
| 28 | * @brief The importer protocol |
|---|
| 29 | * |
|---|
| 30 | * This protocol is the basic functionality that all importers must implement. Through this, a common UI can implement all the importers. |
|---|
| 31 | */ |
|---|
| 32 | @protocol SapphireImporter <NSObject> |
|---|
| 33 | |
|---|
| 34 | /*! |
|---|
| 35 | * @brief Import a single File |
|---|
| 36 | * |
|---|
| 37 | * @param metaData The file to import |
|---|
| 38 | * @return YES if imported, NO otherwise |
|---|
| 39 | */ |
|---|
| 40 | - (BOOL)importMetaData:(id <SapphireFileMetaDataProtocol>)metaData; |
|---|
| 41 | |
|---|
| 42 | /*! |
|---|
| 43 | * @brief Sets the importer's data menu |
|---|
| 44 | * |
|---|
| 45 | * This is the text to display under the title, stating that the importer is done. |
|---|
| 46 | * |
|---|
| 47 | * @param theDataMenu The importer's menu |
|---|
| 48 | */ |
|---|
| 49 | - (void)setImporterDataMenu:(SapphireImporterDataMenu *)theDataMenu; |
|---|
| 50 | |
|---|
| 51 | /*! |
|---|
| 52 | * @brief The completion text to display |
|---|
| 53 | * |
|---|
| 54 | * @return The completion text to display |
|---|
| 55 | */ |
|---|
| 56 | - (NSString *)completionText; |
|---|
| 57 | |
|---|
| 58 | /*! |
|---|
| 59 | * @brief The initial text to display |
|---|
| 60 | * |
|---|
| 61 | * This is the initial text to display in the title. |
|---|
| 62 | * |
|---|
| 63 | * @return The initial text to display |
|---|
| 64 | */ |
|---|
| 65 | - (NSString *)initialText; |
|---|
| 66 | |
|---|
| 67 | /*! |
|---|
| 68 | * @brief The informative text to display |
|---|
| 69 | * |
|---|
| 70 | * This is the text to display under the title, describing what this importer will do. |
|---|
| 71 | * |
|---|
| 72 | * @return The informative text to display |
|---|
| 73 | */ |
|---|
| 74 | - (NSString *)informativeText; |
|---|
| 75 | |
|---|
| 76 | /*! |
|---|
| 77 | * @brief The button title |
|---|
| 78 | * |
|---|
| 79 | * This text is displayed in the button before the user starts. The button is hidden after completion, so there are no other functions for this text. |
|---|
| 80 | * |
|---|
| 81 | * @return The button title |
|---|
| 82 | */ |
|---|
| 83 | - (NSString *)buttonTitle; |
|---|
| 84 | |
|---|
| 85 | /*! |
|---|
| 86 | * @brief The data menu was exhumed |
|---|
| 87 | * |
|---|
| 88 | * Some importers present the user with other choices, so this lets the importer know that the "dialog" has completed. |
|---|
| 89 | * |
|---|
| 90 | * @param controller The Controller which was on top |
|---|
| 91 | */ |
|---|
| 92 | - (void) wasExhumedByPoppingController: (BRLayerController *) controller; |
|---|
| 93 | @end |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | /*! |
|---|
| 97 | * @brief The importer UI |
|---|
| 98 | * |
|---|
| 99 | * This class creates the importer UI. It handles all the user interaction and passes commands on to its subordinates. |
|---|
| 100 | */ |
|---|
| 101 | @interface SapphireImporterDataMenu : SapphireLayerController <SapphireMetaDataScannerDelegate, SapphireImporterBackgroundProtocol> |
|---|
| 102 | { |
|---|
| 103 | BRHeaderControl *title; /*!< @brief The title*/ |
|---|
| 104 | BRButtonControl *button; /*!< @brief The button to press*/ |
|---|
| 105 | BRTextControl *text; /*!< @brief The informative text*/ |
|---|
| 106 | BRTextControl *fileProgress; /*!< @brief The progress text*/ |
|---|
| 107 | BRTextControl *currentFile; /*!< @brief The current file text*/ |
|---|
| 108 | BRProgressBarWidget *bar; /*!< @brief The progress bar*/ |
|---|
| 109 | |
|---|
| 110 | SapphireMetaDataCollection *metaCollection; /*!< @brief The main collection*/ |
|---|
| 111 | NSMutableArray *collectionDirectories; /*!< @brief The directories to import*/ |
|---|
| 112 | int collectionIndex; /*!< @brief The current index in the directories*/ |
|---|
| 113 | NSMutableArray *importItems; /*!< @brief The items remaining to import*/ |
|---|
| 114 | NSTimer *importTimer; /*!< @brief The timer to do the next import (so we don't freeze the UI)*/ |
|---|
| 115 | float max; /*!< @brief The max number to import*/ |
|---|
| 116 | float current; /*!< @brief The current count of imported items*/ |
|---|
| 117 | float updated ; /*!< @brief The number of items with new data*/ |
|---|
| 118 | BOOL suspended; /*!< @brief YES if import is suspended, NO otherwise*/ |
|---|
| 119 | BOOL canceled; /*!< @brief YES if the import was cancelled, NO otherwise*/ |
|---|
| 120 | BOOL backgrounded; /*!< @brief YES if the current file is backgrounded, NO otherwise*/ |
|---|
| 121 | |
|---|
| 122 | id <SapphireImporter> importer; /*!< @brief The importer who does the dirty work*/ |
|---|
| 123 | } |
|---|
| 124 | /*! |
|---|
| 125 | * @brief Creates a new Importer Data Menu |
|---|
| 126 | * |
|---|
| 127 | * @param scene The scene |
|---|
| 128 | * @praam collection The metadata collection to browse |
|---|
| 129 | * @return The Menu |
|---|
| 130 | */ |
|---|
| 131 | - (id) initWithScene: (BRRenderScene *) scene metaDataCollection:(SapphireMetaDataCollection *)collection importer:(id <SapphireImporter>)import; |
|---|
| 132 | @end |
|---|
| 133 | |
|---|
| 134 | /*! |
|---|
| 135 | * @brief The importer UI protected API |
|---|
| 136 | * |
|---|
| 137 | * This category is for use by the SapphireImporter objects to control the overal import process. It has the ability to pause, resume, and skip an item. |
|---|
| 138 | */ |
|---|
| 139 | @interface SapphireImporterDataMenu (protectedAccess) |
|---|
| 140 | |
|---|
| 141 | /*! |
|---|
| 142 | * @brief Pause the import process |
|---|
| 143 | */ |
|---|
| 144 | - (void)pause; |
|---|
| 145 | |
|---|
| 146 | /*! |
|---|
| 147 | * @brief Resume the import process |
|---|
| 148 | */ |
|---|
| 149 | - (void)resume; |
|---|
| 150 | |
|---|
| 151 | /*! |
|---|
| 152 | * @brief Say that the file's import is backgrounded |
|---|
| 153 | */ |
|---|
| 154 | - (void)itemImportBackgrounded; |
|---|
| 155 | |
|---|
| 156 | /*! |
|---|
| 157 | * @brief Skip the next item in the queue |
|---|
| 158 | */ |
|---|
| 159 | - (void)skipNextItem; |
|---|
| 160 | @end |
|---|