]> https://gitweb.dealii.org/ - parameter_gui.git/commitdiff
Add multiple file dialog. Improve appearance. 4/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 30 Mar 2017 02:34:42 +0000 (20:34 -0600)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 30 Mar 2017 02:34:42 +0000 (20:34 -0600)
browse_lineedit.cpp
browse_lineedit.h
parameter_delegate.cpp

index d2890b5f6ad943bb096c5406a7a91405262dc579..e35abdef22d107b91cfceedbb1ac3662414cd79f 100644 (file)
@@ -37,6 +37,7 @@ namespace dealii
 
       QHBoxLayout *layout = new QHBoxLayout;
 
+      layout->setContentsMargins(1,1,1,1);
       layout->addWidget(line_editor);
       layout->addWidget(browse_button);
       setLayout(layout);
@@ -109,6 +110,15 @@ namespace dealii
               break;
             };
 
+          case files:
+            {
+              QStringList names = QFileDialog::getOpenFileNames(this, tr("Open Files"),
+                                                  QDir::currentPath(),
+                                                  tr("All Files (*.*)"));
+              name = names.join(",");
+              break;
+            };
+
           case directory:
             {
               name = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
index 1c14ec626cd3052342db0d686b227876a9fe5c58..6abe7f002f23b56a89b68574ba68d44d98ac20c4 100644 (file)
@@ -54,7 +54,7 @@ namespace dealii
                                      * a <tt>directory</tt> dialog. This can be specified
                                      * in the constructor by setting this flag <tt>BrowseType</tt>.
                                      */
-        enum BrowseType {file = 0, directory = 1};
+        enum BrowseType {file = 0, directory = 1, files = 2};
                                     /**
                                      * Constructor. The type of the browse dialog can be specified
                                      * by the flag <tt>BrowseType</tt>, the default is <tt>file</tt>.
index 28fc27a55f9d55adadfe9771352a79252c6c3df1..a2480f9efa8a237cf961dfa14e313fd0b7d90313 100644 (file)
@@ -101,7 +101,8 @@ namespace dealii
         {
           QString pattern_description = index.data(Qt::StatusTipRole).toString();      // load pattern description
                                                                                        // stored in the StatusLine
-          QRegExp  rx_string("\\b(Anything|MultipleSelection|List|Map)\\b"),
+          QRegExp  rx_string("\\b(Anything|MultipleSelection|Map)\\b"),
+                   rx_list("\\b(List)\\b"),
                    rx_filename("\\b(FileName)\\b"),    
                    rx_dirname("\\b(DirectoryName)\\b"),        
                    rx_integer("\\b(Integer)\\b"),
@@ -118,6 +119,28 @@ namespace dealii
 
               return line_editor;
             }
+          else if (rx_list.indexIn (pattern_description) != -1)                         // if the type is "List"
+            {
+              if (rx_filename.indexIn (pattern_description) != -1)
+                {
+                  BrowseLineEdit * filename_editor =                                        // choose a BrowseLineEditor
+                      new BrowseLineEdit(BrowseLineEdit::files, parent);
+
+                  connect(filename_editor, SIGNAL(editingFinished()),
+                          this, SLOT(commit_and_close_editor()));
+
+                  return filename_editor;
+                }
+              else
+                {
+                  QLineEdit * line_editor = new QLineEdit(parent);                                // choose a LineEditor
+
+                  connect(line_editor, SIGNAL(editingFinished()),                           // and connect editors signal
+                          this, SLOT(commit_and_close_editor()));                           // to the closer function
+
+                  return line_editor;
+                }
+            }
           else if (rx_filename.indexIn (pattern_description) != -1)                    // if the type is "FileName"
             {
               BrowseLineEdit * filename_editor =                                       // choose a BrowseLineEditor
@@ -245,7 +268,8 @@ namespace dealii
                                                                                        // stored in the StatusLine
 
 
-          QRegExp  rx_string("\\b(Anything|MultipleSelection|List|Map)\\b"),
+          QRegExp  rx_string("\\b(Anything|MultipleSelection|Map)\\b"),
+                   rx_list("\\b(List)\\b"),
                    rx_filename("\\b(FileName)\\b"),
                    rx_dirname("\\b(DirectoryName)\\b"),
                    rx_selection("\\b(Selection)\\b");
@@ -254,6 +278,20 @@ namespace dealii
             {
               QItemDelegate::setEditorData(editor, index);
             }
+          else if (rx_list.indexIn (pattern_description) != -1)                   // if the type is "List"
+            {
+              if (rx_filename.indexIn (pattern_description) != -1)
+                {
+                  QString  file_name = index.data(Qt::DisplayRole).toString();
+
+                  BrowseLineEdit *filename_editor = qobject_cast<BrowseLineEdit *>(editor); // set the text of the editor
+                  filename_editor->setText(file_name);
+                }
+              else
+                {
+                  QItemDelegate::setEditorData(editor, index);
+                }
+            }
           else if (rx_filename.indexIn (pattern_description) != -1)                    // if the type is "FileName"
             {
               QString  file_name = index.data(Qt::DisplayRole).toString();
@@ -304,7 +342,8 @@ namespace dealii
           QString pattern_description = index.data(Qt::StatusTipRole).toString();      // load pattern description
                                                                                        // stored in the StatusLine
 
-          QRegExp  rx_string("\\b(Anything|MultipleSelection|List|Map)\\b"),
+          QRegExp  rx_string("\\b(Anything|MultipleSelection|Map)\\b"),
+                   rx_list("\\b(List)\\b"),
                    rx_filename("\\b(FileName)\\b"),
                    rx_dirname("\\b(DirectoryName)\\b"),
                    rx_selection("\\b(Selection)\\b");
@@ -313,6 +352,19 @@ namespace dealii
             {
               QItemDelegate::setModelData(editor, model, index);
             }
+          else if (rx_list.indexIn (pattern_description) != -1)                   // if the type is "List"
+            {
+              if (rx_filename.indexIn (pattern_description) != -1)
+                {
+                  BrowseLineEdit * filename_editor = qobject_cast<BrowseLineEdit *>(editor);        // set the text from the editor
+                  QString value = filename_editor->text();
+                  model->setData(index, value);
+                }
+              else
+                {
+                  QItemDelegate::setModelData(editor, model, index);
+                }
+            }
           else if (rx_filename.indexIn (pattern_description) != -1)                            // if the type is "FileName"
             {
               BrowseLineEdit * filename_editor = qobject_cast<BrowseLineEdit *>(editor);       // set the text from the editor

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.