source: ntrip/trunk/GnssCenter/inpedit/uniline.cpp@ 10460

Last change on this file since 10460 was 5112, checked in by mervart, 12 years ago
File size: 3.5 KB
RevLine 
[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"
19
20using namespace std;
[5000]21using namespace GnssCenter;
[4879]22
[4883]23static const char* plus_xpm[] = {
24"16 16 2 1",
25" c #FFFFFFFFFFFF",
26". c #00000000FFFF",
27" ",
28" ... ",
29" ... ",
30" ... ",
31" ... ",
32" ... ",
33" .............. ",
34" .............. ",
35" .............. ",
36" ... ",
37" ... ",
38" ... ",
39" ... ",
40" ... ",
41" ",
42" "};
43
44static const char* minus_xpm[] = {
45"16 16 2 1",
46" c #FFFFFFFFFFFF",
47". c #00000000FFFF",
48" ",
49" ",
50" ",
51" ",
52" ",
53" ",
54" .............. ",
55" .............. ",
56" .............. ",
57" ",
58" ",
59" ",
60" ",
61" ",
62" ",
63" "};
64
[4879]65// Constructor
66////////////////////////////////////////////////////////////////////////////////
[5107]67t_uniLine::t_uniLine(const QString& fldMask, const QStringList& values,
[4882]68 QWidget* parent) : QTableWidget(parent) {
[4881]69
[4883]70 static const QPixmap plusXPM(plus_xpm);
71 static const QPixmap minusXPM(minus_xpm);
72 static const QIcon plusIcon(plusXPM);
73 static const QIcon minusIcon(minusXPM);
74
[4881]75 setRowCount(values.size());
[4882]76
77 QStringList labels = fldMask.split(QRegExp("\\s+"), QString::SkipEmptyParts);
78 if (labels.size() > 0) {
79 setColumnCount(labels.size() + 2);
80 labels << "" << "";
81 setHorizontalHeaderLabels(labels);
82 }
[4881]83
84 for (int iRow = 0; iRow < values.size(); iRow++) {
85 QStringList txt = values.at(iRow).split(QRegExp("\"\\s*\""));
[4882]86 if (labels.size() == 0 && iRow == 0) {
87 setColumnCount(txt.size() + 2);
[4881]88 }
89 for (int iCol = 0; iCol < txt.size(); iCol++) {
90 setItem(iRow, iCol, new QTableWidgetItem(txt.at(iCol).trimmed()));
91 }
[5112]92 for (int iCol = txt.size(); iCol < columnCount()-2; iCol++) {
93 setItem(iRow, iCol, new QTableWidgetItem(""));
94 }
[4883]95 setItem(iRow, columnCount()-2, new QTableWidgetItem(plusIcon, QString()));
96 setItem(iRow, columnCount()-1, new QTableWidgetItem(minusIcon, QString()));
[4881]97 }
[4884]98 connect(this, SIGNAL(itemClicked(QTableWidgetItem*)),
99 this, SLOT(slotItemClicked(QTableWidgetItem*)));
[4879]100}
101
102// Destructor
103////////////////////////////////////////////////////////////////////////////////
104t_uniLine::~t_uniLine() {
105}
106
[4884]107// Add/Remove Line
108////////////////////////////////////////////////////////////////////////////////
109void t_uniLine::slotItemClicked(QTableWidgetItem* item) {
[4885]110
111 static const QPixmap plusXPM(plus_xpm);
112 static const QPixmap minusXPM(minus_xpm);
113 static const QIcon plusIcon(plusXPM);
114 static const QIcon minusIcon(minusXPM);
115
[4884]116 int iCol = item->column();
117 if (iCol == columnCount()-2) {
[4885]118 int iRow = item->row() + 1;
119 insertRow(iRow);
120 setItem(iRow, columnCount()-2, new QTableWidgetItem(plusIcon, QString()));
121 setItem(iRow, columnCount()-1, new QTableWidgetItem(minusIcon, QString()));
[4884]122 }
123 else if (iCol == columnCount()-1) {
124 removeRow(item->row());
125 }
126}
127
Note: See TracBrowser for help on using the repository browser.