src/tools/uic/cpp/cppwriteinitialization.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the tools applications of the Qt Toolkit.
     7 ** This file is part of the tools applications of the Qt Toolkit.
     8 **
     8 **
   719             }
   719             }
   720 
   720 
   721             m_output << m_indent << parentWidget << "->addDockWidget(" << area << varName << ");\n";
   721             m_output << m_indent << parentWidget << "->addDockWidget(" << area << varName << ");\n";
   722         } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStatusBar"))) {
   722         } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStatusBar"))) {
   723             m_output << m_indent << parentWidget << "->setStatusBar(" << varName << ");\n";
   723             m_output << m_indent << parentWidget << "->setStatusBar(" << varName << ");\n";
   724         } else {
   724         } else if (!m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3DockWindow"))
   725             m_output << m_indent << parentWidget << "->setCentralWidget(" << varName << ");\n";
   725                    && !m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3ToolBar"))) {
       
   726                 m_output << m_indent << parentWidget << "->setCentralWidget(" << varName << ");\n";
   726         }
   727         }
   727     }
   728     }
   728 
   729 
   729     // Check for addPageMethod of a custom plugin first
   730     // Check for addPageMethod of a custom plugin first
   730     const QString addPageMethod = m_uic->customWidgetsInfo()->customWidgetAddPageMethod(parentClass);
   731     const QString addPageMethod = m_uic->customWidgetsInfo()->customWidgetAddPageMethod(parentClass);
  1219         // special case for the property `geometry': Do not use position
  1220         // special case for the property `geometry': Do not use position
  1220         if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) {
  1221         if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) {
  1221             const DomRect *r = p->elementRect();
  1222             const DomRect *r = p->elementRect();
  1222             m_output << m_indent << varName << "->resize(" << r->elementWidth() << ", " << r->elementHeight() << ");\n";
  1223             m_output << m_indent << varName << "->resize(" << r->elementWidth() << ", " << r->elementHeight() << ");\n";
  1223             continue;
  1224             continue;
  1224         } else if (propertyName == QLatin1String("buttonGroupId") && buttonGroupWidget) { // Q3ButtonGroup support
  1225         } else if (propertyName == QLatin1String("buttonGroupId")) { // Q3ButtonGroup support
  1225             m_output << m_indent << m_driver->findOrInsertWidget(buttonGroupWidget) << "->insert("
  1226             if (buttonGroupWidget)
  1226                    << varName << ", " << p->elementNumber() << ");\n";
  1227                 m_output << m_indent << m_driver->findOrInsertWidget(buttonGroupWidget) << "->insert("
       
  1228                          << varName << ", " << p->elementNumber() << ");\n";
  1227             continue;
  1229             continue;
  1228         } else if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow
  1230         } else if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow
  1229                     && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) {
  1231                     && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) {
  1230             m_delayedOut << m_indent << varName << "->setCurrentRow("
  1232             m_delayedOut << m_indent << varName << "->setCurrentRow("
  1231                        << p->elementNumber() << ");\n";
  1233                        << p->elementNumber() << ");\n";
  2784 {
  2786 {
  2785     if (directives.isEmpty())
  2787     if (directives.isEmpty())
  2786         return;
  2788         return;
  2787 
  2789 
  2788     QMap<QString, bool> map; // bool is dummy. The idea is to sort that (always generate in the same order) by putting a set into a map
  2790     QMap<QString, bool> map; // bool is dummy. The idea is to sort that (always generate in the same order) by putting a set into a map
  2789     foreach (QString str, directives)
  2791     foreach (const QString &str, directives)
  2790         map[str] = true;
  2792         map.insert(str, true);
  2791 
  2793 
  2792     if (map.size() == 1) {
  2794     if (map.size() == 1) {
  2793         outputStream << "#ifndef " << map.constBegin().key() << endl;
  2795         outputStream << "#ifndef " << map.constBegin().key() << endl;
  2794         return;
  2796         return;
  2795     }
  2797     }
  2796 
  2798 
  2797     outputStream << "#if";
  2799     outputStream << "#if";
  2798     bool doOr = false;
  2800     bool doOr = false;
  2799     foreach (QString str, map.keys()) {
  2801     foreach (const QString &str, map.keys()) {
  2800         if (doOr)
  2802         if (doOr)
  2801             outputStream << " ||";
  2803             outputStream << " ||";
  2802         outputStream << " !defined(" << str << ')';
  2804         outputStream << " !defined(" << str << ')';
  2803         doOr = true;
  2805         doOr = true;
  2804     }
  2806     }