2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-01-07 14:33:28 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-01-07 14:33:28 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-01-07 14:33:28 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-01-07 14:33:28 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-01-07 14:33:28 +01:00
|
|
|
|
2009-03-23 12:03:20 +01:00
|
|
|
#include "submitfieldwidget.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QCompleter>
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
#include <QToolBar>
|
2009-03-23 12:03:20 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QList>
|
|
|
|
|
#include <QDebug>
|
2009-03-23 12:03:20 +01:00
|
|
|
|
|
|
|
|
enum { debug = 0 };
|
|
|
|
|
enum { spacing = 2 };
|
|
|
|
|
|
|
|
|
|
static void inline setComboBlocked(QComboBox *cb, int index)
|
|
|
|
|
{
|
|
|
|
|
const bool blocked = cb->blockSignals(true);
|
|
|
|
|
cb->setCurrentIndex(index);
|
|
|
|
|
cb->blockSignals(blocked);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-02 17:13:33 +01:00
|
|
|
/*!
|
2013-01-02 22:12:06 +02:00
|
|
|
\class VcsBase::SubmitFieldWidget
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The SubmitFieldWidget class is a widget for editing submit message
|
|
|
|
|
fields like "reviewed-by:",
|
2011-03-02 17:13:33 +01:00
|
|
|
"signed-off-by:".
|
|
|
|
|
|
2013-09-10 15:46:58 +02:00
|
|
|
The widget displays the fields in a vertical row of combo boxes or line edit fields
|
2011-03-02 17:13:33 +01:00
|
|
|
that is modeled after the target address controls of mail clients.
|
2013-09-10 15:46:58 +02:00
|
|
|
When choosing a different field in the combo box, a new row is opened if text
|
|
|
|
|
has been entered for the current field. Optionally, a \gui Browse button and
|
2011-03-02 17:13:33 +01:00
|
|
|
completer can be added.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-01-02 22:12:06 +02:00
|
|
|
namespace VcsBase {
|
2009-03-23 12:03:20 +01:00
|
|
|
|
|
|
|
|
// Field/Row entry
|
|
|
|
|
struct FieldEntry {
|
|
|
|
|
FieldEntry();
|
|
|
|
|
void createGui(const QIcon &removeIcon);
|
|
|
|
|
void deleteGuiLater();
|
|
|
|
|
|
|
|
|
|
QComboBox *combo;
|
|
|
|
|
QHBoxLayout *layout;
|
|
|
|
|
QLineEdit *lineEdit;
|
|
|
|
|
QToolBar *toolBar;
|
|
|
|
|
QToolButton *clearButton;
|
|
|
|
|
QToolButton *browseButton;
|
|
|
|
|
int comboIndex;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FieldEntry::FieldEntry() :
|
|
|
|
|
combo(0),
|
|
|
|
|
layout(0),
|
|
|
|
|
lineEdit(0),
|
|
|
|
|
toolBar(0),
|
|
|
|
|
clearButton(0),
|
|
|
|
|
browseButton(0),
|
|
|
|
|
comboIndex(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FieldEntry::createGui(const QIcon &removeIcon)
|
|
|
|
|
{
|
|
|
|
|
layout = new QHBoxLayout;
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout ->setSpacing(spacing);
|
|
|
|
|
combo = new QComboBox;
|
|
|
|
|
layout->addWidget(combo);
|
|
|
|
|
lineEdit = new QLineEdit;
|
|
|
|
|
layout->addWidget(lineEdit);
|
|
|
|
|
toolBar = new QToolBar;
|
|
|
|
|
toolBar->setProperty("_q_custom_style_disabled", QVariant(true));
|
|
|
|
|
layout->addWidget(toolBar);
|
|
|
|
|
clearButton = new QToolButton;
|
|
|
|
|
clearButton->setIcon(removeIcon);
|
|
|
|
|
toolBar->addWidget(clearButton);
|
|
|
|
|
browseButton = new QToolButton;
|
|
|
|
|
browseButton->setText(QLatin1String("..."));
|
|
|
|
|
toolBar->addWidget(browseButton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FieldEntry::deleteGuiLater()
|
|
|
|
|
{
|
|
|
|
|
clearButton->deleteLater();
|
|
|
|
|
browseButton->deleteLater();
|
|
|
|
|
toolBar->deleteLater();
|
2010-01-29 21:33:57 +01:00
|
|
|
lineEdit->deleteLater();
|
2009-03-23 12:03:20 +01:00
|
|
|
combo->deleteLater();
|
|
|
|
|
layout->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ------- SubmitFieldWidgetPrivate
|
|
|
|
|
struct SubmitFieldWidgetPrivate {
|
|
|
|
|
SubmitFieldWidgetPrivate();
|
|
|
|
|
|
|
|
|
|
int findSender(const QObject *o) const;
|
|
|
|
|
int findField(const QString &f, int excluded = -1) const;
|
|
|
|
|
inline QString fieldText(int) const;
|
|
|
|
|
inline QString fieldValue(int) const;
|
|
|
|
|
inline void focusField(int);
|
|
|
|
|
|
|
|
|
|
const QIcon removeFieldIcon;
|
|
|
|
|
QStringList fields;
|
|
|
|
|
QCompleter *completer;
|
|
|
|
|
bool hasBrowseButton;
|
|
|
|
|
bool allowDuplicateFields;
|
|
|
|
|
|
|
|
|
|
QList <FieldEntry> fieldEntries;
|
|
|
|
|
QVBoxLayout *layout;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SubmitFieldWidgetPrivate::SubmitFieldWidgetPrivate() :
|
2013-01-02 22:12:06 +02:00
|
|
|
removeFieldIcon(QLatin1String(":/vcsbase/images/removesubmitfield.png")),
|
2009-03-23 12:03:20 +01:00
|
|
|
completer(0),
|
|
|
|
|
hasBrowseButton(false),
|
|
|
|
|
allowDuplicateFields(false),
|
|
|
|
|
layout(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SubmitFieldWidgetPrivate::findSender(const QObject *o) const
|
|
|
|
|
{
|
|
|
|
|
const int count = fieldEntries.size();
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
const FieldEntry &fe = fieldEntries.at(i);
|
|
|
|
|
if (fe.combo == o || fe.browseButton == o || fe.clearButton == o || fe.lineEdit == o)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SubmitFieldWidgetPrivate::findField(const QString &ft, int excluded) const
|
|
|
|
|
{
|
|
|
|
|
const int count = fieldEntries.size();
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
if (i != excluded && fieldText(i) == ft)
|
|
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SubmitFieldWidgetPrivate::fieldText(int pos) const
|
|
|
|
|
{
|
|
|
|
|
return fieldEntries.at(pos).combo->currentText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SubmitFieldWidgetPrivate::fieldValue(int pos) const
|
|
|
|
|
{
|
|
|
|
|
return fieldEntries.at(pos).lineEdit->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidgetPrivate::focusField(int pos)
|
|
|
|
|
{
|
|
|
|
|
fieldEntries.at(pos).lineEdit->setFocus(Qt::TabFocusReason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SubmitFieldWidget
|
|
|
|
|
SubmitFieldWidget::SubmitFieldWidget(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
2011-09-07 14:26:11 +02:00
|
|
|
d(new SubmitFieldWidgetPrivate)
|
2009-03-23 12:03:20 +01:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
d->layout = new QVBoxLayout;
|
|
|
|
|
d->layout->setMargin(0);
|
|
|
|
|
d->layout->setSpacing(spacing);
|
|
|
|
|
setLayout(d->layout);
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SubmitFieldWidget::~SubmitFieldWidget()
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
delete d;
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::setFields(const QStringList & f)
|
|
|
|
|
{
|
|
|
|
|
// remove old fields
|
2011-09-07 14:26:11 +02:00
|
|
|
for (int i = d->fieldEntries.size() - 1 ; i >= 0 ; i--)
|
2010-01-29 21:33:57 +01:00
|
|
|
removeField(i);
|
2009-03-23 12:03:20 +01:00
|
|
|
|
2011-09-07 14:26:11 +02:00
|
|
|
d->fields = f;
|
2009-03-23 12:03:20 +01:00
|
|
|
if (!f.empty())
|
|
|
|
|
createField(f.front());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList SubmitFieldWidget::fields() const
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->fields;
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SubmitFieldWidget::hasBrowseButton() const
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->hasBrowseButton;
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-07 14:26:11 +02:00
|
|
|
void SubmitFieldWidget::setHasBrowseButton(bool on)
|
2009-03-23 12:03:20 +01:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
if (d->hasBrowseButton == on)
|
2009-03-23 12:03:20 +01:00
|
|
|
return;
|
2011-09-07 14:26:11 +02:00
|
|
|
d->hasBrowseButton = on;
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (const FieldEntry &fe, d->fieldEntries)
|
2011-09-07 14:26:11 +02:00
|
|
|
fe.browseButton->setVisible(on);
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SubmitFieldWidget::allowDuplicateFields() const
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->allowDuplicateFields;
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::setAllowDuplicateFields(bool v)
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
d->allowDuplicateFields = v;
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QCompleter *SubmitFieldWidget::completer() const
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->completer;
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::setCompleter(QCompleter *c)
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
if (c == d->completer)
|
2009-03-23 12:03:20 +01:00
|
|
|
return;
|
2011-09-07 14:26:11 +02:00
|
|
|
d->completer = c;
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (const FieldEntry &fe, d->fieldEntries)
|
2009-03-23 12:03:20 +01:00
|
|
|
fe.lineEdit->setCompleter(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SubmitFieldWidget::fieldValue(int pos) const
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->fieldValue(pos);
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::setFieldValue(int pos, const QString &value)
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
d->fieldEntries.at(pos).lineEdit->setText(value);
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString SubmitFieldWidget::fieldValues() const
|
|
|
|
|
{
|
|
|
|
|
const QChar blank = QLatin1Char(' ');
|
|
|
|
|
const QChar newLine = QLatin1Char('\n');
|
|
|
|
|
// Format as "RevBy: value\nSigned-Off: value\n"
|
|
|
|
|
QString rc;
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (const FieldEntry &fe, d->fieldEntries) {
|
2009-03-23 12:03:20 +01:00
|
|
|
const QString value = fe.lineEdit->text().trimmed();
|
|
|
|
|
if (!value.isEmpty()) {
|
|
|
|
|
rc += fe.combo->currentText();
|
|
|
|
|
rc += blank;
|
|
|
|
|
rc += value;
|
|
|
|
|
rc += newLine;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::createField(const QString &f)
|
|
|
|
|
{
|
|
|
|
|
FieldEntry fe;
|
2011-09-07 14:26:11 +02:00
|
|
|
fe.createGui(d->removeFieldIcon);
|
|
|
|
|
fe.combo->addItems(d->fields);
|
2009-03-23 12:03:20 +01:00
|
|
|
if (!f.isEmpty()) {
|
|
|
|
|
const int index = fe.combo->findText(f);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
setComboBlocked(fe.combo, index);
|
|
|
|
|
fe.comboIndex = index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(fe.browseButton, SIGNAL(clicked()), this, SLOT(slotBrowseButtonClicked()));
|
2011-09-07 14:26:11 +02:00
|
|
|
if (!d->hasBrowseButton)
|
2009-03-23 12:03:20 +01:00
|
|
|
fe.browseButton->setVisible(false);
|
|
|
|
|
|
2011-09-07 14:26:11 +02:00
|
|
|
if (d->completer)
|
|
|
|
|
fe.lineEdit->setCompleter(d->completer);
|
2009-03-23 12:03:20 +01:00
|
|
|
|
|
|
|
|
connect(fe.combo, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(slotComboIndexChanged(int)));
|
|
|
|
|
connect(fe.clearButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(slotRemove()));
|
2011-09-07 14:26:11 +02:00
|
|
|
d->layout->addLayout(fe.layout);
|
|
|
|
|
d->fieldEntries.push_back(fe);
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::slotRemove()
|
|
|
|
|
{
|
|
|
|
|
// Never remove first entry
|
2011-09-07 14:26:11 +02:00
|
|
|
const int index = d->findSender(sender());
|
2009-03-23 12:03:20 +01:00
|
|
|
switch (index) {
|
|
|
|
|
case -1:
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
2011-09-07 14:26:11 +02:00
|
|
|
d->fieldEntries.front().lineEdit->clear();
|
2009-03-23 12:03:20 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
removeField(index);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::removeField(int index)
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
FieldEntry fe = d->fieldEntries.takeAt(index);
|
|
|
|
|
QLayoutItem * item = d->layout->takeAt(index);
|
2009-03-23 12:03:20 +01:00
|
|
|
fe.deleteGuiLater();
|
|
|
|
|
delete item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::slotComboIndexChanged(int comboIndex)
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
const int pos = d->findSender(sender());
|
2009-03-23 12:03:20 +01:00
|
|
|
if (debug)
|
|
|
|
|
qDebug() << '>' << Q_FUNC_INFO << pos;
|
|
|
|
|
if (pos == -1)
|
|
|
|
|
return;
|
|
|
|
|
// Accept new index or reset combo to previous value?
|
2011-09-07 14:26:11 +02:00
|
|
|
int &previousIndex = d->fieldEntries[pos].comboIndex;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (comboIndexChange(pos, comboIndex))
|
2009-03-23 12:03:20 +01:00
|
|
|
previousIndex = comboIndex;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2011-09-07 14:26:11 +02:00
|
|
|
setComboBlocked(d->fieldEntries.at(pos).combo, previousIndex);
|
2009-03-23 12:03:20 +01:00
|
|
|
if (debug)
|
|
|
|
|
qDebug() << '<' << Q_FUNC_INFO << pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle change of a combo. Return "false" if the combo
|
|
|
|
|
// is to be reset (refuse new field).
|
|
|
|
|
bool SubmitFieldWidget::comboIndexChange(int pos, int index)
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
const QString newField = d->fieldEntries.at(pos).combo->itemText(index);
|
2009-03-23 12:03:20 +01:00
|
|
|
// If the field is visible elsewhere: focus the existing one and refuse
|
2011-09-07 14:26:11 +02:00
|
|
|
if (!d->allowDuplicateFields) {
|
|
|
|
|
const int existingFieldIndex = d->findField(newField, pos);
|
2009-03-23 12:03:20 +01:00
|
|
|
if (existingFieldIndex != -1) {
|
2011-09-07 14:26:11 +02:00
|
|
|
d->focusField(existingFieldIndex);
|
2009-03-23 12:03:20 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Empty value: just change the field
|
2011-09-07 14:26:11 +02:00
|
|
|
if (d->fieldValue(pos).isEmpty())
|
2009-03-23 12:03:20 +01:00
|
|
|
return true;
|
|
|
|
|
// Non-empty: Create a new field and reset the triggering combo
|
|
|
|
|
createField(newField);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubmitFieldWidget::slotBrowseButtonClicked()
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
const int pos = d->findSender(sender());
|
|
|
|
|
emit browseButtonClicked(pos, d->fieldText(pos));
|
2009-03-23 12:03:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|