Exemple #1
0
void DateEdit::stepBy(int steps)
{
    if( currentSection()==QDateTimeEdit::DaySection )
        setDate(date().addDays(steps));
    else if( currentSection()==QDateTimeEdit::MonthSection )
        setDate(date().addMonths(steps));
    else if( currentSection()==QDateTimeEdit::YearSection )
        setDate(date().addYears(steps));
}
void cQDateTimeEdit::stepBy(int steps) {
    qint64 Current=QTime(0,0,0,0).msecsTo(time());
    qint64 NewTime=Current;
    if          (currentSection()==QDateTimeEdit::MSecSection)   NewTime=(qint64(qreal(Current)/MsecStep)+steps)*MsecStep;
        else if (currentSection()==QDateTimeEdit::SecondSection) NewTime=qint64(qreal(Current+   1000*steps)/MsecStep)*MsecStep;
        else if (currentSection()==QDateTimeEdit::MinuteSection) NewTime=qint64(qreal(Current+  60000*steps)/MsecStep)*MsecStep;
        else if (currentSection()==QDateTimeEdit::HourSection)   NewTime=qint64(qreal(Current+3600000*steps)/MsecStep)*MsecStep;
    if (NewTime<0) NewTime=0;
    if (NewTime>QTime(0,0,0,0).msecsTo(maximumTime())) NewTime=QTime(0,0,0,0).msecsTo(maximumTime());
    setTime(QTime(0,0,0,0).addMSecs(NewTime));
}
void QgsDateTimeEdit::resetBeforeChange( int delta )
{
  QDateTime dt = QDateTime::currentDateTime();
  switch ( currentSection() )
  {
    case QDateTimeEdit::DaySection:
      dt = dt.addDays( delta );
      break;
    case QDateTimeEdit::MonthSection:
      dt = dt.addMonths( delta );
      break;
    case QDateTimeEdit::YearSection:
      dt = dt.addYears( delta );
      break;
    default:
      break;
  }
  if ( dt < minimumDateTime() )
  {
    dt = minimumDateTime();
  }
  else if ( dt > maximumDateTime() )
  {
    dt = maximumDateTime();
  }
  QDateTimeEdit::setDateTime( dt );
}
AbstractOptionStorage *
OptionsAssigner::Impl::findOption(const char *name)
{
    GMX_RELEASE_ASSERT(currentOption_ == nullptr,
                       "Cannot search for another option while processing one");
    const Section         &section = currentSection();
    AbstractOptionStorage *option  = section.findOption(name);
    if (option == nullptr && bAcceptBooleanNoPrefix_)
    {
        if (name[0] == 'n' && name[1] == 'o')
        {
            option = section.findOption(name + 2);
            if (option != nullptr && option->isBoolean())
            {
                reverseBoolean_ = true;
            }
            else
            {
                option = nullptr;
            }
        }
    }
    return option;
}
int QDateTimeEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractSpinBox::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 7)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 7;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QDateTime*>(_v) = dateTime(); break;
        case 1: *reinterpret_cast< QDate*>(_v) = date(); break;
        case 2: *reinterpret_cast< QTime*>(_v) = time(); break;
        case 3: *reinterpret_cast< QDateTime*>(_v) = maximumDateTime(); break;
        case 4: *reinterpret_cast< QDateTime*>(_v) = minimumDateTime(); break;
        case 5: *reinterpret_cast< QDate*>(_v) = maximumDate(); break;
        case 6: *reinterpret_cast< QDate*>(_v) = minimumDate(); break;
        case 7: *reinterpret_cast< QTime*>(_v) = maximumTime(); break;
        case 8: *reinterpret_cast< QTime*>(_v) = minimumTime(); break;
        case 9: *reinterpret_cast< Section*>(_v) = currentSection(); break;
        case 10: *reinterpret_cast<int*>(_v) = QFlag(displayedSections()); break;
        case 11: *reinterpret_cast< QString*>(_v) = displayFormat(); break;
        case 12: *reinterpret_cast< bool*>(_v) = calendarPopup(); break;
        case 13: *reinterpret_cast< int*>(_v) = currentSectionIndex(); break;
        case 14: *reinterpret_cast< int*>(_v) = sectionCount(); break;
        case 15: *reinterpret_cast< Qt::TimeSpec*>(_v) = timeSpec(); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDateTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 1: setDate(*reinterpret_cast< QDate*>(_v)); break;
        case 2: setTime(*reinterpret_cast< QTime*>(_v)); break;
        case 3: setMaximumDateTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 4: setMinimumDateTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 5: setMaximumDate(*reinterpret_cast< QDate*>(_v)); break;
        case 6: setMinimumDate(*reinterpret_cast< QDate*>(_v)); break;
        case 7: setMaximumTime(*reinterpret_cast< QTime*>(_v)); break;
        case 8: setMinimumTime(*reinterpret_cast< QTime*>(_v)); break;
        case 9: setCurrentSection(*reinterpret_cast< Section*>(_v)); break;
        case 11: setDisplayFormat(*reinterpret_cast< QString*>(_v)); break;
        case 12: setCalendarPopup(*reinterpret_cast< bool*>(_v)); break;
        case 13: setCurrentSectionIndex(*reinterpret_cast< int*>(_v)); break;
        case 15: setTimeSpec(*reinterpret_cast< Qt::TimeSpec*>(_v)); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 3: clearMaximumDateTime(); break;
        case 4: clearMinimumDateTime(); break;
        case 5: clearMaximumDate(); break;
        case 6: clearMinimumDate(); break;
        case 7: clearMaximumTime(); break;
        case 8: clearMinimumTime(); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 16;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
AbstractOptionStorage *
OptionsAssigner::Impl::findOption(const char *name)
{
    GMX_RELEASE_ASSERT(_currentOption == NULL,
                       "Cannot search for another option while processing one");
    AbstractOptionStorage *option = NULL;
    Options *section = NULL;
    Options *root = &currentSection();
    Options *oldRoot = NULL;
    int      upcount = 0;
    std::deque<Options *> searchList;
    searchList.push_back(root);
    while (option == NULL && !searchList.empty())
    {
        section = searchList.front();
        option = section->_impl->findOption(name);
        if (option == NULL && hasFlag(efAcceptBooleanNoPrefix))
        {
            if (name[0] == 'n' && name[1] == 'o')
            {
                option = section->_impl->findOption(name + 2);
                if (option != NULL && option->isBoolean())
                {
                    _reverseBoolean = true;
                }
                else
                {
                    option = NULL;
                }
            }
        }
        searchList.pop_front();
        if (hasFlag(efNoStrictSectioning))
        {
            Options::Impl::SubSectionList::const_iterator i;
            for (i = section->_impl->_subSections.begin();
                 i != section->_impl->_subSections.end(); ++i)
            {
                if (*i != oldRoot)
                {
                    searchList.push_back(*i);
                }
            }
            if (searchList.empty() && root != &_options)
            {
                Options *oldRoot = root;
                root = root->_impl->_parent;
                ++upcount;
                searchList.push_back(root);
            }
        }
    }
    if (hasFlag(efNoStrictSectioning) && option != NULL)
    {
        while (upcount > 0)
        {
            _sectionStack.pop_back();
            --upcount;
        }
        std::vector<Options *> sections;
        while (section != &currentSection())
        {
            sections.push_back(section);
            section = section->_impl->_parent;
        }
        while (!sections.empty())
        {
            _sectionStack.push_back(sections.back());
            sections.pop_back();
        }
    }
    return option;
}
 QGLSection *section() { return currentSection(); }