Merge branch 'qt-convert-simplify'
Simplify Qt conversion functions and stop mapping wxPoint(-1,-1) and wxSize(-1,-1) to QPoint(0,0) and QSize(0,0), respectively. See https://github.com/wxWidgets/wxWidgets/pull/1206
This commit is contained in:
@@ -12,27 +12,47 @@
|
||||
#define _WX_QT_CONVERTER_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include <QtCore/Qt>
|
||||
|
||||
#include "wx/kbdstate.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtCore/QSize>
|
||||
#include <QtCore/QString>
|
||||
|
||||
// Rely on overloading and let the compiler pick the correct version, which makes
|
||||
// them easier to use then to write wxQtConvertQtRectToWxRect() or wxQtConvertWxRectToQtRect()
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxPoint;
|
||||
class QPoint;
|
||||
wxPoint wxQtConvertPoint( const QPoint &point );
|
||||
QPoint wxQtConvertPoint( const wxPoint &point );
|
||||
inline wxPoint wxQtConvertPoint( const QPoint &point )
|
||||
{
|
||||
return wxPoint( point.x(), point.y() );
|
||||
}
|
||||
inline QPoint wxQtConvertPoint( const wxPoint &point )
|
||||
{
|
||||
return QPoint( point.x, point.y );
|
||||
}
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxRect;
|
||||
class QRect;
|
||||
wxRect wxQtConvertRect( const QRect &rect );
|
||||
QRect wxQtConvertRect( const wxRect &rect );
|
||||
inline wxRect wxQtConvertRect( const QRect &rect )
|
||||
{
|
||||
return wxRect( rect.x(), rect.y(), rect.width(), rect.height() );
|
||||
}
|
||||
|
||||
class WXDLLIMPEXP_FWD_BASE wxString;
|
||||
class QString;
|
||||
wxString wxQtConvertString( const QString &str );
|
||||
QString wxQtConvertString( const wxString &str );
|
||||
inline QRect wxQtConvertRect( const wxRect &rect )
|
||||
{
|
||||
return QRect( rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight() );
|
||||
}
|
||||
|
||||
// TODO: Check whether QString::toStdString/QString::toStdWString might be faster
|
||||
|
||||
inline wxString wxQtConvertString( const QString &str )
|
||||
{
|
||||
return wxString( str.toUtf8().data(), wxConvUTF8 );
|
||||
}
|
||||
|
||||
inline QString wxQtConvertString( const wxString &str )
|
||||
{
|
||||
return QString( str.utf8_str() );
|
||||
}
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
|
||||
@@ -44,10 +64,14 @@ QDate wxQtConvertDate(const wxDateTime& date);
|
||||
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
class WXDLLIMPEXP_FWD_BASE wxSize;
|
||||
class QSize;
|
||||
wxSize wxQtConvertSize( const QSize &size );
|
||||
QSize wxQtConvertSize( const wxSize &size );
|
||||
inline wxSize wxQtConvertSize( const QSize &size )
|
||||
{
|
||||
return wxSize(size.width(), size.height());
|
||||
}
|
||||
inline QSize wxQtConvertSize( const wxSize &size )
|
||||
{
|
||||
return QSize(size.GetWidth(), size.GetHeight());
|
||||
}
|
||||
|
||||
Qt::Orientation wxQtConvertOrientation( long style, wxOrientation defaultOrientation );
|
||||
wxOrientation wxQtConvertOrientation( Qt::Orientation );
|
||||
|
@@ -13,61 +13,14 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtCore/QSize>
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
#include "wx/datetime.h"
|
||||
#include <QtCore/QDate>
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
#include "wx/kbdstate.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
|
||||
wxPoint wxQtConvertPoint( const QPoint &point )
|
||||
{
|
||||
if (point.isNull())
|
||||
return wxDefaultPosition;
|
||||
|
||||
return wxPoint( point.x(), point.y() );
|
||||
}
|
||||
|
||||
QPoint wxQtConvertPoint( const wxPoint &point )
|
||||
{
|
||||
if (point == wxDefaultPosition)
|
||||
return QPoint();
|
||||
|
||||
return QPoint( point.x, point.y );
|
||||
}
|
||||
|
||||
|
||||
QRect wxQtConvertRect( const wxRect &rect )
|
||||
{
|
||||
return QRect( rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight() );
|
||||
}
|
||||
|
||||
wxRect wxQtConvertRect( const QRect &rect )
|
||||
{
|
||||
return wxRect( rect.x(), rect.y(), rect.width(), rect.height() );
|
||||
}
|
||||
|
||||
// TODO: Check whether QString::toStdString/QString::toStdWString might be faster
|
||||
|
||||
wxString wxQtConvertString( const QString &str )
|
||||
{
|
||||
return wxString( str.toUtf8().data(), wxConvUTF8 );
|
||||
}
|
||||
|
||||
QString wxQtConvertString( const wxString &str )
|
||||
{
|
||||
return QString( str.utf8_str() );
|
||||
}
|
||||
|
||||
|
||||
#include "wx/qt/private/converter.h"
|
||||
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
@@ -92,22 +45,6 @@ QDate wxQtConvertDate(const wxDateTime& date)
|
||||
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
wxSize wxQtConvertSize( const QSize &size )
|
||||
{
|
||||
if (size.isNull())
|
||||
return wxDefaultSize;
|
||||
|
||||
return wxSize(size.width(), size.height());
|
||||
}
|
||||
|
||||
QSize wxQtConvertSize( const wxSize &size )
|
||||
{
|
||||
if (size == wxDefaultSize)
|
||||
return QSize();
|
||||
|
||||
return QSize(size.GetWidth(), size.GetHeight());
|
||||
}
|
||||
|
||||
Qt::Orientation wxQtConvertOrientation( long style, wxOrientation defaultOrientation )
|
||||
{
|
||||
if (( style & ( wxHORIZONTAL | wxVERTICAL )) == 0 )
|
||||
|
Reference in New Issue
Block a user