Introduced MapEditor QMainWindow within the top-level QMainWindow · mapeditor/tiled@abc687b (original) (raw)

Original file line number Diff line number Diff line change
@@ -36,18 +36,24 @@ QString Command::finalCommand() const
36 36 QString finalCommand = command;
37 37
38 38 // Perform variable replacement
39 -MapDocument *mapDocument = DocumentManager::instance()->currentDocument();
40 -if (mapDocument) {
41 -const QString fileName = mapDocument->fileName();
39 +Document *document = DocumentManager::instance()->currentDocument();
40 +if (document) {
41 +const QString fileName = document->fileName();
42 42
43 43 finalCommand.replace(QLatin1String("%mapfile"),
44 44 QString(QLatin1String("\"%1\"")).arg(fileName));
45 45
46 - MapObject *currentObject = dynamic_cast<MapObject *>(mapDocument->currentObject());
46 + finalCommand.replace(QLatin1String("%file"),
47 +QString(QLatin1String("\"%1\"")).arg(fileName));
48 +
49 +// todo: consider moving currentObject up into Document
50 +/*
51 + MapObject *currentObject = dynamic_cast<MapObject *>(document->currentObject());
47 52 if (currentObject) {
48 53 finalCommand.replace(QLatin1String("%objecttype"),
49 54 QString(QLatin1String("\"%1\"")).arg(currentObject->type()));
50 55 }
56 + */
51 57 }
52 58
53 59 return finalCommand;
@@ -59,9 +65,10 @@ void Command::execute(bool inTerminal) const
59 65 QSettings settings;
60 66 QVariant variant = settings.value(QLatin1String("saveBeforeExecute"), true);
61 67 if (variant.toBool()) {
62 - MapDocument *document = DocumentManager::instance()->currentDocument();
63 -if (document)
64 - document->save();
68 +// todo: Move the 'save' function up into Document
69 +// Document *document = DocumentManager::instance()->currentDocument();
70 +// if (document)
71 +// document->save();
65 72 }
66 73
67 74 // Start the process