mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 06:56:39 +00:00 
			
		
		
		
	added scope configuration to creators
This commit is contained in:
		
							parent
							
								
									0be1e3d12f
								
							
						
					
					
						commit
						35803bc9b6
					
				
					 4 changed files with 29 additions and 8 deletions
				
			
		| 
						 | 
					@ -56,7 +56,7 @@ CSVFilter::FilterCreator::FilterCreator (CSMWorld::Data& data, QUndoStack& undoS
 | 
				
			||||||
    /// \todo re-enable for OpenMW 1.1
 | 
					    /// \todo re-enable for OpenMW 1.1
 | 
				
			||||||
    // mScope->addItem ("Content");
 | 
					    // mScope->addItem ("Content");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    connect (mScope, SIGNAL (currentIndexChanged (int)), this, SLOT (setScope (int)));
 | 
					    connect (mScope, SIGNAL (currentIndexChanged (int)), this, SLOT (setScope2 (int)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    insertAtBeginning (mScope, false);
 | 
					    insertAtBeginning (mScope, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ void CSVFilter::FilterCreator::reset()
 | 
				
			||||||
    GenericCreator::reset();
 | 
					    GenericCreator::reset();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CSVFilter::FilterCreator::setScope (int index)
 | 
					void CSVFilter::FilterCreator::setScope2 (int index)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    update();
 | 
					    update();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@ namespace CSVFilter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private slots:
 | 
					        private slots:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            void setScope (int index);
 | 
					            void setScope2 (int index);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,16 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "creator.hpp"
 | 
					#include "creator.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CSVWorld::Creator:: ~Creator() {}
 | 
					#include <stdexcept>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CSVWorld::Creator::~Creator() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CSVWorld::Creator::setScope (unsigned int scope)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (scope!=CSMWorld::Scope_Content)
 | 
				
			||||||
 | 
					        throw std::logic_error ("Invalid scope in creator");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}
 | 
					CSVWorld::CreatorFactoryBase::~CreatorFactoryBase() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,14 @@
 | 
				
			||||||
#ifndef CSV_WORLD_CREATOR_H
 | 
					#ifndef CSV_WORLD_CREATOR_H
 | 
				
			||||||
#define CSV_WORLD_CREATOR_H
 | 
					#define CSV_WORLD_CREATOR_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <memory>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QWidget>
 | 
					#include <QWidget>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../../model/world/universalid.hpp"
 | 
					#include "../../model/world/universalid.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../../model/world/scope.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class QUndoStack;
 | 
					class QUndoStack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace CSMWorld
 | 
					namespace CSMWorld
 | 
				
			||||||
| 
						 | 
					@ -32,6 +37,9 @@ namespace CSVWorld
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            virtual void toggleWidgets(bool active = true) = 0;
 | 
					            virtual void toggleWidgets(bool active = true) = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            /// Default implementation: Throw an exception if scope!=Scope_Content.
 | 
				
			||||||
 | 
					            virtual void setScope (unsigned int scope);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        signals:
 | 
					        signals:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            void done();
 | 
					            void done();
 | 
				
			||||||
| 
						 | 
					@ -68,7 +76,7 @@ namespace CSVWorld
 | 
				
			||||||
            /// \note The function always returns 0.
 | 
					            /// \note The function always returns 0.
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    template<class CreatorT>
 | 
					    template<class CreatorT, unsigned int scope = CSMWorld::Scope_Content>
 | 
				
			||||||
    class CreatorFactory : public CreatorFactoryBase
 | 
					    class CreatorFactory : public CreatorFactoryBase
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public:
 | 
					        public:
 | 
				
			||||||
| 
						 | 
					@ -81,11 +89,15 @@ namespace CSVWorld
 | 
				
			||||||
            /// records should be provided.
 | 
					            /// records should be provided.
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    template<class CreatorT>
 | 
					    template<class CreatorT, unsigned int scope>
 | 
				
			||||||
    Creator *CreatorFactory<CreatorT>::makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
 | 
					    Creator *CreatorFactory<CreatorT, scope>::makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
 | 
				
			||||||
        const CSMWorld::UniversalId& id) const
 | 
					        const CSMWorld::UniversalId& id) const
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return new CreatorT (data, undoStack, id);
 | 
					        std::auto_ptr<CreatorT> creator (new CreatorT (data, undoStack, id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        creator->setScope (scope);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return creator.release();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue