Method: Ruber::AbstractProject#initialize
- Defined in:
- lib/ruber/project.rb
#initialize(parent, backend, name = nil) ⇒ AbstractProject
Creates a new Project. parent is the projects parent object (derived from Qt::Object); file is the name of the project file, which may already exist or not, while name is the name of the project. name can only be specified if the project file doesn’t exist, otherwise ArgumentError will be raised.
The project file, if existing, must follow the format described in the documentation for YamlSettingsBackend and must contain a :project_name entry under the :general group, otherwise it will be considered invalid. In this case, InvalidProjectFile will be raised.
The new project asks each component to register itself with it, so that project options, project widgets (widgets to be shown in the project’s configuration dialog) and project extensions are added. It also connects to the component_loaded and unloading_component signals of the component manager. The first allow each newly loaded plugin to register itself with the project, while the second allows any unloading plugin to unregister itself.
When the project is created, it’s not active.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/ruber/project.rb', line 112 def initialize parent, backend, name = nil super(parent) @active = false @project_file = backend.file setup_container backend, project_dir @dialog_class = ProjectDialog self.dialog_title = 'Configure Project' add_option OpenStruct.new(:group => :general, :name => :project_name, :default => nil) @project_name = self[:general, :project_name] if @project_name and name raise ArgumentError, "You can't specify a file name for an already existing project" elsif name self[:general, :project_name] = name @project_name = name elsif !@project_name and File.exist? @project_file raise InvalidProjectFile, "The project file #{@project_file} isn't invalid because it doesn't contain a project name entry" elsif !name and !File.exist? @project_file raise InvalidProjectFile, "You need to specify a project name for a new project" end @project_extensions = {} Ruber[:components].named_connect(SIGNAL('component_loaded(QObject*)'), "register_component_with_project #{object_id}"){|c| c.register_with_project self} Ruber[:components].named_connect(SIGNAL('unloading_component(QObject*)'), "remove_component_from_project #{object_id}"){|c| c.remove_from_project self} end |