Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/queries/kexiquerydesignersql.cpp
Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Line(s) | 94 | { | |||
---|---|---|---|---|---|
153 | a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5)); | 153 | a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5)); | ||
154 | a->setToolTip(xi18n("Check Query")); | 154 | a->setToolTip(xi18n("Check Query")); | ||
155 | a->setWhatsThis(xi18n("Checks query for validity.")); | 155 | a->setWhatsThis(xi18n("Checks query for validity.")); | ||
156 | addAction(a); | 156 | addAction(a); | ||
157 | connect(a, SIGNAL(triggered()), this, SLOT(slotCheckQuery())); | 157 | connect(a, SIGNAL(triggered()), this, SLOT(slotCheckQuery())); | ||
158 | 158 | | |||
159 | setViewActions(viewActions); | 159 | setViewActions(viewActions); | ||
160 | 160 | | |||
161 | slotUpdateMode(); | | |||
162 | slotCheckQuery(); | 161 | slotCheckQuery(); | ||
163 | updateGeometry(); | 162 | updateGeometry(); | ||
164 | } | 163 | } | ||
165 | 164 | | |||
166 | KexiQueryDesignerSQLView::~KexiQueryDesignerSQLView() | 165 | KexiQueryDesignerSQLView::~KexiQueryDesignerSQLView() | ||
167 | { | 166 | { | ||
168 | delete d; | 167 | delete d; | ||
169 | } | 168 | } | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 228 | if (KMessageBox::No == KMessageBox::warningYesNo(this, | |||
231 | + "</p><p>" + xi18n("Do you want to cancel any changes made to this SQL text?") + "</p>" | 230 | + "</p><p>" + xi18n("Do you want to cancel any changes made to this SQL text?") + "</p>" | ||
232 | + "</p><p>" + xi18n("Answering \"No\" allows you to make corrections.") + "</p>")) { | 231 | + "</p><p>" + xi18n("Answering \"No\" allows you to make corrections.") + "</p>")) { | ||
233 | return cancelled; | 232 | return cancelled; | ||
234 | } | 233 | } | ||
235 | //do not change original query - it's invalid | 234 | //do not change original query - it's invalid | ||
236 | temp->setQueryChangedInView(false); | 235 | temp->setQueryChangedInView(false); | ||
237 | //this view is no longer _just_ switched from "NoViewMode" | 236 | //this view is no longer _just_ switched from "NoViewMode" | ||
238 | d->justSwitchedFromNoViewMode = false; | 237 | d->justSwitchedFromNoViewMode = false; | ||
238 | d->slotTextChangedEnabled = false; | ||||
239 | d->editor->setText(d->origStatement.toString()); | ||||
240 | d->slotTextChangedEnabled = true; | ||||
241 | slotCheckQuery(); | ||||
239 | return true; | 242 | return true; | ||
240 | } | 243 | } | ||
241 | //this view is no longer _just_ switched from "NoViewMode" | 244 | //this view is no longer _just_ switched from "NoViewMode" | ||
242 | d->justSwitchedFromNoViewMode = false; | 245 | d->justSwitchedFromNoViewMode = false; | ||
243 | //replace old query schema with new one | 246 | //replace old query schema with new one | ||
244 | temp->setQuery(d->parsedQuery); //this will also delete temp->query() | 247 | temp->setQuery(d->parsedQuery); //this will also delete temp->query() | ||
245 | d->parsedQuery = 0; | 248 | d->parsedQuery = 0; | ||
246 | temp->setQueryChangedInView(true); | 249 | temp->setQueryChangedInView(true); | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 261 | { | |||
290 | if (d->origStatement.isEmpty() && !window()->partItem()->neverSaved()) { | 293 | if (d->origStatement.isEmpty() && !window()->partItem()->neverSaved()) { | ||
291 | //no valid query delivered or query has not been modified: | 294 | //no valid query delivered or query has not been modified: | ||
292 | // just load sql text, no matter if it's valid | 295 | // just load sql text, no matter if it's valid | ||
293 | QString sql; | 296 | QString sql; | ||
294 | if (!loadDataBlock(&sql, "sql", true /*canBeEmpty*/)) { | 297 | if (!loadDataBlock(&sql, "sql", true /*canBeEmpty*/)) { | ||
295 | return false; | 298 | return false; | ||
296 | } | 299 | } | ||
297 | d->origStatement = KDbEscapedString(sql); | 300 | d->origStatement = KDbEscapedString(sql); | ||
301 | d->slotTextChangedEnabled = false; | ||||
302 | d->editor->setText(d->origStatement.toString()); | ||||
303 | d->slotTextChangedEnabled = true; | ||||
298 | } | 304 | } | ||
299 | 305 | | |||
300 | if (temp->queryChangedInView() == Kexi::DesignViewMode /* true in this scenario: | 306 | if (temp->queryChangedInView() == Kexi::DesignViewMode /* true in this scenario: | ||
301 | - user switched from SQL to Design, | 307 | - user switched from SQL to Design, | ||
302 | - changed the design, | 308 | - changed the design, | ||
303 | - switched to Data | 309 | - switched to Data | ||
304 | - switched back to SQL */ | 310 | - switched back to SQL */ | ||
305 | || mode != Kexi::DataViewMode) /* true in this scenario: user switched from No-view | 311 | || mode != Kexi::DataViewMode) /* true in this scenario: user switched from No-view | ||
Show All 37 Lines | 344 | if (!d->parsedQuery || !ok || !parser->error().type().isEmpty()) { | |||
343 | d->parsedQuery = 0; | 349 | d->parsedQuery = 0; | ||
344 | return false; | 350 | return false; | ||
345 | } | 351 | } | ||
346 | 352 | | |||
347 | setStatusOk(); | 353 | setStatusOk(); | ||
348 | return true; | 354 | return true; | ||
349 | } | 355 | } | ||
350 | 356 | | |||
351 | void KexiQueryDesignerSQLView::slotUpdateMode() | | |||
352 | { | | |||
353 | slotCheckQuery(); | | |||
354 | } | | |||
355 | | ||||
356 | void KexiQueryDesignerSQLView::slotTextChanged() | 357 | void KexiQueryDesignerSQLView::slotTextChanged() | ||
357 | { | 358 | { | ||
358 | if (!d->slotTextChangedEnabled) | 359 | if (!d->slotTextChangedEnabled) | ||
359 | return; | 360 | return; | ||
360 | setDirty(true); | 361 | setDirty(true); | ||
361 | setStatusEmpty(); | 362 | setStatusEmpty(); | ||
362 | } | 363 | } | ||
363 | 364 | | |||
364 | void KexiQueryDesignerSQLView::updateActions(bool activated) | 365 | void KexiQueryDesignerSQLView::updateActions(bool activated) | ||
365 | { | 366 | { | ||
366 | if (activated) { | 367 | if (activated) { | ||
367 | slotUpdateMode(); | 368 | if (isDirty()) { | ||
369 | slotCheckQuery(); | ||||
370 | } | ||||
368 | } | 371 | } | ||
369 | setAvailable("querypart_check_query", true); | 372 | setAvailable("querypart_check_query", true); | ||
370 | KexiView::updateActions(activated); | 373 | KexiView::updateActions(activated); | ||
371 | } | 374 | } | ||
372 | 375 | | |||
373 | KexiQueryPartTempData* KexiQueryDesignerSQLView::tempData() const | 376 | KexiQueryPartTempData* KexiQueryDesignerSQLView::tempData() const | ||
374 | { | 377 | { | ||
375 | return dynamic_cast<KexiQueryPartTempData*>(window()->data()); | 378 | return dynamic_cast<KexiQueryPartTempData*>(window()->data()); | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |