IndexOutputPtr MockRAMDirectory::createOutput(const String& name)
 {
     SyncLock syncLock(this);
     if (crashed)
         boost::throw_exception(IOException(L"cannot createOutput after crash"));
     init();
     if (preventDoubleWrite && createdFiles.contains(name) && name != L"segments.gen")
         boost::throw_exception(IOException(L"file \"" + name + L"\" was already written to"));
     if (noDeleteOpenFile && openFiles.contains(name))
         boost::throw_exception(IOException(L"MockRAMDirectory: file \"" + name + L"\" is still open: cannot overwrite"));
     RAMFilePtr file(newLucene<RAMFile>(shared_from_this()));
     if (crashed)
         boost::throw_exception(IOException(L"cannot createOutput after crash"));
     unSyncedFiles.add(name);
     createdFiles.add(name);
     RAMFilePtr existing(fileMap.get(name));
     // Enforce write once
     if (existing && name != L"segments.gen" && preventDoubleWrite)
         boost::throw_exception(IOException(L"file " + name + L" already exists"));
     else
     {
         if (existing)
         {
             _sizeInBytes -= existing->getSizeInBytes();
             existing->_directory.reset();
         }
         fileMap.put(name, file);
     }
     
     return newLucene<MockRAMOutputStream>(shared_from_this(), file, name);
 }
예제 #2
0
void PaletteEditor::colourChanged()
{
    QColor qc = m_RGBWidget->colour();

    Colour c( qc.red(), qc.green(), qc.blue(), qc.alpha() );

    Colour existing( m_Proj.GetColour( m_Selected ) );

    if (c==existing) {
        return;
    }


    // if the last cmd was a modification of the same colour, we'll just amend it!
    // this lets us keep the project up-to-date as user twiddles the colour,
    // but also avoids clogging up the undo stack with insane numbers of operations.
    Cmd* cmd = m_Ed.TopCmd();
    if (cmd)
    {
        Cmd_PaletteModify* mod = cmd->ToPaletteModify();
        if (mod)
        {
            if (mod->Merge(m_Selected, c))
            {
                return;
            }
        }
    }
    
    // if we get this far we need a fresh cmd.
    cmd = new Cmd_PaletteModify(m_Proj, m_Selected, 1, &c);
    m_Ed.AddCmd(cmd);
}
void SeasideNameGroupModel::setRequiredProperty(int properties)
{
    if (m_requiredProperty != properties) {
        m_requiredProperty = properties;

        // Update counts
        QList<SeasideNameGroup>::iterator it = m_groups.begin(), end = m_groups.end();
        for ( ; it != end; ++it) {
            SeasideNameGroup &existing(*it);

            int newCount = countFilteredContacts(existing.contactIds);
            if (existing.count != newCount) {
                existing.count = newCount;

                const int row = it - m_groups.begin();
                const QModelIndex updateIndex(createIndex(row, 0));
                emit dataChanged(updateIndex, updateIndex);
            }
        }

        emit requiredPropertyChanged();
    }
}
예제 #4
0
void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate& update, const Element* animatingElement, Element& element, const ComputedStyle& style, ComputedStyle* parentStyle, StyleResolver* resolver)
{
    const ElementAnimations* elementAnimations = animatingElement ? animatingElement->elementAnimations() : nullptr;

    bool isAnimationStyleChange = elementAnimations && elementAnimations->isAnimationStyleChange();

#if !ENABLE(ASSERT)
    // If we're in an animation style change, no animations can have started, been cancelled or changed play state.
    // When ASSERT is enabled, we verify this optimization.
    if (isAnimationStyleChange)
        return;
#endif

    const CSSAnimationData* animationData = style.animations();
    const CSSAnimations* cssAnimations = elementAnimations ? &elementAnimations->cssAnimations() : nullptr;
    const Element* elementForScoping = animatingElement ? animatingElement : &element;

    HashSet<AtomicString> inactive;
    if (cssAnimations) {
        for (const auto& entry : cssAnimations->m_animations)
            inactive.add(entry.key);
    }

    if (style.display() != NONE) {
        for (size_t i = 0; animationData && i < animationData->nameList().size(); ++i) {
            AtomicString animationName(animationData->nameList()[i]);
            if (animationName == CSSAnimationData::initialName())
                continue;

            const bool isPaused = CSSTimingData::getRepeated(animationData->playStateList(), i) == AnimPlayStatePaused;

            Timing timing = animationData->convertToTiming(i);
            Timing specifiedTiming = timing;
            RefPtr<TimingFunction> keyframeTimingFunction = timing.timingFunction;
            timing.timingFunction = Timing::defaults().timingFunction;

            RefPtrWillBeRawPtr<StyleRuleKeyframes> keyframesRule = resolver->findKeyframesRule(elementForScoping, animationName);
            if (!keyframesRule)
                continue; // Cancel the animation if there's no style rule for it.

            if (cssAnimations) {
                AnimationMap::const_iterator existing(cssAnimations->m_animations.find(animationName));
                if (existing != cssAnimations->m_animations.end()) {
                    inactive.remove(animationName);

                    const RunningAnimation* runningAnimation = existing->value.get();
                    Animation* animation = runningAnimation->animation.get();

                    if (keyframesRule != runningAnimation->styleRule || keyframesRule->version() != runningAnimation->styleRuleVersion || runningAnimation->specifiedTiming != specifiedTiming) {
                        ASSERT(!isAnimationStyleChange);
                        update.updateAnimation(animationName, animation, InertEffect::create(
                            createKeyframeEffectModel(resolver, animatingElement, element, &style, parentStyle, animationName, keyframeTimingFunction.get(), i),
                            timing, isPaused, animation->unlimitedCurrentTimeInternal()), specifiedTiming, keyframesRule);
                    }

                    if (isPaused != animation->paused()) {
                        ASSERT(!isAnimationStyleChange);
                        update.toggleAnimationPaused(animationName);
                    }

                    continue;
                }
            }

            ASSERT(!isAnimationStyleChange);
            update.startAnimation(animationName, InertEffect::create(
                createKeyframeEffectModel(resolver, animatingElement, element, &style, parentStyle, animationName, keyframeTimingFunction.get(), i),
                timing, isPaused, 0), specifiedTiming, keyframesRule);
        }
    }

    ASSERT(inactive.isEmpty() || cssAnimations);
    for (const AtomicString& animationName : inactive) {
        ASSERT(!isAnimationStyleChange);
        update.cancelAnimation(animationName, *cssAnimations->m_animations.get(animationName)->animation);
    }
}
void SeasideNameGroupModel::nameGroupsUpdated(const QHash<QString, QSet<quint32> > &groups)
{
    if (groups.isEmpty())
        return;

    bool wasEmpty = m_groups.isEmpty();
    bool insertedRows = false;

    if (wasEmpty) {
        const QStringList &allGroups = SeasideCache::allNameGroups();
        if (!allGroups.isEmpty()) {
            beginInsertRows(QModelIndex(), 0, allGroups.count() - 1);
            for (int i=0; i<allGroups.count(); i++)
                m_groups << SeasideNameGroup(allGroups[i]);

            insertedRows = true;
        }
    }

    QHash<QString, QSet<quint32> >::const_iterator it = groups.constBegin(), end = groups.constEnd();
    for ( ; it != end; ++it) {
        const QString group(it.key());

        QList<SeasideNameGroup>::iterator existingIt = m_groups.begin(), existingEnd = m_groups.end();
        for ( ; existingIt != existingEnd; ++existingIt) {
            SeasideNameGroup &existing(*existingIt);
            if (existing.name == group) {
                existing.contactIds = it.value();
                const int count = countFilteredContacts(existing.contactIds);
                if (existing.count != count) {
                    existing.count = count;
                    if (!wasEmpty) {
                        const int row = existingIt - m_groups.begin();
                        const QModelIndex updateIndex(createIndex(row, 0));
                        emit dataChanged(updateIndex, updateIndex);
                    }
                }
                break;
            }
        }
        if (existingIt == existingEnd) {
            // Find the index of this group in the groups list
            const QStringList &allGroups = SeasideCache::allNameGroups();

            int allIndex = 0;
            int groupIndex = 0;
            for ( ; allGroups.at(allIndex) != group; ++allIndex) {
                if (m_groups.at(groupIndex).name == allGroups.at(allIndex)) {
                    ++groupIndex;
                }
            }
            if (allIndex < allGroups.count()) {
                // Insert this group
                beginInsertRows(QModelIndex(), groupIndex, groupIndex);
                m_groups.insert(groupIndex, SeasideNameGroup(group, it.value()));
                endInsertRows();

                insertedRows = true;
            } else {
                qWarning() << "Could not find unknown group in allGroups!" << group;
            }
        }
    }

    if (wasEmpty) {
        endInsertRows();
    }
    if (insertedRows) {
        emit countChanged();
    }
}
예제 #6
0
void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const Element* animatingElement, Element& element, const RenderStyle& style, RenderStyle* parentStyle, StyleResolver* resolver)
{
    const ActiveAnimations* activeAnimations = animatingElement ? animatingElement->activeAnimations() : nullptr;

#if !ENABLE(ASSERT)
    // If we're in an animation style change, no animations can have started, been cancelled or changed play state.
    // When ASSERT is enabled, we verify this optimization.
    if (activeAnimations && activeAnimations->isAnimationStyleChange())
        return;
#endif

    const CSSAnimationData* animationData = style.animations();
    const CSSAnimations* cssAnimations = activeAnimations ? &activeAnimations->cssAnimations() : nullptr;

    HashSet<AtomicString> inactive;
    if (cssAnimations) {
        for (const auto& entry : cssAnimations->m_animations)
            inactive.add(entry.key);
    }

    if (style.display() != NONE) {
        for (size_t i = 0; animationData && i < animationData->nameList().size(); ++i) {
            AtomicString animationName(animationData->nameList()[i]);
            if (animationName == CSSAnimationData::initialName())
                continue;

            bool isPaused = CSSTimingData::getRepeated(animationData->playStateList(), i) == AnimPlayStatePaused;

            // Keyframes and animation properties are snapshotted when the
            // animation starts, so we don't need to track changes to these,
            // with the exception of play-state.
            if (cssAnimations) {
                AnimationMap::const_iterator existing(cssAnimations->m_animations.find(animationName));
                if (existing != cssAnimations->m_animations.end()) {
                    inactive.remove(animationName);
                    AnimationPlayer* player = existing->value.get();
                    if (isPaused != player->paused()) {
                        ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange());
                        update->toggleAnimationPaused(animationName);
                    }
                    continue;
                }
            }

            Timing timing = animationData->convertToTiming(i);
            RefPtr<TimingFunction> keyframeTimingFunction = timing.timingFunction;
            timing.timingFunction = Timing::defaults().timingFunction;
            AnimatableValueKeyframeVector resolvedKeyframes;
            resolveKeyframes(resolver, animatingElement, element, style, parentStyle, animationName, keyframeTimingFunction.get(), resolvedKeyframes);
            if (!resolvedKeyframes.isEmpty()) {
                ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange());
                update->startAnimation(animationName, InertAnimation::create(AnimatableValueKeyframeEffectModel::create(resolvedKeyframes), timing, isPaused));
            }
        }
    }

    ASSERT(inactive.isEmpty() || cssAnimations);
    for (const AtomicString& animationName : inactive) {
        ASSERT(!activeAnimations || !activeAnimations->isAnimationStyleChange());
        update->cancelAnimation(animationName, *cssAnimations->m_animations.get(animationName));
    }
}
void function::add_to_namespace(
    object const& name_space, char const* name_, object const& attribute, char const* doc)
{
    str const name(name_);
    PyObject* const ns = name_space.ptr();
    
    if (attribute.ptr()->ob_type == &function_type)
    {
        function* new_func = downcast<function>(attribute.ptr());
        PyObject* dict = 0;
        
#if PY_VERSION_HEX < 0x03000000
        // Old-style class gone in Python 3
        if (PyClass_Check(ns))
            dict = ((PyClassObject*)ns)->cl_dict;
        else
#endif        
        if (PyType_Check(ns))
            dict = ((PyTypeObject*)ns)->tp_dict;
        else    
            dict = PyObject_GetAttrString(ns, const_cast<char*>("__dict__"));

        if (dict == 0)
            throw_error_already_set();

        handle<> existing(allow_null(::PyObject_GetItem(dict, name.ptr())));
        
        if (existing)
        {
            if (existing->ob_type == &function_type)
            {
                new_func->add_overload(
                    handle<function>(
                        borrowed(
                            downcast<function>(existing.get())
                        )
                    )
                );
            }
            else if (existing->ob_type == &PyStaticMethod_Type)
            {
                char const* name_space_name = extract<char const*>(name_space.attr("__name__"));
                
                ::PyErr_Format(
                    PyExc_RuntimeError
                    , "Boost.Python - All overloads must be exported "
                      "before calling \'class_<...>(\"%s\").staticmethod(\"%s\")\'"
                    , name_space_name
                    , name_
                    );
                throw_error_already_set();
            }
        }
        else if (is_binary_operator(name_))
        {
            // Binary operators need an additional overload which
            // returns NotImplemented, so that Python will try the
            // __rxxx__ functions on the other operand. We add this
            // when no overloads for the operator already exist.
            new_func->add_overload(not_implemented_function());
        }

        // A function is named the first time it is added to a namespace.
        if (new_func->name().is_none())
            new_func->m_name = name;

        handle<> name_space_name(
            allow_null(::PyObject_GetAttrString(name_space.ptr(), const_cast<char*>("__name__"))));
        
        if (name_space_name)
            new_func->m_namespace = object(name_space_name);
    }

    // The PyObject_GetAttrString() or PyObject_GetItem calls above may
    // have left an active error
    PyErr_Clear();
    if (PyObject_SetAttr(ns, name.ptr(), attribute.ptr()) < 0)
        throw_error_already_set();

    object mutable_attribute(attribute);
/*
    if (doc != 0 && docstring_options::show_user_defined_)
    {
        // Accumulate documentation
        
        if (
            PyObject_HasAttrString(mutable_attribute.ptr(), "__doc__")
            && mutable_attribute.attr("__doc__"))
        {
            mutable_attribute.attr("__doc__") += "\n\n";
            mutable_attribute.attr("__doc__") += doc;
        }
        else {
            mutable_attribute.attr("__doc__") = doc;
        }
    }

    if (docstring_options::show_signatures_)
    {
        if (   PyObject_HasAttrString(mutable_attribute.ptr(), "__doc__")
            && mutable_attribute.attr("__doc__")) {
            mutable_attribute.attr("__doc__") += (
              mutable_attribute.attr("__doc__")[-1] != "\n" ? "\n\n" : "\n");
        }
        else {
            mutable_attribute.attr("__doc__") = "";
        }
        function* f = downcast<function>(attribute.ptr());
        mutable_attribute.attr("__doc__") += str("\n    ").join(make_tuple(
          "C++ signature:", f->signature(true)));
    }
    */
    str _doc;

    if (docstring_options::show_py_signatures_)
    {
        _doc += str(const_cast<const char*>(detail::py_signature_tag));
    }
    if (doc != 0 && docstring_options::show_user_defined_)
        _doc += doc;

    if (docstring_options::show_cpp_signatures_)
    {
        _doc += str(const_cast<const char*>(detail::cpp_signature_tag));
    }
    if(_doc)
    {    
        object mutable_attribute(attribute);
        mutable_attribute.attr("__doc__")= _doc;
    }
}