Support drag and drop on tables with schema != "main"

This improves commit 44eb2d4f99 so that
drag and drop of data on temporary tables is supported as well.
This commit is contained in:
Martin Kleusberg
2017-09-03 21:49:32 +02:00
parent 44eb2d4f99
commit fbaf78ea65

View File

@@ -183,11 +183,12 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const
if(data(index.sibling(index.row(), ColumnObjectType), Qt::DisplayRole).toString() == "table")
{
SqliteTableModel tableModel(m_db);
tableModel.setTable(sqlb::ObjectIdentifier(data(index.sibling(index.row(), ColumnSchema), Qt::DisplayRole).toString(),
data(index.sibling(index.row(), ColumnName), Qt::DisplayRole).toString()));
sqlb::ObjectIdentifier objid(data(index.sibling(index.row(), ColumnSchema), Qt::DisplayRole).toString(),
data(index.sibling(index.row(), ColumnName), Qt::DisplayRole).toString());
tableModel.setTable(objid);
for(int i=0; i < tableModel.rowCount(); ++i)
{
QString insertStatement = "INSERT INTO " + sqlb::escapeIdentifier(data(index.sibling(index.row(), ColumnName), Qt::DisplayRole).toString()) + " VALUES(";
QString insertStatement = "INSERT INTO " + objid.toString() + " VALUES(";
for(int j=1; j < tableModel.columnCount(); ++j)
insertStatement += QString("'%1',").arg(tableModel.data(tableModel.index(i, j)).toString());
insertStatement.chop(1);