GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DbStructureModel: Also send table data when dragging one · feng2010java/sqlitebrowser@16b5be4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • DbStructureModel.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/DbStructureModel.cpp‎

Copy file name to clipboardExpand all lines: src/DbStructureModel.cpp
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "DbStructureModel.h"
22
#include "sqlitedb.h"
3+
#include "sqlitetablemodel.h"
34
#include <QTreeWidgetItem>
45
#include <QMimeData>
56
#include <QMessageBox>
@@ -183,7 +184,26 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const
183184
{
184185
// Only export data for valid indices and only for the SQL column, i.e. only once per row
185186
if(index.isValid() && index.column() == 3)
187+
{
188+
// Add the SQL code used to create the object
186189
d = d.append(data(index, Qt::DisplayRole).toString() + ";\n");
190+
191+
// If it is a table also add the content
192+
if(data(index.sibling(index.row(), 1), Qt::DisplayRole).toString() == "table")
193+
{
194+
SqliteTableModel tableModel(0, m_db);
195+
tableModel.setTable(data(index.sibling(index.row(), 0), Qt::DisplayRole).toString());
196+
for(int i=0;i<tableModel.rowCount();i++)
197+
{
198+
QString insertStatement = "INSERT INTO `" + data(index.sibling(index.row(), 0), Qt::DisplayRole).toString() + "` VALUES(";
199+
for(int j=1;j<tableModel.columnCount();j++)
200+
insertStatement += QString("'%1',").arg(tableModel.data(tableModel.index(i, j)).toString());
201+
insertStatement.chop(1);
202+
insertStatement += ");\n";
203+
d = d.append(insertStatement);
204+
}
205+
}
206+
}
187207
}
188208

189209
// Create the MIME data object

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.