19 #include "ui_diagramcontextwidget.h" 26 connect(
ui->m_table, SIGNAL(itemChanged(QTableWidgetItem *)),
this, SLOT(
checkTableRows()));
42 for (
int i = 0 ; i <
ui->m_table-> rowCount() ; ++ i)
44 QTableWidgetItem *qtwi_name =
ui->m_table-> item(i, 0);
45 QTableWidgetItem *qtwi_value =
ui->m_table-> item(i, 1);
46 if (!qtwi_name || !qtwi_value) {
50 QString key = qtwi_name -> text();
55 QString value = qtwi_value -> text();
74 ui->m_table->setItem(i, 0,
new QTableWidgetItem(key));
75 ui->m_table->setItem(i, 1,
new QTableWidgetItem(
context[key].toString()));
88 int name_less_rows_count = 0;
89 for (
int i = 0 ; i <
ui->m_table->rowCount() ; ++ i)
91 QTableWidgetItem *qtwi_name =
ui->m_table->item(i, 0);
92 if (qtwi_name && qtwi_name -> text().isEmpty()) {
93 ++ name_less_rows_count;
97 return(name_less_rows_count);
106 ui->m_table->clearContents();
107 for (
int i = 1 ; i <
ui->m_table->rowCount() ; ++ i) {
108 ui->m_table->removeRow(i);
123 QBrush fg_brush =
ui->m_table->palette().brush(QPalette::WindowText);
125 int invalid_keys = 0;
126 for (
int i = 0 ; i <
ui->m_table->rowCount() ; ++ i)
128 QTableWidgetItem *qtwi_name =
ui->m_table->item(i, 0);
133 bool highlight =
false;
134 if (!qtwi_name -> text().isEmpty())
136 if (!re.exactMatch(qtwi_name -> text()))
142 qtwi_name -> setForeground(highlight ? Qt::red : fg_brush);
145 return(invalid_keys);
155 QString format_text =
tr(
156 "Les noms ne peuvent contenir que des lettres minuscules, des " 157 "chiffres et des tirets." 161 format_text = QString(
"<span style=\"color: red;\">%1</span>").arg(format_text);
163 ui->m_label->setText(format_text);
175 int new_idx =
ui->m_table->rowCount();
176 ui->m_table->setRowCount(new_idx + 1);
177 ui->m_table->setItem(new_idx, 0,
new QTableWidgetItem(
""));
178 ui->m_table->setItem(new_idx, 1,
new QTableWidgetItem(
""));
Ui::DiagramContextWidget * ui
void checkTableRows()
DiagramContextWidget::checkTableRows Adds a row in the additional fields table if needed...
void refreshFormatLabel()
DiagramContextWidget::refreshFormatLabel Sets the text describing the acceptable format for keys when...
bool addValue(const QString &, const QVariant &, bool show=true)
QList< QString > keys(KeyOrder=None) const
DiagramContext context() const
DiagramContextWidget::context.
int nameLessRowsCount() const
DiagramContextWidget::nameLessRowsCount.
DiagramContextWidget(QWidget *parent=nullptr)
int highlightNonAcceptableKeys()
DiagramContextWidget::highlightNonAcceptableKeys Highlight keys that would not be accepted by a Diagr...
void setContext(const DiagramContext &context)
DiagramContextWidget::setContext Load the content from into this widget.
static QString validKeyRegExp()
void clear()
DiagramContextWidget::clear Clear any values entered within this widget.