Beispiel #1
0
void BaseMainPage::focusNextRightChild()
{
	if(!m_pCtrlPage)
		return;
	if(isNavigatorMode())
	{
		if(m_nNavigatorCnt <= 0)
			return;

		int tindex = (m_nCurrentNavigator+1)%m_nNavigatorCnt;
		navigatorPageAt(tindex);
		return;
	}

	QObjectList list = m_pCtrlPage->xList;
	if(list.length() == 0)
		return;

	QObject *obj = m_pCtrlPage->focusWidget();
	int index = list.indexOf(obj);
	if(index == -1)
		index = list.length()-1;
	if(index == list.length()-1)
	{
		index = -1;
	}
	index++;
	QWidget *tab =static_cast<QWidget *>(list.at(index));
	tab->setFocus();
}
/*!
  Selects a whole unit group.

  It has to be created first, of course.
  */
void CcfQmlBaseScenario::selectGroup(int groupNumber)
{
    if (groupNumber < 0)
        return;

    QObjectList group = mUnitGroups.value(groupNumber);
    deselectAllUnits();

    for (int i = 0; i < group.length(); ++i) {
        group.at(i)->set("selected", true);
    }
}
///
/// \brief Form_PlatformConfiguration::traversalControl
/// \param q
/// save
///
void Form_PlatformConfiguration::traversalControl(const QObjectList& q)
{
    for(int i=0;i<q.length();i++)
    {

        if(!q.at(i)->children().empty())
        {
            traversalControl(q.at(i)->children());
        }

        QObject* o = q.at(i);
        if (o->inherits("QLineEdit"))
        {
            QLineEdit* b = qobject_cast<QLineEdit*>(o);
            QDomElement qe= doc_config.createElement(b->objectName());
            qe.setAttribute("Value",b->text());
            qe.setAttribute("Type","QLineEdit");
            doc_config.firstChildElement("root").appendChild(qe);
        }
        else if (o->inherits("QGroupBox"))
        {
            QGroupBox* b = qobject_cast<QGroupBox*>(o);
            QDomElement qe= doc_config.createElement(b->objectName());
            qe.setAttribute("Value",b->isChecked());
            qe.setAttribute("Type","QGroupBox");
            doc_config.firstChildElement("root").appendChild(qe);
        }
        else if (o->inherits("QTableWidget"))
        {
            QTableWidget * b = qobject_cast<QTableWidget*>(o);
            int col_rate = b->objectName() == "table_labels" ? 1:0;
            QDomElement qe= doc_config.createElement(b->objectName());
            qe.setAttribute("Value_R",b->rowCount());
            qe.setAttribute("Value_C",b->columnCount());
            qe.setAttribute("Type","QTableWidget");
            for(int i =0 ; i<b->rowCount() ;i++)
            {
                QDomElement item= doc_config.createElement("R"+QString::number(i));
                for(int j=0 ;j <b->columnCount()  - col_rate; j++)
                {
                    item.setAttribute("C"+QString::number(j), b->item(i,j)->text());
                }
                qe.appendChild(item);
            }
            doc_config.firstChildElement("root").appendChild(qe);
        }
    }

}
void Form_PlatformConfiguration::LoadConfig(const QObjectList &q)
{
    for(int i=0;i<q.length();i++)
    {

        if(!q.at(i)->children().empty())
        {
            LoadConfig(q.at(i)->children());
        }

        QObject* obj = q.at(i);

        if (obj->inherits("QLineEdit"))
        {
            QLineEdit *b = qobject_cast<QLineEdit*>(obj);
            QString Name = obj->objectName();
            QDomNode node = STT_Global::FindXml(doc_config,Name);
            if(!node.isNull() ) b->setText(node.attributes().namedItem("Value").nodeValue() );

        }
        else if (obj->inherits("QGroupBox"))
        {
            QGroupBox* b = qobject_cast<QGroupBox*>(obj);
            QDomNode node = STT_Global::FindXml(doc_config,b->objectName());
            if(!node.isNull() ) b->setChecked( node.attributes().namedItem("Value").nodeValue() == "1" ? true:false);
        }
        else if (obj->inherits("QTableWidget"))
        {
            QTableWidget* b = qobject_cast<QTableWidget*>(obj);
            QDomNode node = STT_Global::FindXml(doc_config,b->objectName());
            if( !node.isNull() )
            {
              int Value_R =  node.attributes().namedItem("Value_R").nodeValue().toInt();
              int Value_C =  node.attributes().namedItem("Value_C").nodeValue().toInt();
              b->setRowCount(Value_R);

              for(int i =0 ; i<Value_R ;i++)
              {
                  QDomNode item= node.childNodes().at(i);
                  for(int j=0 ;j < Value_C ; j++)
                  {
                      b->setItem(i, j, new QTableWidgetItem(item.attributes().namedItem("C"+QString::number(j)).nodeValue()));
                  }
              }
            }
        }
    }
}
Beispiel #5
0
bool SGMainWindowEvent::eventFilter(QObject* object, QEvent* evt) {
	QWidget* focusWidget = QApplication::focusWidget();
	if (focusWidget == NULL) return true;
	if (m_focusWidgetName == focusWidget->objectName().toStdString().c_str()) return QObject::eventFilter(object, evt);

	QObjectList objList = focusWidget->children();
	bool glWidgetExists = false;
	for (int i = 0; i < objList.length(); i++) {
		QWidget* widget = (QWidget*)objList[i];
		QObjectList objList2 = widget->children();
		for (int j = 0; j < objList2.length(); j++) {
			QWidget* widget2 = (QWidget*)objList2[j];
			if (strcmp(widget2->metaObject()->className(), "QmayaGLWidget") == 0) {
				if (m_beforeWidget != NULL) {
					m_beforeWidget->releaseKeyboard();
					m_beforeWidget->removeEventFilter(toolEvent);
				}
				widget2->installEventFilter(toolEvent);
				widget2->grabKeyboard();

				m_beforeWidget = widget2;

				m_focusWidgetName = focusWidget->objectName().toStdString().c_str();
				glWidgetExists = true;

				SGKey::initializeKeys();
				SGMouse::initializeButtons();
				break;
			}
		}
		if (glWidgetExists)break;
	}

	if (!glWidgetExists) {
		if (m_beforeWidget != NULL) {
			m_beforeWidget->releaseKeyboard();
			m_beforeWidget->removeEventFilter(toolEvent);
		}
		m_focusWidgetName = focusWidget->objectName().toStdString().c_str();
	}

	return QObject::eventFilter(object, evt);
}
Beispiel #6
0
void WidgetSizeHelper::setDefaultFontSize(QWidget* pWidget) {

    // we get all of pWidget's children
    QObjectList children = pWidget->children();

    // for each child
    for ( int i = 0; i < children.length(); i++ ) {

        /*
         * we change its font size if it is of one of those types
         *
         *  - QLabel
         *  - QLineEdit
         *  - QRadioButton
         *  - QGroupBox
         *  - QCheckBox
         *  - QStatusBar
         */
        QWidget* pChild = static_cast<QWidget*> ( children.at(i) );

        if (  qobject_cast<QLabel*>(pChild) != NULL         ||
              qobject_cast<QLineEdit*>(pChild) != NULL      ||
              qobject_cast<QRadioButton*>(pChild) != NULL   ||
              qobject_cast<QGroupBox*>(pChild) != NULL      ||
              qobject_cast<QCheckBox*>(pChild) != NULL      ||
              qobject_cast<QStatusBar*>(pChild) != NULL )
        {
            QFont lFont = pChild->font();
            lFont.setPointSize(Constants::MAC_FONT_SIZE);
            pChild->setFont(lFont);
        }

        // and scan it, if it has children
        if (  ! pChild->children().isEmpty() ) {

            setDefaultFontSize( pChild );
        }
    }
}
/*!
  Creates an unit group. Usually done with CTRL+number.
  */
void CcfQmlBaseScenario::groupUnits(int groupNumber)
{
    if ((groupNumber < 0) || (selectedUnitsCount() == 0)) {
        return;
    }

    // Remove old members.
    if (groupNumber < mUnitGroups.count()) {
        for (int i = 0; i < mUnitGroups.value(groupNumber).length(); ++i) {
            if (mUnitGroups.value(groupNumber).at(i)->getBool("selected") == false)
                mUnitGroups.value(groupNumber).at(i)->set("groupNumber", 0);
        }
    }

    QObjectList group = selectedUnits();
    mUnitGroups.insert(groupNumber, group);

    for (int i = 0; i < group.length(); ++i) {
        group.at(i)->set("groupNumber", groupNumber);
    }

    //    console.log("Group " + groupNumber + " created.");
    mlogger->statusMessage(tr("Group %1 created.").arg(groupNumber));
}