1.1 --- a/mapeditor.cpp Mon Mar 05 23:22:51 2007 +0000
1.2 +++ b/mapeditor.cpp Tue Mar 06 19:37:39 2007 +0000
1.3 @@ -489,7 +489,7 @@
1.4 if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t);
1.5 addMapReplaceInt(selb->getSelectString(),t);
1.6 }
1.7 - } else if (com==QString("addMparsernsert"))
1.8 + } else if (com==QString("addMapInsert"))
1.9 {
1.10 if (xelection.isEmpty())
1.11 {
1.12 @@ -552,9 +552,9 @@
1.13 if (xelection.isEmpty())
1.14 {
1.15 parser.setError (Aborted,"Nothing selected");
1.16 - } else if (! selb )
1.17 + } else if (xelection.type() != Branch && xelection.type() != FloatImage )
1.18 {
1.19 - parser.setError (Aborted,"Type of selection is not a branch");
1.20 + parser.setError (Aborted,"Type of selection is wrong.");
1.21 } else if (parser.checkParamCount(0))
1.22 {
1.23 deleteSelection();
1.24 @@ -722,6 +722,21 @@
1.25 {
1.26 paste();
1.27 }
1.28 + } else if (com=="saveImage")
1.29 + {
1.30 + FloatImageObj *fio=xelection.getFloatImage();
1.31 + if (!fio)
1.32 + {
1.33 + parser.setError (Aborted,"Type of selection is not an image");
1.34 + } else if (parser.checkParamCount(2))
1.35 + {
1.36 + s=parser.parString(ok,0);
1.37 + if (ok)
1.38 + {
1.39 + t=parser.parString(ok,1);
1.40 + if (ok) saveFloatImageInt (fio,t,s);
1.41 + }
1.42 + }
1.43 } else if (com=="scroll")
1.44 {
1.45 if (xelection.isEmpty() )
1.46 @@ -758,6 +773,22 @@
1.47 selectInt (bo);
1.48
1.49 }
1.50 + } else if (com=="selectLastImage")
1.51 + {
1.52 + if (xelection.isEmpty() )
1.53 + {
1.54 + parser.setError (Aborted,"Nothing selected");
1.55 + } else if (! selb )
1.56 + {
1.57 + parser.setError (Aborted,"Type of selection is not a branch");
1.58 + } else if (parser.checkParamCount(0))
1.59 + {
1.60 + FloatImageObj *fio=selb->getLastFloatImage();
1.61 + if (!fio)
1.62 + parser.setError (Aborted,"Could not select last image");
1.63 + selectInt (fio);
1.64 +
1.65 + }
1.66 } else if (com=="setMapAuthor")
1.67 {
1.68 if (parser.checkParamCount(1))
1.69 @@ -827,11 +858,38 @@
1.70 } else if (! selb)
1.71 {
1.72 parser.setError (Aborted,"Type of selection is not a branch or floatimage");
1.73 + //FIXME selb is never a floatimage!!
1.74 } else if (parser.checkParamCount(1))
1.75 {
1.76 b=parser.parBool(ok,0);
1.77 if (ok) setHideExport (b);
1.78 }
1.79 + } else if (com=="setIncludeImagesHorizontally")
1.80 + {
1.81 + if (xelection.isEmpty() )
1.82 + {
1.83 + parser.setError (Aborted,"Nothing selected");
1.84 + } else if (! selb)
1.85 + {
1.86 + parser.setError (Aborted,"Type of selection is not a branch");
1.87 + } else if (parser.checkParamCount(1))
1.88 + {
1.89 + b=parser.parBool(ok,0);
1.90 + if (ok) setIncludeImagesHor(b);
1.91 + }
1.92 + } else if (com=="setIncludeImagesVertically")
1.93 + {
1.94 + if (xelection.isEmpty() )
1.95 + {
1.96 + parser.setError (Aborted,"Nothing selected");
1.97 + } else if (! selb)
1.98 + {
1.99 + parser.setError (Aborted,"Type of selection is not a branch");
1.100 + } else if (parser.checkParamCount(1))
1.101 + {
1.102 + b=parser.parBool(ok,0);
1.103 + if (ok) setIncludeImagesVer(b);
1.104 + }
1.105 } else if (com=="setURL")
1.106 {
1.107 if (xelection.isEmpty() )
1.108 @@ -3130,6 +3188,11 @@
1.109 }
1.110 }
1.111
1.112 +void MapEditor::saveFloatImageInt (FloatImageObj *fio, const QString &type, const QString &fn)
1.113 +{
1.114 + fio->save (fn,type);
1.115 +}
1.116 +
1.117 void MapEditor::saveFloatImage ()
1.118 {
1.119 FloatImageObj *fio=xelection.getFloatImage();
1.120 @@ -3144,13 +3207,14 @@
1.121 fd->show();
1.122
1.123 QString fn;
1.124 - if ( fd->exec() == QDialog::Accepted )
1.125 + if ( fd->exec() == QDialog::Accepted && fd->selectedFiles().count()==1)
1.126 {
1.127 - if (QFile (fd->selectedFile()).exists() )
1.128 + fn=fd->selectedFiles().at(0);
1.129 + if (QFile (fn).exists() )
1.130 {
1.131 QMessageBox mb( vymName,
1.132 tr("The file %1 exists already.\n"
1.133 - "Do you want to overwrite it?").arg(fd->selectedFile()),
1.134 + "Do you want to overwrite it?").arg(fn),
1.135 QMessageBox::Warning,
1.136 QMessageBox::Yes | QMessageBox::Default,
1.137 QMessageBox::Cancel | QMessageBox::Escape,
1.138 @@ -3170,7 +3234,7 @@
1.139 break;
1.140 }
1.141 }
1.142 - fio->save (fd->selectedFile(),imageIO.getType (fd->selectedFilter() ) );
1.143 + saveFloatImageInt (fio,fd->selectedFilter(),fn );
1.144 }
1.145 delete (fd);
1.146 }
1.147 @@ -3192,6 +3256,16 @@
1.148 BranchObj *bo=xelection.getBranch();
1.149 if (bo)
1.150 {
1.151 + QString u= b ? "false" : "true";
1.152 + QString r=!b ? "false" : "true";
1.153 +
1.154 + saveState(
1.155 + bo,
1.156 + QString("setIncludeImagesVertically (%1)").arg(u),
1.157 + bo,
1.158 + QString("setIncludeImagesVertically (%1)").arg(r),
1.159 + QString("Include images vertically in %1").arg(getName(bo))
1.160 + );
1.161 bo->setIncludeImagesVer(b);
1.162 mapCenter->reposition();
1.163 }
1.164 @@ -3202,6 +3276,16 @@
1.165 BranchObj *bo=xelection.getBranch();
1.166 if (bo)
1.167 {
1.168 + QString u= b ? "false" : "true";
1.169 + QString r=!b ? "false" : "true";
1.170 +
1.171 + saveState(
1.172 + bo,
1.173 + QString("setIncludeImagesHorizontally (%1)").arg(u),
1.174 + bo,
1.175 + QString("setIncludeImagesHorizontally (%1)").arg(r),
1.176 + QString("Include images horizontally in %1").arg(getName(bo))
1.177 + );
1.178 bo->setIncludeImagesHor(b);
1.179 mapCenter->reposition();
1.180 }