Clean up the code a bit to follow the guidelines, including handling of default in switches and line length.
This commit is contained in:
@@ -17,7 +17,9 @@ public:
|
|||||||
virtual ~wxDropTarget();
|
virtual ~wxDropTarget();
|
||||||
|
|
||||||
virtual bool OnDrop(wxCoord x, wxCoord y) wxOVERRIDE;
|
virtual bool OnDrop(wxCoord x, wxCoord y) wxOVERRIDE;
|
||||||
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) wxOVERRIDE;
|
virtual wxDragResult OnData(wxCoord x,
|
||||||
|
wxCoord y,
|
||||||
|
wxDragResult def) wxOVERRIDE;
|
||||||
virtual bool GetData() wxOVERRIDE;
|
virtual bool GetData() wxOVERRIDE;
|
||||||
|
|
||||||
wxDataFormat GetMatchingPair();
|
wxDataFormat GetMatchingPair();
|
||||||
|
@@ -117,7 +117,7 @@ bool wxDataFormat::operator!=(const wxDataFormat& format) const
|
|||||||
return !operator==(format);
|
return !operator==(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#############################################################################
|
//############################################################################
|
||||||
|
|
||||||
wxDataObject::wxDataObject()
|
wxDataObject::wxDataObject()
|
||||||
{
|
{
|
||||||
@@ -127,7 +127,8 @@ wxDataObject::~wxDataObject()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) const
|
bool wxDataObject::IsSupportedFormat(const wxDataFormat& format,
|
||||||
|
Direction dir) const
|
||||||
{
|
{
|
||||||
const size_t formatCount = GetFormatCount(dir);
|
const size_t formatCount = GetFormatCount(dir);
|
||||||
if ( formatCount == 1 )
|
if ( formatCount == 1 )
|
||||||
@@ -147,7 +148,7 @@ bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#############################################################################
|
//############################################################################
|
||||||
|
|
||||||
wxBitmapDataObject::wxBitmapDataObject()
|
wxBitmapDataObject::wxBitmapDataObject()
|
||||||
{
|
{
|
||||||
@@ -160,7 +161,7 @@ wxBitmapDataObject::wxBitmapDataObject( const wxBitmap &WXUNUSED(bitmap) )
|
|||||||
//#############################################################################
|
//#############################################################################
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxTextDataObject
|
// wxTextDataObject
|
||||||
// ----------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
void wxTextDataObject::GetAllFormats(wxDataFormat *formats,
|
void wxTextDataObject::GetAllFormats(wxDataFormat *formats,
|
||||||
|
@@ -32,12 +32,14 @@ namespace
|
|||||||
case Qt::CopyAction:
|
case Qt::CopyAction:
|
||||||
return wxDragCopy;
|
return wxDragCopy;
|
||||||
case Qt::MoveAction:
|
case Qt::MoveAction:
|
||||||
|
case Qt::TargetMoveAction:
|
||||||
return wxDragMove;
|
return wxDragMove;
|
||||||
case Qt::LinkAction:
|
case Qt::LinkAction:
|
||||||
return wxDragLink;
|
return wxDragLink;
|
||||||
default:
|
|
||||||
return wxDragNone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFAIL_MSG("Illegal drop action");
|
||||||
|
return wxDragNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::DropAction DragResultToDropAction(wxDragResult result)
|
Qt::DropAction DragResultToDropAction(wxDragResult result)
|
||||||
@@ -50,12 +52,19 @@ namespace
|
|||||||
return Qt::MoveAction;
|
return Qt::MoveAction;
|
||||||
case wxDragLink:
|
case wxDragLink:
|
||||||
return Qt::LinkAction;
|
return Qt::LinkAction;
|
||||||
default:
|
case wxDragError:
|
||||||
|
case wxDragNone:
|
||||||
|
case wxDragCancel:
|
||||||
return Qt::IgnoreAction;
|
return Qt::IgnoreAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFAIL_MSG("Illegal drag result");
|
||||||
|
return Qt::IgnoreAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddDataFormat(wxDataObject* dataObject, QMimeData* mimeData, const wxDataFormat& format)
|
void AddDataFormat(wxDataObject* dataObject,
|
||||||
|
QMimeData* mimeData,
|
||||||
|
const wxDataFormat& format)
|
||||||
{
|
{
|
||||||
const size_t data_size = dataObject->GetDataSize(format);
|
const size_t data_size = dataObject->GetDataSize(format);
|
||||||
|
|
||||||
@@ -82,7 +91,9 @@ namespace
|
|||||||
return mimeData;
|
return mimeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDragCursor(QDrag& drag, const wxCursor& cursor, Qt::DropAction action)
|
void SetDragCursor(QDrag& drag,
|
||||||
|
const wxCursor& cursor,
|
||||||
|
Qt::DropAction action)
|
||||||
{
|
{
|
||||||
if ( cursor.IsOk() )
|
if ( cursor.IsOk() )
|
||||||
drag.setDragCursor(cursor.GetHandle().pixmap(), action);
|
drag.setDragCursor(cursor.GetHandle().pixmap(), action);
|
||||||
@@ -91,7 +102,8 @@ namespace
|
|||||||
class PendingMimeDataSetter
|
class PendingMimeDataSetter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PendingMimeDataSetter(const QMimeData*& targetMimeData, const QMimeData* mimeData)
|
PendingMimeDataSetter(const QMimeData*& targetMimeData,
|
||||||
|
const QMimeData* mimeData)
|
||||||
: m_targetMimeData(targetMimeData)
|
: m_targetMimeData(targetMimeData)
|
||||||
{
|
{
|
||||||
m_targetMimeData = mimeData;
|
m_targetMimeData = mimeData;
|
||||||
@@ -190,7 +202,11 @@ public:
|
|||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
const QPoint where = e->pos();
|
const QPoint where = e->pos();
|
||||||
const wxDragResult result = m_dropTarget->OnEnter(where.x(), where.y(), DropActionToDragResult(e->proposedAction()));
|
const wxDragResult proposedResult =
|
||||||
|
DropActionToDragResult(e->proposedAction());
|
||||||
|
const wxDragResult result = m_dropTarget->OnEnter(where.x(),
|
||||||
|
where.y(),
|
||||||
|
proposedResult);
|
||||||
|
|
||||||
e->setDropAction(DragResultToDropAction(result));
|
e->setDropAction(DragResultToDropAction(result));
|
||||||
}
|
}
|
||||||
@@ -210,7 +226,11 @@ public:
|
|||||||
const PendingMimeDataSetter setter(m_pendingMimeData, e->mimeData());
|
const PendingMimeDataSetter setter(m_pendingMimeData, e->mimeData());
|
||||||
|
|
||||||
const QPoint where = e->pos();
|
const QPoint where = e->pos();
|
||||||
const wxDragResult result = m_dropTarget->OnDragOver(where.x(), where.y(), DropActionToDragResult(e->proposedAction()));
|
const wxDragResult proposedResult =
|
||||||
|
DropActionToDragResult(e->proposedAction());
|
||||||
|
const wxDragResult result = m_dropTarget->OnDragOver(where.x(),
|
||||||
|
where.y(),
|
||||||
|
proposedResult);
|
||||||
|
|
||||||
e->setDropAction(DragResultToDropAction(result));
|
e->setDropAction(DragResultToDropAction(result));
|
||||||
}
|
}
|
||||||
@@ -226,7 +246,9 @@ public:
|
|||||||
const QPoint where = e->pos();
|
const QPoint where = e->pos();
|
||||||
if ( m_dropTarget->OnDrop(where.x(), where.y()) )
|
if ( m_dropTarget->OnDrop(where.x(), where.y()) )
|
||||||
{
|
{
|
||||||
m_dropTarget->OnData(where.x(), where.y(), DropActionToDragResult(e->dropAction()));
|
m_dropTarget->OnData(where.x(),
|
||||||
|
where.y(),
|
||||||
|
DropActionToDragResult(e->dropAction()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +285,9 @@ bool wxDropTarget::OnDrop(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDragResult wxDropTarget::OnData(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def)
|
wxDragResult wxDropTarget::OnData(wxCoord WXUNUSED(x),
|
||||||
|
wxCoord WXUNUSED(y),
|
||||||
|
wxDragResult def)
|
||||||
{
|
{
|
||||||
return GetData() ? def : wxDragNone;
|
return GetData() ? def : wxDragNone;
|
||||||
}
|
}
|
||||||
@@ -272,11 +296,12 @@ bool wxDropTarget::GetData()
|
|||||||
{
|
{
|
||||||
const wxDataFormat droppedFormat = GetMatchingPair();
|
const wxDataFormat droppedFormat = GetMatchingPair();
|
||||||
|
|
||||||
const wxString mimeType = droppedFormat.GetMimeType();
|
const wxString& mimeType = droppedFormat.GetMimeType();
|
||||||
if ( mimeType.empty() )
|
if ( mimeType.empty() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QByteArray data = m_pImpl->GetMimeData()->data(wxQtConvertString(mimeType));
|
const QString qMimeType = wxQtConvertString(mimeType);
|
||||||
|
const QByteArray data = m_pImpl->GetMimeData()->data(qMimeType);
|
||||||
|
|
||||||
return m_dataObject->SetData(droppedFormat, data.size(), data.data());
|
return m_dataObject->SetData(droppedFormat, data.size(), data.data());
|
||||||
}
|
}
|
||||||
@@ -310,7 +335,7 @@ void wxDropTarget::Disconnect()
|
|||||||
m_pImpl->Disconnect();
|
m_pImpl->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
//##############################################################################
|
//###########################################################################
|
||||||
|
|
||||||
wxDropSource::wxDropSource(wxWindow *win,
|
wxDropSource::wxDropSource(wxWindow *win,
|
||||||
const wxCursor ©,
|
const wxCursor ©,
|
||||||
@@ -334,8 +359,11 @@ wxDropSource::wxDropSource(wxDataObject& data,
|
|||||||
|
|
||||||
wxDragResult wxDropSource::DoDragDrop(int flags /*=wxDrag_CopyOnly*/)
|
wxDragResult wxDropSource::DoDragDrop(int flags /*=wxDrag_CopyOnly*/)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(m_data != NULL, wxDragNone, wxT("No data in wxDropSource!"));
|
wxCHECK_MSG(m_data != NULL, wxDragNone,
|
||||||
wxCHECK_MSG(m_parentWindow != NULL, wxDragNone, wxT("NULL parent window in wxDropSource!"));
|
wxT("No data in wxDropSource!"));
|
||||||
|
|
||||||
|
wxCHECK_MSG(m_parentWindow != NULL, wxDragNone,
|
||||||
|
wxT("NULL parent window in wxDropSource!"));
|
||||||
|
|
||||||
QDrag drag(m_parentWindow->GetHandle());
|
QDrag drag(m_parentWindow->GetHandle());
|
||||||
drag.setMimeData(CreateMimeData(m_data));
|
drag.setMimeData(CreateMimeData(m_data));
|
||||||
|
Reference in New Issue
Block a user