-lbqplot -lbanner -lbrttutil $(DBLIBS) #include "BQ.h"
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)).
This class also inherits the BQTableview(3) class. The virtual BQTableview::callback method is implemented in this class. This class will show static database tables and views. There is no editing support. This class is meant as a simple display for selecting single rows for further processing.
BQDbTableview(QWidget *parent, Dbptr db);
Where "parent" is the QWidget parent for this object and db is the database table or view to display.
- label label
This is a label string to be used in the column header. If it is not specified, then the label will be set to the column definition name.- source source_expression
This is a datascope expression string that is used to derive the cell text. This must conform to a valid datascope expression for the input table or view (see dbexpressions(5)). Thus must be specified.- sort sort_field1[ sort_field2[ ...]
This is a list of white space separated fields that will be used to sort using this column. Each field must exist in the table or view and will be used to form the fields tbl argument in dbsort(3). If this is not specified, then sorts on this column will use the default Qt string sorting based on the cell text.- format format_string
This is a format specification, ala sprintf(3), for making the cell text. The format string type must match the type returned from the source expression. If this is not specified, then a default string conversion will be done.- text_template text_template_string
This is a template string used to set a fixed width for the column. The font metrics of the string using the current font is used to determine the width in pixels. If this can be parsed as an integer, then that value will be used as the width (see DBTableview(3) column_widths configuration parameter).- alignment {w|c|e}
This determines the cell text horizontal alignment, w for a west (left) alignment, c for a center alignment, or e for an east (right) alignment. If this is not specified then a default alignment will be used.
#include "BQ.h" class MyDbTableview : public BQDbTableview { public: MyDbTableview (QWidget *parent, Dbptr db) : BQDbTableview (parent, db) {} protected: void selectionCallback (int &row) { printf ("Selection record %d\n", row); } }; int main (int argc, char **argv) { char *dbname = "/opt/antelope/data/db/demo/demo"; Dbptr db = dbinvalid(); if (dbopen (dbname, (char *)"r", &db) < 0) { fprintf (stderr, "bqplot_test_dbtableview: dbopen(%s) error\n", dbname); exit (1); } db = dblookup (db, 0, (char *)"origin", 0, 0); Dbptr dba = dblookup (db, 0, (char *)"assoc", 0, 0); db = dbjoin (db, dba, 0, 0, 0, 0, 0); dba = dblookup (db, 0, (char *)"arrival", 0, 0); db = dbjoin (db, dba, 0, 0, 0, 0, 0); QApplication qapp(argc, argv); qapp.setApplicationName("bqplot_test_dbtableview"); QWidget *widget = new QWidget(); widget->setWindowTitle("bqplot_test_dbtableview"); widget->show(); widget->resize (800, 400); QGridLayout *layout = new QGridLayout (widget); layout->setSpacing (0); layout->setContentsMargins (0, 0, 0, 0); widget->setLayout (layout); char *column_names = (char *)"\ column_names &Tbl{\n\ time\n\ lat\n\ lon\n\ depth\n\ ml\n\ sta\n\ iphase\n\ }\n"; char *column_definitions = (char *)"\ column_definitions &Arr{\n\ time &Arr{\n\ label time\n\ text_template XXXXXXXXXXXXXXXXXXXXXX\n\ source epoch2str(time,\"%Y%j:%T\")\n\ }\n\ lat &Arr{\n\ label lat\n\ text_template XXXXXXXXXX\n\ source lat\n\ sort lat\n\ alignment e\n\ format %.3lf\n\ }\n\ lon &Arr{\n\ label lon\n\ text_template XXXXXXXXXX\n\ source lon\n\ sort lon\n\ alignment e\n\ format %.3lf\n\ }\n\ depth &Arr{\n\ label depth\n\ text_template XXXXXXXX\n\ source depth\n\ sort depth\n\ alignment e\n\ format %.2lf\n\ }\n\ ml &Arr{\n\ label ml\n\ text_template XXXXXXX\n\ source ml\n\ sort ml\n\ alignment e\n\ format %.2lf\n\ }\n\ sta &Arr{\n\ label sta\n\ text_template XXXXXXX\n\ source sta\n\ }\n\ iphase &Arr{\n\ label iphase\n\ text_template XXXXXXX\n\ source iphase\n\ }\n\ }\n"; MyDbTableview *dbtv = new MyDbTableview(widget, db); dbtv->configure ( "column_names", column_names, "column_definitions", column_definitions, "color_hover", "magenta", "font", "courier,18", "font_header", "arial,14,Normal", "default_hover_interaction", "no", "show_record_numbers", "yes", NULL); layout->addWidget (dbtv, 0, 0, 1, 1); int width, height; dbtv->totalSize (width, height); width += 18; height += 18; if (width > 2000) width = 2000; if (height > 2000) height = 2000; widget->resize (width, height); widget->setMaximumWidth (width); widget->setMaximumHeight (height); qapp.exec(); exit (0); }