Example #1
0
DofDialog::DofDialog(Graph* graph, Shape* shape, QWidget *parent) :
  QDialog(parent),
  m_graph(graph),
  m_shape(shape)
{
  m_ui.setupUi(this);

  setAttribute(Qt::WA_DeleteOnClose);
  connect(shape, SIGNAL(destroyed()), this, SLOT(close()));
  connect(this, SIGNAL(dofActivated(int)), shape, SLOT(setModeEditDof(int)));

  m_comboBoxes.clear();

  for (int i = 0; i < m_shape->dofCount(); ++i)
  {
    QComboBox* comboBox = new QComboBox(this);
    comboBox->addItem("None");

    DOF* dof = m_shape->dof(i);
    Attribute* currentAttribute = (dof == 0 ? 0 : dof->attribute());

    for (size_t j = 0; j < m_graph->getSizeAttributes(); ++j)
    {
      Attribute* attribute = m_graph->getAttribute(j);
      comboBox->addItem(attribute->name());
      if (currentAttribute == attribute)
      {
        comboBox->setCurrentIndex(comboBox->count()-1);
      }
    }

    m_ui.formLayout->addRow(m_shape->dofLabel(i), comboBox);

    m_comboBoxes.insert(i, comboBox);
    connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(attributeSelected(int)));
    comboBox->setFocusPolicy(Qt::StrongFocus);
    comboBox->installEventFilter(this);
  }
  m_ui.colorLabel->setText(m_shape->colorDOF()->label());
  m_ui.opacityLabel->setText(m_shape->opacityDOF()->label());

  m_colorChooser = new ColorChooser(m_ui.colorChooser, m_shape->colorDOF(), &m_shape->colorYValues(), ColorChooser::HueColor);
  m_ui.colorChooser->layout()->addWidget(m_colorChooser);
  connect(m_colorChooser, SIGNAL(activated()), this, SLOT(colorActivated()));

  m_opacityChooser = new ColorChooser(m_ui.opacityChooser, m_shape->opacityDOF(), &m_shape->opacityYValues(), ColorChooser::OpacityColor);
  m_ui.opacityChooser->layout()->addWidget(m_opacityChooser);
  connect(m_opacityChooser , SIGNAL(activated()), this, SLOT(opacityActivated()));
}
Example #2
0
QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
{
    if (index.column() != ScanFoldersModel::DOWNLOAD) return 0;

    QComboBox* editor = new QComboBox(parent);

    editor->setFocusPolicy(Qt::StrongFocus);
    editor->addItem(tr("Watch Folder"));
    editor->addItem(tr("Default Folder"));
    editor->addItem(tr("Browse..."));
    if (index.data(Qt::UserRole).toInt() == ScanFoldersModel::CUSTOM_LOCATION) {
        editor->insertSeparator(3);
        editor->addItem(index.data().toString());
    }

    connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(comboboxIndexChanged(int)));
    return editor;
}
Example #3
0
QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
{
    if (index.column() != PRIORITY) return 0;

    if (m_properties) {
        BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
        if (!torrent || !torrent->hasMetadata() || torrent->isSeed())
            return 0;
    }

    if (index.data().toInt() <= 0) {
        // IGNORED or MIXED
        return 0;
    }

    QComboBox* editor = new QComboBox(parent);
    editor->setFocusPolicy(Qt::StrongFocus);
    editor->addItem(tr("Normal", "Normal (priority)"));
    editor->addItem(tr("High", "High (priority)"));
    editor->addItem(tr("Maximum", "Maximum (priority)"));
    return editor;
}