Commit 212f6077 authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Apply naming convention to variables

This change applies the naming convention to function parameters and local variables.

Change-Id: Ifa495c70520923f14ba6791513d3691bfa7694f6
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 06821596
......@@ -66,9 +66,9 @@ ConfigController::~ConfigController()
delete d;
}
void ConfigController::setStereotypeController(StereotypeController *stereotype_controller)
void ConfigController::setStereotypeController(StereotypeController *stereotypeController)
{
d->m_stereotypeController = stereotype_controller;
d->m_stereotypeController = stereotypeController;
}
void ConfigController::readStereotypeDefinitions(const QString &path)
......@@ -79,8 +79,8 @@ void ConfigController::readStereotypeDefinitions(const QString &path)
QDir dir(path);
dir.setNameFilters(QStringList() << QStringLiteral("*.def"));
foreach (const QString &file_name, dir.entryList(QDir::Files)) {
QFile file(QFileInfo(dir, file_name).absoluteFilePath());
foreach (const QString &fileName, dir.entryList(QDir::Files)) {
QFile file(QFileInfo(dir, fileName).absoluteFilePath());
if (file.open(QIODevice::ReadOnly)) {
QString text = QString::fromUtf8(file.readAll());
file.close();
......@@ -99,9 +99,9 @@ void ConfigController::readStereotypeDefinitions(const QString &path)
}
}
void ConfigController::onStereotypeIconParsed(const StereotypeIcon &stereotype_icon)
void ConfigController::onStereotypeIconParsed(const StereotypeIcon &stereotypeIcon)
{
d->m_stereotypeController->addStereotypeIcon(stereotype_icon);
d->m_stereotypeController->addStereotypeIcon(stereotypeIcon);
}
void ConfigController::onToolbarParsed(const Toolbar &toolbar)
......
......@@ -55,7 +55,7 @@ public:
public:
void setStereotypeController(StereotypeController *stereotype_controller);
void setStereotypeController(StereotypeController *stereotypeController);
public:
......@@ -63,7 +63,7 @@ public:
private slots:
void onStereotypeIconParsed(const StereotypeIcon &stereotype_icon);
void onStereotypeIconParsed(const StereotypeIcon &stereotypeIcon);
void onToolbarParsed(const Toolbar &toolbar);
......
......@@ -39,10 +39,10 @@ SourcePos::SourcePos()
{
}
SourcePos::SourcePos(int source_id, int line_number, int column_number)
: m_sourceId(source_id),
m_lineNumber(line_number),
m_columnNumber(column_number)
SourcePos::SourcePos(int sourceId, int lineNumber, int columnNumber)
: m_sourceId(sourceId),
m_lineNumber(lineNumber),
m_columnNumber(columnNumber)
{
}
......
......@@ -41,7 +41,7 @@ public:
SourcePos();
SourcePos(int source_id, int line_number, int column_number = -1);
SourcePos(int sourceId, int lineNumber, int columnNumber = -1);
public:
......
......@@ -50,7 +50,7 @@ class QMT_EXPORT StereotypeDefinitionParserError :
{
public:
StereotypeDefinitionParserError(const QString &error_msg, const SourcePos &source_pos);
StereotypeDefinitionParserError(const QString &errorMsg, const SourcePos &sourcePos);
~StereotypeDefinitionParserError();
......@@ -79,7 +79,7 @@ public:
signals:
void iconParsed(const StereotypeIcon &stereotype_icon);
void iconParsed(const StereotypeIcon &stereotypeIcon);
void toolbarParsed(const Toolbar &toolbar);
......@@ -93,7 +93,7 @@ private:
void parseIcon();
void parseIconProperties(StereotypeIcon *stereotype_icon);
void parseIconProperties(StereotypeIcon *stereotypeIcon);
void parseToolbar();
......@@ -113,7 +113,7 @@ private:
QColor parseColorProperty();
void parseIconCommands(StereotypeIcon *stereotype_icon);
void parseIconCommands(StereotypeIcon *stereotypeIcon);
QList<ShapeValueF> parseIconCommandParameters(const QList<IconCommandParameter> &parameters);
......@@ -133,13 +133,13 @@ private:
Token readNextToken();
qreal expectAbsoluteValue(const ShapeValueF &value, const SourcePos &source_pos);
qreal expectAbsoluteValue(const ShapeValueF &value, const SourcePos &sourcePos);
void expectSemicolonOrEndOfLine();
bool nextIsComma();
void expectOperator(int op, const QString &op_name);
void expectOperator(int op, const QString &opName);
void expectComma();
......
......@@ -55,9 +55,9 @@ void StringTextSource::setText(const QString &text)
m_columnNumber = 1;
}
void StringTextSource::setSourceId(int source_id)
void StringTextSource::setSourceId(int sourceId)
{
m_sourceId = source_id;
m_sourceId = sourceId;
}
SourceChar StringTextSource::readNextChar()
......
......@@ -51,7 +51,7 @@ public:
int getSourceId() const { return m_sourceId; }
void setSourceId(int source_id);
void setSourceId(int sourceId);
// ITextSource interface
public:
......
......@@ -48,7 +48,7 @@ class QMT_EXPORT TextScannerError :
{
public:
TextScannerError(const QString &error_msg, const SourcePos &source_pos);
TextScannerError(const QString &errorMsg, const SourcePos &sourcePos);
~TextScannerError();
......@@ -80,7 +80,7 @@ public:
void setOperators(const QList<QPair<QString, int> > &operators);
void setSource(ITextSource *text_source);
void setSource(ITextSource *textSource);
SourcePos getSourcePos() const;
......@@ -94,19 +94,19 @@ private:
SourceChar readChar();
void unreadChar(const SourceChar &source_char);
void unreadChar(const SourceChar &sourceChar);
void skipWhitespaces();
Token scanString(const SourceChar &delimiter_char);
Token scanString(const SourceChar &delimiterChar);
Token scanNumber(const SourceChar &first_digit);
Token scanNumber(const SourceChar &firstDigit);
Token scanIdentifier(const SourceChar &first_char);
Token scanIdentifier(const SourceChar &firstChar);
Token scanColorIdentifier(const SourceChar &first_char);
Token scanColorIdentifier(const SourceChar &firstChar);
Token scanOperator(const SourceChar &first_char);
Token scanOperator(const SourceChar &firstChar);
private:
......
......@@ -40,9 +40,9 @@ namespace qmt {
struct SourceChar {
SourceChar() { }
SourceChar(QChar chr, const SourcePos &source_pos)
SourceChar(QChar chr, const SourcePos &sourcePos)
: ch(chr),
pos(source_pos)
pos(sourcePos)
{
}
......
......@@ -38,19 +38,19 @@ Token::Token()
{
}
Token::Token(Type type, const QString &text, const SourcePos &source_pos)
Token::Token(Type type, const QString &text, const SourcePos &sourcePos)
: m_type(type),
m_subtype(0),
m_text(text),
m_sourcePos(source_pos)
m_sourcePos(sourcePos)
{
}
Token::Token(Token::Type type, int subtype, const QString &text, const SourcePos &source_pos)
Token::Token(Token::Type type, int subtype, const QString &text, const SourcePos &sourcePos)
: m_type(type),
m_subtype(subtype),
m_text(text),
m_sourcePos(source_pos)
m_sourcePos(sourcePos)
{
}
......@@ -73,9 +73,9 @@ void Token::setText(const QString &text)
m_text = text;
}
void Token::setSourcePos(const SourcePos &source_pos)
void Token::setSourcePos(const SourcePos &sourcePos)
{
m_sourcePos = source_pos;
m_sourcePos = sourcePos;
}
} // namespace qmt
......@@ -56,8 +56,8 @@ public:
public:
Token();
Token(Type type, const QString &text, const SourcePos &source_pos);
Token(Type type, int subtype, const QString &text, const SourcePos &source_pos);
Token(Type type, const QString &text, const SourcePos &sourcePos);
Token(Type type, int subtype, const QString &text, const SourcePos &sourcePos);
~Token();
public:
......@@ -76,7 +76,7 @@ public:
SourcePos getSourcePos() const { return m_sourcePos; }
void setSourcePos(const SourcePos &source_pos);
void setSourcePos(const SourcePos &sourcePos);
private:
Type m_type;
......
......@@ -45,117 +45,117 @@ NameController::~NameController()
}
QString NameController::convertFileNameToElementName(const QString &file_name)
QString NameController::convertFileNameToElementName(const QString &fileName)
{
QFileInfo file_info(file_name);
QString base_name = file_info.baseName().trimmed();
QString element_name;
bool make_uppercase = true;
bool insert_space = false;
for (int i = 0; i < base_name.size(); ++i) {
if (base_name.at(i) == QLatin1Char('_')) {
make_uppercase = true;
insert_space = true;
} else if (base_name.at(i) == QLatin1Char(' ') || base_name.at(i) == QLatin1Char('-')) {
make_uppercase = true;
insert_space = false;
element_name += base_name.at(i);
} else if (make_uppercase) {
if (insert_space) {
element_name += QLatin1Char(' ');
insert_space = false;
QFileInfo fileInfo(fileName);
QString baseName = fileInfo.baseName().trimmed();
QString elementName;
bool makeUppercase = true;
bool insertSpace = false;
for (int i = 0; i < baseName.size(); ++i) {
if (baseName.at(i) == QLatin1Char('_')) {
makeUppercase = true;
insertSpace = true;
} else if (baseName.at(i) == QLatin1Char(' ') || baseName.at(i) == QLatin1Char('-')) {
makeUppercase = true;
insertSpace = false;
elementName += baseName.at(i);
} else if (makeUppercase) {
if (insertSpace) {
elementName += QLatin1Char(' ');
insertSpace = false;
}
element_name += base_name.at(i).toUpper();
make_uppercase = false;
elementName += baseName.at(i).toUpper();
makeUppercase = false;
} else {
if (insert_space) {
element_name += QLatin1Char(' ');
insert_space = false;
if (insertSpace) {
elementName += QLatin1Char(' ');
insertSpace = false;
}
element_name += base_name.at(i);
elementName += baseName.at(i);
}
}
return element_name;
return elementName;
}
QString NameController::convertElementNameToBaseFileName(const QString &element_name)
QString NameController::convertElementNameToBaseFileName(const QString &elementName)
{
QString base_file_name;
bool insert_underscore = false;
for (int i = 0; i < element_name.size(); ++i) {
if (element_name.at(i) == QLatin1Char(' ')) {
insert_underscore = true;
QString baseFileName;
bool insertUnderscore = false;
for (int i = 0; i < elementName.size(); ++i) {
if (elementName.at(i) == QLatin1Char(' ')) {
insertUnderscore = true;
} else {
if (insert_underscore) {
base_file_name += QLatin1Char('_');
insert_underscore = false;
if (insertUnderscore) {
baseFileName += QLatin1Char('_');
insertUnderscore = false;
}
base_file_name += element_name.at(i).toLower();
baseFileName += elementName.at(i).toLower();
}
}
return base_file_name;
return baseFileName;
}
QString NameController::calcRelativePath(const QString &absolute_file_name, const QString &anchor_path)
QString NameController::calcRelativePath(const QString &absoluteFileName, const QString &anchorPath)
{
int second_last_slash_index = -1;
int slash_index = -1;
int secondLastSlashIndex = -1;
int slashIndex = -1;
int i = 0;
while (i < absolute_file_name.size() && i < anchor_path.size() && absolute_file_name.at(i) == anchor_path.at(i)) {
if (absolute_file_name.at(i) == QLatin1Char('/')) {
second_last_slash_index = slash_index;
slash_index = i;
while (i < absoluteFileName.size() && i < anchorPath.size() && absoluteFileName.at(i) == anchorPath.at(i)) {
if (absoluteFileName.at(i) == QLatin1Char('/')) {
secondLastSlashIndex = slashIndex;
slashIndex = i;
}
++i;
}
QString relative_path;
QString relativePath;
if (slash_index < 0) {
relative_path = absolute_file_name;
} else if (i >= absolute_file_name.size()) {
// absolute_file_name is a substring of anchor path.
if (slash_index == i - 1) {
if (second_last_slash_index < 0) {
relative_path = absolute_file_name;
if (slashIndex < 0) {
relativePath = absoluteFileName;
} else if (i >= absoluteFileName.size()) {
// absoluteFileName is a substring of anchor path.
if (slashIndex == i - 1) {
if (secondLastSlashIndex < 0) {
relativePath = absoluteFileName;
} else {
relative_path = absolute_file_name.mid(second_last_slash_index + 1);
relativePath = absoluteFileName.mid(secondLastSlashIndex + 1);
}
} else {
relative_path = absolute_file_name.mid(slash_index + 1);
relativePath = absoluteFileName.mid(slashIndex + 1);
}
} else {
relative_path = absolute_file_name.mid(slash_index + 1);
relativePath = absoluteFileName.mid(slashIndex + 1);
}
return relative_path;
return relativePath;
}
QString NameController::calcElementNameSearchId(const QString &element_name)
QString NameController::calcElementNameSearchId(const QString &elementName)
{
QString search_id;
foreach (const QChar &c, element_name) {
QString searchId;
foreach (const QChar &c, elementName) {
if (c.isLetterOrNumber()) {
search_id += c.toLower();
searchId += c.toLower();
}
}
return search_id;
return searchId;
}
QList<QString> NameController::buildElementsPath(const QString &file_path, bool ignore_last_file_path_part)
QList<QString> NameController::buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart)
{
QList<QString> relative_elements;
QList<QString> relativeElements;
QStringList splitted = file_path.split(QStringLiteral("/"));
QStringList::const_iterator splitted_end = splitted.end();
if (ignore_last_file_path_part || splitted.last().isEmpty()) {
splitted_end = --splitted_end;
QStringList splitted = filePath.split(QStringLiteral("/"));
QStringList::const_iterator splittedEnd = splitted.end();
if (ignoreLastFilePathPart || splitted.last().isEmpty()) {
splittedEnd = --splittedEnd;
}
for (QStringList::const_iterator it = splitted.cbegin(); it != splitted_end; ++it) {
QString package_name = qmt::NameController::convertFileNameToElementName(*it);
relative_elements.append(package_name);
for (QStringList::const_iterator it = splitted.cbegin(); it != splittedEnd; ++it) {
QString packageName = qmt::NameController::convertFileNameToElementName(*it);
relativeElements.append(packageName);
}
return relative_elements;
return relativeElements;
}
......
......@@ -51,15 +51,15 @@ private:
public:
static QString convertFileNameToElementName(const QString &file_name);
static QString convertFileNameToElementName(const QString &fileName);
static QString convertElementNameToBaseFileName(const QString &element_name);
static QString convertElementNameToBaseFileName(const QString &elementName);
static QString calcRelativePath(const QString &absolute_file_name, const QString &anchor_path);
static QString calcRelativePath(const QString &absoluteFileName, const QString &anchorPath);
static QString calcElementNameSearchId(const QString &element_name);
static QString calcElementNameSearchId(const QString &elementName);
static QList<QString> buildElementsPath(const QString &file_path, bool ignore_last_file_path_part);
static QList<QString> buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart);
private:
......
......@@ -55,9 +55,9 @@ void Selection::append(const Index &index)
m_indices.append(index);
}
void Selection::append(const Uid &element_key, const Uid &owner_key)
void Selection::append(const Uid &elementKey, const Uid &ownerKey)
{
append(Index(element_key, owner_key));
append(Index(elementKey, ownerKey));
}
}
......@@ -44,9 +44,9 @@ public:
class Index {
public:
Index(const Uid &element_key, const Uid &owner_key)
: m_elementKey(element_key),
m_ownerKey(owner_key)
Index(const Uid &elementKey, const Uid &ownerKey)
: m_elementKey(elementKey),
m_ownerKey(ownerKey)
{
}
......@@ -83,7 +83,7 @@ public:
void append(const Index &index);
void append(const Uid &element_key, const Uid &owner_key);
void append(const Uid &elementKey, const Uid &ownerKey);
private:
......
......@@ -50,21 +50,21 @@ int UndoCommand::id() const
return 1;
}
void UndoCommand::setDoNotMerge(bool do_not_merge)
void UndoCommand::setDoNotMerge(bool doNotMerge)
{
m_doNotMerge = do_not_merge;
m_doNotMerge = doNotMerge;
}
bool UndoCommand::mergeWith(const QUndoCommand *other)
{
const UndoCommand *other_command = dynamic_cast<const UndoCommand *>(other);
if (!other_command) {
const UndoCommand *otherCommand = dynamic_cast<const UndoCommand *>(other);
if (!otherCommand) {
return false;
}
if (other_command->m_doNotMerge) {
if (otherCommand->m_doNotMerge) {
return false;
}
return mergeWith(other_command);
return mergeWith(otherCommand);
}
bool UndoCommand::mergeWith(const UndoCommand *other)
......
......@@ -51,7 +51,7 @@ public:
int id() const;
void setDoNotMerge(bool do_not_merge);
void setDoNotMerge(bool doNotMerge);
public:
......
......@@ -84,14 +84,14 @@ void DAnnotation::setRect(const QRectF &rect)
m_rect = rect;
}
void DAnnotation::setVisualRole(DAnnotation::VisualRole visual_role)
void DAnnotation::setVisualRole(DAnnotation::VisualRole visualRole)
{
m_visualRole = visual_role;
m_visualRole = visualRole;
}
void DAnnotation::setAutoSize(bool auto_sized)
void DAnnotation::setAutoSize(bool autoSized)
{
m_autoSized = auto_sized;
m_autoSized = autoSized;
}
void DAnnotation::accept(DVisitor *visitor)
......
......@@ -82,11 +82,11 @@ public:
VisualRole getVisualRole() const { return m_visualRole; }
void setVisualRole(VisualRole visual_role);
void setVisualRole(VisualRole visualRole);
bool hasAutoSize() const { return m_autoSized; }
void setAutoSize(bool auto_sized);
void setAutoSize(bool autoSized);
public: