mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-09-04 06:04:50 -06:00
add copy insert format
add copy insert format replace path for autosave query
This commit is contained in:
parent
61c23d272f
commit
9050d8fee0
7 changed files with 45 additions and 20 deletions
Binary file not shown.
|
|
@ -69,7 +69,7 @@ void ctlSQLGrid::OnGridColSize(wxGridSizeEvent &event)
|
|||
}
|
||||
void ctlSQLGrid::OnCopy(wxCommandEvent &ev)
|
||||
{
|
||||
Copy();
|
||||
Copy(false);
|
||||
}
|
||||
|
||||
void ctlSQLGrid::OnMouseWheel(wxMouseEvent &event)
|
||||
|
|
@ -131,14 +131,18 @@ wxString ctlSQLGrid::GetExportLine(int row, wxArrayInt cols)
|
|||
|
||||
if (GetNumberCols() == 0)
|
||||
return str;
|
||||
|
||||
wxString colsep=settings->GetCopyColSeparator();
|
||||
if (generatesql) colsep=wxT(",");
|
||||
wxString qtsimbol=settings->GetCopyQuoteChar();
|
||||
if (generatesql) qtsimbol=wxT("'");
|
||||
wxString head=wxT("insert into tbl(");
|
||||
for (col = 0 ; col < cols.Count() ; col++)
|
||||
{
|
||||
if (col > 0)
|
||||
str.Append(settings->GetCopyColSeparator());
|
||||
|
||||
str.Append(colsep);
|
||||
if (col > 0) head.Append(colsep);
|
||||
head=head+GetColumnName(cols[col]);
|
||||
wxString text = GetCellValue(row, cols[col]);
|
||||
|
||||
bool needQuote = false;
|
||||
if (settings->GetCopyQuoting() == 1)
|
||||
{
|
||||
|
|
@ -147,13 +151,21 @@ wxString ctlSQLGrid::GetExportLine(int row, wxArrayInt cols)
|
|||
else if (settings->GetCopyQuoting() == 2)
|
||||
/* Quote everything */
|
||||
needQuote = true;
|
||||
|
||||
if (text.Length()==0&&generatesql) {needQuote = false;}
|
||||
if (needQuote)
|
||||
str.Append(settings->GetCopyQuoteChar());
|
||||
str.Append(qtsimbol);
|
||||
|
||||
if (generatesql) {
|
||||
if (text.Length()!=0) {
|
||||
text.Replace(wxT("'"),wxT("''"));
|
||||
} else text=wxT("null");
|
||||
|
||||
}
|
||||
str.Append(text);
|
||||
if (needQuote)
|
||||
str.Append(settings->GetCopyQuoteChar());
|
||||
str.Append(qtsimbol);
|
||||
}
|
||||
if (generatesql) str=head+wxT(") values (")+str+");";
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +192,7 @@ void ctlSQLGrid::AppendColumnHeader(wxString &str, int start, int end)
|
|||
|
||||
void ctlSQLGrid::AppendColumnHeader(wxString &str, wxArrayInt columns)
|
||||
{
|
||||
if(settings->GetColumnNames())
|
||||
if(settings->GetColumnNames()&&!generatesql)
|
||||
{
|
||||
bool CopyQuoting = (settings->GetCopyQuoting() == 1 || settings->GetCopyQuoting() == 2);
|
||||
size_t i;
|
||||
|
|
@ -202,12 +214,12 @@ void ctlSQLGrid::AppendColumnHeader(wxString &str, wxArrayInt columns)
|
|||
}
|
||||
}
|
||||
|
||||
int ctlSQLGrid::Copy()
|
||||
int ctlSQLGrid::Copy(bool gensql)
|
||||
{
|
||||
wxString str;
|
||||
int copied = 0;
|
||||
size_t i;
|
||||
|
||||
generatesql=gensql;
|
||||
|
||||
|
||||
if (GetSelectedRows().GetCount())
|
||||
|
|
|
|||
|
|
@ -772,7 +772,7 @@ void frmEditGrid::OnCopy(wxCommandEvent &ev)
|
|||
else if(sqlGrid->GetNumberRows() > 0)
|
||||
{
|
||||
int copied;
|
||||
copied = sqlGrid->Copy();
|
||||
copied = sqlGrid->Copy(false);
|
||||
SetStatusText(wxString::Format(
|
||||
wxPLURAL("Data from %d row copied to clipboard.", "Data from %d rows copied to clipboard.", copied),
|
||||
copied));
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ BEGIN_EVENT_TABLE(frmQuery, pgFrame)
|
|||
EVT_MENU(MNU_PASTE, frmQuery::OnPaste)
|
||||
EVT_MENU(MNU_CLEAR, frmQuery::OnClear)
|
||||
EVT_MENU(MNU_SUMMARY_COL, frmQuery::OnSummary_Column)
|
||||
EVT_MENU(MNU_COPY_INSERT, frmQuery::OnCopy_Insert)
|
||||
EVT_MENU(MNU_FIND, frmQuery::OnSearchReplace)
|
||||
EVT_MENU(MNU_UNDO, frmQuery::OnUndo)
|
||||
EVT_MENU(MNU_REDO, frmQuery::OnRedo)
|
||||
|
|
@ -667,7 +668,7 @@ frmQuery::frmQuery(frmMain *form, const wxString &_title, pgConn *_conn, const w
|
|||
wxString str;
|
||||
wxString filename;
|
||||
|
||||
wxString tempDir=wxStandardPaths::Get().GetTempDir()+wxT("\\pgadmin3\\");
|
||||
wxString tempDir=wxStandardPaths::Get().GetUserConfigDir()+wxT("\\postgresql\\recovery\\");
|
||||
|
||||
if (!wxDirExists(tempDir)) {
|
||||
wxFileName dn = tempDir;
|
||||
|
|
@ -1472,7 +1473,7 @@ void frmQuery::OnCopy(wxCommandEvent &ev)
|
|||
{
|
||||
if (obj == sqlResult)
|
||||
{
|
||||
sqlResult->Copy();
|
||||
sqlResult->Copy(false);
|
||||
break;
|
||||
}
|
||||
obj = obj->GetParent();
|
||||
|
|
@ -1933,6 +1934,7 @@ void frmQuery::OnLabelRightClick(wxGridEvent &event)
|
|||
xmenu->Append(MNU_PASTE, _("&Paste"), _("Paste data from the clipboard."));
|
||||
xmenu->Append(MNU_DELETE, _("&Delete"), _("Delete selected rows."));
|
||||
xmenu->Append(MNU_SUMMARY_COL, _("Summary"), _("Summary selected cells."));
|
||||
xmenu->Append(MNU_COPY_INSERT, _("Copy Insert format"), _("Copy Insert format."));
|
||||
|
||||
if ((rows.GetCount()))
|
||||
{
|
||||
|
|
@ -1948,6 +1950,15 @@ void frmQuery::OnLabelRightClick(wxGridEvent &event)
|
|||
}
|
||||
sqlResult->PopupMenu(xmenu);
|
||||
}
|
||||
void frmQuery::OnCopy_Insert(wxCommandEvent &ev)
|
||||
{
|
||||
// if (currentControl() == sqlResult)
|
||||
{
|
||||
wxString s=wxT("Insert into format copy buffer.");
|
||||
sqlResult->Copy(true);
|
||||
SetStatusText(s, STATUSPOS_POS);
|
||||
}
|
||||
}
|
||||
|
||||
void frmQuery::OnSummary_Column(wxCommandEvent &ev)
|
||||
{
|
||||
|
|
@ -2058,7 +2069,7 @@ void frmQuery::SaveTempFile()
|
|||
wxString pref=conn->GetDbname();
|
||||
//if (filename.StartsWith(pref))
|
||||
filename+=wxT(".a");
|
||||
wxString tempDir=wxStandardPaths::Get().GetTempDir()+wxT("\\pgadmin3");
|
||||
wxString tempDir=wxStandardPaths::Get().GetUserConfigDir()+wxT("\\postgresql\\recovery");
|
||||
wxUtfFile file(tempDir+wxT("\\")+filename, wxFile::write, modeUnicode ? wxFONTENCODING_UTF8 : wxFONTENCODING_DEFAULT);
|
||||
if (file.IsOpened())
|
||||
{
|
||||
|
|
@ -3937,7 +3948,7 @@ void frmQuery::OnSqlBookTabRDown (wxAuiNotebookEvent &event) {
|
|||
pref,
|
||||
wxOK | wxCANCEL); //setName( dlg.GetValue().wc_str() );
|
||||
if (dialog.ShowModal() == wxID_OK) {
|
||||
wxString tempDir=wxStandardPaths::Get().GetTempDir()+wxT("\\pgadmin3\\");
|
||||
wxString tempDir=wxStandardPaths::Get().GetUserConfigDir()+wxT("\\postgresql\\recovery\\");
|
||||
wxString filename=sqlQuery->GetTitle(false);
|
||||
wxRemoveFile(tempDir+filename+wxT(".a"));
|
||||
wxString nt=dialog.GetValue();
|
||||
|
|
@ -3982,7 +3993,7 @@ void frmQuery::OnSqlBookPageClose(wxAuiNotebookEvent &event)
|
|||
|
||||
SqlBookDisconnectPage();
|
||||
//drop temp file
|
||||
wxString tempDir=wxStandardPaths::Get().GetTempDir()+wxT("\\pgadmin3\\");
|
||||
wxString tempDir=wxStandardPaths::Get().GetUserConfigDir()+wxT("\\postgresql\\recovery\\");
|
||||
wxString filename=sqlQuery->GetTitle(false)+wxT(".a");
|
||||
if (wxFileName::FileExists(tempDir+filename)) wxRemoveFile(tempDir+filename);
|
||||
|
||||
|
|
@ -4063,7 +4074,7 @@ bool frmQuery::SqlBookRemovePage()
|
|||
|
||||
SqlBookDisconnectPage();
|
||||
pageidx = sqlQueryBook->GetSelection();
|
||||
wxString tempDir=wxStandardPaths::Get().GetTempDir()+wxT("\\pgadmin3\\");
|
||||
wxString tempDir=wxStandardPaths::Get().GetUserConfigDir()+wxT("\\postgresql\\recovery\\");
|
||||
ctlSQLBox *box;
|
||||
box = wxDynamicCast(sqlQueryBook->GetPage(pageidx), ctlSQLBox);
|
||||
wxString filename=box->GetTitle(false);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public:
|
|||
{
|
||||
return false;
|
||||
}
|
||||
int Copy();
|
||||
int Copy(bool gensql);
|
||||
|
||||
virtual bool CheckRowPresent(int row)
|
||||
{
|
||||
|
|
@ -46,7 +46,7 @@ public:
|
|||
wxString GetRowLabelValue( int row );
|
||||
void SetRowGroup(int row);
|
||||
GroupRows *grp;
|
||||
|
||||
bool generatesql;
|
||||
WX_DECLARE_STRING_HASH_MAP( int, ColKeySizeHashMap );
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(ctlSQLGrid)
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ private:
|
|||
void OnPaste(wxCommandEvent &event);
|
||||
void OnClear(wxCommandEvent &event);
|
||||
void OnSummary_Column(wxCommandEvent &event);
|
||||
void OnCopy_Insert(wxCommandEvent &event);
|
||||
void OnSearchReplace(wxCommandEvent &event);
|
||||
void OnUndo(wxCommandEvent &event);
|
||||
void OnRedo(wxCommandEvent &event);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ enum
|
|||
MNU_TIMING,
|
||||
MNU_AUTOSELECTQUERY,
|
||||
MNU_SUMMARY_COL,
|
||||
MNU_COPY_INSERT,
|
||||
MNU_AUTOROLLBACK,
|
||||
MNU_AUTOCOMMIT,
|
||||
MNU_CLEARHISTORY,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue