Skip to content

Commit

Permalink
Release 3.1.4 qt-creator SLE
Browse files Browse the repository at this point in the history
  - Minor fixes to OBJECTIVE_SOURCES from last release
  - New icon
  - Fixed github issues #5, #12 and partially #9
  - Groundwork for OBJECTIVE_HEADERS qmake variable

  * Dev note: Next release will likely have the equivalent of cpptools/
    as objctools/ as well as objective c++ wizards.
  • Loading branch information
NucleaPeon committed Nov 16, 2020
1 parent 0db3a6a commit 21493b4
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 178 deletions.
4 changes: 4 additions & 0 deletions LEFT_OFF
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- First off, auto-add all .m and .mm files into the .pro file OBJECTIVE_{HEADERS/SOURCES}
- Objective C Classes? (struct?) maybe just add in a comment
- Might have to add headers into the wizard to put them in the proper pro file
- If a file has no extension when added, put it in other files
1 change: 1 addition & 0 deletions qtcreator.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OTHER_FILES += dist/copyright_template.txt \
dist/installer/ifw/packages/org.qtproject.qtcreator.application/meta/installscript.qs \
dist/installer/ifw/packages/org.qtproject.qtcreator.application/meta/package.xml.in \
dist/installer/ifw/packages/org.qtproject.qtcreator.application/meta/license.txt \
LEFT_OFF \
$$files(scripts/*.py) \
$$files(scripts/*.sh) \
$$files(scripts/*.pl)
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/cpptools/cppprojectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ ProjectFile::Kind ProjectFile::classify(const QString &file)
return ObjCSource;
if (mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE))
return ObjCXXSource;
if (mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_HEADER_MIMETYPE))
return CXXHeader;
if (mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_HEADER_MIMETYPE))
return Unclassified;
}

Expand Down Expand Up @@ -110,6 +113,8 @@ ProjectFileAdder::ProjectFileAdder(QList<ProjectFile> &files)
addMapping(CppTools::Constants::CPP_HEADER_MIMETYPE, ProjectFile::CXXHeader);
addMapping(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE, ProjectFile::ObjCSource);
addMapping(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE, ProjectFile::ObjCXXSource);
addMapping(CppTools::Constants::OBJECTIVE_C_HEADER_MIMETYPE, ProjectFile::CXXHeader);
addMapping(CppTools::Constants::OBJECTIVE_CPP_HEADER_MIMETYPE, ProjectFile::CXXHeader);
}

ProjectFileAdder::~ProjectFileAdder()
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/cpptools/cpptoolsconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const char C_HEADER_MIMETYPE[] = "text/x-chdr";
const char CPP_SOURCE_MIMETYPE[] = "text/x-c++src";
const char OBJECTIVE_C_SOURCE_MIMETYPE[] = "text/x-objcsrc";
const char OBJECTIVE_CPP_SOURCE_MIMETYPE[] = "text/x-objc++src";
const char OBJECTIVE_C_HEADER_MIMETYPE[] = "text/x-objchdr";
const char OBJECTIVE_CPP_HEADER_MIMETYPE[] = "text/x-objc++hdr";
const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr";

// QSettings keys for use by the "New Class" wizards.
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/objectiveceditor/objectiveceditor.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ HEADERS += \
objectiveceditor.h \
objectiveceditorwidget.h \
objectiveceditorconstants.h \
wizard/objectivecfilewizard.h \
wizard/objectivecclasswizard.h \
wizard/objectivecclassnamepage.h \
wizard/objectivecclasswizarddialog.h \
Expand All @@ -22,19 +21,22 @@ HEADERS += \
tools/objectivecindenter.h \
tools/lexical/objectivecformattoken.h \
tools/lexical/objectivecscanner.h \
tools/lexical/sourcecodestream.h
tools/lexical/sourcecodestream.h \
wizard/objectivecsourcewizard.h \
wizard/objectivecheaderwizard.h

SOURCES += \
objectiveceditorplugin.cpp \
objectiveceditorfactory.cpp \
objectiveceditor.cpp \
objectiveceditorwidget.cpp \
wizard/objectivecfilewizard.cpp \
wizard/objectivecclasswizarddialog.cpp \
wizard/objectivecclasswizard.cpp \
wizard/objectivecclassnamepage.cpp \
wizard/objectivecsourcegenerator.cpp \
tools/objectivechighlighter.cpp \
tools/objectivechighlighterfactory.cpp \
tools/objectivecindenter.cpp \
tools/lexical/objectivecscanner.cpp
tools/lexical/objectivecscanner.cpp \
wizard/objectivecheaderwizard.cpp \
wizard/objectivecsourcewizard.cpp
13 changes: 11 additions & 2 deletions src/plugins/objectiveceditor/objectiveceditorconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,30 @@ const char C_OBJC_DISPLAY_CATEGORY[] = "ObjectiveC";
// source
const char C_OBJC_SOURCE_WIZARD_ID[] = "P.ObjCSource";
const char C_OBJC_SOURCE_CONTENT[] = ""; // Boiler Plate code for top of file
const char EN_OBJC_SOURCE_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("ObjectiveCEditor::FileWizard", "ObjectiveC source file");
const char EN_OBJC_SOURCE_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("ObjectiveCEditor::FileWizard", "ObjectiveC Source file");
const char EN_OBJC_SOURCE_DESCRIPTION[] =
QT_TRANSLATE_NOOP("ObjectiveCEditor::FileWizard", "Creates an empty ObjectiveC source file");

// class
const char C_OBJC_CLASS_WIZARD_ID[] = "P.ObjCClass";
const char EN_OBJC_CLASS_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("ObjectiveCEditor::ClassWizard", "ObjectiveC class");
const char EN_OBJC_CLASS_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("ObjectiveCEditor::ClassWizard", "ObjectiveC Class");
const char EN_OBJC_CLASS_DESCRIPTION[] =
QT_TRANSLATE_NOOP("ObjectiveCEditor::ClassWizard", "Creates new ObjectiveC class");

// header
const char C_OBJC_HEADER_WIZARD_ID[] = "P.ObjCHeader";
const char C_OBJC_HEADER_EXTENSION[] = ".h";
const char C_OBJC_HEADER_CONTENT[] = ""; // Boiler Plate code for top of file
const char EN_OBJC_HEADER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("ObjectiveCEditor::FileWizard", "ObjectiveC Header file");
const char EN_OBJC_HEADER_DESCRIPTION[] =
QT_TRANSLATE_NOOP("ObjectiveCEditor::FileWizard", "Creates an empty ObjectiveC header file");
/*******************************************************************************
* MIME type
******************************************************************************/
const char OBJC_SOURCE_MIMETYPE[] = "text/x-objcsrc";
const char OBJCPP_SOURCE_MIMETYPE[] = "text/x-objc++src";
const char OBJC_HEADER_MIMETYPE[] = "text/x-objchdr";
const char OBJCPP_HEADER_MIMETYPE[] = "text/x-objc++hdr";
const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr";
const char C_HEADER_MIMETYPE[] = "text/x-chdr";
const char RC_OBJC_MIME_XML[] = ":/objectiveceditor/ObjectiveCEditor.mimetypes.xml";
Expand Down
13 changes: 7 additions & 6 deletions src/plugins/objectiveceditor/objectiveceditorplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#include "objectiveceditorplugin.h"
#include "objectiveceditorconstants.h"
#include "wizard/objectivecfilewizard.h"
#include "wizard/objectivecsourcewizard.h"
#include "wizard/objectivecheaderwizard.h"
#include "wizard/objectivecclasswizard.h"
#include "objectiveceditorwidget.h"
#include "objectiveceditorfactory.h"
Expand Down Expand Up @@ -232,9 +233,8 @@ ObjectiveCEditorPlugin::ObjectiveCEditorPlugin()
: m_factory(0)
{
m_instance = this;
copyIdentifiers(LIST_OF_OBJECTIVE_C_KEYWORDS, sizeof(LIST_OF_OBJECTIVE_C_KEYWORDS), m_keywords);
// copyIdentifiers(LIST_OF_OBJECTIVE_CPP_KEYWORDS, sizeof(LIST_OF_OBJECTIVE_CPP_KEYWORDS), m_keywords);
copyIdentifiers(LIST_OF_OBJECTIVE_C_TYPES, sizeof(LIST_OF_OBJECTIVE_C_TYPES), m_magics);
copyIdentifiers(LIST_OF_OBJECTIVE_C_KEYWORDS, sizeof(LIST_OF_OBJECTIVE_C_KEYWORDS), m_keywords);
copyIdentifiers(LIST_OF_OBJECTIVE_C_TYPES, sizeof(LIST_OF_OBJECTIVE_C_TYPES), m_magics);
// copyIdentifiers(LIST_OF_PYTHON_BUILTINS, sizeof(LIST_OF_PYTHON_BUILTINS), m_builtins);
}

Expand All @@ -260,8 +260,9 @@ bool ObjectiveCEditorPlugin::initialize(const QStringList &arguments, QString *e
if (!icon.isNull())
Core::FileIconProvider::registerIconOverlayForMimeType(icon, OBJC_SOURCE_MIMETYPE);

// Add Python files and classes creation dialogs
addAutoReleasedObject(new FileWizard);
// Add Objective C files and classes creation dialogs
addAutoReleasedObject(new ObjectiveCSourceWizard);
addAutoReleasedObject(new ObjectiveCHeaderWizard);
addAutoReleasedObject(new ClassWizard);
addAutoReleasedObject(new Internal::ObjectiveCHighlighterFactory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ ClassNamePage::ClassNamePage(QWidget *parent)
, m_isValid(false)
{
setTitle(tr("Enter Class Name"));
setSubTitle(tr("The source file name will be derived from the class name"));
setSubTitle(tr("The source and header filename will be derived from the class name"));

m_newClassWidget.reset(new Utils::NewClassWidget);
// Order, set extensions first before suggested name is derived
m_newClassWidget->setBaseClassEditable(false);
m_newClassWidget->setFormInputVisible(false);
m_newClassWidget->setHeaderInputVisible(false);
m_newClassWidget->setNamespacesEnabled(true);
m_newClassWidget->setHeaderInputVisible(true);
m_newClassWidget->setNamespacesEnabled(false);
m_newClassWidget->setBaseClassInputVisible(true);
m_newClassWidget->setNamesDelimiter(QLatin1String("."));
m_newClassWidget->setAllowDirectories(true);
Expand All @@ -52,7 +52,6 @@ ClassNamePage::ClassNamePage(QWidget *parent)
pageLayout->addWidget(m_newClassWidget.data());
QSpacerItem *vSpacer = new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::Expanding);
pageLayout->addItem(vSpacer);

initParameters();
}

Expand Down
147 changes: 3 additions & 144 deletions src/plugins/objectiveceditor/wizard/objectivecclasswizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ QString ClassWizard::sourceSuffix() const

QString ClassWizard::headerSuffix() const
{
return preferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE));
return preferredSuffix(QLatin1String(Constants::OBJC_HEADER_MIMETYPE));
}

Core::GeneratedFiles ClassWizard::generateFiles(const QWizard *w,
Expand Down Expand Up @@ -107,13 +107,6 @@ Core::GeneratedFiles ClassWizard::generateFiles(const QWizard *w,
bool ClassWizard::generateHeaderAndSource(const ClassWizardParameters &params,
QString *header, QString *source)
{
// TODO:
// Quite a bit of this code has been copied from FormClassWizardParameters::generateCpp
// and is duplicated in the library wizard.
// Maybe more of it could be merged into Utils.

const QString indent = QString(4, QLatin1Char(' '));

// Do we have namespaces?
QStringList namespaceList = params.className.split(QLatin1String("::"));
if (namespaceList.empty()) // Paranoia!
Expand All @@ -126,151 +119,17 @@ bool ClassWizard::generateHeaderAndSource(const ClassWizardParameters &params,
CppTools::AbstractEditorSupport::licenseTemplate(params.sourceFile,
params.className);

const QString unqualifiedClassName = namespaceList.takeLast();
const QString guard = Utils::headerGuard(params.headerFile, namespaceList);

// == Header file ==
QTextStream headerStr(header);
headerStr << headerLicense << "#ifndef " << guard
<< "\n#define " << guard << '\n';

QRegExp qtClassExpr(QLatin1String("^Q[A-Z3].+"));
QTC_CHECK(qtClassExpr.isValid());
// Determine parent QObject type for Qt types. Provide base
// class in case the user did not specify one.
QString parentQObjectClass;
bool defineQObjectMacro = false;
switch (params.classType) {
case Utils::NewClassWidget::ClassInheritsQObject:
parentQObjectClass = QLatin1String("QObject");
defineQObjectMacro = true;
break;
case Utils::NewClassWidget::ClassInheritsQWidget:
parentQObjectClass = QLatin1String("QWidget");
defineQObjectMacro = true;
break;
case Utils::NewClassWidget::ClassInheritsQDeclarativeItem:
parentQObjectClass = QLatin1String("QDeclarativeItem");
defineQObjectMacro = true;
break;
case Utils::NewClassWidget::ClassInheritsQQuickItem:
parentQObjectClass = QLatin1String("QQuickItem");
defineQObjectMacro = true;
break;
case Utils::NewClassWidget::NoClassType:
case Utils::NewClassWidget::SharedDataClass:
break;
}
const QString baseClass = params.baseClass.isEmpty()
&& params.classType != Utils::NewClassWidget::NoClassType ?
parentQObjectClass : params.baseClass;
const bool superIsQtClass = qtClassExpr.exactMatch(baseClass);
if (superIsQtClass) {
headerStr << '\n';
Utils::writeIncludeFileDirective(baseClass, true, headerStr);
}
if (params.classType == Utils::NewClassWidget::SharedDataClass) {
headerStr << '\n';
Utils::writeIncludeFileDirective(QLatin1String("QSharedDataPointer"), true, headerStr);
}

const QString namespaceIndent = Utils::writeOpeningNameSpaces(namespaceList, QString(), headerStr);

const QString sharedDataClass = unqualifiedClassName + QLatin1String("Data");

if (params.classType == Utils::NewClassWidget::SharedDataClass)
headerStr << '\n' << "class " << sharedDataClass << ";\n";

// Class declaration
headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName;
if (!baseClass.isEmpty())
headerStr << " : public " << baseClass << "\n";
else
headerStr << "\n";
headerStr << namespaceIndent << "{\n";
if (defineQObjectMacro)
headerStr << namespaceIndent << indent << "Q_OBJECT\n";
headerStr << namespaceIndent << "public:\n"
<< namespaceIndent << indent;
// Constructor
if (parentQObjectClass.isEmpty()) {
headerStr << unqualifiedClassName << "();\n";
} else {
headerStr << "explicit " << unqualifiedClassName << '(' << parentQObjectClass
<< " *parent = 0);\n";
}
// Copy/Assignment for shared data classes.
if (params.classType == Utils::NewClassWidget::SharedDataClass) {
headerStr << namespaceIndent << indent
<< unqualifiedClassName << "(const " << unqualifiedClassName << " &);\n"
<< namespaceIndent << indent
<< unqualifiedClassName << " &operator=(const " << unqualifiedClassName << " &);\n"
<< namespaceIndent << indent
<< '~' << unqualifiedClassName << "();\n";
}
if (defineQObjectMacro)
headerStr << '\n' << namespaceIndent << "signals:\n\n" << namespaceIndent << "public slots:\n\n";
if (params.classType == Utils::NewClassWidget::SharedDataClass) {
headerStr << '\n' << namespaceIndent << "private:\n"
<< namespaceIndent << indent << "QSharedDataPointer<" << sharedDataClass << "> data;\n";
}
headerStr << namespaceIndent << "};\n";

Utils::writeClosingNameSpaces(namespaceList, QString(), headerStr);

headerStr << '\n';
headerStr << "#endif // "<< guard << '\n';
<< "\n#define " << guard << '\n' << '\n' << '\n'
<< "#endif // "<< guard << '\n';

// == Source file ==
QTextStream sourceStr(source);
sourceStr << sourceLicense;
Utils::writeIncludeFileDirective(params.headerFile, false, sourceStr);
if (params.classType == Utils::NewClassWidget::SharedDataClass)
Utils::writeIncludeFileDirective(QLatin1String("QSharedData"), true, sourceStr);

Utils::writeOpeningNameSpaces(namespaceList, QString(), sourceStr);
// Private class:
if (params.classType == Utils::NewClassWidget::SharedDataClass) {
sourceStr << '\n' << namespaceIndent << "class " << sharedDataClass
<< " : public QSharedData {\n"
<< namespaceIndent << "public:\n"
<< namespaceIndent << "};\n";
}

// Constructor
sourceStr << '\n' << namespaceIndent;
if (parentQObjectClass.isEmpty()) {
sourceStr << unqualifiedClassName << "::" << unqualifiedClassName << "()";
if (params.classType == Utils::NewClassWidget::SharedDataClass)
sourceStr << " : data(new " << sharedDataClass << ')';
sourceStr << '\n';
} else {
sourceStr << unqualifiedClassName << "::" << unqualifiedClassName
<< '(' << parentQObjectClass << " *parent) :\n"
<< namespaceIndent << indent << baseClass << "(parent)\n";
}

sourceStr << namespaceIndent << "{\n" << namespaceIndent << "}\n";
if (params.classType == Utils::NewClassWidget::SharedDataClass) {
// Copy
sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(const "
<< unqualifiedClassName << " &rhs) : data(rhs.data)\n"
<< namespaceIndent << "{\n" << namespaceIndent << "}\n\n";
// Assignment
sourceStr << namespaceIndent << unqualifiedClassName << " &"
<< unqualifiedClassName << "::operator=(const " << unqualifiedClassName << " &rhs)\n"
<< namespaceIndent << "{\n"
<< namespaceIndent << indent << "if (this != &rhs)\n"
<< namespaceIndent << indent << indent << "data.operator=(rhs.data);\n"
<< namespaceIndent << indent << "return *this;\n"
<< namespaceIndent << "}\n\n";
// Destructor
sourceStr << namespaceIndent << unqualifiedClassName << "::~"
<< unqualifiedClassName << "()\n"
<< namespaceIndent << "{\n"
<< namespaceIndent << "}\n";
}
Utils::writeClosingNameSpaces(namespaceList, QString(), sourceStr);
return true;
}

Expand Down
Loading

0 comments on commit 21493b4

Please sign in to comment.