Commit 0f9f0e2a authored by Matthias Möller's avatar Matthias Möller

- add filename attribute

- cleanup path and filename attribute

refs #670

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14531 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8841e7fd
......@@ -81,7 +81,9 @@ BaseObject::BaseObject(const BaseObject& _object) :
objectType_(_object.objectType_),
flags_(_object.flags_),
visible_(_object.visible_),
parentItem_(0)
parentItem_(0),
path_("."),
filename_("")
{
// Increase id generator as we created a new object
......@@ -203,11 +205,12 @@ void BaseObject::persistentId( int _id ) {
void BaseObject::cleanup() {
persistentId_ = -1;
path_ = ".";
flags_.clear();
visible_ = true;
name_ = "NONAME";
filename_ = "";
}
// ===============================================================================
......@@ -713,43 +716,40 @@ QStringList BaseObject::getGroupNames() {
// Name and path Handling
// ===============================================================================
void BaseObjectData::setFromFileName(QString _filename ) {
QString BaseObject::filename()
{
return filename_;
}
void BaseObject::setFileName(const QString &_filename)
{
filename_ = _filename;
}
void BaseObject::setFromFileName(const QString &_filename ) {
QFileInfo file_info(_filename);
path_ = file_info.path();
setName(file_info.fileName());
setPath(file_info.path());
QString filename = file_info.fileName();
setFileName(filename);
setName(filename);
}
void BaseObjectData::setName( QString _name ) {
void BaseObject::setName(const QString &_name ) {
name_ = _name;
// Tell plugins about the name change
emit objectPropertiesChanged(id());
std::string nodename = std::string("SeparatorNode for object " + _name.toUtf8());
separatorNode_->name( nodename );
nodename = std::string("ManipulatorNode for object " + _name.toUtf8());
manipulatorNode_->name( nodename );
nodename = std::string("BoundingBoxNode for object " + _name.toUtf8());
boundingBoxNode_->name( nodename );
nodename = std::string(_name.toUtf8() + "'s Material" );
materialNode_->name( nodename );
nodename = std::string("StencilRefNode for object " + _name.toUtf8());
stencilRefNode_->name( nodename );
}
QString BaseObject::name() {
return name_;
}
QString BaseObjectData::path(){
QString BaseObject::path(){
return path_;
}
void BaseObjectData::setPath(QString _path ) {
void BaseObject::setPath(const QString &_path ) {
path_ = _path;
}
......
......@@ -420,30 +420,37 @@ class DLLEXPORTONLY BaseObject : public QObject {
//===========================================================================
/** Set the object name from a filename. The function will set the name of the
* object to the filename. At the same time the path is set to the one given in
* the parameter
* object to the filename. At the same time the path and the filename is
* set to the one given in the parameter
*
* @param _filename path to the file.
*/
void setFromFileName(QString _filename );
void setFromFileName(const QString &_filename);
/// return the path to the object ( defaults to "." if unset )
QString path();
/// set the path to the object.
void setPath(QString _path);
void setPath(const QString &_path);
/// return the filename of the object. The name defaults to NONAME if unset.
/// return the name of the object. The name defaults to NONAME if unset.
QString name( );
/// set the filename of the object. ( If you overwrite it, call BaseObject::setName(_name ) it in your funtion first)
virtual void setName( QString _name );
/// set the name of the object. ( If you overwrite it, call BaseObject::setName(_name ) it in your funtion first)
virtual void setName(const QString &_name );
/// return the filename of the object
QString filename();
/// set the filename for this object
void setFileName(const QString &_filename);
private:
/// path to the file from which the object is loaded ( defaults to "." )
QString path_;
QString filename_;
signals:
/** This signal is emitted when properties of the object have been changed like its name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment