[4879] | 1 |
|
---|
| 2 | /* -------------------------------------------------------------------------
|
---|
| 3 | * RTNet GUI
|
---|
| 4 | * -------------------------------------------------------------------------
|
---|
| 5 | *
|
---|
| 6 | * Class: t_uniLine
|
---|
| 7 | *
|
---|
[4880] | 8 | * Purpose: Universal-Line Widget (subclasses QTableWidget)
|
---|
[4879] | 9 | *
|
---|
| 10 | * Author: L. Mervart
|
---|
| 11 | *
|
---|
| 12 | * Created: 08-Jan-2013
|
---|
| 13 | *
|
---|
| 14 | * Changes:
|
---|
| 15 | *
|
---|
| 16 | * -----------------------------------------------------------------------*/
|
---|
| 17 |
|
---|
| 18 | #include "uniline.h"
|
---|
[4882] | 19 | #include "keyword.h"
|
---|
[4879] | 20 |
|
---|
| 21 | using namespace std;
|
---|
[5000] | 22 | using namespace GnssCenter;
|
---|
[4879] | 23 |
|
---|
[4883] | 24 | static const char* plus_xpm[] = {
|
---|
| 25 | "16 16 2 1",
|
---|
| 26 | " c #FFFFFFFFFFFF",
|
---|
| 27 | ". c #00000000FFFF",
|
---|
| 28 | " ",
|
---|
| 29 | " ... ",
|
---|
| 30 | " ... ",
|
---|
| 31 | " ... ",
|
---|
| 32 | " ... ",
|
---|
| 33 | " ... ",
|
---|
| 34 | " .............. ",
|
---|
| 35 | " .............. ",
|
---|
| 36 | " .............. ",
|
---|
| 37 | " ... ",
|
---|
| 38 | " ... ",
|
---|
| 39 | " ... ",
|
---|
| 40 | " ... ",
|
---|
| 41 | " ... ",
|
---|
| 42 | " ",
|
---|
| 43 | " "};
|
---|
| 44 |
|
---|
| 45 | static const char* minus_xpm[] = {
|
---|
| 46 | "16 16 2 1",
|
---|
| 47 | " c #FFFFFFFFFFFF",
|
---|
| 48 | ". c #00000000FFFF",
|
---|
| 49 | " ",
|
---|
| 50 | " ",
|
---|
| 51 | " ",
|
---|
| 52 | " ",
|
---|
| 53 | " ",
|
---|
| 54 | " ",
|
---|
| 55 | " .............. ",
|
---|
| 56 | " .............. ",
|
---|
| 57 | " .............. ",
|
---|
| 58 | " ",
|
---|
| 59 | " ",
|
---|
| 60 | " ",
|
---|
| 61 | " ",
|
---|
| 62 | " ",
|
---|
| 63 | " ",
|
---|
| 64 | " "};
|
---|
| 65 |
|
---|
[4879] | 66 | // Constructor
|
---|
| 67 | ////////////////////////////////////////////////////////////////////////////////
|
---|
[4882] | 68 | t_uniLine::t_uniLine(const QString& fldMask, const t_keyword* keyword,
|
---|
| 69 | QWidget* parent) : QTableWidget(parent) {
|
---|
[4881] | 70 |
|
---|
[4883] | 71 | static const QPixmap plusXPM(plus_xpm);
|
---|
| 72 | static const QPixmap minusXPM(minus_xpm);
|
---|
| 73 | static const QIcon plusIcon(plusXPM);
|
---|
| 74 | static const QIcon minusIcon(minusXPM);
|
---|
| 75 |
|
---|
[4882] | 76 | _keyword = keyword;
|
---|
| 77 | const QStringList& values = _keyword->values();
|
---|
| 78 |
|
---|
[4881] | 79 | setRowCount(values.size());
|
---|
[4882] | 80 |
|
---|
| 81 | QStringList labels = fldMask.split(QRegExp("\\s+"), QString::SkipEmptyParts);
|
---|
| 82 | if (labels.size() > 0) {
|
---|
| 83 | setColumnCount(labels.size() + 2);
|
---|
| 84 | labels << "" << "";
|
---|
| 85 | setHorizontalHeaderLabels(labels);
|
---|
| 86 | }
|
---|
[4881] | 87 |
|
---|
| 88 | for (int iRow = 0; iRow < values.size(); iRow++) {
|
---|
| 89 | QStringList txt = values.at(iRow).split(QRegExp("\"\\s*\""));
|
---|
[4882] | 90 | if (labels.size() == 0 && iRow == 0) {
|
---|
| 91 | setColumnCount(txt.size() + 2);
|
---|
[4881] | 92 | }
|
---|
| 93 | for (int iCol = 0; iCol < txt.size(); iCol++) {
|
---|
| 94 | setItem(iRow, iCol, new QTableWidgetItem(txt.at(iCol).trimmed()));
|
---|
| 95 | }
|
---|
[4883] | 96 | setItem(iRow, columnCount()-2, new QTableWidgetItem(plusIcon, QString()));
|
---|
| 97 | setItem(iRow, columnCount()-1, new QTableWidgetItem(minusIcon, QString()));
|
---|
[4881] | 98 | }
|
---|
[4884] | 99 | connect(this, SIGNAL(itemClicked(QTableWidgetItem*)),
|
---|
| 100 | this, SLOT(slotItemClicked(QTableWidgetItem*)));
|
---|
[4879] | 101 | }
|
---|
| 102 |
|
---|
| 103 | // Destructor
|
---|
| 104 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 105 | t_uniLine::~t_uniLine() {
|
---|
| 106 | }
|
---|
| 107 |
|
---|
[4884] | 108 | // Add/Remove Line
|
---|
| 109 | ////////////////////////////////////////////////////////////////////////////////
|
---|
| 110 | void t_uniLine::slotItemClicked(QTableWidgetItem* item) {
|
---|
[4885] | 111 |
|
---|
| 112 | static const QPixmap plusXPM(plus_xpm);
|
---|
| 113 | static const QPixmap minusXPM(minus_xpm);
|
---|
| 114 | static const QIcon plusIcon(plusXPM);
|
---|
| 115 | static const QIcon minusIcon(minusXPM);
|
---|
| 116 |
|
---|
[4884] | 117 | int iCol = item->column();
|
---|
| 118 | if (iCol == columnCount()-2) {
|
---|
[4885] | 119 | int iRow = item->row() + 1;
|
---|
| 120 | insertRow(iRow);
|
---|
| 121 | setItem(iRow, columnCount()-2, new QTableWidgetItem(plusIcon, QString()));
|
---|
| 122 | setItem(iRow, columnCount()-1, new QTableWidgetItem(minusIcon, QString()));
|
---|
[4884] | 123 | }
|
---|
| 124 | else if (iCol == columnCount()-1) {
|
---|
| 125 | removeRow(item->row());
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 |
|
---|