forked from qt-creator/qt-creator
Use isEmpty() instead of count() or size()
Change-Id: I0a89d2808c6d041da0dc41ea5aea58e6e8759bb4 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -740,7 +740,7 @@ void ConnectableItem::addOverlappingItem(ConnectableItem *item)
|
||||
if (!m_overlappedItems.contains(item))
|
||||
m_overlappedItems.append(item);
|
||||
|
||||
setOverlapping(m_overlappedItems.count() > 0);
|
||||
setOverlapping(!m_overlappedItems.isEmpty());
|
||||
}
|
||||
|
||||
void ConnectableItem::removeOverlappingItem(ConnectableItem *item)
|
||||
@@ -748,7 +748,7 @@ void ConnectableItem::removeOverlappingItem(ConnectableItem *item)
|
||||
if (m_overlappedItems.contains(item))
|
||||
m_overlappedItems.removeAll(item);
|
||||
|
||||
setOverlapping(m_overlappedItems.count() > 0);
|
||||
setOverlapping(!m_overlappedItems.isEmpty());
|
||||
}
|
||||
|
||||
void ConnectableItem::checkOverlapping()
|
||||
@@ -776,7 +776,7 @@ void ConnectableItem::checkOverlapping()
|
||||
}
|
||||
}
|
||||
|
||||
setOverlapping(m_overlappedItems.count() > 0);
|
||||
setOverlapping(!m_overlappedItems.isEmpty());
|
||||
}
|
||||
|
||||
bool ConnectableItem::canStartTransition(ItemType type) const
|
||||
|
||||
@@ -201,7 +201,7 @@ void GraphicsScene::cut()
|
||||
void GraphicsScene::removeSelectedItems()
|
||||
{
|
||||
QVector<ScxmlTag*> tags = SceneUtils::findRemovedTags(m_baseItems);
|
||||
if (tags.count() > 0) {
|
||||
if (!tags.isEmpty()) {
|
||||
m_document->undoStack()->beginMacro(tr("Remove items"));
|
||||
|
||||
// Then remove found tags
|
||||
@@ -235,7 +235,7 @@ void GraphicsScene::copy()
|
||||
if (tags.isEmpty() && m_document->currentTag())
|
||||
tags << m_document->currentTag();
|
||||
|
||||
if (tags.count() > 0) {
|
||||
if (!tags.isEmpty()) {
|
||||
auto mime = new QMimeData;
|
||||
QByteArray result = m_document->content(tags);
|
||||
mime->setText(QLatin1String(result));
|
||||
|
||||
@@ -92,7 +92,7 @@ void ParallelItem::doLayout(int d)
|
||||
// 3. Relocate children-states
|
||||
// a) sort list
|
||||
QVector<StateItem*> sortedList;
|
||||
while (children.count() > 0) {
|
||||
while (!children.isEmpty()) {
|
||||
qreal minTop = children.first()->boundingRect().top();
|
||||
int minTopIndex = 0;
|
||||
for (int i = 1; i < children.count(); ++i) {
|
||||
|
||||
@@ -238,7 +238,7 @@ void layout(const QList<QGraphicsItem*> &items)
|
||||
|
||||
int startAngle = qrand() % 2 == 0 ? 180 : 90;
|
||||
int startDistance = 40 + childItems.count() * 10;
|
||||
if (childItems.count() > 0) {
|
||||
if (!childItems.isEmpty()) {
|
||||
// Init position of the items
|
||||
int angleDiff = 360 / (childItems.count() + 1);
|
||||
for (int i = 0; i < childItems.count(); ++i) {
|
||||
|
||||
@@ -400,7 +400,7 @@ void ScxmlDocument::printSCXML()
|
||||
QByteArray ScxmlDocument::content(const QVector<ScxmlTag*> &tags) const
|
||||
{
|
||||
QByteArray result;
|
||||
if (tags.count() > 0) {
|
||||
if (!tags.isEmpty()) {
|
||||
QBuffer buffer(&result);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
|
||||
@@ -666,7 +666,7 @@ ScxmlTag *ScxmlDocument::popRootTag()
|
||||
|
||||
void ScxmlDocument::deleteRootTags()
|
||||
{
|
||||
while (m_rootTags.count() > 0)
|
||||
while (!m_rootTags.isEmpty())
|
||||
delete m_rootTags.takeLast();
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ void ScxmlTag::setContent(const QString &content)
|
||||
|
||||
bool ScxmlTag::hasData() const
|
||||
{
|
||||
if (m_attributeNames.count() > 0 || !m_content.isEmpty())
|
||||
if (!m_attributeNames.isEmpty() || !m_content.isEmpty())
|
||||
return true;
|
||||
|
||||
foreach (ScxmlTag *tag, m_childTags) {
|
||||
|
||||
@@ -264,7 +264,7 @@ void initChildMenu(TagType tagType, QMenu *menu)
|
||||
|
||||
QVector<TagType> childTags = childTypes(tagType);
|
||||
|
||||
if (childTags.count() > 0) {
|
||||
if (!childTags.isEmpty()) {
|
||||
for (int i = 0; i < childTags.count(); ++i) {
|
||||
if (childTags[i] == OnEntry || childTags[i] == OnExit)
|
||||
initChildMenu(childTags[i], menu->addMenu(QLatin1String(scxml_tags[childTags[i]].name)));
|
||||
|
||||
@@ -120,7 +120,7 @@ void StateItem::updateAttributes()
|
||||
QString strNewId = tagValue("id", true);
|
||||
if (!m_parallelState) {
|
||||
QStringList NSIDs = strNewId.split(tag()->document()->nameSpaceDelimiter(), QString::SkipEmptyParts);
|
||||
if (NSIDs.count() > 0) {
|
||||
if (!NSIDs.isEmpty()) {
|
||||
NSIDs[NSIDs.count() - 1] = m_stateNameItem->toPlainText();
|
||||
QString strOldId = NSIDs.join(tag()->document()->nameSpaceDelimiter());
|
||||
ScxmlTag *parentTag = tag()->parentTag();
|
||||
@@ -388,7 +388,7 @@ void StateItem::checkInitial(bool parent)
|
||||
tag = this->tag();
|
||||
}
|
||||
|
||||
if (items.count() > 0 && tag && uiFactory()) {
|
||||
if (!items.isEmpty() && tag && uiFactory()) {
|
||||
auto utilsProvider = static_cast<UtilsProvider*>(uiFactory()->object("utilsProvider"));
|
||||
if (utilsProvider)
|
||||
utilsProvider->checkInitialState(items, tag);
|
||||
|
||||
@@ -133,7 +133,7 @@ void TransitionItem::createGrabbers()
|
||||
if (m_cornerGrabbers.count() != m_cornerPoints.count()) {
|
||||
int selectedGrabberIndex = m_cornerGrabbers.indexOf(m_selectedCornerGrabber);
|
||||
|
||||
if (m_cornerGrabbers.count() > 0) {
|
||||
if (!m_cornerGrabbers.isEmpty()) {
|
||||
qDeleteAll(m_cornerGrabbers);
|
||||
m_cornerGrabbers.clear();
|
||||
}
|
||||
@@ -158,7 +158,7 @@ void TransitionItem::createGrabbers()
|
||||
|
||||
void TransitionItem::removeGrabbers()
|
||||
{
|
||||
if (m_cornerGrabbers.count() > 0) {
|
||||
if (!m_cornerGrabbers.isEmpty()) {
|
||||
qDeleteAll(m_cornerGrabbers);
|
||||
m_cornerGrabbers.clear();
|
||||
}
|
||||
@@ -267,7 +267,7 @@ void TransitionItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
m_cornerPoints.append(p);
|
||||
snapToAnyPoint(m_cornerPoints.count() - 1, p);
|
||||
|
||||
if (m_cornerGrabbers.count() > 0) {
|
||||
if (!m_cornerGrabbers.isEmpty()) {
|
||||
auto corner = new CornerGrabberItem(this);
|
||||
corner->setGrabberType(CornerGrabberItem::Circle);
|
||||
corner->setPos(p);
|
||||
@@ -615,7 +615,7 @@ void TransitionItem::connectToTopItem(const QPointF &pos, TransitionPoint tp, It
|
||||
|
||||
// First try to find parentItem
|
||||
QList<QGraphicsItem*> items = scene()->items(p);
|
||||
if (items.count() > 0) {
|
||||
if (!items.isEmpty()) {
|
||||
for (int i = 0; i < items.count(); ++i) {
|
||||
ItemType type = ItemType(items[i]->type());
|
||||
if ((targetType == UnknownType && type >= FinalStateType) || type >= StateType) {
|
||||
@@ -797,7 +797,7 @@ QPointF TransitionItem::findIntersectionPoint(ConnectableItem *item, const QLine
|
||||
|
||||
// Find intersection point between line and target item
|
||||
QPolygonF itemPolygon = item->polygonShape();
|
||||
if (itemPolygon.count() > 0) {
|
||||
if (!itemPolygon.isEmpty()) {
|
||||
QPointF intersectPoint;
|
||||
QPointF p1 = itemPolygon.at(0) + item->scenePos();
|
||||
QPointF p2;
|
||||
|
||||
Reference in New Issue
Block a user