Changeset 2229
- Timestamp:
- 08/25/08 23:33:57 (3 months ago)
- Location:
- v2/branches/dev
- Files:
-
- 17 modified
- 2 copied
-
monkey/src/templatesmanager/ui/UITemplatesWizard.cpp (modified) (1 diff)
-
monkey/src/xupmanager/AddFilesDialog.cpp (modified) (2 diffs)
-
monkey/src/xupmanager/AddFilesDialog.h (modified) (1 diff)
-
monkey/src/xupmanager/FilteredProjectItemModel.cpp (modified) (6 diffs)
-
monkey/src/xupmanager/ProjectEditorModel.cpp (modified) (3 diffs)
-
monkey/src/xupmanager/ScopedProjectItemModel.cpp (modified) (4 diffs)
-
monkey/src/xupmanager/ScopedProjectItemModel.h (modified) (3 diffs)
-
monkey/src/xupmanager/XUPIO.cpp (modified) (1 diff)
-
monkey/src/xupmanager/XUPItem.cpp (modified) (15 diffs)
-
monkey/src/xupmanager/XUPItem.h (modified) (8 diffs)
-
monkey/src/xupmanager/XUPProjectItem.cpp (modified) (7 diffs)
-
monkey/src/xupmanager/XUPProjectItem.h (modified) (3 diffs)
-
monkey/src/xupmanager/ui/UIXUPManager.cpp (modified) (8 diffs)
-
monkey/src/xupmanager/ui/UIXUPManager.h (modified) (1 diff)
-
monkey/src/xupmanager/ui/UIXUPProjectEditor.cpp (modified) (6 diffs)
-
monkey/src/xupmanager/ui/UIXUPProjectEditor.h (modified) (1 diff)
-
plugins/xup/QMakeProjectEditor/src/QMakeXUPItem.cpp (modified) (4 diffs)
-
plugins/xup/XUPProjectEditor/src/XUPItem.cpp.bak (copied) (copied from v2/branches/dev/monkey/src/xupmanager/XUPItem.cpp)
-
plugins/xup/XUPProjectEditor/src/XUPItem.h.bak (copied) (copied from v2/branches/dev/monkey/src/xupmanager/XUPItem.h)
Legend:
- Unmodified
- Added
- Removed
-
v2/branches/dev/monkey/src/templatesmanager/ui/UITemplatesWizard.cpp
r2227 r2229 177 177 { 178 178 const QModelIndex idx = mProjects->scopedModel()->mapToSource( index ); 179 if ( XUP Item* it = mProjects->itemFromIndex( idx) )179 if ( XUPProjectItem* it = dynamic_cast<XUPProjectItem*> (mProjects->itemFromIndex( idx )) ) 180 180 { 181 181 cbOperators->clear(); -
v2/branches/dev/monkey/src/xupmanager/AddFilesDialog.cpp
r1999 r2229 1 1 #include "AddFilesDialog.h" 2 2 #include "../pMonkeyStudio.h" 3 4 #include "XUPItem.h" 5 #include "XUPProjectItem.h" 3 6 4 7 #include <QGridLayout> … … 92 95 // create operators combobox 93 96 cbOperators = new QComboBox; 94 cbOperators->addItems( pi-> operators() );97 cbOperators->addItems( pi->project()->operators() ); 95 98 hl2->addWidget( cbOperators ); 96 99 // add groupbox to layout -
v2/branches/dev/monkey/src/xupmanager/AddFilesDialog.h
r1999 r2229 11 11 #include "ScopedProjectItemModel.h" 12 12 #include "ProjectItemModel.h" 13 #include "XUPItem.h"14 13 15 14 class QListView; -
v2/branches/dev/monkey/src/xupmanager/FilteredProjectItemModel.cpp
r1805 r2229 104 104 105 105 // calculate row to insert to 106 int r = it-> filteredVariables().indexOf( vn );106 int r = it->project()->filteredVariables().indexOf( vn ); 107 107 int ri = -1; 108 108 for ( int i = 0; i < pit->rowCount(); i++ ) 109 109 { 110 110 FilteredProjectItem* cit = pit->child( i ); 111 const int ci = it-> filteredVariables().indexOf( cit->item()->defaultValue() );111 const int ci = it->project()->filteredVariables().indexOf( cit->item()->defaultValue() ); 112 112 if ( cit->item()->isProject() ) 113 113 continue; … … 127 127 FilteredProjectItem* FilteredProjectItemModel::createFolder( const QString& name, XUPItem* inItem ) 128 128 { 129 FilteredProjectItem* fit = new FilteredProjectItem( inItem->clone( false) );129 FilteredProjectItem* fit = new FilteredProjectItem( inItem->clone() ); 130 130 fit->item()->setDomElement( inItem->domElement().ownerDocument().createElement( "folder" ) ); 131 131 fit->item()->setValue( "name", name ); … … 186 186 XUPItem* parent = it->parent(); 187 187 // check if we need to show this value 188 if ( !parent-> filteredVariables().contains( parent->defaultValue() ) )188 if ( !parent->project()->filteredVariables().contains( parent->defaultValue() ) ) 189 189 return; 190 190 … … 193 193 194 194 // check file based 195 bool b = it-> fileVariables().contains( parent->defaultValue() );195 bool b = it->project()->fileVariables().contains( parent->defaultValue() ); 196 196 197 197 if ( !it->defaultValue().isEmpty() ) … … 206 206 { 207 207 // check we need to show it 208 if ( !it-> filteredVariables().contains( it->defaultValue() ) )208 if ( !it->project()->filteredVariables().contains( it->defaultValue() ) ) 209 209 return; 210 210 … … 237 237 { 238 238 // if filtered 239 if ( !it-> filteredVariables().isEmpty() )239 if ( !it->project()->filteredVariables().isEmpty() ) 240 240 { 241 241 if ( it->isProject() ) -
v2/branches/dev/monkey/src/xupmanager/ProjectEditorModel.cpp
r1729 r2229 1 1 #include "ProjectEditorModel.h" 2 2 #include "XUPItem.h" 3 #include "XUPProjectItem.h" 3 4 #include "ProjectItemModel.h" 4 5 … … 19 20 if ( XUPItem* it = mSourceModel->itemFromIndex( idx ) ) 20 21 { 21 XUP Item* pit = mProject->project();22 XUPProjectItem* pit = mProject->project(); 22 23 // if project or parent project 23 24 if ( it->isProject() ) … … 25 26 // if variable and filter != values 26 27 if ( it->isType( "variable" ) && mType != ProjectEditorModel::vtValues ) 27 return it->project() == pit && !it-> fileVariables().contains( it->defaultValue() );28 return it->project() == pit && !it->project()->fileVariables().contains( it->defaultValue() ); 28 29 // if value and filter != variable 29 30 if ( ( it->isType( "value" ) || it->isType( "folder" ) ) && mType != ProjectEditorModel::vtVariables ) -
v2/branches/dev/monkey/src/xupmanager/ScopedProjectItemModel.cpp
r1729 r2229 2 2 #include "ProjectItemModel.h" 3 3 #include "XUPItem.h" 4 #include "XUPProjectItem.h" 4 5 5 6 ScopedProjectItemModel::ScopedProjectItemModel( ProjectItemModel* m ) … … 11 12 } 12 13 13 void ScopedProjectItemModel::setFilteredProject( XUP Item* project )14 void ScopedProjectItemModel::setFilteredProject( XUPProjectItem* project ) 14 15 { 15 16 mProject = project; … … 17 18 } 18 19 19 XUP Item* ScopedProjectItemModel::filteredProject() const20 XUPProjectItem* ScopedProjectItemModel::filteredProject() const 20 21 { return mProject; } 21 22 … … 25 26 { 26 27 if ( mProject ) 27 return ( it->children( true, false ).contains( mProject) || it == mProject ) ||28 return ( it->children( true, false ).contains( static_cast<XUPItem*> (mProject) ) || it == mProject ) || 28 29 ( it->project() == mProject && it->isType( "project" ) || it->isType( "scope" ) ); 29 30 else -
v2/branches/dev/monkey/src/xupmanager/ScopedProjectItemModel.h
r1998 r2229 8 8 class ProjectItemModel; 9 9 class XUPItem; 10 class XUPProjectItem; 10 11 11 12 class Q_MONKEY_EXPORT ScopedProjectItemModel : public QSortFilterProxyModel … … 16 17 ScopedProjectItemModel( ProjectItemModel* = 0 ); 17 18 18 void setFilteredProject( XUP Item* project );19 XUP Item* filteredProject() const;19 void setFilteredProject( XUPProjectItem* project ); 20 XUPProjectItem* filteredProject() const; 20 21 21 22 inline ProjectItemModel* model() const { return mSourceModel; } … … 23 24 protected: 24 25 ProjectItemModel* mSourceModel; 25 XUP Item* mProject;26 XUPProjectItem* mProject; 26 27 27 28 virtual bool filterAcceptsRow( int sr, const QModelIndex& sp ) const; -
v2/branches/dev/monkey/src/xupmanager/XUPIO.cpp
r2142 r2229 72 72 QDomElement de = l.at( i ).toElement(); 73 73 // create item 74 XUPItem* it = p->clone( false);74 XUPItem* it = p->clone(); 75 75 // assign node 76 76 it->setDomElement( de ); -
v2/branches/dev/monkey/src/xupmanager/XUPItem.cpp
r2228 r2229 1 1 #include "XUPItem.h" 2 #include "XUPProjectItem.h" 2 3 #include "ProjectItemModel.h" 3 #include "XUPIO.h"4 4 5 5 … … 8 8 #include <QDir> 9 9 10 XUPItemInfos XUPItem::mXUPItemInfos;11 12 void XUPItem::registerItem()13 {14 mXUPItemInfos.Registered = true;15 mXUPItemInfos.TextTypes << "comment" << "value" << "emptyline" << "function";16 mXUPItemInfos.FileVariables << "FILES";17 mXUPItemInfos.VariableLabels["FILES"] = tr( "Project Files" );18 mXUPItemInfos.FilteredVariables << "FILES";19 mXUPItemInfos.Operators << "=" << "+=" << "-=" << "*=" << "~=";20 mXUPItemInfos.Suffixes[tr( "Monkey Studio Project" )] = QStringList( "*.xup" );21 }22 23 const XUPItemInfos& XUPItem::itemInfos() const24 { return mXUPItemInfos; }25 26 QStringList XUPItem::operators() const27 { return mXUPItemInfos.Operators; }28 29 void XUPItem::registerOperator( const QString& s )30 {31 if ( !mXUPItemInfos.Operators.contains( s ) )32 mXUPItemInfos.Operators << s;33 }34 35 QStringList XUPItem::filteredVariables() const36 { return mXUPItemInfos.FilteredVariables; }37 38 void XUPItem::registerFilteredVariables( const QString& s )39 {40 if ( !mXUPItemInfos.FilteredVariables.contains( s ) )41 mXUPItemInfos.FilteredVariables << s;42 }43 44 QStringList XUPItem::textTypes() const45 { return mXUPItemInfos.TextTypes; }46 47 void XUPItem::registerTextType( const QString& s )48 {49 if ( !mXUPItemInfos.TextTypes.contains( s ) )50 mXUPItemInfos.TextTypes << s;51 }52 53 QStringList XUPItem::fileVariables() const54 { return mXUPItemInfos.FileVariables; }55 56 void XUPItem::registerFileVariables( const QString& s )57 {58 if ( !mXUPItemInfos.FileVariables.contains( s ) )59 mXUPItemInfos.FileVariables << s;60 }61 62 QStringList XUPItem::pathVariables() const63 { return mXUPItemInfos.PathVariables; }64 65 void XUPItem::registerPathVariables( const QString& s )66 {67 if ( !mXUPItemInfos.PathVariables.contains( s ) )68 mXUPItemInfos.PathVariables << s;69 }70 71 QHash<QString, QStringList> XUPItem::suffixes() const72 { return mXUPItemInfos.Suffixes; }73 74 void XUPItem::registerSuffixes( const QString& l, const QStringList& s )75 { mXUPItemInfos.Suffixes[l] = s; }76 77 QHash<QString, QString> XUPItem::variableLabels() const78 { return mXUPItemInfos.VariableLabels; }79 80 void XUPItem::registerVariableLabels( const QString& v, const QString& l )81 { mXUPItemInfos.VariableLabels[v] = l; }82 83 QHash<QString, QIcon> XUPItem::variableIcons() const84 { return mXUPItemInfos.VariableIcons; }85 86 void XUPItem::registerVariableIcons( const QString& v, const QIcon& i )87 { mXUPItemInfos.VariableIcons[v] = i; }88 89 QHash<QString, QStringList> XUPItem::variableSuffixes() const90 { return mXUPItemInfos.VariableSuffixes; }91 92 void XUPItem::registerVariableSuffixes( const QString& n, const QStringList& s )93 { mXUPItemInfos.VariableSuffixes[n] = s; }94 10 95 11 QIcon XUPItem::getIcon( const QString& o, const QString& d ) const 96 12 { return QIcon( QFile::exists( o ) ? o : QString( ":/items/%1.png" ).arg( d ) ); } 97 13 98 QString XUPItem::valueName( const QString& s ) const99 {100 if ( textTypes().contains( s ) )101 return "text";102 return "name";103 }104 105 QStringList XUPItem::files( bool a )106 {107 // files list108 QStringList l;109 110 // check valid item111 if ( !isType( "variable" ) || !fileVariables().contains( defaultValue() ) )112 return l;113 114 // check recurs items from vit115 foreach ( XUPItem* cit, children( false, false ) )116 if ( cit->isType( "value" ) )117 l << ( a ? cit->filePath() : cit->relativeFilePath() );118 119 // return list120 return l;121 }122 123 14 QVariant XUPItem::data( int role ) const 124 15 { … … 129 20 if ( isType( "variable" ) ) 130 21 { 131 icn = QFile::exists( value( "icon" ) ) ? QIcon( value( "icon" ) ) : variableIcons().value( value( "name" ) );22 icn = QFile::exists( value( "icon" ) ) ? QIcon( value( "icon" ) ) : project()->variableIcons().value( value( "name" ) ); 132 23 if ( icn.isNull() ) 133 24 icn = getIcon( QString(), value( "type" ) ); … … 143 34 else if ( isType( "variable" ) ) 144 35 { 145 if ( variableLabels().contains( defaultValue() ) )146 txt = variableLabels().value( defaultValue() );36 if ( project()->variableLabels().contains( defaultValue() ) ) 37 txt = project()->variableLabels().value( defaultValue() ); 147 38 } 148 39 else if ( isType( "value" ) ) … … 150 41 if ( parent() ) 151 42 { 152 if ( fileVariables().contains( parent()->defaultValue() ) )43 if ( project()->fileVariables().contains( parent()->defaultValue() ) ) 153 44 txt = QFileInfo( defaultInterpretedValue() ).fileName(); 154 else if ( p athVariables().contains( parent()->defaultValue() ) )45 else if ( project()->pathVariables().contains( parent()->defaultValue() ) ) 155 46 txt = relativeFilePath( defaultInterpretedValue() ); 156 47 } … … 196 87 { return dynamic_cast<ProjectItemModel*>( QStandardItem::model() ); } 197 88 198 XUPItem* XUPItem::clone( bool b) const199 { return b ? new XUPItem( domElement(), projectFilePath(), modified() ) : new XUPItem; }89 XUPItem* XUPItem::clone() const 90 { return new XUPItem; } //FIXME 200 91 201 92 void XUPItem::appendRow( XUPItem* it ) … … 257 148 } 258 149 150 QStringList XUPItem::files( bool a ) 151 { 152 // files list 153 QStringList l; 154 155 // check valid item 156 if ( !isType( "variable" ) || !project()->fileVariables().contains( defaultValue() ) ) 157 return l; 158 159 // check recurs items from vit 160 foreach ( XUPItem* cit, children( false, false ) ) 161 if ( cit->isType( "value" ) ) 162 l << ( a ? cit->filePath() : cit->relativeFilePath() ); 163 164 // return list 165 return l; 166 } 167 168 void XUPItem::addFiles( const QStringList& files, XUPItem* scope, const QString& op ) 169 { 170 // abort if no files 171 if ( files.isEmpty() ) 172 return; 173 174 // set scope 175 if ( !scope ) 176 scope = this; 177 178 // get variable item 179 XUPItem* vit = 0; 180 foreach ( XUPItem* cit, scope->children( false, true ) ) 181 { 182 if ( cit->isType( "variable" ) && cit->defaultValue() == "FILES" && cit->value( "operator", "=" ) == op ) 183 { 184 vit = cit; 185 break; 186 } 187 } 188 189 // check variable exists or not 190 bool exists = vit; 191 192 // create variable if needed 193 if ( !exists ) 194 { 195 vit = clone(); 196 vit->setDomElement( mDomElement.ownerDocument().createElement( "variable" ) ); 197 scope->domElement().appendChild( vit->domElement() ); 198 vit->setValue( vit->valueName(), "FILES" ); 199 vit->setValue( "operator", op ); 200 vit->setValue( "multiline", "true" ); 201 } 202 203 // get all files 204 QStringList existingFiles = vit->files(); 205 206 // add files 207 foreach ( QString f, files ) 208 { 209 QString fp = filePath( f ); 210 if ( !existingFiles.contains( fp ) ) 211 { 212 XUPItem* it = clone(); 213 it->setDomElement( mDomElement.ownerDocument().createElement( "value" ) ); 214 vit->domElement().appendChild( it->domElement() ); 215 it->setValue( it->valueName(), relativeFilePath( fp ) ); 216 vit->appendRow( it ); 217 } 218 } 219 // append var item only at last will prevent multiple call of addFilteredValue from filtered view 220 if ( !exists ) 221 scope->appendRow( vit ); 222 223 // update scope nested if needed 224 if ( scope->isType( "scope" ) ) 225 scope->setValue( "nested", scope->rowCount() > 1 ? "false" : "true" ); 226 } 227 228 void XUPItem::removeFiles( const QStringList& files, XUPItem* scope, const QString& op ) 229 { 230 // abort if no files 231 if ( files.isEmpty() ) 232 return; 233 234 // set scope 235 if ( !scope ) 236 scope = this; 237 238 // get variable item 239 XUPItem* vit = 0; 240 foreach ( XUPItem* cit, scope->children( false, true ) ) 241 { 242 if ( cit->isType( "variable" ) && cit->defaultValue() == "FILES" && cit->value( "operator" ) == op ) 243 { 244 vit = cit; 245 break; 246 } 247 } 248 249 // if not variable, cancel 250 if ( !vit ) 251 return; 252 253 // check each child 254 foreach ( XUPItem* cit, vit->children( false, false ) ) 255 if ( cit->isType( "value" ) && files.contains( cit->filePath() ) ) 256 cit->remove(); 257 258 // remove variable item if emptyline 259 if ( !vit->hasChildren() ) 260 vit->remove(); 261 262 // update scope nested if needed 263 if ( scope->isType( "scope" ) ) 264 scope->setValue( "nested", scope->rowCount() > 1 ? "false" : "true" ); 265 } 266 259 267 void XUPItem::setDomElement( const QDomElement& e ) 260 268 { … … 277 285 QString XUPItem::defaultInterpretedValue() const 278 286 { return defaultValue(); } 287 288 QString XUPItem::valueName( const QString& s ) const 289 { 290 if ( project()->textTypes().contains( s ) ) //FIXME Do it's right? 291 return "text"; 292 return "name"; 293 } 279 294 280 295 QString XUPItem::valueName() const … … 351 366 bool XUPItem::isProjectContainer() const 352 367 { return false; } 353 354 bool XUPItem::loadProject( const QString& s, const QString& v )355 {356 if ( XUPIO::loadXUP( this, s, v ) )357 {358 mProjectFilePath = s;359 setModified( false );360 return true;361 }362 return false;363 }364 365 bool XUPItem::saveProject( const QString& s, const QString& v )366 {367 if ( XUPIO::saveXUP( this, s.isEmpty() ? projectFilePath() : s, v ) )368 {369 mProjectFilePath = s.isEmpty() ? projectFilePath() : s;370 setModified( false );371 return true;372 }373 return false;374 }375 376 void XUPItem::addFiles( const QStringList& files, XUPItem* scope, const QString& op )377 {378 // abort if no files379 if ( files.isEmpty() )380 return;381 382 // set scope383 if ( !scope )384 scope = this;385 386 // get variable item387 XUPItem* vit = 0;388 foreach ( XUPItem* cit, scope->children( false, true ) )389 {390 if ( cit->isType( "variable" ) && cit->defaultValue() == "FILES" && cit->value( "operator", "=" ) == op )391 {392 vit = cit;393 break;394 }395 }396 397 // check variable exists or not398 bool exists = vit;399 400 // create variable if needed401 if ( !exists )402 {403 vit = clone( false );404 vit->setDomElement( mDomElement.ownerDocument().createElement( "variable" ) );405 scope->domElement().appendChild( vit->domElement() );406 vit->setValue( vit->valueName(), "FILES" );407 vit->setValue( "operator", op );408 vit->setValue( "multiline", "true" );409 }410 411 // get all files412 QStringList existingFiles = vit->files();413 414 // add files415 foreach ( QString f, files )416 {417 QString fp = filePath( f );418 if ( !existingFiles.contains( fp ) )419 {420 XUPItem* it = clone( false );421 it->setDomElement( mDomElement.ownerDocument().createElement( "value" ) );422 vit->domElement().appendChild( it->domElement() );423 it->setValue( it->valueName(), relativeFilePath( fp ) );424 vit->appendRow( it );425 }426 }427 428 // append var item only at last will prevent multiple call of addFilteredValue from filtered view429 if ( !exists )430 scope->appendRow( vit );431 432 // update scope nested if needed433 if ( scope->isType( "scope" ) )434 scope->setValue( "nested", scope->rowCount() > 1 ? "false" : "true" );435 }436 437 void XUPItem::removeFiles( const QStringList& files, XUPItem* scope, const QString& op )438 {439 // abort if no files440 if ( files.isEmpty() )441 return;442 443 // set scope444 if ( !scope )445 scope = this;446 447 // get variable item448 XUPItem* vit = 0;449 foreach ( XUPItem* cit, scope->children( false, true ) )450 {451 if ( cit->isType( "variable" ) && cit->defaultValue() == "FILES" && cit->value( "operator" ) == op )452 {453 vit = cit;454 break;455 }456 }457 458 // if not variable, cancel459 if ( !vit )460 return;461 462 // check each child463 foreach ( XUPItem* cit, vit->children( false, false ) )464 if ( cit->isType( "value" ) && files.contains( cit->filePath() ) )465 cit->remove();466
