void LegendGroup::updateModel() {
	QList<QGraphicsItem*> pool;
	for (auto l : legends) { removeFromGroup(l); pool.append(l); }
	for (auto t : texts) { removeFromGroup(t); pool.append(t); }
	for (auto l : pool) delete l;
	legends.clear();
	texts.clear();
	for (int i=0; i<model->rowCount(); i++) {
		auto marker = model->at(i);
		QString l = marker->label() + "\t:  " + QString::number(marker->count());
		QColor color1 = marker->color1();
		QColor color2 = marker->color2();
		int type = marker->activeType();
		if (0 == type) {
			QRectF r = MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize);
			QLineF l(r.topLeft(), r.bottomRight());
			auto marker = new ArrowItem(l);
			marker->setArrowhead(ArrowHead::Start);
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else if (1 == type) {
			auto marker = new RectItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else {
			auto marker = new EllipseItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		auto label = new RichTextItem(l);
		label->setFont(myFont);
		label->setFontSize(myFontSize);
		label->setKeyPressFunc([this](QKeyEvent* event) { updateRect(); });
		label->setTextInteractionFlags(Qt::TextEditorInteraction);
		label->setFlag(QGraphicsItem::ItemIsFocusable);
		QPointF textPos = legends.at(i)->boundingRect().center() + 
			QPointF(legends.at(i)->boundingRect().width()/2+20, -label->boundingRect().height()*0.5);
		label->setPos(textPos);
		label->setZValue(1000);
		texts.append(label);
		addToGroup(label);
	}
	calculatePos();
}
Example #2
0
void PropertyList::removeProperty(const QString &name)
{
    if (m_list.contains(name))
    {
        QString group = m_groupOfProperty[m_list[name]];
        removeFromGroup(m_list[name]);
        Property *property;
        for (property = m_list[name]->list.first(); property; property = m_list[name]->list.next())
        {
            if (m_propertyOwner)
                emit aboutToDeleteProperty(property);

            m_list[property->name()]->removeProperty(property);
            if (m_propertyOwner)
                delete property;
        }
        if (m_list[name]->list.count() == 0)
        {
//            qWarning("rp2:            removing mp for %s itself", name.ascii());
            delete m_list[name];
            m_list.remove(name);
        }
        else
        {
            addToGroup(group, m_list[name]);
        }
    }
}
Example #3
0
int Monster::cleanMobForSaving() {

    // No saving pets!
    if(isPet())
        return(-1);

    // Clear the inventory
    clearMobInventory();

    // Clear any flags that shouldn't be set
    clearFlag(M_WILL_BE_LOGGED);

//  // If the creature is possessed, clean that up
    if(flagIsSet(M_DM_FOLLOW)) {
        clearFlag(M_DM_FOLLOW);
        Player* master;
        if(getMaster() != nullptr && (master = getMaster()->getAsPlayer()) != nullptr) {
            master->clearFlag(P_ALIASING);
            master->getAsPlayer()->setAlias(0);
            master->print("%1M's soul was saved.\n", this);
            removeFromGroup(false);
        }
    }

    // Success
    return(1);
}
Example #4
0
ButtonTaskMenu::ButtonTaskMenu(QAbstractButton *button, QObject *parent)  :
    QDesignerTaskMenu(button, parent),
    m_assignGroupSubMenu(new QMenu),
    m_assignActionGroup(0),
    m_assignToGroupSubMenuAction(new QAction(tr("Assign to button group"), this)),
    m_currentGroupSubMenu(new QMenu),
    m_currentGroupSubMenuAction(new QAction(tr("Button group"), this)),
    m_createGroupAction(new QAction(tr("New button group"), this)),
    m_preferredEditAction(new QAction(tr("Change text..."), this)),
    m_removeFromGroupAction(new QAction(tr("None"), this))
{
    connect(m_createGroupAction, SIGNAL(triggered()), this, SLOT(createGroup()));
    TaskMenuInlineEditor *textEditor = new ButtonTextTaskMenuInlineEditor(button, this);
    connect(m_preferredEditAction, SIGNAL(triggered()), textEditor, SLOT(editText()));
    connect(m_removeFromGroupAction, SIGNAL(triggered()), this, SLOT(removeFromGroup()));

    m_assignToGroupSubMenuAction->setMenu(m_assignGroupSubMenu);

    m_currentGroupSubMenu->addAction(m_groupMenu.breakGroupAction());
    m_currentGroupSubMenu->addAction(m_groupMenu.selectGroupAction());
    m_currentGroupSubMenuAction->setMenu(m_currentGroupSubMenu);


    m_taskActions.append(m_preferredEditAction);
    m_taskActions.append(m_assignToGroupSubMenuAction);
    m_taskActions.append(m_currentGroupSubMenuAction);
    m_taskActions.append(createSeparator());
}
Example #5
0
void CGroupList::removeFamily(const QString &family)
{
    QList<CGroupListItem *>::ConstIterator it(itsGroups.begin()),
                                           end(itsGroups.end());

    for(; it!=end; ++it)
        removeFromGroup(*it, family);
}
// 删除方块组中的所有小方块
void BoxGroup::clearBoxGroup(bool destroyBox)
{
    QList<QGraphicsItem *> itemList = childItems();
    QGraphicsItem *item;
    foreach (item, itemList) {
        removeFromGroup(item);
        if (destroyBox) {
            OneBox *box = (OneBox*) item;
            box->deleteLater();
        }
    }
Example #7
0
CGroupListView::CGroupListView(QWidget *parent, CGroupList *model)
              : QTreeView(parent)
{
    setModel(model);
    setItemDelegate(new CGroupListViewDelegate(this));
    sortByColumn(COL_GROUP_NAME, Qt::AscendingOrder);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setSortingEnabled(true);
    setAllColumnsShowFocus(true);
    setAlternatingRowColors(true);
    setAcceptDrops(true);
    setDragDropMode(QAbstractItemView::DropOnly);
    setDropIndicatorShown(true);
    setDragEnabled(false);
    header()->setSortIndicatorShown(true);
    setRootIsDecorated(false);
    itsMenu=new QMenu(this);

    itsDeleteAct=itsMenu->addAction(QIcon::fromTheme("list-remove"), i18n("Remove"),
                                    this, SIGNAL(del()));
    itsMenu->addSeparator();
    itsEnableAct=itsMenu->addAction(QIcon::fromTheme("enablefont"), i18n("Enable"),
                                    this, SIGNAL(enable()));
    itsDisableAct=itsMenu->addAction(QIcon::fromTheme("disablefont"), i18n("Disable"),
                                     this, SIGNAL(disable()));
    itsMenu->addSeparator();
    itsRenameAct=itsMenu->addAction(QIcon::fromTheme("edit-rename"), i18n("Rename..."),
                                    this, SLOT(rename()));
    
    if(!Misc::app(KFI_PRINTER).isEmpty())
    {
        itsMenu->addSeparator();
        itsPrintAct=itsMenu->addAction(QIcon::fromTheme("document-print"), i18n("Print..."),
                                       this, SIGNAL(print()));
    }
    else
        itsPrintAct=0L;
    itsMenu->addSeparator();
    itsExportAct=itsMenu->addAction(QIcon::fromTheme("document-export"), i18n("Export..."),
                                    this, SIGNAL(zip()));

    setWhatsThis(model->whatsThis());
    header()->setWhatsThis(whatsThis());
    connect(this, SIGNAL(addFamilies(QModelIndex,QSet<QString>)),
            model, SLOT(addToGroup(QModelIndex,QSet<QString>)));
    connect(this, SIGNAL(removeFamilies(QModelIndex,QSet<QString>)),
            model, SLOT(removeFromGroup(QModelIndex,QSet<QString>)));
}
Example #8
0
File: map.cpp Project: Ra8/RAP
void Map::toggleFlag(){
    Person* person;
    if(role==1) // police
        person=polices[role-1];
    else
        person=robber;
    for(unsigned int i=0;i<flags.size();i++){
        if(person->collidesWithItem(flags[i])){
            removeFromGroup(flags[i]);
            flags[i]->scene()->removeItem(flags[i]);
            flags.erase(flags.begin()+i);
            return;
        }
    }
    flags.push_back(new Flag());
    addToGroup(flags[flags.size()-1]);
}
void ItemConnection::DeleteConnection()
{	// delete subitems
	std::for_each(std::begin(mChildrens), std::end(mChildrens), 
		[&] (QGraphicsItem* item) 
		{
			// remove from scene, group and then delete
			removeFromGroup(item);
			if (scene() != nullptr)
			{
				scene()->removeItem(item);
			}
			delete item;
			item = 0;
		}
	);
	mChildrens.clear();
}
Example #10
0
/*!
 * \brief Realigns all the child items of this group (deletes hidden items).
 * This is quite expensive . It removes all property items
 * from the group and then freshly adds them to the group again if it is
 * visible. If the property is hidden, then the corresponding property items
 * are removed from group and deleted. This also updates the visible value of
 * property.
 */
void PropertiesGroup::realignItems()
{
    //Nothing to do if scene doesn't exist.
    if(!scene()) {
        return;
    }
    QPointF savePos;
    if(boundingRect().isNull()) {
        savePos = parentItem()->sceneBoundingRect().bottomLeft();
    }
    else {
        savePos = sceneBoundingRect().topLeft();
    }

    //Remove items from group and make them top level items.
    foreach(PropertyItem *item, m_propertyItemsMap) {
        item->updateValue();
        removeFromGroup(item);
        item->setParentItem(0);
    }
Example #11
0
void CGroupList::removeFromGroup(const QModelIndex &group, const QSet<QString> &families)
{
    if(group.isValid())
    {
        CGroupListItem *grp=static_cast<CGroupListItem *>(group.internalPointer());

        if(grp && grp->isCustom())
        {
            QSet<QString>::ConstIterator it(families.begin()),
                                         end(families.end());
            bool                         update(false);

            for(; it!=end; ++it)
                if(removeFromGroup(grp, *it))
                    update=true;

            if(update)
                emit refresh();
        }
    }
}
Example #12
0
void PropertyList::removeProperty(Property *property)
{
    if (property == 0)
        return;

    if (m_propertyOwner)
        emit aboutToDeleteProperty(property);

    MultiProperty *mp = m_list[property->name()];
    QString group = m_groupOfProperty[mp];
    removeFromGroup(mp);
    QString pname = property->name();
    mp->removeProperty(property);
    if (m_propertyOwner)
        delete property;
    if (mp->list.count() == 0)
    {
//        qWarning("rp:            removing mp for %s itself", pname.ascii());
        m_list.remove(pname);
        delete mp;
    }
    else
        addToGroup(group, mp);
}
 foreach (QGraphicsItem *item, childItems())
 {   
     removeFromGroup(item);
     if (item && item->scene())
         item->scene()->removeItem(item);
 }
Example #14
0
void AbstractGroupItem::removeItem(QGraphicsItem * item)
{
    removeFromGroup(item);
}
bool LLViewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data)
{
	return removeFromGroup(data->getEntry());
}
Example #16
0
void CalloutPointerItem::drawPointerPoly()
{
  QLineF linef = QLineF(points[Base],points[Tip]);

  removeFromGroup(shaft);
  shaft->setLine(linef);
  addToGroup(shaft);
  
  QPolygonF poly;
  
  poly << QPointF(-2*grabSize(), 0);
  poly << QPointF(-2*grabSize(),grabSize()/2);
  poly << QPointF(grabSize()/2,0);
  poly << QPointF(-2*grabSize(),-grabSize()/2);
  poly << QPointF(-2*grabSize(),0);
  
  removeFromGroup(head);
  head->setPolygon(poly);
  
  qreal x = points[Tip].x()-points[Base].x();
  qreal y = points[Tip].y()-points[Base].y();
  qreal h = sqrt(x*x+y*y);
  qreal angle = 180*acos(x/h);

  qreal pi = 22.0/7;

  if (x == 0) {
    if (y < 0) {
      angle = 270.0;
    } else {
      angle = 90.0;
    }
  } else if (y == 0) {
    if (x < 0) {
      angle = 180.0;
    } else {
      angle = 0.0;
    }
  } else {
    volatile qreal h = sqrt(x*x+y*y);
    if (x > 0) {
      if (y > 0) {
        angle = 180-180*acos(-x/h)/pi;
      } else {
        angle = 180+180*acos(-x/h)/pi;
      }
    } else {
      if (y > 0) {
        angle = 180*acos(x/h)/pi;
      } else {
        angle = -180*acos(x/h)/pi;
      }
    }
  }
  
  head->resetTransform();
  head->rotate(angle);
  head->setPos(points[Tip]);
  addToGroup(head);

  QRectF rect = sceneBoundingRect();

  view->updateSceneRect(sceneBoundingRect());
}
 foreach (QGraphicsItem *item, childItems()) {
     removeFromGroup(item);
     item->setFlag(QGraphicsItem::ItemIsSelectable, true);
     item->setFlag(QGraphicsItem::ItemIsFocusable, true);
 }
Example #18
0
FiGroupWidget::FiGroupWidget(FClass* parent)
             : FWidget(parent, FUNC)
{
  mEditing = false;

  QPixmap icon(10, 10);

  mGroupView = new MyTableWidget(this);
  //mGroupView->setDragEnabled(false);
  //mGroupView->setAcceptDrops(false);
  mGroupView->setEditTriggers(QAbstractItemView::EditKeyPressed);

  connect(mGroupView, SIGNAL(currentRowChanged(int))
          , this, SLOT(groupRowChanged(int)));
  connect(mGroupView, SIGNAL(cellDoubleClicked(int, int))
          , this, SLOT(groupOpen(int, int)));
  connect(mGroupView, SIGNAL(cellChanged(int, int))
          , this, SLOT(groupEdited(int, int)));
  connect(mGroupView, SIGNAL(dragToNirvana())
          , this, SLOT(removeGroup()));

  mMotherName = new QLabel(this);
  //mMotherName->setWordWrap(true);
  mMotherName->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

  QToolButton* btn = new QToolButton(this);
  btn->setAutoRaise(true);
  btn->setArrowType(Qt::UpArrow);
  btn->setToolTip("Up to Mother Group");
  connect(btn, SIGNAL(clicked(bool)), this, SLOT(groupUp()));

  QToolButton* newGroupBtn = new QToolButton(this);
  newGroupBtn->setAutoRaise(true);
  icon.fill(Qt::green);
  newGroupBtn->setIcon(icon);
  newGroupBtn->setToolTip("Add New Group");
  connect(newGroupBtn, SIGNAL(clicked(bool)), this, SLOT(newGroup()));

  //mMotherName->setAlignment(Qt::AlignVertical_Mask);
  //mMotherName->setOrientation(Qt::Vertical);
  QGridLayout* gbox = new QGridLayout;
  gbox->setMargin(0);
  gbox->addWidget(mMotherName, 0, 0);
  gbox->addWidget(newGroupBtn, 0, 1);
  gbox->addWidget(btn, 0, 2);
  gbox->addWidget(mGroupView, 1, 0, 1, 3);
  QWidget* gboxw = new QWidget;
  gboxw->setLayout(gbox);

  mMemberView = new MyTableWidget;

  connect( mMemberView, SIGNAL(currentRowChanged(int))
          , this, SLOT(memberRowChanged(int)));
  connect( mMemberView, SIGNAL(dragInFromTableView(QTableView*))
          , this, SLOT(userDragInData(QTableView*)));
  connect(mMemberView, SIGNAL(dragToNirvana())
          , this, SLOT(removeFromGroup()));

  mSplitter = new QSplitter(Qt::Vertical);
  //mSplitter->addWidget(mGroupView);
  mSplitter->addWidget(gboxw);
  mSplitter->addWidget(mMemberView);
  mSplitter->setStretchFactor(0, 1);
  mSplitter->setStretchFactor(1, 3);

  QGridLayout* layout = new QGridLayout;
  layout->setMargin(0);
  layout->addWidget(mSplitter, 0, 0);
  //layout->addWidget(, 0, 1);

  setLayout(layout);
}