Qt 4.8
Classes | Enumerations | Functions
qabstractspinbox_p.h File Reference
#include "QtGui/qabstractspinbox.h"
#include "QtGui/qlineedit.h"
#include "QtGui/qstyleoption.h"
#include "QtGui/qvalidator.h"
#include "QtCore/qdatetime.h"
#include "QtCore/qvariant.h"
#include "private/qwidget_p.h"
#include "private/qdatetime_p.h"

Go to the source code of this file.

Classes

class  QAbstractSpinBoxPrivate
 
class  QSpinBoxValidator
 

Enumerations

enum  Button {
  Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4,
  Old_Abort = 5, Old_Retry = 6, Old_Ignore = 7, Old_YesAll = 8,
  Old_NoAll = 9, Old_ButtonMask = 0xFF, NewButtonMask = 0xFFFFFC00, None = 0x000,
  Keyboard = 0x001, Mouse = 0x002, Wheel = 0x004, ButtonMask = 0x008,
  Up = 0x010, Down = 0x020, DirectionMask = 0x040
}
 
enum  EmitPolicy { EmitIfChanged, AlwaysEmit, NeverEmit }
 

Functions

QVariant operator* (const QVariant &arg1, double multiplier)
 Multiplies arg1 by multiplier and returns the result. More...
 
QVariant operator+ (const QVariant &arg1, const QVariant &arg2)
 Adds two variants together and returns the result. More...
 
QVariant operator- (const QVariant &arg1, const QVariant &arg2)
 Subtracts two variants and returns the result. More...
 
double operator/ (const QVariant &arg1, const QVariant &arg2)
 

Enumeration Type Documentation

◆ Button

enum Button
Enumerator
Old_Ok 
Old_Cancel 
Old_Yes 
Old_No 
Old_Abort 
Old_Retry 
Old_Ignore 
Old_YesAll 
Old_NoAll 
Old_ButtonMask 
NewButtonMask 
None 
Keyboard 
Mouse 
Wheel 
ButtonMask 
Up 
Down 
DirectionMask 

Definition at line 81 of file qabstractspinbox_p.h.

81  {
82  None = 0x000,
83  Keyboard = 0x001,
84  Mouse = 0x002,
85  Wheel = 0x004,
86  ButtonMask = 0x008,
87  Up = 0x010,
88  Down = 0x020,
89  DirectionMask = 0x040
90 };

◆ EmitPolicy

enum EmitPolicy
Enumerator
EmitIfChanged 
AlwaysEmit 
NeverEmit 

Definition at line 75 of file qabstractspinbox_p.h.

Function Documentation

◆ operator*()

QVariant operator* ( const QVariant arg1,
double  multiplier 
)

Multiplies arg1 by multiplier and returns the result.

Warning
This function is not part of the public interface.

Definition at line 2111 of file qabstractspinbox.cpp.

2112 {
2113  QVariant ret;
2114 
2115  switch (arg1.type()) {
2116  case QVariant::Int: ret = QVariant((int)(arg1.toInt() * multiplier)); break;
2117  case QVariant::Double: ret = QVariant(arg1.toDouble() * multiplier); break;
2118  case QVariant::DateTime: {
2119  double days = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDateTime().date()) * multiplier;
2120  int daysInt = (int)days;
2121  days -= daysInt;
2122  long msecs = (long)((QDATETIMEEDIT_TIME_MIN.msecsTo(arg1.toDateTime().time()) * multiplier)
2123  + (days * (24 * 3600 * 1000)));
2124  ret = QDateTime(QDate().addDays(int(days)), QTime().addMSecs(msecs));
2125  break;
2126  }
2127  default: ret = arg1; break;
2128  }
2129 
2130  return ret;
2131 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
The QDate class provides date functions.
Definition: qdatetime.h:55
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QDATETIMEEDIT_DATE_MIN
Definition: qdatetime_p.h:69
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368

◆ operator+()

QVariant operator+ ( const QVariant arg1,
const QVariant arg2 
)

Adds two variants together and returns the result.

Warning
This function is not part of the public interface.

Definition at line 2045 of file qabstractspinbox.cpp.

2046 {
2047  QVariant ret;
2048  if (arg1.type() != arg2.type())
2049  qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)",
2050  arg1.typeName(), arg2.typeName(), __FILE__, __LINE__);
2051  switch (arg1.type()) {
2052  case QVariant::Int: ret = QVariant(arg1.toInt() + arg2.toInt()); break;
2053  case QVariant::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break;
2054  case QVariant::DateTime: {
2055  QDateTime a2 = arg2.toDateTime();
2056  QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATETIME_MIN.daysTo(a2));
2057  a1.setTime(a1.time().addMSecs(QTime().msecsTo(a2.time())));
2058  ret = QVariant(a1);
2059  }
2060  default: break;
2061  }
2062  return ret;
2063 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
The QTime class provides clock time functions.
Definition: qdatetime.h:148
void setTime(const QTime &time)
Sets the time part of this datetime to time.
Definition: qdatetime.cpp:2416
Q_CORE_EXPORT void qWarning(const char *,...)
const char * typeName() const
Returns the name of the type stored in the variant.
Definition: qvariant.cpp:1984
QDateTime addDays(int days) const
Returns a QDateTime object containing a datetime ndays days later than the datetime of this object (o...
Definition: qdatetime.cpp:2783
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QTime addMSecs(int ms) const
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earli...
Definition: qdatetime.cpp:1803
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368
#define QDATETIMEEDIT_DATETIME_MIN
Definition: qdatetime_p.h:72

◆ operator-()

QVariant operator- ( const QVariant arg1,
const QVariant arg2 
)

Subtracts two variants and returns the result.

Warning
This function is not part of the public interface.

Definition at line 2074 of file qabstractspinbox.cpp.

2075 {
2076  QVariant ret;
2077  if (arg1.type() != arg2.type())
2078  qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)",
2079  arg1.typeName(), arg2.typeName(), __FILE__, __LINE__);
2080  switch (arg1.type()) {
2081  case QVariant::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break;
2082  case QVariant::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break;
2083  case QVariant::DateTime: {
2084  QDateTime a1 = arg1.toDateTime();
2085  QDateTime a2 = arg2.toDateTime();
2086  int days = a2.daysTo(a1);
2087  int secs = a2.secsTo(a1);
2088  int msecs = qMax(0, a1.time().msec() - a2.time().msec());
2089  if (days < 0 || secs < 0 || msecs < 0) {
2090  ret = arg1;
2091  } else {
2092  QDateTime dt = a2.addDays(days).addSecs(secs);
2093  if (msecs > 0)
2094  dt.setTime(dt.time().addMSecs(msecs));
2095  ret = QVariant(dt);
2096  }
2097  }
2098  default: break;
2099  }
2100  return ret;
2101 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDateTime addSecs(int secs) const
Returns a QDateTime object containing a datetime s seconds later than the datetime of this object (or...
Definition: qdatetime.cpp:2869
int daysTo(const QDateTime &) const
Returns the number of days from this datetime to the other datetime.
Definition: qdatetime.cpp:2894
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
int msec() const
Returns the millisecond part (0 to 999) of the time.
Definition: qdatetime.cpp:1611
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
void setTime(const QTime &time)
Sets the time part of this datetime to time.
Definition: qdatetime.cpp:2416
int secsTo(const QDateTime &) const
Returns the number of seconds from this datetime to the other datetime.
Definition: qdatetime.cpp:2914
Q_CORE_EXPORT void qWarning(const char *,...)
const char * typeName() const
Returns the name of the type stored in the variant.
Definition: qvariant.cpp:1984
QDateTime addDays(int days) const
Returns a QDateTime object containing a datetime ndays days later than the datetime of this object (o...
Definition: qdatetime.cpp:2783
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QTime addMSecs(int ms) const
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earli...
Definition: qdatetime.cpp:1803
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368

◆ operator/()

double operator/ ( const QVariant arg1,
const QVariant arg2 
)

Definition at line 2135 of file qabstractspinbox.cpp.

2136 {
2137  double a1 = 0;
2138  double a2 = 0;
2139 
2140  switch (arg1.type()) {
2141  case QVariant::Int:
2142  a1 = (double)arg1.toInt();
2143  a2 = (double)arg2.toInt();
2144  break;
2145  case QVariant::Double:
2146  a1 = arg1.toDouble();
2147  a2 = arg2.toDouble();
2148  break;
2149  case QVariant::DateTime:
2150  a1 = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDate());
2151  a2 = QDATETIMEEDIT_DATE_MIN.daysTo(arg2.toDate());
2152  a1 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg1.toDateTime().time()) / (long)(3600 * 24 * 1000);
2153  a2 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg2.toDateTime().time()) / (long)(3600 * 24 * 1000);
2154  default: break;
2155  }
2156 
2157  return (a1 != 0 && a2 != 0) ? (a1 / a2) : 0.0;
2158 }
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
#define QDATETIMEEDIT_TIME_MIN
Definition: qdatetime_p.h:67
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
#define QDATETIMEEDIT_DATE_MIN
Definition: qdatetime_p.h:69
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2311
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368