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_
|
#define _WX_QT_CONVERTER_H_
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include <QtCore/Qt>
|
|
||||||
|
|
||||||
#include "wx/kbdstate.h"
|
#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
|
// Rely on overloading and let the compiler pick the correct version, which makes
|
||||||
// them easier to use then to write wxQtConvertQtRectToWxRect() or wxQtConvertWxRectToQtRect()
|
// them easier to use then to write wxQtConvertQtRectToWxRect() or wxQtConvertWxRectToQtRect()
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxPoint;
|
inline wxPoint wxQtConvertPoint( const QPoint &point )
|
||||||
class QPoint;
|
{
|
||||||
wxPoint wxQtConvertPoint( const QPoint &point );
|
return wxPoint( point.x(), point.y() );
|
||||||
QPoint wxQtConvertPoint( const wxPoint &point );
|
}
|
||||||
|
inline QPoint wxQtConvertPoint( const wxPoint &point )
|
||||||
|
{
|
||||||
|
return QPoint( point.x, point.y );
|
||||||
|
}
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxRect;
|
inline wxRect wxQtConvertRect( const QRect &rect )
|
||||||
class QRect;
|
{
|
||||||
wxRect wxQtConvertRect( const QRect &rect );
|
return wxRect( rect.x(), rect.y(), rect.width(), rect.height() );
|
||||||
QRect wxQtConvertRect( const wxRect &rect );
|
}
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_BASE wxString;
|
inline QRect wxQtConvertRect( const wxRect &rect )
|
||||||
class QString;
|
{
|
||||||
wxString wxQtConvertString( const QString &str );
|
return QRect( rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight() );
|
||||||
QString wxQtConvertString( const wxString &str );
|
}
|
||||||
|
|
||||||
|
// 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
|
#if wxUSE_DATETIME
|
||||||
|
|
||||||
@@ -44,10 +64,14 @@ QDate wxQtConvertDate(const wxDateTime& date);
|
|||||||
|
|
||||||
#endif // wxUSE_DATETIME
|
#endif // wxUSE_DATETIME
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_BASE wxSize;
|
inline wxSize wxQtConvertSize( const QSize &size )
|
||||||
class QSize;
|
{
|
||||||
wxSize wxQtConvertSize( const QSize &size );
|
return wxSize(size.width(), size.height());
|
||||||
QSize wxQtConvertSize( const wxSize &size );
|
}
|
||||||
|
inline QSize wxQtConvertSize( const wxSize &size )
|
||||||
|
{
|
||||||
|
return QSize(size.GetWidth(), size.GetHeight());
|
||||||
|
}
|
||||||
|
|
||||||
Qt::Orientation wxQtConvertOrientation( long style, wxOrientation defaultOrientation );
|
Qt::Orientation wxQtConvertOrientation( long style, wxOrientation defaultOrientation );
|
||||||
wxOrientation wxQtConvertOrientation( Qt::Orientation );
|
wxOrientation wxQtConvertOrientation( Qt::Orientation );
|
||||||
|
@@ -13,61 +13,14 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QtCore/QRect>
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtGui/QFont>
|
#include <QtGui/QFont>
|
||||||
#include <QtCore/QSize>
|
|
||||||
|
|
||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
#include "wx/datetime.h"
|
#include "wx/datetime.h"
|
||||||
#include <QtCore/QDate>
|
#include <QtCore/QDate>
|
||||||
#endif // wxUSE_DATETIME
|
#endif // wxUSE_DATETIME
|
||||||
|
|
||||||
#include "wx/kbdstate.h"
|
#include "wx/qt/private/converter.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() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
@@ -92,22 +45,6 @@ QDate wxQtConvertDate(const wxDateTime& date)
|
|||||||
|
|
||||||
#endif // wxUSE_DATETIME
|
#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 )
|
Qt::Orientation wxQtConvertOrientation( long style, wxOrientation defaultOrientation )
|
||||||
{
|
{
|
||||||
if (( style & ( wxHORIZONTAL | wxVERTICAL )) == 0 )
|
if (( style & ( wxHORIZONTAL | wxVERTICAL )) == 0 )
|
||||||
|
Reference in New Issue
Block a user