Fixed a bug: the edit dialog fields were not cleared if an
[emufront] / src / dialogs / namedialog.cpp
index 215116a..0bbffbf 100644 (file)
@@ -5,17 +5,17 @@
 //
 //
 // EmuFront 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.
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
 //
-// Foobar is distributed in the hope that it will be useful,
+// EmuFront 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+// along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <QtGui>
 #include "namedialog.h"
@@ -28,6 +28,7 @@ NameDialog::NameDialog(QWidget *parent, EmuFrontObject *efObj)
        nameLabel->setBuddy(nameEdit);
     connectSignals();
        layout();
+    emit test();
        setWindowTitle(tr("Set names"));
 }
 
@@ -72,8 +73,12 @@ void NameDialog::acceptChanges()
     }
 
        QString name = nameEdit->text().simplified();
-    setDataObject(name);
-    emit dataObjectUpdated();
+    qDebug() << "We have a name " << name << ".";
+    if (name != efObject->getName()) {
+        setDataObject(name);
+        emit dataObjectUpdated();
+    }
+    qDebug() << "Signal emitted.";
     efObject = 0; // TODO we should also set efObject to null when user clicks abort
     close();
 }
@@ -86,8 +91,14 @@ void NameDialog::enableSaveButton(const QString &/*text*/)
 void NameDialog::setDataObject(EmuFrontObject *ob)
 {
     if (!ob) return;
-    // delete efObject; -> we should not delete the previously referenced data object here, it may be still used in the parent widget
-    // the parent widget will take of destruction
+    // delete efObject; -> we should not delete the previously referenced data object here, it
+    // may be still used in the parent widget
+    // the parent widget will take care of destruction
     // we'll just refresh the name dialog pointer to a new object
     efObject = ob;
 }
+
+void NameDialog::clear()
+{
+    nameEdit->clear();
+}