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>" | ||
Show All 10 Lines | |||||
293 | )); | 293 | )); | ||
294 | 294 | | |||
295 | 295 | | |||
296 | // | 296 | // | ||
297 | // Global Layout | 297 | // Global Layout | ||
298 | // | 298 | // | ||
299 | 299 | | |||
300 | 300 | | |||
301 | QGridLayout *baseLayout = new QGridLayout (baseWidget); | 301 | auto *baseLayout = new QGridLayout (baseWidget); | ||
302 | baseLayout->setMargin (0); | 302 | baseLayout->setMargin (0); | ||
303 | 303 | | |||
304 | // Col 0 | 304 | // Col 0 | ||
305 | baseLayout->addWidget (dpiGroupBox, 0, 0); | 305 | baseLayout->addWidget (dpiGroupBox, 0, 0); | ||
306 | baseLayout->addWidget (offsetGroupBox, 1, 0); | 306 | baseLayout->addWidget (offsetGroupBox, 1, 0); | ||
307 | 307 | | |||
308 | // Col 1 | 308 | // Col 1 | ||
309 | baseLayout->addWidget (fieldsGroupBox, 0, 1, 2/*row span*/, 1/*col span*/); | 309 | baseLayout->addWidget (fieldsGroupBox, 0, 1, 2/*row span*/, 1/*col span*/); | ||
310 | baseLayout->setColumnStretch (1, 1/*stretch*/); | 310 | baseLayout->setColumnStretch (1, 1/*stretch*/); | ||
311 | 311 | | |||
312 | 312 | | |||
313 | // | 313 | // | ||
314 | // Remaining UI Setup | 314 | // Remaining UI Setup | ||
315 | // | 315 | // | ||
316 | 316 | | |||
317 | 317 | | |||
318 | setUIToOriginalMetaInfo (); | 318 | setUIToOriginalMetaInfo (); | ||
319 | 319 | | |||
320 | 320 | | |||
321 | if (::LastWidth > 0 && ::LastHeight > 0) | 321 | if (::LastWidth > 0 && ::LastHeight > 0) { | ||
322 | resize (::LastWidth, ::LastHeight); | 322 | resize (::LastWidth, ::LastHeight); | ||
323 | } | 323 | } | ||
324 | } | ||||
324 | 325 | | |||
325 | //--------------------------------------------------------------------- | 326 | //--------------------------------------------------------------------- | ||
326 | 327 | | |||
327 | kpDocumentMetaInfoDialog::~kpDocumentMetaInfoDialog () | 328 | kpDocumentMetaInfoDialog::~kpDocumentMetaInfoDialog () | ||
328 | { | 329 | { | ||
329 | ::LastWidth = width (); | 330 | ::LastWidth = width (); | ||
330 | ::LastHeight = height (); | 331 | ::LastHeight = height (); | ||
331 | 332 | | |||
Show All 37 Lines | 367 | { | |||
369 | d->fieldsTableWidget->setRowCount (d->originalMetaInfoPtr->textKeys ().size ()); | 370 | d->fieldsTableWidget->setRowCount (d->originalMetaInfoPtr->textKeys ().size ()); | ||
370 | d->fieldsTableWidget->setColumnCount (2); | 371 | d->fieldsTableWidget->setColumnCount (2); | ||
371 | 372 | | |||
372 | QStringList fieldsHeader; | 373 | QStringList fieldsHeader; | ||
373 | fieldsHeader << i18n ("Key") << i18n ("Value"); | 374 | fieldsHeader << i18n ("Key") << i18n ("Value"); | ||
374 | d->fieldsTableWidget->setHorizontalHeaderLabels (fieldsHeader); | 375 | d->fieldsTableWidget->setHorizontalHeaderLabels (fieldsHeader); | ||
375 | 376 | | |||
376 | int row = 0; | 377 | int row = 0; | ||
377 | foreach (const QString &key, d->originalMetaInfoPtr->textKeys ()) | 378 | for (const auto &key : d->originalMetaInfoPtr->textKeys ()) | ||
378 | { | 379 | { | ||
379 | d->fieldsTableWidget->setItem (row, 0/*1st col*/, | 380 | d->fieldsTableWidget->setItem (row, 0/*1st col*/, | ||
380 | new QTableWidgetItem (key)); | 381 | new QTableWidgetItem (key)); | ||
381 | d->fieldsTableWidget->setItem (row, 1/*2nd col*/, | 382 | d->fieldsTableWidget->setItem (row, 1/*2nd col*/, | ||
382 | new QTableWidgetItem (d->originalMetaInfoPtr->text (key))); | 383 | new QTableWidgetItem (d->originalMetaInfoPtr->text (key))); | ||
383 | 384 | | |||
384 | row++; | 385 | row++; | ||
385 | } | 386 | } | ||
Show All 34 Lines | 420 | { | |||
420 | // No errors to start with. | 421 | // No errors to start with. | ||
421 | *errorMessage = QString (); | 422 | *errorMessage = QString (); | ||
422 | } | 423 | } | ||
423 | 424 | | |||
424 | 425 | | |||
425 | kpDocumentMetaInfo ret; | 426 | kpDocumentMetaInfo ret; | ||
426 | 427 | | |||
427 | 428 | | |||
428 | if (d->horizDpiInput->value () < ::DpiLegalMin) | 429 | if (d->horizDpiInput->value () < ::DpiLegalMin) { | ||
429 | ret.setDotsPerMeterX (0/*unspecified*/); | 430 | ret.setDotsPerMeterX (0/*unspecified*/); | ||
430 | else | 431 | } | ||
432 | else { | ||||
431 | ret.setDotsPerMeterX (qRound (d->horizDpiInput->value () * KP_INCHES_PER_METER)); | 433 | ret.setDotsPerMeterX (qRound (d->horizDpiInput->value () * KP_INCHES_PER_METER)); | ||
434 | } | ||||
432 | 435 | | |||
433 | if (d->vertDpiInput->value () < ::DpiLegalMin) | 436 | if (d->vertDpiInput->value () < ::DpiLegalMin) { | ||
434 | ret.setDotsPerMeterY (0/*unspecified*/); | 437 | ret.setDotsPerMeterY (0/*unspecified*/); | ||
435 | else | 438 | } | ||
439 | else { | ||||
436 | ret.setDotsPerMeterY (qRound (d->vertDpiInput->value () * KP_INCHES_PER_METER)); | 440 | ret.setDotsPerMeterY (qRound (d->vertDpiInput->value () * KP_INCHES_PER_METER)); | ||
441 | } | ||||
437 | 442 | | |||
438 | 443 | | |||
439 | ret.setOffset (QPoint (d->horizOffsetInput->value (), | 444 | ret.setOffset (QPoint (d->horizOffsetInput->value (), | ||
440 | d->vertOffsetInput->value ())); | 445 | d->vertOffsetInput->value ())); | ||
441 | 446 | | |||
442 | 447 | | |||
443 | for (int r = 0; r < d->fieldsTableWidget->rowCount (); r++) | 448 | for (int r = 0; r < d->fieldsTableWidget->rowCount (); r++) | ||
444 | { | 449 | { | ||
445 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | 450 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | ||
446 | const QString value = d->fieldsTableWidget->item (r, 1)->text (); | 451 | const QString value = d->fieldsTableWidget->item (r, 1)->text (); | ||
447 | 452 | | |||
448 | // Empty key? | 453 | // Empty key? | ||
449 | if (key.isEmpty ()) | 454 | if (key.isEmpty ()) | ||
450 | { | 455 | { | ||
451 | // Empty value too? | 456 | // Empty value too? | ||
452 | if (value.isEmpty ()) | 457 | if (value.isEmpty ()) | ||
453 | { | 458 | { | ||
454 | // Ignore empty row. | 459 | // Ignore empty row. | ||
455 | continue; | 460 | continue; | ||
456 | } | 461 | } | ||
457 | // Value without a key? | 462 | // Value without a key? | ||
458 | else | 463 | | ||
459 | { | 464 | | ||
460 | if (errorMessage) | 465 | if (errorMessage) | ||
461 | { | 466 | { | ||
462 | *errorMessage = | 467 | *errorMessage = | ||
463 | ki18n ("The text value \"%1\" on line %2 requires a key.") | 468 | ki18n ("The text value \"%1\" on line %2 requires a key.") | ||
464 | .subs (value).subs (r + 1/*count from 1*/).toString (); | 469 | .subs (value).subs (r + 1/*count from 1*/).toString (); | ||
465 | 470 | | |||
466 | // Print only 1 error message per method invocation. | 471 | // Print only 1 error message per method invocation. | ||
467 | errorMessage = nullptr; | 472 | errorMessage = nullptr; | ||
468 | } | 473 | } | ||
469 | 474 | | |||
470 | // Ignore. | 475 | // Ignore. | ||
471 | continue; | 476 | continue; | ||
472 | } | 477 | | ||
473 | } | 478 | } | ||
474 | 479 | | |||
475 | // Duplicate key? | 480 | // Duplicate key? | ||
476 | if (ret.textKeys ().contains (key)) | 481 | if (ret.textKeys ().contains (key)) | ||
477 | { | 482 | { | ||
478 | if (errorMessage) | 483 | if (errorMessage) | ||
479 | { | 484 | { | ||
480 | int q; | 485 | int q; | ||
481 | for (q = 0; q < r; q++) | 486 | for (q = 0; q < r; q++) | ||
482 | { | 487 | { | ||
483 | if (d->fieldsTableWidget->item (q, 0)->text () == key) | 488 | if (d->fieldsTableWidget->item (q, 0)->text () == key) { | ||
484 | break; | 489 | break; | ||
485 | } | 490 | } | ||
491 | } | ||||
486 | Q_ASSERT (q != r); | 492 | Q_ASSERT (q != r); | ||
487 | 493 | | |||
488 | *errorMessage = | 494 | *errorMessage = | ||
489 | ki18n ("All text keys must be unique. The text key \"%1\"" | 495 | ki18n ("All text keys must be unique. The text key \"%1\"" | ||
490 | " on lines %2 and %3 are identical.") | 496 | " on lines %2 and %3 are identical.") | ||
491 | .subs (key) | 497 | .subs (key) | ||
492 | .subs (q + 1/*count from 1*/) | 498 | .subs (q + 1/*count from 1*/) | ||
493 | .subs (r + 1/*count from 1*/) | 499 | .subs (r + 1/*count from 1*/) | ||
Show All 15 Lines | |||||
509 | return ret; | 515 | return ret; | ||
510 | } | 516 | } | ||
511 | 517 | | |||
512 | 518 | | |||
513 | // private | 519 | // private | ||
514 | void kpDocumentMetaInfoDialog::fieldsUpdateVerticalHeader () | 520 | void kpDocumentMetaInfoDialog::fieldsUpdateVerticalHeader () | ||
515 | { | 521 | { | ||
516 | QStringList vertLabels; | 522 | QStringList vertLabels; | ||
517 | for (int r = 1; r <= d->fieldsTableWidget->rowCount (); r++) | 523 | for (int r = 1; r <= d->fieldsTableWidget->rowCount (); r++) { | ||
518 | vertLabels << QString::number (r); | 524 | vertLabels << QString::number (r); | ||
525 | } | ||||
519 | 526 | | |||
520 | d->fieldsTableWidget->setVerticalHeaderLabels (vertLabels); | 527 | d->fieldsTableWidget->setVerticalHeaderLabels (vertLabels); | ||
521 | } | 528 | } | ||
522 | 529 | | |||
523 | 530 | | |||
524 | // private | 531 | // private | ||
525 | void kpDocumentMetaInfoDialog::fieldsAddEmptyRow (int atRow) | 532 | void kpDocumentMetaInfoDialog::fieldsAddEmptyRow (int atRow) | ||
526 | { | 533 | { | ||
Show All 30 Lines | 560 | { | |||
557 | return (row >= 0 && row < d->fieldsTableWidget->rowCount () - 1); | 564 | return (row >= 0 && row < d->fieldsTableWidget->rowCount () - 1); | ||
558 | } | 565 | } | ||
559 | 566 | | |||
560 | // private | 567 | // private | ||
561 | void kpDocumentMetaInfoDialog::fieldsDeleteRow (int r) | 568 | void kpDocumentMetaInfoDialog::fieldsDeleteRow (int r) | ||
562 | { | 569 | { | ||
563 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::fieldsDeleteRow(" | 570 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::fieldsDeleteRow(" | ||
564 | << "row=" << r << ")" | 571 | << "row=" << r << ")" | ||
565 | << " currentRow=" << d->fieldsTableWidget->currentRow () << endl; | 572 | << " currentRow=" << d->fieldsTableWidget->currentRow (); | ||
566 | 573 | | |||
567 | Q_ASSERT (isFieldsRowDeleteable (r)); | 574 | Q_ASSERT (isFieldsRowDeleteable (r)); | ||
568 | 575 | | |||
569 | if (r == d->fieldsTableWidget->currentRow ()) | 576 | if (r == d->fieldsTableWidget->currentRow ()) | ||
570 | { | 577 | { | ||
571 | // Assertion follows from previous assertion. | 578 | // Assertion follows from previous assertion. | ||
572 | const int newRow = r + 1; | 579 | const int newRow = r + 1; | ||
573 | qCDebug(kpLogDialogs) << "\tnewRow=" << newRow; | 580 | qCDebug(kpLogDialogs) << "\tnewRow=" << newRow; | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
628 | } | 635 | } | ||
629 | 636 | | |||
630 | //--------------------------------------------------------------------- | 637 | //--------------------------------------------------------------------- | ||
631 | // private slot | 638 | // private slot | ||
632 | 639 | | |||
633 | void kpDocumentMetaInfoDialog::slotFieldsItemChanged (QTableWidgetItem *it) | 640 | void kpDocumentMetaInfoDialog::slotFieldsItemChanged (QTableWidgetItem *it) | ||
634 | { | 641 | { | ||
635 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsItemChanged(" | 642 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsItemChanged(" | ||
636 | << "item=" << it << ") rows=" << d->fieldsTableWidget->rowCount () | 643 | << "item=" << it << ") rows=" << d->fieldsTableWidget->rowCount (); | ||
637 | << endl; | | |||
638 | 644 | | |||
639 | const int r = d->fieldsTableWidget->row (it); | 645 | const int r = d->fieldsTableWidget->row (it); | ||
640 | qCDebug(kpLogDialogs) << "\tr=" << r; | 646 | qCDebug(kpLogDialogs) << "\tr=" << r; | ||
641 | Q_ASSERT (r >= 0 && r < d->fieldsTableWidget->rowCount ()); | 647 | Q_ASSERT (r >= 0 && r < d->fieldsTableWidget->rowCount ()); | ||
642 | 648 | | |||
643 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | 649 | const QString key = d->fieldsTableWidget->item (r, 0)->text (); | ||
644 | qCDebug(kpLogDialogs) << " key='" << key << "'"; | 650 | qCDebug(kpLogDialogs) << " key='" << key << "'"; | ||
645 | 651 | | |||
Show All 17 Lines | |||||
663 | } | 669 | } | ||
664 | } | 670 | } | ||
665 | 671 | | |||
666 | //--------------------------------------------------------------------- | 672 | //--------------------------------------------------------------------- | ||
667 | // private slot | 673 | // private slot | ||
668 | 674 | | |||
669 | void kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked () | 675 | void kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked () | ||
670 | { | 676 | { | ||
671 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked()" | 677 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsAddRowButtonClicked()"; | ||
672 | << endl; | | |||
673 | 678 | | |||
674 | const int r = d->fieldsTableWidget->currentRow (); | 679 | const int r = d->fieldsTableWidget->currentRow (); | ||
675 | qCDebug(kpLogDialogs) << "\tr=" << r; | 680 | qCDebug(kpLogDialogs) << "\tr=" << r; | ||
676 | 681 | | |||
677 | // (if no row is selected, r = -1) | 682 | // (if no row is selected, r = -1) | ||
678 | fieldsAddEmptyRow (r + 1); | 683 | fieldsAddEmptyRow (r + 1); | ||
679 | 684 | | |||
680 | // Edit the key of this new row (column 0). | 685 | // Edit the key of this new row (column 0). | ||
681 | // No one edits the value first (column 1). | 686 | // No one edits the value first (column 1). | ||
682 | editCell ((r + 1)/*row*/, 0/*col*/); | 687 | editCell ((r + 1)/*row*/, 0/*col*/); | ||
683 | } | 688 | } | ||
684 | 689 | | |||
685 | //--------------------------------------------------------------------- | 690 | //--------------------------------------------------------------------- | ||
686 | 691 | | |||
687 | // private slot | 692 | // private slot | ||
688 | void kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked () | 693 | void kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked () | ||
689 | { | 694 | { | ||
690 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked()" | 695 | qCDebug(kpLogDialogs) << "kpDocumentMetaInfoDialog::slotFieldsDeleteRowButtonClicked()"; | ||
691 | << endl; | | |||
692 | 696 | | |||
693 | const int r = d->fieldsTableWidget->currentRow (); | 697 | const int r = d->fieldsTableWidget->currentRow (); | ||
694 | qCDebug(kpLogDialogs) << "\tr=" << r; | 698 | qCDebug(kpLogDialogs) << "\tr=" << r; | ||
695 | 699 | | |||
696 | Q_ASSERT (isFieldsRowDeleteable (r)); | 700 | Q_ASSERT (isFieldsRowDeleteable (r)); | ||
697 | fieldsDeleteRow (r); | 701 | fieldsDeleteRow (r); | ||
698 | } | 702 | } | ||
699 | 703 | | |||
Show All 15 Lines |