//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void PdmUiFilePathEditor::fileSelectionClicked()
{
    QString defaultPath;
    if ( m_lineEdit->text().isEmpty())
    {
        defaultPath = QDir::homePath();
    }
    else
    {
        defaultPath = m_lineEdit->text();
    }

    if (m_attributes.m_selectDirectory)
    {
        QString directoryPath = QFileDialog::getExistingDirectory(m_lineEdit, 
                                                tr("Get existing directory"),
                                                defaultPath,
                                                QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
        
        if (!directoryPath.isEmpty())
        {
            QString filePathString;
            if (m_attributes.m_appendUiSelectedFolderToText)
            {
                filePathString = m_lineEdit->text();
                if (!filePathString.isEmpty() && !filePathString.endsWith(m_attributes.m_multipleItemSeparator, Qt::CaseInsensitive))
                {
                    filePathString += m_attributes.m_multipleItemSeparator;
                }
                filePathString += directoryPath;
            }
            else
            {
                filePathString = directoryPath;
            }

            m_lineEdit->setText(filePathString);
            slotEditingFinished();
        }
    }
    else
    {
        QString filePath;
        if (m_attributes.m_selectSaveFileName)
        {
            filePath = QFileDialog::getSaveFileName(m_lineEdit, tr("Save File"), defaultPath, m_attributes.m_fileSelectionFilter);
        }
        else
        {
            filePath = QFileDialog::getOpenFileName(m_lineEdit, tr("Choose a file"), defaultPath, m_attributes.m_fileSelectionFilter);
        }

        if (!filePath.isEmpty())
        {
            m_lineEdit->setText(filePath);
            slotEditingFinished();
        }
    }
}
Exemplo n.º 2
0
    // TextPropertyEditor
    TextPropertyEditor::TextPropertyEditor(QWidget *parent,
                                           EmbeddingMode embeddingMode,
                                           TextPropertyValidationMode validationMode) :
        QWidget(parent),
        m_validationMode(ValidationSingleLine),
        m_updateMode(UpdateAsYouType),
        m_lineEdit(new PropertyLineEdit(this)),
        m_textEdited(false)
    {
        switch (embeddingMode) {
        case EmbeddingNone:
            break;
        case EmbeddingTreeView:
            m_lineEdit->setFrame(false);
            break;
        case EmbeddingInPlace:
            m_lineEdit->setFrame(false);
            Q_ASSERT(parent);
            m_lineEdit->setBackgroundRole(parent->backgroundRole());
            break;
        }

        setFocusProxy(m_lineEdit);

        connect(m_lineEdit,SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
        connect(m_lineEdit,SIGNAL(returnPressed()), this, SLOT(slotEditingFinished()));
        connect(m_lineEdit,SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString)));
        connect(m_lineEdit,SIGNAL(textEdited(QString)), this, SLOT(slotTextEdited()));

        setTextPropertyValidationMode(validationMode);
    }
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDateEditor::createEditorWidget(QWidget* parent)
{
    m_dateEdit = new QDateEdit(parent);
    m_dateEdit->setCalendarPopup(true);
    connect(m_dateEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
    return m_dateEdit;
}
Exemplo n.º 4
0
AddTagsLineEdit::AddTagsLineEdit(QWidget* const parent)
    : QLineEdit(parent),
      d(new Private)
{
    setClearButtonEnabled(true);

    d->completer = new TagCompleter(this);
    d->completer->setMaxVisibleItems(15);

    setCompleter(d->completer);

    connect(this, SIGNAL(returnPressed()),
            this, SLOT(slotReturnPressed()));

    connect(this, SIGNAL(editingFinished()),
            this, SLOT(slotEditingFinished()));

    connect(this, SIGNAL(textChanged(QString)),
            this, SLOT(slotTextChanged(QString)));

    connect(this, SIGNAL(textEdited(QString)),
            d->completer, SLOT(slotTextEdited(QString)));

    connect(d->completer, static_cast<void(TagCompleter::*)(const TaggingAction&)>(&TagCompleter::activated),
            [this](const TaggingAction& action){ completerActivated(action); });

    connect(d->completer, static_cast<void(TagCompleter::*)(const TaggingAction&)>(&TagCompleter::highlighted),
            [this](const TaggingAction& action){ completerHighlighted(action); });
}
Exemplo n.º 5
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiLineEditor::createEditorWidget(QWidget * parent)
{
    m_lineEdit = new PdmUiLineEdit(parent);

    connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));

    return m_lineEdit;
}
Exemplo n.º 6
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiDoubleValueEditor::createEditorWidget(QWidget* parent)
{
    QWidget* containerWidget = new QWidget(parent);

    QHBoxLayout* layout = new QHBoxLayout();
    layout->setMargin(0);
    containerWidget->setLayout(layout);

    m_lineEdit = new QLineEdit(containerWidget);
    connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));

    layout->addWidget(m_lineEdit);

    return containerWidget;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QWidget* PdmUiFilePathEditor::createEditorWidget(QWidget * parent)
{
    QWidget* placeholder = new QWidget(parent);

    QHBoxLayout* layout = new QHBoxLayout(placeholder);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);

    m_lineEdit = new QLineEdit(parent);
    m_button = new QToolButton(parent);
    m_button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
    m_button->setText(QLatin1String("..."));

    layout->addWidget(m_lineEdit);
    layout->addWidget(m_button);

    connect(m_button, SIGNAL(clicked()), this, SLOT(fileSelectionClicked()));
    connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));

    return placeholder;
}
Exemplo n.º 8
0
DragValue::DragValue(const QString &label, double defaultValue, int decimals, double min, double max, int id, const QString &suffix, bool showSlider, QWidget* parent) :
    QWidget(parent),
    m_maximum(max),
    m_minimum(min),
    m_decimals(decimals),
    m_default(defaultValue),
    m_id(id),
    m_intEdit(NULL),
    m_doubleEdit(NULL)
{
    if (showSlider) setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    else setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
    setFocusPolicy(Qt::StrongFocus);
    setContextMenuPolicy(Qt::CustomContextMenu);
    setFocusPolicy(Qt::StrongFocus);

    QHBoxLayout *l = new QHBoxLayout;
    l->setSpacing(0);
    l->setContentsMargins(0, 0, 0, 0);
    m_label = new CustomLabel(label, showSlider, m_maximum - m_minimum, this);
    l->addWidget(m_label);
    if (decimals == 0) {
        m_label->setMaximum(max - min);
        m_label->setStep(1);
        m_intEdit = new QSpinBox(this);
        m_intEdit->setObjectName(QStringLiteral("dragBox"));
        m_intEdit->setFocusPolicy(Qt::StrongFocus);
        if (!suffix.isEmpty()) m_intEdit->setSuffix(suffix);
        m_intEdit->setKeyboardTracking(false);
        m_intEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
        m_intEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
        m_intEdit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
        m_intEdit->setRange((int) m_minimum, (int)m_maximum);
        m_intEdit->setValue((int) m_default);
        l->addWidget(m_intEdit);
        connect(m_intEdit, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
        connect(m_intEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
    } else {