Пример #1
0
void MenuItemMgr::insertMenu( Qtitan::RibbonGroup* rGroup , QWidgetAction* item )
{
	QObjectList::iterator it ;

	QActionGroup* pActionGroup = myMainWindow->getActionGroup() ;
	Q_ASSERT( pActionGroup!= NULL ) ;

	QObjectList menuitems = item->children() ;
	if( menuitems.isEmpty() )
		return  ;

	for( it = menuitems.begin() ; it != menuitems.end() ; it++ )
	{
		QWidgetAction *wa = (QWidgetAction*)*it ; 
		if( wa->children().isEmpty() )
		{
			// 不含有子菜单
			//QAction* action = rGroup->addAction( wa->icon(), 
			//	              wa->text(), Qt::ToolButtonTextUnderIcon);
			rGroup->addAction(wa, Qt::ToolButtonTextUnderIcon);
			registerAction( wa ) ;
			pActionGroup->addAction( wa ) ;
            
		}
		else
		{
			// 含有子菜单
			 QMenu* menuPopup = rGroup->addMenu( wa->icon(), 
				 wa->text() , Qt::ToolButtonTextUnderIcon);

			insertMenu( menuPopup , wa ) ;
		}
	}

}
Пример #2
0
AbstractView* ViewLoader::loadFromPlugin(AbstractView *currentView, const QString &menuAction)
{
	AbstractView *view = nullptr;

	// Other views loaded from plugins
	QMultiMap<QString, QObject*> multiMap = _pluginManager->dependencies();
	QObjectList dep = multiMap.values(menuAction);
	if (dep.isEmpty()) {
		return view;
	}
	qDebug() << Q_FUNC_INFO << "No built-in view was found for this action. Was it from an external plugin?";
	for (BasicPlugin *plugin : _pluginManager->loadedPlugins().values()) {
		if (plugin->name() != menuAction) {
			continue;
		}

		// Check if we need to pass some objects from old view to new view, because new one can be brought by plugins
		// For example, a plugin may need the MediaPlayerControl from the current view
		if (MediaPlayerPlugin *mediaPlayerPlugin = qobject_cast<MediaPlayerPlugin*>(plugin)) {
			mediaPlayerPlugin->setMediaPlayerControl(currentView->mediaPlayerControl());
			if (mediaPlayerPlugin->hasView()) {
				view = mediaPlayerPlugin->instanciateView();
				view->setOrigin(currentView);
			}
		}
	}
	return view;
}
Пример #3
0
void QWidgetPrivate::raise_sys()
{
    Q_Q(QWidget);
    //@@@ transaction
    if (q->isWindow()) {
        Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
        QWidget::qwsDisplay()->setAltitude(q->internalWinId(),
                                           QWSChangeAltitudeCommand::Raise);
        // XXX: subsurfaces?
#ifdef QT_NO_WINDOWGROUPHINT
#else
        QObjectList childObjects =  q->children();
        if (!childObjects.isEmpty()) {
            QWidgetList toraise;
            for (int i = 0; i < childObjects.size(); ++i) {
                QObject *obj = childObjects.at(i);
                if (obj->isWidgetType()) {
                    QWidget* w = static_cast<QWidget*>(obj);
                    if (w->isWindow())
                        toraise.append(w);
                }
            }

            for (int i = 0; i < toraise.size(); ++i) {
                QWidget *w = toraise.at(i);
                if (w->isVisible())
                    w->raise();
            }
        }
#endif // QT_NO_WINDOWGROUPHINT
    }
}
Пример #4
0
void NameList::appendLeaves(QObject *object) {
    QObjectList children = object->children();
    if (children.isEmpty())
        leaves.append(object);
    else for (int i = 0; i < children.size(); ++i) {
        appendLeaves(children[i]);
    }
}
void 
PatternWidgetClass::init()
{
  // delete all childs
  QObjectList * childs;
  while((childs =  const_cast<QObjectList *>(this->children())) != NULL && 
	!childs->isEmpty()) {
    delete childs->first();
  }

  // resize widget //
  int numBehaviours = getDocument().getNumBehaviours(patternName);
  setFixedSize(100,
	       PATTERN_NAME_HEIGHT + 
	       BEHAVIOUR_NAME_HEIGHT * numBehaviours + 
	       ARBITER_NAME_HEIGHT +
	       2*frameWidth());

  // get internal rect dimensions (inside the frame) //
  QRect cr = contentsRect();


  //----------------//
  // behaviour list //
  //----------------//

   // get string list with behaviour names //
   QStringList list = getDocument().getBehaviourNames(patternName);

   // show all behaviour names //
   int i = 0;
   for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
     QString behName = (*it);

     // create new label //
     BehaviourWidget* behWidget = new BehaviourWidget(this, behName);
     behWidget->setGeometry(cr.x(), 
			    cr.y()+PATTERN_NAME_HEIGHT+i*BEHAVIOUR_NAME_HEIGHT,
			    cr.width(), BEHAVIOUR_NAME_HEIGHT);  
     behWidget->show();

     i++;
   }


  //---------//
  // arbiter //
  //---------//

  ArbiterWidget * arbiterWidget = 
    new ArbiterWidget(this, getDocument().getArbiter(patternName));
  arbiterWidget->setGeometry(cr.x(), cr.y()+cr.height()-ARBITER_NAME_HEIGHT, 
			     cr.width(), ARBITER_NAME_HEIGHT);  
  arbiterWidget->show();

  update();
}
Пример #6
0
QStringList Folder::subfolders() {
  QStringList subFolderList = QStringList();
  QObjectList folderList = children();
  if (!folderList.isEmpty()) {
    QObject *folder;
    foreach (folder, folderList)
      subFolderList << static_cast<Folder *>(folder)->name();
  }
  return subFolderList;
}
Пример #7
0
QStringList Folder::subfolders()
{
	QStringList list = QStringList();
	QObjectList folderList = children();
	if (!folderList.isEmpty()){
		QObject * f;
		foreach(f,folderList)
			list << static_cast<Folder *>(f)->objectName();
	}
	return list;
}
void
DocumentXML::clear()
{
  document_.removeChild(document_.documentElement());
  setModified(true);

  if(!children().isEmpty()) {
    QObjectList childList = children();
    while(!childList.isEmpty()) {
      delete childList.takeFirst();
    }
  }
}
Пример #9
0
// from: http://stackoverflow.com/questions/5298614/change-the-size-of-qt-dialogs-depending-on-the-platform
void MainWindow::adjustAppearanceToOS(QWidget *rootWidget)
{
    int fontSize = -1;
    #ifdef Q_OS_WIN
        fontSize = 8;
    #elif __APPLE__
        fontSize = 12;
    #elif __linux
        fontSize = 11;
    #endif

    if (rootWidget == NULL)
        return;

    QObject *child = NULL;
    QObjectList Containers;
    QObject *container  = NULL;
    QStringList DoNotAffect;

    // Make an exception list (Objects not to be affected)
    // DoNotAffect.append("widgetName");

    // Append root to containers
    Containers.append(rootWidget);

    while (!Containers.isEmpty())
    {
        container = Containers.takeFirst();
        if (container != NULL)
            for (int i = 0; i < container->children().size(); i++)
            {
                child = container->children()[i];
                if (!child->isWidgetType() || DoNotAffect.contains(child->objectName()))
                    continue;

                if (child->children().size() > 0)
                    Containers.append(child);

                // (if the object is not of the correct type, it will be NULL)
                QLabel *label = qobject_cast<QLabel *>(child);
                if (label != NULL)
                {
                    label->setText(label->text().replace(QRegExp("font-size:.*;"), ""));

                    QFont font = label->font();
                    font.setPointSize(fontSize);
                    label->setFont(font);
                }
            }
    }
}
Пример #10
0
/*!
    Changes the layout of the group box. This function is only useful
    in combination with the default constructor that does not take any
    layout information. This function will put all existing children
    in the new layout. It is not good Qt programming style to call
    this function after children have been inserted. Sets the number
    of columns or rows to be \a strips, depending on \a direction.

    \sa orientation columns
*/
void Q3GroupBox::setColumnLayout(int strips, Qt::Orientation direction)
{
    if (layout())
        delete layout();

    d->vbox = 0;
    d->grid = 0;

    if (strips < 0) // if 0, we create the d->vbox but not the d->grid. See below.
        return;

    d->vbox = new QVBoxLayout(this, d->marg, 0);

    d->nCols = 0;
    d->nRows = 0;
    d->dir = direction;

    // Send all child events and ignore them. Otherwise we will end up
    // with doubled insertion. This won't do anything because d->nCols ==
    // d->nRows == 0.
    QApplication::sendPostedEvents(this, QEvent::ChildInserted);

    // if 0 or smaller , create a vbox-layout but no grid. This allows
    // the designer to handle its own grid layout in a group box.
    if (strips <= 0)
        return;

    d->dir = direction;
    if (d->dir == Qt::Horizontal) {
        d->nCols = strips;
        d->nRows = 1;
    } else {
        d->nCols = 1;
        d->nRows = strips;
    }
    d->grid = new QGridLayout(d->nRows, d->nCols, d->spac);
    d->row = d->col = 0;
    d->grid->setAlignment(Qt::AlignTop);
    d->vbox->addLayout(d->grid);

    // Add all children
    QObjectList childList = children();
    if (!childList.isEmpty()) {
        for (int i = 0; i < childList.size(); ++i) {
            QObject *o = childList.at(i);
            if (o->isWidgetType() && o != d->checkbox)
                insertWid(static_cast<QWidget *>(o));
        }
    }
}
Пример #11
0
DlgPreferencePage* DlgPreferences::currentPage() {
    QObject* pObject = pagesWidget->currentWidget();
    for (int i = 0; i < 2; ++i) {
        if (pObject == NULL) {
            return NULL;
        }
        QObjectList children = pObject->children();
        if (children.isEmpty()) {
            return NULL;
        }
        pObject = children[0];
    }
    return dynamic_cast<DlgPreferencePage*>(pObject);
}
//----------------------------------------------------------------------------
ctkCmdLineModuleObjectTreeWalker::TokenType ctkCmdLineModuleObjectTreeWalker::readNext()
{
  if (AtEnd) return NoToken;

  QObject* curr = 0;
  if (CurrentObject == 0)
  {
    curr = RootObject;
    if (setCurrent(curr)) return CurrentToken;
  }
  else
  {
    curr = CurrentObject;
  }

  while (true)
  {
    if (curr)
    {
      QObjectList children = curr->children();
      QListIterator<QObject*> i(children);
      i.toBack();
      while (i.hasPrevious())
      {
        ObjectStack.push(i.previous());
      }
      if (children.isEmpty())
      {
        curr = 0;
      }
      else
      {
        curr = ObjectStack.pop();
        if (setCurrent(curr)) return CurrentToken;
      }
      continue;
    }

    if (ObjectStack.isEmpty()) break;
    curr = ObjectStack.pop();
    if (setCurrent(curr)) return CurrentToken;
  }

  AtEnd = true;
  CurrentObject = 0;
  CurrentToken = NoToken;

  return NoToken;
}
Пример #13
0
void YGWidget::deleteAllSubuis()
{
    QObjectList childList = children();
    if(!childList.isEmpty())
    {
        for (int i = 0; i < childList.size(); ++i)
        {
            YGWidget* wgt = qobject_cast<YGWidget*>(childList.at(i));
            if(wgt)
            {
                wgt->deleteLater();
            }
        }
    }
}
Пример #14
0
void YGWidget::deleteMsgBox()
{
    QObjectList childList = children();
    if(!childList.isEmpty())
    {
        for (int i = 0; i < childList.size(); ++i)
        {
            YGMsgBox* wgt = qobject_cast<YGMsgBox*>(childList.at(i));
            if(wgt)
            {
                //wgt->finished();
            }
        }
    }
}
Пример #15
0
void
DocumentXML::clear()
{
  // Remove the root element
  document_.removeChild(document_.documentElement());
  // Notify that the document has been modified
  setModified(true);

  // Delete all children of the QObject
  if(!children().isEmpty()) {
    QObjectList childList = children();
    while(!childList.isEmpty()) {
      delete childList.takeFirst();
    }
  }
}
Пример #16
0
Item::~Item()
{
  //  cout << name() << " deleting children" << endl;

  if (!children().isEmpty()) {
    QObjectList childList = children();
    while(!childList.isEmpty() ) {
      delete childList.takeFirst();
    }
  }

  //  cout << name() << " deleting listviewitem" << endl;

  delete treeWidgetItem_;
  // Remove the QTreeWidgetItem from the map to Item
  itemMap_.erase(treeWidgetItem_);

  //  cout << name() << " deleting" << endl;
}
Пример #17
0
void QSAEditor::completeQObject(const QVector<QObject *> &objects,
                                    const QString &object,
                                    QVector<CompletionEntry> &res)
{
    for ( int i = 0; i < objects.count(); i++ ) {
        QObject *qobj = objects[ i ];
        if ( !qobj )
            continue;
        // children
        QObjectList clist;
        if ( qobj == qApp )
            clist = interpreter()->topLevelObjects() != 0 ?
                    *((QObjectList*)interpreter()->topLevelObjects()) :
                    QObjectList();
        else
            clist = qobj->children();

        if ( !clist.isEmpty() ) {
            for (int ci = 0; ci<clist.size(); ++ci) {
                const QObject *o = clist.at(ci);
                CompletionEntry c;
                c.type = o->isWidgetType() ? "widget" : "object";
                c.text = o->objectName();
                c.postfix2 = o->metaObject()->className();
                if ( !c.postfix2.isEmpty() )
                    c.postfix2.prepend( QString::fromLatin1(" : ") );
                res << c;
            }
        }

        QSObject qsobj = interpreter()->wrap( qobj );
        int flags = 0;
        if ( i == 0 )
            flags |= IncludeSuperClass;
        completeQMetaObject( qobj->metaObject(),
                             object,
                             res,
                             flags,
                             qsobj
                             );

    }
}
Пример #18
0
Folder* Folder::findSubfolder(const QString& s, bool caseSensitive, bool partialMatch)
{
	QObjectList folderList = children();
	if (!folderList.isEmpty()){
		QObject * f;

		foreach(f,folderList){
			QString name = static_cast<Folder *>(f)->name();
			if (partialMatch){
				if (caseSensitive && name.startsWith(s,Qt::CaseSensitive))
					return static_cast<Folder *>(f);
				else if (!caseSensitive && name.startsWith(s,Qt::CaseInsensitive))
					return static_cast<Folder *>(f);
			}
			else // partialMatch == false
			{
				if (caseSensitive && name == s)
					return static_cast<Folder *>(f);
				else if ( !caseSensitive && (name.toLower() == s.toLower()) )
					return static_cast<Folder *>(f);
			}
		}
void 
PolicyView::init(PolicyXML * _policy)
{
  if (policy_ == _policy)
    return;

  // delete all childs
  QObjectList * childs;
  while((childs =  const_cast<QObjectList *>(viewport()->children())) != NULL && 
	!childs->isEmpty()) {
    delete childs->first();
  }

  policy_ = _policy;

  if (policy_ == NULL)
    return;

  policy_->setWidget(this);

  //-------------------------
  // rebuild the widget list

  QListViewItem * i = policy_->listViewItem()->firstChild();
  while (i != NULL) {
    Item * item = policy_->itemFromListViewItem(i);
    PatternXML * pattern = dynamic_cast<PatternXML *>(item);
    if (pattern != NULL)
      addPatternWidget(pattern);

    i = i->nextSibling();
  }

  QRect r = viewport()->childrenRect();
  QPoint s = viewportToContents(r.bottomRight());

  resizeContents(s.x(), s.y());
  setContentsPos(0, 0);
}
void 
PolicyViewClass::init()
{
  // delete all childs
  QObjectList * childs;
  while((childs =  const_cast<QObjectList *>(viewport()->children())) != NULL && 
	!childs->isEmpty()) {
    delete childs->first();
  }

  //-------------------------//
  // rebuild the widget list //
  //-------------------------//

  QStringList list = document.getPatternNames();

  QStringList::Iterator patternIter = list.begin();
  while (patternIter !=list.end()) {
    // generate pattern widget //
    QString patternName = *patternIter;

    PatternWidgetClass* patternWidget = new PatternWidgetClass(this, viewport(), patternName);
    patternWidget->show(); 
    int x = std::max(0, document.getX(patternName));
    int y = std::max(0, document.getY(patternName));
    addChild(patternWidget, x, y);

    patternIter++;
  }

  QRect r = viewport()->childrenRect();
  QPoint s = viewportToContents(r.bottomRight());

  resizeContents(s.x(), s.y());
  setContentsPos(0, 0);
}
Пример #21
0
/*!
    \reimp
*/
void Q3WidgetStack::setVisible(bool visible)
{
    if (visible) {
        //  Reimplemented in order to set the children's geometries
        //  appropriately and to pick the first widget as d->topWidget if no
        //  topwidget was defined
        QObjectList c = children();
        if (!isVisible() && !c.isEmpty()) {
            for (int i = 0; i < c.size(); ++i) {
                QObject * o = c.at(i);
                if (o->isWidgetType()) {
                    if (!topWidget && o != invisible)
                        topWidget = static_cast<QWidget*>(o);
                    if (o == topWidget)
                        static_cast<QWidget *>(o)->show();
                    else
                        static_cast<QWidget *>(o)->hide();
                }
            }
            setChildGeometries();
        }
    }
    Q3Frame::setVisible(visible);
}
Пример #22
0
void QtHelpers::GenAdjustWidgetAppearanceToOS(QWidget *rootWidget)
{
    if (rootWidget == NULL)
            return;

        QObject *child = NULL;
        QObjectList Containers;
        QObject *container  = NULL;
        QStringList DoNotAffect;

        // Make an exception list (Objects not to be affected)
        DoNotAffect.append("aboutTitleLabel");     // about Dialog
        DoNotAffect.append("aboutVersionLabel");   // about Dialog
        DoNotAffect.append("aboutCopyrightLabel"); // about Dialog
        DoNotAffect.append("aboutUrlLabel");       // about Dialog
        DoNotAffect.append("aboutLicenseLabel");   // about Dialog

        // Set sizes according to OS:
    #ifdef __APPLE__
        int ButtonHeight = 35;
        int cmbxHeight = 30;
        QFont cntrlFont("Myriad Pro", 14);
        QFont txtFont("Myriad Pro", 14);
    #elif _WIN32 // Win XP/7
        int ButtonHeight = 24;
        int cmbxHeight = 20;
        QFont cntrlFont("MS Shell Dlg 2", 8);
        QFont txtFont("MS Shell Dlg 2", 8);
    #else
        int ButtonHeight = 24;
        int cmbxHeight = 24;
        QFont cntrlFont("Ubuntu Condensed", 10);
        QFont txtFont("Ubuntu", 10);
    #endif

        // Append root to containers
        Containers.append(rootWidget);
        while (!Containers.isEmpty())
        {
            container = Containers.takeFirst();
            if (container != NULL)
            {
                for (int ChIdx=0; ChIdx < container->children().size(); ChIdx++)
                {
                    child = container->children()[ChIdx];
                    if (!child->isWidgetType() || DoNotAffect.contains(child->objectName()))
                        continue;
                    // Append containers to Stack for recursion
                    if (child->children().size() > 0)
                        Containers.append(child);
                    else
                    {
                        // Cast child object to button and label
                        // (if the object is not of the correct type, it will be NULL)
                        QPushButton *button = qobject_cast<QPushButton *>(child);
                        QLabel *label = qobject_cast<QLabel *>(child);
                        QComboBox *cmbx = qobject_cast<QComboBox *>(child);
                        QLineEdit *ln = qobject_cast<QLineEdit *>(child);
                        QTreeWidget *tree = qobject_cast<QTreeWidget *>(child);
                        QPlainTextEdit *plain = qobject_cast<QPlainTextEdit *>(child);
                        QCheckBox *check = qobject_cast<QCheckBox *>(child);
                        if (button != NULL)
                        {
                            button->setMinimumHeight(ButtonHeight); // Win
                            button->setMaximumHeight(ButtonHeight); // Win
                            button->setFont(cntrlFont);
                        }
                        else if (cmbx != NULL)
                        {
                            cmbx->setFont(cntrlFont);
                            cmbx->setMaximumHeight(cmbxHeight);
                        }
                        else if (label != NULL)
                            label->setFont(txtFont);
                        else if (ln != NULL)
                            ln->setFont(txtFont);
                        else if (tree != NULL)
                        {
                            tree->header()->setFont(txtFont);
                        }
                        else if (plain != NULL)
                            plain->setFont(txtFont);
                        else if (check != NULL)
                            check->setFont(txtFont);
                    }
                }
            }
        }
}
Пример #23
0
void XDataWidget::setFields(const XData::FieldList &f)
{
    fields_.clear();

    // delete all child widgets
    QObjectList objlist = queryList();
    while (!objlist.isEmpty()) {
        delete objlist.takeFirst();
    }


    QVBoxLayout* vert = new QVBoxLayout(this);
    if (!instructions_.isEmpty()) {
        QLabel* l = new QLabel(instructions_, this);
        l->setWordWrap(true);
        l->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::LinksAccessibleByMouse);
        connect(l,SIGNAL(linkActivated(const QString&)),SLOT(linkActivated(const QString&)));
        vert->addWidget(l);
    }
    QWidget *fields = new QWidget(this);
    vert->addWidget(fields);
    if ( f.count() ) {
        QGridLayout *grid = new QGridLayout(fields, 3, f.count(), 0, 3);

        int row = 0;
        XData::FieldList::ConstIterator it = f.begin();
        for ( ; it != f.end(); ++it, ++row) {
            XDataField *f;
            switch ( (*it).type() ) {
            case XData::Field::Field_Boolean:
                f = new XDataField_Boolean(*it, grid, row, this);
                break;
            case XData::Field::Field_Fixed:
                f = new XDataField_Fixed(*it, grid, row, this);
                break;
            case XData::Field::Field_Hidden:
                f = new XDataField_Hidden(*it);
                break;
            case XData::Field::Field_JidSingle:
                f = new XDataField_JidSingle(*it, grid, row, this);
                break;
            case XData::Field::Field_ListMulti:
                f = new XDataField_ListMulti(*it, grid, row, this);
                break;
            case XData::Field::Field_ListSingle:
                f = new XDataField_ListSingle(*it, grid, row, this);
                break;
            case XData::Field::Field_TextMulti:
                f = new XDataField_TextMulti(*it, grid, row, this);
                break;
            case XData::Field::Field_JidMulti:
                f = new XDataField_JidMulti(*it, grid, row, this);
                break;
            case XData::Field::Field_TextPrivate:
                f = new XDataField_TextPrivate(*it, grid, row, this);
                break;

            default:
                f = new XDataField_TextSingle(*it, grid, row, this);
            }
            fields_.append(f);
        }
    }
}