53 #include "ui_dialogdatetimeformats.h"
61 const QStringList &userDefinedFormats, QWidget *parent)
67 m_predefined(predefinedFormats)
71 Init(predefinedFormats, userDefinedFormats);
76 const QStringList &userDefinedFormats, QWidget *parent)
82 m_predefined(predefinedFormats)
86 Init(predefinedFormats, userDefinedFormats);
100 for (
int i=0; i<
ui->listWidget->count(); ++i)
102 if (
const QListWidgetItem *lineItem =
ui->listWidget->item(i))
104 const QString format = lineItem->data(Qt::UserRole).toString();
105 if (not format.isEmpty())
107 formats.append(lineItem->data(Qt::UserRole).toString());
118 int row =
ui->listWidget->count();
119 ui->listWidget->insertItem(++row,
new QListWidgetItem(tr(
"<empty>")));
120 ui->listWidget->setCurrentRow(row);
126 ui->listWidget->blockSignals(
true);
127 if (QListWidgetItem *curLine =
ui->listWidget->currentItem())
129 if (not
m_predefined.contains(curLine->data(Qt::UserRole).toString()))
131 delete ui->listWidget->takeItem(
ui->listWidget->currentRow());
134 ui->listWidget->blockSignals(
false);
141 if (QListWidgetItem *curLine =
ui->listWidget->currentItem())
146 curLine->setText(preview);
147 curLine->setData(Qt::UserRole, text);
155 if (
ui->listWidget->count() > 0)
157 if (
const QListWidgetItem *line =
ui->listWidget->currentItem())
159 ui->lineEditFormat->blockSignals(
true);
160 ui->lineEditFormat->setText(line->data(Qt::UserRole).toString());
161 ui->lineEditFormat->blockSignals(
false);
173 ui->lineEditFormat->setClearButtonEnabled(
true);
180 ui->listWidget->setCurrentRow(0);
186 ui->listWidget->blockSignals(
true);
187 ui->listWidget->clear();
191 for (
int i=0; i<predefined.size(); ++i)
193 ui->listWidget->insertItem(++row,
AddListLine(predefined.at(i)));
196 for (
int i=0; i<userDefined.size(); ++i)
198 ui->listWidget->insertItem(++row,
AddListLine(userDefined.at(i)));
201 ui->listWidget->blockSignals(
false);
203 if (
ui->listWidget->count() > 0)
205 ui->listWidget->setCurrentRow(0);
212 const bool enabled =
ui->listWidget->count() > 0;
216 ui->lineEditFormat->blockSignals(
true);
217 ui->lineEditFormat->clear();
218 ui->lineEditFormat->blockSignals(
false);
221 ui->toolButtonAdd->setEnabled(
true);
223 ui->lineEditFormat->setEnabled(enabled);
225 const QListWidgetItem *line =
ui->listWidget->currentItem();
226 if (line !=
nullptr &&
m_predefined.contains(line->data(Qt::UserRole).toString()))
228 ui->toolButtonRemove->setEnabled(
false);
229 ui->lineEditFormat->setReadOnly(
true);
233 ui->toolButtonRemove->setEnabled(enabled);
234 ui->lineEditFormat->setReadOnly(
false);
242 QListWidgetItem *item =
new QListWidgetItem(preview);
243 item->setData(Qt::UserRole, format);