Source trigger patch file drop (#1236)

* Add Signal if File dropped

* Check if Index is valid

Send Signal and return if Index is invalid and File was dropped

* Connect Dropsignal to fileopen
This commit is contained in:
SourceTrigger
2017-11-20 21:05:47 +01:00
committed by Martin Kleusberg
parent 09e170f75d
commit 0a995423fa
3 changed files with 10 additions and 0 deletions

View File

@@ -543,6 +543,14 @@ void ExtendedTableWidget::dragMoveEvent(QDragMoveEvent* event)
void ExtendedTableWidget::dropEvent(QDropEvent* event)
{
QModelIndex index = indexAt(event->pos());
if (!index.isValid())
{
if (event->mimeData()->hasUrls() && event->mimeData()->urls().first().isLocalFile())
emit openFileFromDropEvent(event->mimeData()->urls().first().toLocalFile());
return;
}
model()->dropMimeData(event->mimeData(), Qt::CopyAction, index.row(), index.column(), QModelIndex());
event->acceptProposedAction();
}

View File

@@ -29,6 +29,7 @@ public slots:
signals:
void foreignKeyClicked(const sqlb::ObjectIdentifier& table, const QString& column, const QByteArray& value);
void switchTable(bool next); // 'next' parameter is set to true if next table should be selected and to false if previous table should be selected
void openFileFromDropEvent(QString);
private:
void copy(const bool withHeaders = false);

View File

@@ -252,6 +252,7 @@ void MainWindow::init()
connect(ui->dbTreeWidget->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(changeTreeSelection()));
connect(ui->dataTable->horizontalHeader(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showDataColumnPopupMenu(QPoint)));
connect(ui->dataTable->verticalHeader(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showRecordPopupMenu(QPoint)));
connect(ui->dataTable, SIGNAL(openFileFromDropEvent(QString)), this, SLOT(fileOpen(QString)));
connect(ui->dockEdit, SIGNAL(visibilityChanged(bool)), this, SLOT(toggleEditDock(bool)));
connect(m_remoteDb, SIGNAL(openFile(QString)), this, SLOT(fileOpen(QString)));
connect(m_remoteDb, &RemoteDatabase::gotCurrentVersion, this, &MainWindow::checkNewVersion);