23 #include <QtCore/QRegExp>
31 #if QT_VERSION >= 0x050000
32 # include <QtWidgets/QAction>
33 # include <QtWidgets/QBoxLayout>
34 # include <QtWidgets/QLabel>
35 # include <QtWidgets/QMenu>
36 # include <QtWidgets/QMessageBox>
37 # include <QtWidgets/QPushButton>
38 # include <QtWidgets/QShortcut>
40 # include <QtGui/QAction>
41 # include <QtGui/QBoxLayout>
42 # include <QtGui/QLabel>
43 # include <QtGui/QMenu>
44 # include <QtGui/QMessageBox>
45 # include <QtGui/QPushButton>
46 # include <QtGui/QShortcut>
62 QBoxLayout *layout =
new QVBoxLayout(
this);
68 QBrush userRecordBrushF(QBrush(QColor(30, 90, 255)));
69 QBrush operatorRecordBrushF(QBrush(QColor(214, 61, 210)));
71 QRegExp reUserComment(
"^\\w{2}>(.+)", Qt::CaseInsensitive);
72 QRegExp reOperatorComment(
"readLogFile: station ([\\w\\s-+_]{1,8}): "
73 "\\d{4}/\\d{2}/\\d{2}\\s+(.+)", Qt::CaseInsensitive);
76 QStringList headerLabels;
84 for (
int i=0; i<
history_->size(); i++)
91 item->setData(0, Qt::TextAlignmentRole, Qt::AlignRight);
92 item->setData(0, Qt::UserRole, i);
93 item->setText(1, str.sprintf(
"%3d", rec->
getVersion()));
94 item->setData(1, Qt::TextAlignmentRole, Qt::AlignRight);
95 item->setText(2, rec->
getText());
96 item->setData(2, Qt::TextAlignmentRole, Qt::AlignLeft);
97 if (reUserComment.indexIn(rec->
getText()) != -1)
99 QFont fnt=item->font(2);
101 item->setFont(2, fnt);
102 item->setForeground(2, userRecordBrushF);
104 else if (reOperatorComment.indexIn(rec->
getText()) != -1)
106 QFont fnt=item->font(2);
108 item->setFont(2, fnt);
109 item->setForeground(2, operatorRecordBrushF);
113 twHistory_->header()->resizeSections(QHeaderView::ResizeToContents);
114 #if QT_VERSION >= 0x050000
115 twHistory_->header()->setSectionResizeMode(QHeaderView::Interactive);
117 twHistory_->header()->setResizeMode(QHeaderView::Interactive);
119 twHistory_->header()->setStretchLastSection(
true);
129 QBoxLayout *hLayout =
new QHBoxLayout();
130 layout->addLayout(hLayout);
133 QLabel *label =
new QLabel(
"&Add a record:",
this);
135 label->setMinimumSize(label->sizeHint());
139 hLayout->addWidget(label);
142 QPushButton *button =
new QPushButton(
"Submit",
this);
143 button->setMinimumSize(button->sizeHint());
144 button->setDefault(
true);
145 hLayout->addWidget(button);
149 QShortcut *shCut=
new QShortcut(QKeySequence(QKeySequence::Delete),
this);
150 connect(shCut, SIGNAL(activated()),
this, SLOT(
delHistoryLine()));
158 QBrush newRecordBrush(Qt::blue);
161 if (text.simplified() !=
"")
163 int version=
history_->last()->getVersion();
169 if (0<idx && !
history_->at(idx-1)->getIsEditable())
173 item->setData(0, Qt::TextAlignmentRole, Qt::AlignRight);
174 item->setData(0, Qt::ForegroundRole, newRecordBrush);
175 item->setData(0, Qt::UserRole, idx);
177 item->setText(1, str.sprintf(
"%3d", rec->
getVersion()));
178 item->setData(1, Qt::TextAlignmentRole, Qt::AlignRight);
179 item->setData(1, Qt::ForegroundRole, newRecordBrush);
180 item->setText(2, rec->
getText());
181 item->setData(2, Qt::TextAlignmentRole, Qt::AlignLeft);
182 item->setData(2, Qt::ForegroundRole, newRecordBrush);
198 int idx=item->data(0, Qt::UserRole).toInt(&isOk);
204 if (QMessageBox::warning(
this,
"Warning",
205 "Are you sure to delete the history record?\nThe record was issued on " +
207 QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
210 ": delHistoryLine(): the history record \"" + rec->
getText() +
"\" sunk into oblivion");
215 else if (!
history_->at(idx-1)->getIsEditable())
217 if (idx<history_->size()-1)
230 it->setData(0, Qt::UserRole, idx++);
virtual QString className() const
SgGuiVlbiHistory(SgVlbiHistory *, QWidget *=0, Qt::WindowFlags=0)
virtual void write(LogLevel, quint32, const QString &, bool=false)
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
QString toString(Format format=F_Verbose) const
static SgMJD currentMJD()
bool getIsEditable() const
const SgMJD & getEpoch() const
const QString & getText() const
void setFirstRecordFromUser(const QString &)