From c0050115c2e9963d0f70ac64f0a693df8b7d9056 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sacha=20Percot-T=C3=A9tu?= <zakinster@zakinster.com>
Date: Mon, 9 Jul 2012 10:15:30 +0200
Subject: [PATCH] Moved utility method to namespace Tools

---
 app/Operations/PointOp.cpp |  6 ++++--
 app/Operations/PointOp.h   | 10 ----------
 app/Tools.h                | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 12 deletions(-)
 create mode 100644 app/Tools.h

diff --git a/app/Operations/PointOp.cpp b/app/Operations/PointOp.cpp
index cd6daac..55528c0 100644
--- a/app/Operations/PointOp.cpp
+++ b/app/Operations/PointOp.cpp
@@ -33,6 +33,8 @@
 #include "ImgWidget.h"
 #include "ImageListBox.h"
 
+#include "../Tools.h"
+
 using namespace std;
 using namespace imagein;
 
@@ -106,7 +108,7 @@ vector<QWidget*> PointOp::operator()(const imagein::Image* image, const std::map
     exprEdits[0] = new QLineEdit(pixelWidget);
     exprEdits[0]->setFixedWidth(64);
     imageBoxes[0] = new ImageListBox(pixelWidget, image, imgList);
-    valueLayouts[0]->addWidget(new QLabel("Image", pixelWidget));
+    valueLayouts[0]->addWidget(new QLabel(dialog->tr("Image"), pixelWidget));
     valueLayouts[0]->addWidget(pixOperatorBoxes[0]);
     valueLayouts[0]->addWidget(imgOperatorBoxes[0]);
     valueLayouts[0]->addWidget(exprEdits[0]);
@@ -127,7 +129,7 @@ vector<QWidget*> PointOp::operator()(const imagein::Image* image, const std::map
         exprEdits[i] = new QLineEdit(colorWidget);
         exprEdits[i]->setFixedWidth(64);
         imageBoxes[i] = new ImageListBox(colorWidget, image, imgList);
-        valueLayouts[i]->addWidget(new QLabel(colorName(i-1, nChannel), colorWidget));
+        valueLayouts[i]->addWidget(new QLabel(Tools::colorName(i-1, nChannel), colorWidget));
         valueLayouts[i]->addWidget(pixOperatorBoxes[i]);
         valueLayouts[i]->addWidget(imgOperatorBoxes[i]);
         valueLayouts[i]->addWidget(exprEdits[i]);
diff --git a/app/Operations/PointOp.h b/app/Operations/PointOp.h
index cadebb1..a97c8fb 100644
--- a/app/Operations/PointOp.h
+++ b/app/Operations/PointOp.h
@@ -40,16 +40,6 @@ class PointOp : public Operation {
 
     bool needCurrentImg();
 
-    inline static QString colorName(int i, int n) {
-        if((n==1 || n==2) && i==0) return tr("Black");
-        if((n==2 && i==1) || (n==4 && i==3)) return tr("Alpha");
-        switch(i) { case 0: return tr("Red"); case 1: return tr("Green"); case 2: return tr("Blue"); default: return tr("Color"); }
-    }
-
-
-
-    static inline QString tr(const char* str) { return QCoreApplication::tr(str); }
-
   private:
     typedef imagein::Image::depth_t depth_t;
 
diff --git a/app/Tools.h b/app/Tools.h
new file mode 100644
index 0000000..d0afc1a
--- /dev/null
+++ b/app/Tools.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011-2012 INSA Rennes
+ *
+ * This file is part of EIImage.
+ *
+ * EIImage is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EIImage is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EIImage.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef TOOLS_H
+#define TOOLS_H
+
+namespace Tools {
+
+    inline QString tr(const char* str) { return QCoreApplication::tr(str); }
+
+    inline QString colorName(int i, int n) {
+        if((n==1 || n==2) && i==0) return tr("Black");
+        if((n==2 && i==1) || (n==4 && i==3)) return tr("Alpha");
+        switch(i) { case 0: return tr("Red"); case 1: return tr("Green"); case 2: return tr("Blue"); default: return tr("Color"); }
+    }
+
+}
+
+#endif // TOOLS_H
-- 
GitLab