Copy as C string added.

This commit is contained in:
Eelke Klein 2017-02-05 08:23:06 +01:00
parent 4a2c6cc396
commit df866d7b67
9 changed files with 89 additions and 32 deletions

View file

@ -12,6 +12,8 @@
#include <windows.h>
#include <algorithm>
#include <QCloseEvent>
#include <QMetaObject>
#include <QMetaMethod>
#include <querytab.h>
#include "util.h"
#include "MasterController.h"
@ -155,37 +157,6 @@ void MainWindow::on_actionAbout_triggered()
}
#if false
void Copy( )
{
QString selected_text;
// You need a pair of indexes to find the row changes
QModelIndex previous = indexes.first();
indexes.removeFirst();
foreach(current, indexes)
{
QVariant data = model->data(current);
QString text = data.toString();
// At this point `text` contains the text in one cell
selected_text.append(text);
// If you are at the start of the row the row number of the previous index
// isn't the same. Text is followed by a row separator, which is a newline.
if (current.row() != previous.row())
{
selected_text.append('\n');
}
// Otherwise it's the same row, so append a column separator, which is a tab.
else
{
selected_text.append('\t');
}
previous = current;
}
QApplication.clipboard().setText(selected_text);
}
#endif
void MainWindow::on_actionExecute_SQL_triggered()
{
QueryTab *tab = GetActiveQueryTab();
@ -202,7 +173,6 @@ void MainWindow::on_actionExplain_triggered()
}
}
void MainWindow::on_actionExplain_Analyze_triggered()
{
QueryTab *tab = GetActiveQueryTab();
@ -269,5 +239,26 @@ void MainWindow::on_actionCopy_triggered()
if (tv) {
copySelectionToClipboard(tv);
}
else {
const QMetaObject *meta = w->metaObject();
int i = meta->indexOfSlot("copy");
if (i != -1) {
QMetaMethod method = meta->method(i);
method.invoke(w, Qt::AutoConnection);
}
}
//this->ui->
}
void MainWindow::on_actionCopy_as_C_string_triggered()
{
// Find which edit is active, copy the selected text or all text if no selection present
// Put quote's around each line and add escapes.
QueryTab *tab = GetActiveQueryTab();
if (tab) {
tab->copyQueryAsCString();
}
}