Class: Ruber::World::World
- Inherits:
-
Qt::Object
- Object
- Qt::Object
- Ruber::World::World
- Includes:
- PluginLike
- Defined in:
- lib/ruber/world/world.rb
Defined Under Namespace
Classes: ExistingProjectFileError
Instance Attribute Summary (collapse)
-
- (Object) active_document
readonly
Returns the value of attribute active_document.
-
- (Object) active_environment
Returns the value of attribute active_environment.
-
- (Object) default_environment
readonly
Returns the value of attribute default_environment.
Attributes included from PluginLike
Instance Method Summary (collapse)
- - (Object) active_project
- - (Object) active_project(prj)
- - (Object) add_environment(env, prj) private
- - (Object) close_all(what, save_behaviour = :save)
-
- (Document?) document(file)
The document associated with the given file or URL.
- - (Object) documents
- - (Object) each_document
- - (Object) each_environment
- - (Object) each_project
- - (Object) environment(prj)
- - (Object) environment_closing(env) slot private
- - (Object) environments
-
- (World) initialize(_, psf)
constructor
A new instance of World.
- - (Object) load_settings slot private
-
- (Document) new_document
Creates a new document.
-
- (Project) new_project(file, name)
Creates a new project.
-
- (Project) project(file)
Retrieves the project associated with a given project file.
- - (Object) projects
- - (Object) query_close
- - (Object) save_settings
- - (Object) slot_active_editor_changed(editor) slot private
- - (Object) slot_closing_project(prj) slot private
- - (Object) slot_document_closing(doc) slot private
- - (Object) slot_document_created(doc) slot private
- - (Object) slot_project_created(prj) slot private
Methods included from PluginLike
#add_extensions_to_project, #add_options_to_project, #add_widgets_to_project, #create_tool_widget, #delayed_initialize, #initialize_plugin, #plugin_name, #register_options, #register_with_project, #remove_extensions_from_project, #remove_from_project, #remove_options_from_project, #remove_widgets_from_project, #restore_session, #session_data, #setup_action, #setup_actions, #shutdown, #unload, #update_project
Signal Summary
- - active_environment_changed(QObject* arg1)
- - active_environment_changed_2(QObject* arg1, QObject* arg2)
- - active_project_changed(QObject* arg1)
- - active_project_changed_2(QObject* arg1, QObject* arg2)
- - document_created(QObject* arg1)
- - project_created(QObject* arg1)
- - closing_project(QObject* arg1)
- - closing_document(QObject* arg1)
- - active_document_changed(QObject* arg1)
- - active_editor_changed(QWidget* arg1)
Constructor Details
- (World) initialize(_, psf)
A new instance of World
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ruber/world/world.rb', line 76 def initialize _, psf super Ruber[:app] @documents = MutableDocumentList.new [] @projects = MutableProjectList.new [] @environments = {} initialize_plugin psf @active_environment = nil @active_document = nil @document_factory = DocumentFactory.new self connect @document_factory, SIGNAL('document_created(QObject*)'), self, SLOT('slot_document_created(QObject*)') @project_factory = ProjectFactory.new self connect @project_factory, SIGNAL('project_created(QObject*)'), self, SLOT('slot_project_created(QObject*)') @default_environment = Environment.new(nil, self) add_environment @default_environment, nil end |
Instance Attribute Details
- (Object) active_document (readonly)
Returns the value of attribute active_document
48 49 50 |
# File 'lib/ruber/world/world.rb', line 48 def active_document @active_document end |
- (Object) active_environment
Returns the value of attribute active_environment
46 47 48 |
# File 'lib/ruber/world/world.rb', line 46 def active_environment @active_environment end |
- (Object) default_environment (readonly)
Returns the value of attribute default_environment
44 45 46 |
# File 'lib/ruber/world/world.rb', line 44 def default_environment @default_environment end |
Instance Method Details
- (Object) active_project
134 135 136 |
# File 'lib/ruber/world/world.rb', line 134 def active_project @active_environment.project if @active_environment end |
- (Object) active_project=(prj)
124 125 126 127 128 129 130 131 132 |
# File 'lib/ruber/world/world.rb', line 124 def active_project= prj old = @active_environment.project if @active_environment return old if old == prj old.deactivate if old self.active_environment = @environments[prj] emit active_project_changed prj emit active_project_changed_2 prj, old prj.activate if prj end |
- (Object) add_environment(env, prj) (private)
238 239 240 241 242 |
# File 'lib/ruber/world/world.rb', line 238 def add_environment env, prj @environments[prj] = env connect env, SIGNAL('closing(QObject*)'), self, SLOT('environment_closing(QObject*)') connect env, SIGNAL('active_editor_changed(QWidget*)'), self, SLOT('slot_active_editor_changed(QWidget*)') end |
- (Object) close_all(what, save_behaviour = :save)
216 217 218 219 220 221 222 |
# File 'lib/ruber/world/world.rb', line 216 def close_all what, save_behaviour = :save close_docs = (what == :all || what == :documents) close_prjs = (what == :all || what == :projects) save = save_behaviour == :save @projects.dup.each{|prj| prj.close save} if close_prjs @documents.dup.each{|doc| doc.close save} if close_docs end |
- (Document?) document(file)
The document associated with the given file or URL
If a document for the given file or URL already exists, that document will be returned, otherwise a new one will be created.
file to retrieve the document for
170 171 172 |
# File 'lib/ruber/world/world.rb', line 170 def document file @document_factory.document file, self end |
- (Object) documents
174 175 176 |
# File 'lib/ruber/world/world.rb', line 174 def documents DocumentList.new @documents end |
- (Object) each_document
178 179 180 181 182 183 184 |
# File 'lib/ruber/world/world.rb', line 178 def each_document if block_given? @documents.each{|doc| yield doc} self else self.to_enum :each_document end end |
- (Object) each_environment
116 117 118 119 120 121 122 |
# File 'lib/ruber/world/world.rb', line 116 def each_environment if block_given? @environments.each_value{|e| yield e} self else to_enum(:each_environment) end end |
- (Object) each_project
142 143 144 145 146 147 148 |
# File 'lib/ruber/world/world.rb', line 142 def each_project if block_given? @environments.each_key{|prj| yield prj if prj} self else self.to_enum(:each_project) end end |
- (Object) environment(prj)
92 93 94 95 96 97 98 99 100 |
# File 'lib/ruber/world/world.rb', line 92 def environment prj @environments[prj] # unless env # env = Environment.new(prj) # connect env, SIGNAL('closing(QObject*)'), self, SLOT('environment_closing(QObject*)') # connect env, SIGNAL('active_editor_changed(QWidget*)'), self, SLOT('slot_active_editor_changed(QWidget*)') # @environments[prj] = env # end end |
- (Object) environment_closing(env) (private)
244 245 246 247 |
# File 'lib/ruber/world/world.rb', line 244 def environment_closing env @environments.delete env.project self.active_environment = nil if @active_environment == env end |
Slot Signature:
environment_closing(QObject*)
- (Object) environments
112 113 114 |
# File 'lib/ruber/world/world.rb', line 112 def environments @environments.values end |
- (Object) load_settings (private)
277 278 279 280 |
# File 'lib/ruber/world/world.rb', line 277 def load_settings tabs_closable = Ruber[:config][:workspace, :close_buttons] @environments.each_value{|e| e..tabs_closable = tabs_closable} end |
Slot Signature:
load_settings()
- (Document) new_document
Creates a new document
154 155 156 157 |
# File 'lib/ruber/world/world.rb', line 154 def new_document doc = @document_factory.document nil, self doc end |
- (Project) new_project(file, name)
Creates a new project
195 196 197 198 |
# File 'lib/ruber/world/world.rb', line 195 def new_project file, name raise ExistingProjectFileError, "#{file} already exists" if File.exist?(file) @project_factory.project file, name end |
- (Project) project(file)
Retrieves the project associated with a given project file
If a project associated with the project file file already exists, that project is returned. Otherwise, a new project object is created.
212 213 214 |
# File 'lib/ruber/world/world.rb', line 212 def project file @project_factory.project file end |
- (Object) projects
138 139 140 |
# File 'lib/ruber/world/world.rb', line 138 def projects ProjectList.new @environments.keys.compact end |
- (Object) query_close
229 230 231 232 233 234 |
# File 'lib/ruber/world/world.rb', line 229 def query_close @documents.each{|doc| return false unless doc.own_project.query_close} return false unless Ruber[:main_window].save_documents @documents.to_a @projects.each{|prj| return false unless prj.query_close} true end |
- (Object) save_settings
224 225 226 227 |
# File 'lib/ruber/world/world.rb', line 224 def save_settings @documents.each{|doc| doc.save_settings} @projects.each{|prj| prj.save} end |
- (Object) slot_active_editor_changed(editor) (private)
283 284 285 286 287 288 289 290 |
# File 'lib/ruber/world/world.rb', line 283 def slot_active_editor_changed editor doc = editor ? editor.document : nil if doc != @active_document @active_document = doc emit active_document_changed(@active_document) end emit active_editor_changed(editor) end |
Slot Signature:
slot_active_editor_changed(QWidget*)
- (Object) slot_closing_project(prj) (private)
271 272 273 274 |
# File 'lib/ruber/world/world.rb', line 271 def slot_closing_project prj emit closing_project(prj) @projects.remove prj end |
Slot Signature:
slot_closing_project(QObject*)
- (Object) slot_document_closing(doc) (private)
265 266 267 268 |
# File 'lib/ruber/world/world.rb', line 265 def slot_document_closing doc emit closing_document(doc) @documents.remove doc end |
Slot Signature:
slot_document_closing(QObject*)
- (Object) slot_document_created(doc) (private)
250 251 252 253 254 |
# File 'lib/ruber/world/world.rb', line 250 def slot_document_created doc @documents.add doc connect doc, SIGNAL('closing(QObject*)'), self, SLOT('slot_document_closing(QObject*)') emit document_created(doc) end |
Slot Signature:
slot_document_created(QObject*)
- (Object) slot_project_created(prj) (private)
257 258 259 260 261 262 |
# File 'lib/ruber/world/world.rb', line 257 def slot_project_created prj @projects.add prj connect prj, SIGNAL('closing(QObject*)'), self, SLOT('slot_closing_project(QObject*)') add_environment prj.extension(:environment), prj emit project_created(prj) end |
Slot Signature:
slot_project_created(QObject*)
Signal Details
- active_environment_changed(QObject* arg1)
- active_environment_changed_2(QObject* arg1, QObject* arg2)
- active_project_changed(QObject* arg1)
- active_project_changed_2(QObject* arg1, QObject* arg2)
- document_created(QObject* arg1)
- project_created(QObject* arg1)
- closing_project(QObject* arg1)
- closing_document(QObject* arg1)
- active_document_changed(QObject* arg1)
- active_editor_changed(QWidget* arg1)