-
Notifications
You must be signed in to change notification settings - Fork 9
/
browse_lineedit.h
127 lines (108 loc) · 3.55 KB
/
browse_lineedit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// ---------------------------------------------------------------------
//
// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef BROWSELINEEDIT_H
#define BROWSELINEEDIT_H
#include <QFrame>
#include <QLineEdit>
#include <QFileDialog>
#include <QPushButton>
namespace dealii
{
/*! @addtogroup ParameterGui
*@{
*/
namespace ParameterGui
{
/**
* The BrowseLineEdit class provides a special line editor for the parameterGUI.
* While editing file- or directory names it is much more easier to have a file-dialog
* and just click on existing files or directories. This editor provides a simple QLineEditor
* and a browse-button which opens a file- or a directory dialog. Clicking on existing files or directories
* copies the path to the line editor. Depending on the <tt>BrowseType</tt> given in the constructor
* the browse button opens a <tt>file</tt> or a <tt>directory</tt> dialog.
*
* @note This class is used in the graphical user interface for the @ref ParameterHandler class.
* It is not compiled into the deal.II libraries and can not be used by applications using deal.II.
*
* @ingroup ParameterGui
* @author Martin Steigemann, Wolfgang Bangerth, 2010
*/
class BrowseLineEdit : public QFrame
{
Q_OBJECT
public:
/**
* The browse button opens a <tt>file</tt> or
* 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, files = 2};
/**
* Constructor. The type of the browse dialog can be specified
* by the flag <tt>BrowseType</tt>, the default is <tt>file</tt>.
*/
BrowseLineEdit (const BrowseType type = file,
QWidget *parent = 0);
/**
* Reimplemented from the QWidget class.
* Returns the size of the editor.
*/
QSize sizeHint() const;
/**
* Reimplemented from the QWidget class.
*/
QSize minimumSizeHint() const;
/**
* Returns the text of the line editor.
*/
QString text() const;
/**
* This pattern stores the type of the browse dialog.
*/
BrowseType browse_type;
public slots:
/**
* A <tt>slot</tt> to set @p str as text of the line editor.
*/
void setText(const QString &str);
signals:
/**
* This <tt>signal</tt> will be emitted, if editing is finished.
*/
void editingFinished();
private slots:
/**
* This <tt>slot</tt> should be always called, if editing is finished.
*/
void editing_finished();
/**
* This function opens a file- or a directory dialog as specified in the
* constructor.
*/
void browse();
private:
/**
* The line editor.
*/
QLineEdit *line_editor;
/**
* The browse button.
*/
QPushButton *browse_button;
};
}
/**@}*/
}
#endif