NAME
BQPfTreeview - BRTT Qt graphics class for displaying and editing parameter file objects
SYNOPSIS
-lbqplot -lbanner -lbrttutil $(STOCKLIB)
#include "BQ.h"
DESCRIPTION
BQPfTreeview objects are used to display and edit parameter file objects
using the
BUPf(3) and
QTreeView classes.
This class inherits the BQConfigure class which is itself a subclass of the BUConfigure class
with extensions to process Qt colors and fonts. The configure methods are implemented
in the BUConfigure parent (see BUConfigure(3)).
INHERITS FROM
QTreeView,
BQConfigure
CONSTRUCTOR
BQPfTreeview(QWidget *parent, BUPf *bupf);
Where "parent" is the QWidget parent for this object and "bupf" is
the BUPf object, or a sub-class, to be displayed and/or edited.
METHODS INHERITED FROM BQConfigure
-
void configure (Pf *params);
An Antelope parameter file object pointer that contains the BQPfTreeview object
parameters. The parameters are described below.
-
void configure (...);
A variable argument list composed entirely of character string key-value pairs with
a single NULL terminating argument. This is an alternate method for specifying
the BQPfTreeview object parameters. The parameters are described below.
BQPfTreeview METHODS
-
bool checkValue (int pfindex, QString *invalue=NULL, QList<int> *types=NULL)
This will return a true or false depending on whether or not the value constraints are satisfied
for BUPf entry index index.
If invalue is NULL, then the existing value is checked, otherwise the value of *invalue
is checked. This can be used to screen prospective change to the entry value. If types is not NUL,
then a list of constraints types will be returned (see BUPf(3)).
-
void redraw ()
This will cause the object to be completely re-rendered.
OBJECT CONFIGURATION PARAMETERS
-
allow_value_edits allow_value_edits
Specifies whether or not the values can be edited. Specified by a Boolean.
This defaults to "yes".
-
show_keys show_keys
Specifies whether or not the the parameter file keys should be displayed. Specified by a Boolean.
This defaults to "yes".
-
show_values show_values
Specifies whether or not the the parameter file values should be displayed. Specified by a Boolean.
This defaults to "yes".
-
show_comments show_comments
Specifies whether or not the the parameter file in-line comments should be displayed. Specified by a Boolean.
This defaults to "yes".
-
show_comments show_constraints
Specifies whether or not the constraints should be displayed. Specified by a Boolean.
This defaults to "no".
-
show_sources show_sources
Specifies whether or not the corresponding source file information should be
displayed. Specified by a Boolean.
This defaults to "no".
-
show_noninline_comments show_noninline_constraints
Specifies whether or not the non-inline comments should be displayed. Specified by a Boolean.
This defaults to "no".
-
font font
Specifies a font to use for displaying the strings.
Fonts are specified as "<family>[ <size>[ <weight>[ <italic?>]]]",
where <family> is a font family name, <size>size is a font size in integer points, <weight>
is an integer weight or can be one of Light, Normal, DemiBold, Bold or Black,
and <italic?> is a boolean (yes or no) to indicate if the font is in italics. System defaults
for <size>, <weight> and <italic?> are used if not specified. System default
for <family is used as the system default fixed font.
-
font_size font_size
This is a convenience option that can be used to set the font sizes without specifying
the entire font.
-
color_key color_key
Specifies a color to use for the key text.
This defaults to "black".
-
color_key_arr color_key_arr
Specifies a color to use for the key text when the key is an &Arr.
This defaults to "blue".
-
color_key_tbl color_key_tbl
Specifies a color to use for the key text when the key is a &Tbl.
This defaults to "blue".
EXAMPLE
Following is a simple c++ example.
#include "BQ.h"
class MyBUPf : public BUPf {
public:
MyBUPf (std::string pffile) : BUPf (pffile, PF_TYPE_PFFILE) {}
BQPfTreeview *tv;
protected:
void valueChangedCallback (std::string key,
int index, std::string from, std::string &to);
};
void MyBUPf::valueChangedCallback (std::string key, int index,
std::string from, std::string &to) {
printf ("Attempting to change '%s' to '%s'\n", from.c_str(), to.c_str());
QString to_qstr = to.c_str();
bool ok = tv->checkValue (index, &to_qstr);
if (ok) {
printf ("Change ok\n");
} else {
printf ("Constraints exception: changing back to original\n");
to = from;
}
}
int
main (int argc, char **argv)
{
if (argc != 2) {
fprintf (stderr, "usage: bqplot_test_pftreeview pfname\n");
exit (1);
}
char *pfname = argv[1];
MyBUPf *bupf;
try {
bupf = new MyBUPf (pfname);
}
catch (char const *err) {
fprintf (stderr, "bqplot_test_opitonsdialog: BUPf(%s) error: %s\n", pfname, err);
exit (1);
}
QApplication qapp(argc, argv);
qapp.setApplicationName("bqplot_test_pftreeview");
QWidget *widget = new QWidget();
widget->setWindowTitle("bqplot_test_pftreeview");
widget->show();
widget->resize (800, 400);
QGridLayout *layout = new QGridLayout (widget);
layout->setSpacing (0);
layout->setContentsMargins (0, 0, 0, 0);
widget->setLayout (layout);
BQPfTreeview *tv = new BQPfTreeview(widget, bupf);
bupf->tv = tv;
layout->addWidget (tv, 0, 0);
tv->configure ("font", "courier 18 Bold", NULL);
qapp.exec();
exit (0);
}
SEE ALSO
bqplot(3),
BQConfigure(3),
BUPf(3)
AUTHOR
Danny Harvey, BRTT