Commit bbc4a5f5 authored by Christian Kamm's avatar Christian Kamm
Browse files

C++ indenter: Change to a more descriptive name for 'Padding mode'.

'Align continuation lines' should be easier to understand.

Done-with: Friedemann Kleint
parent 9caecbae
......@@ -158,7 +158,7 @@ void BehaviorSettingsPage::settingsFromUI(TabSettings &tabSettings,
tabSettings.m_doubleIndentBlocks = m_d->m_page.indentBlocksBehavior->currentIndex() >= 2;
tabSettings.m_tabKeyBehavior = (TabSettings::TabKeyBehavior)m_d->m_page.tabKeyBehavior->currentIndex();
tabSettings.m_paddingMode = (TabSettings::PaddingMode)m_d->m_page.paddingMode->currentIndex();
tabSettings.m_continuationAlignBehavior = (TabSettings::ContinuationAlignBehavior)m_d->m_page.continuationAlignBehavior->currentIndex();
storageSettings.m_cleanWhitespace = m_d->m_page.cleanWhitespace->isChecked();
storageSettings.m_inEntireDocument = m_d->m_page.inEntireDocument->isChecked();
......@@ -182,7 +182,7 @@ void BehaviorSettingsPage::settingsToUI()
(tabSettings.m_doubleIndentBlocks ? 2 : 1)
: 0);
m_d->m_page.tabKeyBehavior->setCurrentIndex(tabSettings.m_tabKeyBehavior);
m_d->m_page.paddingMode->setCurrentIndex(tabSettings.m_paddingMode);
m_d->m_page.continuationAlignBehavior->setCurrentIndex(tabSettings.m_continuationAlignBehavior);
const StorageSettings &storageSettings = m_d->m_storageSettings;
m_d->m_page.cleanWhitespace->setChecked(storageSettings.m_cleanWhitespace);
......
......@@ -206,36 +206,54 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="paddingStyleLabel">
<widget class="QLabel" name="continuationAlignLabel">
<property name="text">
<string>Padding style:</string>
<string>Align continuation lines:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="paddingMode">
<widget class="QComboBox" name="continuationAlignBehavior">
<property name="toolTip">
<string>Padding is the part of indentation exceeding logical indentation and is usually used to align consecutive lines of code.
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;
Influences the indentation of continuation lines.
Disable Padding: Do not pad at all. Lines will only be indented to the current logical indentation depth.
&lt;ul&gt;
&lt;li&gt;Not At All: Do not align at all. Lines will only be indented to the current logical indentation depth.
&lt;pre&gt;
(tab)int i = foo(a, b
(tab)c, d);
&lt;/pre&gt;
&lt;/li&gt;
Pad With Spaces: Always use spaces for padding, regardless of the choice between tabs and spaces above.
&lt;li&gt;With Spaces: Always use spaces for alignment, regardless of the other indentation settings.
&lt;pre&gt;
(tab)int i = foo(a, b
(tab) c, d);
&lt;/pre&gt;
&lt;/li&gt;
Pad With Indentation: Padding will be part of the indentation and follow the settings above.</string>
&lt;li&gt;With Regular Indent: Use tabs and/or spaces for alignment, as configured above.
&lt;pre&gt;
(tab)int i = foo(a, b
(tab)(tab)(tab) c, d);
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>Disable Padding</string>
<string>Not At All</string>
</property>
</item>
<item>
<property name="text">
<string>Pad With Spaces</string>
<string>With Spaces</string>
</property>
</item>
<item>
<property name="text">
<string>Pad With Indentation</string>
<string>With Regular Indent</string>
</property>
</item>
</widget>
......
......@@ -59,7 +59,7 @@ TabSettings::TabSettings() :
m_indentBraces(false),
m_doubleIndentBlocks(false),
m_tabKeyBehavior(TabNeverIndents),
m_paddingMode(PadWithSpaces)
m_continuationAlignBehavior(ContinuationAlignWithSpaces)
{
}
......@@ -78,7 +78,7 @@ void TabSettings::toSettings(const QString &category, QSettings *s) const
s->setValue(QLatin1String(indentBracesKey), m_indentBraces);
s->setValue(QLatin1String(doubleIndentBlocksKey), m_doubleIndentBlocks);
s->setValue(QLatin1String(tabKeyBehaviorKey), m_tabKeyBehavior);
s->setValue(QLatin1String(paddingModeKey), m_paddingMode);
s->setValue(QLatin1String(paddingModeKey), m_continuationAlignBehavior);
s->endGroup();
}
......@@ -102,7 +102,7 @@ void TabSettings::fromSettings(const QString &category, const QSettings *s)
= s->value(group + QLatin1String(doubleIndentBlocksKey), m_doubleIndentBlocks).toBool();
m_tabKeyBehavior = (TabKeyBehavior)s->value(group + QLatin1String(tabKeyBehaviorKey), m_tabKeyBehavior).toInt();
m_paddingMode = (PaddingMode)s->value(group + QLatin1String(paddingModeKey), m_paddingMode).toInt();
m_continuationAlignBehavior = (ContinuationAlignBehavior)s->value(group + QLatin1String(paddingModeKey), m_continuationAlignBehavior).toInt();
}
......@@ -323,10 +323,10 @@ void TabSettings::indentLine(QTextBlock block, int newIndent, int padding) const
const QString text = block.text();
const int oldBlockLength = text.size();
if (m_paddingMode == DisablePadding) {
if (m_continuationAlignBehavior == NoContinuationAlign) {
newIndent -= padding;
padding = 0;
} else if (m_paddingMode == PadWithIndent) {
} else if (m_continuationAlignBehavior == ContinuationAlignWithIndent) {
padding = 0;
}
......@@ -400,7 +400,7 @@ bool TabSettings::equals(const TabSettings &ts) const
&& m_indentBraces == ts.m_indentBraces
&& m_doubleIndentBlocks == ts.m_doubleIndentBlocks
&& m_tabKeyBehavior == ts.m_tabKeyBehavior
&& m_paddingMode == ts.m_paddingMode;
&& m_continuationAlignBehavior == ts.m_continuationAlignBehavior;
}
} // namespace TextEditor
......@@ -52,11 +52,11 @@ public:
TabLeadingWhitespaceIndents = 2
};
// This enum must match the indexes of paddingMode widget
enum PaddingMode {
DisablePadding = 0,
PadWithSpaces = 1,
PadWithIndent = 2
// This enum must match the indexes of continuationAlignBehavior widget
enum ContinuationAlignBehavior {
NoContinuationAlign = 0,
ContinuationAlignWithSpaces = 1,
ContinuationAlignWithIndent = 2
};
TabSettings();
......@@ -96,7 +96,7 @@ public:
bool m_indentBraces;
bool m_doubleIndentBlocks;
TabKeyBehavior m_tabKeyBehavior;
PaddingMode m_paddingMode;
ContinuationAlignBehavior m_continuationAlignBehavior;
bool equals(const TabSettings &ts) const;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment