Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/importexport/csv/kexicsvexportwizard.cpp
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 60 | if (m_options.mode == KexiCSVExport::Clipboard) { | |||
---|---|---|---|---|---|
62 | button(QDialogButtonBox::Ok)->setText(xi18n("Copy")); | 62 | button(QDialogButtonBox::Ok)->setText(xi18n("Copy")); | ||
63 | } else { | 63 | } else { | ||
64 | button(QDialogButtonBox::Ok)->setText(xi18n("Export")); | 64 | button(QDialogButtonBox::Ok)->setText(xi18n("Export")); | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | QString infoLblFromText; | 67 | QString infoLblFromText; | ||
68 | QString captionOrName; | 68 | QString captionOrName; | ||
69 | KexiGUIMessageHandler msgh(this); | 69 | KexiGUIMessageHandler msgh(this); | ||
70 | KDbConnection* conn = KexiMainWindowIface::global()->project()->dbConnection(); | ||||
70 | if (m_options.useTempQuery) { | 71 | if (m_options.useTempQuery) { | ||
71 | m_tableOrQuery = new KDbTableOrQuerySchema(KexiMainWindowIface::global()->unsavedQuery(options.itemId)); | 72 | m_tableOrQuery = new KDbTableOrQuerySchema(KexiMainWindowIface::global()->unsavedQuery(options.itemId)); | ||
72 | captionOrName = KexiMainWindowIface::global()->project()->dbConnection()->querySchema(m_options.itemId)->captionOrName(); | 73 | captionOrName = conn->querySchema(m_options.itemId)->captionOrName(); | ||
73 | } else { | 74 | } else { | ||
74 | m_tableOrQuery = new KDbTableOrQuerySchema( | 75 | m_tableOrQuery = new KDbTableOrQuerySchema(conn, m_options.itemId); | ||
75 | KexiMainWindowIface::global()->project()->dbConnection(), m_options.itemId); | | |||
76 | captionOrName = m_tableOrQuery->captionOrName(); | 76 | captionOrName = m_tableOrQuery->captionOrName(); | ||
77 | } | 77 | } | ||
78 | if (m_tableOrQuery->table()) { | 78 | if (m_tableOrQuery->table()) { | ||
79 | if (m_options.mode == KexiCSVExport::Clipboard) { | 79 | if (m_options.mode == KexiCSVExport::Clipboard) { | ||
80 | setWindowTitle(xi18nc("@title:window", "Copy Data From Table to Clipboard")); | 80 | setWindowTitle(xi18nc("@title:window", "Copy Data From Table to Clipboard")); | ||
81 | infoLblFromText = xi18n("Copying data from table:"); | 81 | infoLblFromText = xi18n("Copying data from table:"); | ||
82 | } else { | 82 | } else { | ||
83 | setWindowTitle(xi18nc("@title:window", "Export Data From Table to CSV File")); | 83 | setWindowTitle(xi18nc("@title:window", "Export Data From Table to CSV File")); | ||
84 | infoLblFromText = xi18n("Exporting data from table:"); | 84 | infoLblFromText = xi18n("Exporting data from table:"); | ||
85 | } | 85 | } | ||
86 | } else if (m_tableOrQuery->query()) { | 86 | } else if (m_tableOrQuery->query()) { | ||
87 | if (m_options.mode == KexiCSVExport::Clipboard) { | 87 | if (m_options.mode == KexiCSVExport::Clipboard) { | ||
88 | setWindowTitle(xi18nc("@title:window", "Copy Data From Query to Clipboard")); | 88 | setWindowTitle(xi18nc("@title:window", "Copy Data From Query to Clipboard")); | ||
89 | infoLblFromText = xi18n("Copying data from table:"); | 89 | infoLblFromText = xi18n("Copying data from table:"); | ||
90 | } else { | 90 | } else { | ||
91 | setWindowTitle(xi18nc("@title:window", "Export Data From Query to CSV File")); | 91 | setWindowTitle(xi18nc("@title:window", "Export Data From Query to CSV File")); | ||
92 | infoLblFromText = xi18n("Exporting data from query:"); | 92 | infoLblFromText = xi18n("Exporting data from query:"); | ||
93 | } | 93 | } | ||
94 | } else { | 94 | } else { | ||
95 | msgh.showErrorMessage(KexiMainWindowIface::global()->project()->dbConnection()->result(), | 95 | msgh.showErrorMessage(conn->result(), KDbMessageHandler::Error, | ||
96 | KDbMessageHandler::Error, | | |||
97 | xi18n("Could not open data for exporting.")); | 96 | xi18n("Could not open data for exporting.")); | ||
98 | m_canceled = true; | 97 | m_canceled = true; | ||
99 | return; | 98 | return; | ||
100 | } | 99 | } | ||
101 | 100 | | |||
102 | QString text = "\n" + captionOrName; | 101 | QString text = "\n" + captionOrName; | ||
103 | int m_recordCount = KDb::recordCount(m_tableOrQuery); | 102 | int m_recordCount = conn->recordCount(m_tableOrQuery); | ||
104 | int columns = KDb::fieldCount(m_tableOrQuery); | 103 | int columns = m_tableOrQuery->fieldCount(conn); | ||
105 | text += "\n"; | 104 | text += "\n"; | ||
106 | if (m_recordCount > 0) | 105 | if (m_recordCount > 0) | ||
107 | text += xi18n("(rows: %1, columns: %2)", m_recordCount, columns); | 106 | text += xi18n("(rows: %1, columns: %2)", m_recordCount, columns); | ||
108 | else | 107 | else | ||
109 | text += xi18n("(columns: %1)", columns); | 108 | text += xi18n("(columns: %1)", columns); | ||
110 | infoLblFromText.append(text); | 109 | infoLblFromText.append(text); | ||
111 | 110 | | |||
112 | // OK, source data found. | 111 | // OK, source data found. | ||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Line(s) | 297 | if (currentPage() == m_fileSavePage) { | |||
302 | KAssistantDialog::next(); | 301 | KAssistantDialog::next(); | ||
303 | return; | 302 | return; | ||
304 | } | 303 | } | ||
305 | KAssistantDialog::next(); | 304 | KAssistantDialog::next(); | ||
306 | } | 305 | } | ||
307 | 306 | | |||
308 | void KexiCSVExportWizard::done(int result) | 307 | void KexiCSVExportWizard::done(int result) | ||
309 | { | 308 | { | ||
309 | KDbConnection* conn = KexiMainWindowIface::global()->project()->dbConnection(); | ||||
310 | if (QDialog::Accepted == result) { | 310 | if (QDialog::Accepted == result) { | ||
311 | if (m_fileSavePage) { | 311 | if (m_fileSavePage) { | ||
312 | //qDebug() << selectedFile(); | 312 | //qDebug() << selectedFile(); | ||
313 | m_options.fileName = selectedFile(); | 313 | m_options.fileName = selectedFile(); | ||
314 | } | 314 | } | ||
315 | m_options.delimiter = m_delimiterWidget->delimiter(); | 315 | m_options.delimiter = m_delimiterWidget->delimiter(); | ||
316 | m_options.textQuote = m_textQuote->textQuote(); | 316 | m_options.textQuote = m_textQuote->textQuote(); | ||
317 | m_options.addColumnNames = m_addColumnNamesCheckBox->isChecked(); | 317 | m_options.addColumnNames = m_addColumnNamesCheckBox->isChecked(); | ||
318 | if (!KexiCSVExport::exportData(m_tableOrQuery, m_options)) | 318 | if (!KexiCSVExport::exportData(conn, m_tableOrQuery, m_options)) | ||
319 | return; | 319 | return; | ||
320 | 320 | | |||
321 | //store options | 321 | //store options | ||
322 | if (m_options.mode != KexiCSVExport::Clipboard) | 322 | if (m_options.mode != KexiCSVExport::Clipboard) | ||
323 | writeEntry("ShowOptionsInCSVExportDialog", m_exportOptionsSection->isVisible()); | 323 | writeEntry("ShowOptionsInCSVExportDialog", m_exportOptionsSection->isVisible()); | ||
324 | const bool store = m_alwaysUseCheckBox->isChecked(); | 324 | const bool store = m_alwaysUseCheckBox->isChecked(); | ||
325 | writeEntry("StoreOptionsForCSVExportDialog", store); | 325 | writeEntry("StoreOptionsForCSVExportDialog", store); | ||
326 | // only save if an option differs from default | 326 | // only save if an option differs from default | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |