Commit cb055c1d authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Simplify editor code a bit



* Introduce a const submitEditorWidget() and use it
* Directly use layout from ui

Change-Id: Ib566bab464d4f1c08a3f2af0edb5e1fa989c3160
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 633c11d1
......@@ -96,6 +96,11 @@ GitSubmitEditorWidget *GitSubmitEditor::submitEditorWidget()
return static_cast<GitSubmitEditorWidget *>(widget());
}
const GitSubmitEditorWidget *GitSubmitEditor::submitEditorWidget() const
{
return static_cast<GitSubmitEditorWidget *>(widget());
}
void GitSubmitEditor::setCommitData(const CommitData &d)
{
GitSubmitEditorWidget *w = submitEditorWidget();
......@@ -174,12 +179,12 @@ void GitSubmitEditor::updateFileModel()
GitSubmitEditorPanelData GitSubmitEditor::panelData() const
{
return const_cast<GitSubmitEditor*>(this)->submitEditorWidget()->panelData();
return submitEditorWidget()->panelData();
}
QByteArray GitSubmitEditor::fileContents() const
{
const QString& text = const_cast<GitSubmitEditor*>(this)->submitEditorWidget()->descriptionText();
const QString &text = submitEditorWidget()->descriptionText();
if (!m_commitEncoding.isEmpty()) {
// Do the encoding convert, When use user-defined encoding
......
......@@ -71,6 +71,7 @@ private slots:
private:
inline GitSubmitEditorWidget *submitEditorWidget();
inline const GitSubmitEditorWidget *submitEditorWidget() const;
VcsBase::SubmitFileModel *m_model;
QString m_commitEncoding;
......
......@@ -568,9 +568,7 @@ void SubmitEditorWidget::addSubmitFieldWidget(SubmitFieldWidget *f)
QHBoxLayout *outerLayout = new QHBoxLayout;
outerLayout->addLayout(d->m_fieldLayout);
outerLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
QBoxLayout *descrLayout = qobject_cast<QBoxLayout*>(d->m_ui.descriptionBox->layout());
Q_ASSERT(descrLayout);
descrLayout->addLayout(outerLayout);
d->m_ui.descriptionLayout->addLayout(outerLayout);
}
d->m_fieldLayout->addWidget(f);
d->m_fieldWidgets.push_back(f);
......
......@@ -29,7 +29,7 @@
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="descriptionLayout">
<item>
<widget class="Utils::CompletingTextEdit" name="description">
<property name="acceptRichText">
......
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