PropertyValueDelegate::PropertyValueDelegate( QObject* parent ):
    QItemDelegate( parent )
{ 
    QItemEditorFactory* factory = new QItemEditorFactory;
    QItemEditorCreatorBase* creator = new QStandardItemEditorCreator< PositiveSpinBox >( );
    factory->registerEditor( QVariant::UInt, creator );
    this->setItemEditorFactory( factory );
}
Beispiel #2
0
ComboBoxDelegate::ComboBoxDelegate(const QStringList &data, Type type, QObject* parent)
  : QItemDelegate(parent)
{
  QItemEditorFactory *factory = new QItemEditorFactory;
  QItemEditorCreatorBase *creator = new ComboBoxEditorCreator(data, type);
  factory->registerEditor(QVariant::String, creator);

  setItemEditorFactory(factory);
}
repo::gui::RepoComboBoxDelegate::RepoComboBoxDelegate(
         const QList<RepoComboBoxEditor::SeparatedEntries> &comboBoxLists)
{
    for (unsigned int i = 0; i < comboBoxLists.size(); ++i)
    {
        QItemEditorFactory *factory = new QItemEditorFactory();
        factory->registerEditor(QVariant::String, new RepoComboBoxEditor(comboBoxLists[i]));
        factories.append(factory);
    }
}
Beispiel #4
0
Window::Window()
{
	QItemEditorFactory *factory = new QItemEditorFactory;

	QItemEditorCreatorBase *colorListCreator  = new QStandardItemEditorCreator<ColorListEditor>();
	factory->registerEditor(QVariant::Color, colorListCreator);
	
	QItemEditorFactory::setDefaultFactory(factory);

	createGUI();
}
Beispiel #5
0
void
TagColorEditor::createGUI()
{
  QItemEditorFactory *colorFactory = new QItemEditorFactory;
  QItemEditorCreatorBase *colorCreator =
    new QStandardItemEditorCreator<ColorEditor>();
  colorFactory->registerEditor(QVariant::Color, colorCreator);
  
  QItemEditorFactory *opFactory = new QItemEditorFactory;
  QItemEditorCreatorBase *opacityCreator =
    new QStandardItemEditorCreator<OpacityEditor>();
  opFactory->registerEditor(QVariant::Double, opacityCreator);


  table = new QTableWidget(254, 2);
  table->setHorizontalHeaderLabels(QStringList() << tr("Color")
				                 << tr("Opacity"));
  table->resize(150, 200);
  
  QItemDelegate *colorDelegate = new QItemDelegate();
  colorDelegate->setItemEditorFactory(colorFactory);
  
  QItemDelegate *opDelegate = new QItemDelegate();
  opDelegate->setItemEditorFactory(opFactory);
  
  table->setItemDelegateForColumn(0, colorDelegate);
  table->setItemDelegateForColumn(1, opDelegate);
  
  table->setEditTriggers(QAbstractItemView::DoubleClicked);
  
  setColors();

  table->setGridStyle(Qt::NoPen);
  for (int i=0; i < table->rowCount(); i++)
    table->setRowHeight(i, 20);

  table->setColumnWidth(0, 100);
  table->setColumnWidth(1, 50);
    
  QVBoxLayout *layout = new QVBoxLayout;
  layout->addWidget(table);
  
  setLayout(layout);
  
  setWindowTitle(tr("Tag Color Editor"));
  
  connect(table, SIGNAL(itemChanged(QTableWidgetItem*)),
	  this, SLOT(itemChanged(QTableWidgetItem*)));

  connect(table, SIGNAL(cellClicked(int, int)),
	  this, SLOT(tagClicked(int, int)));
}
Beispiel #6
0
ViewerDelegate::
ViewerDelegate(
  QMdiArea * mdiArea,
  QObject *parent):
QStyledItemDelegate(parent)
{
  // register ViewerListEditor
  QItemEditorFactory *factory = new QItemEditorFactory;
  QItemEditorCreatorBase *viewerListCreator =
      new ViewerListEditorBase(mdiArea);
  factory->registerEditor(
      (QVariant::Type)QMetaType::QObjectStar, viewerListCreator);
  setItemEditorFactory(factory);
}
Beispiel #7
0
ItemDelegate::ItemDelegate(qf::qmlwidgets::TableView *parent)
	: Super(parent)
{
	QItemEditorFactory *fact = itemEditorFactory();
	if(!fact) {
		fact = m_factory = new QItemEditorFactory();
		setItemEditorFactory(m_factory);
	}
	{
		auto creator = new QStandardItemEditorCreator<TimeEdit>();
		fact->registerEditor(qMetaTypeId<TimeMs>(), creator);
	}
	{
		auto creator = new QStandardItemEditorCreator<si::SiIdEdit>();
		fact->registerEditor(qMetaTypeId<si::SiId>(), creator);
	}
}
SceneGraphPropertyViewImpl::SceneGraphPropertyViewImpl(SceneGraphPropertyView* self)
    : self(self)
{
    tableWidget = new CustomizedTableWidget(self);
    tableWidget->setFrameShape(QFrame::NoFrame);
    tableWidget->setColumnCount(2);
    tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    tableWidget->setSelectionMode(QAbstractItemView::NoSelection);

    tableWidget->horizontalHeader()->hide();
    tableWidget->horizontalHeader()->setStretchLastSection(true);

    tableWidget->verticalHeader()->hide();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    tableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#else
    tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif

    QStyledItemDelegate* delegate = new CustomizedItemDelegate(tableWidget);
    QItemEditorFactory* factory = new QItemEditorFactory;
    
    QItemEditorCreatorBase* selectionListCreator =
        new QStandardItemEditorCreator<SelectionListEditor>();
    factory->registerEditor(QVariant::StringList, selectionListCreator);
    
    delegate->setItemEditorFactory(factory);

    tableWidget->setItemDelegate(delegate);

    QVBoxLayout* layout = new QVBoxLayout();
    layout->addWidget(tableWidget);
    self->setLayout(layout);
    
    self->sigActivated().connect(std::bind(&SceneGraphPropertyViewImpl::onActivated, this, true));
    self->sigDeactivated().connect(std::bind(&SceneGraphPropertyViewImpl::onActivated, this ,false));

    currentObject = 0;

    fontPointSizeDiff = 0;
    MappingPtr config = AppConfig::archive()->openMapping("SceneGraphPropertyView");
    int storedFontPointSizeDiff;
    if(config->read("fontZoom", storedFontPointSizeDiff)){
        zoomFontSize(storedFontPointSizeDiff);
    }
}
Beispiel #9
0
//-----------------------------------------------------------------------------
void ctkMatrixWidgetPrivate::init()
{
  CTK_P(ctkMatrixWidget);
  // Set Read-only
  p->setEditable(false);

  // Set parameters for the spinbox
  this->Minimum = -100;
  this->Maximum = 100;
  this->Decimals = 2;
  this->SingleStep = 0.01;

  // Hide headers
  p->verticalHeader()->hide();
  p->horizontalHeader()->hide();

  // Disable scrollBars
  p->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  p->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

  // Don't expand for no reason
  p->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

  // Disable the frame by default
  p->setFrameStyle(QFrame::NoFrame);

  // Register custom editors
  QItemEditorFactory *editorFactory = new QItemEditorFactory;
  editorFactory->registerEditor(QVariant::Double, new QStandardItemEditorCreator<CustomDoubleSpinBox>);

  QStyledItemDelegate* defaultItemDelegate =
    qobject_cast<QStyledItemDelegate*>(p->itemDelegate());
  Q_ASSERT(defaultItemDelegate);
  defaultItemDelegate->setItemEditorFactory(editorFactory);

  // Define prototype item
  QTableWidgetItem* _item = new QTableWidgetItem();
  _item->setData(Qt::DisplayRole, QVariant(0.0));
  _item->setTextAlignment(Qt::AlignCenter);

  // The table takes ownership of the prototype.
  p->setItemPrototype(_item);

  // Initialize
  p->reset();
}
Beispiel #10
0
void setItemEditor()
{
	static bool registered =false;
	if (registered) return;
	else registered = true;


	QItemEditorFactory *factory = new QItemEditorFactory(*QItemEditorFactory::defaultFactory());

	//QItemEditorCreatorBase *spinCreator = new QStandardItemEditorCreator<QSpinBox>();
	//QItemEditorCreatorBase *comboCreator = new QStandardItemEditorCreator<QComboBox>();
	QItemEditorCreatorBase *colorCreator = new QStandardItemEditorCreator<ColorEditor>();

	factory->registerEditor(QVariant::String, 0);
	factory->registerEditor(QVariant::Color, colorCreator);

	QItemEditorFactory::setDefaultFactory(factory);
}
void setArgumentsItemEditorFactory ()
{
    QItemEditorCreatorBase *booleanComboBoxEditorCreator =
    new QStandardItemEditorCreator<BooleanComboBoxEditorCreator>();
    QItemEditorCreatorBase *uIntEditorCreator =
    new QStandardItemEditorCreator<UIntEditorCreator>();
    QItemEditorCreatorBase *intEditorCreator =
    new QStandardItemEditorCreator<IntEditorCreator>();
    QItemEditorCreatorBase *uLongLongEditorCreator =
    new QStandardItemEditorCreator<ULongLongEditorCreator>();
    QItemEditorCreatorBase *longLongEditorCreator =
    new QStandardItemEditorCreator<LongLongEditorCreator>();
    QItemEditorCreatorBase *pixmapEditorCreator =
    new QStandardItemEditorCreator<PixmapEditorCreator>();
    QItemEditorCreatorBase *floatEditorCreator =
    new QStandardItemEditorCreator<FloatEditorCreator>();
    QItemEditorCreatorBase *doubleEditorCreator =
    new QStandardItemEditorCreator<DoubleEditorCreator>();
    QItemEditorCreatorBase *stringEditorCreator =
    new QStandardItemEditorCreator<StringEditorCreator>();
    QItemEditorCreatorBase *invalidEditorCreator =
    new QStandardItemEditorCreator<InvalidEditorCreator>();

    QItemEditorFactory *factory =
        new QItemEditorFactory();

    QVariant::Type typeFloat = static_cast<QVariant::Type> (qMetaTypeId<float>());

    factory->registerEditor(QVariant::Bool, booleanComboBoxEditorCreator);
    factory->registerEditor(QVariant::UInt, uIntEditorCreator);
    factory->registerEditor(QVariant::Int, intEditorCreator);
    factory->registerEditor(QVariant::ULongLong, uLongLongEditorCreator);
    factory->registerEditor(QVariant::LongLong, longLongEditorCreator);
    factory->registerEditor(QVariant::Pixmap, pixmapEditorCreator);
    factory->registerEditor(typeFloat, floatEditorCreator);
    factory->registerEditor(QVariant::Double, doubleEditorCreator);
    factory->registerEditor(QVariant::String, stringEditorCreator);
    factory->registerEditor(QVariant::Invalid, invalidEditorCreator);

    QItemEditorFactory::setDefaultFactory(factory);
}
void tst_QItemEditorFactory::createCustomEditor()
{
    QPointer<MyEditor> creator = new MyEditor;
    QPointer<MyEditor> creator2 = new MyEditor;

    {
        QItemEditorFactory editorFactory;

        editorFactory.registerEditor(QVariant::Rect, creator);
        editorFactory.registerEditor(QVariant::RectF, creator);

        //creator should not be deleted as a result of calling the next line
        editorFactory.registerEditor(QVariant::Rect, creator2);
        QVERIFY(creator);

        //this should erase creator2
        editorFactory.registerEditor(QVariant::Rect, creator);
        QVERIFY(creator2.isNull());


        QWidget parent;

        QWidget *w = editorFactory.createEditor(QVariant::Rect, &parent);
        QCOMPARE(w->metaObject()->className(), "QDoubleSpinBox");
        QCOMPARE(w->metaObject()->userProperty().type(), QVariant::Double);
    }

    //editorFactory has been deleted, so should be creator
    //because editorFActory has the ownership
    QVERIFY(creator.isNull());
    QVERIFY(creator2.isNull());

    delete creator;
}
static PyObject *meth_QItemEditorFactory_registerEditor(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        int a0;
        QItemEditorCreatorBase* a1;
        QItemEditorFactory *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BiJ:", &sipSelf, sipType_QItemEditorFactory, &sipCpp, &a0, sipType_QItemEditorCreatorBase, &a1))
        {
            sipCpp->registerEditor(a0,a1);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QItemEditorFactory, sipName_registerEditor, doc_QItemEditorFactory_registerEditor);

    return NULL;
}
Beispiel #14
0
//-----------------------------------------------------------------------------
void ctkMatrixWidgetPrivate::init()
{
  Q_Q(ctkMatrixWidget);

  this->Table->setParent(q);
  QHBoxLayout* layout = new QHBoxLayout(q);
  layout->addWidget(this->Table);
  layout->setContentsMargins(0,0,0,0);
  q->setLayout(layout);

  // Set parameters for the spinbox
  // TODO: not sure [-100. 100.] is the right default range
  this->Minimum = -100;
  this->Maximum = 100;
  this->Decimals = 2;
  this->SingleStep = 0.01;

  // Don't select the items
  this->Table->setSelectionMode(QAbstractItemView::NoSelection);

  // Hide headers
  this->Table->verticalHeader()->hide();
  this->Table->horizontalHeader()->hide();

  // Disable scrollBars
  this->Table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  this->Table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

  // Don't expand for no reason
  q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);

  // Disable the frame by default
  this->Table->setFrameStyle(QFrame::NoFrame);

  // Register custom editors
  QItemEditorFactory *editorFactory = new QItemEditorFactory;
  editorFactory->registerEditor(QVariant::Double, new QStandardItemEditorCreator<ctkMatrixDoubleSpinBox>);

  QStyledItemDelegate* defaultItemDelegate =
    qobject_cast<QStyledItemDelegate*>(this->Table->itemDelegate());
  Q_ASSERT(defaultItemDelegate);
  defaultItemDelegate->setItemEditorFactory(editorFactory);

  // Define prototype item
  QTableWidgetItem* _item = new QTableWidgetItem;
  _item->setData(Qt::DisplayRole, QVariant(0.0));
  _item->setTextAlignment(Qt::AlignCenter);

  // The table takes ownership of the prototype.
  this->Table->setItemPrototype(_item);

  QObject::connect(this->Table, SIGNAL(cellChanged(int,int)),
                   q, SIGNAL(matrixChanged()));
  /// \todo Wrap model signals to emit signals when the matrix is changed.
/// Right now you can connect to the signal:
/// matrixWidget->model()->dataChanged(...)

  // Set Read-only
  q->setEditable(true);

  // Initialize
  this->validateItems();

  this->updateGeometries();
}
Beispiel #15
0
QWidget* DelegatingItemEditorFactory::createEditor(int userType, QWidget* parent) const {
    QWidget* editor = QItemEditorFactory::createEditor(userType, parent);
    return (!editor) ? _parentFactory->createEditor(userType, parent) : editor;
}
Beispiel #16
0
/**
 * Construct a settings dialog. The actions in the list should have
 * a "defaultshortcut" property for reset to default to work.
 *
 * @param actions list of customizeable actions (for shortcut editing)
 * @param parent parent widget
 */
SettingsDialog::SettingsDialog(QWidget *parent)
	: QDialog(parent)
{
	_ui = new Ui_SettingsDialog;
	_ui->setupUi(this);

	connect(_ui->pickFfmpeg, &QToolButton::clicked, [this]() {
		QString path = QFileDialog::getOpenFileName(this, tr("Set ffmepg path"), _ui->ffmpegpath->text(),
#ifdef Q_OS_WIN
			tr("Executables (%1)").arg("*.exe") + ";;" +
#endif
			QApplication::tr("All files (*)")
		);
		if(!path.isEmpty())
			_ui->ffmpegpath->setText(path);
	});

	connect(_ui->pickRecordingFolder, &QToolButton::clicked, [this]() {
		QString path = QFileDialog::getExistingDirectory(this, tr("Recording folder"), _ui->recordingFolder->text());
		if(!path.isEmpty())
			_ui->recordingFolder->setText(path);
	});

	connect(_ui->notificationVolume, &QSlider::valueChanged, [this](int val) {
		if(val>0)
			_ui->volumeLabel->setText(QString::number(val) + "%");
		else
			_ui->volumeLabel->setText(tr("off", "notifications sounds"));
	});

	// Get available languages
	_ui->languageBox->addItem(tr("Default"), QString());
	_ui->languageBox->addItem(QStringLiteral("English"), QStringLiteral("en"));

	const QLocale localeC = QLocale::c();
	QStringList locales;
	for(const QString &datapath : DrawpileApp::dataPaths()) {
		QStringList files = QDir(datapath + "/i18n").entryList(QStringList("drawpile_*.qm"), QDir::Files, QDir::Name);
		for(const QString &file : files) {
			QString localename = file.mid(9, file.length() - 3 - 9);
			QLocale locale(localename);
			if(locale != localeC && !locales.contains(localename)) {
				locales << localename;
				_ui->languageBox->addItem(locale.nativeLanguageName(), localename);
			}
		}
	}

	// Editable shortcuts
	_customShortcuts = new CustomShortcutModel(this);
	auto filteredShortcuts = new QSortFilterProxyModel(this);
	filteredShortcuts->setSourceModel(_customShortcuts);
	connect(_ui->shortcutFilter, &QLineEdit::textChanged, filteredShortcuts, &QSortFilterProxyModel::setFilterFixedString);
	filteredShortcuts->setFilterCaseSensitivity(Qt::CaseInsensitive);
	_ui->shortcuts->setModel(filteredShortcuts);
	_ui->shortcuts->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
	_ui->shortcuts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);

	// QKeySequence editor delegate
	QStyledItemDelegate *keyseqdel = new QStyledItemDelegate(this);
	QItemEditorFactory *itemeditorfactory = new QItemEditorFactory;
	itemeditorfactory->registerEditor(QVariant::nameToType("QKeySequence"), new KeySequenceEditFactory);
	keyseqdel->setItemEditorFactory(itemeditorfactory);
	_ui->shortcuts->setItemDelegateForColumn(1, keyseqdel);

	// Deselect item before saving. This causes the editor widget to close
	// and commit the change.
	connect(_ui->buttonBox, &QDialogButtonBox::accepted, [this]() {
		_ui->shortcuts->setCurrentIndex(QModelIndex());
	});

	// Known hosts list
	connect(_ui->knownHostList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(viewCertificate(QListWidgetItem*)));
	connect(_ui->knownHostList, SIGNAL(itemSelectionChanged()), this, SLOT(certificateSelectionChanged()));
	connect(_ui->trustKnownHosts, SIGNAL(clicked()), this, SLOT(markTrustedCertificates()));
	connect(_ui->removeKnownHosts, SIGNAL(clicked()), this, SLOT(removeCertificates()));
	connect(_ui->importTrustedButton, SIGNAL(clicked()), this, SLOT(importTrustedCertificate()));

	QStringList pemfilter; pemfilter << "*.pem";
	QDir knownHostsDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/known-hosts/");

	for(const QString &filename : knownHostsDir.entryList(pemfilter, QDir::Files)) {
		auto *i = new QListWidgetItem(filename.left(filename.length()-4), _ui->knownHostList);
		i->setData(Qt::UserRole, false);
		i->setData(Qt::UserRole+1, knownHostsDir.absoluteFilePath(filename));
	}

	QDir trustedHostsDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/trusted-hosts/");
	QIcon trustedIcon("builtin:trusted.svg");
	for(const QString &filename : trustedHostsDir.entryList(pemfilter, QDir::Files)) {
		auto *i = new QListWidgetItem(trustedIcon, filename.left(filename.length()-4), _ui->knownHostList);
		i->setData(Qt::UserRole, true);
		i->setData(Qt::UserRole+1, trustedHostsDir.absoluteFilePath(filename));
	}

	// Session listing server list
	_listservers = new sessionlisting::ListServerModel(false, this);
	_ui->listserverview->setModel(_listservers);
	_ui->listserverview->setItemDelegate(new sessionlisting::ListServerDelegate(this));

	connect(_ui->addListServer, &QPushButton::clicked, this, &SettingsDialog::addListingServer);
	connect(_ui->removeListServer, &QPushButton::clicked, this, &SettingsDialog::removeListingServer);

	// Load configuration
	restoreSettings();

	// Settings saving
	connect(_ui->buttonBox, SIGNAL(accepted()), this, SLOT(rememberSettings()));
	connect(_ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveCertTrustChanges()));
	connect(_ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(resetSettings()));
}
Beispiel #17
0
QByteArray DelegatingItemEditorFactory::valuePropertyName(int userType) const {
    QByteArray propertyName = QItemEditorFactory::valuePropertyName(userType);
    return propertyName.isNull() ? _parentFactory->valuePropertyName(userType) : propertyName;
}