Index: trunk/BNC/qtfilechooser.cpp
===================================================================
--- trunk/BNC/qtfilechooser.cpp	(revision 3601)
+++ trunk/BNC/qtfilechooser.cpp	(revision 3601)
@@ -0,0 +1,72 @@
+/* -------------------------------------------------------------------------
+ * Generally useful widget
+ * -------------------------------------------------------------------------
+ *
+ * Class:      qtFileChooser
+ *
+ * Purpose:    Widget for selecting a file or directory
+ *
+ * Author:     L. Mervart
+ *
+ * Created:    10-May-2011
+ *
+ * Changes:
+ *
+ * -----------------------------------------------------------------------*/
+
+#include "qtfilechooser.h"
+
+// Constructor
+////////////////////////////////////////////////////////////////////////////////
+qtFileChooser::qtFileChooser(QWidget* parent) : QWidget(parent), _mode(File) {
+
+  QHBoxLayout* layout = new QHBoxLayout( this );
+  layout->setMargin(0);
+
+  _lineEdit = new QLineEdit(this);
+  layout->addWidget(_lineEdit);
+
+  connect(_lineEdit, SIGNAL(textChanged(const QString &)),
+          this, SIGNAL(fileNameChanged(const QString &)));
+
+  _button = new QPushButton("...", this);
+  _button->setFixedWidth(_button->fontMetrics().width(" ... "));
+  layout->addWidget(_button);
+
+  connect(_button, SIGNAL(clicked()), this, SLOT(chooseFile()));
+  setFocusProxy(_lineEdit);
+}
+
+// Destructor
+////////////////////////////////////////////////////////////////////////////////
+qtFileChooser::~qtFileChooser() {
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////////
+void qtFileChooser::setFileName(const QString& fileName) {
+  _lineEdit->setText(fileName);
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////////
+QString qtFileChooser::fileName() const {
+  return _lineEdit->text();
+}
+
+// 
+////////////////////////////////////////////////////////////////////////////////
+void qtFileChooser::chooseFile() {
+  QString fileName;
+  if (mode() == File) {
+    fileName = QFileDialog::getOpenFileName(this);
+  }
+  else {
+    fileName = QFileDialog::getExistingDirectory(this);
+  }
+
+  if (!fileName.isEmpty()) {
+    _lineEdit->setText(fileName);
+    emit fileNameChanged(fileName);
+  }
+}
Index: trunk/BNC/qtfilechooser.h
===================================================================
--- trunk/BNC/qtfilechooser.h	(revision 3601)
+++ trunk/BNC/qtfilechooser.h	(revision 3601)
@@ -0,0 +1,39 @@
+
+#ifndef QTFILECHOOSER
+#define QTFILECHOOSER
+
+#include <QtGui>
+
+class qtFileChooser : public QWidget {
+  Q_OBJECT
+
+  Q_ENUMS( Mode )
+  Q_PROPERTY( Mode mode READ mode WRITE setMode )
+  Q_PROPERTY( QString fileName READ fileName WRITE setFileName )
+
+ public:
+  qtFileChooser(QWidget* parent = 0);
+  ~qtFileChooser();
+
+  enum Mode {File, Directory};
+
+  QString fileName() const;
+  Mode mode() const {return _mode;}
+
+  public slots:
+   void setFileName(const QString& fileName);
+   void setMode(Mode mode) {_mode = mode;}
+
+  signals:
+   void fileNameChanged(const QString&);
+
+  private slots:
+   void chooseFile();
+
+  private:
+   QLineEdit*   _lineEdit;
+   QPushButton* _button;
+   Mode         _mode;
+
+};
+#endif
