FGx  1
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
fileDialog.h
1 /* ********************************************************
2  * fileDialog.h
3  *
4  * Created by Geoff R. Mclane, Paris
5  * (C) Dec 2011 GPL2 (or later)
6  *
7  * A rather crude getFileName capability
8  *
9  ******************************************************** */
10 #ifndef FILEDIALOG_H
11 #define FILEDIALOG_H
12 
13 // #include "app_config.h"
14 #include <QWidget>
15 #include <QDialog>
16 #include <QLabel>
17 #include <QLineEdit>
18 #include <QGridLayout>
19 #include <QPushButton>
20 #include <QTreeWidget>
21 #include <QAbstractItemView>
22 #include <QStatusBar>
23 
24 enum COLS{
25  C_TYPE = 0,
26  C_NAME
27 };
28 
29 // these are 'special' paths
30 #define ST_ROOT "<root>" // in linux system - at the 'root'
31 #define ST_DRIVES "<drives>" // in windows system - at the 'root' with active DRIVES listed
32 
33 #define flg_AddExtent 0x0001
34 
35 #define flg_Default (flg_AddExtent)
36 
37 class fileDialog : public QDialog
38 {
39  Q_OBJECT
40 public:
41  explicit fileDialog(QWidget *parent = 0);
42  // ***TBD*** could also have an instatiation that included the 'title', 'previous' and filter
43  void init(QString title = QString(), QString prev = QString(), QStringList filt = QStringList());
44  QString getFileName(); // get results. Return "" if user cancelled, and ADDS extension if single filter given, and not added
45  bool got_cancel;
46  // this ONLY applies to WINDOWS
47  int getDriveCount();
48  int optionFlag;
49 
50 signals:
51  void set_file(QString);
52 
53 public slots:
54  void on_ok();
55  void on_cancel();
56  void on_tree_selection_changed();
57  void on_name_change(QString);
58  void on_path_change(QString);
59 
60 
61 private:
62  // no user access to these
63  void fill_tree(); // using pathEd->text()
64  QLabel *nameLab; // = new QLabel("Name:",this);
65  QLabel *pathLab; // = new QLabel("Path:",this);
66  QLineEdit *nameEd; // = new QLineEdit(this);
67  QLineEdit *pathEd; // = new QLineEdit(this);
68  QLabel *filtLabel1; // = new QLabel("Filter:",this);
69  QLabel *filtLabel2; // = new QLabel("*",this);
70  QTreeWidget *treeWidget; // = new QTreeWidget(this);
71  int filt_count; // if user supplies a filter like '*.ini'
72 };
73 
74 
75 #endif // FILEDIALOG_H
Definition: fileDialog.h:37