Changeset View
Changeset View
Standalone View
Standalone View
src/errordialog.cpp
Show All 29 Lines | |||||
30 | #include <KGuiItem> | 30 | #include <KGuiItem> | ||
31 | #include <KHelpClient> | 31 | #include <KHelpClient> | ||
32 | #include <KLocalizedString> | 32 | #include <KLocalizedString> | ||
33 | 33 | | |||
34 | 34 | | |||
35 | ErrorDialog::ErrorDialog(QWidget* parent) | 35 | ErrorDialog::ErrorDialog(QWidget* parent) | ||
36 | : QDialog(parent) | 36 | : QDialog(parent) | ||
37 | { | 37 | { | ||
38 | errorList = 0; | 38 | errorList = nullptr; | ||
39 | 39 | | |||
40 | setWindowTitle(i18n("Errors")); | 40 | setWindowTitle(i18n("Errors")); | ||
41 | setModal(false); | 41 | setModal(false); | ||
42 | QVBoxLayout *mainLayout = new QVBoxLayout; | 42 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
43 | setLayout(mainLayout); | 43 | setLayout(mainLayout); | ||
44 | 44 | | |||
45 | QWidget *mainWidget = new QWidget(this); | 45 | QWidget *mainWidget = new QWidget(this); | ||
46 | mainLayout->addWidget(mainWidget); | 46 | mainLayout->addWidget(mainWidget); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 86 | // setButtonGuiItem(User1, i18n("Help on &Error")); // TODO context help in the error dialog | |||
89 | clear(); | 89 | clear(); | ||
90 | } | 90 | } | ||
91 | 91 | | |||
92 | 92 | | |||
93 | 93 | | |||
94 | void ErrorDialog::clear() | 94 | void ErrorDialog::clear() | ||
95 | { | 95 | { | ||
96 | disable(); | 96 | disable(); | ||
97 | errorList = 0; | 97 | errorList = nullptr; | ||
98 | errorTable->clearContents(); | 98 | errorTable->clearContents(); | ||
99 | 99 | | |||
100 | // put a friendly 'nothing to see here' notice in the empty table | 100 | // put a friendly 'nothing to see here' notice in the empty table | ||
101 | errorTable->setRowCount(1); | 101 | errorTable->setRowCount(1); | ||
102 | QTableWidgetItem* emptyItem = new QTableWidgetItem(i18n("No errors occurred yet.")); | 102 | QTableWidgetItem* emptyItem = new QTableWidgetItem(i18n("No errors occurred yet.")); | ||
103 | QFont emptyFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont)); | 103 | QFont emptyFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont)); | ||
104 | emptyFont.setItalic(true); | 104 | emptyFont.setItalic(true); | ||
105 | emptyItem->setFont(emptyFont); | 105 | emptyItem->setFont(emptyFont); | ||
106 | errorTable->setItem(0, 1, emptyItem); | 106 | errorTable->setItem(0, 1, emptyItem); | ||
107 | 107 | | |||
108 | errorTable->resizeColumnsToContents(); | 108 | errorTable->resizeColumnsToContents(); | ||
109 | // errorTable->setColumnWidth(0, errorTable->fontMetrics().width("88888")); | 109 | // errorTable->setColumnWidth(0, errorTable->fontMetrics().width("88888")); | ||
110 | // errorTable->setColumnWidth(2, errorTable->fontMetrics().width("88888")); | 110 | // errorTable->setColumnWidth(2, errorTable->fontMetrics().width("88888")); | ||
111 | // errorTable->setColumnWidth(1, errorTable->width() - errorTable->verticalHeader()->width() - errorTable->columnWidth(0) - errorTable->columnWidth(2)); | 111 | // errorTable->setColumnWidth(1, errorTable->width() - errorTable->verticalHeader()->width() - errorTable->columnWidth(0) - errorTable->columnWidth(2)); | ||
112 | } | 112 | } | ||
113 | 113 | | |||
114 | void ErrorDialog::enable() | 114 | void ErrorDialog::enable() | ||
115 | { | 115 | { | ||
116 | Q_ASSERT (errorList != 0); | 116 | Q_ASSERT (errorList); | ||
117 | errorTable->setEnabled(true); | 117 | errorTable->setEnabled(true); | ||
118 | m_buttonBox->button(QDialogButtonBox::Help)->setEnabled(true); | 118 | m_buttonBox->button(QDialogButtonBox::Help)->setEnabled(true); | ||
119 | connect(errorTable, &QTableWidget::itemSelectionChanged, this, &ErrorDialog::selectedErrorChangedProxy); | 119 | connect(errorTable, &QTableWidget::itemSelectionChanged, this, &ErrorDialog::selectedErrorChangedProxy); | ||
120 | errorTable->selectRow(0); | 120 | errorTable->selectRow(0); | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | void ErrorDialog::disable() | 123 | void ErrorDialog::disable() | ||
124 | { | 124 | { | ||
Show All 21 Lines | 133 | { | |||
146 | } | 146 | } | ||
147 | errorTable->clearSelection(); | 147 | errorTable->clearSelection(); | ||
148 | errorTable->resizeColumnsToContents(); | 148 | errorTable->resizeColumnsToContents(); | ||
149 | enable(); | 149 | enable(); | ||
150 | } | 150 | } | ||
151 | 151 | | |||
152 | void ErrorDialog::selectedErrorChangedProxy() | 152 | void ErrorDialog::selectedErrorChangedProxy() | ||
153 | { | 153 | { | ||
154 | Q_ASSERT (errorList != 0); | 154 | Q_ASSERT (errorList); | ||
155 | const Token* t = &errorList->at(errorTable->selectedItems().first()->row()).token(); | 155 | const Token* t = &errorList->at(errorTable->selectedItems().first()->row()).token(); | ||
156 | emit currentlySelectedError(t->startRow(), t->startCol(), t->endRow(), t->endCol()); | 156 | emit currentlySelectedError(t->startRow(), t->startCol(), t->endRow(), t->endCol()); | ||
157 | // //qDebug() << "EMITTED: " << t->startRow() << ", " << t->startCol() << ", " << t->endRow() << ", " << t->endCol(); | 157 | // //qDebug() << "EMITTED: " << t->startRow() << ", " << t->startCol() << ", " << t->endRow() << ", " << t->endCol(); | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | void ErrorDialog::helpRequested() | 160 | void ErrorDialog::helpRequested() | ||
161 | { | 161 | { | ||
162 | KHelpClient::invokeHelp("reference", "kturtle"); | 162 | KHelpClient::invokeHelp("reference", "kturtle"); | ||
163 | } | 163 | } |