1 #include "ImageListActionWorkOrder.h"
10 ImageListActionWorkOrder::ImageListActionWorkOrder(Project *project) :
15 ImageListActionWorkOrder::ImageListActionWorkOrder(Action action, Project *project) :
18 QUndoCommand::setText(
toString(action));
21 internalData.append(
toString(action));
22 setInternalData(internalData);
26 ImageListActionWorkOrder::ImageListActionWorkOrder(
27 const ImageListActionWorkOrder &other) : WorkOrder(other) {
28 foreach (
const Image *image, *other.imageList()) {
29 connect(
this, SIGNAL(bringToFront()), image->displayProperties(), SIGNAL(moveToTop()));
34 ImageListActionWorkOrder::~ImageListActionWorkOrder() {
50 return !images->isEmpty();
58 WorkOrder::setData(images);
60 if (internalData().count()) {
61 QAction::setText(qualifyString(internalData()[0], imageList()));
63 QString modifiedString = (qualifyString(internalData()[0], imageList()) +
" on %1 images")
64 .arg(imageList()->count());
65 QUndoCommand::setText(modifiedString);
68 foreach (
Image *image, *images) {
69 connect(
this, SIGNAL(bringToFront()), image->
displayProperties(), SIGNAL(moveToTop()));
80 if (!internalData().isEmpty()) {
82 QString actionString = internalData()[0];
84 switch(fromActionString(actionString)) {
89 case ChangeTransparency: {
91 result = imageList()->
askAlpha(&alpha);
92 state.append(QString::number(alpha));
98 result = imageList()->askNewColor(&color);
101 if (color.isValid()) {
102 state.append(Color::toRGBAString(color));
110 case ToggleShowLabel: {
111 int maxRecommendedLabels = 2000;
112 if (qualifyString(actionString, imageList()).startsWith(tr(
"Show")) &&
113 imageList()->count() > maxRecommendedLabels) {
114 QMessageBox::StandardButton selectedOpt = QMessageBox::warning(NULL,
115 tr(
"Potentially Slow Operation"),
116 tr(
"You are asking to show the labels on %L1 images. When viewing these images in "
117 "a 2D footprint view, these images will take at least 3x longer to render. This "
118 "is a significant performance loss. Showing more than a few labels at a time is "
119 "not recommended. Are you sure you want to show the labels on these %L1 images?")
120 .arg(imageList()->count()),
121 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
123 if (selectedOpt == QMessageBox::No) {
130 case ToggleShowFilled:
133 case ToggleShowCubeData:
136 case ToggleShowOutline:
140 setInternalData(state);
152 QString actionString = internalData()[0];
154 switch(fromActionString(actionString)) {
158 case ChangeTransparency:
159 state = state.mid(0, 2);
160 state.append(imageList()->saveAndApplyAlpha(state[1].
toInt()));
164 state = state.mid(0, 2);
165 state.append(imageList()->saveAndApplyColor(Color::fromRGBAString(state[1])));
169 if (state.count() > 1) {
171 imageList()->applyColors(state.mid(1), 1);
174 state.append(imageList()->saveAndApplyRandomColor());
178 case ToggleShowLabel:
179 state = state.mid(0, 1);
180 state.append(imageList()->saveAndToggleShowLabel());
183 case ToggleShowFilled:
184 state = state.mid(0, 1);
185 state.append(imageList()->saveAndToggleShowFill());
188 case ToggleShowCubeData:
189 state = state.mid(0, 1);
190 state.append(imageList()->saveAndToggleShowDNs());
193 case ToggleShowOutline:
194 state = state.mid(0, 1);
195 state.append(imageList()->saveAndToggleShowOutline());
199 setInternalData(state);
205 QString actionString = internalData()[0];
207 switch(fromActionString(actionString)) {
211 case ChangeTransparency:
212 imageList()->applyAlphas(state.mid(2));
216 imageList()->applyColors(state.mid(2));
221 imageList()->applyColors(state.mid(1), 0);
224 case ToggleShowLabel:
225 imageList()->applyShowLabel(state.mid(1));
228 case ToggleShowFilled:
229 imageList()->applyShowFill(state.mid(1));
232 case ToggleShowCubeData:
233 imageList()->applyShowDNs(state.mid(1));
236 case ToggleShowOutline:
237 imageList()->applyShowOutline(state.mid(1));
241 setInternalData(state);
245 QString ImageListActionWorkOrder::qualifyString(QString unqualifiedString,
247 QString result = unqualifiedString;
249 if (imageList && imageList->count()) {
251 Action act = fromActionString(unqualifiedString);
253 if (act == ToggleShowLabel) {
255 result = tr(
"Hide Label");
258 result = tr(
"Show Label");
262 if (act == ToggleShowFilled) {
264 result = tr(
"Show Unfilled");
267 result = tr(
"Show Filled");
271 if (act == ToggleShowCubeData) {
273 result = tr(
"Hide Cube Data");
276 result = tr(
"Show Cube Data");
280 if (act == ToggleShowOutline) {
282 result = tr(
"Hide Outline");
285 result = tr(
"Show Outline");
294 QString ImageListActionWorkOrder::toString(Action action) {
302 case ChangeTransparency:
303 result = tr(
"Change Transparency");
307 result = tr(
"Change Color");
311 result = tr(
"Randomize Color");
314 case ToggleShowLabel:
315 result = tr(
"Toggle Label");
318 case ToggleShowFilled:
319 result = tr(
"Toggle Show Filled");
322 case ToggleShowCubeData:
323 result = tr(
"Toggle Show Cube Data");
326 case ToggleShowOutline:
327 result = tr(
"Toggle Show Outline");
335 ImageListActionWorkOrder::Action ImageListActionWorkOrder::fromActionString(
336 QString actionString) {
337 Action result = UnknownAction;
339 for (Action act = UnknownAction;
340 result == UnknownAction && act <= ToggleShowOutline;
341 act = (Action)(act + 1)) {
342 if (toString(act).toUpper() == actionString.toUpper()) {