Esempio n. 1
0
ViewItem* LabelItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
  LabelItem *rc = 0;
  while (!xml.atEnd()) {
    bool validTag = true;
    if (xml.isStartElement()) {
      if (!rc && xml.name().toString() == "label") {
      QXmlStreamAttributes attrs = xml.attributes();
      QStringRef av;
      av = attrs.value("text");
      if (!av.isNull()) {
        Q_ASSERT(!rc);
        rc = new LabelItem(view, av.toString());
        if (parent) {
          rc->setParentViewItem(parent);
         // Add any new specialized LabelItem Properties here.
          }
        }
        av = attrs.value("scale");
        if (!av.isNull()) {
          rc->setLabelScale(QVariant(av.toString()).toInt());
        }
        av = attrs.value("color");
        if (!av.isNull()) {
            rc->setLabelColor(QColor(av.toString()));
        }
        av = attrs.value("font");
        if (!av.isNull()) {
          QFont font;
          font.fromString(av.toString());
          rc->setLabelFont(font);
        }
        av = attrs.value("fixleft");
        if (!av.isNull()) {
          rc->setFixLeft(QVariant(av.toString()).toBool());
        }
      } else {
        Q_ASSERT(rc);
        if (!rc->parse(xml, validTag) && validTag) {
          ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
          if (!i) {
          }
        }
      }
    } else if (xml.isEndElement()) {
      if (xml.name().toString() == "label") {
        break;
      } else {
        validTag = false;
      }
    }
    if (!validTag) {
      qDebug("invalid Tag\n");
      Debug::self()->log(QObject::tr("Error creating box object from Kst file."), Debug::Warning);
      delete rc;
      return 0;
    }
    xml.readNext();
  }
  return rc;
}
Esempio n. 2
0
void CreateLabelCommand::createItem(QString *inText) {
  if (inText) {
    _item = new LabelItem(_view, *inText);
  } else {
    bool ok = false;
    QString text;
    LabelCreator dialog;
    if (dialog.exec() == QDialog::Accepted) {
      text = dialog.labelText();
      ok = true;
    }

    if (!ok || text.isEmpty()) {
      return;
    }

    _item = new LabelItem(_view, text);
    LabelItem *label = qobject_cast<LabelItem*>(_item);

    label->setLabelScale(dialog.labelScale());
    label->setLabelColor(dialog.labelColor());
    label->setLabelFont(dialog.labelFont());
    label->setFixLeft(dialog.fixLeft());
    label->setLockPosToData(dialog.lockPosToData());
    if (dialog.saveAsDefaults()) {
      label->saveAsDialogDefaults();
      dialogDefaults().setValue(label->staticDefaultsGroupName()+"/fixLeft",dialog.fixLeft());
      dialogDefaults().setValue(label->staticDefaultsGroupName()+"/lockPosToData",dialog.lockPosToData());
    }
  }
  _item->view()->scene()->addItem(_item);

  _view->setCursor(Qt::IBeamCursor);

  CreateCommand::createItem();
}
Esempio n. 3
0
SNSTableViewCellItem *SGHelpLayer::tableViewItemForCell(SNSTableView* tableView, SNSIndexPath* indexPath)
{
    CCSize size = tableView->getItemSize();
    int num = tableView->getItemPointerWithIndexPath(indexPath);
    LabelItem *item = (LabelItem*)tableView->dequeueReusableCellItemForIndexPath(indexPath);
    
    if (NULL == item)
    {
        item = LabelItem::create(size,num,false,this,tableView);
    }
    
    //获得title指针,修改文本。
    SGCCLabelTTF* label = item->title;
    
    switch (num)
    {
        case SGSFT_GALLERY:
        {
            label->setString(str_HelpLayer_str9);
        }
            break;
        case SGSFT_FRIEND:
        {
            label->setString(str_FriendCountFull_str11);
            //好友需要判断红点显隐。
            SGPlayerInfo * playerInfo = SGPlayerInfo::sharePlayerInfo();
            CCArray *temp = playerInfo->getApplyList();
            if (temp->data && temp->data->arr && temp->count() != 0  && playerInfo->getPlayerLevel() >= playerInfo->getShowPlayerNoticeLimitLev())
            {
                item->setRedSpot(true);
            }
            else
            {
                item->setRedSpot(false);
            }
        }
            break;
        case SGSFT_SETTING:
        {
            label->setString(str_HelpLayer_str1);
        }
            break;
        case SGSFT_HELP:
        {
            label->setString(str_HelpLayer_str2);
        }
            break;
        case SGSFT_ADVICE:
        {
            CCArray *temp = SGPlayerInfo::sharePlayerInfo()->getQAContent();
            int count=0;
            if (temp)
            {
                for(int i=0;i<temp->count();i++)
                {
                    SGQAConcent * qa = (SGQAConcent*)temp->objectAtIndex(i);
                    
                    if(!qa->getState())
                    {
                        count ++;
                    }
                }
            }
            CCString*string=CCString::createWithFormat(str_HelpLayer_str3,count);
            label->setString(string->getCString());
        }
            break;
        case SGSFT_SHARE:
        {
            if(SGPlayerInfo::sharePlayerInfo()->getShowvip()==SHOW_SHAREBOX_ID)
            {
                label->setString(str_HelpLayer_str8);
            }
            else
            {
                if (GAME_ACCOUNT_TYPE == GCAT_PP)
                {
                    label->setString(str_HelpLayer_str4);
                }
                else if (GAME_ACCOUNT_TYPE == GCAT_TONGBUTUI)
                {
                    label->setString(str_HelpLayer_str5);
                }
                else//如果其他情况一旦显示出来
                {
                    label->setString(str_HelpLayer_str6);
                }
            }
            //label->setString("绑定帐号");
        }
            break;
        case SGSFT_FANS:
        {
            if (isTaiWanGo2Play) //台湾版本要添加fb粉丝团的直达通道。
            {
                label->setString(str_HelpLayer_str10);
            }
            else
            {
                label->setString(str_SkipUpdate);
            }
            break;
            //这以下是添加引流功能之前的老代码,保留待命,不执行。
            /*
            if(SGPlayerInfo::sharePlayerInfo()->getShowvip()==SHOW_SHAREBOX_ID)
            {
                if (GAME_ACCOUNT_TYPE == GCAT_PP)
                {
                    label->setString(str_HelpLayer_str4);
                }
                else if (GAME_ACCOUNT_TYPE == GCAT_TONGBUTUI)
                {
                    label->setString(str_HelpLayer_str5);
                }
                else//如果其他情况一旦显示出来
                {
                    label->setString(str_HelpLayer_str6);
                }
            }
            else
            {
                label->setString(str_HelpLayer_str7);
                
            }
            */
        }
            break;
        case SGSFT_RELOGIN:
        {
            label->setString(str_HelpLayer_str7);
        }
            break;
        default:
            break;
    }

    return item;
}
void LabelItemDialog::saveDimensions(ViewItem *viewitem) {
  Q_ASSERT(viewitem);

  LabelItem *item = qobject_cast<LabelItem*>(viewitem);
  Q_ASSERT(item);

  QPointF xy(_labelDimensionsTab->x(),_labelDimensionsTab->y());
  qreal theta = _labelDimensionsTab->rotation();
  bool fix_left = _labelDimensionsTab->fixLeft();

  if (_labelDimensionsTab->lockPosToData() && item->dataPosLockable()) {
    QRectF dr = item->dataRelativeRect();
    if (fix_left) {
      dr.moveTopLeft(xy);
      item->setFixLeft(true);
    } else {
      dr.moveBottomRight(xy);
      item->setFixLeft(false);
    }
    item->setDataRelativeRect(dr);

    bool lockPosToData = _labelDimensionsTab->lockPosToDataDirty() ? _labelDimensionsTab->lockPosToData() : item->lockPosToData();
    item->setLockPosToData(lockPosToData);

    item->applyDataLockedDimensions();

  } else {
    QRectF parentRect = item->parentRect();
    qreal parentWidth = parentRect.width();
    qreal parentHeight = parentRect.height();
    qreal parentX = parentRect.x();
    qreal parentY = parentRect.y();
    bool lockPosToData = _labelDimensionsTab->lockPosToDataDirty() ? _labelDimensionsTab->lockPosToData() : item->lockPosToData();
    item->setLockPosToData(lockPosToData);
    qreal width = item->rect().width();
    qreal height = item->rect().height();

    item->setPos(parentX + xy.x()*parentWidth, parentY + xy.y()*parentHeight);
    if (fix_left) {
      item->setViewRect(0,-height, width, height);
      item->setFixLeft(true);
    } else {
      item->setViewRect(-width,-height, width, height);
      item->setFixLeft(false);
    }
  }
  QTransform transform;
  transform.rotate(theta);
  item->setTransform(transform);
  item->updateRelativeSize(true);

  if (_saveAsDefault->isChecked()) {
    _dialogDefaults->setValue(item->staticDefaultsGroupName()+"/fixLeft",_labelDimensionsTab->fixLeft());
  }
}