示例#1
0
QSize Spacer::sizeHint() const
{
    if ( parentWidget() && WidgetFactory::layoutType( parentWidget() ) != WidgetFactory::NoLayout &&
	 ( sizeType() == Fixed || sizeType() == Maximum ) )
	return size();
    return QSize( 20, 20 );
}
示例#2
0
void
Spring::setOrientation(Qt::Orientation orient)
{
    QSizePolicy::Policy policy = sizeType();
    m_orient = orient;
    setSizeType(policy);
    repaint();
}
    double ParserDoubleItem::getDefault() const {
        if (hasDefault())
            return m_default;

        if (sizeType() == Opm::ALL)
            return std::numeric_limits<double>::quiet_NaN();

        throw std::invalid_argument("No default value available for item "+name());
    }
示例#4
0
    int ParserIntItem::getDefault() const {
        if (hasDefault())
            return m_default;

        if (sizeType() == Opm::ALL)
            return -1;

        throw std::invalid_argument("No default value available for item "+name());
    }
示例#5
0
 bool ParserItem::equal(const ParserItem& other) const {
     if (typeid(this) == typeid(&other)) {
         if ((name() == other.name()) && (sizeType() == other.sizeType()))
             return true;
         else
             return false;
     }
     else
         return false;
 }
示例#6
0
void Spacer::setOrientation( Qt::Orientation o )
{
    if ( orient == o )
 	return;
	
    SizeType st = sizeType();
    orient = o;
    setSizeType( st );
    if ( ar )
	resize( QSize( size().height(), size().width() ) );
    updateMask();
    update();
    updateGeometry();
}
示例#7
0
    /// Scans the rawRecords data according to the ParserItems definition.
    /// returns a DeckItem object.
    /// NOTE: data are popped from the rawRecords deque!
    DeckItemPtr ParserIntItem::scan(RawRecordPtr rawRecord) const {
        DeckIntItemPtr deckItem(new DeckIntItem( name() , scalar() ));
        int defaultValue = m_default;

        if (sizeType() == ALL) {  
            // The '*' should be interpreted either as a default indicator in the cases '*' and '5*'
            // or as multiplier in the case: '5*99'. 
            while (rawRecord->size() > 0) {
                std::string token = rawRecord->pop_front();
                if (tokenContainsStar( token )) {
                    StarToken<int> st(token);
                    int value = defaultValue;    
                    if (st.hasValue())
                        value = st.value();
                    deckItem->push_backMultiple( value , st.multiplier() );
                } else {
                    int value = readValueToken<int>(token);
                    deckItem->push_back(value);
                }
            }
        } else {
            // The '*' should be interpreted as a default indicator
            if (rawRecord->size() > 0) {
                std::string token = rawRecord->pop_front();
                if (tokenContainsStar( token )) {
                    StarToken<int> st(token);
        
                    if (st.hasValue()) { // Probably never true
                        deckItem->push_back( st.value() ); 
                        std::string stringValue = boost::lexical_cast<std::string>(st.value());
                        for (size_t i=1; i < st.multiplier(); i++)
                            rawRecord->push_front( stringValue );
                    } else {
                        deckItem->push_backDefault( defaultValue );
                        for (size_t i=1; i < st.multiplier(); i++)
                            rawRecord->push_front( "*" );
                    }
                } else {
                    int value = readValueToken<int>(token);
                    deckItem->push_back(value);
                }
            } else
                deckItem->push_backDefault( defaultValue );
        }
        return deckItem;
    }
示例#8
0
    /// Scans the rawRecords data according to the ParserItems definition.
    /// returns a DeckItem object.
    /// NOTE: data are popped from the rawRecords deque!
    DeckItemPtr ParserFloatItem::scan(RawRecordPtr rawRecord) const {
        DeckFloatItemPtr deckItem(new DeckFloatItem(name()));
        float defaultValue = m_default;

        if (sizeType() == ALL) {  // This can probably not be combined with a default value ....
            // The '*' should be interpreted as a multiplication sign
            while (rawRecord->size() > 0) {
                std::string token = rawRecord->pop_front();
                if (tokenContainsStar( token )) {
                    StarToken<float> st(token);
                    float value = defaultValue;    // This probably does never apply
                    if (st.hasValue())
                        value = st.value();
                    deckItem->push_backMultiple( value , st.multiplier() );
                } else {
                    float value = readValueToken<float>(token);
                    deckItem->push_back(value);
                }
            }
        } else {
            // The '*' should be interpreted as a default indicator
            if (rawRecord->size() > 0) {
                std::string token = rawRecord->pop_front();
                if (tokenContainsStar( token )) {
                    StarToken<float> st(token);

                    if (st.hasValue()) { // Probably never true
                        deckItem->push_back( st.value() );
                        std::string stringValue = boost::lexical_cast<std::string>(st.value());
                        for (size_t i=1; i < st.multiplier(); i++)
                            rawRecord->push_front( stringValue );
                    } else {
                        deckItem->push_backDefault( defaultValue );
                        for (size_t i=1; i < st.multiplier(); i++)
                            rawRecord->push_front( "*" );
                    }
                } else {
                    float value = readValueToken<float>(token);
                    deckItem->push_back(value);
                }
            } else
                deckItem->push_backDefault( defaultValue );
        }
        return deckItem;
    }
void Spacer::setOrientation(Qt::Orientation o)
{
    if (m_orientation == o)
        return;

    const QSizePolicy::Policy st = sizeType(); // flip size type
    m_orientation = o;
    setSizeType(st);

    if (m_interactive) {
        m_sizeHint = QSize(m_sizeHint.height(), m_sizeHint.width());
        if (!isInLayout())
            resize(m_sizeHint + m_SizeOffset);
    }

    updateMask();
    update();
    updateGeometry();
}
示例#10
0
 void ParserFloatItem::inlineNew(std::ostream& os) const {
       os << "new ParserFloatItem(" << "\"" << name() << "\"" << "," << ParserItemSizeEnum2String( sizeType() );
       if (m_defaultSet)
           os << "," << getDefault();
       os << ")";
   }
示例#11
0
    void ParserFloatItem::push_backDimension(const std::string& dimension) {
        if ((sizeType() == SINGLE) && (m_dimensions.size() > 0))
            throw std::invalid_argument("Internal error - can not add more than one dimension to a Item os size 1");

        m_dimensions.push_back( dimension );
    }
    std::string ParserDoubleItem::createCode() const {
        std::stringstream ss;

        ss << "new ParserDoubleItem(" << "\"" << name() << "\"" << ",Opm::" << ParserItemSizeEnum2String( sizeType() );
        if (m_defaultSet)
            ss << "," << boost::lexical_cast<std::string>(getDefault());
        ss << ")";

        return ss.str();
    }
示例#13
0
    std::string ParserIntItem::createCode() const {
        std::stringstream ss;

        ss << "new ParserIntItem(" << "\"" << name() << "\"" << ",Opm::" << ParserItemSizeEnum2String( sizeType() );
        if (m_defaultSet)
            ss << "," << getDefault();
        ss << ")";

        return ss.str();
    }
示例#14
0
 void ParserIntItem::setDefault(int defaultValue) {
     if (sizeType() == ALL)
         throw std::invalid_argument("The size type ALL can not be combined with an explicit default value");
     m_defaultSet = true;
     m_default = defaultValue;
 }