From 42c2ce7f19eaeb8a9c7f41535bccbec7416b1982 Mon Sep 17 00:00:00 2001
From: Bert <bertrand.provot@insa-rennes.fr>
Date: Wed, 27 Jun 2018 11:29:27 +0200
Subject: [PATCH] Improvments on filter editor interface and bug fixes

---
 app/Widgets/FilterEditor.cpp     |  8 ++++++-
 app/Widgets/FilterEditorItem.cpp | 36 +++++++++++++++++++++-----------
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/app/Widgets/FilterEditor.cpp b/app/Widgets/FilterEditor.cpp
index 97e00b6..6413a60 100644
--- a/app/Widgets/FilterEditor.cpp
+++ b/app/Widgets/FilterEditor.cpp
@@ -169,7 +169,13 @@ void FilterEditor::save()
     return;
   }
   //condition regex sur le format du fichier .xml
-  // if(...
+  if(!regex_match(_linePath->text().toStdString(),regex("(.*).xml$"))){
+    QMessageBox msgBox(QMessageBox::Critical, tr("Error!"), tr("Your file needs .xml format."));
+    msgBox.setStandardButtons(QMessageBox::Ok);
+    msgBox.setDefaultButton(QMessageBox::Ok);
+    msgBox.exec();
+    return;
+  }
 
 
   bool ok;
diff --git a/app/Widgets/FilterEditorItem.cpp b/app/Widgets/FilterEditorItem.cpp
index 1e8f18f..5cbf5bb 100644
--- a/app/Widgets/FilterEditorItem.cpp
+++ b/app/Widgets/FilterEditorItem.cpp
@@ -96,23 +96,35 @@ void FilterEditorItem::initUI()
 
 void FilterEditorItem::widthChanged(const int width)
 {
-  if(_width < width)
-    emit(insertColumn(width-_width));
-  else
-    emit(removeColumn(_width-width));
-    
-  _width = width;
+  if(_width < width){
+      while(_width!=width){
+          emit(insertColumn(width-_width));
+          _width++;
+      }
+  }
+  else{
+      while(_width!=width){
+          emit(removeColumn(_width-width));
+          _width--;
+      }
+   }
   _filter->resizeColumnsToContents();
 }
 
 void FilterEditorItem::heightChanged(const int height)
 {
-  if(_height < height)
-    emit(insertRow(height-_height));
-  else
-    emit(removeRow(_height-height));
-  
-  _height = height;
+    if(_height < height){
+        while(_height!=height){
+            emit(insertRow(height-_height));
+            _height++;
+        }
+    }
+    else{
+        while(_height!=height){
+            emit(removeRow(_height-height));
+            _height--;
+        }
+     }
   _filter->resizeRowsToContents();
 }
 
-- 
GitLab