예제 #1
0
BasketListViewItem* BasketListViewItem::lastChild()
{
    int count = childCount();
    if (count <= 0)
        return 0;
    return (BasketListViewItem*)(child(count - 1));
}
예제 #2
0
bool ObjectItem::isContain(ObjectItem **ppRet, QPoint &pos, int frame, bool bChild, bool bCheckFlag)
{
    if (bChild)
    {
        for (int i = childCount() - 1; i >= 0; i--)
        {
            if (child(i)->isContain(ppRet, pos, frame, true))
            {
                return true;
            }
        }
    }

    if (bCheckFlag)
    {
        int flag = data(Qt::CheckStateRole).toInt();
        if (!(flag & kState_Disp) || (flag & kState_Lock))
        {   // 非表示
            return false;
        }
    }

    bool valid;
    FrameData d = getDisplayFrameData(frame, &valid);
    if (valid && isContain(d, pos, getDisplayMatrix(frame)))
    {
        *ppRet = this;
        return true;
    }
    return false;
}
예제 #3
0
int EventBrowser::FindEvent(QTreeWidgetItem *parent, QString filter, uint32_t after, bool forward)
{
	if(parent == NULL) return -1;

	for(int i = forward ? 0 : parent->childCount() - 1;
			i >= 0 && i < parent->childCount();
			i += forward ? 1 : -1)
	{
		auto n = parent->child(i);

		uint eid = n->data(COL_EID, Qt::UserRole).toUInt();

		bool matchesAfter = (forward && eid > after) || (!forward && eid < after);

		if(matchesAfter)
		{
			QString name = n->text(COL_NAME);
			if(name.contains(filter, Qt::CaseInsensitive))
				return (int)eid;
		}

		if(n->childCount() > 0)
		{
			int found = FindEvent(n, filter, after, forward);

			if(found > 0)
				return found;
		}
	}

	return -1;
}
bool SCgCommandSelectedObjectMove::mergeWith (const QUndoCommand* command)
{
    if (command->id() != id() || childCount() || command->childCount())
        return false;

    const SCgCommandSelectedObjectMove* c = static_cast<const SCgCommandSelectedObjectMove*>(command);
    if(mUndoInfo.keys() != c->mUndoInfo.keys())
        return false;

    qreal maxManhattanLength = 0;

    SCgScene::ObjectUndoInfo::ConstIterator const_it = c->mUndoInfo.begin();
    while(const_it != c->mUndoInfo.end())
    {
        QPointF offset = const_it.value().second.second - const_it.value().first.second;
        if(offset.manhattanLength() > maxManhattanLength)
            maxManhattanLength = offset.manhattanLength();
        ++const_it;
    }

    if(maxManhattanLength > 35)
        return false;

    SCgScene::ObjectUndoInfo::iterator it = mUndoInfo.begin();
    while(it != mUndoInfo.end())
    {
        it.value().second = c->mUndoInfo.value(it.key()).second;
        ++it;
    }
    return true;
}
예제 #5
0
KcmTreeItem *KcmTreeItem::child(const int row)
{
    if(childCount() > row) {
        return m_children.value(row);
    }
    return NULL;
}
예제 #6
0
/*! \reimp */
int QAccessibleWidget::childAt(int x, int y) const
{
    QWidget *w = widget();
    if (!w->isVisible())
        return -1;
    QPoint gp = w->mapToGlobal(QPoint(0, 0));
    if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
        return -1;

    QWidgetList list = childWidgets(w);
    int ccount = childCount();

    // a complex child
    if (list.size() < ccount) {
        for (int i = 1; i <= ccount; ++i) {
            if (rect(i).contains(x, y))
                return i;
        }
        return 0;
    }

    QPoint rp = w->mapFromGlobal(QPoint(x, y));
    for (int i = 0; i<list.size(); ++i) {
        QWidget *child = list.at(i);
        if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
            return i + 1;
        }
    }
    return 0;
}
예제 #7
0
/*! \reimp */
QString Q3AccessibleHeader::text(Text t, int child) const
{
    QString str;

    if (child <= childCount()) {
        switch (t) {
            case Name:
                str = header()->label(child - 1);
                break;
            case Description: {
                QAccessibleEvent event(QEvent::AccessibilityDescription, child);
                if (QApplication::sendEvent(widget(), &event))
                    str = event.value();
                break; }
            case Help: {
                QAccessibleEvent event(QEvent::AccessibilityHelp, child);
                if (QApplication::sendEvent(widget(), &event))
                    str = event.value();
                break; }
            default:
                break;
        }
    }
    if (str.isEmpty())
        str = QAccessibleWidget::text(t, child);;
    return str;
}
예제 #8
0
void QgsLegendLayer::changeSymbologySettings( const QgsMapLayer* theMapLayer,
    const SymbologyList& newSymbologyItems )
{
  if ( !theMapLayer )
  {
    return;
  }

  QgsLegendSymbologyItem* theSymbologyItem = 0;

  //remove the symbology items under the legend layer
  for ( int i = childCount(); i >= 0; --i )
  {
    theSymbologyItem = dynamic_cast<QgsLegendSymbologyItem *>( child( i ) );
    if ( theSymbologyItem )
    {
      delete takeChild( i );
    }
  }

  //add the new symbology items
  int childposition = 0; //position to insert the items
  for ( SymbologyList::const_iterator it = newSymbologyItems.begin(); it != newSymbologyItems.end(); ++it )
  {
    QgsLegendSymbologyItem* theItem = new QgsLegendSymbologyItem( it->second.width(), it->second.height() );
    theItem->setText( 0, it->first );
    theItem->setIcon( 0, QIcon( it->second ) );
    insertChild( childposition, theItem );

    ++childposition;
  }

}
예제 #9
0
/*! \reimp */
int QAccessibleApplication::navigate(RelationFlag relation, int entry,
                                     QAccessibleInterface **target) const
{
    if (!target)
        return -1;

    *target = 0;
    QObject *targetObject = 0;

    switch (relation) {
    case Self:
        targetObject = object();
        break;
    case Child:
        if (entry > 0 && entry <= childCount()) {
            const QWidgetList tlw(topLevelWidgets());
            if (tlw.count() >= entry)
                targetObject = tlw.at(entry-1);
        } else {
            return -1;
        }
        break;
    case FocusChild:
        targetObject = QApplication::activeWindow();
        break;
    default:
        break;
    }
    *target = QAccessible::queryAccessibleInterface(targetObject);
    return *target ? 0 : -1;
}
예제 #10
0
bool ObjectItem::validate(bool bRecv)
{
    int i;

    QList<unsigned short> frames;
    for (i = 0; i < m_frameDatas.size(); i++)
    {
        const FrameData &d = m_frameDatas.at(i);
        if (frames.contains(d.frame))
        {
            return false;
        }
        frames.append(d.frame);
    }

    if (bRecv)
    {
        for (i = 0; i < childCount(); i++)
        {
            if (!child(i)->validate(bRecv))
            {
                return false;
            }
        }
    }
    return true;
}
예제 #11
0
CharString NounShip::status() const
{
	CharString sTargetInfo;

	// team & ship type..
	sTargetInfo += CharString().format("%s - %s\n", teamName(), nounContext()->name() );
	// hull %
	sTargetInfo += CharString().format("Hull: %d%%\n", int( damageRatioInv() * 100) );

	int armor = 0, maxArmor = 0;
	int shield = 0, maxShield = 0;
	for(int i=0;i<childCount();i++)
	{
		BaseNode * pChild = child(i);
		if ( WidgetCast<GadgetShield>( pChild ) )
		{
			shield += ((GadgetShield *)pChild)->charge();
			maxShield += ((GadgetShield *)pChild)->maxCharge();
		}
		else if ( WidgetCast<GadgetArmor>( pChild ) )
		{
			armor += ((GadgetArmor *)pChild)->armor();
			maxArmor += ((GadgetArmor *)pChild)->maxArmor();
		}
	}

	if ( maxShield > 0 )
		sTargetInfo += CharString().format("Shield: %d%%\n", (shield * 100) / maxShield);
	if ( maxArmor > 0 )
		sTargetInfo += CharString().format("Armor: %d%%\n", (armor * 100) / maxArmor );

	return sTargetInfo;
}
예제 #12
0
void KACLListView::slotAddEntry()
{
    int allowedTypes = NamedUser | NamedGroup;
    if ( !m_hasMask )
        allowedTypes |= Mask;
    int allowedDefaultTypes = NamedUser | NamedGroup;
    if ( !findDefaultItemByType( Mask ) )
        allowedDefaultTypes |=  Mask;
    if ( !hasDefaultEntries() )
        allowedDefaultTypes |= User | Group;
    EditACLEntryDialog dlg( this, 0,
                            allowedUsers( false ), allowedGroups( false ),
                            allowedUsers( true ), allowedGroups( true ),
                            allowedTypes, allowedDefaultTypes, m_allowDefaults );
    dlg.exec();
    KACLListViewItem *item = dlg.item();
    if ( !item ) return; // canceled
    if ( item->type == Mask && !item->isDefault ) {
        m_hasMask = true;
        m_mask = item->value;
    }
    if ( item->isDefault && !hasDefaultEntries() ) {
        // first default entry, fill in what is needed
        if ( item->type != User ) {
            unsigned short v = findDefaultItemByType( User )->value;
            new KACLListViewItem( this, User, v, true );
        }
        if ( item->type != Group ) {
            unsigned short v = findDefaultItemByType( Group )->value;
            new KACLListViewItem( this, Group, v, true );
        }
        if ( item->type != Others ) {
            unsigned short v = findDefaultItemByType( Others )->value;
            new KACLListViewItem( this, Others, v, true );
        }
    }
    const KACLListViewItem *defaultMaskItem = findDefaultItemByType( Mask );
    if ( item->isDefault && !defaultMaskItem ) {
        unsigned short v = calculateMaskValue( true );
        new KACLListViewItem( this, Mask, v, true );
    }
    if ( !item->isDefault && !m_hasMask &&
            ( item->type == Group
              || item->type == NamedUser
              || item->type == NamedGroup ) ) {
        // auto-add a mask entry
        unsigned short v = calculateMaskValue( false );
        new KACLListViewItem( this, Mask, v, false );
        m_hasMask = true;
        m_mask = v;
    }
    calculateEffectiveRights();
    sort();
    setCurrentItem( item );
    // TQListView doesn't seem to emit, in this case, and we need to update 
    // the buttons...
    if ( childCount() == 1 ) 
        emit currentChanged( item );
}
예제 #13
0
void classSpecialColumns::setOpen( bool o )
{
    if ( o && !childCount() )
	{
		LoadColumns();
    }
    QListViewItem::setOpen( o );
}
예제 #14
0
const Object *Container::childAt(NPT_Ordinal index) const
{
	Object *child = NULL;
	if (index < childCount()) {
		child = *m_children.GetItem(index);
	}
	return child;
}
예제 #15
0
void classPrimaryKeys::setOpen( bool o )
{
    if ( o && !childCount() )
	{
		LoadColumns();
    }
    QListViewItem::setOpen( o );
}
예제 #16
0
void SpawnListItem::updateTitle(const QString& name)
{
    // update childcount in header
    QString temp;
    temp.sprintf("%s (%d)",
                 (const char*)name, childCount());
    setText(tSpawnColName, temp);
} // end if spawn should be in this category
예제 #17
0
TwXmlElement* TwXmlElement::childAt(int index)
{
    if (index < 0 || index >= childCount())
    {
        return NULL;
    }
    return m_dptr->children.at(index);
}
int  QAccessibleInterfaceEx_QtDShell::__override_childCount(bool static_call) const
{
    if (static_call) {
        return 0;
    } else {
        return childCount();
    }
}
예제 #19
0
void WidgetContainer::destroyChild(Widget &child)
{
    removeChild(child);
    child.onClosed();
    delete &child;
    if (closing() && childCount() == 0)
        destroy();
}
예제 #20
0
int  QAccessibleWidgetEx_QtDShell::__override_childCount(bool static_call) const
{
    if (static_call) {
        return QAccessibleWidgetEx::childCount();
    } else {
        return childCount();
    }
}
예제 #21
0
void classDriver::setOpen( bool o )
{
    if ( o && !childCount() )
	{
		setExpandable( FALSE );
    }
    QListViewItem::setOpen( o );
}
예제 #22
0
NPT_List<const Object*> Container::getChildren() const
{
	NPT_List<const Object*> ls;
	for (NPT_Ordinal i = 0; i < childCount(); i++) {
		ls.Add(childAt(i));
	}
	return ls;
}
NoiseNetwork* Displace::network() {
    // 0. query module for readieness
    //    a module is ready if all dependencies are sadisfied, if that did not happen
    //    we can't use it as libnoise could throw an exception or do other weird things...
    if (ready()) {
        //   1. create a noiseNetwork (if generator module)
        NoiseNetwork* noiseNetwork = new NoiseNetwork;

        //   2. construct the local module (in this case Perlin)
        noise::module::Displace* m_Displace = new noise::module::Displace();
        noiseNetwork->addModule(m_Displace);

        //   3. assign all properties
        //   m_Displace->SetOctaveCount (property("OctaveCount"));
        //FIXME: implement this

        //   4. connect all source modules (in case of a generator module: none) & merge the NoiseNetwork(s)
        //   foreach(input i)
        //       m_perlin->SetSourceModule(i->portnumber, i->topLevelModule);
        //       noiseNetwork->merge(i->network)
        //   foreach(input m)
        //     m_perlin->SetControlModule(m->topLevelModule);
        //     noiseNetwork->merge(m->network)

        for (int x=0; x < childCount(); ++x) {
            DataAbstractItem* chi = childItems()[x];
            if (chi->getObjectType() == DataItemType::PORT) {
                DataPort* p = static_cast<DataPort*>(chi);
                if (p->PortDirection() == PortDirection::IN || p->PortDirection() == PortDirection::MOD) {
                    // 1. reconstruct the Connection
                    DataConnection* c = static_cast<DataConnection*> (p->referenceChildItems().first());
                    // 2. reconstruct the remote port
                    DataAbstractItem* abstractPort = c->dst();
                    // 3. reconstruct the remote module
                    DataAbstractModule* module = static_cast<DataAbstractModule*> (abstractPort->parent());
                    // 4. check if it is ready
                    /*
                    if (p->PortDirection() == PortDirection::IN) {
                      NoiseNetwork* n = module->network();
                      m_Displace->SetSourceModule(p->PortNumber(), n->topLevelModule());
                      noiseNetwork += n;
                    }
                    */
                    /*
                    if (p->PortDirection() == PortDirection::MOD) {
                      NoiseNetwork* n = module->network();
                      m_Displace->SetControlModule(n->topLevelModule());
                      noiseNetwork += n;                      
                    }
                    */
                }
            }
        }

        return noiseNetwork;
    }
    return NULL;
}
예제 #24
0
   bool ActorTypeTreeWidget::recursivelyAddCategoryAndActorTypeAsChildren(
      QMutableStringListIterator* listIterator, dtCore::RefPtr<const dtDAL::ActorType> actorType)
   {
      bool foundChildMatch = false;
      bool result          = false;

      // error
      if (listIterator == NULL)
      {
         result = false;
      }
      // if we're at the end of the list, then add the actor to this node.
      else if (!listIterator->hasNext())
      {
         new ActorTypeTreeWidget(this, actorType);
         result = true;
      }

      // if we're not at the end, then pop off the first sub-category and work with it to find
      // our rightful place in the tree
      else
      {
         QString subCategory = listIterator->next();
         listIterator->remove(); // in effect, pop the first subCategory off.

         // if for some reason the next sub category is empty, then just skip it and recurse.
         if (subCategory.isNull() || subCategory.isEmpty())
         {
            result = recursivelyAddCategoryAndActorTypeAsChildren(listIterator, actorType);
         }
         else
         {
            // take the category and try to find it as a child of this tree node.
            for (int i = 0; i < childCount(); ++i)
            {
               QTreeWidgetItem*     childWidget = child(i);
               ActorTypeTreeWidget* actorChild  = dynamic_cast<ActorTypeTreeWidget*>(childWidget);
               if (actorChild != NULL && subCategory == actorChild->getCategorySegment())
               {
                  result = actorChild->recursivelyAddCategoryAndActorTypeAsChildren(listIterator, actorType);
                  foundChildMatch = true;
                  break;
               }
            }

            // if we didn't find a match, then make an internal node and add the type to that
            if (!foundChildMatch)
            {
               result = true;
               ActorTypeTreeWidget* innerNode = new ActorTypeTreeWidget(this, subCategory);
               result = innerNode->recursivelyAddCategoryAndActorTypeAsChildren(listIterator, actorType);
            }
         }
      }

      // return whether we did or didn't add the node, regardless of how deep we had to go.
      return result;
   }
예제 #25
0
TestTreeItem *TestTreeItem::findChildBy(CompareFunction compare)
{
    for (int row = 0, count = childCount(); row < count; ++row) {
        TestTreeItem *child = childItem(row);
        if (compare(child))
            return child;
    }
    return 0;
}
예제 #26
0
int TTAudioListView::count()
{
  int list_count;

  list_count = childCount();
  TTCut::numAudioTracks = list_count;

  return list_count;
}
예제 #27
0
QTreeWidgetItem *KWalletContainerItem::getItem(const QString& key) {
	for (int i = 0; i < childCount(); ++i) {
		KWalletEntryItem* entryItem = dynamic_cast<KWalletEntryItem *>(child(i));
		if (entryItem && entryItem->name() == key) {
			return entryItem;
		}
	}
	return 0;
}
예제 #28
0
QList<AbstractAspect *> AbstractAspect::descendantsThatInherit(const char * class_name)
{
	QList<AbstractAspect *> list;
	if (inherits(class_name))
		list << this;
	for (int i=0; i<childCount(); i++)
		list << child(i)->descendantsThatInherit(class_name);
	return list;
}
예제 #29
0
bool DeviceDesc::getChildAt(NPT_Ordinal index, DeviceDesc*& child) const
{
	if (index < childCount()) {
		child = *m_private->m_children.GetItem(index);
		child->addRef();
		return true;
	}
	return false;
}
예제 #30
0
GadgetCloak * NounShip::gadgetCloak() 
{
	GadgetCloak * pGadgetCloak = NULL;
	for(int i=0;i<childCount();i++)
		if ( WidgetCast<GadgetCloak>( child(i) ) )
			pGadgetCloak = (GadgetCloak *)child(i);

	return pGadgetCloak;
}