mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 19:11:39 -06:00
Drag and drop feature of a db file implemented: Arvind Kumar
This commit is contained in:
52
sqlitebrowser/sqlitebrowser/extendedmainform.cpp
Normal file
52
sqlitebrowser/sqlitebrowser/extendedmainform.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Arvind Kumar *
|
||||
* arvind.your@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "extendedmainform.h"
|
||||
#include <QUrl>
|
||||
|
||||
ExtendedMainForm::ExtendedMainForm(QWidget* parent, const char* name, Qt::WindowFlags fl) : mainForm( parent, name, fl )
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
ExtendedMainForm::~ExtendedMainForm(void)
|
||||
{
|
||||
}
|
||||
|
||||
void ExtendedMainForm::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if( event->mimeData()->hasFormat("text/uri-list") )
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
|
||||
void ExtendedMainForm::dropEvent(QDropEvent *event)
|
||||
{
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
|
||||
if( urls.isEmpty() )
|
||||
return;
|
||||
|
||||
QString fileName = urls.first().toLocalFile();
|
||||
|
||||
if( !fileName.isEmpty() && fileName.endsWith("db") )
|
||||
fileOpen(fileName);
|
||||
}
|
||||
|
||||
39
sqlitebrowser/sqlitebrowser/extendedmainform.h
Normal file
39
sqlitebrowser/sqlitebrowser/extendedmainform.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2009 by Arvind Kumar *
|
||||
* arvind.your@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __EXTENDEDMAINFORM__
|
||||
#define __EXTENDEDMAINFORM__
|
||||
|
||||
#include "form1.h"
|
||||
#include <QDragEnterEvent>
|
||||
|
||||
class ExtendedMainForm : public mainForm
|
||||
{
|
||||
public:
|
||||
ExtendedMainForm(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);
|
||||
~ExtendedMainForm(void);
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
};
|
||||
|
||||
#endif // __EXTENDEDMAINFORM__
|
||||
|
||||
Reference in New Issue
Block a user