FGx  1
dirDialog.h
1 /* ********************************************************
2  * dirDialog.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 DIRDIALOG_H
11 #define DIRDIALOG_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 <QModelIndex>
23 
24 enum DCOLS{
25  D_TYPE = 0,
26  D_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 class dirDialog : public QDialog
34 {
35  Q_OBJECT
36 public:
37  explicit dirDialog(QWidget *parent = 0);
38  // ***TBD*** could also have an instatiation that included the 'title', 'previous' and filter
39  void init(QString title = QString(), QString prev = QString());
40  QString getDirName(); // get results. Return "" if user cancelled
41  bool got_cancel;
42  // this ONLY applies to WINDOWS
43  int getDriveCount();
44  int optionFlag;
45 
46 signals:
47  void set_file(QString);
48 
49 public slots:
50  void on_ok();
51  void on_cancel();
52  void on_tree_selection_changed();
53  void on_tree_double_clicked(QModelIndex);
54  void on_name_change(QString);
55  void on_path_change(QString);
56 
57 
58 private:
59  // no user access to these
60  void fill_tree(); // using pathEd->text()
61  QGridLayout *mainLayout; // = new QGridLayout(this);
62  QLabel *info1; // = new QLabel("Enter file Name: or Path: or navigate via the tree list below.",this);
63  QLabel *info2; // = new QLabel("Green if exists. Red if new.",this);
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  QTreeWidget *treeWidget; // = new QTreeWidget(this);
69  QPushButton *cancelButton; // = new QPushButton(this);
70  QPushButton *okButton; // = new QPushButton(this);
71 };
72 
73 
74 #endif // DIRDIALOG_H
Definition: dirDialog.h:33