Changeset View
Changeset View
Standalone View
Standalone View
dialogs/imagelib/kpDocumentMetaInfoDialog.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 111 | kpDocumentMetaInfoDialog::kpDocumentMetaInfoDialog ( | |||
---|---|---|---|---|---|
114 | 114 | | |||
115 | : QDialog (parent), | 115 | : QDialog (parent), | ||
116 | d (new kpDocumentMetaInfoDialogPrivate ()) | 116 | d (new kpDocumentMetaInfoDialogPrivate ()) | ||
117 | { | 117 | { | ||
118 | d->originalMetaInfoPtr = docMetaInfo; | 118 | d->originalMetaInfoPtr = docMetaInfo; | ||
119 | 119 | | |||
120 | 120 | | |||
121 | setWindowTitle (i18nc ("@title:window", "Document Properties")); | 121 | setWindowTitle (i18nc ("@title:window", "Document Properties")); | ||
122 | QDialogButtonBox * buttons = new QDialogButtonBox (QDialogButtonBox::Ok | | 122 | auto * buttons = new QDialogButtonBox (QDialogButtonBox::Ok | | ||
123 | QDialogButtonBox::Cancel, this); | 123 | QDialogButtonBox::Cancel, this); | ||
124 | 124 | | |||
125 | connect (buttons, &QDialogButtonBox::accepted, this, &kpDocumentMetaInfoDialog::accept); | 125 | connect (buttons, &QDialogButtonBox::accepted, this, &kpDocumentMetaInfoDialog::accept); | ||
126 | connect (buttons, &QDialogButtonBox::rejected, this, &kpDocumentMetaInfoDialog::reject); | 126 | connect (buttons, &QDialogButtonBox::rejected, this, &kpDocumentMetaInfoDialog::reject); | ||
127 | 127 | | |||
128 | QWidget *baseWidget = new QWidget (this); | 128 | auto *baseWidget = new QWidget (this); | ||
129 | 129 | | |||
130 | QVBoxLayout *dialogLayout = new QVBoxLayout (this); | 130 | auto *dialogLayout = new QVBoxLayout (this); | ||
131 | dialogLayout->addWidget (baseWidget); | 131 | dialogLayout->addWidget (baseWidget); | ||
132 | dialogLayout->addWidget (buttons); | 132 | dialogLayout->addWidget (buttons); | ||
133 | 133 | | |||
134 | 134 | | |||
135 | // | 135 | // | ||
136 | // DPI Group Box | 136 | // DPI Group Box | ||
137 | // | 137 | // | ||
138 | 138 | | |||
139 | Q_ASSERT (::DpiInputMin < ::DpiInputMax); | 139 | Q_ASSERT (::DpiInputMin < ::DpiInputMax); | ||
140 | 140 | | |||
141 | QGroupBox *dpiGroupBox = new QGroupBox(i18n("Dots &Per Inch (DPI)"), baseWidget); | 141 | auto *dpiGroupBox = new QGroupBox(i18n("Dots &Per Inch (DPI)"), baseWidget); | ||
142 | 142 | | |||
143 | d->horizDpiInput = new QDoubleSpinBox(dpiGroupBox); | 143 | d->horizDpiInput = new QDoubleSpinBox(dpiGroupBox); | ||
144 | d->horizDpiInput->setRange(::DpiInputMin, ::DpiInputMax); | 144 | d->horizDpiInput->setRange(::DpiInputMin, ::DpiInputMax); | ||
145 | d->horizDpiInput->setValue(0.0); | 145 | d->horizDpiInput->setValue(0.0); | ||
146 | d->horizDpiInput->setSingleStep(::DpiInputStep); | 146 | d->horizDpiInput->setSingleStep(::DpiInputStep); | ||
147 | d->horizDpiInput->setDecimals(::DpiPrecision); | 147 | d->horizDpiInput->setDecimals(::DpiPrecision); | ||
148 | d->horizDpiInput->setSpecialValueText(i18n("Unspecified")); | 148 | d->horizDpiInput->setSpecialValueText(i18n("Unspecified")); | ||
149 | 149 | | |||
150 | QLabel *dpiXLabel = new QLabel ( | 150 | auto *dpiXLabel = new QLabel ( | ||
151 | i18nc ("Horizontal DPI 'x' Vertical DPI", " x "), dpiGroupBox); | 151 | i18nc ("Horizontal DPI 'x' Vertical DPI", " x "), dpiGroupBox); | ||
152 | dpiXLabel->setAlignment (Qt::AlignCenter); | 152 | dpiXLabel->setAlignment (Qt::AlignCenter); | ||
153 | 153 | | |||
154 | d->vertDpiInput = new QDoubleSpinBox(dpiGroupBox); | 154 | d->vertDpiInput = new QDoubleSpinBox(dpiGroupBox); | ||
155 | d->vertDpiInput->setRange(::DpiInputMin, ::DpiInputMax); | 155 | d->vertDpiInput->setRange(::DpiInputMin, ::DpiInputMax); | ||
156 | d->vertDpiInput->setValue(0.0); | 156 | d->vertDpiInput->setValue(0.0); | ||
157 | d->vertDpiInput->setSingleStep(::DpiInputStep); | 157 | d->vertDpiInput->setSingleStep(::DpiInputStep); | ||
158 | d->vertDpiInput->setDecimals(::DpiPrecision); | 158 | d->vertDpiInput->setDecimals(::DpiPrecision); | ||
159 | d->vertDpiInput->setSpecialValueText(i18n("Unspecified")); | 159 | d->vertDpiInput->setSpecialValueText(i18n("Unspecified")); | ||
160 | 160 | | |||
161 | 161 | | |||
162 | QGridLayout *dpiLay = new QGridLayout(dpiGroupBox); | 162 | auto *dpiLay = new QGridLayout(dpiGroupBox); | ||
163 | 163 | | |||
164 | dpiLay->addWidget(new QLabel(i18n("Horizontal:")), 0, 0, Qt::AlignHCenter); | 164 | dpiLay->addWidget(new QLabel(i18n("Horizontal:")), 0, 0, Qt::AlignHCenter); | ||
165 | dpiLay->addWidget(d->horizDpiInput, 1, 0); | 165 | dpiLay->addWidget(d->horizDpiInput, 1, 0); | ||
166 | dpiLay->addWidget(dpiXLabel, 0, 1); | 166 | dpiLay->addWidget(dpiXLabel, 0, 1); | ||
167 | dpiLay->addWidget(new QLabel(i18n("Vertical:")), 0, 2, Qt::AlignHCenter); | 167 | dpiLay->addWidget(new QLabel(i18n("Vertical:")), 0, 2, Qt::AlignHCenter); | ||
168 | dpiLay->addWidget(d->vertDpiInput, 1, 2); | 168 | dpiLay->addWidget(d->vertDpiInput, 1, 2); | ||
169 | 169 | | |||
170 | dpiLay->setRowStretch(2, 1); | 170 | dpiLay->setRowStretch(2, 1); | ||
Show All 26 Lines | 174 | i18n ( | |||
197 | "</qt>" | 197 | "</qt>" | ||
198 | )); | 198 | )); | ||
199 | 199 | | |||
200 | 200 | | |||
201 | // | 201 | // | ||
202 | // Offset Group Box | 202 | // Offset Group Box | ||
203 | // | 203 | // | ||
204 | 204 | | |||
205 | QGroupBox *offsetGroupBox = new QGroupBox(i18n ("O&ffset"), baseWidget); | 205 | auto *offsetGroupBox = new QGroupBox(i18n ("O&ffset"), baseWidget); | ||
206 | 206 | | |||
207 | d->horizOffsetInput = new QSpinBox; | 207 | d->horizOffsetInput = new QSpinBox; | ||
208 | d->horizOffsetInput->setRange(kpDocumentMetaInfo::MinOffset, kpDocumentMetaInfo::MaxOffset); | 208 | d->horizOffsetInput->setRange(kpDocumentMetaInfo::MinOffset, kpDocumentMetaInfo::MaxOffset); | ||
209 | 209 | | |||
210 | d->vertOffsetInput = new QSpinBox; | 210 | d->vertOffsetInput = new QSpinBox; | ||
211 | d->vertOffsetInput->setRange(kpDocumentMetaInfo::MinOffset, kpDocumentMetaInfo::MaxOffset); | 211 | d->vertOffsetInput->setRange(kpDocumentMetaInfo::MinOffset, kpDocumentMetaInfo::MaxOffset); | ||
212 | 212 | | |||
213 | QGridLayout *offsetLay = new QGridLayout(offsetGroupBox); | 213 | auto *offsetLay = new QGridLayout(offsetGroupBox); | ||
214 | 214 | | |||
215 | offsetLay->addWidget(new QLabel(i18n("Horizontal:")), 0, 0, Qt::AlignHCenter); | 215 | offsetLay->addWidget(new QLabel(i18n("Horizontal:")), 0, 0, Qt::AlignHCenter); | ||
216 | offsetLay->addWidget(d->horizOffsetInput, 1, 0); | 216 | offsetLay->addWidget(d->horizOffsetInput, 1, 0); | ||
217 | offsetLay->addWidget(new QLabel(i18n("Vertical:")), 0, 1, Qt::AlignHCenter); | 217 | offsetLay->addWidget(new QLabel(i18n("Vertical:")), 0, 1, Qt::AlignHCenter); | ||
218 | offsetLay->addWidget(d->vertOffsetInput, 1, 1); | 218 | offsetLay->addWidget(d->vertOffsetInput, 1, 1); | ||
219 | 219 | | |||
220 | offsetLay->setRowStretch (2, 1); | 220 | offsetLay->setRowStretch (2, 1); | ||
221 | 221 | | |||
Show All 11 Lines | 223 | offsetGroupBox->setWhatsThis ( | |||
233 | )); | 233 | )); | ||
234 | 234 | | |||
235 | 235 | | |||
236 | // | 236 | // | ||
237 | // Fields Group Box | 237 | // Fields Group Box | ||
238 | // | 238 | // | ||
239 | 239 | | |||
240 | 240 | | |||
241 | QGroupBox *fieldsGroupBox = new QGroupBox (i18n ("&Text Fields"), | 241 | auto *fieldsGroupBox = new QGroupBox (i18n ("&Text Fields"), | ||
242 | baseWidget); | 242 | baseWidget); | ||
243 | 243 | | |||
244 | d->fieldsTableWidget = new QTableWidget (fieldsGroupBox); | 244 | d->fieldsTableWidget = new QTableWidget (fieldsGroupBox); | ||
245 | d->fieldsTableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers); | 245 | d->fieldsTableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers); | ||
246 | 246 | | |||
247 | connect (d->fieldsTableWidget, &QTableWidget::currentCellChanged, | 247 | connect (d->fieldsTableWidget, &QTableWidget::currentCellChanged, | ||
248 | this, &kpDocumentMetaInfoDialog::slotFieldsCurrentCellChanged); | 248 | this, &kpDocumentMetaInfoDialog::slotFieldsCurrentCellChanged); | ||
249 | 249 | | |||
Show All 10 Lines | |||||
260 | connect (d->fieldsDeleteRowButton, &QPushButton::clicked, | 260 | connect (d->fieldsDeleteRowButton, &QPushButton::clicked, | ||
261 | this, &kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked); | 261 | this, &kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked); | ||
262 | 262 | | |||
263 | d->fieldsResetButton = new QPushButton (i18n ("&Reset"), | 263 | d->fieldsResetButton = new QPushButton (i18n ("&Reset"), | ||
264 | fieldsGroupBox); | 264 | fieldsGroupBox); | ||
265 | connect (d->fieldsResetButton, &QPushButton::clicked, | 265 | connect (d->fieldsResetButton, &QPushButton::clicked, | ||
266 | this, &kpDocumentMetaInfoDialog::setUIToOriginalMetaInfo); | 266 | this, &kpDocumentMetaInfoDialog::setUIToOriginalMetaInfo); | ||
267 | 267 | | |||
268 | QHBoxLayout *fieldsButtonsLayout = new QHBoxLayout (); | 268 | auto *fieldsButtonsLayout = new QHBoxLayout (); | ||
269 | fieldsButtonsLayout->addWidget (d->fieldsAddRowButton); | 269 | fieldsButtonsLayout->addWidget (d->fieldsAddRowButton); | ||
270 | fieldsButtonsLayout->addWidget (d->fieldsDeleteRowButton); | 270 | fieldsButtonsLayout->addWidget (d->fieldsDeleteRowButton); | ||
271 | fieldsButtonsLayout->addStretch (); | 271 | fieldsButtonsLayout->addStretch (); | ||
272 | fieldsButtonsLayout->addWidget (d->fieldsResetButton); | 272 | fieldsButtonsLayout->addWidget (d->fieldsResetButton); | ||
273 | 273 | | |||
274 | QVBoxLayout *fieldsLayout = new QVBoxLayout (fieldsGroupBox); | 274 | auto *fieldsLayout = new QVBoxLayout (fieldsGroupBox); | ||
275 | 275 | | |||
276 | fieldsLayout->addWidget (d->fieldsTableWidget); | 276 | fieldsLayout->addWidget (d->fieldsTableWidget); | ||
277 | fieldsLayout->addLayout (fieldsButtonsLayout); | 277 | fieldsLayout->addLayout (fieldsButtonsLayout); | ||
278 | 278 | | |||
279 | 279 | | |||
280 | fieldsGroupBox->setWhatsThis ( | 280 | fieldsGroupBox->setWhatsThis ( | ||
281 | i18n ( | 281 | i18n ( | ||
282 | "<qt>" | 282 | "<qt>" | ||
283 | "<p><b>Text Fields</b> provide extra information about the image." | 283 | "<p><b>Text Fields</b> provide extra information about the image." | ||
284 | " This is probably a comment area that you can freely write any text in.</p>" | 284 | " This is probably a comment area that you can freely write any text in.</p>" | ||
285 | 285 | | |||
286 | "<p>However, this is format-specific so the fields could theoretically be" | 286 | "<p>However, this is format-specific so the fields could theoretically be" | ||
287 | " computer-interpreted data - that you should not modify -" | 287 | " computer-interpreted data - that you should not modify -" | ||
288 | " but this is unlikely.</p>" | 288 | " but this is unlikely.</p>" | ||
289 | 289 | | |||
290 | "<p>Not all image formats support <b>Text Fields</b>. If the format" | 290 | "<p>Not all image formats support <b>Text Fields</b>. If the format" | ||
291 | " you save in does not support them, they will not be saved.</p>" | 291 | " you save in does not support them, they will not be saved.</p>" | ||
292 | "</qt>" | 292 | "</qt>" | ||
293 | )); | 293 | )); | ||
294 | 294 | | |||
295 | 295 | | |||
296 | // | 296 | // | ||
297 | // Global Layout | 297 | // Global Layout | ||
298 | // | 298 | // | ||
299 | 299 | auto *baseLayout = new QGridLayout (baseWidget); | |||
300 | | ||||
301 | QGridLayout *baseLayout = new QGridLayout (baseWidget); | | |||
302 | baseLayout->setContentsMargins(0, 0, 0, 0); | 300 | baseLayout->setContentsMargins(0, 0, 0, 0); | ||
303 | 301 | | |||
304 | // Col 0 | 302 | // Col 0 | ||
305 | baseLayout->addWidget (dpiGroupBox, 0, 0); | 303 | baseLayout->addWidget (dpiGroupBox, 0, 0); | ||
306 | baseLayout->addWidget (offsetGroupBox, 1, 0); | 304 | baseLayout->addWidget (offsetGroupBox, 1, 0); | ||
307 | 305 | | |||
308 | // Col 1 | 306 | // Col 1 | ||
309 | baseLayout->addWidget (fieldsGroupBox, 0, 1, 2/*row span*/, 1/*col span*/); | 307 | baseLayout->addWidget (fieldsGroupBox, 0, 1, 2/*row span*/, 1/*col span*/); | ||
310 | baseLayout->setColumnStretch (1, 1/*stretch*/); | 308 | baseLayout->setColumnStretch (1, 1/*stretch*/); | ||
311 | 309 | | |||
312 | 310 | | |||
313 | // | 311 | // | ||
314 | // Remaining UI Setup | 312 | // Remaining UI Setup | ||
315 | // | 313 | // | ||
316 | 314 | | |||
317 | 315 | | |||
318 | setUIToOriginalMetaInfo (); | 316 | setUIToOriginalMetaInfo (); | ||
319 | 317 | | |||
320 | 318 | | |||
321 | if (::LastWidth > 0 && ::LastHeight > 0) | 319 | if (::LastWidth > 0 && ::LastHeight > 0) { | ||
322 | resize (::LastWidth, ::LastHeight); | 320 | resize (::LastWidth, ::LastHeight); | ||
323 | } | 321 | } | ||
322 | } | ||||
324 | 323 | | |||
325 | //--------------------------------------------------------------------- | 324 | //--------------------------------------------------------------------- | ||
326 | 325 | | |||
327 | kpDocumentMetaInfoDialog::~kpDocumentMetaInfoDialog () | 326 | kpDocumentMetaInfoDialog::~kpDocumentMetaInfoDialog () | ||
328 | { | 327 | { | ||
329 | ::LastWidth = width (); | 328 | ::LastWidth = width (); | ||
330 | ::LastHeight = height (); | 329 | ::LastHeight = height (); | ||
331 | 330 | | |||
Show All 37 Lines | 365 | { | |||
369 | d->fieldsTableWidget->setRowCount (d->originalMetaInfoPtr->textKeys ().size ()); | 368 | d->fieldsTableWidget->setRowCount (d->originalMetaInfoPtr->textKeys ().size ()); | ||
370 | d->fieldsTableWidget->setColumnCount (2); | 369 | d->fieldsTableWidget->setColumnCount (2); | ||
371 | 370 | | |||
372 | QStringList fieldsHeader; | 371 | QStringList fieldsHeader; | ||
373 | fieldsHeader << i18n ("Key") << i18n ("Value"); | 372 | fieldsHeader << i18n ("Key") << i18n ("Value"); | ||
374 | d->fieldsTableWidget->setHorizontalHeaderLabels (fieldsHeader); | 373 | d->fieldsTableWidget->setHorizontalHeaderLabels (fieldsHeader); | ||
375 | 374 | | |||
376 | int row = 0; | 375 | int row = 0; | ||
377 | foreach (const QString &key, d->originalMetaInfoPtr->textKeys ()) | 376 | for (const auto &key : d->originalMetaInfoPtr->textKeys ()) | ||
378 | { | 377 | { | ||
379 | d->fieldsTableWidget->setItem (row, 0/*1st col*/, | 378 | d->fieldsTableWidget->setItem (row, 0/*1st col*/, | ||
380 | new QTableWidgetItem (key)); | 379 | new QTableWidgetItem (key)); | ||
381 | d->fieldsTableWidget->setItem (row, 1/*2nd col*/, | 380 | d->fieldsTableWidget->setItem (row, 1/*2nd col*/, | ||
382 | new QTableWidgetItem (d->originalMetaInfoPtr->text (key))); | 381 | new QTableWidgetItem (d->originalMetaInfoPtr->text (key))); | ||
383 | 382 | | |||
384 | row++; | 383 | row++; | ||
385 | } | 384 | } | ||
Show All 34 Lines | 418 | { | |||
420 | // No errors to start with. | 419 | // No errors to start with. | ||
421 | *errorMessage = QString (); | 420 | *errorMessage = QString (); | ||
422 | } | 421 | } | ||
423 | 422 | | |||
424 | 423 | | |||
425 | kpDocumentMetaInfo ret; | 424 | kpDocumentMetaInfo ret; | ||
426 | 425 | | |||
427 | 426 | | |||
428 | if (d->horizDpiInput->value () < ::DpiLegalMin) | 427 | if (d->horizDpiInput->value () < ::DpiLegalMin) { | ||
429 | ret.setDotsPerMeterX (0/*unspecified*/); | 428 | ret.setDotsPerMeterX (0/*unspecified*/); | ||
430 | else | 429 | } | ||
430 | else { | ||||
431 | ret.setDotsPerMeterX (qRound (d->horizDpiInput->value () * KP_INCHES_PER_METER)); | 431 | ret.setDotsPerMeterX (qRound (d->horizDpiInput->value () * KP_INCHES_PER_METER)); | ||
432 | } | ||||
432 | 433 | | |||
433 | if (d->vertDpiInput->value () < ::DpiLegalMin) | 434 | if (d->vertDpiInput->value () < ::DpiLegalMin) { | ||
434 | ret.setDotsPerMeterY (0/*unspecified*/); | 435 | ret.setDotsPerMeterY (0/*unspecified*/); | ||
435 | else | 436 | } | ||
437 | else { | ||||
436 | ret.setDotsPerMeterY (qRound (d->vertDpiInput->value () * KP_INCHES_PER_METER)); | 438 | ret.setDotsPerMeterY (qRound (d->vertDpiInput->value () * KP_INCHES_PER_METER)); | ||
439 | } | ||||
437 | 440 | | |||
438 | 441 | | |||
439 | ret.setOffset (QPoint (d->horizOffsetInput->value (), | 442 | ret.setOffset (QPoint (d->horizOffsetInput->value (), | ||
440 | d->vertOffsetInput->value ())); | 443 | d->vertOffsetInput->value ())); | ||
441 | 444 | | |||
442 | 445 | | |||
443 | for (int r = 0; r < d->fieldsTableWidget->rowCount (); r++) | 446 | for (int r = 0; r < d->fieldsTableWidget->rowCount (); r++) | ||
444 | { | 447 | { | ||
445 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | 448 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | ||
446 | const QString value = d->fieldsTableWidget->item (r, 1)->text (); | 449 | const QString value = d->fieldsTableWidget->item (r, 1)->text (); | ||
447 | 450 | | |||
448 | // Empty key? | 451 | // Empty key? | ||
449 | if (key.isEmpty ()) | 452 | if (key.isEmpty ()) | ||
450 | { | 453 | { | ||
451 | // Empty value too? | 454 | // Empty value too? | ||
452 | if (value.isEmpty ()) | 455 | if (value.isEmpty ()) | ||
453 | { | 456 | { | ||
454 | // Ignore empty row. | 457 | // Ignore empty row. | ||
455 | continue; | 458 | continue; | ||
456 | } | 459 | } | ||
457 | // Value without a key? | 460 | // Value without a key? | ||
458 | else | 461 | | ||
459 | { | 462 | | ||
460 | if (errorMessage) | 463 | if (errorMessage) | ||
461 | { | 464 | { | ||
462 | *errorMessage = | 465 | *errorMessage = | ||
463 | ki18n ("The text value \"%1\" on line %2 requires a key.") | 466 | ki18n ("The text value \"%1\" on line %2 requires a key.") | ||
464 | .subs (value).subs (r + 1/*count from 1*/).toString (); | 467 | .subs (value).subs (r + 1/*count from 1*/).toString (); | ||
465 | 468 | | |||
466 | // Print only 1 error message per method invocation. | 469 | // Print only 1 error message per method invocation. | ||
467 | errorMessage = nullptr; | 470 | errorMessage = nullptr; | ||
468 | } | 471 | } | ||
469 | 472 | | |||
470 | // Ignore. | 473 | // Ignore. | ||
471 | continue; | 474 | continue; | ||
472 | } | 475 | | ||
473 | } | 476 | } | ||
474 | 477 | | |||
475 | // Duplicate key? | 478 | // Duplicate key? | ||
476 | if (ret.textKeys ().contains (key)) | 479 | if (ret.textKeys ().contains (key)) | ||
477 | { | 480 | { | ||
478 | if (errorMessage) | 481 | if (errorMessage) | ||
479 | { | 482 | { | ||
480 | int q; | 483 | int q; | ||
481 | for (q = 0; q < r; q++) | 484 | for (q = 0; q < r; q++) | ||
482 | { | 485 | { | ||
483 | if (d->fieldsTableWidget->item (q, 0)->text () == key) | 486 | if (d->fieldsTableWidget->item (q, 0)->text () == key) { | ||
484 | break; | 487 | break; | ||
485 | } | 488 | } | ||
489 | } | ||||
486 | Q_ASSERT (q != r); | 490 | Q_ASSERT (q != r); | ||
487 | 491 | | |||
488 | *errorMessage = | 492 | *errorMessage = | ||
489 | ki18n ("All text keys must be unique. The text key \"%1\"" | 493 | ki18n ("All text keys must be unique. The text key \"%1\"" | ||
490 | " on lines %2 and %3 are identical.") | 494 | " on lines %2 and %3 are identical.") | ||
491 | .subs (key) | 495 | .subs (key) | ||
492 | .subs (q + 1/*count from 1*/) | 496 | .subs (q + 1/*count from 1*/) | ||
493 | .subs (r + 1/*count from 1*/) | 497 | .subs (r + 1/*count from 1*/) | ||
Show All 15 Lines | |||||
509 | return ret; | 513 | return ret; | ||
510 | } | 514 | } | ||
511 | 515 | | |||
512 | 516 | | |||
513 | // private | 517 | // private | ||
514 | void kpDocumentMetaInfoDialog::fieldsUpdateVerticalHeader () | 518 | void kpDocumentMetaInfoDialog::fieldsUpdateVerticalHeader () | ||
515 | { | 519 | { | ||
516 | QStringList vertLabels; | 520 | QStringList vertLabels; | ||
517 | for (int r = 1; r <= d->fieldsTableWidget->rowCount (); r++) | 521 | for (int r = 1; r <= d->fieldsTableWidget->rowCount (); r++) { | ||
518 | vertLabels << QString::number (r); | 522 | vertLabels << QString::number (r); | ||
523 | } | ||||
519 | 524 | | |||
520 | d->fieldsTableWidget->setVerticalHeaderLabels (vertLabels); | 525 | d->fieldsTableWidget->setVerticalHeaderLabels (vertLabels); | ||
521 | } | 526 | } | ||
522 | 527 | | |||
523 | 528 | | |||
524 | // private | 529 | // private | ||
525 | void kpDocumentMetaInfoDialog::fieldsAddEmptyRow (int atRow) | 530 | void kpDocumentMetaInfoDialog::fieldsAddEmptyRow (int atRow) | ||
526 | { | 531 | { | ||
Show All 30 Lines | 558 | { | |||
557 | return (row >= 0 && row < d->fieldsTableWidget->rowCount () - 1); | 562 | return (row >= 0 && row < d->fieldsTableWidget->rowCount () - 1); | ||
558 | } | 563 | } | ||
559 | 564 | | |||
560 | // private | 565 | // private | ||
561 | void kpDocumentMetaInfoDialog::fieldsDeleteRow (int r) | 566 | void kpDocumentMetaInfoDialog::fieldsDeleteRow (int r) | ||
562 | { | 567 | { | ||
563 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::fieldsDeleteRow(" | 568 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::fieldsDeleteRow(" | ||
564 | << "row=" << r << ")" | 569 | << "row=" << r << ")" | ||
565 | << " currentRow=" << d->fieldsTableWidget->currentRow () << endl; | 570 | << " currentRow=" << d->fieldsTableWidget->currentRow (); | ||
566 | 571 | | |||
567 | Q_ASSERT (isFieldsRowDeleteable (r)); | 572 | Q_ASSERT (isFieldsRowDeleteable (r)); | ||
568 | 573 | | |||
569 | if (r == d->fieldsTableWidget->currentRow ()) | 574 | if (r == d->fieldsTableWidget->currentRow ()) | ||
570 | { | 575 | { | ||
571 | // Assertion follows from previous assertion. | 576 | // Assertion follows from previous assertion. | ||
572 | const int newRow = r + 1; | 577 | const int newRow = r + 1; | ||
573 | qCDebug(kpLogDialogs) << "\tnewRow=" << newRow; | 578 | qCDebug(kpLogDialogs) << "\tnewRow=" << newRow; | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
628 | } | 633 | } | ||
629 | 634 | | |||
630 | //--------------------------------------------------------------------- | 635 | //--------------------------------------------------------------------- | ||
631 | // private slot | 636 | // private slot | ||
632 | 637 | | |||
633 | void kpDocumentMetaInfoDialog::slotFieldsItemChanged (QTableWidgetItem *it) | 638 | void kpDocumentMetaInfoDialog::slotFieldsItemChanged (QTableWidgetItem *it) | ||
634 | { | 639 | { | ||
635 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsItemChanged(" | 640 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsItemChanged(" | ||
636 | << "item=" << it << ") rows=" << d->fieldsTableWidget->rowCount () | 641 | << "item=" << it << ") rows=" << d->fieldsTableWidget->rowCount (); | ||
637 | << endl; | | |||
638 | 642 | | |||
639 | const int r = d->fieldsTableWidget->row (it); | 643 | const int r = d->fieldsTableWidget->row (it); | ||
640 | qCDebug(kpLogDialogs) << "\tr=" << r; | 644 | qCDebug(kpLogDialogs) << "\tr=" << r; | ||
641 | Q_ASSERT (r >= 0 && r < d->fieldsTableWidget->rowCount ()); | 645 | Q_ASSERT (r >= 0 && r < d->fieldsTableWidget->rowCount ()); | ||
642 | 646 | | |||
643 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | 647 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | ||
644 | qCDebug(kpLogDialogs) << " key='" << key << "'"; | 648 | qCDebug(kpLogDialogs) << " key='" << key << "'"; | ||
645 | 649 | | |||
Show All 17 Lines | |||||
663 | } | 667 | } | ||
664 | } | 668 | } | ||
665 | 669 | | |||
666 | //--------------------------------------------------------------------- | 670 | //--------------------------------------------------------------------- | ||
667 | // private slot | 671 | // private slot | ||
668 | 672 | | |||
669 | void kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked () | 673 | void kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked () | ||
670 | { | 674 | { | ||
671 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked()" | 675 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked()"; | ||
672 | << endl; | | |||
673 | 676 | | |||
674 | const int r = d->fieldsTableWidget->currentRow (); | 677 | const int r = d->fieldsTableWidget->currentRow (); | ||
675 | qCDebug(kpLogDialogs) << "\tr=" << r; | 678 | qCDebug(kpLogDialogs) << "\tr=" << r; | ||
676 | 679 | | |||
677 | // (if no row is selected, r = -1) | 680 | // (if no row is selected, r = -1) | ||
678 | fieldsAddEmptyRow (r + 1); | 681 | fieldsAddEmptyRow (r + 1); | ||
679 | 682 | | |||
680 | // Edit the key of this new row (column 0). | 683 | // Edit the key of this new row (column 0). | ||
681 | // No one edits the value first (column 1). | 684 | // No one edits the value first (column 1). | ||
682 | editCell ((r + 1)/*row*/, 0/*col*/); | 685 | editCell ((r + 1)/*row*/, 0/*col*/); | ||
683 | } | 686 | } | ||
684 | 687 | | |||
685 | //--------------------------------------------------------------------- | 688 | //--------------------------------------------------------------------- | ||
686 | 689 | | |||
687 | // private slot | 690 | // private slot | ||
688 | void kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked () | 691 | void kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked () | ||
689 | { | 692 | { | ||
690 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked()" | 693 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked()"; | ||
691 | << endl; | | |||
692 | 694 | | |||
693 | const int r = d->fieldsTableWidget->currentRow (); | 695 | const int r = d->fieldsTableWidget->currentRow (); | ||
694 | qCDebug(kpLogDialogs) << "\tr=" << r; | 696 | qCDebug(kpLogDialogs) << "\tr=" << r; | ||
695 | 697 | | |||
696 | Q_ASSERT (isFieldsRowDeleteable (r)); | 698 | Q_ASSERT (isFieldsRowDeleteable (r)); | ||
697 | fieldsDeleteRow (r); | 699 | fieldsDeleteRow (r); | ||
698 | } | 700 | } | ||
699 | 701 | | |||
Show All 15 Lines |