Drag and drop feature of a db file implemented: Arvind Kumar

This commit is contained in:
arvind_your
2009-06-28 03:34:49 +00:00
parent d42188ab20
commit eb48435c28
2 changed files with 91 additions and 0 deletions

View 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);
}

View 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__