Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/queries/kexiquerypart.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | |||||
112 | void KexiQueryPart::initInstanceActions() | 112 | void KexiQueryPart::initInstanceActions() | ||
113 | { | 113 | { | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | KDbObject* KexiQueryPart::loadSchemaObject( | 116 | KDbObject* KexiQueryPart::loadSchemaObject( | ||
117 | KexiWindow *window, const KDbObject& object, Kexi::ViewMode viewMode, | 117 | KexiWindow *window, const KDbObject& object, Kexi::ViewMode viewMode, | ||
118 | bool *ownedByWindow) | 118 | bool *ownedByWindow) | ||
119 | { | 119 | { | ||
120 | Q_ASSERT(ownedByWindow); | ||||
121 | *ownedByWindow = false; | ||||
120 | KexiQueryPartTempData * temp = static_cast<KexiQueryPartTempData*>(window->data()); | 122 | KexiQueryPartTempData * temp = static_cast<KexiQueryPartTempData*>(window->data()); | ||
121 | QString sql; | 123 | QString sql; | ||
122 | if (!loadDataBlock(window, &sql, "sql")) { | 124 | if (!loadDataBlock(window, &sql, "sql")) { | ||
123 | return 0; | 125 | return 0; | ||
124 | } | 126 | } | ||
125 | KDbEscapedString sqlText(sql); | 127 | KDbEscapedString sqlText(sql); | ||
126 | KDbParser *parser = KexiMainWindowIface::global()->project()->sqlParser(); | 128 | KDbParser *parser = KexiMainWindowIface::global()->project()->sqlParser(); | ||
127 | KDbQuerySchema *query = 0; | 129 | KDbQuerySchema *query = 0; | ||
Show All 14 Lines | 134 | if (!query) { | |||
142 | //! @todo | 144 | //! @todo | ||
143 | return 0; | 145 | return 0; | ||
144 | } | 146 | } | ||
145 | qDebug() << KDbConnectionAndQuerySchema( | 147 | qDebug() << KDbConnectionAndQuerySchema( | ||
146 | KexiMainWindowIface::global()->project()->dbConnection(), *query); | 148 | KexiMainWindowIface::global()->project()->dbConnection(), *query); | ||
147 | (KDbObject&)*query = object; //copy main attributes | 149 | (KDbObject&)*query = object; //copy main attributes | ||
148 | 150 | | |||
149 | temp->registerTableSchemaChanges(query); | 151 | temp->registerTableSchemaChanges(query); | ||
150 | if (ownedByWindow) | 152 | *ownedByWindow = true; // owned because it is created by the parser | ||
151 | *ownedByWindow = false; | | |||
152 | 153 | | |||
153 | qDebug() << KDbConnectionAndQuerySchema( | 154 | qDebug() << KDbConnectionAndQuerySchema( | ||
154 | KexiMainWindowIface::global()->project()->dbConnection(), *query); | 155 | KexiMainWindowIface::global()->project()->dbConnection(), *query); | ||
155 | return query; | 156 | return query; | ||
156 | } | 157 | } | ||
157 | 158 | | |||
158 | KDbQuerySchema *KexiQueryPart::currentQuery(KexiView* view) | 159 | KDbQuerySchema *KexiQueryPart::currentQuery(KexiView* view) | ||
159 | { | 160 | { | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 240 | { | |||
241 | m_query = 0; | 242 | m_query = 0; | ||
242 | return query; | 243 | return query; | ||
243 | } | 244 | } | ||
244 | 245 | | |||
245 | void KexiQueryPartTempData::setQuery(KDbQuerySchema *query) | 246 | void KexiQueryPartTempData::setQuery(KDbQuerySchema *query) | ||
246 | { | 247 | { | ||
247 | if (m_query && m_query == query) | 248 | if (m_query && m_query == query) | ||
248 | return; | 249 | return; | ||
250 | KexiWindow* window = static_cast<KexiWindow*>(parent()); | ||||
249 | if (m_query | 251 | if (m_query | ||
250 | /* query not owned by window */ | 252 | /* query not owned by window */ | ||
251 | && (static_cast<KexiWindow*>(parent())->schemaObject() != static_cast<KDbObject*>(m_query))) | 253 | && (static_cast<KexiWindow*>(parent())->schemaObject() != static_cast<KDbObject*>(m_query))) | ||
252 | { | 254 | { | ||
255 | KexiQueryView* dataView = qobject_cast<KexiQueryView*>(window->viewForMode(Kexi::DataViewMode)); | ||||
256 | if (dataView && dataView->query() == m_query) { | ||||
257 | dataView->setQuery(nullptr); // unassign before deleting | ||||
258 | } | ||||
253 | delete m_query; | 259 | delete m_query; | ||
254 | } | 260 | } | ||
255 | m_query = query; | 261 | m_query = query; | ||
256 | } | 262 | } | ||
257 | 263 | | |||
258 | Kexi::ViewMode KexiQueryPartTempData::queryChangedInView() const | 264 | Kexi::ViewMode KexiQueryPartTempData::queryChangedInView() const | ||
259 | { | 265 | { | ||
260 | return m_queryChangedInView; | 266 | return m_queryChangedInView; | ||
Show All 9 Lines |